dbeu Mon Sep 3 22:19:31 2001 EDT
Modified files:
/php4/ext/standard array.c php_rand.h rand.c rand_mt.c rand_sys.c
Log:
fix zts+win32 build
Index: php4/ext/standard/array.c
diff -u php4/ext/standard/array.c:1.131 php4/ext/standard/array.c:1.132
--- php4/ext/standard/array.c:1.131 Mon Sep 3 16:21:00 2001
+++ php4/ext/standard/array.c Mon Sep 3 22:19:30 2001
@@ -21,7 +21,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: array.c,v 1.131 2001/09/03 20:21:00 andi Exp $ */
+/* $Id: array.c,v 1.132 2001/09/04 02:19:30 dbeu Exp $ */
#include "php.h"
#include "php_ini.h"
@@ -2765,7 +2765,7 @@
- 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: php4/ext/standard/php_rand.h
diff -u php4/ext/standard/php_rand.h:1.12 php4/ext/standard/php_rand.h:1.13
--- php4/ext/standard/php_rand.h:1.12 Mon Sep 3 13:38:10 2001
+++ php4/ext/standard/php_rand.h Mon Sep 3 22:19:30 2001
@@ -20,7 +20,7 @@
| Based on code from: Shawn Cokus <Cokus@math.washington.edu> |
+----------------------------------------------------------------------+
*/
-/* $Id: php_rand.h,v 1.12 2001/09/03 17:38:10 derick Exp $ */
+/* $Id: php_rand.h,v 1.13 2001/09/04 02:19:30 dbeu Exp $ */
/* Layout implementation random functions
*
@@ -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_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: php4/ext/standard/rand.c
diff -u php4/ext/standard/rand.c:1.36 php4/ext/standard/rand.c:1.37
--- php4/ext/standard/rand.c:1.36 Mon Sep 3 13:38:10 2001
+++ php4/ext/standard/rand.c Mon Sep 3 22:19:30 2001
@@ -18,7 +18,7 @@
| Jeroen van Wolffelaar <jeroen@php.net> |
+----------------------------------------------------------------------+
*/
-/* $Id: rand.c,v 1.36 2001/09/03 17:38:10 derick Exp $ */
+/* $Id: rand.c,v 1.37 2001/09/04 02:19:30 dbeu Exp $ */
#include <stdlib.h>
@@ -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(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_SRAND(i,SRAND_A_RANDOM_SEED);
}
}
+
+ return SUCCESS;
}
/* INI */
@@ -128,7 +132,6 @@
{ \
zval **seed; \
zval **alg; \
- TSRMLS_FETCH(); \
\
switch (ZEND_NUM_ARGS()) { \
case 0: \
@@ -177,7 +180,7 @@
/* 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 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 @@
/* {{{ 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 @@
WRONG_PARAM_COUNT;
}
- RETURN_LONG( php_randmax());
+ RETURN_LONG( php_randmax(TSRMLS_C));
}
/* }}} */
@@ -305,7 +308,7 @@
WRONG_PARAM_COUNT;
}
- RETURN_LONG( php_randmax() );
+ RETURN_LONG( php_randmax(TSRMLS_C) );
}
/* }}} */
Index: php4/ext/standard/rand_mt.c
diff -u php4/ext/standard/rand_mt.c:1.2 php4/ext/standard/rand_mt.c:1.3
--- php4/ext/standard/rand_mt.c:1.2 Sun Sep 2 21:10:29 2001
+++ php4/ext/standard/rand_mt.c Mon Sep 3 22:19:30 2001
@@ -20,7 +20,7 @@
| Based on code from: Shawn Cokus <Cokus@math.washington.edu> |
+----------------------------------------------------------------------+
*/
-/* $Id: rand_mt.c,v 1.2 2001/09/03 01:10:29 jeroen Exp $ */
+/* $Id: rand_mt.c,v 1.3 2001/09/04 02:19:30 dbeu Exp $ */
#include <stdlib.h>
@@ -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_RANDMAX_MT, /* long randmax */
"mt" /* char *ini_str */
);
+
+ return SUCCESS;
}
#define N MT_N /* length of state vector */
@@ -210,10 +212,9 @@
/*}}}*/
/* {{{ 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: php4/ext/standard/rand_sys.c
diff -u php4/ext/standard/rand_sys.c:1.2 php4/ext/standard/rand_sys.c:1.3
--- php4/ext/standard/rand_sys.c:1.2 Sun Sep 2 21:10:29 2001
+++ php4/ext/standard/rand_sys.c Mon Sep 3 22:19:30 2001
@@ -17,25 +17,23 @@
| Jeroen van Wolffelaar <jeroen@php.net> |
+----------------------------------------------------------------------+
*/
-/* $Id: rand_sys.c,v 1.2 2001/09/03 01:10:29 jeroen Exp $ */
+/* $Id: rand_sys.c,v 1.3 2001/09/04 02:19:30 dbeu Exp $ */
#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_randgen_entries[PHP_RAND_LRAND48] = NULL;
#endif
+ return SUCCESS;
}
/*