summaryrefslogtreecommitdiff
path: root/pp.c
diff options
context:
space:
mode:
authorNick Ing-Simmons <nik@tiuk.ti.com>1998-07-19 12:38:30 +0000
committerNick Ing-Simmons <nik@tiuk.ti.com>1998-07-19 12:38:30 +0000
commita15299417de39f35d2ce17e6891b4f961265fb6a (patch)
tree676ab2ce1d7c4e738906552a4d6c4f71645f7d16 /pp.c
parent911d147d409bfec728014bf1ae544556d9e97f28 (diff)
parentbdda3fbd757cd1d51073d4e041d25f173c8b2f82 (diff)
downloadperl-a15299417de39f35d2ce17e6891b4f961265fb6a.tar.gz
Merge Mainline
p4raw-id: //depot/ansiperl@1566
Diffstat (limited to 'pp.c')
-rw-r--r--pp.c25
1 files changed, 19 insertions, 6 deletions
diff --git a/pp.c b/pp.c
index 4a66aba645..0e11daa947 100644
--- a/pp.c
+++ b/pp.c
@@ -1550,6 +1550,19 @@ PP(pp_cos)
}
}
+/* Support Configure command-line overrides for rand() functions.
+ After 5.005, perhaps we should replace this by Configure support
+ for drand48(), random(), or rand(). For 5.005, though, maintain
+ compatibility by calling rand() but allow the user to override it.
+ See INSTALL for details. --Andy Dougherty 15 July 1998
+*/
+#ifndef my_rand
+# define my_rand rand
+#endif
+#ifndef my_srand
+# define my_srand srand
+#endif
+
PP(pp_rand)
{
djSP; dTARGET;
@@ -1561,19 +1574,19 @@ PP(pp_rand)
if (value == 0.0)
value = 1.0;
if (!srand_called) {
- (void)srand((unsigned)seed());
+ (void)my_srand((unsigned)seed());
srand_called = TRUE;
}
#if RANDBITS == 31
- value = rand() * value / 2147483648.0;
+ value = my_rand() * value / 2147483648.0;
#else
#if RANDBITS == 16
- value = rand() * value / 65536.0;
+ value = my_rand() * value / 65536.0;
#else
#if RANDBITS == 15
- value = rand() * value / 32768.0;
+ value = my_rand() * value / 32768.0;
#else
- value = rand() * value / (double)(((unsigned long)1) << RANDBITS);
+ value = my_rand() * value / (double)(((unsigned long)1) << RANDBITS);
#endif
#endif
#endif
@@ -1589,7 +1602,7 @@ PP(pp_srand)
anum = seed();
else
anum = POPu;
- (void)srand((unsigned)anum);
+ (void)my_srand((unsigned)anum);
srand_called = TRUE;
EXTEND(SP, 1);
RETPUSHYES;