summaryrefslogtreecommitdiffhomepage
path: root/mrbgems/mruby-random/src/mt19937ar.c
diff options
context:
space:
mode:
authorchasonr <[email protected]>2014-02-25 00:06:31 -0500
committerchasonr <[email protected]>2014-02-25 00:06:31 -0500
commit7c9ff7c8ff118a1d3cdd1cae5ea9b4bbfac8cefb (patch)
tree62d029f6fced07e4a1b1d7a820ac5bf76fbcb70d /mrbgems/mruby-random/src/mt19937ar.c
parentebd976be842c0c16be855e7f9d7cea71a95311f0 (diff)
downloadmruby-7c9ff7c8ff118a1d3cdd1cae5ea9b4bbfac8cefb.tar.gz
mruby-7c9ff7c8ff118a1d3cdd1cae5ea9b4bbfac8cefb.zip
Implement default Random instance.
Previously, the default random number generator was implemented using static storage. This storage is common to all instances of mruby in a process, and use of the default random number generator in one instance will perturb the default random number generator in other instances. It is also not thread safe. With this change, the default random number generator is defined as Random::DEFAULT, as it is in CRuby.
Diffstat (limited to 'mrbgems/mruby-random/src/mt19937ar.c')
-rw-r--r--mrbgems/mruby-random/src/mt19937ar.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/mrbgems/mruby-random/src/mt19937ar.c b/mrbgems/mruby-random/src/mt19937ar.c
index 2c22b23ad..b237af56d 100644
--- a/mrbgems/mruby-random/src/mt19937ar.c
+++ b/mrbgems/mruby-random/src/mt19937ar.c
@@ -14,8 +14,10 @@
#define UPPER_MASK 0x80000000UL /* most significant w-r bits */
#define LOWER_MASK 0x7fffffffUL /* least significant r bits */
+#if 0 /* dead_code */
static unsigned long mt[N]; /* the array for the state vector */
static int mti=N+1; /* mti==N+1 means mt[N] is not initialized */
+#endif /* dead_code */
void mrb_random_init_genrand(mt_state *t, unsigned long s)
{
@@ -74,6 +76,7 @@ double mrb_random_genrand_real1(mt_state *t)
/* divided by 2^32-1 */
}
+#if 0 /* dead_code */
/* initializes mt[N] with a seed */
void init_genrand(unsigned long s)
{
@@ -191,3 +194,4 @@ double genrand_res53(void)
return(a*67108864.0+b)*(1.0/9007199254740992.0);
}
/* These real versions are due to Isaku Wada, 2002/01/09 added */
+#endif /* dead_code */