summaryrefslogtreecommitdiff
path: root/random.c
diff options
context:
space:
mode:
authorkosaki <kosaki@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-11-30 20:31:11 (GMT)
committerkosaki <kosaki@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-11-30 20:31:11 (GMT)
commit052535be3e082d9c2d6b7650ff9430479036bab5 (patch)
treee2beb81e99b68448aad8d621f25c39e7a90a6428 /random.c
parent0c4e7767edf623e0b070256f7bdc75b0f404ba71 (diff)
* random.c (init_hashseed, init_siphash): extract initialize
functions. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52814 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'random.c')
-rw-r--r--random.c33
1 files changed, 24 insertions, 9 deletions
diff --git a/random.c b/random.c
index 76775f2..11b7a3f 100644
--- a/random.c
+++ b/random.c
@@ -1465,13 +1465,10 @@ init_randomseed(struct MT *mt)
return seed;
}
-void
-Init_RandomSeed(void)
+static void
+init_hashseed(void)
{
- rb_random_t *r = &default_rand;
- struct MT *mt = &r->mt;
- VALUE seed = init_randomseed(mt);
- int i;
+ struct MT *mt = default_mt();
hashseed = genrand_int32(mt);
#if SIZEOF_ST_INDEX_T*CHAR_BIT > 4*8
@@ -1486,12 +1483,16 @@ Init_RandomSeed(void)
hashseed <<= 32;
hashseed |= genrand_int32(mt);
#endif
+}
+
+static void
+init_siphash(void)
+{
+ struct MT *mt = default_mt();
+ int i;
for (i = 0; i < numberof(sipseed.u32); ++i)
sipseed.u32[i] = genrand_int32(mt);
-
- rb_global_variable(&r->seed);
- r->seed = seed;
}
st_index_t
@@ -1511,6 +1512,20 @@ rb_memhash(const void *ptr, long len)
#endif
}
+void
+Init_RandomSeed(void)
+{
+ rb_random_t *r = &default_rand;
+ struct MT *mt = &r->mt;
+ VALUE seed = init_randomseed(mt);
+
+ init_hashseed();
+ init_siphash();
+
+ rb_global_variable(&r->seed);
+ r->seed = seed;
+}
+
static void
Init_RandomSeed2(void)
{