summaryrefslogtreecommitdiff
path: root/ext/standard/php_lcg.h
diff options
context:
space:
mode:
authorSascha Schumann <sas@php.net>2001-09-21 13:38:44 +0000
committerSascha Schumann <sas@php.net>2001-09-21 13:38:44 +0000
commit9002e37e4e25cf751d675612bdde48316c1a0613 (patch)
tree9ac38f3f3d5b26c6147cf9f8a48114f9df80756d /ext/standard/php_lcg.h
parent78fb121a61f5b940308ad33ab8db66c685b0ecba (diff)
downloadphp-git-9002e37e4e25cf751d675612bdde48316c1a0613.tar.gz
Always seed the LCG from the request-init hook, otherwise the seed
would be shared among the threads which is quite pointless. Also use a function of the current time as one factor. Use gettimeofday() instead of time(), because it is faster on some operating systems.
Diffstat (limited to 'ext/standard/php_lcg.h')
-rw-r--r--ext/standard/php_lcg.h8
1 files changed, 5 insertions, 3 deletions
diff --git a/ext/standard/php_lcg.h b/ext/standard/php_lcg.h
index 05bcc83c44..ecb97178ac 100644
--- a/ext/standard/php_lcg.h
+++ b/ext/standard/php_lcg.h
@@ -26,16 +26,18 @@
typedef struct {
php_int32 s1;
php_int32 s2;
+ int seeded;
} php_lcg_globals;
-double php_combined_lcg(TSRMLS_D);
+PHPAPI double php_combined_lcg(TSRMLS_D);
PHP_FUNCTION(lcg_value);
-#ifdef ZTS
PHP_MINIT_FUNCTION(lcg);
+PHP_RINIT_FUNCTION(lcg);
+
+#ifdef ZTS
#define LCG(v) TSRMG(lcg_globals_id, php_lcg_globals *, v)
#else
-PHP_RINIT_FUNCTION(lcg);
#define LCG(v) (lcg_globals.v)
#endif