diff --git a/ChangeLog b/ChangeLog index b9b7fd1203..6733d21786 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Thu Oct 22 05:23:48 2015 KOSAKI Motohiro + + * random.c (init_hashseed, init_siphash): extract initialize + functions. + Thu Oct 22 01:01:34 2015 KOSAKI Motohiro * configure.in: sort AC_CHECK_HEADERS() by alphabetical order. diff --git a/random.c b/random.c index 76775f2d80..11b7a3febe 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) {