summaryrefslogtreecommitdiff
path: root/ext/standard/php_rand.h
diff options
context:
space:
mode:
authorJames Moore <jmoore@php.net>2001-02-22 00:24:19 +0000
committerJames Moore <jmoore@php.net>2001-02-22 00:24:19 +0000
commit118c015529d69e06b6970bc9185436e60313f31e (patch)
tree5b58f083918e0f364229be2d4a24e88c42a93192 /ext/standard/php_rand.h
parent6e31987376e066b4fb856c2f619e78bb49222e23 (diff)
downloadphp-git-118c015529d69e06b6970bc9185436e60313f31e.tar.gz
Adding php_rand() and php_srand(seed) as a wrapper around random, lrand48 and rand.
Diffstat (limited to 'ext/standard/php_rand.h')
-rw-r--r--ext/standard/php_rand.h22
1 files changed, 22 insertions, 0 deletions
diff --git a/ext/standard/php_rand.h b/ext/standard/php_rand.h
index 7ef8b6d9ab..3cc4296d94 100644
--- a/ext/standard/php_rand.h
+++ b/ext/standard/php_rand.h
@@ -36,4 +36,26 @@
#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
+
#endif /* PHP_RAND_H */