1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* 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
This commit is contained in:
kosaki 2015-11-30 20:31:11 +00:00
parent 0c4e7767ed
commit 052535be3e
2 changed files with 29 additions and 9 deletions

View file

@ -1,3 +1,8 @@
Thu Oct 22 05:23:48 2015 KOSAKI Motohiro <kosaki.motohiro@gmail.com>
* random.c (init_hashseed, init_siphash): extract initialize
functions.
Thu Oct 22 01:01:34 2015 KOSAKI Motohiro <kosaki.motohiro@gmail.com>
* configure.in: sort AC_CHECK_HEADERS() by alphabetical order.

View file

@ -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)
{