Skip to content

Commit 4d4e767

Browse files
committed
---
yaml --- r: 4813 b: refs/heads/master c: ddc2076 h: refs/heads/master i: 4811: 947af0e v: v3
1 parent d677897 commit 4d4e767

File tree

2 files changed

+11
-12
lines changed

2 files changed

+11
-12
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
refs/heads/master: 0a00fab2492245bd637269a1a65ab6975ee17da2
2+
refs/heads/master: ddc2076902c7286c3766c406e17d63a1eac90098

trunk/src/rt/rust_util.h

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,15 @@ isaac_init(sched_or_kernel *sched, randctx *rctx)
130130
{
131131
memset(rctx, 0, sizeof(randctx));
132132

133+
char *rust_seed = sched->env->rust_seed;
134+
if (rust_seed != NULL) {
135+
ub4 seed = (ub4) atoi(rust_seed);
136+
for (size_t i = 0; i < RANDSIZ; i ++) {
137+
memcpy(&rctx->randrsl[i], &seed, sizeof(ub4));
138+
seed = (seed + 0x7ed55d16) + (seed << 12);
139+
}
140+
} else {
133141
#ifdef __WIN32__
134-
{
135142
HCRYPTPROV hProv;
136143
sched->win32_require
137144
(_T("CryptAcquireContext"),
@@ -144,24 +151,16 @@ isaac_init(sched_or_kernel *sched, randctx *rctx)
144151
sched->win32_require
145152
(_T("CryptReleaseContext"),
146153
CryptReleaseContext(hProv, 0));
147-
}
148154
#else
149-
char *rust_seed = sched->env->rust_seed;
150-
if (rust_seed != NULL) {
151-
ub4 seed = (ub4) atoi(rust_seed);
152-
for (size_t i = 0; i < RANDSIZ; i ++) {
153-
memcpy(&rctx->randrsl[i], &seed, sizeof(ub4));
154-
seed = (seed + 0x7ed55d16) + (seed << 12);
155-
}
156-
} else {
157155
int fd = open("/dev/urandom", O_RDONLY);
158156
I(sched, fd > 0);
159157
I(sched,
160158
read(fd, (void*) &rctx->randrsl, sizeof(rctx->randrsl))
161159
== sizeof(rctx->randrsl));
162160
I(sched, close(fd) == 0);
163-
}
164161
#endif
162+
}
163+
165164
randinit(rctx, 1);
166165
}
167166

0 commit comments

Comments
 (0)