about summary refs log tree commit diff
path: root/src/rt/rust_dom.cpp
diff options
context:
space:
mode:
authorRoy Frostig <rfrostig@mozilla.com>2010-07-25 21:45:09 -0700
committerRoy Frostig <rfrostig@mozilla.com>2010-07-25 21:45:09 -0700
commit5b6e714d05a0c96ade618256a67a9cb7f337f196 (patch)
tree45406973ea3c0ffb1a9e070588f4ca5fc8c7744c /src/rt/rust_dom.cpp
parent7ef9e82f51de73e89759910fd1b45ce5ccc363b3 (diff)
downloadrust-5b6e714d05a0c96ade618256a67a9cb7f337f196.tar.gz
rust-5b6e714d05a0c96ade618256a67a9cb7f337f196.zip
Expose an RNG (the one used by our runtime) to Rust via std.
Diffstat (limited to 'src/rt/rust_dom.cpp')
-rw-r--r--src/rt/rust_dom.cpp27
1 files changed, 2 insertions, 25 deletions
diff --git a/src/rt/rust_dom.cpp b/src/rt/rust_dom.cpp
index ac1e7d0cc42..205084ff263 100644
--- a/src/rt/rust_dom.cpp
+++ b/src/rt/rust_dom.cpp
@@ -36,35 +36,12 @@ rust_dom::rust_dom(rust_srv *srv, rust_crate const *root_crate) :
     rval(0)
 {
     logptr("new dom", (uintptr_t)this);
-    memset(&rctx, 0, sizeof(rctx));
-
-#ifdef __WIN32__
-    {
-        HCRYPTPROV hProv;
-        win32_require
-            (_T("CryptAcquireContext"),
-             CryptAcquireContext(&hProv, NULL, NULL, PROV_RSA_FULL,
-                                 CRYPT_VERIFYCONTEXT|CRYPT_SILENT));
-        win32_require
-            (_T("CryptGenRandom"),
-             CryptGenRandom(hProv, sizeof(rctx.randrsl),
-                            (BYTE*)(&rctx.randrsl)));
-        win32_require
-            (_T("CryptReleaseContext"),
-             CryptReleaseContext(hProv, 0));
-    }
-#else
-    int fd = open("/dev/urandom", O_RDONLY);
-    I(this, fd > 0);
-    I(this, read(fd, (void*) &rctx.randrsl, sizeof(rctx.randrsl))
-      == sizeof(rctx.randrsl));
-    I(this, close(fd) == 0);
+    isaac_init(this, &rctx);
+#ifndef __WIN32__
     pthread_attr_init(&attr);
     pthread_attr_setstacksize(&attr, 1024 * 1024);
     pthread_attr_setdetachstate(&attr, true);
 #endif
-    randinit(&rctx, 1);
-
     root_task = new (this) rust_task(this, NULL);
 }