Added the RUST_SEED env variable to seed the Rust task scheduler -- helpful when debugging task race conditions within a single thread domain.
This commit is contained in:
parent
768adb3ddd
commit
c5744c8aef
@ -140,11 +140,20 @@ isaac_init(rust_dom *dom, randctx *rctx)
|
|||||||
CryptReleaseContext(hProv, 0));
|
CryptReleaseContext(hProv, 0));
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
int fd = open("/dev/urandom", O_RDONLY);
|
char *rust_seed = getenv("RUST_SEED");
|
||||||
I(dom, fd > 0);
|
if (rust_seed != NULL) {
|
||||||
I(dom, read(fd, (void*) &rctx->randrsl, sizeof(rctx->randrsl))
|
ub4 seed = (ub4) atoi(rust_seed);
|
||||||
== sizeof(rctx->randrsl));
|
for (size_t i = 0; i < RANDSIZ; i ++) {
|
||||||
I(dom, close(fd) == 0);
|
memcpy(&rctx->randrsl[i], &seed, sizeof(ub4));
|
||||||
|
seed = (seed + 0x7ed55d16) + (seed << 12);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
int fd = open("/dev/urandom", O_RDONLY);
|
||||||
|
I(dom, fd > 0);
|
||||||
|
I(dom, read(fd, (void*) &rctx->randrsl, sizeof(rctx->randrsl))
|
||||||
|
== sizeof(rctx->randrsl));
|
||||||
|
I(dom, close(fd) == 0);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
randinit(rctx, 1);
|
randinit(rctx, 1);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user