diff --git a/src/rt/rust_builtin.cpp b/src/rt/rust_builtin.cpp index 1fafbc588ae..c5725f0e392 100644 --- a/src/rt/rust_builtin.cpp +++ b/src/rt/rust_builtin.cpp @@ -139,7 +139,7 @@ rand_new() { task->fail(); return NULL; } - isaac_init(thread, rctx); + isaac_init(thread->kernel, rctx); return rctx; } diff --git a/src/rt/rust_scheduler.cpp b/src/rt/rust_scheduler.cpp index 937960575cd..3e306cc418d 100644 --- a/src/rt/rust_scheduler.cpp +++ b/src/rt/rust_scheduler.cpp @@ -9,7 +9,7 @@ rust_scheduler::rust_scheduler(rust_kernel *kernel, env(srv->env), num_threads(num_threads) { - isaac_init(this, &rctx); + isaac_init(kernel, &rctx); create_task_threads(); } diff --git a/src/rt/rust_task_thread.cpp b/src/rt/rust_task_thread.cpp index d31575510e9..a3bf729ad2f 100644 --- a/src/rt/rust_task_thread.cpp +++ b/src/rt/rust_task_thread.cpp @@ -37,7 +37,7 @@ rust_task_thread::rust_task_thread(rust_scheduler *sched, should_exit(false) { LOGPTR(this, "new dom", (uintptr_t)this); - isaac_init(this, &rctx); + isaac_init(kernel, &rctx); #ifndef __WIN32__ pthread_attr_init(&attr); pthread_attr_setstacksize(&attr, 1024 * 1024); diff --git a/src/rt/rust_task_thread.h b/src/rt/rust_task_thread.h index 8a3736098fe..e8fb70fee93 100644 --- a/src/rt/rust_task_thread.h +++ b/src/rt/rust_task_thread.h @@ -117,12 +117,6 @@ struct rust_task_thread : public kernel_owned, virtual void run(); -#ifdef __WIN32__ - inline void win32_require(LPCTSTR fn, BOOL ok) { - kernel->win32_require(fn, ok); - } -#endif - void init_tls(); void place_task_in_tls(rust_task *task); diff --git a/src/rt/rust_util.h b/src/rt/rust_util.h index 87b3da930d5..23c67422c39 100644 --- a/src/rt/rust_util.h +++ b/src/rt/rust_util.h @@ -124,13 +124,12 @@ align_to(T size, size_t alignment) { // Initialization helper for ISAAC RNG -template -static inline void -isaac_init(thread_or_kernel *thread, randctx *rctx) +inline void +isaac_init(rust_kernel *kernel, randctx *rctx) { memset(rctx, 0, sizeof(randctx)); - char *rust_seed = thread->env->rust_seed; + char *rust_seed = kernel->env->rust_seed; if (rust_seed != NULL) { ub4 seed = (ub4) atoi(rust_seed); for (size_t i = 0; i < RANDSIZ; i ++) { @@ -140,24 +139,24 @@ isaac_init(thread_or_kernel *thread, randctx *rctx) } else { #ifdef __WIN32__ HCRYPTPROV hProv; - thread->win32_require + kernel->win32_require (_T("CryptAcquireContext"), CryptAcquireContext(&hProv, NULL, NULL, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT|CRYPT_SILENT)); - thread->win32_require + kernel->win32_require (_T("CryptGenRandom"), CryptGenRandom(hProv, sizeof(rctx->randrsl), (BYTE*)(&rctx->randrsl))); - thread->win32_require + kernel->win32_require (_T("CryptReleaseContext"), CryptReleaseContext(hProv, 0)); #else int fd = open("/dev/urandom", O_RDONLY); - I(thread, fd > 0); - I(thread, + I(kernel, fd > 0); + I(kernel, read(fd, (void*) &rctx->randrsl, sizeof(rctx->randrsl)) == sizeof(rctx->randrsl)); - I(thread, close(fd) == 0); + I(kernel, close(fd) == 0); #endif }