cvs: php4 /ext/standard php_rand.h rand.c
| From: | Jeroen van Wolffelaar | Date: | Mon, 03 Sep 2001 11:57:15 +0000 |
| Subject: | cvs: php4 /ext/standard php_rand.h rand.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-7178@lists.php.net to get a copy of this message | ||
jeroen Mon Sep 3 07:57:15 2001 EDT
Modified files:
/php4/ext/standard php_rand.h rand.c
Log:
Kill some warnings/errors (reported by Sebastian, more to come, but
could take some time. Update of ZTS-builderrors is welcome)
Index: php4/ext/standard/php_rand.h
diff -u php4/ext/standard/php_rand.h:1.9 php4/ext/standard/php_rand.h:1.10
--- php4/ext/standard/php_rand.h:1.9 Sun Sep 2 21:06:23 2001
+++ php4/ext/standard/php_rand.h Mon Sep 3 07:57:15 2001
@@ -20,7 +20,7 @@
| Based on code from: Shawn Cokus <Cokus@math.washington.edu> |
+----------------------------------------------------------------------+
*/
-/* $Id: php_rand.h,v 1.9 2001/09/03 01:06:23 jeroen Exp $ */
+/* $Id: php_rand.h,v 1.10 2001/09/03 11:57:15 jeroen Exp $ */
/* Layout implementation random functions
*
@@ -106,6 +106,11 @@
#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_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);
Index: php4/ext/standard/rand.c
diff -u php4/ext/standard/rand.c:1.34 php4/ext/standard/rand.c:1.35
--- php4/ext/standard/rand.c:1.34 Sun Sep 2 21:25:24 2001
+++ php4/ext/standard/rand.c Mon Sep 3 07:57:15 2001
@@ -18,13 +18,14 @@
| Jeroen van Wolffelaar <jeroen@php.net> |
+----------------------------------------------------------------------+
*/
-/* $Id: rand.c,v 1.34 2001/09/03 01:25:24 jeroen Exp $ */
+/* $Id: rand.c,v 1.35 2001/09/03 11:57:15 jeroen Exp $ */
#include <stdlib.h>
#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 @@
/* 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 @@
/* 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 @@
{ \
zval **seed; \
zval **alg; \
+ TSRMLS_FETCH(); \
\
switch (ZEND_NUM_ARGS()) { \
case 0: \
@@ -227,7 +230,7 @@
/* }}} */
/* {{{ 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;