diff options
author | Nick Ing-Simmons <nik@tiuk.ti.com> | 1998-07-19 12:38:30 +0000 |
---|---|---|
committer | Nick Ing-Simmons <nik@tiuk.ti.com> | 1998-07-19 12:38:30 +0000 |
commit | a15299417de39f35d2ce17e6891b4f961265fb6a (patch) | |
tree | 676ab2ce1d7c4e738906552a4d6c4f71645f7d16 /pp.c | |
parent | 911d147d409bfec728014bf1ae544556d9e97f28 (diff) | |
parent | bdda3fbd757cd1d51073d4e041d25f173c8b2f82 (diff) | |
download | perl-a15299417de39f35d2ce17e6891b4f961265fb6a.tar.gz |
Merge Mainline
p4raw-id: //depot/ansiperl@1566
Diffstat (limited to 'pp.c')
-rw-r--r-- | pp.c | 25 |
1 files changed, 19 insertions, 6 deletions
@@ -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; |