diff options
author | Anatol Belski <ab@php.net> | 2014-08-16 17:31:40 +0200 |
---|---|---|
committer | Anatol Belski <ab@php.net> | 2014-08-16 17:31:40 +0200 |
commit | 864172d9a49a6201513d83c06b77b5d309dc50ab (patch) | |
tree | 6aa4b3249a59aa8f3b21a06cb28a1fc2f0f5dae6 /ext/standard/rand.c | |
parent | 54906c760fb578079b6783a2aa4184372a3179d3 (diff) | |
download | php-git-864172d9a49a6201513d83c06b77b5d309dc50ab.tar.gz |
further fixes to ext/standard and zend
Diffstat (limited to 'ext/standard/rand.c')
-rw-r--r-- | ext/standard/rand.c | 34 |
1 files changed, 17 insertions, 17 deletions
diff --git a/ext/standard/rand.c b/ext/standard/rand.c index 3029ed28bc..972f015948 100644 --- a/ext/standard/rand.c +++ b/ext/standard/rand.c @@ -38,7 +38,7 @@ /* {{{ php_srand */ -PHPAPI void php_srand(long seed TSRMLS_DC) +PHPAPI void php_srand(php_int_t seed TSRMLS_DC) { #ifdef ZTS BG(rand_seed) = (unsigned int) seed; @@ -59,9 +59,9 @@ PHPAPI void php_srand(long seed TSRMLS_DC) /* {{{ php_rand */ -PHPAPI long php_rand(TSRMLS_D) +PHPAPI php_int_t php_rand(TSRMLS_D) { - long ret; + php_int_t ret; if (!BG(rand_is_seeded)) { php_srand(GENERATE_SEED() TSRMLS_CC); @@ -229,9 +229,9 @@ PHPAPI php_uint32 php_mt_rand(TSRMLS_D) Seeds random number generator */ PHP_FUNCTION(srand) { - long seed = 0; + php_int_t seed = 0; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|l", &seed) == FAILURE) + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|i", &seed) == FAILURE) return; if (ZEND_NUM_ARGS() == 0) @@ -245,9 +245,9 @@ PHP_FUNCTION(srand) Seeds Mersenne Twister random number generator */ PHP_FUNCTION(mt_srand) { - long seed = 0; + php_int_t seed = 0; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|l", &seed) == FAILURE) + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|i", &seed) == FAILURE) return; if (ZEND_NUM_ARGS() == 0) @@ -288,12 +288,12 @@ PHP_FUNCTION(mt_srand) Returns a random number */ PHP_FUNCTION(rand) { - long min; - long max; - long number; + php_int_t min; + php_int_t max; + php_int_t number; int argc = ZEND_NUM_ARGS(); - if (argc != 0 && zend_parse_parameters(argc TSRMLS_CC, "ll", &min, &max) == FAILURE) + if (argc != 0 && zend_parse_parameters(argc TSRMLS_CC, "ii", &min, &max) == FAILURE) return; number = php_rand(TSRMLS_C); @@ -309,16 +309,16 @@ PHP_FUNCTION(rand) Returns a random number from Mersenne Twister */ PHP_FUNCTION(mt_rand) { - long min; - long max; - long number; + php_int_t min; + php_int_t max; + php_int_t number; int argc = ZEND_NUM_ARGS(); if (argc != 0) { - if (zend_parse_parameters(argc TSRMLS_CC, "ll", &min, &max) == FAILURE) { + if (zend_parse_parameters(argc TSRMLS_CC, "ii", &min, &max) == FAILURE) { return; } else if (max < min) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "max(%ld) is smaller than min(%ld)", max, min); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "max(" ZEND_INT_FMT ") is smaller than min(" ZEND_INT_FMT ")", max, min); RETURN_FALSE; } } @@ -335,7 +335,7 @@ PHP_FUNCTION(mt_rand) * Update: * I talked with Cokus via email and it won't ruin the algorithm */ - number = (long) (php_mt_rand(TSRMLS_C) >> 1); + number = (php_int_t) (php_mt_rand(TSRMLS_C) >> 1); if (argc == 2) { RAND_RANGE(number, min, max, PHP_MT_RAND_MAX); } |