]> granicus.if.org Git - php/commitdiff
fix zts+win32 build
authorDaniel Beulshausen <dbeu@php.net>
Tue, 4 Sep 2001 02:19:30 +0000 (02:19 +0000)
committerDaniel Beulshausen <dbeu@php.net>
Tue, 4 Sep 2001 02:19:30 +0000 (02:19 +0000)
ext/standard/array.c
ext/standard/php_rand.h
ext/standard/rand.c
ext/standard/rand_mt.c
ext/standard/rand_sys.c

index d08bacdb55a90a7c277d08235905dd567431a83b..9e4d1e2c7e5dc64d72667ed644e6ecfd117db45d 100644 (file)
@@ -2765,7 +2765,7 @@ PHP_FUNCTION(array_rand)
 
        
 
-       randval = php_drand();
+       randval = php_drand(TSRMLS_C);
                if (randval < (double)num_req_val/(double)num_avail) {
                        /* If we are returning a single result, just do it. */
                        if (Z_TYPE_P(return_value) != IS_ARRAY) {
index 1efbbd4bb6a3a68324b73f5720004e0f8730b642..d90b5583aa1e25f9afa95bb20a81c8e1e85951ad 100644 (file)
@@ -58,8 +58,8 @@
 
 /* FIXME: that '_php_randgen_entry' needed, or not? */
 typedef struct _php_randgen_entry {
-       void (*srand)(long seed);
-       long (*rand)(void);
+       void (*srand)(long seed TSRMLS_DC);
+       long (*rand)(TSRMLS_D);
        long randmax;
        char *ini_str;
 } php_randgen_entry;
@@ -99,10 +99,10 @@ PHP_FUNCTION(mt_srand);
 PHP_FUNCTION(mt_rand);
 PHP_FUNCTION(mt_getrandmax);
 
-PHPAPI long   php_rand(void);
+PHPAPI long   php_rand(TSRMLS_D);
 PHPAPI long   php_rand_range(long min, long max TSRMLS_DC);
-PHPAPI double php_drand(void);
-PHPAPI long   php_randmax(void);
+PHPAPI double php_drand(TSRMLS_D);
+PHPAPI long   php_randmax(TSRMLS_D);
 
 #endif /* PHP_RAND_H */
 
index ef0e41507e924522561e619f8693e38255f4829c..a51ce4c940ea5a17a5ec82a989ca100535b39656 100644 (file)
@@ -38,8 +38,8 @@
 php_randgen_entry *php_randgen_entries[PHP_RAND_NUMRANDS];
 
 #define PHP_HAS_SRAND(which)   (php_randgen_entries[which] && php_randgen_entries[which]->srand)
-#define PHP_SRAND(which,seed)  ((*(php_randgen_entries[which]->srand))(seed))
-#define PHP_RAND(which)                        ((*(php_randgen_entries[which]->rand))())
+#define PHP_SRAND(which,seed)  ((*(php_randgen_entries[which]->srand))(seed TSRMLS_CC))
+#define PHP_RAND(which)                        ((*(php_randgen_entries[which]->rand))(TSRMLS_C))
 #define PHP_RANDMAX(which)             (php_randgen_entries[which]->randmax)
 #define PHP_RAND_INISTR(which) (php_randgen_entries[which]->ini_str)
 
@@ -51,6 +51,8 @@ PHP_MINIT_FUNCTION(rand)
        PHP_MINIT(rand_mt)(INIT_FUNC_ARGS_PASSTHRU);
        /* lcg not yet implemented */
        php_randgen_entries[PHP_RAND_LCG] = NULL;
+
+       return SUCCESS;
 }
 
 /* TODO: check that this function is called on the start of each script
@@ -72,6 +74,8 @@ PHP_RINIT_FUNCTION(rand)
                        PHP_SRAND(i,SRAND_A_RANDOM_SEED);
                }
        }
+
+       return SUCCESS;
 }
 
 /* INI */
@@ -128,7 +132,6 @@ PHP_FUNCTION(name)                                                  \
 {                                                                                      \
        zval **seed;                                                            \
        zval **alg;                                                             \
-       TSRMLS_FETCH();                                                 \
                                                                                        \
        switch (ZEND_NUM_ARGS()) {                                              \
                case 0:                                                                         \
@@ -177,7 +180,7 @@ pim_srand_common(mt_srand,PHP_RAND_MT)
 /* rand */
 
 /* {{{ PHPAPI long php_rand(void) */
-PHPAPI long php_rand(void)
+PHPAPI long php_rand(TSRMLS_D)
 {
        return PHP_RAND(CURR_GEN);
 }
@@ -185,9 +188,9 @@ PHPAPI long php_rand(void)
 
 /* {{{ PHPAPI double php_drand(void) 
  *      returns a double in the range [0,1) */
-PHPAPI double php_drand(void)
+PHPAPI double php_drand(TSRMLS_D)
 {
-       return  (double)php_rand() /
+       return  (double)php_rand(TSRMLS_C) /
                        (double)(PHP_RANDMAX(CURR_GEN)+1.0);
 }
 /* }}} */
@@ -279,7 +282,7 @@ PHP_FUNCTION_RAND(mt_rand,PHP_RAND_MT)
 
 /* {{{ PHPAPI long php_randmax(void)
    Returns the maximum value a random number can have */
-PHPAPI long php_randmax(void)
+PHPAPI long php_randmax(TSRMLS_D)
 {
        return PHP_RANDMAX(CURR_GEN);
 }
@@ -293,7 +296,7 @@ PHP_FUNCTION(getrandmax)
                WRONG_PARAM_COUNT;
        }
 
-       RETURN_LONG( php_randmax());
+       RETURN_LONG( php_randmax(TSRMLS_C));
 }
 /* }}} */
 
@@ -305,7 +308,7 @@ PHP_FUNCTION(mt_getrandmax)
                WRONG_PARAM_COUNT;
        }
 
-       RETURN_LONG( php_randmax() );
+       RETURN_LONG( php_randmax(TSRMLS_C) );
 }
 /* }}} */
 
index 877074653b6f9a1fbce255cf6a3c5519fc11225e..ec67d32a7a9c1f925dc983ae9e8a10ff6089b30a 100644 (file)
@@ -85,7 +85,7 @@
 
 static        void _php_srand_mt(long seed TSRMLS_DC);
 static inline long _php_rand_mt_reload(TSRMLS_D);
-static        long _php_rand_mt(void);
+static        long _php_rand_mt(TSRMLS_D);
 /*
  * Melo: it could be 2^^32 but we only use 2^^31 to maintain
  * compatibility with the previous php_rand
@@ -100,6 +100,8 @@ PHP_MINIT_FUNCTION(rand_mt)
                PHP_RANDMAX_MT, /* long randmax                         */
                "mt"                    /* char *ini_str                        */
        );
+
+       return SUCCESS;
 }
 
 #define N             MT_N                 /* length of state vector */
@@ -210,10 +212,9 @@ static inline long _php_rand_mt_reload(TSRMLS_D)
 /*}}}*/
 
 /* {{{ long _php_rand_mt(void) */
-static long _php_rand_mt(void)
+static long _php_rand_mt(TSRMLS_D)
 {
     php_uint32 y;
-       TSRMLS_FETCH();
 
     if(--BG(left) < 0)
         return(_php_rand_mt_reload(TSRMLS_C));
index fcb52fb365a4f72d1512894d6644a97ce788bcc6..33ea44fef8b29705348204866d43e706dc95dbdb 100644 (file)
 
 #include <stdlib.h>
 
-#include "php.h"
+#include "php_reentrancy.h"
 #include "php_rand.h"
-
 #include "basic_functions.h"
 
-
 /* rand() & co (thread safe this time!): */
-static void _php_srand_sys(long seed) 
+static void _php_srand_sys(long seed TSRMLS_DC
 {
        BG(rand_sys_seed) = (unsigned int) seed;
 }
 
-static long _php_rand_sys(void)
+static long _php_rand_sys(TSRMLS_D)
 {
-       return (long) rand_r(&BG(rand_sys_seed));
+       return (long) php_rand_r(&BG(rand_sys_seed));
 }
 
 PHP_MINIT_FUNCTION(rand_sys)
@@ -67,6 +65,7 @@ PHP_MINIT_FUNCTION(rand_sys)
        php_randgen_entries[PHP_RAND_LRAND48] = NULL;
 #endif
 
+       return SUCCESS;
 }
 
 /*