summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ext/standard/php_rand.h7
-rw-r--r--ext/standard/rand.c11
2 files changed, 13 insertions, 5 deletions
diff --git a/ext/standard/php_rand.h b/ext/standard/php_rand.h
index 19686a8066..21c6f63ec0 100644
--- a/ext/standard/php_rand.h
+++ b/ext/standard/php_rand.h
@@ -106,6 +106,11 @@ extern php_randgen_entry *php_randgen_entries[];
#define PHP_RAND_NUMRANDS 4
/* Proto's */
+PHP_RINIT_FUNCTION(rand);
+PHP_MINIT_FUNCTION(rand);
+PHP_MINIT_FUNCTION(rand_mt);
+PHP_MINIT_FUNCTION(rand_sys);
+
PHP_FUNCTION(srand);
PHP_FUNCTION(rand);
PHP_FUNCTION(getrandmax);
@@ -114,7 +119,7 @@ PHP_FUNCTION(mt_rand);
PHP_FUNCTION(mt_getrandmax);
PHPAPI long php_rand(void);
-PHPAPI long php_rand_range(long min, long max);
+PHPAPI long php_rand_range(long min, long max TSRMLS_D);
PHPAPI double php_drand(void);
PHPAPI long php_randmax(void);
diff --git a/ext/standard/rand.c b/ext/standard/rand.c
index 108f58a9ad..d9fba0e160 100644
--- a/ext/standard/rand.c
+++ b/ext/standard/rand.c
@@ -25,6 +25,7 @@
#include "php.h"
#include "php_math.h"
#include "php_rand.h"
+#include "php_lcg.h"
#include "php_ini.h"
#include "zend_execute.h"
@@ -67,7 +68,7 @@ PHP_RINIT_FUNCTION(rand)
/* FIXME: or seed relevant numgen on init/update ini-entry? */
for (i = 0 ; i < PHP_RAND_NUMRANDS ; i++) {
if (PHP_HAS_SRAND(i)) {
-#define SRAND_A_RANDOM_SEED (time(0) * getpid() * (php_combined_lcg(TSRMLS_C) * 10000.0)) /* something with microtime? */
+#define SRAND_A_RANDOM_SEED ((long)time(0) * (long)getpid() * (long)(php_combined_lcg(TSRMLS_C) * 10000.0)) /* something with microtime? */
PHP_SRAND(i,SRAND_A_RANDOM_SEED);
}
}
@@ -112,8 +113,9 @@ PHP_INI_END()
/* srand */
-/* {{{ PHPAPI void php_srand(void) */
-PHPAPI void php_srand(void)
+/* FIXME: isn't used? */
+/* {{{ void php_srand(void) */
+static void php_srand(TSRMLS_D)
{
CURR_GEN = BG(rand_generator);
PHP_SRAND(BG(rand_generator), SRAND_A_RANDOM_SEED);
@@ -126,6 +128,7 @@ PHP_FUNCTION(name) \
{ \
zval **seed; \
zval **alg; \
+ TSRMLS_FETCH(); \
\
switch (ZEND_NUM_ARGS()) { \
case 0: \
@@ -227,7 +230,7 @@ PHPAPI double php_drand(void)
/* }}} */
/* {{{ PHPAPI long php_rand_range(long min, long max) */
-PHPAPI long php_rand_range(long min, long max)
+PHPAPI long php_rand_range(long min, long max TSRMLS_D)
{
register long result;