summaryrefslogtreecommitdiff
path: root/ext/standard/php_rand.h
diff options
context:
space:
mode:
authorSterling Hughes <sterling@php.net>2001-09-16 20:49:57 +0000
committerSterling Hughes <sterling@php.net>2001-09-16 20:49:57 +0000
commit97fea0931c3cff32c0b027fad372492031349a5b (patch)
tree91c0e17e56eaa188ca17eab6a83f20b4f1af36c3 /ext/standard/php_rand.h
parent96763e8372497ddf6ee725f194b142a7534e777d (diff)
downloadphp-git-97fea0931c3cff32c0b027fad372492031349a5b.tar.gz
Make rand thread safe when ZTS is defined.
Diffstat (limited to 'ext/standard/php_rand.h')
-rw-r--r--ext/standard/php_rand.h27
1 files changed, 4 insertions, 23 deletions
diff --git a/ext/standard/php_rand.h b/ext/standard/php_rand.h
index 7b3b471e40..52dcf38de2 100644
--- a/ext/standard/php_rand.h
+++ b/ext/standard/php_rand.h
@@ -15,6 +15,7 @@
| Authors: Rasmus Lerdorf <rasmus@lerdorf.on.ca> |
| Zeev Suraski <zeev@zend.com> |
| Pedro Melo <melo@ip.pt> |
+ | Sterling Hughes <sterling@php.net> |
| |
| Based on code from: Shawn Cokus <Cokus@math.washington.edu> |
+----------------------------------------------------------------------+
@@ -38,31 +39,11 @@
#define PHP_RAND_MAX RAND_MAX
#endif
-/* Define rand Function wrapper */
-#ifdef HAVE_RANDOM
-#define php_rand() random()
-#else
-#ifdef HAVE_LRAND48
-#define php_rand() lrand48()
-#else
-#define php_rand() rand()
-#endif
-#endif
-
-/* Define srand Function wrapper */
-#ifdef HAVE_SRANDOM
-#define php_srand(seed) srandom((unsigned int)seed)
-#else
-#ifdef HAVE_SRAND48
-#define php_srand(seed) srand48((long)seed)
-#else
-#define php_srand(seed) srand((unsigned int)seed)
-#endif
-#endif
-
/* MT Rand */
-#define PHP_MT_RAND_MAX ((long)(0x7FFFFFFF)) /* (1<<31) - 1 */
+#define PHP_MT_RAND_MAX ((long) (0x7FFFFFFF)) /* (1<<31) - 1 */
+PHPAPI void php_srand(long seed TSRMLS_DC);
+PHPAPI long php_rand(TSRMLS_D);
PHPAPI void php_mt_srand(php_uint32 seed TSRMLS_DC);
PHPAPI php_uint32 php_mt_rand(TSRMLS_D);