@@ -19489,26 +19489,7 @@ esac
19489
19489
19490
19490
: How can we generate normalized random numbers ?
19491
19491
echo " "
19492
- echo "Looking for a random number function..." >&4
19493
- case "$randfunc" in
19494
- '')
19495
- if set drand48 val -f; eval $csym; $val; then
19496
- dflt="drand48"
19497
- echo "Good, found drand48()." >&4
19498
- elif set random val -f; eval $csym; $val; then
19499
- dflt="random"
19500
- echo "OK, found random()." >&4
19501
- else
19502
- dflt="rand"
19503
- echo "Yuck, looks like I have to use rand()." >&4
19504
- fi
19505
- echo " "
19506
- ;;
19507
- *)
19508
- dflt="$randfunc"
19509
- ;;
19510
- esac
19511
- cont=true
19492
+ echo "Using our internal random number implementation..." >&4
19512
19493
19513
19494
case "$ccflags" in
19514
19495
*-Dmy_rand=*|*-Dmy_srand=*)
@@ -19519,103 +19500,11 @@ case "$ccflags" in
19519
19500
;;
19520
19501
esac
19521
19502
19522
- while $test "$cont"; do
19523
- rp="Use which function to generate random numbers?"
19524
- . ./myread
19525
- if $test "$ans" = "$dflt"; then
19526
- : null
19527
- else
19528
- randbits=''
19529
- fi
19530
- randfunc="$ans"
19531
- if set $ans val -f; eval $csym; $val; then
19532
- cont=''
19533
- else
19534
- dflt=y
19535
- rp="I cannot find function $ans. Use that name anyway?"
19536
- . ./myread
19537
- dflt=rand
19538
- case "$ans" in
19539
- [yY]*) cont='';;
19540
- esac
19541
- fi
19542
- case "$cont" in
19543
- '')
19544
- case "$randfunc" in
19545
- drand48)
19546
- drand01="drand48()"
19547
- seedfunc="srand48"
19548
- randbits=48
19549
- randseedtype=long
19550
- ;;
19551
- rand|random)
19552
- case "$randbits" in
19553
- '')
19554
- echo "Checking to see how many bits your $randfunc() function produces..." >&4
19555
- $cat >try.c <<EOCP
19556
- #$i_unistd I_UNISTD
19557
- #$i_stdlib I_STDLIB
19558
- #include <stdio.h>
19559
- #ifdef I_UNISTD
19560
- # include <unistd.h>
19561
- #endif
19562
- #ifdef I_STDLIB
19563
- # include <stdlib.h>
19564
- #endif
19565
- int main()
19566
- {
19567
- int i;
19568
- unsigned long tmp;
19569
- unsigned long max = 0L;
19570
-
19571
- for (i = 1000; i; i--) {
19572
- tmp = (unsigned long) $randfunc();
19573
- if (tmp > max) max = tmp;
19574
- }
19575
- for (i = 0; max; i++)
19576
- max /= 2;
19577
- printf("%d\n",i);
19578
- }
19579
- EOCP
19580
- set try
19581
- if eval $compile_ok; then
19582
- dflt=`try`
19583
- else
19584
- dflt='?'
19585
- echo "(I can't seem to compile the test program...)"
19586
- fi
19587
- ;;
19588
- *)
19589
- dflt="$randbits"
19590
- ;;
19591
- esac
19592
- rp="How many bits does your $randfunc() function produce?"
19593
- . ./myread
19594
- randbits="$ans"
19595
- $rm_try
19596
- drand01="($randfunc() / (double) ((unsigned long)1 << $randbits))"
19597
- seedfunc="s$randfunc"
19598
- randseedtype=unsigned
19599
- ;;
19600
- *)
19601
- dflt="31"
19602
- rp="How many bits does your $randfunc() function produce?"
19603
- . ./myread
19604
- randbits="$ans"
19605
- seedfunc="s$randfunc"
19606
- drand01="($randfunc() / (double) ((unsigned long)1 << $randbits))"
19607
- if set $seedfunc val -f; eval $csym; $val; then
19608
- echo "(Using $seedfunc() to seed random generator)"
19609
- else
19610
- echo "(Warning: no $seedfunc() to seed random generator)"
19611
- seedfunc=rand
19612
- fi
19613
- randseedtype=unsigned
19614
- ;;
19615
- esac
19616
- ;;
19617
- esac
19618
- done
19503
+ randfunc=Perl_drand48
19504
+ drand01="Perl_drand48()"
19505
+ seedfunc="Perl_drand48_init"
19506
+ randbits=48
19507
+ randseedtype=U32
19619
19508
19620
19509
: Check how to flush
19621
19510
echo " "
0 commit comments