* PHP-5.6:
update NEWS and UPGRADING
Upated NEWS
Address issues raised by @nikic
Make sure min < max
Mersenne Twister was added in GMP 4.2
Add test files
Add gmp_random_bits(bits) and gmp_random_range(min, max)
Change GMPs default PRNG to Mersenne Twister
Conflicts:
ext/gmp/gmp.c
}
/* }}} */
-#if GMP_42_OR_NEWER
+ static void gmp_init_random(TSRMLS_D)
+ {
+ if (!GMPG(rand_initialized)) {
+ /* Initialize */
-#else
- gmp_randinit_lc_2exp(GMPG(rand_state), 32L);
-#endif
+ gmp_randinit_mt(GMPG(rand_state));
+ /* Seed */
+ gmp_randseed_ui(GMPG(rand_state), GENERATE_SEED());
+
+ GMPG(rand_initialized) = 1;
+ }
+ }
+
/* {{{ proto GMP gmp_random([int limiter])
Gets random number */
ZEND_FUNCTION(gmp_random)