diff --git a/Configure b/Configure index 7868560295fb..9ccafef71abb 100755 --- a/Configure +++ b/Configure @@ -439,9 +439,6 @@ d_dlopen='' d_dlsymun='' d_dosuid='' d_suidsafe='' -d_drand48_r='' -drand48_r_proto='' -d_drand48proto='' d_dup2='' d_dup3='' d_eaccess='' @@ -729,8 +726,6 @@ d_sched_yield='' sched_yield='' d_ptrdiff_t='' d_qgcvt='' -d_random_r='' -random_r_proto='' d_readdir64_r='' readdir64_r_proto='' d_readdir='' @@ -849,10 +844,6 @@ socketlib='' d_socklen_t='' d_socks5_init='' d_sqrtl='' -d_srand48_r='' -srand48_r_proto='' -d_srandom_r='' -srandom_r_proto='' d_sresgproto='' d_sresuproto='' d_stat='' @@ -1280,10 +1271,8 @@ quadkind='' quadtype='' uquadtype='' drand01='' -randbits='' randfunc='' randseedtype='' -seedfunc='' installscript='' scriptdir='' scriptdirexp='' @@ -4702,7 +4691,7 @@ esac # to fail hard and early. # # Annoyingly -std=c99 will cause gcc to tell glibc not to define prototypes for -# syscall, drand48 etc when including , which messes up our build. +# syscall, etc when including , which messes up our build. # I guess we *could* loop round trying -std=c99 first with checks both for the # prototype found and the code compiling (because -std=gnu99 might do other # things we don't want, particularly on non-GCC compilers) but @@ -12692,52 +12681,6 @@ $rm -f fred fred.* dyna.$dlext dyna.* tmp-dyna.* set d_dlsymun eval $setvar -: see if drand48_r exists -set drand48_r d_drand48_r -eval $inlibc -case "$d_drand48_r" in -"$define") - hdrs="$i_systypes sys/types.h define stdio.h $i_stdlib stdlib.h" - case "$d_drand48_r_proto:$usethreads" in - ":define") d_drand48_r_proto=define - set d_drand48_r_proto drand48_r $hdrs - eval $hasproto ;; - *) ;; - esac - case "$d_drand48_r_proto" in - define) - case "$drand48_r_proto" in - ''|0) try='int drand48_r(struct drand48_data*, double*);' - ./protochk "$extern_C $try" $hdrs && drand48_r_proto=I_ST ;; - esac - case "$drand48_r_proto" in - ''|0) d_drand48_r=undef - drand48_r_proto=0 - echo "Disabling drand48_r, cannot determine prototype." >&4 ;; - * ) case "$drand48_r_proto" in - REENTRANT_PROTO*) ;; - *) drand48_r_proto="REENTRANT_PROTO_$drand48_r_proto" ;; - esac - echo "Prototype: $try" ;; - esac - ;; - *) case "$usethreads" in - define) echo "drand48_r has no prototype, not using it." >&4 ;; - esac - d_drand48_r=undef - drand48_r_proto=0 - ;; - esac - ;; -*) drand48_r_proto=0 - ;; -esac - -: see if prototype for drand48 is available -echo " " -set d_drand48proto drand48 $i_stdlib stdlib.h $i_unistd unistd.h -eval $hasproto - : see if dup2 exists set dup2 d_dup2 eval $inlibc @@ -18091,55 +18034,6 @@ $rm_try set d_ptrdiff_t eval $setvar -: see if random_r exists -set random_r d_random_r -eval $inlibc -case "$d_random_r" in -"$define") - hdrs="$i_systypes sys/types.h define stdio.h $i_stdlib stdlib.h" - case "$d_random_r_proto:$usethreads" in - ":define") d_random_r_proto=define - set d_random_r_proto random_r $hdrs - eval $hasproto ;; - *) ;; - esac - case "$d_random_r_proto" in - define) - case "$random_r_proto" in - ''|0) try='int random_r(int*, struct random_data*);' - ./protochk "$extern_C $try" $hdrs && random_r_proto=I_iS ;; - esac - case "$random_r_proto" in - ''|0) try='int random_r(long*, struct random_data*);' - ./protochk "$extern_C $try" $hdrs && random_r_proto=I_lS ;; - esac - case "$random_r_proto" in - ''|0) try='int random_r(struct random_data*, int32_t*);' - ./protochk "$extern_C $try" $hdrs && random_r_proto=I_St ;; - esac - case "$random_r_proto" in - ''|0) d_random_r=undef - random_r_proto=0 - echo "Disabling random_r, cannot determine prototype." >&4 ;; - * ) case "$random_r_proto" in - REENTRANT_PROTO*) ;; - *) random_r_proto="REENTRANT_PROTO_$random_r_proto" ;; - esac - echo "Prototype: $try" ;; - esac - ;; - *) case "$usethreads" in - define) echo "random_r has no prototype, not using it." >&4 ;; - esac - d_random_r=undef - random_r_proto=0 - ;; - esac - ;; -*) random_r_proto=0 - ;; -esac - : see if readdir and friends exist set readdir d_readdir eval $inlibc @@ -19349,88 +19243,6 @@ eval $hasproto set socks5_init d_socks5_init eval $inlibc -: see if srand48_r exists -set srand48_r d_srand48_r -eval $inlibc -case "$d_srand48_r" in -"$define") - hdrs="$i_systypes sys/types.h define stdio.h $i_stdlib stdlib.h" - case "$d_srand48_r_proto:$usethreads" in - ":define") d_srand48_r_proto=define - set d_srand48_r_proto srand48_r $hdrs - eval $hasproto ;; - *) ;; - esac - case "$d_srand48_r_proto" in - define) - case "$srand48_r_proto" in - ''|0) try='int srand48_r(long, struct drand48_data*);' - ./protochk "$extern_C $try" $hdrs && srand48_r_proto=I_LS ;; - esac - case "$srand48_r_proto" in - ''|0) d_srand48_r=undef - srand48_r_proto=0 - echo "Disabling srand48_r, cannot determine prototype." >&4 ;; - * ) case "$srand48_r_proto" in - REENTRANT_PROTO*) ;; - *) srand48_r_proto="REENTRANT_PROTO_$srand48_r_proto" ;; - esac - echo "Prototype: $try" ;; - esac - ;; - *) case "$usethreads" in - define) echo "srand48_r has no prototype, not using it." >&4 ;; - esac - d_srand48_r=undef - srand48_r_proto=0 - ;; - esac - ;; -*) srand48_r_proto=0 - ;; -esac - -: see if srandom_r exists -set srandom_r d_srandom_r -eval $inlibc -case "$d_srandom_r" in -"$define") - hdrs="$i_systypes sys/types.h define stdio.h $i_stdlib stdlib.h" - case "$d_srandom_r_proto:$usethreads" in - ":define") d_srandom_r_proto=define - set d_srandom_r_proto srandom_r $hdrs - eval $hasproto ;; - *) ;; - esac - case "$d_srandom_r_proto" in - define) - case "$srandom_r_proto" in - ''|0) try='int srandom_r(unsigned int, struct random_data*);' - ./protochk "$extern_C $try" $hdrs && srandom_r_proto=I_TS ;; - esac - case "$srandom_r_proto" in - ''|0) d_srandom_r=undef - srandom_r_proto=0 - echo "Disabling srandom_r, cannot determine prototype." >&4 ;; - * ) case "$srandom_r_proto" in - REENTRANT_PROTO*) ;; - *) srandom_r_proto="REENTRANT_PROTO_$srandom_r_proto" ;; - esac - echo "Prototype: $try" ;; - esac - ;; - *) case "$usethreads" in - define) echo "srandom_r has no prototype, not using it." >&4 ;; - esac - d_srandom_r=undef - srandom_r_proto=0 - ;; - esac - ;; -*) srandom_r_proto=0 - ;; -esac - : see if prototype for setresgid is available echo " " set d_sresgproto setresgid $i_unistd unistd.h @@ -21343,12 +21155,6 @@ case "$ccflags" in ;; esac -randfunc=Perl_drand48 -drand01="Perl_drand48()" -seedfunc="Perl_drand48_init" -randbits=48 -randseedtype=U32 - : Probe whether dtrace builds an object, as newer Illumos requires an input : object file that uses at least one of the probes defined in the .d file case "$usedtrace" in @@ -24999,8 +24805,6 @@ d_double_style_cray='$d_double_style_cray' d_double_style_ibm='$d_double_style_ibm' d_double_style_ieee='$d_double_style_ieee' d_double_style_vax='$d_double_style_vax' -d_drand48_r='$d_drand48_r' -d_drand48proto='$d_drand48proto' d_dup2='$d_dup2' d_dup3='$d_dup3' d_duplocale='$d_duplocale' @@ -25286,7 +25090,6 @@ d_pwquota='$d_pwquota' d_qgcvt='$d_qgcvt' d_quad='$d_quad' d_querylocale='$d_querylocale' -d_random_r='$d_random_r' d_re_comp='$d_re_comp' d_readdir64_r='$d_readdir64_r' d_readdir='$d_readdir' @@ -25383,8 +25186,6 @@ d_socklen_t='$d_socklen_t' d_sockpair='$d_sockpair' d_socks5_init='$d_socks5_init' d_sqrtl='$d_sqrtl' -d_srand48_r='$d_srand48_r' -d_srandom_r='$d_srandom_r' d_sresgproto='$d_sresgproto' d_sresuproto='$d_sresuproto' d_stat='$d_stat' @@ -25492,7 +25293,6 @@ doublemantbits='$doublemantbits' doublenanbytes='$doublenanbytes' doublesize='$doublesize' drand01='$drand01' -drand48_r_proto='$drand48_r_proto' dtrace='$dtrace' dtraceobject='$dtraceobject' dtracexnolibs='$dtracexnolibs' @@ -25829,9 +25629,7 @@ procselfexe='$procselfexe' ptrsize='$ptrsize' quadkind='$quadkind' quadtype='$quadtype' -randbits='$randbits' randfunc='$randfunc' -random_r_proto='$random_r_proto' randseedtype='$randseedtype' ranlib='$ranlib' rd_nodata='$rd_nodata' @@ -25864,7 +25662,6 @@ sched_yield='$sched_yield' scriptdir='$scriptdir' scriptdirexp='$scriptdirexp' sed='$sed' -seedfunc='$seedfunc' selectminbits='$selectminbits' selecttype='$selecttype' sendmail='$sendmail' @@ -25919,8 +25716,6 @@ socksizetype='$socksizetype' sort='$sort' spackage='$spackage' spitshell='$spitshell' -srand48_r_proto='$srand48_r_proto' -srandom_r_proto='$srandom_r_proto' src='$src' ssizetype='$ssizetype' st_dev_sign='$st_dev_sign' @@ -26175,4 +25970,3 @@ $rm -f kit*isdone ark*isdone $rm -rf UU : End of Configure - diff --git a/Cross/config.sh-arm-linux b/Cross/config.sh-arm-linux index 1b0d1def775d..3f965be11b36 100644 --- a/Cross/config.sh-arm-linux +++ b/Cross/config.sh-arm-linux @@ -177,8 +177,6 @@ d_double_style_cray='undef' d_double_style_ibm='undef' d_double_style_ieee='define' d_double_style_vax='undef' -d_drand48_r='undef' -d_drand48proto='define' d_dup2='define' d_dup3='undef' d_duplocale='undef' @@ -462,7 +460,6 @@ d_pwquota='undef' d_qgcvt='define' d_quad='define' d_querylocale='undef' -d_random_r='undef' d_readdir64_r='undef' d_readdir='define' d_readdir_r='undef' @@ -556,8 +553,6 @@ d_socklen_t='define' d_sockpair='define' d_socks5_init='undef' d_sqrtl='define' -d_srand48_r='undef' -d_srandom_r='undef' d_sresgproto='undef' d_sresuproto='undef' d_stat='define' @@ -665,8 +660,6 @@ doublekind='3' doublemantbits='52' doublenanbytes='0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x7f' doublesize='8' -drand01='Perl_drand48()' -drand48_r_proto='0' dtrace='' dynamic_ext='B ByteLoader Cwd Data/Dumper Devel/DProf Devel/PPPort Devel/Peek Digest/MD5 Encode Fcntl File/Glob Filter/Util/Call I18N/Langinfo IO IPC/SysV List/Util MIME/Base64 Opcode POSIX PerlIO/encoding PerlIO/scalar PerlIO/via SDBM_File Socket Storable Sys/Hostname Sys/Syslog Time/HiRes Unicode/Collate Unicode/Normalize XS/APItest XS/Typemap attributes re threads threads/shared' eagain='EAGAIN' @@ -996,10 +989,6 @@ prototype='define' ptrsize='4' quadkind='3' quadtype='long long' -randbits='48' -randfunc='Perl_drand48' -random_r_proto='0' -randseedtype='U32' ranlib=':' rd_nodata='-1' readdir64_r_proto='0' @@ -1030,7 +1019,6 @@ sched_yield='sched_yield()' scriptdir='/usr/bin' scriptdirexp='/usr/bin' sed='sed' -seedfunc='Perl_drand48_init' selectminbits='32' selecttype='fd_set *' sendmail='' @@ -1085,8 +1073,6 @@ socksizetype='socklen_t' sort='sort' spackage='Perl5' spitshell='cat' -srand48_r_proto='0' -srandom_r_proto='0' src='.' ssizetype='ssize_t' st_dev_sign='1' diff --git a/Cross/config.sh-arm-linux-n770 b/Cross/config.sh-arm-linux-n770 index 724d46c228fb..f34b3abee659 100644 --- a/Cross/config.sh-arm-linux-n770 +++ b/Cross/config.sh-arm-linux-n770 @@ -176,8 +176,6 @@ d_double_style_cray='undef' d_double_style_ibm='undef' d_double_style_ieee='define' d_double_style_vax='undef' -d_drand48_r='undef' -d_drand48proto='define' d_dup2='define' d_dup3='undef' d_duplocale='undef' @@ -461,7 +459,6 @@ d_pwquota='undef' d_qgcvt='define' d_quad='define' d_querylocale='undef' -d_random_r='undef' d_readdir64_r='undef' d_readdir='define' d_readdir_r='undef' @@ -555,8 +552,6 @@ d_socklen_t='define' d_sockpair='define' d_socks5_init='undef' d_sqrtl='define' -d_srand48_r='undef' -d_srandom_r='undef' d_sresgproto='undef' d_sresuproto='undef' d_stat='define' @@ -664,8 +659,6 @@ doublekind='3' doublemantbits='52' doublenanbytes='0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x7f' doublesize='8' -drand01='Perl_drand48()' -drand48_r_proto='0' dynamic_ext='B ByteLoader Cwd Data/Dumper Devel/DProf Devel/PPPort Devel/Peek Digest/MD5 Encode Fcntl File/Glob Filter/Util/Call I18N/Langinfo IO IPC/SysV List/Util MIME/Base64 Opcode POSIX PerlIO/encoding PerlIO/scalar PerlIO/via SDBM_File Socket Storable Sys/Hostname Sys/Syslog Time/HiRes Unicode/Collate Unicode/Normalize XS/APItest XS/Typemap attributes re threads threads/shared' eagain='EAGAIN' ebcdic='undef' @@ -994,10 +987,6 @@ prototype='define' ptrsize='4' quadkind='3' quadtype='long long' -randbits='48' -randfunc='Perl_drand48' -random_r_proto='0' -randseedtype='U32' ranlib=':' rd_nodata='-1' readdir64_r_proto='0' @@ -1028,7 +1017,6 @@ sched_yield='sched_yield()' scriptdir='/usr/bin' scriptdirexp='/usr/bin' sed='sed' -seedfunc='Perl_drand48_init' selectminbits='32' selecttype='fd_set *' sendmail='' @@ -1083,8 +1071,6 @@ socksizetype='socklen_t' sort='sort' spackage='Perl5' spitshell='cat' -srand48_r_proto='0' -srandom_r_proto='0' src='.' ssizetype='ssize_t' st_dev_sign='1' diff --git a/Porting/Glossary b/Porting/Glossary index bb505c653b0b..cd21163b54f4 100644 --- a/Porting/Glossary +++ b/Porting/Glossary @@ -732,17 +732,6 @@ d_double_style_vax (longdblfio.U): This variable conditionally defines the symbol DOUBLE_STYLE_VAX, which indicates that the double is the 64-bit VAX format D or G. -d_drand48_r (d_drand48_r.U): - This variable conditionally defines the HAS_DRAND48_R symbol, - which indicates to the C program that the drand48_r() - routine is available. - -d_drand48proto (d_drand48proto.U): - This variable conditionally defines the HAS_DRAND48_PROTO symbol, - which indicates to the C program that the system provides - a prototype for the drand48() function. Otherwise, it is - up to the program to supply one. - d_dup2 (d_dup2.U): This variable conditionally defines HAS_DUP2 if dup2() is available to duplicate file descriptors. @@ -2143,11 +2132,6 @@ d_querylocale (d_newlocale.U): indicates to the C program that the querylocale() routine is available to return the name of the locale for a category mask. -d_random_r (d_random_r.U): - This variable conditionally defines the HAS_RANDOM_R symbol, - which indicates to the C program that the random_r() - routine is available. - d_re_comp (d_regcmp.U): This variable conditionally defines the HAS_RECOMP symbol, which indicates to the C program that the re_comp() routine is available @@ -2582,16 +2566,6 @@ d_sqrtl (d_sqrtl.U): This variable conditionally defines the HAS_SQRTL symbol, which indicates to the C program that the sqrtl() routine is available. -d_srand48_r (d_srand48_r.U): - This variable conditionally defines the HAS_SRAND48_R symbol, - which indicates to the C program that the srand48_r() - routine is available. - -d_srandom_r (d_srandom_r.U): - This variable conditionally defines the HAS_SRANDOM_R symbol, - which indicates to the C program that the srandom_r() - routine is available. - d_sresgproto (d_sresgproto.U): This variable conditionally defines the HAS_SETRESGID_PROTO symbol, which indicates to the C program that the system provides @@ -3082,19 +3056,6 @@ doublesize (doublesize.U): This variable contains the value of the DOUBLESIZE symbol, which indicates to the C program how many bytes there are in a double. -drand01 (randfunc.U): - Indicates the macro to be used to generate normalized - random numbers. Uses randfunc, often divided by - (double) (((unsigned long) 1 << randbits)) in order to - normalize the result. - In C programs, the macro 'Drand01' is mapped to drand01. - -drand48_r_proto (d_drand48_r.U): - This variable encodes the prototype of drand48_r. - It is zero if d_drand48_r is undef, and one of the - REENTRANT_PROTO_T_ABC macros of reentr.h if d_drand48_r - is defined. - dtrace (usedtrace.U): This variable holds the location of the dtrace executable. @@ -4835,25 +4796,6 @@ quadtype (quadtype.U): This variable defines Quad_t to be something like long, int, long long, int64_t, or whatever type is used for 64-bit integers. -randbits (randfunc.U): - Indicates how many bits are produced by the function used to - generate normalized random numbers. - -randfunc (randfunc.U): - Indicates the name of the random number function to use. - Values include drand48, random, and rand. In C programs, - the 'Drand01' macro is defined to generate uniformly distributed - random numbers over the range [0., 1.[ (see drand01 and nrand). - -random_r_proto (d_random_r.U): - This variable encodes the prototype of random_r. - It is zero if d_random_r is undef, and one of the - REENTRANT_PROTO_T_ABC macros of reentr.h if d_random_r - is defined. - -randseedtype (randfunc.U): - Indicates the type of the argument of the seedfunc. - ranlib (orderlib.U): This variable is set to the pathname of the ranlib program, if it is needed to generate random libraries. Set to ":" if ar can generate @@ -4926,10 +4868,6 @@ sed (Loc.U): full pathname (if any) of the sed program. After Configure runs, the value is reset to a plain "sed" and is not useful. -seedfunc (randfunc.U): - Indicates the random number generating seed function. - Values include srand48, srandom, and srand. - selectminbits (selectminbits.U): This variable holds the minimum number of bits operated by select. That is, if you do select(n, ...), how many bits at least will be @@ -5323,18 +5261,6 @@ sPRIXU64 (quadfio.U): The 'U' in the name is to separate this from sPRIx64 so that even case-blind systems can see the difference. -srand48_r_proto (d_srand48_r.U): - This variable encodes the prototype of srand48_r. - It is zero if d_srand48_r is undef, and one of the - REENTRANT_PROTO_T_ABC macros of reentr.h if d_srand48_r - is defined. - -srandom_r_proto (d_srandom_r.U): - This variable encodes the prototype of srandom_r. - It is zero if d_srandom_r is undef, and one of the - REENTRANT_PROTO_T_ABC macros of reentr.h if d_srandom_r - is defined. - src (src.U): This variable holds the (possibly relative) path of the package source. It is up to the Makefile to use this variable and set VPATH accordingly diff --git a/Porting/config.sh b/Porting/config.sh index 57b5bd34bf58..a57183cb1852 100644 --- a/Porting/config.sh +++ b/Porting/config.sh @@ -188,8 +188,6 @@ d_double_style_cray='undef' d_double_style_ibm='undef' d_double_style_ieee='define' d_double_style_vax='undef' -d_drand48_r='define' -d_drand48proto='define' d_dup2='define' d_dup3='define' d_duplocale='define' @@ -475,7 +473,6 @@ d_pwquota='undef' d_qgcvt='define' d_quad='define' d_querylocale='undef' -d_random_r='define' d_re_comp='undef' d_readdir64_r='define' d_readdir='define' @@ -572,8 +569,6 @@ d_socklen_t='define' d_sockpair='define' d_socks5_init='undef' d_sqrtl='define' -d_srand48_r='define' -d_srandom_r='define' d_sresgproto='define' d_sresuproto='define' d_stat='define' @@ -681,8 +676,6 @@ doublekind='3' doublemantbits='52' doublenanbytes='0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0xff' doublesize='8' -drand01='Perl_drand48()' -drand48_r_proto='REENTRANT_PROTO_I_ST' dtrace='' dtraceobject='' dtracexnolibs='' @@ -1019,10 +1012,6 @@ procselfexe='"/proc/self/exe"' ptrsize='8' quadkind='2' quadtype='long' -randbits='48' -randfunc='Perl_drand48' -random_r_proto='REENTRANT_PROTO_I_St' -randseedtype='U32' ranlib=':' rd_nodata='-1' readdir64_r_proto='REENTRANT_PROTO_I_TSR' @@ -1054,7 +1043,6 @@ sched_yield='sched_yield()' scriptdir='/pro/bin' scriptdirexp='/pro/bin' sed='sed' -seedfunc='Perl_drand48_init' selectminbits='64' selecttype='fd_set *' sendmail='' @@ -1109,8 +1097,6 @@ socksizetype='socklen_t' sort='sort' spackage='Perl5' spitshell='cat' -srand48_r_proto='REENTRANT_PROTO_I_LS' -srandom_r_proto='REENTRANT_PROTO_I_TS' src='.' ssizetype='ssize_t' st_dev_sign='1' diff --git a/Porting/config_H b/Porting/config_H index 5e8847134f54..e148d514b5b1 100644 --- a/Porting/config_H +++ b/Porting/config_H @@ -1185,31 +1185,6 @@ */ #define PTRSIZE 8 /**/ -/* Drand01: - * This macro is to be used to generate uniformly distributed - * random numbers over the range [0., 1.[. You may have to supply - * an 'extern double drand48();' in your program since SunOS 4.1.3 - * doesn't provide you with anything relevant in its headers. - * See HAS_DRAND48_PROTO. - */ -/* Rand_seed_t: - * This symbol defines the type of the argument of the - * random seed function. - */ -/* seedDrand01: - * This symbol defines the macro to be used in seeding the - * random number generator (see Drand01). - */ -/* RANDBITS: - * This symbol indicates how many bits are produced by the - * function used to generate normalized random numbers. - * Values include 15, 16, 31, and 48. - */ -#define Drand01() Perl_drand48() /**/ -#define Rand_seed_t U32 /**/ -#define seedDrand01(x) Perl_drand48_init((Rand_seed_t)x) /**/ -#define RANDBITS 48 /**/ - /* SSize_t: * This symbol holds the type used by functions that return * a count of bytes or an error condition. It must be a signed type. @@ -4262,14 +4237,6 @@ /*#define USE_SOCKS / **/ #endif -/* HAS_DRAND48_PROTO: - * This symbol, if defined, indicates that the system provides - * a prototype for the drand48() function. Otherwise, it is up - * to the program to supply one. A good guess is - * extern double drand48(void); - */ -#define HAS_DRAND48_PROTO /**/ - /* HAS_GETHOST_PROTOS: * This symbol, if defined, indicates that includes * prototypes for gethostent(), gethostbyname(), and @@ -4405,19 +4372,6 @@ /*#define HAS_CTIME_R / **/ #define CTIME_R_PROTO 0 /**/ -/* HAS_DRAND48_R: - * This symbol, if defined, indicates that the drand48_r routine - * is available to drand48 re-entrantly. - */ -/* DRAND48_R_PROTO: - * This symbol encodes the prototype of drand48_r. - * It is zero if d_drand48_r is undef, and one of the - * REENTRANT_PROTO_T_ABC macros of reentr.h if d_drand48_r - * is defined. - */ -/*#define HAS_DRAND48_R / **/ -#define DRAND48_R_PROTO 0 /**/ - /* HAS_ENDGRENT_R: * This symbol, if defined, indicates that the endgrent_r routine * is available to endgrent re-entrantly. @@ -4854,19 +4808,6 @@ #define SCHED_YIELD sched_yield() /**/ #define HAS_SCHED_YIELD /**/ -/* HAS_RANDOM_R: - * This symbol, if defined, indicates that the random_r routine - * is available to random re-entrantly. - */ -/* RANDOM_R_PROTO: - * This symbol encodes the prototype of random_r. - * It is zero if d_random_r is undef, and one of the - * REENTRANT_PROTO_T_ABC macros of reentr.h if d_random_r - * is defined. - */ -/*#define HAS_RANDOM_R / **/ -#define RANDOM_R_PROTO 0 /**/ - /* HAS_READDIR64_R: * This symbol, if defined, indicates that the readdir64_r routine * is available to readdir64 re-entrantly. @@ -4984,32 +4925,6 @@ /*#define HAS_SETSERVENT_R / **/ #define SETSERVENT_R_PROTO 0 /**/ -/* HAS_SRAND48_R: - * This symbol, if defined, indicates that the srand48_r routine - * is available to srand48 re-entrantly. - */ -/* SRAND48_R_PROTO: - * This symbol encodes the prototype of srand48_r. - * It is zero if d_srand48_r is undef, and one of the - * REENTRANT_PROTO_T_ABC macros of reentr.h if d_srand48_r - * is defined. - */ -/*#define HAS_SRAND48_R / **/ -#define SRAND48_R_PROTO 0 /**/ - -/* HAS_SRANDOM_R: - * This symbol, if defined, indicates that the srandom_r routine - * is available to srandom re-entrantly. - */ -/* SRANDOM_R_PROTO: - * This symbol encodes the prototype of srandom_r. - * It is zero if d_srandom_r is undef, and one of the - * REENTRANT_PROTO_T_ABC macros of reentr.h if d_srandom_r - * is defined. - */ -/*#define HAS_SRANDOM_R / **/ -#define SRANDOM_R_PROTO 0 /**/ - /* HAS_STRERROR_R: * This symbol, if defined, indicates that the strerror_r routine * is available to strerror re-entrantly. diff --git a/Porting/findrfuncs b/Porting/findrfuncs index c9a7ff80a73d..a16d207eb81d 100755 --- a/Porting/findrfuncs +++ b/Porting/findrfuncs @@ -68,7 +68,6 @@ delete $rfuncs{setlocale_r} if $^O eq 'linux'; my $netdb_r_obsolete; if ($^O eq 'hpux') { delete $rfuncs{crypt_r}; - delete $rfuncs{drand48_r}; delete $rfuncs{endgrent_r}; delete $rfuncs{endpwent_r}; delete $rfuncs{getgrent_r}; diff --git a/config_h.SH b/config_h.SH index da0f2dbcd7b7..724347aefe65 100755 --- a/config_h.SH +++ b/config_h.SH @@ -1210,31 +1210,6 @@ sed <$CONFIG_H -e 's!^#undef\(.*/\)\*!/\*#define\1 \*!' -e 's!^#un */ #define PTRSIZE $ptrsize /**/ -/* Drand01: - * This macro is to be used to generate uniformly distributed - * random numbers over the range [0., 1.[. You may have to supply - * an 'extern double drand48();' in your program since SunOS 4.1.3 - * doesn't provide you with anything relevant in its headers. - * See HAS_DRAND48_PROTO. - */ -/* Rand_seed_t: - * This symbol defines the type of the argument of the - * random seed function. - */ -/* seedDrand01: - * This symbol defines the macro to be used in seeding the - * random number generator (see Drand01). - */ -/* RANDBITS: - * This symbol indicates how many bits are produced by the - * function used to generate normalized random numbers. - * Values include 15, 16, 31, and 48. - */ -#define Drand01() $drand01 /**/ -#define Rand_seed_t $randseedtype /**/ -#define seedDrand01(x) $seedfunc((Rand_seed_t)x) /**/ -#define RANDBITS $randbits /**/ - /* SSize_t: * This symbol holds the type used by functions that return * a count of bytes or an error condition. It must be a signed type. @@ -4455,14 +4430,6 @@ sed <$CONFIG_H -e 's!^#undef\(.*/\)\*!/\*#define\1 \*!' -e 's!^#un #$usesocks USE_SOCKS /**/ #endif -/* HAS_DRAND48_PROTO: - * This symbol, if defined, indicates that the system provides - * a prototype for the drand48() function. Otherwise, it is up - * to the program to supply one. A good guess is - * extern double drand48(void); - */ -#$d_drand48proto HAS_DRAND48_PROTO /**/ - /* HAS_GETHOST_PROTOS: * This symbol, if defined, indicates that includes * prototypes for gethostent(), gethostbyname(), and @@ -4598,19 +4565,6 @@ sed <$CONFIG_H -e 's!^#undef\(.*/\)\*!/\*#define\1 \*!' -e 's!^#un #$d_ctime_r HAS_CTIME_R /**/ #define CTIME_R_PROTO $ctime_r_proto /**/ -/* HAS_DRAND48_R: - * This symbol, if defined, indicates that the drand48_r routine - * is available to drand48 re-entrantly. - */ -/* DRAND48_R_PROTO: - * This symbol encodes the prototype of drand48_r. - * It is zero if d_drand48_r is undef, and one of the - * REENTRANT_PROTO_T_ABC macros of reentr.h if d_drand48_r - * is defined. - */ -#$d_drand48_r HAS_DRAND48_R /**/ -#define DRAND48_R_PROTO $drand48_r_proto /**/ - /* HAS_ENDGRENT_R: * This symbol, if defined, indicates that the endgrent_r routine * is available to endgrent re-entrantly. @@ -5057,19 +5011,6 @@ sed <$CONFIG_H -e 's!^#undef\(.*/\)\*!/\*#define\1 \*!' -e 's!^#un #define SCHED_YIELD $sched_yield /**/ #$d_sched_yield HAS_SCHED_YIELD /**/ -/* HAS_RANDOM_R: - * This symbol, if defined, indicates that the random_r routine - * is available to random re-entrantly. - */ -/* RANDOM_R_PROTO: - * This symbol encodes the prototype of random_r. - * It is zero if d_random_r is undef, and one of the - * REENTRANT_PROTO_T_ABC macros of reentr.h if d_random_r - * is defined. - */ -#$d_random_r HAS_RANDOM_R /**/ -#define RANDOM_R_PROTO $random_r_proto /**/ - /* HAS_READDIR64_R: * This symbol, if defined, indicates that the readdir64_r routine * is available to readdir64 re-entrantly. @@ -5187,32 +5128,6 @@ sed <$CONFIG_H -e 's!^#undef\(.*/\)\*!/\*#define\1 \*!' -e 's!^#un #$d_setservent_r HAS_SETSERVENT_R /**/ #define SETSERVENT_R_PROTO $setservent_r_proto /**/ -/* HAS_SRAND48_R: - * This symbol, if defined, indicates that the srand48_r routine - * is available to srand48 re-entrantly. - */ -/* SRAND48_R_PROTO: - * This symbol encodes the prototype of srand48_r. - * It is zero if d_srand48_r is undef, and one of the - * REENTRANT_PROTO_T_ABC macros of reentr.h if d_srand48_r - * is defined. - */ -#$d_srand48_r HAS_SRAND48_R /**/ -#define SRAND48_R_PROTO $srand48_r_proto /**/ - -/* HAS_SRANDOM_R: - * This symbol, if defined, indicates that the srandom_r routine - * is available to srandom re-entrantly. - */ -/* SRANDOM_R_PROTO: - * This symbol encodes the prototype of srandom_r. - * It is zero if d_srandom_r is undef, and one of the - * REENTRANT_PROTO_T_ABC macros of reentr.h if d_srandom_r - * is defined. - */ -#$d_srandom_r HAS_SRANDOM_R /**/ -#define SRANDOM_R_PROTO $srandom_r_proto /**/ - /* HAS_STRERROR_R: * This symbol, if defined, indicates that the strerror_r routine * is available to strerror re-entrantly. diff --git a/configure.com b/configure.com index 99527c180bfc..d53bf4b6f092 100644 --- a/configure.com +++ b/configure.com @@ -5270,17 +5270,10 @@ $ d_statvfs = "define" $ i_sysstatvfs = "define" $ endif $! -$! Check rand48 and its ilk +$! Perl now bundles its own RNG, we don't care about the system one. $! $ echo4 "Using our internal random number implementation..." $! -$ randfunc = "Perl_drand48" -$ drand01 = "Perl_drand48()" -$ seedfunc = "Perl_drand48_init" -$ randbits = "48" -$ randseedtype = "U32" -$ d_drand48proto = "define" -$! $! Done with compiler checks. Clean up. $ IF F$SEARCH("try.c") .NES."" THEN DELETE/NOLOG/NOCONFIRM try.c;* $ IF F$SEARCH("try.obj").NES."" THEN DELETE/NOLOG/NOCONFIRM try.obj;* @@ -5979,7 +5972,6 @@ $ WC "d_double_style_cray='undef'" $ WC "d_double_style_ibm='undef'" $ WC "d_double_style_ieee='" + d_double_style_ieee + "'" $ WC "d_double_style_vax='" + d_double_style_vax + "'" -$ WC "d_drand48proto='" + d_drand48proto + "'" $ WC "d_dup2='define'" $ WC "d_dup3='undef'" $ WC "d_duplocale='undef'" @@ -6460,7 +6452,6 @@ $ WC "doubleinfbytes='0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x7f'" $ WC "doublenanbytes='0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x7f'" $ WC "doublemantbits='" + doublemantbits + "'" $ WC "doublesize='" + doublesize + "'" -$ WC "drand01='" + drand01 + "'" $ WC "dtrace='" + "'" $! $! The dynamic_ext symbol may be quite long @@ -6704,7 +6695,6 @@ $ WC "prototype='define'" $ WC "ptrsize='" + ptrsize + "'" $ WC "quadkind='" + quadkind + "'" $ WC "quadtype='" + quadtype + "'" -$ WC "randbits='" + randbits + "'" $ WC "randfunc='" + randfunc + "'" $ WC "randseedtype='" + randseedtype + "'" $ WC "ranlib='" + "'" @@ -6730,7 +6720,6 @@ $ WC "sSCNfldbl='" + sSCNfldbl + "'" $ WC "sched_yield='" + sched_yield + "'" $ WC "scriptdir='" + scriptdir + "'" $ WC "scriptdirexp='" + scriptdir + "'" ! use scriptdir for now -$ WC "seedfunc='" + seedfunc + "'" $ WC "selectminbits='32'" $ WC "selecttype='" + selecttype + "'" $ WC "sh='MCR'" @@ -6884,7 +6873,6 @@ $ WC "d_ctime_r='undef'" $ ENDIF $ WC "d_crypt_r='undef'" $ WC "d_ctermid_r='undef'" -$ WC "d_drand48_r='undef'" $ WC "d_endgrent_r='undef'" $ WC "d_endhostent_r='undef'" $ WC "d_endnetent_r='undef'" @@ -6919,7 +6907,6 @@ $ WC "d_localtime_r='undef'" ! leave undef'd; we use my_localtime $ WC "d_localtime_r_needs_tzset='undef'" $ WC "d_newlocale='undef'" $ WC "d_querylocale='undef'" -$ WC "d_random_r='undef'" $ WC "d_readdir_r='define'" ! always defined; we roll our own $ WC "d_readdir64_r='undef'" $ WC "d_setgrent_r='undef'" @@ -6930,8 +6917,6 @@ $ WC "d_setprotoent_r='undef'" $ WC "d_setpwent_r='undef'" $ WC "d_setservent_r='undef'" $ WC "d_snprintf='" + d_snprintf + "'" -$ WC "d_srand48_r='undef'" -$ WC "d_srandom_r='undef'" $ WC "d_strerror_l='undef'" $ WC "d_strerror_r='undef'" $ WC "d_tmpnam_r='undef'" @@ -6941,7 +6926,6 @@ $ WC "d_ttyname_r='" + d_ttyname_r + "'" $ WC "d_uselocale='undef'" $ WC "ctermid_r_proto='0'" $ WC "crypt_r_proto='0'" -$ WC "drand48_r_proto='0'" $ WC "endgrent_r_proto='0'" $ WC "endhostent_r_proto='0'" $ WC "endnetent_r_proto='0'" @@ -6975,7 +6959,6 @@ $ WC "getservent_r_proto='0'" $ WC "getspnam_r_proto='0'" $ WC "gmtime_r_proto='0'" $ WC "localtime_r_proto='0'" -$ WC "random_r_proto='0'" $ WC "readdir_r_proto='REENTRANT_PROTO_I_TSR'" ! always defined; we roll our own $ WC "readdir64_r_proto='0'" $ WC "setgrent_r_proto='0'" @@ -6985,8 +6968,6 @@ $ WC "setnetent_r_proto='0'" $ WC "setprotoent_r_proto='0'" $ WC "setpwent_r_proto='0'" $ WC "setservent_r_proto='0'" -$ WC "srand48_r_proto='0'" -$ WC "srandom_r_proto='0'" $ WC "strerror_r_proto='0'" $ WC "tmpnam_r_proto='0'" $ WC "ttyname_r_proto='" + ttyname_r_proto + "'" diff --git a/embed.fnc b/embed.fnc index 6a977512583f..33e7131b2f80 100644 --- a/embed.fnc +++ b/embed.fnc @@ -1149,9 +1149,6 @@ p |void |do_vop |I32 optype \ |NN SV *left \ |NN SV *right CDRdp |U8 |dowantarray -TXop |void |drand48_init_r |NN perl_drand48_t *random_state \ - |U32 seed -TXop |double |drand48_r |NN perl_drand48_t *random_state Adp |void |dump_all p |void |dump_all_perl |bool justperl Adhp |void |dump_eval @@ -6284,6 +6281,18 @@ Tp |Signal_t|sighandler |int sig \ CTp |Signal_t|csighandler |int sig Tp |Signal_t|sighandler |int sig #endif +#if defined(PERL_USE_WELL512A_RNG) +TXop |double |drand01_wellrng512a_r \ + |NN U32 *random_state +TXop |void |wellrng512a_init_r \ + |NN U32 *random_state \ + |U32 seed +TXop |U32 |wellrng512a_u_r|NN U32 *random_state +#else +TXop |void |drand48_init_r |NN perl_drand48_t *random_state \ + |U32 seed +TXop |double |drand48_r |NN perl_drand48_t *random_state +#endif #if defined(U64TYPE) CRTip |unsigned|lsbit_pos64 |U64 word CRTip |unsigned|msbit_pos64 |U64 word diff --git a/embedvar.h b/embedvar.h index 085df4802814..0cd85d4b76b1 100644 --- a/embedvar.h +++ b/embedvar.h @@ -150,7 +150,6 @@ # define PL_initav (vTHX->Iinitav) # define PL_InMultiCharFold (vTHX->IInMultiCharFold) # define PL_inplace (vTHX->Iinplace) -# define PL_internal_random_state (vTHX->Iinternal_random_state) # define PL_isarev (vTHX->Iisarev) # define PL_known_layers (vTHX->Iknown_layers) # define PL_langinfo_sv (vTHX->Ilanginfo_sv) @@ -242,6 +241,7 @@ # define PL_psig_ptr (vTHX->Ipsig_ptr) # define PL_ptr_table (vTHX->Iptr_table) # define PL_random_state (vTHX->Irandom_state) +# define PL_random_state_internal (vTHX->Irandom_state_internal) # define PL_reentrant_buffer (vTHX->Ireentrant_buffer) # define PL_reentrant_retint (vTHX->Ireentrant_retint) # define PL_reg_curpm (vTHX->Ireg_curpm) diff --git a/handy.h b/handy.h index e2e5aa9e3e98..73f0695b564f 100644 --- a/handy.h +++ b/handy.h @@ -43,8 +43,9 @@ from it, and are very unlikely to change =for apidoc_defn Amu|token|CAT2|token x|token y =for apidoc_defn Amu|string|STRINGIFY|token x -=for apidoc_defn Am|double|Drand01 -=for apidoc_defn Am|void|seedDrand01|Rand_seed_t x +=for apidoc_defn AmT|double|Drand01 +=for apidoc_defn AmT|void|seedDrand01|Rand_seed_t x + =for apidoc_defn Am|char *|Gconvert|double x|Size_t n|bool t|char * b =cut diff --git a/hints/aix.sh b/hints/aix.sh index 279365c85bab..39a3f599923a 100644 --- a/hints/aix.sh +++ b/hints/aix.sh @@ -224,16 +224,12 @@ case "$ldlibpthname" in cat > UU/usethreads.cbu <<'EOCBU' case "$usethreads" in $define|true|[yY]*) - d_drand48_r='undef' d_endgrent_r='undef' d_endpwent_r='undef' d_getgrent_r='undef' d_getpwent_r='undef' - d_random_r='undef' d_setgrent_r='undef' d_setpwent_r='undef' - d_srand48_r='undef' - d_srandom_r='undef' d_strerror_r='undef' ccflags="$ccflags -DNEED_PTHREAD_INIT" diff --git a/hints/aix_3.sh b/hints/aix_3.sh index 95401beb315a..689fa0fac78e 100644 --- a/hints/aix_3.sh +++ b/hints/aix_3.sh @@ -219,15 +219,12 @@ case "$ldlibpthname" in cat > UU/usethreads.cbu <<'EOCBU' case "$usethreads" in $define|true|[yY]*) - d_drand48_r='undef' d_endgrent_r='undef' d_endpwent_r='undef' d_getgrent_r='undef' d_getpwent_r='undef' - d_random_r='undef' d_setgrent_r='undef' d_setpwent_r='undef' - d_srand48_r='undef' d_strerror_r='undef' ccflags="$ccflags -DNEED_PTHREAD_INIT" case "$cc" in diff --git a/hints/aix_4.sh b/hints/aix_4.sh index 08a689480a45..1d78fdb01f95 100644 --- a/hints/aix_4.sh +++ b/hints/aix_4.sh @@ -304,15 +304,12 @@ case "`oslevel`" in cat > UU/usethreads.cbu <<'EOCBU' case "$usethreads" in $define|true|[yY]*) - d_drand48_r='undef' d_endgrent_r='undef' d_endpwent_r='undef' d_getgrent_r='undef' d_getpwent_r='undef' - d_random_r='undef' d_setgrent_r='undef' d_setpwent_r='undef' - d_srand48_r='undef' d_strerror_r='undef' ccflags="$ccflags -DNEED_PTHREAD_INIT" diff --git a/intrpvar.h b/intrpvar.h index 921d15d38c95..d87d4ab9a3a4 100644 --- a/intrpvar.h +++ b/intrpvar.h @@ -1018,17 +1018,24 @@ PERLVARA(I, op_exec_cnt, OP_max+2, UV) /* Counts of executed OPs of the given t for profiling in DEBUGGING mode. */ #endif -PERLVAR(I, random_state, PL_RANDOM_STATE_TYPE) - PERLVARI(I, dump_re_max_len, STRLEN, 60) +#ifndef PERL_USE_WELL512A_RNG +PERLVAR(I, random_state, PL_RANDOM_STATE_TYPE) +#else +PERLVARA(I, random_state, PL_RANDOM_STATE_LENGTH, PL_RANDOM_STATE_TYPE) +#endif + /* For internal uses of randomness, this ensures the sequence of * random numbers returned by rand() isn't modified by perl's internal * use of randomness. * This is important if the user has called srand() with a seed. */ - -PERLVAR(I, internal_random_state, PL_RANDOM_STATE_TYPE) +#ifndef PERL_USE_WELL512A_RNG +PERLVAR(I, random_state_internal, PL_RANDOM_STATE_TYPE) +#else +PERLVARA(I, random_state_internal, PL_RANDOM_STATE_LENGTH, PL_RANDOM_STATE_TYPE) +#endif PERLVARA(I, TR_SPECIAL_HANDLING_UTF8, UTF8_MAXBYTES, char) diff --git a/makedef.pl b/makedef.pl index 538595086373..646ed25293ce 100644 --- a/makedef.pl +++ b/makedef.pl @@ -673,6 +673,19 @@ sub readvar { ); } +if (!$define{PERL_USE_WELL512A_RNG}) { + ++$skip{$_} foreach qw( + Perl_drand01_wellrng512a_r + Perl_wellrng512a_init_r + Perl_wellrng512a_u_r + ); +} else { + ++$skip{$_} foreach qw( + Perl_drand48_init_r + Perl_drand48_r + ); +} + # functions from *.sym files my @syms = qw(globvar.sym); diff --git a/perl.c b/perl.c index fdf5e9082264..3342d16d8112 100644 --- a/perl.c +++ b/perl.c @@ -288,7 +288,7 @@ perl_construct(pTHXx) /* This is NOT the state used for C, this is only * used in internal functionality */ #ifdef NO_PERL_INTERNAL_RAND_SEED - Perl_drand48_init_r(&PL_internal_random_state, seed()); + Perl_drand01_init_r(PL_PTR_RANDOM_STATE_INTERNAL, seed()); #else { UV seed; @@ -301,7 +301,7 @@ perl_construct(pTHXx) /* use a randomly generated seed */ seed = seed(); } - Perl_drand48_init_r(&PL_internal_random_state, (U32)seed); + Perl_drand01_init_r(PL_PTR_RANDOM_STATE_INTERNAL, (U32)seed); } #endif @@ -2070,6 +2070,10 @@ S_Internals_V(pTHX_ CV *cv) # ifdef PERL_USE_UNSHARED_KEYS_IN_LARGE_HASHES " PERL_USE_UNSHARED_KEYS_IN_LARGE_HASHES" # endif +# ifdef PERL_USE_WELL512A_RNG + " PERL_USE_WELL512A_RNG" +# endif + # ifdef SILENT_NO_TAINT_SUPPORT " SILENT_NO_TAINT_SUPPORT" # endif @@ -2475,7 +2479,7 @@ S_parse_body(pTHX_ char **env, XSINIT_t xsinit) if (TAINT_get && PerlProc_getuid() == PerlProc_geteuid() && PerlProc_getgid() == PerlProc_getegid()) { - Perl_drand48_init_r(&PL_internal_random_state, seed()); + Perl_drand01_init_r(PL_PTR_RANDOM_STATE_INTERNAL, seed()); } #endif if (DEBUG_h_TEST) diff --git a/perl.h b/perl.h index e4205477a107..938cf27ac5cb 100644 --- a/perl.h +++ b/perl.h @@ -9253,7 +9253,6 @@ END_EXTERN_C #define PERL_PARSE_ERROR_COUNT(f) (f) - /* Work around https://github.com/Perl/perl5/issues/21313 diff --git a/plan9/config.plan9 b/plan9/config.plan9 index a59a1893f830..3e3b678e0903 100644 --- a/plan9/config.plan9 +++ b/plan9/config.plan9 @@ -1144,27 +1144,6 @@ */ /*#define DLSYM_NEEDS_UNDERSCORE / **/ -/* HAS_DRAND48_R: - * This symbol, if defined, indicates that the drand48_r routine - * is available to drand48 re-entrantly. - */ -/* DRAND48_R_PROTO: - * This symbol encodes the prototype of drand48_r. - * It is zero if d_drand48_r is undef, and one of the - * REENTRANT_PROTO_T_ABC macros of reentr.h if d_drand48_r - * is defined. - */ -/*#define HAS_DRAND48_R / **/ -#define DRAND48_R_PROTO 0 /**/ - -/* HAS_DRAND48_PROTO: - * This symbol, if defined, indicates that the system provides - * a prototype for the drand48() function. Otherwise, it is up - * to the program to supply one. A good guess is - * extern double drand48(void); - */ -/*#define HAS_DRAND48_PROTO / **/ - /* HAS_ENDGRENT: * This symbol, if defined, indicates that the getgrent routine is * available for finalizing sequential access of the group database. @@ -2004,19 +1983,6 @@ #define SCHED_YIELD undef /**/ /*#define HAS_SCHED_YIELD / **/ -/* HAS_RANDOM_R: - * This symbol, if defined, indicates that the random_r routine - * is available to random re-entrantly. - */ -/* RANDOM_R_PROTO: - * This symbol encodes the prototype of random_r. - * It is zero if d_random_r is undef, and one of the - * REENTRANT_PROTO_T_ABC macros of reentr.h if d_random_r - * is defined. - */ -/*#define HAS_RANDOM_R / **/ -#define RANDOM_R_PROTO 0 /**/ - /* HAS_READDIR_R: * This symbol, if defined, indicates that the readdir_r routine * is available to readdir re-entrantly. @@ -2257,32 +2223,6 @@ */ /*#define HAS_SQRTL / **/ -/* HAS_SRAND48_R: - * This symbol, if defined, indicates that the srand48_r routine - * is available to srand48 re-entrantly. - */ -/* SRAND48_R_PROTO: - * This symbol encodes the prototype of srand48_r. - * It is zero if d_srand48_r is undef, and one of the - * REENTRANT_PROTO_T_ABC macros of reentr.h if d_srand48_r - * is defined. - */ -/*#define HAS_SRAND48_R / **/ -#define SRAND48_R_PROTO 0 /**/ - -/* HAS_SRANDOM_R: - * This symbol, if defined, indicates that the srandom_r routine - * is available to srandom re-entrantly. - */ -/* SRANDOM_R_PROTO: - * This symbol encodes the prototype of srandom_r. - * It is zero if d_srandom_r is undef, and one of the - * REENTRANT_PROTO_T_ABC macros of reentr.h if d_srandom_r - * is defined. - */ -/*#define HAS_SRANDOM_R / **/ -#define SRANDOM_R_PROTO 0 /**/ - /* USE_STAT_BLOCKS: * This symbol is defined if this system has a stat structure declaring * st_blksize and st_blocks. @@ -3244,31 +3184,6 @@ */ #define PTRSIZE 4 /**/ -/* Drand01: - * This macro is to be used to generate uniformly distributed - * random numbers over the range [0., 1.[. You may have to supply - * an 'extern double drand48();' in your program since SunOS 4.1.3 - * doesn't provide you with anything relevant in its headers. - * See HAS_DRAND48_PROTO. - */ -/* Rand_seed_t: - * This symbol defines the type of the argument of the - * random seed function. - */ -/* seedDrand01: - * This symbol defines the macro to be used in seeding the - * random number generator (see Drand01). - */ -/* RANDBITS: - * This symbol indicates how many bits are produced by the - * function used to generate normalized random numbers. - * Values include 15, 16, 31, and 48. - */ -#define Drand01() (rand() / (double) ((unsigned long)1 << 15)) /**/ -#define Rand_seed_t unsigned /**/ -#define seedDrand01(x) srand((Rand_seed_t)x) /**/ -#define RANDBITS 15 /**/ - /* SELECT_MIN_BITS: * This symbol holds the minimum number of bits operated by select. * That is, if you do select(n, ...), how many bits at least will be diff --git a/plan9/config_h.sample b/plan9/config_h.sample index 1720754dd86f..f1d143312923 100644 --- a/plan9/config_h.sample +++ b/plan9/config_h.sample @@ -1093,27 +1093,6 @@ */ /*#define DLSYM_NEEDS_UNDERSCORE / **/ -/* HAS_DRAND48_R: - * This symbol, if defined, indicates that the drand48_r routine - * is available to drand48 re-entrantly. - */ -/* DRAND48_R_PROTO: - * This symbol encodes the prototype of drand48_r. - * It is zero if d_drand48_r is undef, and one of the - * REENTRANT_PROTO_T_ABC macros of reentr.h if d_drand48_r - * is defined. - */ -/*#define HAS_DRAND48_R / **/ -#define DRAND48_R_PROTO 0 /**/ - -/* HAS_DRAND48_PROTO: - * This symbol, if defined, indicates that the system provides - * a prototype for the drand48() function. Otherwise, it is up - * to the program to supply one. A good guess is - * extern double drand48(void); - */ -/*#define HAS_DRAND48_PROTO / **/ - /* HAS_ENDGRENT: * This symbol, if defined, indicates that the getgrent routine is * available for finalizing sequential access of the group database. @@ -1913,19 +1892,6 @@ #define SCHED_YIELD undef /**/ /*#define HAS_SCHED_YIELD / **/ -/* HAS_RANDOM_R: - * This symbol, if defined, indicates that the random_r routine - * is available to random re-entrantly. - */ -/* RANDOM_R_PROTO: - * This symbol encodes the prototype of random_r. - * It is zero if d_random_r is undef, and one of the - * REENTRANT_PROTO_T_ABC macros of reentr.h if d_random_r - * is defined. - */ -/*#define HAS_RANDOM_R / **/ -#define RANDOM_R_PROTO 0 /**/ - /* HAS_READDIR_R: * This symbol, if defined, indicates that the readdir_r routine * is available to readdir re-entrantly. @@ -2145,32 +2111,6 @@ */ /*#define HAS_SQRTL / **/ -/* HAS_SRAND48_R: - * This symbol, if defined, indicates that the srand48_r routine - * is available to srand48 re-entrantly. - */ -/* SRAND48_R_PROTO: - * This symbol encodes the prototype of srand48_r. - * It is zero if d_srand48_r is undef, and one of the - * REENTRANT_PROTO_T_ABC macros of reentr.h if d_srand48_r - * is defined. - */ -/*#define HAS_SRAND48_R / **/ -#define SRAND48_R_PROTO 0 /**/ - -/* HAS_SRANDOM_R: - * This symbol, if defined, indicates that the srandom_r routine - * is available to srandom re-entrantly. - */ -/* SRANDOM_R_PROTO: - * This symbol encodes the prototype of srandom_r. - * It is zero if d_srandom_r is undef, and one of the - * REENTRANT_PROTO_T_ABC macros of reentr.h if d_srandom_r - * is defined. - */ -/*#define HAS_SRANDOM_R / **/ -#define SRANDOM_R_PROTO 0 /**/ - /* USE_STAT_BLOCKS: * This symbol is defined if this system has a stat structure declaring * st_blksize and st_blocks. @@ -3092,31 +3032,6 @@ */ #define PTRSIZE 4 /**/ -/* Drand01: - * This macro is to be used to generate uniformly distributed - * random numbers over the range [0., 1.[. You may have to supply - * an 'extern double drand48();' in your program since SunOS 4.1.3 - * doesn't provide you with anything relevant in its headers. - * See HAS_DRAND48_PROTO. - */ -/* Rand_seed_t: - * This symbol defines the type of the argument of the - * random seed function. - */ -/* seedDrand01: - * This symbol defines the macro to be used in seeding the - * random number generator (see Drand01). - */ -/* RANDBITS: - * This symbol indicates how many bits are produced by the - * function used to generate normalized random numbers. - * Values include 15, 16, 31, and 48. - */ -#define Drand01() (rand() / (double) ((unsigned long)1 << 15)) /**/ -#define Rand_seed_t unsigned /**/ -#define seedDrand01(x) srand((Rand_seed_t)x) /**/ -#define RANDBITS 15 /**/ - /* SELECT_MIN_BITS: * This symbol holds the minimum number of bits operated by select. * That is, if you do select(n, ...), how many bits at least will be @@ -3990,4 +3905,3 @@ #define TTYNAME_R_PROTO 0 /**/ #endif - diff --git a/plan9/config_sh.sample b/plan9/config_sh.sample index 6bf1765a9602..4b66b78e6761 100644 --- a/plan9/config_sh.sample +++ b/plan9/config_sh.sample @@ -177,8 +177,6 @@ d_double_style_cray='undef' d_double_style_ibm='undef' d_double_style_ieee='define' d_double_style_vax='undef' -d_drand48_r='undef' -d_drand48proto='undef' d_dup2='define' d_dup3='undef' d_duplocale='undef' @@ -462,7 +460,6 @@ d_pwquota='undef' d_qgcvt='undef' d_quad='define' d_querylocale='undef' -d_random_r='undef' d_readdir64_r='undef' d_readdir='define' d_readdir_r='undef' @@ -556,8 +553,6 @@ d_socklen_t='undef' d_sockpair='define' d_socks5_init='undef' d_sqrtl='undef' -d_srand48_r='undef' -d_srandom_r='undef' d_sresgproto='undef' d_sresuproto='undef' d_stat='define' @@ -664,8 +659,6 @@ doublekind='3' doublemantbits='52' doublenanbytes='0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x7f' doublesize='8' -drand01='(rand() / (double) ((unsigned long)1 << 15))' -drand48_r_proto='0' dtrace='' dynamic_ext='' eagain='EAGAIN' @@ -977,10 +970,6 @@ prototype='define' ptrsize='4' quadkind='3' quadtype='long long' -randbits='15' -randfunc='rand' -random_r_proto='0' -randseedtype='unsigned' ranlib=':' rd_nodata='-1' readdir64_r_proto='0' @@ -1011,7 +1000,6 @@ sched_yield='undef' scriptdir='/usr/bin' scriptdirexp='/usr/bin' sed='sed' -seedfunc='srand' selectminbits='32' selecttype='int *' sendmail='' @@ -1056,8 +1044,6 @@ socksizetype='int' sort='sort' spackage='Perl5' spitshell='cat' -srand48_r_proto='0' -srandom_r_proto='0' src='.' ssizetype='ssize_t' st_dev_sign='1' diff --git a/proto.h b/proto.h index 1e2a0fdb3ccc..ebac3c183f9e 100644 --- a/proto.h +++ b/proto.h @@ -1027,16 +1027,6 @@ Perl_dowantarray(pTHX) __attribute__warn_unused_result__; #define PERL_ARGS_ASSERT_DOWANTARRAY -PERL_CALLCONV void -Perl_drand48_init_r(perl_drand48_t *random_state, U32 seed); -#define PERL_ARGS_ASSERT_DRAND48_INIT_R \ - assert(random_state) - -PERL_CALLCONV double -Perl_drand48_r(perl_drand48_t *random_state); -#define PERL_ARGS_ASSERT_DRAND48_R \ - assert(random_state) - PERL_CALLCONV void Perl_dump_all(pTHX); #define PERL_ARGS_ASSERT_DUMP_ALL @@ -10502,6 +10492,34 @@ Perl_sighandler(int sig) # define PERL_ARGS_ASSERT_SIGHANDLER #endif /* !defined(PERL_USE_3ARG_SIGHANDLER) */ +#if defined(PERL_USE_WELL512A_RNG) +PERL_CALLCONV double +Perl_drand01_wellrng512a_r(U32 *random_state); +# define PERL_ARGS_ASSERT_DRAND01_WELLRNG512A_R \ + assert(random_state) + +PERL_CALLCONV void +Perl_wellrng512a_init_r(U32 *random_state, U32 seed); +# define PERL_ARGS_ASSERT_WELLRNG512A_INIT_R \ + assert(random_state) + +PERL_CALLCONV U32 +Perl_wellrng512a_u_r(U32 *random_state); +# define PERL_ARGS_ASSERT_WELLRNG512A_U_R \ + assert(random_state) + +#else /* if !defined(PERL_USE_WELL512A_RNG) */ +PERL_CALLCONV void +Perl_drand48_init_r(perl_drand48_t *random_state, U32 seed); +# define PERL_ARGS_ASSERT_DRAND48_INIT_R \ + assert(random_state) + +PERL_CALLCONV double +Perl_drand48_r(perl_drand48_t *random_state); +# define PERL_ARGS_ASSERT_DRAND48_R \ + assert(random_state) + +#endif /* !defined(PERL_USE_WELL512A_RNG) */ #if defined(U64TYPE) #endif diff --git a/regen/HeaderParser.pm b/regen/HeaderParser.pm index 8b166570fea7..ae9eae93fcfd 100644 --- a/regen/HeaderParser.pm +++ b/regen/HeaderParser.pm @@ -1564,6 +1564,14 @@ sub HeaderLine::new { return bless \%self, $class; } sub HeaderLine::cond { $_[0]->{cond} } # AoA +sub HeaderLine::cond_as_str { + my $cond= $_[0]->cond; + return "" unless $cond; + join " && ", map { + @$_ == 1 ? $_->[0] : + "( " . join(" && ", @$_) . " )" + } @$cond; +} sub HeaderLine::type { $_[0]->{type} } sub HeaderLine::type_is { return $_[0]->type eq $_[1] ? 1 : 0 } sub HeaderLine::sub_type { $_[0]->{sub_type} } diff --git a/regen/embed.pl b/regen/embed.pl index abbee02401fe..5b036ae9e405 100755 --- a/regen/embed.pl +++ b/regen/embed.pl @@ -457,11 +457,15 @@ sub readvars { foreach my $line_data (@{$hp->lines}) { #next unless $line_data->is_content; my $line= $line_data->line; + my $cond= $line_data->cond_as_str(); if ($line=~m/^\s*PERLVARA?I?C?\(\s*$pre\s*,\s*(\w+)/){ - $seen{$1}++ - and - die_at_end "duplicate symbol $1 while processing $file line " - . ($line_data->start_line_num) . "\n" + my $sym = $1; + my $with_cond = $cond ? " with condition $cond" : ""; + if ($seen{$sym}{$cond}++) { + die_at_end "duplicate symbol '$sym'$with_cond " + . "while processing $file line " + . ($line_data->start_line_num) . "\n"; + } } } my @keys= sort { lc($a) cmp lc($b) || diff --git a/regen/reentr.pl b/regen/reentr.pl index 4b13cc2a8ce7..6293c3435bdb 100644 --- a/regen/reentr.pl +++ b/regen/reentr.pl @@ -1205,10 +1205,7 @@ sub define { # As of February 2024, the config.h entries that have reentrant prototypes that # aren't in this file are: -# drand48 -# random -# srand48 -# srandom +# None at this time. # Additionally, these are the POSIX defined _r functions that aren't defined # getgrid_r # rand_r diff --git a/sv.c b/sv.c index 1b63d417a5f6..b2608d091b53 100644 --- a/sv.c +++ b/sv.c @@ -15918,7 +15918,10 @@ perl_clone_using(PerlInterpreter *proto_perl, UV flags, PL_globhook = proto_perl->Iglobhook; PL_srand_called = proto_perl->Isrand_called; - Copy(&(proto_perl->Irandom_state), &PL_random_state, 1, PL_RANDOM_STATE_TYPE); + Copy(PL_PTR_PROTO_RANDOM_STATE, PL_PTR_RANDOM_STATE, + PL_RANDOM_STATE_LENGTH, PL_RANDOM_STATE_TYPE); + Copy(PL_PTR_PROTO_RANDOM_STATE_INTERNAL, PL_PTR_RANDOM_STATE_INTERNAL, + PL_RANDOM_STATE_LENGTH, PL_RANDOM_STATE_TYPE); PL_srand_override = proto_perl->Isrand_override; PL_srand_override_next = proto_perl->Isrand_override_next; diff --git a/t/op/rand.t b/t/op/rand.t index 7a7f757b0312..801f4b5959cb 100644 --- a/t/op/rand.t +++ b/t/op/rand.t @@ -126,15 +126,19 @@ EOM srand 12345; is(rand(1), $r, 'rand() without args is rand(1)'); - # This checks that rand without an argument is not # rand($_). (In case somebody got overzealous.) # cmp_ok($r, '<', 1, 'rand() without args is under 1'); } -{ # [perl #115928] use a standard rand() implementation +if ($Config{ccflags}!~/PERL_USE_WELL512A_RNG/){ + # [perl #115928] use a standard rand() implementation srand(1); is(int rand(1000), 41, "our own implementation behaves consistently"); is(int rand(1000), 454, "and still consistently"); +} else { + srand(1); + is(int rand(1000), 133, "our implementation of WELLRNG512A behaves consistently"); + is(int rand(1000), 346, "and still consistently"); } diff --git a/t/run/runenv_randseed.t b/t/run/runenv_randseed.t index bdcf20269c5f..2164626da938 100644 --- a/t/run/runenv_randseed.t +++ b/t/run/runenv_randseed.t @@ -13,56 +13,91 @@ skip_all("This perl is built with NO_PERL_RAND_SEED") if $Config{ccflags} =~ /-DNO_PERL_RAND_SEED\b/; use strict; use warnings; +my $test_code = <<'EOF_TEST_CODE'; + for my $l ("A".."E") { + my $pid= fork; + if ($pid) { + push @pids, $pid; + } + elsif (!defined $pid) { + print "$l:failed fork"; + } elsif (!$pid) { + print "$l:", map { chr(utf8::unicode_to_native(rand(26)+65)) } 1..10; + exit; + } + } + waitpid $_,0 for @pids; +EOF_TEST_CODE -for (1..2) { - local $ENV{PERL_RAND_SEED} = 1; - fresh_perl_is("print map { chr(utf8::unicode_to_native(rand(26)+65)) } 1..10", - "BLVIOAEZTJ", undef, "Test randomness with PERL_RAND_SEED=1"); -} +if ($Config{ccflags}!~/PERL_USE_WELL512A_RNG/){ + for (1..2) { + local $ENV{PERL_RAND_SEED} = 1; + fresh_perl_is("print map { chr(utf8::unicode_to_native(rand(26)+65)) } 1..10", + "BLVIOAEZTJ", undef, "Test randomness with PERL_RAND_SEED=1"); + } -for (1..2) { - local $ENV{PERL_RAND_SEED} = 2; - fresh_perl_is("print map { chr(utf8::unicode_to_native(rand(26)+65)) } 1..10", - "XEOUOFRPQZ", undef, "Test randomness with PERL_RAND_SEED=2"); -} + for (1..2) { + local $ENV{PERL_RAND_SEED} = 2; + fresh_perl_is("print map { chr(utf8::unicode_to_native(rand(26)+65)) } 1..10", + "XEOUOFRPQZ", undef, "Test randomness with PERL_RAND_SEED=2"); + } -my %got; -for my $try (1..10) { - local $ENV{PERL_RAND_SEED}; - my ($out,$err)= runperl_and_capture({}, ['-e',"print map { chr(rand(26)+65) } 1..10;"]); - if ($err) { diag $err } - $got{$out}++; -} -ok(8 <= keys %got, "Got at least 8 different strings"); -for (1..2) { - local $ENV{PERL_RAND_SEED} = 1; - my ($out,$err)= runperl_and_capture({}, ['-le', - <<'EOF_TEST_CODE' - for my $l ("A".."E") { - my $pid= fork; - if ($pid) { - push @pids, $pid; - } - elsif (!defined $pid) { - print "$l:failed fork"; - } elsif (!$pid) { - print "$l:", map { chr(utf8::unicode_to_native(rand(26)+65)) } 1..10; - exit; - } - } - waitpid $_,0 for @pids; -EOF_TEST_CODE - ]); - is($err, "", "No exceptions forking."); - my @parts= sort { $a cmp $b } split /\n/, $out; - my @want= ( - "A:KNXDITWWJZ", - "B:WDQJGTBJQS", - "C:ZGYCCINIHE", - "D:UGLGAEXFBP", - "E:MQLTNZGZQB" - ); - is("@parts","@want","Works as expected with forks."); -} + my %got; + for my $try (1..10) { + local $ENV{PERL_RAND_SEED}; + my ($out,$err)= runperl_and_capture({}, ['-e',"print map { chr(rand(26)+65) } 1..10;"]); + if ($err) { diag $err } + $got{$out}++; + } + ok(8 <= keys %got, "Got at least 8 different strings"); + for (1..2) { + local $ENV{PERL_RAND_SEED} = 1; + my ($out,$err)= runperl_and_capture({}, ['-le', $test_code]); + is($err, "", "No exceptions forking."); + my @parts= sort { $a cmp $b } split /\n/, $out; + my @want= ( + "A:KNXDITWWJZ", + "B:WDQJGTBJQS", + "C:ZGYCCINIHE", + "D:UGLGAEXFBP", + "E:MQLTNZGZQB" + ); + is("@parts","@want","Works as expected with forks."); + } +} else { + for (1..2) { + local $ENV{PERL_RAND_SEED} = 1; + fresh_perl_is("print map { chr(utf8::unicode_to_native(rand(26)+65)) } 1..10", + "DJSFVUOCEP", undef, "Test randomness with PERL_RAND_SEED=1"); + } + for (1..2) { + local $ENV{PERL_RAND_SEED} = 2; + fresh_perl_is("print map { chr(utf8::unicode_to_native(rand(26)+65)) } 1..10", + "HYLBKECYNV", undef, "Test randomness with PERL_RAND_SEED=2"); + } + + my %got; + for my $try (1..10) { + local $ENV{PERL_RAND_SEED}; + my ($out,$err)= runperl_and_capture({}, ['-e',"print map { chr(rand(26)+65) } 1..10;"]); + if ($err) { diag $err } + $got{$out}++; + } + ok(8 <= keys %got, "Got at least 8 different strings"); + for (1..2) { + local $ENV{PERL_RAND_SEED} = 1; + my ($out,$err)= runperl_and_capture({}, ['-le', $test_code]); + is($err, "", "No exceptions forking."); + my @parts= sort { $a cmp $b } split /\n/, $out; + my @want= ( + "A:GPYNXCIGON", + "B:FAIKJCRQID", + "C:TOSQBPNSUS", + "D:POQSAQWNFD", + "E:LXUSDWIRZB" + ); + is("@parts","@want","Works as expected with forks."); + } +} done_testing(); diff --git a/util.c b/util.c index b21cd5ce6cff..cc7ceaf9abd5 100644 --- a/util.c +++ b/util.c @@ -4809,7 +4809,7 @@ Perl_get_hash_seed(pTHX_ unsigned char * const seed_buffer) #endif /* NO_PERL_HASH_ENV */ { for( i = 0; i < PERL_HASH_SEED_BYTES; i++ ) { - seed_buffer[i] = (unsigned char)(Perl_internal_drand48() * (U8_MAX+1)); + seed_buffer[i] = (unsigned char)(Perl_drand01_internal() * (U8_MAX+1)); } } #ifdef USE_PERL_PERTURB_KEYS @@ -5810,7 +5810,7 @@ S_my_mkostemp(char *templte, int flags) { do { int i; for (i = 1; i <= 6; ++i) { - templte[len-i] = TEMP_FILE_CH[(int)(Perl_internal_drand48() * TEMP_FILE_CH_COUNT)]; + templte[len-i] = TEMP_FILE_CH[(int)(Perl_drand01_internal() * TEMP_FILE_CH_COUNT)]; } #ifdef VMS if (delete_on_close) { @@ -5879,6 +5879,8 @@ Perl_get_re_arg(pTHX_ SV *sv) { return NULL; } +#ifndef PERL_USE_WELL512A_RNG + /* * This code is derived from drand48() implementation from FreeBSD, * found in lib/libc/gen/_rand48.c. @@ -5977,6 +5979,66 @@ Perl_drand48_r(perl_drand48_t *random_state) #endif } +#else + +void +Perl_wellrng512a_init_r(U32 *random_state, U32 seed) +{ + PERL_ARGS_ASSERT_WELLRNG512A_INIT_R; + random_state[0] = seed; + if (!seed) seed |= 1; + for (int i=1; i<16; i++) { + /* we take a 32 bit seed and use a Marsaglia Xorshift randomizer + * to turn it into a buffer worth of state. So we only support + * 2**32 sequences, but they will all be different */ + PERL_XORSHIFT32_A(seed); + random_state[i] = seed; + } + random_state[16] = 0; +} + +U32 +Perl_wellrng512a_u_r(U32 *random_state) +{ + PERL_ARGS_ASSERT_WELLRNG512A_U_R; + + const U32 WELL512a_MASK = 0xDA442D24UL; + U32 index = random_state[16]; + U32 a = random_state[index]; + U32 c = random_state[ ( index + 13 ) & 15 ]; + U32 b = a ^ c ^ ( a << 16 ) ^ ( c << 15 ); + c = random_state[ ( index + 9 ) & 15 ]; + c ^= ( c >> 11 ); + a = random_state[index] = b ^ c; + U32 d = a ^ ( (a << 5 ) & WELL512a_MASK ); + index = (index + 15) & 15; + random_state[16] = index; + a = random_state[index]; + random_state[index] = a ^ b ^ d ^ ( a << 2 ) ^ ( b << 18 ) ^ ( c << 28 ); + + return random_state[index]; +} + +double +Perl_drand01_wellrng512a_r(U32 *random_state) +{ + PERL_ARGS_ASSERT_DRAND01_WELLRNG512A_R; + +#ifdef PERL_DRAND48_QUAD + U64 i = Perl_wellrng512a_u_r(random_state); + i = (i << 32) | Perl_wellrng512a_u_r(random_state); + i = i >> 11; + return ldexp((double)i, -53); +#else + U32 a = Perl_wellrng512a_u_r(random_state); + U32 b = Perl_wellrng512a_u_r(random_state) >> 11; + return ldexp((double)a,-32) + ldexp((double)b,-53); +#endif +} + +#endif + + #ifdef USE_C_BACKTRACE /* Possibly move all this USE_C_BACKTRACE code into a new file. */ diff --git a/util.h b/util.h index 9ef5e38fcbb0..79ee8dd44b65 100644 --- a/util.h +++ b/util.h @@ -51,6 +51,10 @@ Hence, for example, C is S> #define ibcmp_utf8(s1, pe1, l1, u1, s2, pe2, l2, u2) \ cBOOL(! foldEQ_utf8(s1, pe1, l1, u1, s2, pe2, l2, u2)) + + +#ifndef PERL_USE_WELL512A_RNG + /* outside the core, perl.h undefs HAS_QUAD if IV isn't 64-bit We can't swap this to HAS_QUAD, because the logic here affects the type of perl_drand48_t below, and that is visible outside of the core. */ @@ -59,6 +63,13 @@ Hence, for example, C is S> # define PERL_DRAND48_QUAD #endif +#define PL_PTR_RANDOM_STATE &PL_random_state +#define PL_PTR_RANDOM_STATE_INTERNAL &PL_random_state_internal +#define PL_PTR_PROTO_RANDOM_STATE &(proto_perl->Irandom_state) +#define PL_PTR_PROTO_RANDOM_STATE_INTERNAL &(proto_perl->Irandom_state_internal) + +#define PL_RANDOM_STATE_LENGTH 1 + #ifdef PERL_DRAND48_QUAD /* U64 is only defined under PERL_CORE, but this needs to be visible @@ -76,17 +87,56 @@ typedef struct PERL_DRAND48_T perl_drand48_t; #endif + #define PL_RANDOM_STATE_TYPE perl_drand48_t -#define Perl_drand48_init(seed) (Perl_drand48_init_r(&PL_random_state, (seed))) -#define Perl_drand48() (Perl_drand48_r(&PL_random_state)) + +#define Perl_drand01_init_r(state,seed) (Perl_drand48_init_r((state), (seed))) +#define Perl_drand01_r(state) (Perl_drand48_r(state)) + + +#else +/* stuff we need to use WELLRNG512 instead of Drand48 */ + +#define PL_PTR_RANDOM_STATE PL_random_state +#define PL_PTR_RANDOM_STATE_INTERNAL PL_random_state_internal +#define PL_PTR_PROTO_RANDOM_STATE proto_perl->Irandom_state +#define PL_PTR_PROTO_RANDOM_STATE_INTERNAL proto_perl->Irandom_state_internal + +#define PL_RANDOM_STATE_LENGTH 17 + +#define PL_RANDOM_STATE_TYPE U32 + +#define Perl_drand01_init_r(state,seed) (Perl_wellrng512a_init_r(state, (seed))) +#define Perl_drand01_r(state) (Perl_drand01_wellrng512a_r(state)) + +#endif + +#define Perl_drand01_init(seed) (Perl_drand01_init_r(PL_PTR_RANDOM_STATE, (seed))) +#define Perl_drand01() (Perl_drand01_r(PL_PTR_RANDOM_STATE)) #ifdef PERL_CORE /* uses a different source of randomness to avoid interfering with the results * of rand() */ -#define Perl_internal_drand48() (Perl_drand48_r(&PL_internal_random_state)) +#define Perl_drand01_internal() (Perl_drand01_r(PL_PTR_RANDOM_STATE_INTERNAL)) #endif +/* +=for apidoc_section $numeric + +=for apidoc Drand01 +This macro is to be used to generate uniformly distributed +random numbers over the interval [0.0, 1.0) +=for apidoc seedDrand01 +This symbol defines the macro to be used in seeding the +random number generator (see Drand01). +=cut +*/ + +#define Drand01() Perl_drand01() +#define Rand_seed_t U32 +#define seedDrand01(x) Perl_drand01_init((Rand_seed_t)x) + #ifdef USE_C_BACKTRACE typedef struct { diff --git a/win32/config.gc b/win32/config.gc index d0a675e50177..93157da8bf42 100644 --- a/win32/config.gc +++ b/win32/config.gc @@ -164,8 +164,6 @@ d_double_style_cray='undef' d_double_style_ibm='undef' d_double_style_ieee='define' d_double_style_vax='undef' -d_drand48_r='undef' -d_drand48proto='undef' d_dup2='define' d_dup3='undef' d_duplocale='undef' @@ -451,7 +449,6 @@ d_pwquota='undef' d_qgcvt='undef' d_quad='define' d_querylocale='undef' -d_random_r='undef' d_readdir64_r='undef' d_readdir='define' d_readdir_r='undef' @@ -545,8 +542,6 @@ d_socklen_t='undef' d_sockpair='undef' d_socks5_init='undef' d_sqrtl='define' -d_srand48_r='undef' -d_srandom_r='undef' d_sresgproto='undef' d_sresuproto='undef' d_stat='define' @@ -655,8 +650,6 @@ doublekind='3' doublemantbits='52' doublenanbytes='0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x7f' doublesize='8' -drand01='Perl_drand48()' -drand48_r_proto='0' dtrace='' dynamic_ext='Socket IO Fcntl Opcode SDBM_File attributes' eagain='EAGAIN' @@ -990,10 +983,6 @@ prototype='define' ptrsize='4' quadkind='3' quadtype='long long' -randbits='48' -randfunc='Perl_drand48' -random_r_proto='0' -randseedtype='U32' ranlib='rem' rd_nodata='-1' readdir64_r_proto='0' @@ -1025,7 +1014,6 @@ sched_yield='' scriptdir='~INST_TOP~~INST_VER~\bin' scriptdirexp='~INST_TOP~~INST_VER~\bin' sed='sed' -seedfunc='Perl_drand48_init' selectminbits='32' selecttype='Perl_fd_set *' sendmail='blat' @@ -1080,8 +1068,6 @@ socksizetype='int' sort='sort' spackage='Perl5' spitshell='' -srand48_r_proto='0' -srandom_r_proto='0' src='' ssizetype='int' st_dev_sign='1' diff --git a/win32/config.vc b/win32/config.vc index 619979e22b53..510d276b03d1 100644 --- a/win32/config.vc +++ b/win32/config.vc @@ -164,8 +164,6 @@ d_double_style_cray='undef' d_double_style_ibm='undef' d_double_style_ieee='define' d_double_style_vax='undef' -d_drand48_r='undef' -d_drand48proto='undef' d_dup2='define' d_dup3='undef' d_duplocale='undef' @@ -451,7 +449,6 @@ d_pwquota='undef' d_qgcvt='undef' d_quad='define' d_querylocale='undef' -d_random_r='undef' d_readdir64_r='undef' d_readdir='define' d_readdir_r='undef' @@ -545,8 +542,6 @@ d_socklen_t='undef' d_sockpair='undef' d_socks5_init='undef' d_sqrtl='undef' -d_srand48_r='undef' -d_srandom_r='undef' d_sresgproto='undef' d_sresuproto='undef' d_stat='define' @@ -654,8 +649,6 @@ doublekind='3' doublemantbits='52' doublenanbytes='0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x7f' doublesize='8' -drand01='Perl_drand48()' -drand48_r_proto='0' dtrace='' dynamic_ext='Socket IO Fcntl Opcode SDBM_File attributes' eagain='EAGAIN' @@ -989,10 +982,6 @@ prototype='define' ptrsize='4' quadkind='5' quadtype='__int64' -randbits='48' -randfunc='Perl_drand48' -random_r_proto='0' -randseedtype='U32' ranlib='rem' rd_nodata='-1' readdir64_r_proto='0' @@ -1024,7 +1013,6 @@ sched_yield='' scriptdir='~INST_TOP~~INST_VER~\bin' scriptdirexp='~INST_TOP~~INST_VER~\bin' sed='sed' -seedfunc='Perl_drand48_init' selectminbits='32' selecttype='Perl_fd_set *' sendmail='blat' @@ -1079,8 +1067,6 @@ socksizetype='int' sort='sort' spackage='Perl5' spitshell='' -srand48_r_proto='0' -srandom_r_proto='0' src='' ssizetype='int' st_dev_sign='1' diff --git a/win32/config_H.gc b/win32/config_H.gc index 9730cd6eb753..4371299c1710 100644 --- a/win32/config_H.gc +++ b/win32/config_H.gc @@ -1175,31 +1175,6 @@ */ #define PTRSIZE 8 /**/ -/* Drand01: - * This macro is to be used to generate uniformly distributed - * random numbers over the range [0., 1.[. You may have to supply - * an 'extern double drand48();' in your program since SunOS 4.1.3 - * doesn't provide you with anything relevant in its headers. - * See HAS_DRAND48_PROTO. - */ -/* Rand_seed_t: - * This symbol defines the type of the argument of the - * random seed function. - */ -/* seedDrand01: - * This symbol defines the macro to be used in seeding the - * random number generator (see Drand01). - */ -/* RANDBITS: - * This symbol indicates how many bits are produced by the - * function used to generate normalized random numbers. - * Values include 15, 16, 31, and 48. - */ -#define Drand01() Perl_drand48() /**/ -#define Rand_seed_t U32 /**/ -#define seedDrand01(x) Perl_drand48_init((Rand_seed_t)x) /**/ -#define RANDBITS 48 /**/ - /* SSize_t: * This symbol holds the type used by functions that return * a count of bytes or an error condition. It must be a signed type. @@ -4420,14 +4395,6 @@ /*#define USE_SOCKS / **/ #endif -/* HAS_DRAND48_PROTO: - * This symbol, if defined, indicates that the system provides - * a prototype for the drand48() function. Otherwise, it is up - * to the program to supply one. A good guess is - * extern double drand48(void); - */ -/*#define HAS_DRAND48_PROTO / **/ - /* HAS_GETHOST_PROTOS: * This symbol, if defined, indicates that includes * prototypes for gethostent(), gethostbyname(), and @@ -4563,19 +4530,6 @@ /*#define HAS_CTIME_R / **/ #define CTIME_R_PROTO 0 /**/ -/* HAS_DRAND48_R: - * This symbol, if defined, indicates that the drand48_r routine - * is available to drand48 re-entrantly. - */ -/* DRAND48_R_PROTO: - * This symbol encodes the prototype of drand48_r. - * It is zero if d_drand48_r is undef, and one of the - * REENTRANT_PROTO_T_ABC macros of reentr.h if d_drand48_r - * is defined. - */ -/*#define HAS_DRAND48_R / **/ -#define DRAND48_R_PROTO 0 /**/ - /* HAS_ENDGRENT_R: * This symbol, if defined, indicates that the endgrent_r routine * is available to endgrent re-entrantly. @@ -5022,19 +4976,6 @@ #define SCHED_YIELD /**/ /*#define HAS_SCHED_YIELD / **/ -/* HAS_RANDOM_R: - * This symbol, if defined, indicates that the random_r routine - * is available to random re-entrantly. - */ -/* RANDOM_R_PROTO: - * This symbol encodes the prototype of random_r. - * It is zero if d_random_r is undef, and one of the - * REENTRANT_PROTO_T_ABC macros of reentr.h if d_random_r - * is defined. - */ -/*#define HAS_RANDOM_R / **/ -#define RANDOM_R_PROTO 0 /**/ - /* HAS_READDIR64_R: * This symbol, if defined, indicates that the readdir64_r routine * is available to readdir64 re-entrantly. @@ -5152,32 +5093,6 @@ /*#define HAS_SETSERVENT_R / **/ #define SETSERVENT_R_PROTO 0 /**/ -/* HAS_SRAND48_R: - * This symbol, if defined, indicates that the srand48_r routine - * is available to srand48 re-entrantly. - */ -/* SRAND48_R_PROTO: - * This symbol encodes the prototype of srand48_r. - * It is zero if d_srand48_r is undef, and one of the - * REENTRANT_PROTO_T_ABC macros of reentr.h if d_srand48_r - * is defined. - */ -/*#define HAS_SRAND48_R / **/ -#define SRAND48_R_PROTO 0 /**/ - -/* HAS_SRANDOM_R: - * This symbol, if defined, indicates that the srandom_r routine - * is available to srandom re-entrantly. - */ -/* SRANDOM_R_PROTO: - * This symbol encodes the prototype of srandom_r. - * It is zero if d_srandom_r is undef, and one of the - * REENTRANT_PROTO_T_ABC macros of reentr.h if d_srandom_r - * is defined. - */ -/*#define HAS_SRANDOM_R / **/ -#define SRANDOM_R_PROTO 0 /**/ - /* HAS_STRERROR_R: * This symbol, if defined, indicates that the strerror_r routine * is available to strerror re-entrantly. diff --git a/win32/config_H.vc b/win32/config_H.vc index 9a50246dce2f..444e665c58c1 100644 --- a/win32/config_H.vc +++ b/win32/config_H.vc @@ -1175,31 +1175,6 @@ */ #define PTRSIZE 8 /**/ -/* Drand01: - * This macro is to be used to generate uniformly distributed - * random numbers over the range [0., 1.[. You may have to supply - * an 'extern double drand48();' in your program since SunOS 4.1.3 - * doesn't provide you with anything relevant in its headers. - * See HAS_DRAND48_PROTO. - */ -/* Rand_seed_t: - * This symbol defines the type of the argument of the - * random seed function. - */ -/* seedDrand01: - * This symbol defines the macro to be used in seeding the - * random number generator (see Drand01). - */ -/* RANDBITS: - * This symbol indicates how many bits are produced by the - * function used to generate normalized random numbers. - * Values include 15, 16, 31, and 48. - */ -#define Drand01() Perl_drand48() /**/ -#define Rand_seed_t U32 /**/ -#define seedDrand01(x) Perl_drand48_init((Rand_seed_t)x) /**/ -#define RANDBITS 48 /**/ - /* SSize_t: * This symbol holds the type used by functions that return * a count of bytes or an error condition. It must be a signed type. @@ -4420,14 +4395,6 @@ /*#define USE_SOCKS / **/ #endif -/* HAS_DRAND48_PROTO: - * This symbol, if defined, indicates that the system provides - * a prototype for the drand48() function. Otherwise, it is up - * to the program to supply one. A good guess is - * extern double drand48(void); - */ -/*#define HAS_DRAND48_PROTO / **/ - /* HAS_GETHOST_PROTOS: * This symbol, if defined, indicates that includes * prototypes for gethostent(), gethostbyname(), and @@ -4563,19 +4530,6 @@ /*#define HAS_CTIME_R / **/ #define CTIME_R_PROTO 0 /**/ -/* HAS_DRAND48_R: - * This symbol, if defined, indicates that the drand48_r routine - * is available to drand48 re-entrantly. - */ -/* DRAND48_R_PROTO: - * This symbol encodes the prototype of drand48_r. - * It is zero if d_drand48_r is undef, and one of the - * REENTRANT_PROTO_T_ABC macros of reentr.h if d_drand48_r - * is defined. - */ -/*#define HAS_DRAND48_R / **/ -#define DRAND48_R_PROTO 0 /**/ - /* HAS_ENDGRENT_R: * This symbol, if defined, indicates that the endgrent_r routine * is available to endgrent re-entrantly. @@ -5022,19 +4976,6 @@ #define SCHED_YIELD /**/ /*#define HAS_SCHED_YIELD / **/ -/* HAS_RANDOM_R: - * This symbol, if defined, indicates that the random_r routine - * is available to random re-entrantly. - */ -/* RANDOM_R_PROTO: - * This symbol encodes the prototype of random_r. - * It is zero if d_random_r is undef, and one of the - * REENTRANT_PROTO_T_ABC macros of reentr.h if d_random_r - * is defined. - */ -/*#define HAS_RANDOM_R / **/ -#define RANDOM_R_PROTO 0 /**/ - /* HAS_READDIR64_R: * This symbol, if defined, indicates that the readdir64_r routine * is available to readdir64 re-entrantly. @@ -5152,32 +5093,6 @@ /*#define HAS_SETSERVENT_R / **/ #define SETSERVENT_R_PROTO 0 /**/ -/* HAS_SRAND48_R: - * This symbol, if defined, indicates that the srand48_r routine - * is available to srand48 re-entrantly. - */ -/* SRAND48_R_PROTO: - * This symbol encodes the prototype of srand48_r. - * It is zero if d_srand48_r is undef, and one of the - * REENTRANT_PROTO_T_ABC macros of reentr.h if d_srand48_r - * is defined. - */ -/*#define HAS_SRAND48_R / **/ -#define SRAND48_R_PROTO 0 /**/ - -/* HAS_SRANDOM_R: - * This symbol, if defined, indicates that the srandom_r routine - * is available to srandom re-entrantly. - */ -/* SRANDOM_R_PROTO: - * This symbol encodes the prototype of srandom_r. - * It is zero if d_srandom_r is undef, and one of the - * REENTRANT_PROTO_T_ABC macros of reentr.h if d_srandom_r - * is defined. - */ -/*#define HAS_SRANDOM_R / **/ -#define SRANDOM_R_PROTO 0 /**/ - /* HAS_STRERROR_R: * This symbol, if defined, indicates that the strerror_r routine * is available to strerror re-entrantly.