about summary refs log tree commit diff
path: root/src/rt/rust_builtin.cpp
diff options
context:
space:
mode:
authorChris Peterson <cpeterson@mozilla.com>2013-02-14 00:48:40 -0800
committerChris Peterson <cpeterson@mozilla.com>2013-02-14 22:31:08 -0800
commit665e900edeb611a7bfc9b0b911489cb802740945 (patch)
tree9e2361cdcbd298e2f608280cd278df73c6b38637 /src/rt/rust_builtin.cpp
parentf4320b6195d2704cf5cb5cb7d23f2b6077a0b34c (diff)
downloadrust-665e900edeb611a7bfc9b0b911489cb802740945.tar.gz
rust-665e900edeb611a7bfc9b0b911489cb802740945.zip
encapsulate isaac RNG in rust_rng struct
Diffstat (limited to 'src/rt/rust_builtin.cpp')
-rw-r--r--src/rt/rust_builtin.cpp28
1 files changed, 14 insertions, 14 deletions
diff --git a/src/rt/rust_builtin.cpp b/src/rt/rust_builtin.cpp
index 63e24f37f24..a63348a2924 100644
--- a/src/rt/rust_builtin.cpp
+++ b/src/rt/rust_builtin.cpp
@@ -135,7 +135,7 @@ rand_seed() {
     rust_vec *v = (rust_vec *) task->kernel->malloc(vec_size<uint8_t>(size),
                                             "rand_seed");
     v->fill = v->alloc = size;
-    isaac_seed(task->kernel, (uint8_t*) &v->data, size);
+    rng_gen_seed(task->kernel, (uint8_t*) &v->data, size);
     return v;
 }
 
@@ -143,27 +143,27 @@ extern "C" CDECL void *
 rand_new() {
     rust_task *task = rust_get_current_task();
     rust_sched_loop *thread = task->sched_loop;
-    randctx *rctx = (randctx *) task->malloc(sizeof(randctx), "rand_new");
-    if (!rctx) {
+    rust_rng *rng = (rust_rng *) task->malloc(sizeof(rust_rng), "rand_new");
+    if (!rng) {
         task->fail();
         return NULL;
     }
-    isaac_init(thread->kernel, rctx, NULL);
-    return rctx;
+    rng_init(thread->kernel, rng, NULL);
+    return rng;
 }
 
 extern "C" CDECL void *
 rand_new_seeded(rust_vec_box* seed) {
     rust_task *task = rust_get_current_task();
     rust_sched_loop *thread = task->sched_loop;
-    randctx *rctx = (randctx *) task->malloc(sizeof(randctx),
-                                             "rand_new_seeded");
-    if (!rctx) {
+    rust_rng *rng = (rust_rng *) task->malloc(sizeof(rust_rng),
+                                              "rand_new_seeded");
+    if (!rng) {
         task->fail();
         return NULL;
     }
-    isaac_init(thread->kernel, rctx, seed);
-    return rctx;
+    rng_init(thread->kernel, rng, seed);
+    return rng;
 }
 
 extern "C" CDECL void *
@@ -172,14 +172,14 @@ rand_new_seeded2(rust_vec_box** seed) {
 }
 
 extern "C" CDECL uint32_t
-rand_next(randctx *rctx) {
-    return isaac_rand(rctx);
+rand_next(rust_rng *rng) {
+    return rng_gen_u32(rng);
 }
 
 extern "C" CDECL void
-rand_free(randctx *rctx) {
+rand_free(rust_rng *rng) {
     rust_task *task = rust_get_current_task();
-    task->free(rctx);
+    task->free(rng);
 }