summaryrefslogtreecommitdiff
path: root/ext/gmp/gmp.c
diff options
context:
space:
mode:
authorAnatol Belski <ab@php.net>2014-12-05 03:50:02 +0100
committerAnatol Belski <ab@php.net>2014-12-05 03:50:02 +0100
commit88bb9fedc4b5fc750524a7b00be1d46fde2f5929 (patch)
treee799ee0cdf4a5d8a8236f599ab8c85a9a05d8673 /ext/gmp/gmp.c
parent864cd82acef03b75b994f3fd98d9b4a51a99204a (diff)
parentf0a17c293b5b240a4da27e6b5f89dbd9c9183488 (diff)
downloadphp-git-88bb9fedc4b5fc750524a7b00be1d46fde2f5929.tar.gz
Merge remote-tracking branch 'origin/master' into native-tls
* origin/master: (111 commits) Fix zend_fcall_info_arg*() to use ZVAL_COPY Fixed #65213 - cannot cast SplFileInfo to boolean add initial install switch to C travis project instead of PHP use the generic TRAVIS environment var to check for travis (see http://docs.travis-ci.com/user/ci-environment/) fix TS build add config option to target codegen architectures updated NEWS updated NEWS Fixed bug #55541 errors spawn MessageBox, which blocks test automation Get rid of duplicate handlers (ZEND_ADD_SPEC_TMP_TMP and ZEND_ADD_SPEC_VAR_VAR are absolutely the same). Use zend_string* for op_array->arg_info[]->name and op_array->arg_info[]->class_name. For internal functions we still use char*. Fixed __debugInfo() support Update UPGRADING for the new variadic functions, and re-sort. Improved POST INC/DEC make sure that we don't truncate the stack trace and cause false test failures when the test is executed in a directory with long path Missed closed folder mark Revert "Unecessary assignment" Fixed improper memory release Unecessary assignment ...
Diffstat (limited to 'ext/gmp/gmp.c')
-rw-r--r--ext/gmp/gmp.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/ext/gmp/gmp.c b/ext/gmp/gmp.c
index 78d471c9d6..5d1d1e689e 100644
--- a/ext/gmp/gmp.c
+++ b/ext/gmp/gmp.c
@@ -104,6 +104,10 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_gmp_random, 0, 0, 0)
ZEND_ARG_INFO(0, limiter)
ZEND_END_ARG_INFO()
+ZEND_BEGIN_ARG_INFO_EX(arginfo_gmp_random_seed, 0, 0, 1)
+ ZEND_ARG_INFO(0, seed)
+ZEND_END_ARG_INFO()
+
ZEND_BEGIN_ARG_INFO_EX(arginfo_gmp_random_bits, 0, 0, 1)
ZEND_ARG_INFO(0, bits)
ZEND_END_ARG_INFO()
@@ -170,6 +174,7 @@ const zend_function_entry gmp_functions[] = {
ZEND_FE(gmp_cmp, arginfo_gmp_binary)
ZEND_FE(gmp_sign, arginfo_gmp_unary)
ZEND_FE(gmp_random, arginfo_gmp_random)
+ ZEND_FE(gmp_random_seed, arginfo_gmp_random_seed)
ZEND_FE(gmp_random_bits, arginfo_gmp_random_bits)
ZEND_FE(gmp_random_range, arginfo_gmp_random_range)
ZEND_FE(gmp_and, arginfo_gmp_binary)
@@ -1768,6 +1773,33 @@ ZEND_FUNCTION(gmp_random)
}
/* }}} */
+/* {{{ proto GMP gmp_random_seed(mixed seed)
+ Seed the RNG */
+ZEND_FUNCTION(gmp_random_seed)
+{
+ zval *seed;
+ mpz_ptr gmpnum_seed;
+ gmp_temp_t temp_a;
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &seed) == FAILURE) {
+ return;
+ }
+
+ gmp_init_random(TSRMLS_C);
+
+ if (Z_TYPE_P(seed) == IS_LONG && Z_LVAL_P(seed) >= 0) {
+ gmp_randseed_ui(GMPG(rand_state), Z_LVAL_P(seed));
+ }
+ else {
+ FETCH_GMP_ZVAL(gmpnum_seed, seed, temp_a);
+
+ gmp_randseed(GMPG(rand_state), gmpnum_seed);
+
+ FREE_GMP_TEMP(temp_a);
+ }
+}
+/* }}} */
+
/* {{{ proto GMP gmp_random_bits(int bits)
Gets a random number in the range 0 to (2 ** n) - 1 */
ZEND_FUNCTION(gmp_random_bits)