Math-Random-MT-Auto-6.23/0000755000175000001440000000000013377133764014501 5ustar jdheddenusersMath-Random-MT-Auto-6.23/META.json0000664000175000001440000000240513377133764016125 0ustar jdheddenusers{ "abstract" : "Auto-seeded Mersenne Twister PRNGs", "author" : [ "Jerry D. Hedden " ], "dynamic_config" : 1, "generated_by" : "ExtUtils::MakeMaker version 7.34, CPAN::Meta::Converter version 2.150010", "license" : [ "unrestricted" ], "meta-spec" : { "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec", "version" : 2 }, "name" : "Math-Random-MT-Auto", "no_index" : { "directory" : [ "t", "inc" ] }, "prereqs" : { "build" : { "requires" : { "ExtUtils::MakeMaker" : "0" } }, "configure" : { "requires" : { "ExtUtils::MakeMaker" : "0" } }, "runtime" : { "requires" : { "Carp" : "0", "Config" : "0", "Data::Dumper" : "0", "Exception::Class" : "1.32", "Fcntl" : "0", "Object::InsideOut" : "3.88", "Scalar::Util" : "1.23", "Test::More" : "0", "XSLoader" : "0", "strict" : "0", "warnings" : "0" } } }, "release_status" : "stable", "version" : "6.23", "x_serialization_backend" : "JSON::PP version 2.97001" } Math-Random-MT-Auto-6.23/Changes0000644000175000001440000001522613377133756016003 0ustar jdheddenusersRevision history for Perl extension Math::Random::MT::Auto. 6.23 Tue Nov 27 03:12:07 2018 - Fix for non-threaded Perl (rt.cpan.org #127809) 6.22 Tue Sep 4 14:06:20 2012 - Enhancement to shuffle() to return an array 6.21 Mon Aug 6 17:27:37 2012 - Haiku does not support non-blocking IO 6.19 Fri Jul 27 00:48:20 2012 - Prevent use of incompatible state vectors 6.18 Thu Jan 26 14:58:57 2012 - Ignore warnings from other modules during tests 6.17 Wed Jan 11 05:55:09 2012 - Require OIO 3.85 to fix some 'used only once' warnings 6.16 Fri Dec 24 15:26:40 2010 - POD update 6.15 Fri Mar 5 18:06:27 2010 - Explicitly require Win32 where needed - Upgraded ppport.h to Devel::PPPort 3.19 6.14 Wed Jun 11 16:44:48 2008 - Support 'win32' source under Cygwin 6.13 Tue Jun 10 16:45:22 2008 - Upgraded ppport.h to Devel::PPPort 3.14 - End all tests with exit(0) - Recommended modules in META.yml 6.12 Tue Feb 26 13:58:15 2008 - Read random devices in smaller chunks - 'die' properly if no compiler 6.11 Wed Feb 20 17:36:53 2008 - POD updates - Upgraded ppport.h to Devel::PPPort 3.13_01 6.09 Sat Sep 15 12:02:30 2007 - More test fixes for Test::More 0.71 6.08 Sat Sep 15 02:24:18 2007 - Test fixes for Test::More 0.71 - Upgraded ppport.h to Devel::PPPort 3.11_06 6.07 Tue Sep 11 14:27:48 2007 - More changes with random number site testing 6.06 Mon Sep 10 18:20:18 2007 - Better random number site testing 6.05 Mon Sep 10 17:17:30 2007 - Skip tests on random number sites when not available 6.04 Mon Sep 10 15:43:55 2007 - POD spelling test (maintainer only) 6.03 Fri Jun 8 18:37:01 2007 - Documented that module's import() function must get called 6.02 Tue May 15 16:32:10 2007 - More checks on /dev/random in test suite 6.01 Tue May 15 12:29:08 2007 - Standalone PRNG is now an (internal) object 5.06 Mon May 14 19:19:16 2007 - Use 'deep' cloning on objects 5.05 Mon May 14 13:46:28 2007 - Handle '/dev/random unavailable' in test suite - Upgraded ppport.h to Devel::PPPort 3.11 5.04 Mon Oct 9 16:11:50 EDT 2006 - Uses OIO's :hash_only flag - Added tests for POD and exports - Upgraded ppport.h to Devel::PPPort 3.10 5.03 Thu Aug 10 13:42:12 EDT 2006 - Fix to overload test 5.02 Thu Jul 20 10:00:43 EDT 2006 - Upgraded ppport.h to Devel::PPPort 3.09 - Handle Win32::API missing under MSWin32 on Win XP 5.01 Wed Dec 28 08:50:00 2005 - Converted to using Object::InsideOut and Exception::Class - Added support for Object::InsideOut style serialization - Require Scalar::Util 1.18 or higher - 'get_seed' and 'get_state' return array or array ref - Fixed URL for randomnumbers.info - Workable version numbering - Tested back to Perl 5.6.0 4.13.00 Wed Sep 21 15:53:50 2005 - Repaired DynaLoader name in Makefile.PL 4.12.00 Wed Sep 21 14:48:00 2005 - Added RandomNumbers.info 4.11.00 Tue Sep 20 11:07:00 2005 - Require Scalar::Util 1.10 or higher - Properly handle no threads in tests 4.10.00 Mon Sep 19 15:39:45 2005 - Use 'attributes' instead of 'Attribute::Handlers' - Ensure PRNG memory is not freed twice - Upgraded ppport.h 4.09.00 Sat Sep 17 08:45:30 2005 - use Attribute::Handlers; - Added 'Utils' module - Removed ->_rebless() - not needed - Reduced internet timeout to 5 secs. - Skip internet tests if can't connect 4.08.00 Fri Sep 09 10:06:40 2005 - Changed subclass object ID usage - Bug fix in seed acquisition routine 4.07.00 Thu Sep 08 12:44:10 2005 - Output warnings using Carp - removed 'get_warnings' - Warnings and errors documented in POD - Proper postamble in Makefile.PL 4.06.00 Wed Sep 07 10:41:40 2005 - Added ->clone() method - removed cloning via ->new() - Made object's ref 'readonly' - More speed improvements - POD reorganization 4.05.00 Tue Aug 30 20:00:00 2005 - Proper localization of '__WARN__' handler 4.04.00 Tue Aug 30 09:08:00 2005 - Improved check for 'C' compiler in Makefile.PL - Removed Build.PL due to Module::Build bug under MSWin32 4.03.00 Mon Aug 29 09:34:25 2005 - Speed improvements 4.02.00 Sun Aug 28 11:20:00 2005 - Removed INIT block and moved code to import() function - Silence (harmless) warning generated by 'require Win32::API;' 4.01.00 Sun Aug 28 09:46:00 2005 - Bug fix for WinXP random source 4.00.00 Fri Aug 26 14:26:30 2005 - Changed to "get_/set_" accessors for seed, state and warnings - Removed 'mt_rand' and 'mt_srand' 3.00.00 Mon Aug 22 15:27:10 2005 - Rewritten using inside-out object model - Added pedagogical subclass Math::Random::MT::Auto::Range - Fix for Win32 free() bug - Build support for Module::Build 2.20.00 Thu Aug 18 08:17:45 2005 - Fix for Win32 build error 2.1.0 Tue Aug 09 12:46:40 2005 - Fixed memory leak when using threads with sub-classes 2.0.0 Wed Aug 03 08:07:10 2005 - Added shuffle() - Fisher-Yates shuffle - Sample program for shuffle function - New (faster) method for Gaussian random numbers - Added exponential() - Exponentially distributed random numbers - Added erlang() - Random numbers based on an Erlang distribution - Added poisson() - Random numbers based on a Poisson distribution - Added binomial() - Random numbers based on a binomial distribution - Sample programs for non-uniform random deviates 1.37 Sat Jul 16 18:42:40 2005 - Fix to 32-bit floating point conversion 1.36 Fri Jul 15 09:18:30 2005 - Support gaussian($sd, $mean) - Fix to non-blocking IO code 1.35 Tue Jul 12 11:17:40 2005 - Require 'C' compiler in Makefile.PL - No non-blocking IO on Windows - Non-fatal if can't set non-blocking IO - Fix for identifying Win XP 1.34 Mon Jul 11 09:03:00 2005 - Require Scalar::Util 1.16 or higher - Removed deprecated rand32 1.33 Fri Jul 08 13:20:00 2005 - Fix for determining 64-bit support by using $Config{'uvsize'} - Mandate >5.6.0 (for the above) 1.30 Thu Jul 07 20:16:00 2005 - Belated version bump for 64-bit support - Fix for non-gcc compilers 1.23 Thu Jul 07 11:41:00 2005 - 64-bit algorithm on Perls with 'use64bitint' - Added irand for random integers (rand32 deprecated) 1.22 Tue Jul 05 15:06:00 2005 - Subclass handling - Documented as not thread-safe for < 5.7.2 1.21 Fri Jul 01 14:43:30 2005 - Added gaussian() - Gaussian (normal) distributed random numbers 1.20 Thu Jun 30 14:22:45 2005 - Full-blown OO interface that is also thread safe - Replaced @errors array with warnings() function/method - Win32 XP random seed source 1.11 Fri Jun 24 12:36:30 2005 - Fixed :!auto flag processing - Better arg handling in srand() and seed() - Added cautionary note to POD concerning the use of 'require' 1.10 Thu Jun 23 16:09:45 2005 - Generalized random device support - Support for user-supplied seeding functions - Support for fetching and restoring PRNG state vector 1.00 Wed Jun 22 15:54:26 2005 - Initial release Math-Random-MT-Auto-6.23/ppport.h0000644000175000001440000052540613377133756016213 0ustar jdheddenusers#if 0 <<'SKIP'; #endif /* ---------------------------------------------------------------------- ppport.h -- Perl/Pollution/Portability Version 3.19 Automatically created by Devel::PPPort running under perl 5.010000. Do NOT edit this file directly! -- Edit PPPort_pm.PL and the includes in parts/inc/ instead. Use 'perldoc ppport.h' to view the documentation below. ---------------------------------------------------------------------- SKIP =pod =head1 NAME ppport.h - Perl/Pollution/Portability version 3.19 =head1 SYNOPSIS perl ppport.h [options] [source files] Searches current directory for files if no [source files] are given --help show short help --version show version --patch=file write one patch file with changes --copy=suffix write changed copies with suffix --diff=program use diff program and options --compat-version=version provide compatibility with Perl version --cplusplus accept C++ comments --quiet don't output anything except fatal errors --nodiag don't show diagnostics --nohints don't show hints --nochanges don't suggest changes --nofilter don't filter input files --strip strip all script and doc functionality from ppport.h --list-provided list provided API --list-unsupported list unsupported API --api-info=name show Perl API portability information =head1 COMPATIBILITY This version of F is designed to support operation with Perl installations back to 5.003, and has been tested up to 5.10.0. =head1 OPTIONS =head2 --help Display a brief usage summary. =head2 --version Display the version of F. =head2 --patch=I If this option is given, a single patch file will be created if any changes are suggested. This requires a working diff program to be installed on your system. =head2 --copy=I If this option is given, a copy of each file will be saved with the given suffix that contains the suggested changes. This does not require any external programs. Note that this does not automagially add a dot between the original filename and the suffix. If you want the dot, you have to include it in the option argument. If neither C<--patch> or C<--copy> are given, the default is to simply print the diffs for each file. This requires either C or a C program to be installed. =head2 --diff=I Manually set the diff program and options to use. The default is to use C, when installed, and output unified context diffs. =head2 --compat-version=I Tell F to check for compatibility with the given Perl version. The default is to check for compatibility with Perl version 5.003. You can use this option to reduce the output of F if you intend to be backward compatible only down to a certain Perl version. =head2 --cplusplus Usually, F will detect C++ style comments and replace them with C style comments for portability reasons. Using this option instructs F to leave C++ comments untouched. =head2 --quiet Be quiet. Don't print anything except fatal errors. =head2 --nodiag Don't output any diagnostic messages. Only portability alerts will be printed. =head2 --nohints Don't output any hints. Hints often contain useful portability notes. Warnings will still be displayed. =head2 --nochanges Don't suggest any changes. Only give diagnostic output and hints unless these are also deactivated. =head2 --nofilter Don't filter the list of input files. By default, files not looking like source code (i.e. not *.xs, *.c, *.cc, *.cpp or *.h) are skipped. =head2 --strip Strip all script and documentation functionality from F. This reduces the size of F dramatically and may be useful if you want to include F in smaller modules without increasing their distribution size too much. The stripped F will have a C<--unstrip> option that allows you to undo the stripping, but only if an appropriate C module is installed. =head2 --list-provided Lists the API elements for which compatibility is provided by F. Also lists if it must be explicitly requested, if it has dependencies, and if there are hints or warnings for it. =head2 --list-unsupported Lists the API elements that are known not to be supported by F and below which version of Perl they probably won't be available or work. =head2 --api-info=I Show portability information for API elements matching I. If I is surrounded by slashes, it is interpreted as a regular expression. =head1 DESCRIPTION In order for a Perl extension (XS) module to be as portable as possible across differing versions of Perl itself, certain steps need to be taken. =over 4 =item * Including this header is the first major one. This alone will give you access to a large part of the Perl API that hasn't been available in earlier Perl releases. Use perl ppport.h --list-provided to see which API elements are provided by ppport.h. =item * You should avoid using deprecated parts of the API. For example, using global Perl variables without the C prefix is deprecated. Also, some API functions used to have a C prefix. Using this form is also deprecated. You can safely use the supported API, as F will provide wrappers for older Perl versions. =item * If you use one of a few functions or variables that were not present in earlier versions of Perl, and that can't be provided using a macro, you have to explicitly request support for these functions by adding one or more C<#define>s in your source code before the inclusion of F. These functions or variables will be marked C in the list shown by C<--list-provided>. Depending on whether you module has a single or multiple files that use such functions or variables, you want either C or global variants. For a C function or variable (used only in a single source file), use: #define NEED_function #define NEED_variable For a global function or variable (used in multiple source files), use: #define NEED_function_GLOBAL #define NEED_variable_GLOBAL Note that you mustn't have more than one global request for the same function or variable in your project. Function / Variable Static Request Global Request ----------------------------------------------------------------------------------------- PL_parser NEED_PL_parser NEED_PL_parser_GLOBAL PL_signals NEED_PL_signals NEED_PL_signals_GLOBAL eval_pv() NEED_eval_pv NEED_eval_pv_GLOBAL grok_bin() NEED_grok_bin NEED_grok_bin_GLOBAL grok_hex() NEED_grok_hex NEED_grok_hex_GLOBAL grok_number() NEED_grok_number NEED_grok_number_GLOBAL grok_numeric_radix() NEED_grok_numeric_radix NEED_grok_numeric_radix_GLOBAL grok_oct() NEED_grok_oct NEED_grok_oct_GLOBAL load_module() NEED_load_module NEED_load_module_GLOBAL my_snprintf() NEED_my_snprintf NEED_my_snprintf_GLOBAL my_sprintf() NEED_my_sprintf NEED_my_sprintf_GLOBAL my_strlcat() NEED_my_strlcat NEED_my_strlcat_GLOBAL my_strlcpy() NEED_my_strlcpy NEED_my_strlcpy_GLOBAL newCONSTSUB() NEED_newCONSTSUB NEED_newCONSTSUB_GLOBAL newRV_noinc() NEED_newRV_noinc NEED_newRV_noinc_GLOBAL newSV_type() NEED_newSV_type NEED_newSV_type_GLOBAL newSVpvn_flags() NEED_newSVpvn_flags NEED_newSVpvn_flags_GLOBAL newSVpvn_share() NEED_newSVpvn_share NEED_newSVpvn_share_GLOBAL pv_display() NEED_pv_display NEED_pv_display_GLOBAL pv_escape() NEED_pv_escape NEED_pv_escape_GLOBAL pv_pretty() NEED_pv_pretty NEED_pv_pretty_GLOBAL sv_2pv_flags() NEED_sv_2pv_flags NEED_sv_2pv_flags_GLOBAL sv_2pvbyte() NEED_sv_2pvbyte NEED_sv_2pvbyte_GLOBAL sv_catpvf_mg() NEED_sv_catpvf_mg NEED_sv_catpvf_mg_GLOBAL sv_catpvf_mg_nocontext() NEED_sv_catpvf_mg_nocontext NEED_sv_catpvf_mg_nocontext_GLOBAL sv_pvn_force_flags() NEED_sv_pvn_force_flags NEED_sv_pvn_force_flags_GLOBAL sv_setpvf_mg() NEED_sv_setpvf_mg NEED_sv_setpvf_mg_GLOBAL sv_setpvf_mg_nocontext() NEED_sv_setpvf_mg_nocontext NEED_sv_setpvf_mg_nocontext_GLOBAL vload_module() NEED_vload_module NEED_vload_module_GLOBAL vnewSVpvf() NEED_vnewSVpvf NEED_vnewSVpvf_GLOBAL warner() NEED_warner NEED_warner_GLOBAL To avoid namespace conflicts, you can change the namespace of the explicitly exported functions / variables using the C macro. Just C<#define> the macro before including C: #define DPPP_NAMESPACE MyOwnNamespace_ #include "ppport.h" The default namespace is C. =back The good thing is that most of the above can be checked by running F on your source code. See the next section for details. =head1 EXAMPLES To verify whether F is needed for your module, whether you should make any changes to your code, and whether any special defines should be used, F can be run as a Perl script to check your source code. Simply say: perl ppport.h The result will usually be a list of patches suggesting changes that should at least be acceptable, if not necessarily the most efficient solution, or a fix for all possible problems. If you know that your XS module uses features only available in newer Perl releases, if you're aware that it uses C++ comments, and if you want all suggestions as a single patch file, you could use something like this: perl ppport.h --compat-version=5.6.0 --cplusplus --patch=test.diff If you only want your code to be scanned without any suggestions for changes, use: perl ppport.h --nochanges You can specify a different C program or options, using the C<--diff> option: perl ppport.h --diff='diff -C 10' This would output context diffs with 10 lines of context. If you want to create patched copies of your files instead, use: perl ppport.h --copy=.new To display portability information for the C function, use: perl ppport.h --api-info=newSVpvn Since the argument to C<--api-info> can be a regular expression, you can use perl ppport.h --api-info=/_nomg$/ to display portability information for all C<_nomg> functions or perl ppport.h --api-info=/./ to display information for all known API elements. =head1 BUGS If this version of F is causing failure during the compilation of this module, please check if newer versions of either this module or C are available on CPAN before sending a bug report. If F was generated using the latest version of C and is causing failure of this module, please file a bug report using the CPAN Request Tracker at L. Please include the following information: =over 4 =item 1. The complete output from running "perl -V" =item 2. This file. =item 3. The name and version of the module you were trying to build. =item 4. A full log of the build that failed. =item 5. Any other information that you think could be relevant. =back For the latest version of this code, please get the C module from CPAN. =head1 COPYRIGHT Version 3.x, Copyright (c) 2004-2009, Marcus Holland-Moritz. Version 2.x, Copyright (C) 2001, Paul Marquess. Version 1.x, Copyright (C) 1999, Kenneth Albanowski. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =head1 SEE ALSO See L. =cut use strict; # Disable broken TRIE-optimization BEGIN { eval '${^RE_TRIE_MAXBUF} = -1' if $] >= 5.009004 && $] <= 5.009005 } my $VERSION = 3.19; my %opt = ( quiet => 0, diag => 1, hints => 1, changes => 1, cplusplus => 0, filter => 1, strip => 0, version => 0, ); my($ppport) = $0 =~ /([\w.]+)$/; my $LF = '(?:\r\n|[\r\n])'; # line feed my $HS = "[ \t]"; # horizontal whitespace # Never use C comments in this file! my $ccs = '/'.'*'; my $cce = '*'.'/'; my $rccs = quotemeta $ccs; my $rcce = quotemeta $cce; eval { require Getopt::Long; Getopt::Long::GetOptions(\%opt, qw( help quiet diag! filter! hints! changes! cplusplus strip version patch=s copy=s diff=s compat-version=s list-provided list-unsupported api-info=s )) or usage(); }; if ($@ and grep /^-/, @ARGV) { usage() if "@ARGV" =~ /^--?h(?:elp)?$/; die "Getopt::Long not found. Please don't use any options.\n"; } if ($opt{version}) { print "This is $0 $VERSION.\n"; exit 0; } usage() if $opt{help}; strip() if $opt{strip}; if (exists $opt{'compat-version'}) { my($r,$v,$s) = eval { parse_version($opt{'compat-version'}) }; if ($@) { die "Invalid version number format: '$opt{'compat-version'}'\n"; } die "Only Perl 5 is supported\n" if $r != 5; die "Invalid version number: $opt{'compat-version'}\n" if $v >= 1000 || $s >= 1000; $opt{'compat-version'} = sprintf "%d.%03d%03d", $r, $v, $s; } else { $opt{'compat-version'} = 5; } my %API = map { /^(\w+)\|([^|]*)\|([^|]*)\|(\w*)$/ ? ( $1 => { ($2 ? ( base => $2 ) : ()), ($3 ? ( todo => $3 ) : ()), (index($4, 'v') >= 0 ? ( varargs => 1 ) : ()), (index($4, 'p') >= 0 ? ( provided => 1 ) : ()), (index($4, 'n') >= 0 ? ( nothxarg => 1 ) : ()), } ) : die "invalid spec: $_" } qw( AvFILLp|5.004050||p AvFILL||| CLASS|||n CPERLscope|5.005000||p CX_CURPAD_SAVE||| CX_CURPAD_SV||| CopFILEAV|5.006000||p CopFILEGV_set|5.006000||p CopFILEGV|5.006000||p CopFILESV|5.006000||p CopFILE_set|5.006000||p CopFILE|5.006000||p CopSTASHPV_set|5.006000||p CopSTASHPV|5.006000||p CopSTASH_eq|5.006000||p CopSTASH_set|5.006000||p CopSTASH|5.006000||p CopyD|5.009002||p Copy||| CvPADLIST||| CvSTASH||| CvWEAKOUTSIDE||| DEFSV_set|5.011000||p DEFSV|5.004050||p END_EXTERN_C|5.005000||p ENTER||| ERRSV|5.004050||p EXTEND||| EXTERN_C|5.005000||p F0convert|||n FREETMPS||| GIMME_V||5.004000|n GIMME|||n GROK_NUMERIC_RADIX|5.007002||p G_ARRAY||| G_DISCARD||| G_EVAL||| G_METHOD|5.006001||p G_NOARGS||| G_SCALAR||| G_VOID||5.004000| GetVars||| GvSVn|5.009003||p GvSV||| Gv_AMupdate||| HEf_SVKEY||5.004000| HeHASH||5.004000| HeKEY||5.004000| HeKLEN||5.004000| HePV||5.004000| HeSVKEY_force||5.004000| HeSVKEY_set||5.004000| HeSVKEY||5.004000| HeUTF8||5.011000| HeVAL||5.004000| HvNAMELEN_get|5.009003||p HvNAME_get|5.009003||p HvNAME||| INT2PTR|5.006000||p IN_LOCALE_COMPILETIME|5.007002||p IN_LOCALE_RUNTIME|5.007002||p IN_LOCALE|5.007002||p IN_PERL_COMPILETIME|5.008001||p IS_NUMBER_GREATER_THAN_UV_MAX|5.007002||p IS_NUMBER_INFINITY|5.007002||p IS_NUMBER_IN_UV|5.007002||p IS_NUMBER_NAN|5.007003||p IS_NUMBER_NEG|5.007002||p IS_NUMBER_NOT_INT|5.007002||p IVSIZE|5.006000||p IVTYPE|5.006000||p IVdf|5.006000||p LEAVE||| LVRET||| MARK||| MULTICALL||5.011000| MY_CXT_CLONE|5.009002||p MY_CXT_INIT|5.007003||p MY_CXT|5.007003||p MoveD|5.009002||p Move||| NOOP|5.005000||p NUM2PTR|5.006000||p NVTYPE|5.006000||p NVef|5.006001||p NVff|5.006001||p NVgf|5.006001||p Newxc|5.009003||p Newxz|5.009003||p Newx|5.009003||p Nullav||| Nullch||| Nullcv||| Nullhv||| Nullsv||| ORIGMARK||| PAD_BASE_SV||| PAD_CLONE_VARS||| PAD_COMPNAME_FLAGS||| PAD_COMPNAME_GEN_set||| PAD_COMPNAME_GEN||| PAD_COMPNAME_OURSTASH||| PAD_COMPNAME_PV||| PAD_COMPNAME_TYPE||| PAD_DUP||| PAD_RESTORE_LOCAL||| PAD_SAVE_LOCAL||| PAD_SAVE_SETNULLPAD||| PAD_SETSV||| PAD_SET_CUR_NOSAVE||| PAD_SET_CUR||| PAD_SVl||| PAD_SV||| PERLIO_FUNCS_CAST|5.009003||p PERLIO_FUNCS_DECL|5.009003||p PERL_ABS|5.008001||p PERL_BCDVERSION|5.011000||p PERL_GCC_BRACE_GROUPS_FORBIDDEN|5.008001||p PERL_HASH|5.004000||p PERL_INT_MAX|5.004000||p PERL_INT_MIN|5.004000||p PERL_LONG_MAX|5.004000||p PERL_LONG_MIN|5.004000||p PERL_MAGIC_arylen|5.007002||p PERL_MAGIC_backref|5.007002||p PERL_MAGIC_bm|5.007002||p PERL_MAGIC_collxfrm|5.007002||p PERL_MAGIC_dbfile|5.007002||p PERL_MAGIC_dbline|5.007002||p PERL_MAGIC_defelem|5.007002||p PERL_MAGIC_envelem|5.007002||p PERL_MAGIC_env|5.007002||p PERL_MAGIC_ext|5.007002||p PERL_MAGIC_fm|5.007002||p PERL_MAGIC_glob|5.011000||p PERL_MAGIC_isaelem|5.007002||p PERL_MAGIC_isa|5.007002||p PERL_MAGIC_mutex|5.011000||p PERL_MAGIC_nkeys|5.007002||p PERL_MAGIC_overload_elem|5.007002||p PERL_MAGIC_overload_table|5.007002||p PERL_MAGIC_overload|5.007002||p PERL_MAGIC_pos|5.007002||p PERL_MAGIC_qr|5.007002||p PERL_MAGIC_regdata|5.007002||p PERL_MAGIC_regdatum|5.007002||p PERL_MAGIC_regex_global|5.007002||p PERL_MAGIC_shared_scalar|5.007003||p PERL_MAGIC_shared|5.007003||p PERL_MAGIC_sigelem|5.007002||p PERL_MAGIC_sig|5.007002||p PERL_MAGIC_substr|5.007002||p PERL_MAGIC_sv|5.007002||p PERL_MAGIC_taint|5.007002||p PERL_MAGIC_tiedelem|5.007002||p PERL_MAGIC_tiedscalar|5.007002||p PERL_MAGIC_tied|5.007002||p PERL_MAGIC_utf8|5.008001||p PERL_MAGIC_uvar_elem|5.007003||p PERL_MAGIC_uvar|5.007002||p PERL_MAGIC_vec|5.007002||p PERL_MAGIC_vstring|5.008001||p PERL_PV_ESCAPE_ALL|5.009004||p PERL_PV_ESCAPE_FIRSTCHAR|5.009004||p PERL_PV_ESCAPE_NOBACKSLASH|5.009004||p PERL_PV_ESCAPE_NOCLEAR|5.009004||p PERL_PV_ESCAPE_QUOTE|5.009004||p PERL_PV_ESCAPE_RE|5.009005||p PERL_PV_ESCAPE_UNI_DETECT|5.009004||p PERL_PV_ESCAPE_UNI|5.009004||p PERL_PV_PRETTY_DUMP|5.009004||p PERL_PV_PRETTY_ELLIPSES|5.010000||p PERL_PV_PRETTY_LTGT|5.009004||p PERL_PV_PRETTY_NOCLEAR|5.010000||p PERL_PV_PRETTY_QUOTE|5.009004||p PERL_PV_PRETTY_REGPROP|5.009004||p PERL_QUAD_MAX|5.004000||p PERL_QUAD_MIN|5.004000||p PERL_REVISION|5.006000||p PERL_SCAN_ALLOW_UNDERSCORES|5.007003||p PERL_SCAN_DISALLOW_PREFIX|5.007003||p PERL_SCAN_GREATER_THAN_UV_MAX|5.007003||p PERL_SCAN_SILENT_ILLDIGIT|5.008001||p PERL_SHORT_MAX|5.004000||p PERL_SHORT_MIN|5.004000||p PERL_SIGNALS_UNSAFE_FLAG|5.008001||p PERL_SUBVERSION|5.006000||p PERL_SYS_INIT3||5.006000| PERL_SYS_INIT||| PERL_SYS_TERM||5.011000| PERL_UCHAR_MAX|5.004000||p PERL_UCHAR_MIN|5.004000||p PERL_UINT_MAX|5.004000||p PERL_UINT_MIN|5.004000||p PERL_ULONG_MAX|5.004000||p PERL_ULONG_MIN|5.004000||p PERL_UNUSED_ARG|5.009003||p PERL_UNUSED_CONTEXT|5.009004||p PERL_UNUSED_DECL|5.007002||p PERL_UNUSED_VAR|5.007002||p PERL_UQUAD_MAX|5.004000||p PERL_UQUAD_MIN|5.004000||p PERL_USE_GCC_BRACE_GROUPS|5.009004||p PERL_USHORT_MAX|5.004000||p PERL_USHORT_MIN|5.004000||p PERL_VERSION|5.006000||p PL_DBsignal|5.005000||p PL_DBsingle|||pn PL_DBsub|||pn PL_DBtrace|||pn PL_Sv|5.005000||p PL_bufend|5.011000||p PL_bufptr|5.011000||p PL_compiling|5.004050||p PL_copline|5.011000||p PL_curcop|5.004050||p PL_curstash|5.004050||p PL_debstash|5.004050||p PL_defgv|5.004050||p PL_diehook|5.004050||p PL_dirty|5.004050||p PL_dowarn|||pn PL_errgv|5.004050||p PL_error_count|5.011000||p PL_expect|5.011000||p PL_hexdigit|5.005000||p PL_hints|5.005000||p PL_in_my_stash|5.011000||p PL_in_my|5.011000||p PL_last_in_gv|||n PL_laststatval|5.005000||p PL_lex_state|5.011000||p PL_lex_stuff|5.011000||p PL_linestr|5.011000||p PL_modglobal||5.005000|n PL_na|5.004050||pn PL_no_modify|5.006000||p PL_ofsgv|||n PL_parser|5.009005||p PL_perl_destruct_level|5.004050||p PL_perldb|5.004050||p PL_ppaddr|5.006000||p PL_rsfp_filters|5.004050||p PL_rsfp|5.004050||p PL_rs|||n PL_signals|5.008001||p PL_stack_base|5.004050||p PL_stack_sp|5.004050||p PL_statcache|5.005000||p PL_stdingv|5.004050||p PL_sv_arenaroot|5.004050||p PL_sv_no|5.004050||pn PL_sv_undef|5.004050||pn PL_sv_yes|5.004050||pn PL_tainted|5.004050||p PL_tainting|5.004050||p PL_tokenbuf|5.011000||p POP_MULTICALL||5.011000| POPi|||n POPl|||n POPn|||n POPpbytex||5.007001|n POPpx||5.005030|n POPp|||n POPs|||n PTR2IV|5.006000||p PTR2NV|5.006000||p PTR2UV|5.006000||p PTR2nat|5.009003||p PTR2ul|5.007001||p PTRV|5.006000||p PUSHMARK||| PUSH_MULTICALL||5.011000| PUSHi||| PUSHmortal|5.009002||p PUSHn||| PUSHp||| PUSHs||| PUSHu|5.004000||p PUTBACK||| PerlIO_clearerr||5.007003| PerlIO_close||5.007003| PerlIO_context_layers||5.009004| PerlIO_eof||5.007003| PerlIO_error||5.007003| PerlIO_fileno||5.007003| PerlIO_fill||5.007003| PerlIO_flush||5.007003| PerlIO_get_base||5.007003| PerlIO_get_bufsiz||5.007003| PerlIO_get_cnt||5.007003| PerlIO_get_ptr||5.007003| PerlIO_read||5.007003| PerlIO_seek||5.007003| PerlIO_set_cnt||5.007003| PerlIO_set_ptrcnt||5.007003| PerlIO_setlinebuf||5.007003| PerlIO_stderr||5.007003| PerlIO_stdin||5.007003| PerlIO_stdout||5.007003| PerlIO_tell||5.007003| PerlIO_unread||5.007003| PerlIO_write||5.007003| Perl_signbit||5.009005|n PoisonFree|5.009004||p PoisonNew|5.009004||p PoisonWith|5.009004||p Poison|5.008000||p RETVAL|||n Renewc||| Renew||| SAVECLEARSV||| SAVECOMPPAD||| SAVEPADSV||| SAVETMPS||| SAVE_DEFSV|5.004050||p SPAGAIN||| SP||| START_EXTERN_C|5.005000||p START_MY_CXT|5.007003||p STMT_END|||p STMT_START|||p STR_WITH_LEN|5.009003||p ST||| SV_CONST_RETURN|5.009003||p SV_COW_DROP_PV|5.008001||p SV_COW_SHARED_HASH_KEYS|5.009005||p SV_GMAGIC|5.007002||p SV_HAS_TRAILING_NUL|5.009004||p SV_IMMEDIATE_UNREF|5.007001||p SV_MUTABLE_RETURN|5.009003||p SV_NOSTEAL|5.009002||p SV_SMAGIC|5.009003||p SV_UTF8_NO_ENCODING|5.008001||p SVfARG|5.009005||p SVf_UTF8|5.006000||p SVf|5.006000||p SVt_IV||| SVt_NV||| SVt_PVAV||| SVt_PVCV||| SVt_PVHV||| SVt_PVMG||| SVt_PV||| Safefree||| Slab_Alloc||| Slab_Free||| Slab_to_rw||| StructCopy||| SvCUR_set||| SvCUR||| SvEND||| SvGAMAGIC||5.006001| SvGETMAGIC|5.004050||p SvGROW||| SvIOK_UV||5.006000| SvIOK_notUV||5.006000| SvIOK_off||| SvIOK_only_UV||5.006000| SvIOK_only||| SvIOK_on||| SvIOKp||| SvIOK||| SvIVX||| SvIV_nomg|5.009001||p SvIV_set||| SvIVx||| SvIV||| SvIsCOW_shared_hash||5.008003| SvIsCOW||5.008003| SvLEN_set||| SvLEN||| SvLOCK||5.007003| SvMAGIC_set|5.009003||p SvNIOK_off||| SvNIOKp||| SvNIOK||| SvNOK_off||| SvNOK_only||| SvNOK_on||| SvNOKp||| SvNOK||| SvNVX||| SvNV_set||| SvNVx||| SvNV||| SvOK||| SvOOK_offset||5.011000| SvOOK||| SvPOK_off||| SvPOK_only_UTF8||5.006000| SvPOK_only||| SvPOK_on||| SvPOKp||| SvPOK||| SvPVX_const|5.009003||p SvPVX_mutable|5.009003||p SvPVX||| SvPV_const|5.009003||p SvPV_flags_const_nolen|5.009003||p SvPV_flags_const|5.009003||p SvPV_flags_mutable|5.009003||p SvPV_flags|5.007002||p SvPV_force_flags_mutable|5.009003||p SvPV_force_flags_nolen|5.009003||p SvPV_force_flags|5.007002||p SvPV_force_mutable|5.009003||p SvPV_force_nolen|5.009003||p SvPV_force_nomg_nolen|5.009003||p SvPV_force_nomg|5.007002||p SvPV_force|||p SvPV_mutable|5.009003||p SvPV_nolen_const|5.009003||p SvPV_nolen|5.006000||p SvPV_nomg_const_nolen|5.009003||p SvPV_nomg_const|5.009003||p SvPV_nomg|5.007002||p SvPV_renew|5.009003||p SvPV_set||| SvPVbyte_force||5.009002| SvPVbyte_nolen||5.006000| SvPVbytex_force||5.006000| SvPVbytex||5.006000| SvPVbyte|5.006000||p SvPVutf8_force||5.006000| SvPVutf8_nolen||5.006000| SvPVutf8x_force||5.006000| SvPVutf8x||5.006000| SvPVutf8||5.006000| SvPVx||| SvPV||| SvREFCNT_dec||| SvREFCNT_inc_NN|5.009004||p SvREFCNT_inc_simple_NN|5.009004||p SvREFCNT_inc_simple_void_NN|5.009004||p SvREFCNT_inc_simple_void|5.009004||p SvREFCNT_inc_simple|5.009004||p SvREFCNT_inc_void_NN|5.009004||p SvREFCNT_inc_void|5.009004||p SvREFCNT_inc|||p SvREFCNT||| SvROK_off||| SvROK_on||| SvROK||| SvRV_set|5.009003||p SvRV||| SvRXOK||5.009005| SvRX||5.009005| SvSETMAGIC||| SvSHARED_HASH|5.009003||p SvSHARE||5.007003| SvSTASH_set|5.009003||p SvSTASH||| SvSetMagicSV_nosteal||5.004000| SvSetMagicSV||5.004000| SvSetSV_nosteal||5.004000| SvSetSV||| SvTAINTED_off||5.004000| SvTAINTED_on||5.004000| SvTAINTED||5.004000| SvTAINT||| SvTRUE||| SvTYPE||| SvUNLOCK||5.007003| SvUOK|5.007001|5.006000|p SvUPGRADE||| SvUTF8_off||5.006000| SvUTF8_on||5.006000| SvUTF8||5.006000| SvUVXx|5.004000||p SvUVX|5.004000||p SvUV_nomg|5.009001||p SvUV_set|5.009003||p SvUVx|5.004000||p SvUV|5.004000||p SvVOK||5.008001| SvVSTRING_mg|5.009004||p THIS|||n UNDERBAR|5.009002||p UTF8_MAXBYTES|5.009002||p UVSIZE|5.006000||p UVTYPE|5.006000||p UVXf|5.007001||p UVof|5.006000||p UVuf|5.006000||p UVxf|5.006000||p WARN_ALL|5.006000||p WARN_AMBIGUOUS|5.006000||p WARN_ASSERTIONS|5.011000||p WARN_BAREWORD|5.006000||p WARN_CLOSED|5.006000||p WARN_CLOSURE|5.006000||p WARN_DEBUGGING|5.006000||p WARN_DEPRECATED|5.006000||p WARN_DIGIT|5.006000||p WARN_EXEC|5.006000||p WARN_EXITING|5.006000||p WARN_GLOB|5.006000||p WARN_INPLACE|5.006000||p WARN_INTERNAL|5.006000||p WARN_IO|5.006000||p WARN_LAYER|5.008000||p WARN_MALLOC|5.006000||p WARN_MISC|5.006000||p WARN_NEWLINE|5.006000||p WARN_NUMERIC|5.006000||p WARN_ONCE|5.006000||p WARN_OVERFLOW|5.006000||p WARN_PACK|5.006000||p WARN_PARENTHESIS|5.006000||p WARN_PIPE|5.006000||p WARN_PORTABLE|5.006000||p WARN_PRECEDENCE|5.006000||p WARN_PRINTF|5.006000||p WARN_PROTOTYPE|5.006000||p WARN_QW|5.006000||p WARN_RECURSION|5.006000||p WARN_REDEFINE|5.006000||p WARN_REGEXP|5.006000||p WARN_RESERVED|5.006000||p WARN_SEMICOLON|5.006000||p WARN_SEVERE|5.006000||p WARN_SIGNAL|5.006000||p WARN_SUBSTR|5.006000||p WARN_SYNTAX|5.006000||p WARN_TAINT|5.006000||p WARN_THREADS|5.008000||p WARN_UNINITIALIZED|5.006000||p WARN_UNOPENED|5.006000||p WARN_UNPACK|5.006000||p WARN_UNTIE|5.006000||p WARN_UTF8|5.006000||p WARN_VOID|5.006000||p XCPT_CATCH|5.009002||p XCPT_RETHROW|5.009002||p XCPT_TRY_END|5.009002||p XCPT_TRY_START|5.009002||p XPUSHi||| XPUSHmortal|5.009002||p XPUSHn||| XPUSHp||| XPUSHs||| XPUSHu|5.004000||p XSPROTO|5.010000||p XSRETURN_EMPTY||| XSRETURN_IV||| XSRETURN_NO||| XSRETURN_NV||| XSRETURN_PV||| XSRETURN_UNDEF||| XSRETURN_UV|5.008001||p XSRETURN_YES||| XSRETURN|||p XST_mIV||| XST_mNO||| XST_mNV||| XST_mPV||| XST_mUNDEF||| XST_mUV|5.008001||p XST_mYES||| XS_VERSION_BOOTCHECK||| XS_VERSION||| XSprePUSH|5.006000||p XS||| ZeroD|5.009002||p Zero||| _aMY_CXT|5.007003||p _pMY_CXT|5.007003||p aMY_CXT_|5.007003||p aMY_CXT|5.007003||p aTHXR_|5.011000||p aTHXR|5.011000||p aTHX_|5.006000||p aTHX|5.006000||p add_data|||n addmad||| allocmy||| amagic_call||| amagic_cmp_locale||| amagic_cmp||| amagic_i_ncmp||| amagic_ncmp||| any_dup||| ao||| append_elem||| append_list||| append_madprops||| apply_attrs_my||| apply_attrs_string||5.006001| apply_attrs||| apply||| atfork_lock||5.007003|n atfork_unlock||5.007003|n av_arylen_p||5.009003| av_clear||| av_create_and_push||5.009005| av_create_and_unshift_one||5.009005| av_delete||5.006000| av_exists||5.006000| av_extend||| av_fetch||| av_fill||| av_iter_p||5.011000| av_len||| av_make||| av_pop||| av_push||| av_reify||| av_shift||| av_store||| av_undef||| av_unshift||| ax|||n bad_type||| bind_match||| block_end||| block_gimme||5.004000| block_start||| boolSV|5.004000||p boot_core_PerlIO||| boot_core_UNIVERSAL||| boot_core_mro||| bytes_from_utf8||5.007001| bytes_to_uni|||n bytes_to_utf8||5.006001| call_argv|5.006000||p call_atexit||5.006000| call_list||5.004000| call_method|5.006000||p call_pv|5.006000||p call_sv|5.006000||p calloc||5.007002|n cando||| cast_i32||5.006000| cast_iv||5.006000| cast_ulong||5.006000| cast_uv||5.006000| check_type_and_open||| check_uni||| checkcomma||| checkposixcc||| ckWARN|5.006000||p ck_anoncode||| ck_bitop||| ck_concat||| ck_defined||| ck_delete||| ck_die||| ck_each||| ck_eof||| ck_eval||| ck_exec||| ck_exists||| ck_exit||| ck_ftst||| ck_fun||| ck_glob||| ck_grep||| ck_index||| ck_join||| ck_lfun||| ck_listiob||| ck_match||| ck_method||| ck_null||| ck_open||| ck_readline||| ck_repeat||| ck_require||| ck_return||| ck_rfun||| ck_rvconst||| ck_sassign||| ck_select||| ck_shift||| ck_sort||| ck_spair||| ck_split||| ck_subr||| ck_substr||| ck_svconst||| ck_trunc||| ck_unpack||| ckwarn_d||5.009003| ckwarn||5.009003| cl_and|||n cl_anything|||n cl_init_zero|||n cl_init|||n cl_is_anything|||n cl_or|||n clear_placeholders||| closest_cop||| convert||| cop_free||| cr_textfilter||| create_eval_scope||| croak_nocontext|||vn croak_xs_usage||5.011000| croak|||v csighandler||5.009003|n curmad||| custom_op_desc||5.007003| custom_op_name||5.007003| cv_ckproto_len||| cv_clone||| cv_const_sv||5.004000| cv_dump||| cv_undef||| cx_dump||5.005000| cx_dup||| cxinc||| dAXMARK|5.009003||p dAX|5.007002||p dITEMS|5.007002||p dMARK||| dMULTICALL||5.009003| dMY_CXT_SV|5.007003||p dMY_CXT|5.007003||p dNOOP|5.006000||p dORIGMARK||| dSP||| dTHR|5.004050||p dTHXR|5.011000||p dTHXa|5.006000||p dTHXoa|5.006000||p dTHX|5.006000||p dUNDERBAR|5.009002||p dVAR|5.009003||p dXCPT|5.009002||p dXSARGS||| dXSI32||| dXSTARG|5.006000||p deb_curcv||| deb_nocontext|||vn deb_stack_all||| deb_stack_n||| debop||5.005000| debprofdump||5.005000| debprof||| debstackptrs||5.007003| debstack||5.007003| debug_start_match||| deb||5.007003|v del_sv||| delete_eval_scope||| delimcpy||5.004000| deprecate_old||| deprecate||| despatch_signals||5.007001| destroy_matcher||| die_nocontext|||vn die_where||| die|||v dirp_dup||| div128||| djSP||| do_aexec5||| do_aexec||| do_aspawn||| do_binmode||5.004050| do_chomp||| do_chop||| do_close||| do_dump_pad||| do_eof||| do_exec3||| do_execfree||| do_exec||| do_gv_dump||5.006000| do_gvgv_dump||5.006000| do_hv_dump||5.006000| do_ipcctl||| do_ipcget||| do_join||| do_kv||| do_magic_dump||5.006000| do_msgrcv||| do_msgsnd||| do_oddball||| do_op_dump||5.006000| do_op_xmldump||| do_open9||5.006000| do_openn||5.007001| do_open||5.004000| do_pmop_dump||5.006000| do_pmop_xmldump||| do_print||| do_readline||| do_seek||| do_semop||| do_shmio||| do_smartmatch||| do_spawn_nowait||| do_spawn||| do_sprintf||| do_sv_dump||5.006000| do_sysseek||| do_tell||| do_trans_complex_utf8||| do_trans_complex||| do_trans_count_utf8||| do_trans_count||| do_trans_simple_utf8||| do_trans_simple||| do_trans||| do_vecget||| do_vecset||| do_vop||| docatch||| doeval||| dofile||| dofindlabel||| doform||| doing_taint||5.008001|n dooneliner||| doopen_pm||| doparseform||| dopoptoeval||| dopoptogiven||| dopoptolabel||| dopoptoloop||| dopoptosub_at||| dopoptowhen||| doref||5.009003| dounwind||| dowantarray||| dump_all||5.006000| dump_eval||5.006000| dump_exec_pos||| dump_fds||| dump_form||5.006000| dump_indent||5.006000|v dump_mstats||| dump_packsubs||5.006000| dump_sub||5.006000| dump_sv_child||| dump_trie_interim_list||| dump_trie_interim_table||| dump_trie||| dump_vindent||5.006000| dumpuntil||| dup_attrlist||| emulate_cop_io||| eval_pv|5.006000||p eval_sv|5.006000||p exec_failed||| expect_number||| fbm_compile||5.005000| fbm_instr||5.005000| feature_is_enabled||| fetch_cop_label||5.011000| filter_add||| filter_del||| filter_gets||| filter_read||| find_and_forget_pmops||| find_array_subscript||| find_beginning||| find_byclass||| find_hash_subscript||| find_in_my_stash||| find_runcv||5.008001| find_rundefsvoffset||5.009002| find_script||| find_uninit_var||| first_symbol|||n fold_constants||| forbid_setid||| force_ident||| force_list||| force_next||| force_version||| force_word||| forget_pmop||| form_nocontext|||vn form||5.004000|v fp_dup||| fprintf_nocontext|||vn free_global_struct||| free_tied_hv_pool||| free_tmps||| gen_constant_list||| get_arena||| get_aux_mg||| get_av|5.006000||p get_context||5.006000|n get_cvn_flags||5.009005| get_cv|5.006000||p get_db_sub||| get_debug_opts||| get_hash_seed||| get_hv|5.006000||p get_isa_hash||| get_mstats||| get_no_modify||| get_num||| get_op_descs||5.005000| get_op_names||5.005000| get_opargs||| get_ppaddr||5.006000| get_re_arg||| get_sv|5.006000||p get_vtbl||5.005030| getcwd_sv||5.007002| getenv_len||| glob_2number||| glob_assign_glob||| glob_assign_ref||| gp_dup||| gp_free||| gp_ref||| grok_bin|5.007003||p grok_hex|5.007003||p grok_number|5.007002||p grok_numeric_radix|5.007002||p grok_oct|5.007003||p group_end||| gv_AVadd||| gv_HVadd||| gv_IOadd||| gv_SVadd||| gv_autoload4||5.004000| gv_check||| gv_const_sv||5.009003| gv_dump||5.006000| gv_efullname3||5.004000| gv_efullname4||5.006001| gv_efullname||| gv_ename||| gv_fetchfile_flags||5.009005| gv_fetchfile||| gv_fetchmeth_autoload||5.007003| gv_fetchmethod_autoload||5.004000| gv_fetchmethod_flags||5.011000| gv_fetchmethod||| gv_fetchmeth||| gv_fetchpvn_flags|5.009002||p gv_fetchpvs|5.009004||p gv_fetchpv||| gv_fetchsv||5.009002| gv_fullname3||5.004000| gv_fullname4||5.006001| gv_fullname||| gv_get_super_pkg||| gv_handler||5.007001| gv_init_sv||| gv_init||| gv_name_set||5.009004| gv_stashpvn|5.004000||p gv_stashpvs|5.009003||p gv_stashpv||| gv_stashsv||| he_dup||| hek_dup||| hfreeentries||| hsplit||| hv_assert||5.011000| hv_auxinit|||n hv_backreferences_p||| hv_clear_placeholders||5.009001| hv_clear||| hv_common_key_len||5.010000| hv_common||5.010000| hv_copy_hints_hv||| hv_delayfree_ent||5.004000| hv_delete_common||| hv_delete_ent||5.004000| hv_delete||| hv_eiter_p||5.009003| hv_eiter_set||5.009003| hv_exists_ent||5.004000| hv_exists||| hv_fetch_ent||5.004000| hv_fetchs|5.009003||p hv_fetch||| hv_free_ent||5.004000| hv_iterinit||| hv_iterkeysv||5.004000| hv_iterkey||| hv_iternext_flags||5.008000| hv_iternextsv||| hv_iternext||| hv_iterval||| hv_kill_backrefs||| hv_ksplit||5.004000| hv_magic_check|||n hv_magic||| hv_name_set||5.009003| hv_notallowed||| hv_placeholders_get||5.009003| hv_placeholders_p||5.009003| hv_placeholders_set||5.009003| hv_riter_p||5.009003| hv_riter_set||5.009003| hv_scalar||5.009001| hv_store_ent||5.004000| hv_store_flags||5.008000| hv_stores|5.009004||p hv_store||| hv_undef||| ibcmp_locale||5.004000| ibcmp_utf8||5.007003| ibcmp||| incline||| incpush_if_exists||| incpush_use_sep||| incpush||| ingroup||| init_argv_symbols||| init_debugger||| init_global_struct||| init_i18nl10n||5.006000| init_i18nl14n||5.006000| init_ids||| init_interp||| init_main_stash||| init_perllib||| init_postdump_symbols||| init_predump_symbols||| init_stacks||5.005000| init_tm||5.007002| instr||| intro_my||| intuit_method||| intuit_more||| invert||| io_close||| isALNUMC|5.006000||p isALNUM||| isALPHA||| isASCII|5.006000||p isBLANK|5.006001||p isCNTRL|5.006000||p isDIGIT||| isGRAPH|5.006000||p isGV_with_GP|5.009004||p isLOWER||| isPRINT|5.004000||p isPSXSPC|5.006001||p isPUNCT|5.006000||p isSPACE||| isUPPER||| isXDIGIT|5.006000||p is_an_int||| is_gv_magical_sv||| is_handle_constructor|||n is_list_assignment||| is_lvalue_sub||5.007001| is_uni_alnum_lc||5.006000| is_uni_alnumc_lc||5.006000| is_uni_alnumc||5.006000| is_uni_alnum||5.006000| is_uni_alpha_lc||5.006000| is_uni_alpha||5.006000| is_uni_ascii_lc||5.006000| is_uni_ascii||5.006000| is_uni_cntrl_lc||5.006000| is_uni_cntrl||5.006000| is_uni_digit_lc||5.006000| is_uni_digit||5.006000| is_uni_graph_lc||5.006000| is_uni_graph||5.006000| is_uni_idfirst_lc||5.006000| is_uni_idfirst||5.006000| is_uni_lower_lc||5.006000| is_uni_lower||5.006000| is_uni_print_lc||5.006000| is_uni_print||5.006000| is_uni_punct_lc||5.006000| is_uni_punct||5.006000| is_uni_space_lc||5.006000| is_uni_space||5.006000| is_uni_upper_lc||5.006000| is_uni_upper||5.006000| is_uni_xdigit_lc||5.006000| is_uni_xdigit||5.006000| is_utf8_alnumc||5.006000| is_utf8_alnum||5.006000| is_utf8_alpha||5.006000| is_utf8_ascii||5.006000| is_utf8_char_slow|||n is_utf8_char||5.006000| is_utf8_cntrl||5.006000| is_utf8_common||| is_utf8_digit||5.006000| is_utf8_graph||5.006000| is_utf8_idcont||5.008000| is_utf8_idfirst||5.006000| is_utf8_lower||5.006000| is_utf8_mark||5.006000| is_utf8_print||5.006000| is_utf8_punct||5.006000| is_utf8_space||5.006000| is_utf8_string_loclen||5.009003| is_utf8_string_loc||5.008001| is_utf8_string||5.006001| is_utf8_upper||5.006000| is_utf8_xdigit||5.006000| isa_lookup||| items|||n ix|||n jmaybe||| join_exact||| keyword||| leave_scope||| lex_end||| lex_start||| linklist||| listkids||| list||| load_module_nocontext|||vn load_module|5.006000||pv localize||| looks_like_bool||| looks_like_number||| lop||| mPUSHi|5.009002||p mPUSHn|5.009002||p mPUSHp|5.009002||p mPUSHs|5.011000||p mPUSHu|5.009002||p mXPUSHi|5.009002||p mXPUSHn|5.009002||p mXPUSHp|5.009002||p mXPUSHs|5.011000||p mXPUSHu|5.009002||p mad_free||| madlex||| madparse||| magic_clear_all_env||| magic_clearenv||| magic_clearhint||| magic_clearisa||| magic_clearpack||| magic_clearsig||| magic_dump||5.006000| magic_existspack||| magic_freearylen_p||| magic_freeovrld||| magic_getarylen||| magic_getdefelem||| magic_getnkeys||| magic_getpack||| magic_getpos||| magic_getsig||| magic_getsubstr||| magic_gettaint||| magic_getuvar||| magic_getvec||| magic_get||| magic_killbackrefs||| magic_len||| magic_methcall||| magic_methpack||| magic_nextpack||| magic_regdata_cnt||| magic_regdatum_get||| magic_regdatum_set||| magic_scalarpack||| magic_set_all_env||| magic_setamagic||| magic_setarylen||| magic_setcollxfrm||| magic_setdbline||| magic_setdefelem||| magic_setenv||| magic_sethint||| magic_setisa||| magic_setmglob||| magic_setnkeys||| magic_setpack||| magic_setpos||| magic_setregexp||| magic_setsig||| magic_setsubstr||| magic_settaint||| magic_setutf8||| magic_setuvar||| magic_setvec||| magic_set||| magic_sizepack||| magic_wipepack||| make_matcher||| make_trie_failtable||| make_trie||| malloc_good_size|||n malloced_size|||n malloc||5.007002|n markstack_grow||| matcher_matches_sv||| measure_struct||| memEQ|5.004000||p memNE|5.004000||p mem_collxfrm||| mem_log_common|||n mess_alloc||| mess_nocontext|||vn mess||5.006000|v method_common||| mfree||5.007002|n mg_clear||| mg_copy||| mg_dup||| mg_find||| mg_free||| mg_get||| mg_length||5.005000| mg_localize||| mg_magical||| mg_set||| mg_size||5.005000| mini_mktime||5.007002| missingterm||| mode_from_discipline||| modkids||| mod||| more_bodies||| more_sv||| moreswitches||| mro_get_from_name||5.011000| mro_get_linear_isa_dfs||| mro_get_linear_isa||5.009005| mro_get_private_data||5.011000| mro_isa_changed_in||| mro_meta_dup||| mro_meta_init||| mro_method_changed_in||5.009005| mro_register||5.011000| mro_set_mro||5.011000| mro_set_private_data||5.011000| mul128||| mulexp10|||n my_atof2||5.007002| my_atof||5.006000| my_attrs||| my_bcopy|||n my_betoh16|||n my_betoh32|||n my_betoh64|||n my_betohi|||n my_betohl|||n my_betohs|||n my_bzero|||n my_chsize||| my_clearenv||| my_cxt_index||| my_cxt_init||| my_dirfd||5.009005| my_exit_jump||| my_exit||| my_failure_exit||5.004000| my_fflush_all||5.006000| my_fork||5.007003|n my_htobe16|||n my_htobe32|||n my_htobe64|||n my_htobei|||n my_htobel|||n my_htobes|||n my_htole16|||n my_htole32|||n my_htole64|||n my_htolei|||n my_htolel|||n my_htoles|||n my_htonl||| my_kid||| my_letoh16|||n my_letoh32|||n my_letoh64|||n my_letohi|||n my_letohl|||n my_letohs|||n my_lstat||| my_memcmp||5.004000|n my_memset|||n my_ntohl||| my_pclose||5.004000| my_popen_list||5.007001| my_popen||5.004000| my_setenv||| my_snprintf|5.009004||pvn my_socketpair||5.007003|n my_sprintf|5.009003||pvn my_stat||| my_strftime||5.007002| my_strlcat|5.009004||pn my_strlcpy|5.009004||pn my_swabn|||n my_swap||| my_unexec||| my_vsnprintf||5.009004|n need_utf8|||n newANONATTRSUB||5.006000| newANONHASH||| newANONLIST||| newANONSUB||| newASSIGNOP||| newATTRSUB||5.006000| newAVREF||| newAV||| newBINOP||| newCONDOP||| newCONSTSUB|5.004050||p newCVREF||| newDEFSVOP||| newFORM||| newFOROP||| newGIVENOP||5.009003| newGIVWHENOP||| newGP||| newGVOP||| newGVREF||| newGVgen||| newHVREF||| newHVhv||5.005000| newHV||| newIO||| newLISTOP||| newLOGOP||| newLOOPEX||| newLOOPOP||| newMADPROP||| newMADsv||| newMYSUB||| newNULLLIST||| newOP||| newPADOP||| newPMOP||| newPROG||| newPVOP||| newRANGE||| newRV_inc|5.004000||p newRV_noinc|5.004000||p newRV||| newSLICEOP||| newSTATEOP||| newSUB||| newSVOP||| newSVREF||| newSV_type|5.009005||p newSVhek||5.009003| newSViv||| newSVnv||| newSVpvf_nocontext|||vn newSVpvf||5.004000|v newSVpvn_flags|5.011000||p newSVpvn_share|5.007001||p newSVpvn_utf8|5.011000||p newSVpvn|5.004050||p newSVpvs_flags|5.011000||p newSVpvs_share||5.009003| newSVpvs|5.009003||p newSVpv||| newSVrv||| newSVsv||| newSVuv|5.006000||p newSV||| newTOKEN||| newUNOP||| newWHENOP||5.009003| newWHILEOP||5.009003| newXS_flags||5.009004| newXSproto||5.006000| newXS||5.006000| new_collate||5.006000| new_constant||| new_ctype||5.006000| new_he||| new_logop||| new_numeric||5.006000| new_stackinfo||5.005000| new_version||5.009000| new_warnings_bitfield||| next_symbol||| nextargv||| nextchar||| ninstr||| no_bareword_allowed||| no_fh_allowed||| no_op||| not_a_number||| nothreadhook||5.008000| nuke_stacks||| num_overflow|||n offer_nice_chunk||| oopsAV||| oopsHV||| op_clear||| op_const_sv||| op_dump||5.006000| op_free||| op_getmad_weak||| op_getmad||| op_null||5.007002| op_refcnt_dec||| op_refcnt_inc||| op_refcnt_lock||5.009002| op_refcnt_unlock||5.009002| op_xmldump||| open_script||| pMY_CXT_|5.007003||p pMY_CXT|5.007003||p pTHX_|5.006000||p pTHX|5.006000||p packWARN|5.007003||p pack_cat||5.007003| pack_rec||| package||| packlist||5.008001| pad_add_anon||| pad_add_name||| pad_alloc||| pad_block_start||| pad_check_dup||| pad_compname_type||| pad_findlex||| pad_findmy||| pad_fixup_inner_anons||| pad_free||| pad_leavemy||| pad_new||| pad_peg|||n pad_push||| pad_reset||| pad_setsv||| pad_sv||5.011000| pad_swipe||| pad_tidy||| pad_undef||| parse_body||| parse_unicode_opts||| parser_dup||| parser_free||| path_is_absolute|||n peep||| pending_Slabs_to_ro||| perl_alloc_using|||n perl_alloc|||n perl_clone_using|||n perl_clone|||n perl_construct|||n perl_destruct||5.007003|n perl_free|||n perl_parse||5.006000|n perl_run|||n pidgone||| pm_description||| pmflag||| pmop_dump||5.006000| pmop_xmldump||| pmruntime||| pmtrans||| pop_scope||| pregcomp||5.009005| pregexec||| pregfree2||5.011000| pregfree||| prepend_elem||| prepend_madprops||| printbuf||| printf_nocontext|||vn process_special_blocks||| ptr_table_clear||5.009005| ptr_table_fetch||5.009005| ptr_table_find|||n ptr_table_free||5.009005| ptr_table_new||5.009005| ptr_table_split||5.009005| ptr_table_store||5.009005| push_scope||| put_byte||| pv_display|5.006000||p pv_escape|5.009004||p pv_pretty|5.009004||p pv_uni_display||5.007003| qerror||| qsortsvu||| re_compile||5.009005| re_croak2||| re_dup_guts||| re_intuit_start||5.009005| re_intuit_string||5.006000| readpipe_override||| realloc||5.007002|n reentrant_free||| reentrant_init||| reentrant_retry|||vn reentrant_size||| ref_array_or_hash||| refcounted_he_chain_2hv||| refcounted_he_fetch||| refcounted_he_free||| refcounted_he_new_common||| refcounted_he_new||| refcounted_he_value||| refkids||| refto||| ref||5.011000| reg_check_named_buff_matched||| reg_named_buff_all||5.009005| reg_named_buff_exists||5.009005| reg_named_buff_fetch||5.009005| reg_named_buff_firstkey||5.009005| reg_named_buff_iter||| reg_named_buff_nextkey||5.009005| reg_named_buff_scalar||5.009005| reg_named_buff||| reg_namedseq||| reg_node||| reg_numbered_buff_fetch||| reg_numbered_buff_length||| reg_numbered_buff_store||| reg_qr_package||| reg_recode||| reg_scan_name||| reg_skipcomment||| reg_temp_copy||| reganode||| regatom||| regbranch||| regclass_swash||5.009004| regclass||| regcppop||| regcppush||| regcurly|||n regdump_extflags||| regdump||5.005000| regdupe_internal||| regexec_flags||5.005000| regfree_internal||5.009005| reghop3|||n reghop4|||n reghopmaybe3|||n reginclass||| reginitcolors||5.006000| reginsert||| regmatch||| regnext||5.005000| regpiece||| regpposixcc||| regprop||| regrepeat||| regtail_study||| regtail||| regtry||| reguni||| regwhite|||n reg||| repeatcpy||| report_evil_fh||| report_uninit||| require_pv||5.006000| require_tie_mod||| restore_magic||| rninstr||| rsignal_restore||| rsignal_save||| rsignal_state||5.004000| rsignal||5.004000| run_body||| run_user_filter||| runops_debug||5.005000| runops_standard||5.005000| rvpv_dup||| rxres_free||| rxres_restore||| rxres_save||| safesyscalloc||5.006000|n safesysfree||5.006000|n safesysmalloc||5.006000|n safesysrealloc||5.006000|n same_dirent||| save_I16||5.004000| save_I32||| save_I8||5.006000| save_adelete||5.011000| save_aelem||5.004050| save_alloc||5.006000| save_aptr||| save_ary||| save_bool||5.008001| save_clearsv||| save_delete||| save_destructor_x||5.006000| save_destructor||5.006000| save_freeop||| save_freepv||| save_freesv||| save_generic_pvref||5.006001| save_generic_svref||5.005030| save_gp||5.004000| save_hash||| save_hek_flags|||n save_helem_flags||5.011000| save_helem||5.004050| save_hints||| save_hptr||| save_int||| save_item||| save_iv||5.005000| save_lines||| save_list||| save_long||| save_magic||| save_mortalizesv||5.007001| save_nogv||| save_op||| save_padsv_and_mortalize||5.011000| save_pptr||| save_pushi32ptr||| save_pushptri32ptr||| save_pushptrptr||| save_pushptr||5.011000| save_re_context||5.006000| save_scalar_at||| save_scalar||| save_set_svflags||5.009000| save_shared_pvref||5.007003| save_sptr||| save_svref||| save_vptr||5.006000| savepvn||| savepvs||5.009003| savepv||| savesharedpvn||5.009005| savesharedpv||5.007003| savestack_grow_cnt||5.008001| savestack_grow||| savesvpv||5.009002| sawparens||| scalar_mod_type|||n scalarboolean||| scalarkids||| scalarseq||| scalarvoid||| scalar||| scan_bin||5.006000| scan_commit||| scan_const||| scan_formline||| scan_heredoc||| scan_hex||| scan_ident||| scan_inputsymbol||| scan_num||5.007001| scan_oct||| scan_pat||| scan_str||| scan_subst||| scan_trans||| scan_version||5.009001| scan_vstring||5.009005| scan_word||| scope||| screaminstr||5.005000| search_const||| seed||5.008001| sequence_num||| sequence_tail||| sequence||| set_context||5.006000|n set_numeric_local||5.006000| set_numeric_radix||5.006000| set_numeric_standard||5.006000| setdefout||| share_hek_flags||| share_hek||5.004000| si_dup||| sighandler|||n simplify_sort||| skipspace0||| skipspace1||| skipspace2||| skipspace||| softref2xv||| sortcv_stacked||| sortcv_xsub||| sortcv||| sortsv_flags||5.009003| sortsv||5.007003| space_join_names_mortal||| ss_dup||| stack_grow||| start_force||| start_glob||| start_subparse||5.004000| stashpv_hvname_match||5.011000| stdize_locale||| store_cop_label||| strEQ||| strGE||| strGT||| strLE||| strLT||| strNE||| str_to_version||5.006000| strip_return||| strnEQ||| strnNE||| study_chunk||| sub_crush_depth||| sublex_done||| sublex_push||| sublex_start||| sv_2bool||| sv_2cv||| sv_2io||| sv_2iuv_common||| sv_2iuv_non_preserve||| sv_2iv_flags||5.009001| sv_2iv||| sv_2mortal||| sv_2num||| sv_2nv||| sv_2pv_flags|5.007002||p sv_2pv_nolen|5.006000||p sv_2pvbyte_nolen|5.006000||p sv_2pvbyte|5.006000||p sv_2pvutf8_nolen||5.006000| sv_2pvutf8||5.006000| sv_2pv||| sv_2uv_flags||5.009001| sv_2uv|5.004000||p sv_add_arena||| sv_add_backref||| sv_backoff||| sv_bless||| sv_cat_decode||5.008001| sv_catpv_mg|5.004050||p sv_catpvf_mg_nocontext|||pvn sv_catpvf_mg|5.006000|5.004000|pv sv_catpvf_nocontext|||vn sv_catpvf||5.004000|v sv_catpvn_flags||5.007002| sv_catpvn_mg|5.004050||p sv_catpvn_nomg|5.007002||p sv_catpvn||| sv_catpvs|5.009003||p sv_catpv||| sv_catsv_flags||5.007002| sv_catsv_mg|5.004050||p sv_catsv_nomg|5.007002||p sv_catsv||| sv_catxmlpvn||| sv_catxmlsv||| sv_chop||| sv_clean_all||| sv_clean_objs||| sv_clear||| sv_cmp_locale||5.004000| sv_cmp||| sv_collxfrm||| sv_compile_2op||5.008001| sv_copypv||5.007003| sv_dec||| sv_del_backref||| sv_derived_from||5.004000| sv_destroyable||5.010000| sv_does||5.009004| sv_dump||| sv_dup_inc_multiple||| sv_dup||| sv_eq||| sv_exp_grow||| sv_force_normal_flags||5.007001| sv_force_normal||5.006000| sv_free2||| sv_free_arenas||| sv_free||| sv_gets||5.004000| sv_grow||| sv_i_ncmp||| sv_inc||| sv_insert_flags||5.011000| sv_insert||| sv_isa||| sv_isobject||| sv_iv||5.005000| sv_kill_backrefs||| sv_len_utf8||5.006000| sv_len||| sv_magic_portable|5.011000|5.004000|p sv_magicext||5.007003| sv_magic||| sv_mortalcopy||| sv_ncmp||| sv_newmortal||| sv_newref||| sv_nolocking||5.007003| sv_nosharing||5.007003| sv_nounlocking||| sv_nv||5.005000| sv_peek||5.005000| sv_pos_b2u_midway||| sv_pos_b2u||5.006000| sv_pos_u2b_cached||| sv_pos_u2b_forwards|||n sv_pos_u2b_midway|||n sv_pos_u2b||5.006000| sv_pvbyten_force||5.006000| sv_pvbyten||5.006000| sv_pvbyte||5.006000| sv_pvn_force_flags|5.007002||p sv_pvn_force||| sv_pvn_nomg|5.007003|5.005000|p sv_pvn||5.005000| sv_pvutf8n_force||5.006000| sv_pvutf8n||5.006000| sv_pvutf8||5.006000| sv_pv||5.006000| sv_recode_to_utf8||5.007003| sv_reftype||| sv_release_COW||| sv_replace||| sv_report_used||| sv_reset||| sv_rvweaken||5.006000| sv_setiv_mg|5.004050||p sv_setiv||| sv_setnv_mg|5.006000||p sv_setnv||| sv_setpv_mg|5.004050||p sv_setpvf_mg_nocontext|||pvn sv_setpvf_mg|5.006000|5.004000|pv sv_setpvf_nocontext|||vn sv_setpvf||5.004000|v sv_setpviv_mg||5.008001| sv_setpviv||5.008001| sv_setpvn_mg|5.004050||p sv_setpvn||| sv_setpvs|5.009004||p sv_setpv||| sv_setref_iv||| sv_setref_nv||| sv_setref_pvn||| sv_setref_pv||| sv_setref_uv||5.007001| sv_setsv_cow||| sv_setsv_flags||5.007002| sv_setsv_mg|5.004050||p sv_setsv_nomg|5.007002||p sv_setsv||| sv_setuv_mg|5.004050||p sv_setuv|5.004000||p sv_tainted||5.004000| sv_taint||5.004000| sv_true||5.005000| sv_unglob||| sv_uni_display||5.007003| sv_unmagic||| sv_unref_flags||5.007001| sv_unref||| sv_untaint||5.004000| sv_upgrade||| sv_usepvn_flags||5.009004| sv_usepvn_mg|5.004050||p sv_usepvn||| sv_utf8_decode||5.006000| sv_utf8_downgrade||5.006000| sv_utf8_encode||5.006000| sv_utf8_upgrade_flags_grow||5.011000| sv_utf8_upgrade_flags||5.007002| sv_utf8_upgrade_nomg||5.007002| sv_utf8_upgrade||5.007001| sv_uv|5.005000||p sv_vcatpvf_mg|5.006000|5.004000|p sv_vcatpvfn||5.004000| sv_vcatpvf|5.006000|5.004000|p sv_vsetpvf_mg|5.006000|5.004000|p sv_vsetpvfn||5.004000| sv_vsetpvf|5.006000|5.004000|p sv_xmlpeek||| svtype||| swallow_bom||| swap_match_buff||| swash_fetch||5.007002| swash_get||| swash_init||5.006000| sys_init3||5.010000|n sys_init||5.010000|n sys_intern_clear||| sys_intern_dup||| sys_intern_init||| sys_term||5.010000|n taint_env||| taint_proper||| tmps_grow||5.006000| toLOWER||| toUPPER||| to_byte_substr||| to_uni_fold||5.007003| to_uni_lower_lc||5.006000| to_uni_lower||5.007003| to_uni_title_lc||5.006000| to_uni_title||5.007003| to_uni_upper_lc||5.006000| to_uni_upper||5.007003| to_utf8_case||5.007003| to_utf8_fold||5.007003| to_utf8_lower||5.007003| to_utf8_substr||| to_utf8_title||5.007003| to_utf8_upper||5.007003| token_free||| token_getmad||| tokenize_use||| tokeq||| tokereport||| too_few_arguments||| too_many_arguments||| uiv_2buf|||n unlnk||| unpack_rec||| unpack_str||5.007003| unpackstring||5.008001| unshare_hek_or_pvn||| unshare_hek||| unsharepvn||5.004000| unwind_handler_stack||| update_debugger_info||| upg_version||5.009005| usage||| utf16_to_utf8_reversed||5.006001| utf16_to_utf8||5.006001| utf8_distance||5.006000| utf8_hop||5.006000| utf8_length||5.007001| utf8_mg_pos_cache_update||| utf8_to_bytes||5.006001| utf8_to_uvchr||5.007001| utf8_to_uvuni||5.007001| utf8n_to_uvchr||| utf8n_to_uvuni||5.007001| utilize||| uvchr_to_utf8_flags||5.007003| uvchr_to_utf8||| uvuni_to_utf8_flags||5.007003| uvuni_to_utf8||5.007001| validate_suid||| varname||| vcmp||5.009000| vcroak||5.006000| vdeb||5.007003| vdie_common||| vdie_croak_common||| vdie||| vform||5.006000| visit||| vivify_defelem||| vivify_ref||| vload_module|5.006000||p vmess||5.006000| vnewSVpvf|5.006000|5.004000|p vnormal||5.009002| vnumify||5.009000| vstringify||5.009000| vverify||5.009003| vwarner||5.006000| vwarn||5.006000| wait4pid||| warn_nocontext|||vn warner_nocontext|||vn warner|5.006000|5.004000|pv warn|||v watch||| whichsig||| write_no_mem||| write_to_stderr||| xmldump_all||| xmldump_attr||| xmldump_eval||| xmldump_form||| xmldump_indent|||v xmldump_packsubs||| xmldump_sub||| xmldump_vindent||| yyerror||| yylex||| yyparse||| yywarn||| ); if (exists $opt{'list-unsupported'}) { my $f; for $f (sort { lc $a cmp lc $b } keys %API) { next unless $API{$f}{todo}; print "$f ", '.'x(40-length($f)), " ", format_version($API{$f}{todo}), "\n"; } exit 0; } # Scan for possible replacement candidates my(%replace, %need, %hints, %warnings, %depends); my $replace = 0; my($hint, $define, $function); sub find_api { my $code = shift; $code =~ s{ / (?: \*[^*]*\*+(?:[^$ccs][^*]*\*+)* / | /[^\r\n]*) | "[^"\\]*(?:\\.[^"\\]*)*" | '[^'\\]*(?:\\.[^'\\]*)*' }{}egsx; grep { exists $API{$_} } $code =~ /(\w+)/mg; } while () { if ($hint) { my $h = $hint->[0] eq 'Hint' ? \%hints : \%warnings; if (m{^\s*\*\s(.*?)\s*$}) { for (@{$hint->[1]}) { $h->{$_} ||= ''; # suppress warning with older perls $h->{$_} .= "$1\n"; } } else { undef $hint } } $hint = [$1, [split /,?\s+/, $2]] if m{^\s*$rccs\s+(Hint|Warning):\s+(\w+(?:,?\s+\w+)*)\s*$}; if ($define) { if ($define->[1] =~ /\\$/) { $define->[1] .= $_; } else { if (exists $API{$define->[0]} && $define->[1] !~ /^DPPP_\(/) { my @n = find_api($define->[1]); push @{$depends{$define->[0]}}, @n if @n } undef $define; } } $define = [$1, $2] if m{^\s*#\s*define\s+(\w+)(?:\([^)]*\))?\s+(.*)}; if ($function) { if (/^}/) { if (exists $API{$function->[0]}) { my @n = find_api($function->[1]); push @{$depends{$function->[0]}}, @n if @n } undef $function; } else { $function->[1] .= $_; } } $function = [$1, ''] if m{^DPPP_\(my_(\w+)\)}; $replace = $1 if m{^\s*$rccs\s+Replace:\s+(\d+)\s+$rcce\s*$}; $replace{$2} = $1 if $replace and m{^\s*#\s*define\s+(\w+)(?:\([^)]*\))?\s+(\w+)}; $replace{$2} = $1 if m{^\s*#\s*define\s+(\w+)(?:\([^)]*\))?\s+(\w+).*$rccs\s+Replace\s+$rcce}; $replace{$1} = $2 if m{^\s*$rccs\s+Replace (\w+) with (\w+)\s+$rcce\s*$}; if (m{^\s*$rccs\s+(\w+(\s*,\s*\w+)*)\s+depends\s+on\s+(\w+(\s*,\s*\w+)*)\s+$rcce\s*$}) { my @deps = map { s/\s+//g; $_ } split /,/, $3; my $d; for $d (map { s/\s+//g; $_ } split /,/, $1) { push @{$depends{$d}}, @deps; } } $need{$1} = 1 if m{^#if\s+defined\(NEED_(\w+)(?:_GLOBAL)?\)}; } for (values %depends) { my %s; $_ = [sort grep !$s{$_}++, @$_]; } if (exists $opt{'api-info'}) { my $f; my $count = 0; my $match = $opt{'api-info'} =~ m!^/(.*)/$! ? $1 : "^\Q$opt{'api-info'}\E\$"; for $f (sort { lc $a cmp lc $b } keys %API) { next unless $f =~ /$match/; print "\n=== $f ===\n\n"; my $info = 0; if ($API{$f}{base} || $API{$f}{todo}) { my $base = format_version($API{$f}{base} || $API{$f}{todo}); print "Supported at least starting from perl-$base.\n"; $info++; } if ($API{$f}{provided}) { my $todo = $API{$f}{todo} ? format_version($API{$f}{todo}) : "5.003"; print "Support by $ppport provided back to perl-$todo.\n"; print "Support needs to be explicitly requested by NEED_$f.\n" if exists $need{$f}; print "Depends on: ", join(', ', @{$depends{$f}}), ".\n" if exists $depends{$f}; print "\n$hints{$f}" if exists $hints{$f}; print "\nWARNING:\n$warnings{$f}" if exists $warnings{$f}; $info++; } print "No portability information available.\n" unless $info; $count++; } $count or print "Found no API matching '$opt{'api-info'}'."; print "\n"; exit 0; } if (exists $opt{'list-provided'}) { my $f; for $f (sort { lc $a cmp lc $b } keys %API) { next unless $API{$f}{provided}; my @flags; push @flags, 'explicit' if exists $need{$f}; push @flags, 'depend' if exists $depends{$f}; push @flags, 'hint' if exists $hints{$f}; push @flags, 'warning' if exists $warnings{$f}; my $flags = @flags ? ' ['.join(', ', @flags).']' : ''; print "$f$flags\n"; } exit 0; } my @files; my @srcext = qw( .xs .c .h .cc .cpp -c.inc -xs.inc ); my $srcext = join '|', map { quotemeta $_ } @srcext; if (@ARGV) { my %seen; for (@ARGV) { if (-e) { if (-f) { push @files, $_ unless $seen{$_}++; } else { warn "'$_' is not a file.\n" } } else { my @new = grep { -f } glob $_ or warn "'$_' does not exist.\n"; push @files, grep { !$seen{$_}++ } @new; } } } else { eval { require File::Find; File::Find::find(sub { $File::Find::name =~ /($srcext)$/i and push @files, $File::Find::name; }, '.'); }; if ($@) { @files = map { glob "*$_" } @srcext; } } if (!@ARGV || $opt{filter}) { my(@in, @out); my %xsc = map { /(.*)\.xs$/ ? ("$1.c" => 1, "$1.cc" => 1) : () } @files; for (@files) { my $out = exists $xsc{$_} || /\b\Q$ppport\E$/i || !/($srcext)$/i; push @{ $out ? \@out : \@in }, $_; } if (@ARGV && @out) { warning("Skipping the following files (use --nofilter to avoid this):\n| ", join "\n| ", @out); } @files = @in; } die "No input files given!\n" unless @files; my(%files, %global, %revreplace); %revreplace = reverse %replace; my $filename; my $patch_opened = 0; for $filename (@files) { unless (open IN, "<$filename") { warn "Unable to read from $filename: $!\n"; next; } info("Scanning $filename ..."); my $c = do { local $/; }; close IN; my %file = (orig => $c, changes => 0); # Temporarily remove C/XS comments and strings from the code my @ccom; $c =~ s{ ( ^$HS*\#$HS*include\b[^\r\n]+\b(?:\Q$ppport\E|XSUB\.h)\b[^\r\n]* | ^$HS*\#$HS*(?:define|elif|if(?:def)?)\b[^\r\n]* ) | ( ^$HS*\#[^\r\n]* | "[^"\\]*(?:\\.[^"\\]*)*" | '[^'\\]*(?:\\.[^'\\]*)*' | / (?: \*[^*]*\*+(?:[^$ccs][^*]*\*+)* / | /[^\r\n]* ) ) }{ defined $2 and push @ccom, $2; defined $1 ? $1 : "$ccs$#ccom$cce" }mgsex; $file{ccom} = \@ccom; $file{code} = $c; $file{has_inc_ppport} = $c =~ /^$HS*#$HS*include[^\r\n]+\b\Q$ppport\E\b/m; my $func; for $func (keys %API) { my $match = $func; $match .= "|$revreplace{$func}" if exists $revreplace{$func}; if ($c =~ /\b(?:Perl_)?($match)\b/) { $file{uses_replace}{$1}++ if exists $revreplace{$func} && $1 eq $revreplace{$func}; $file{uses_Perl}{$func}++ if $c =~ /\bPerl_$func\b/; if (exists $API{$func}{provided}) { $file{uses_provided}{$func}++; if (!exists $API{$func}{base} || $API{$func}{base} > $opt{'compat-version'}) { $file{uses}{$func}++; my @deps = rec_depend($func); if (@deps) { $file{uses_deps}{$func} = \@deps; for (@deps) { $file{uses}{$_} = 0 unless exists $file{uses}{$_}; } } for ($func, @deps) { $file{needs}{$_} = 'static' if exists $need{$_}; } } } if (exists $API{$func}{todo} && $API{$func}{todo} > $opt{'compat-version'}) { if ($c =~ /\b$func\b/) { $file{uses_todo}{$func}++; } } } } while ($c =~ /^$HS*#$HS*define$HS+(NEED_(\w+?)(_GLOBAL)?)\b/mg) { if (exists $need{$2}) { $file{defined $3 ? 'needed_global' : 'needed_static'}{$2}++; } else { warning("Possibly wrong #define $1 in $filename") } } for (qw(uses needs uses_todo needed_global needed_static)) { for $func (keys %{$file{$_}}) { push @{$global{$_}{$func}}, $filename; } } $files{$filename} = \%file; } # Globally resolve NEED_'s my $need; for $need (keys %{$global{needs}}) { if (@{$global{needs}{$need}} > 1) { my @targets = @{$global{needs}{$need}}; my @t = grep $files{$_}{needed_global}{$need}, @targets; @targets = @t if @t; @t = grep /\.xs$/i, @targets; @targets = @t if @t; my $target = shift @targets; $files{$target}{needs}{$need} = 'global'; for (@{$global{needs}{$need}}) { $files{$_}{needs}{$need} = 'extern' if $_ ne $target; } } } for $filename (@files) { exists $files{$filename} or next; info("=== Analyzing $filename ==="); my %file = %{$files{$filename}}; my $func; my $c = $file{code}; my $warnings = 0; for $func (sort keys %{$file{uses_Perl}}) { if ($API{$func}{varargs}) { unless ($API{$func}{nothxarg}) { my $changes = ($c =~ s{\b(Perl_$func\s*\(\s*)(?!aTHX_?)(\)|[^\s)]*\))} { $1 . ($2 eq ')' ? 'aTHX' : 'aTHX_ ') . $2 }ge); if ($changes) { warning("Doesn't pass interpreter argument aTHX to Perl_$func"); $file{changes} += $changes; } } } else { warning("Uses Perl_$func instead of $func"); $file{changes} += ($c =~ s{\bPerl_$func(\s*)\((\s*aTHX_?)?\s*} {$func$1(}g); } } for $func (sort keys %{$file{uses_replace}}) { warning("Uses $func instead of $replace{$func}"); $file{changes} += ($c =~ s/\b$func\b/$replace{$func}/g); } for $func (sort keys %{$file{uses_provided}}) { if ($file{uses}{$func}) { if (exists $file{uses_deps}{$func}) { diag("Uses $func, which depends on ", join(', ', @{$file{uses_deps}{$func}})); } else { diag("Uses $func"); } } $warnings += hint($func); } unless ($opt{quiet}) { for $func (sort keys %{$file{uses_todo}}) { print "*** WARNING: Uses $func, which may not be portable below perl ", format_version($API{$func}{todo}), ", even with '$ppport'\n"; $warnings++; } } for $func (sort keys %{$file{needed_static}}) { my $message = ''; if (not exists $file{uses}{$func}) { $message = "No need to define NEED_$func if $func is never used"; } elsif (exists $file{needs}{$func} && $file{needs}{$func} ne 'static') { $message = "No need to define NEED_$func when already needed globally"; } if ($message) { diag($message); $file{changes} += ($c =~ s/^$HS*#$HS*define$HS+NEED_$func\b.*$LF//mg); } } for $func (sort keys %{$file{needed_global}}) { my $message = ''; if (not exists $global{uses}{$func}) { $message = "No need to define NEED_${func}_GLOBAL if $func is never used"; } elsif (exists $file{needs}{$func}) { if ($file{needs}{$func} eq 'extern') { $message = "No need to define NEED_${func}_GLOBAL when already needed globally"; } elsif ($file{needs}{$func} eq 'static') { $message = "No need to define NEED_${func}_GLOBAL when only used in this file"; } } if ($message) { diag($message); $file{changes} += ($c =~ s/^$HS*#$HS*define$HS+NEED_${func}_GLOBAL\b.*$LF//mg); } } $file{needs_inc_ppport} = keys %{$file{uses}}; if ($file{needs_inc_ppport}) { my $pp = ''; for $func (sort keys %{$file{needs}}) { my $type = $file{needs}{$func}; next if $type eq 'extern'; my $suffix = $type eq 'global' ? '_GLOBAL' : ''; unless (exists $file{"needed_$type"}{$func}) { if ($type eq 'global') { diag("Files [@{$global{needs}{$func}}] need $func, adding global request"); } else { diag("File needs $func, adding static request"); } $pp .= "#define NEED_$func$suffix\n"; } } if ($pp && ($c =~ s/^(?=$HS*#$HS*define$HS+NEED_\w+)/$pp/m)) { $pp = ''; $file{changes}++; } unless ($file{has_inc_ppport}) { diag("Needs to include '$ppport'"); $pp .= qq(#include "$ppport"\n) } if ($pp) { $file{changes} += ($c =~ s/^($HS*#$HS*define$HS+NEED_\w+.*?)^/$1$pp/ms) || ($c =~ s/^(?=$HS*#$HS*include.*\Q$ppport\E)/$pp/m) || ($c =~ s/^($HS*#$HS*include.*XSUB.*\s*?)^/$1$pp/m) || ($c =~ s/^/$pp/); } } else { if ($file{has_inc_ppport}) { diag("No need to include '$ppport'"); $file{changes} += ($c =~ s/^$HS*?#$HS*include.*\Q$ppport\E.*?$LF//m); } } # put back in our C comments my $ix; my $cppc = 0; my @ccom = @{$file{ccom}}; for $ix (0 .. $#ccom) { if (!$opt{cplusplus} && $ccom[$ix] =~ s!^//!!) { $cppc++; $file{changes} += $c =~ s/$rccs$ix$rcce/$ccs$ccom[$ix] $cce/; } else { $c =~ s/$rccs$ix$rcce/$ccom[$ix]/; } } if ($cppc) { my $s = $cppc != 1 ? 's' : ''; warning("Uses $cppc C++ style comment$s, which is not portable"); } my $s = $warnings != 1 ? 's' : ''; my $warn = $warnings ? " ($warnings warning$s)" : ''; info("Analysis completed$warn"); if ($file{changes}) { if (exists $opt{copy}) { my $newfile = "$filename$opt{copy}"; if (-e $newfile) { error("'$newfile' already exists, refusing to write copy of '$filename'"); } else { local *F; if (open F, ">$newfile") { info("Writing copy of '$filename' with changes to '$newfile'"); print F $c; close F; } else { error("Cannot open '$newfile' for writing: $!"); } } } elsif (exists $opt{patch} || $opt{changes}) { if (exists $opt{patch}) { unless ($patch_opened) { if (open PATCH, ">$opt{patch}") { $patch_opened = 1; } else { error("Cannot open '$opt{patch}' for writing: $!"); delete $opt{patch}; $opt{changes} = 1; goto fallback; } } mydiff(\*PATCH, $filename, $c); } else { fallback: info("Suggested changes:"); mydiff(\*STDOUT, $filename, $c); } } else { my $s = $file{changes} == 1 ? '' : 's'; info("$file{changes} potentially required change$s detected"); } } else { info("Looks good"); } } close PATCH if $patch_opened; exit 0; sub try_use { eval "use @_;"; return $@ eq '' } sub mydiff { local *F = shift; my($file, $str) = @_; my $diff; if (exists $opt{diff}) { $diff = run_diff($opt{diff}, $file, $str); } if (!defined $diff and try_use('Text::Diff')) { $diff = Text::Diff::diff($file, \$str, { STYLE => 'Unified' }); $diff = <
$tmp") { print F $str; close F; if (open F, "$prog $file $tmp |") { while () { s/\Q$tmp\E/$file.patched/; $diff .= $_; } close F; unlink $tmp; return $diff; } unlink $tmp; } else { error("Cannot open '$tmp' for writing: $!"); } return undef; } sub rec_depend { my($func, $seen) = @_; return () unless exists $depends{$func}; $seen = {%{$seen||{}}}; return () if $seen->{$func}++; my %s; grep !$s{$_}++, map { ($_, rec_depend($_, $seen)) } @{$depends{$func}}; } sub parse_version { my $ver = shift; if ($ver =~ /^(\d+)\.(\d+)\.(\d+)$/) { return ($1, $2, $3); } elsif ($ver !~ /^\d+\.[\d_]+$/) { die "cannot parse version '$ver'\n"; } $ver =~ s/_//g; $ver =~ s/$/000000/; my($r,$v,$s) = $ver =~ /(\d+)\.(\d{3})(\d{3})/; $v = int $v; $s = int $s; if ($r < 5 || ($r == 5 && $v < 6)) { if ($s % 10) { die "cannot parse version '$ver'\n"; } } return ($r, $v, $s); } sub format_version { my $ver = shift; $ver =~ s/$/000000/; my($r,$v,$s) = $ver =~ /(\d+)\.(\d{3})(\d{3})/; $v = int $v; $s = int $s; if ($r < 5 || ($r == 5 && $v < 6)) { if ($s % 10) { die "invalid version '$ver'\n"; } $s /= 10; $ver = sprintf "%d.%03d", $r, $v; $s > 0 and $ver .= sprintf "_%02d", $s; return $ver; } return sprintf "%d.%d.%d", $r, $v, $s; } sub info { $opt{quiet} and return; print @_, "\n"; } sub diag { $opt{quiet} and return; $opt{diag} and print @_, "\n"; } sub warning { $opt{quiet} and return; print "*** ", @_, "\n"; } sub error { print "*** ERROR: ", @_, "\n"; } my %given_hints; my %given_warnings; sub hint { $opt{quiet} and return; my $func = shift; my $rv = 0; if (exists $warnings{$func} && !$given_warnings{$func}++) { my $warn = $warnings{$func}; $warn =~ s!^!*** !mg; print "*** WARNING: $func\n", $warn; $rv++; } if ($opt{hints} && exists $hints{$func} && !$given_hints{$func}++) { my $hint = $hints{$func}; $hint =~ s/^/ /mg; print " --- hint for $func ---\n", $hint; } $rv; } sub usage { my($usage) = do { local(@ARGV,$/)=($0); <> } =~ /^=head\d$HS+SYNOPSIS\s*^(.*?)\s*^=/ms; my %M = ( 'I' => '*' ); $usage =~ s/^\s*perl\s+\S+/$^X $0/; $usage =~ s/([A-Z])<([^>]+)>/$M{$1}$2$M{$1}/g; print < }; my($copy) = $self =~ /^=head\d\s+COPYRIGHT\s*^(.*?)^=\w+/ms; $copy =~ s/^(?=\S+)/ /gms; $self =~ s/^$HS+Do NOT edit.*?(?=^-)/$copy/ms; $self =~ s/^SKIP.*(?=^__DATA__)/SKIP if (\@ARGV && \$ARGV[0] eq '--unstrip') { eval { require Devel::PPPort }; \$@ and die "Cannot require Devel::PPPort, please install.\\n"; if (eval \$Devel::PPPort::VERSION < $VERSION) { die "$0 was originally generated with Devel::PPPort $VERSION.\\n" . "Your Devel::PPPort is only version \$Devel::PPPort::VERSION.\\n" . "Please install a newer version, or --unstrip will not work.\\n"; } Devel::PPPort::WriteFile(\$0); exit 0; } print <$0" or die "cannot strip $0: $!\n"; print OUT "$pl$c\n"; exit 0; } __DATA__ */ #ifndef _P_P_PORTABILITY_H_ #define _P_P_PORTABILITY_H_ #ifndef DPPP_NAMESPACE # define DPPP_NAMESPACE DPPP_ #endif #define DPPP_CAT2(x,y) CAT2(x,y) #define DPPP_(name) DPPP_CAT2(DPPP_NAMESPACE, name) #ifndef PERL_REVISION # if !defined(__PATCHLEVEL_H_INCLUDED__) && !(defined(PATCHLEVEL) && defined(SUBVERSION)) # define PERL_PATCHLEVEL_H_IMPLICIT # include # endif # if !(defined(PERL_VERSION) || (defined(SUBVERSION) && defined(PATCHLEVEL))) # include # endif # ifndef PERL_REVISION # define PERL_REVISION (5) /* Replace: 1 */ # define PERL_VERSION PATCHLEVEL # define PERL_SUBVERSION SUBVERSION /* Replace PERL_PATCHLEVEL with PERL_VERSION */ /* Replace: 0 */ # endif #endif #define _dpppDEC2BCD(dec) ((((dec)/100)<<8)|((((dec)%100)/10)<<4)|((dec)%10)) #define PERL_BCDVERSION ((_dpppDEC2BCD(PERL_REVISION)<<24)|(_dpppDEC2BCD(PERL_VERSION)<<12)|_dpppDEC2BCD(PERL_SUBVERSION)) /* It is very unlikely that anyone will try to use this with Perl 6 (or greater), but who knows. */ #if PERL_REVISION != 5 # error ppport.h only works with Perl version 5 #endif /* PERL_REVISION != 5 */ #ifndef dTHR # define dTHR dNOOP #endif #ifndef dTHX # define dTHX dNOOP #endif #ifndef dTHXa # define dTHXa(x) dNOOP #endif #ifndef pTHX # define pTHX void #endif #ifndef pTHX_ # define pTHX_ #endif #ifndef aTHX # define aTHX #endif #ifndef aTHX_ # define aTHX_ #endif #if (PERL_BCDVERSION < 0x5006000) # ifdef USE_THREADS # define aTHXR thr # define aTHXR_ thr, # else # define aTHXR # define aTHXR_ # endif # define dTHXR dTHR #else # define aTHXR aTHX # define aTHXR_ aTHX_ # define dTHXR dTHX #endif #ifndef dTHXoa # define dTHXoa(x) dTHXa(x) #endif #ifdef I_LIMITS # include #endif #ifndef PERL_UCHAR_MIN # define PERL_UCHAR_MIN ((unsigned char)0) #endif #ifndef PERL_UCHAR_MAX # ifdef UCHAR_MAX # define PERL_UCHAR_MAX ((unsigned char)UCHAR_MAX) # else # ifdef MAXUCHAR # define PERL_UCHAR_MAX ((unsigned char)MAXUCHAR) # else # define PERL_UCHAR_MAX ((unsigned char)~(unsigned)0) # endif # endif #endif #ifndef PERL_USHORT_MIN # define PERL_USHORT_MIN ((unsigned short)0) #endif #ifndef PERL_USHORT_MAX # ifdef USHORT_MAX # define PERL_USHORT_MAX ((unsigned short)USHORT_MAX) # else # ifdef MAXUSHORT # define PERL_USHORT_MAX ((unsigned short)MAXUSHORT) # else # ifdef USHRT_MAX # define PERL_USHORT_MAX ((unsigned short)USHRT_MAX) # else # define PERL_USHORT_MAX ((unsigned short)~(unsigned)0) # endif # endif # endif #endif #ifndef PERL_SHORT_MAX # ifdef SHORT_MAX # define PERL_SHORT_MAX ((short)SHORT_MAX) # else # ifdef MAXSHORT /* Often used in */ # define PERL_SHORT_MAX ((short)MAXSHORT) # else # ifdef SHRT_MAX # define PERL_SHORT_MAX ((short)SHRT_MAX) # else # define PERL_SHORT_MAX ((short) (PERL_USHORT_MAX >> 1)) # endif # endif # endif #endif #ifndef PERL_SHORT_MIN # ifdef SHORT_MIN # define PERL_SHORT_MIN ((short)SHORT_MIN) # else # ifdef MINSHORT # define PERL_SHORT_MIN ((short)MINSHORT) # else # ifdef SHRT_MIN # define PERL_SHORT_MIN ((short)SHRT_MIN) # else # define PERL_SHORT_MIN (-PERL_SHORT_MAX - ((3 & -1) == 3)) # endif # endif # endif #endif #ifndef PERL_UINT_MAX # ifdef UINT_MAX # define PERL_UINT_MAX ((unsigned int)UINT_MAX) # else # ifdef MAXUINT # define PERL_UINT_MAX ((unsigned int)MAXUINT) # else # define PERL_UINT_MAX (~(unsigned int)0) # endif # endif #endif #ifndef PERL_UINT_MIN # define PERL_UINT_MIN ((unsigned int)0) #endif #ifndef PERL_INT_MAX # ifdef INT_MAX # define PERL_INT_MAX ((int)INT_MAX) # else # ifdef MAXINT /* Often used in */ # define PERL_INT_MAX ((int)MAXINT) # else # define PERL_INT_MAX ((int)(PERL_UINT_MAX >> 1)) # endif # endif #endif #ifndef PERL_INT_MIN # ifdef INT_MIN # define PERL_INT_MIN ((int)INT_MIN) # else # ifdef MININT # define PERL_INT_MIN ((int)MININT) # else # define PERL_INT_MIN (-PERL_INT_MAX - ((3 & -1) == 3)) # endif # endif #endif #ifndef PERL_ULONG_MAX # ifdef ULONG_MAX # define PERL_ULONG_MAX ((unsigned long)ULONG_MAX) # else # ifdef MAXULONG # define PERL_ULONG_MAX ((unsigned long)MAXULONG) # else # define PERL_ULONG_MAX (~(unsigned long)0) # endif # endif #endif #ifndef PERL_ULONG_MIN # define PERL_ULONG_MIN ((unsigned long)0L) #endif #ifndef PERL_LONG_MAX # ifdef LONG_MAX # define PERL_LONG_MAX ((long)LONG_MAX) # else # ifdef MAXLONG # define PERL_LONG_MAX ((long)MAXLONG) # else # define PERL_LONG_MAX ((long) (PERL_ULONG_MAX >> 1)) # endif # endif #endif #ifndef PERL_LONG_MIN # ifdef LONG_MIN # define PERL_LONG_MIN ((long)LONG_MIN) # else # ifdef MINLONG # define PERL_LONG_MIN ((long)MINLONG) # else # define PERL_LONG_MIN (-PERL_LONG_MAX - ((3 & -1) == 3)) # endif # endif #endif #if defined(HAS_QUAD) && (defined(convex) || defined(uts)) # ifndef PERL_UQUAD_MAX # ifdef ULONGLONG_MAX # define PERL_UQUAD_MAX ((unsigned long long)ULONGLONG_MAX) # else # ifdef MAXULONGLONG # define PERL_UQUAD_MAX ((unsigned long long)MAXULONGLONG) # else # define PERL_UQUAD_MAX (~(unsigned long long)0) # endif # endif # endif # ifndef PERL_UQUAD_MIN # define PERL_UQUAD_MIN ((unsigned long long)0L) # endif # ifndef PERL_QUAD_MAX # ifdef LONGLONG_MAX # define PERL_QUAD_MAX ((long long)LONGLONG_MAX) # else # ifdef MAXLONGLONG # define PERL_QUAD_MAX ((long long)MAXLONGLONG) # else # define PERL_QUAD_MAX ((long long) (PERL_UQUAD_MAX >> 1)) # endif # endif # endif # ifndef PERL_QUAD_MIN # ifdef LONGLONG_MIN # define PERL_QUAD_MIN ((long long)LONGLONG_MIN) # else # ifdef MINLONGLONG # define PERL_QUAD_MIN ((long long)MINLONGLONG) # else # define PERL_QUAD_MIN (-PERL_QUAD_MAX - ((3 & -1) == 3)) # endif # endif # endif #endif /* This is based on code from 5.003 perl.h */ #ifdef HAS_QUAD # ifdef cray #ifndef IVTYPE # define IVTYPE int #endif #ifndef IV_MIN # define IV_MIN PERL_INT_MIN #endif #ifndef IV_MAX # define IV_MAX PERL_INT_MAX #endif #ifndef UV_MIN # define UV_MIN PERL_UINT_MIN #endif #ifndef UV_MAX # define UV_MAX PERL_UINT_MAX #endif # ifdef INTSIZE #ifndef IVSIZE # define IVSIZE INTSIZE #endif # endif # else # if defined(convex) || defined(uts) #ifndef IVTYPE # define IVTYPE long long #endif #ifndef IV_MIN # define IV_MIN PERL_QUAD_MIN #endif #ifndef IV_MAX # define IV_MAX PERL_QUAD_MAX #endif #ifndef UV_MIN # define UV_MIN PERL_UQUAD_MIN #endif #ifndef UV_MAX # define UV_MAX PERL_UQUAD_MAX #endif # ifdef LONGLONGSIZE #ifndef IVSIZE # define IVSIZE LONGLONGSIZE #endif # endif # else #ifndef IVTYPE # define IVTYPE long #endif #ifndef IV_MIN # define IV_MIN PERL_LONG_MIN #endif #ifndef IV_MAX # define IV_MAX PERL_LONG_MAX #endif #ifndef UV_MIN # define UV_MIN PERL_ULONG_MIN #endif #ifndef UV_MAX # define UV_MAX PERL_ULONG_MAX #endif # ifdef LONGSIZE #ifndef IVSIZE # define IVSIZE LONGSIZE #endif # endif # endif # endif #ifndef IVSIZE # define IVSIZE 8 #endif #ifndef PERL_QUAD_MIN # define PERL_QUAD_MIN IV_MIN #endif #ifndef PERL_QUAD_MAX # define PERL_QUAD_MAX IV_MAX #endif #ifndef PERL_UQUAD_MIN # define PERL_UQUAD_MIN UV_MIN #endif #ifndef PERL_UQUAD_MAX # define PERL_UQUAD_MAX UV_MAX #endif #else #ifndef IVTYPE # define IVTYPE long #endif #ifndef IV_MIN # define IV_MIN PERL_LONG_MIN #endif #ifndef IV_MAX # define IV_MAX PERL_LONG_MAX #endif #ifndef UV_MIN # define UV_MIN PERL_ULONG_MIN #endif #ifndef UV_MAX # define UV_MAX PERL_ULONG_MAX #endif #endif #ifndef IVSIZE # ifdef LONGSIZE # define IVSIZE LONGSIZE # else # define IVSIZE 4 /* A bold guess, but the best we can make. */ # endif #endif #ifndef UVTYPE # define UVTYPE unsigned IVTYPE #endif #ifndef UVSIZE # define UVSIZE IVSIZE #endif #ifndef sv_setuv # define sv_setuv(sv, uv) \ STMT_START { \ UV TeMpUv = uv; \ if (TeMpUv <= IV_MAX) \ sv_setiv(sv, TeMpUv); \ else \ sv_setnv(sv, (double)TeMpUv); \ } STMT_END #endif #ifndef newSVuv # define newSVuv(uv) ((uv) <= IV_MAX ? newSViv((IV)uv) : newSVnv((NV)uv)) #endif #ifndef sv_2uv # define sv_2uv(sv) ((PL_Sv = (sv)), (UV) (SvNOK(PL_Sv) ? SvNV(PL_Sv) : sv_2nv(PL_Sv))) #endif #ifndef SvUVX # define SvUVX(sv) ((UV)SvIVX(sv)) #endif #ifndef SvUVXx # define SvUVXx(sv) SvUVX(sv) #endif #ifndef SvUV # define SvUV(sv) (SvIOK(sv) ? SvUVX(sv) : sv_2uv(sv)) #endif #ifndef SvUVx # define SvUVx(sv) ((PL_Sv = (sv)), SvUV(PL_Sv)) #endif /* Hint: sv_uv * Always use the SvUVx() macro instead of sv_uv(). */ #ifndef sv_uv # define sv_uv(sv) SvUVx(sv) #endif #if !defined(SvUOK) && defined(SvIOK_UV) # define SvUOK(sv) SvIOK_UV(sv) #endif #ifndef XST_mUV # define XST_mUV(i,v) (ST(i) = sv_2mortal(newSVuv(v)) ) #endif #ifndef XSRETURN_UV # define XSRETURN_UV(v) STMT_START { XST_mUV(0,v); XSRETURN(1); } STMT_END #endif #ifndef PUSHu # define PUSHu(u) STMT_START { sv_setuv(TARG, (UV)(u)); PUSHTARG; } STMT_END #endif #ifndef XPUSHu # define XPUSHu(u) STMT_START { sv_setuv(TARG, (UV)(u)); XPUSHTARG; } STMT_END #endif #ifdef HAS_MEMCMP #ifndef memNE # define memNE(s1,s2,l) (memcmp(s1,s2,l)) #endif #ifndef memEQ # define memEQ(s1,s2,l) (!memcmp(s1,s2,l)) #endif #else #ifndef memNE # define memNE(s1,s2,l) (bcmp(s1,s2,l)) #endif #ifndef memEQ # define memEQ(s1,s2,l) (!bcmp(s1,s2,l)) #endif #endif #ifndef MoveD # define MoveD(s,d,n,t) memmove((char*)(d),(char*)(s), (n) * sizeof(t)) #endif #ifndef CopyD # define CopyD(s,d,n,t) memcpy((char*)(d),(char*)(s), (n) * sizeof(t)) #endif #ifdef HAS_MEMSET #ifndef ZeroD # define ZeroD(d,n,t) memzero((char*)(d), (n) * sizeof(t)) #endif #else #ifndef ZeroD # define ZeroD(d,n,t) ((void)memzero((char*)(d), (n) * sizeof(t)), d) #endif #endif #ifndef PoisonWith # define PoisonWith(d,n,t,b) (void)memset((char*)(d), (U8)(b), (n) * sizeof(t)) #endif #ifndef PoisonNew # define PoisonNew(d,n,t) PoisonWith(d,n,t,0xAB) #endif #ifndef PoisonFree # define PoisonFree(d,n,t) PoisonWith(d,n,t,0xEF) #endif #ifndef Poison # define Poison(d,n,t) PoisonFree(d,n,t) #endif #ifndef Newx # define Newx(v,n,t) New(0,v,n,t) #endif #ifndef Newxc # define Newxc(v,n,t,c) Newc(0,v,n,t,c) #endif #ifndef Newxz # define Newxz(v,n,t) Newz(0,v,n,t) #endif #ifndef PERL_UNUSED_DECL # ifdef HASATTRIBUTE # if (defined(__GNUC__) && defined(__cplusplus)) || defined(__INTEL_COMPILER) # define PERL_UNUSED_DECL # else # define PERL_UNUSED_DECL __attribute__((unused)) # endif # else # define PERL_UNUSED_DECL # endif #endif #ifndef PERL_UNUSED_ARG # if defined(lint) && defined(S_SPLINT_S) /* www.splint.org */ # include # define PERL_UNUSED_ARG(x) NOTE(ARGUNUSED(x)) # else # define PERL_UNUSED_ARG(x) ((void)x) # endif #endif #ifndef PERL_UNUSED_VAR # define PERL_UNUSED_VAR(x) ((void)x) #endif #ifndef PERL_UNUSED_CONTEXT # ifdef USE_ITHREADS # define PERL_UNUSED_CONTEXT PERL_UNUSED_ARG(my_perl) # else # define PERL_UNUSED_CONTEXT # endif #endif #ifndef NOOP # define NOOP /*EMPTY*/(void)0 #endif #ifndef dNOOP # define dNOOP extern int /*@unused@*/ Perl___notused PERL_UNUSED_DECL #endif #ifndef NVTYPE # if defined(USE_LONG_DOUBLE) && defined(HAS_LONG_DOUBLE) # define NVTYPE long double # else # define NVTYPE double # endif typedef NVTYPE NV; #endif #ifndef INT2PTR # if (IVSIZE == PTRSIZE) && (UVSIZE == PTRSIZE) # define PTRV UV # define INT2PTR(any,d) (any)(d) # else # if PTRSIZE == LONGSIZE # define PTRV unsigned long # else # define PTRV unsigned # endif # define INT2PTR(any,d) (any)(PTRV)(d) # endif #endif #ifndef PTR2ul # if PTRSIZE == LONGSIZE # define PTR2ul(p) (unsigned long)(p) # else # define PTR2ul(p) INT2PTR(unsigned long,p) # endif #endif #ifndef PTR2nat # define PTR2nat(p) (PTRV)(p) #endif #ifndef NUM2PTR # define NUM2PTR(any,d) (any)PTR2nat(d) #endif #ifndef PTR2IV # define PTR2IV(p) INT2PTR(IV,p) #endif #ifndef PTR2UV # define PTR2UV(p) INT2PTR(UV,p) #endif #ifndef PTR2NV # define PTR2NV(p) NUM2PTR(NV,p) #endif #undef START_EXTERN_C #undef END_EXTERN_C #undef EXTERN_C #ifdef __cplusplus # define START_EXTERN_C extern "C" { # define END_EXTERN_C } # define EXTERN_C extern "C" #else # define START_EXTERN_C # define END_EXTERN_C # define EXTERN_C extern #endif #if defined(PERL_GCC_PEDANTIC) # ifndef PERL_GCC_BRACE_GROUPS_FORBIDDEN # define PERL_GCC_BRACE_GROUPS_FORBIDDEN # endif #endif #if defined(__GNUC__) && !defined(PERL_GCC_BRACE_GROUPS_FORBIDDEN) && !defined(__cplusplus) # ifndef PERL_USE_GCC_BRACE_GROUPS # define PERL_USE_GCC_BRACE_GROUPS # endif #endif #undef STMT_START #undef STMT_END #ifdef PERL_USE_GCC_BRACE_GROUPS # define STMT_START (void)( /* gcc supports ``({ STATEMENTS; })'' */ # define STMT_END ) #else # if defined(VOIDFLAGS) && (VOIDFLAGS) && (defined(sun) || defined(__sun__)) && !defined(__GNUC__) # define STMT_START if (1) # define STMT_END else (void)0 # else # define STMT_START do # define STMT_END while (0) # endif #endif #ifndef boolSV # define boolSV(b) ((b) ? &PL_sv_yes : &PL_sv_no) #endif /* DEFSV appears first in 5.004_56 */ #ifndef DEFSV # define DEFSV GvSV(PL_defgv) #endif #ifndef SAVE_DEFSV # define SAVE_DEFSV SAVESPTR(GvSV(PL_defgv)) #endif #ifndef DEFSV_set # define DEFSV_set(sv) (DEFSV = (sv)) #endif /* Older perls (<=5.003) lack AvFILLp */ #ifndef AvFILLp # define AvFILLp AvFILL #endif #ifndef ERRSV # define ERRSV get_sv("@",FALSE) #endif /* Hint: gv_stashpvn * This function's backport doesn't support the length parameter, but * rather ignores it. Portability can only be ensured if the length * parameter is used for speed reasons, but the length can always be * correctly computed from the string argument. */ #ifndef gv_stashpvn # define gv_stashpvn(str,len,create) gv_stashpv(str,create) #endif /* Replace: 1 */ #ifndef get_cv # define get_cv perl_get_cv #endif #ifndef get_sv # define get_sv perl_get_sv #endif #ifndef get_av # define get_av perl_get_av #endif #ifndef get_hv # define get_hv perl_get_hv #endif /* Replace: 0 */ #ifndef dUNDERBAR # define dUNDERBAR dNOOP #endif #ifndef UNDERBAR # define UNDERBAR DEFSV #endif #ifndef dAX # define dAX I32 ax = MARK - PL_stack_base + 1 #endif #ifndef dITEMS # define dITEMS I32 items = SP - MARK #endif #ifndef dXSTARG # define dXSTARG SV * targ = sv_newmortal() #endif #ifndef dAXMARK # define dAXMARK I32 ax = POPMARK; \ register SV ** const mark = PL_stack_base + ax++ #endif #ifndef XSprePUSH # define XSprePUSH (sp = PL_stack_base + ax - 1) #endif #if (PERL_BCDVERSION < 0x5005000) # undef XSRETURN # define XSRETURN(off) \ STMT_START { \ PL_stack_sp = PL_stack_base + ax + ((off) - 1); \ return; \ } STMT_END #endif #ifndef XSPROTO # define XSPROTO(name) void name(pTHX_ CV* cv) #endif #ifndef SVfARG # define SVfARG(p) ((void*)(p)) #endif #ifndef PERL_ABS # define PERL_ABS(x) ((x) < 0 ? -(x) : (x)) #endif #ifndef dVAR # define dVAR dNOOP #endif #ifndef SVf # define SVf "_" #endif #ifndef UTF8_MAXBYTES # define UTF8_MAXBYTES UTF8_MAXLEN #endif #ifndef CPERLscope # define CPERLscope(x) x #endif #ifndef PERL_HASH # define PERL_HASH(hash,str,len) \ STMT_START { \ const char *s_PeRlHaSh = str; \ I32 i_PeRlHaSh = len; \ U32 hash_PeRlHaSh = 0; \ while (i_PeRlHaSh--) \ hash_PeRlHaSh = hash_PeRlHaSh * 33 + *s_PeRlHaSh++; \ (hash) = hash_PeRlHaSh; \ } STMT_END #endif #ifndef PERLIO_FUNCS_DECL # ifdef PERLIO_FUNCS_CONST # define PERLIO_FUNCS_DECL(funcs) const PerlIO_funcs funcs # define PERLIO_FUNCS_CAST(funcs) (PerlIO_funcs*)(funcs) # else # define PERLIO_FUNCS_DECL(funcs) PerlIO_funcs funcs # define PERLIO_FUNCS_CAST(funcs) (funcs) # endif #endif /* provide these typedefs for older perls */ #if (PERL_BCDVERSION < 0x5009003) # ifdef ARGSproto typedef OP* (CPERLscope(*Perl_ppaddr_t))(ARGSproto); # else typedef OP* (CPERLscope(*Perl_ppaddr_t))(pTHX); # endif typedef OP* (CPERLscope(*Perl_check_t)) (pTHX_ OP*); #endif #ifndef isPSXSPC # define isPSXSPC(c) (isSPACE(c) || (c) == '\v') #endif #ifndef isBLANK # define isBLANK(c) ((c) == ' ' || (c) == '\t') #endif #ifdef EBCDIC #ifndef isALNUMC # define isALNUMC(c) isalnum(c) #endif #ifndef isASCII # define isASCII(c) isascii(c) #endif #ifndef isCNTRL # define isCNTRL(c) iscntrl(c) #endif #ifndef isGRAPH # define isGRAPH(c) isgraph(c) #endif #ifndef isPRINT # define isPRINT(c) isprint(c) #endif #ifndef isPUNCT # define isPUNCT(c) ispunct(c) #endif #ifndef isXDIGIT # define isXDIGIT(c) isxdigit(c) #endif #else # if (PERL_BCDVERSION < 0x5010000) /* Hint: isPRINT * The implementation in older perl versions includes all of the * isSPACE() characters, which is wrong. The version provided by * Devel::PPPort always overrides a present buggy version. */ # undef isPRINT # endif #ifndef isALNUMC # define isALNUMC(c) (isALPHA(c) || isDIGIT(c)) #endif #ifndef isASCII # define isASCII(c) ((c) <= 127) #endif #ifndef isCNTRL # define isCNTRL(c) ((c) < ' ' || (c) == 127) #endif #ifndef isGRAPH # define isGRAPH(c) (isALNUM(c) || isPUNCT(c)) #endif #ifndef isPRINT # define isPRINT(c) (((c) >= 32 && (c) < 127)) #endif #ifndef isPUNCT # define isPUNCT(c) (((c) >= 33 && (c) <= 47) || ((c) >= 58 && (c) <= 64) || ((c) >= 91 && (c) <= 96) || ((c) >= 123 && (c) <= 126)) #endif #ifndef isXDIGIT # define isXDIGIT(c) (isDIGIT(c) || ((c) >= 'a' && (c) <= 'f') || ((c) >= 'A' && (c) <= 'F')) #endif #endif #ifndef PERL_SIGNALS_UNSAFE_FLAG #define PERL_SIGNALS_UNSAFE_FLAG 0x0001 #if (PERL_BCDVERSION < 0x5008000) # define D_PPP_PERL_SIGNALS_INIT PERL_SIGNALS_UNSAFE_FLAG #else # define D_PPP_PERL_SIGNALS_INIT 0 #endif #if defined(NEED_PL_signals) static U32 DPPP_(my_PL_signals) = D_PPP_PERL_SIGNALS_INIT; #elif defined(NEED_PL_signals_GLOBAL) U32 DPPP_(my_PL_signals) = D_PPP_PERL_SIGNALS_INIT; #else extern U32 DPPP_(my_PL_signals); #endif #define PL_signals DPPP_(my_PL_signals) #endif /* Hint: PL_ppaddr * Calling an op via PL_ppaddr requires passing a context argument * for threaded builds. Since the context argument is different for * 5.005 perls, you can use aTHXR (supplied by ppport.h), which will * automatically be defined as the correct argument. */ #if (PERL_BCDVERSION <= 0x5005005) /* Replace: 1 */ # define PL_ppaddr ppaddr # define PL_no_modify no_modify /* Replace: 0 */ #endif #if (PERL_BCDVERSION <= 0x5004005) /* Replace: 1 */ # define PL_DBsignal DBsignal # define PL_DBsingle DBsingle # define PL_DBsub DBsub # define PL_DBtrace DBtrace # define PL_Sv Sv # define PL_bufend bufend # define PL_bufptr bufptr # define PL_compiling compiling # define PL_copline copline # define PL_curcop curcop # define PL_curstash curstash # define PL_debstash debstash # define PL_defgv defgv # define PL_diehook diehook # define PL_dirty dirty # define PL_dowarn dowarn # define PL_errgv errgv # define PL_error_count error_count # define PL_expect expect # define PL_hexdigit hexdigit # define PL_hints hints # define PL_in_my in_my # define PL_laststatval laststatval # define PL_lex_state lex_state # define PL_lex_stuff lex_stuff # define PL_linestr linestr # define PL_na na # define PL_perl_destruct_level perl_destruct_level # define PL_perldb perldb # define PL_rsfp_filters rsfp_filters # define PL_rsfp rsfp # define PL_stack_base stack_base # define PL_stack_sp stack_sp # define PL_statcache statcache # define PL_stdingv stdingv # define PL_sv_arenaroot sv_arenaroot # define PL_sv_no sv_no # define PL_sv_undef sv_undef # define PL_sv_yes sv_yes # define PL_tainted tainted # define PL_tainting tainting # define PL_tokenbuf tokenbuf /* Replace: 0 */ #endif /* Warning: PL_parser * For perl versions earlier than 5.9.5, this is an always * non-NULL dummy. Also, it cannot be dereferenced. Don't * use it if you can avoid is and unless you absolutely know * what you're doing. * If you always check that PL_parser is non-NULL, you can * define DPPP_PL_parser_NO_DUMMY to avoid the creation of * a dummy parser structure. */ #if (PERL_BCDVERSION >= 0x5009005) # ifdef DPPP_PL_parser_NO_DUMMY # define D_PPP_my_PL_parser_var(var) ((PL_parser ? PL_parser : \ (croak("panic: PL_parser == NULL in %s:%d", \ __FILE__, __LINE__), (yy_parser *) NULL))->var) # else # ifdef DPPP_PL_parser_NO_DUMMY_WARNING # define D_PPP_parser_dummy_warning(var) # else # define D_PPP_parser_dummy_warning(var) \ warn("warning: dummy PL_" #var " used in %s:%d", __FILE__, __LINE__), # endif # define D_PPP_my_PL_parser_var(var) ((PL_parser ? PL_parser : \ (D_PPP_parser_dummy_warning(var) &DPPP_(dummy_PL_parser)))->var) #if defined(NEED_PL_parser) static yy_parser DPPP_(dummy_PL_parser); #elif defined(NEED_PL_parser_GLOBAL) yy_parser DPPP_(dummy_PL_parser); #else extern yy_parser DPPP_(dummy_PL_parser); #endif # endif /* PL_expect, PL_copline, PL_rsfp, PL_rsfp_filters, PL_linestr, PL_bufptr, PL_bufend, PL_lex_state, PL_lex_stuff, PL_tokenbuf depends on PL_parser */ /* Warning: PL_expect, PL_copline, PL_rsfp, PL_rsfp_filters, PL_linestr, PL_bufptr, PL_bufend, PL_lex_state, PL_lex_stuff, PL_tokenbuf * Do not use this variable unless you know exactly what you're * doint. It is internal to the perl parser and may change or even * be removed in the future. As of perl 5.9.5, you have to check * for (PL_parser != NULL) for this variable to have any effect. * An always non-NULL PL_parser dummy is provided for earlier * perl versions. * If PL_parser is NULL when you try to access this variable, a * dummy is being accessed instead and a warning is issued unless * you define DPPP_PL_parser_NO_DUMMY_WARNING. * If DPPP_PL_parser_NO_DUMMY is defined, the code trying to access * this variable will croak with a panic message. */ # define PL_expect D_PPP_my_PL_parser_var(expect) # define PL_copline D_PPP_my_PL_parser_var(copline) # define PL_rsfp D_PPP_my_PL_parser_var(rsfp) # define PL_rsfp_filters D_PPP_my_PL_parser_var(rsfp_filters) # define PL_linestr D_PPP_my_PL_parser_var(linestr) # define PL_bufptr D_PPP_my_PL_parser_var(bufptr) # define PL_bufend D_PPP_my_PL_parser_var(bufend) # define PL_lex_state D_PPP_my_PL_parser_var(lex_state) # define PL_lex_stuff D_PPP_my_PL_parser_var(lex_stuff) # define PL_tokenbuf D_PPP_my_PL_parser_var(tokenbuf) # define PL_in_my D_PPP_my_PL_parser_var(in_my) # define PL_in_my_stash D_PPP_my_PL_parser_var(in_my_stash) # define PL_error_count D_PPP_my_PL_parser_var(error_count) #else /* ensure that PL_parser != NULL and cannot be dereferenced */ # define PL_parser ((void *) 1) #endif #ifndef mPUSHs # define mPUSHs(s) PUSHs(sv_2mortal(s)) #endif #ifndef PUSHmortal # define PUSHmortal PUSHs(sv_newmortal()) #endif #ifndef mPUSHp # define mPUSHp(p,l) sv_setpvn(PUSHmortal, (p), (l)) #endif #ifndef mPUSHn # define mPUSHn(n) sv_setnv(PUSHmortal, (NV)(n)) #endif #ifndef mPUSHi # define mPUSHi(i) sv_setiv(PUSHmortal, (IV)(i)) #endif #ifndef mPUSHu # define mPUSHu(u) sv_setuv(PUSHmortal, (UV)(u)) #endif #ifndef mXPUSHs # define mXPUSHs(s) XPUSHs(sv_2mortal(s)) #endif #ifndef XPUSHmortal # define XPUSHmortal XPUSHs(sv_newmortal()) #endif #ifndef mXPUSHp # define mXPUSHp(p,l) STMT_START { EXTEND(sp,1); sv_setpvn(PUSHmortal, (p), (l)); } STMT_END #endif #ifndef mXPUSHn # define mXPUSHn(n) STMT_START { EXTEND(sp,1); sv_setnv(PUSHmortal, (NV)(n)); } STMT_END #endif #ifndef mXPUSHi # define mXPUSHi(i) STMT_START { EXTEND(sp,1); sv_setiv(PUSHmortal, (IV)(i)); } STMT_END #endif #ifndef mXPUSHu # define mXPUSHu(u) STMT_START { EXTEND(sp,1); sv_setuv(PUSHmortal, (UV)(u)); } STMT_END #endif /* Replace: 1 */ #ifndef call_sv # define call_sv perl_call_sv #endif #ifndef call_pv # define call_pv perl_call_pv #endif #ifndef call_argv # define call_argv perl_call_argv #endif #ifndef call_method # define call_method perl_call_method #endif #ifndef eval_sv # define eval_sv perl_eval_sv #endif /* Replace: 0 */ #ifndef PERL_LOADMOD_DENY # define PERL_LOADMOD_DENY 0x1 #endif #ifndef PERL_LOADMOD_NOIMPORT # define PERL_LOADMOD_NOIMPORT 0x2 #endif #ifndef PERL_LOADMOD_IMPORT_OPS # define PERL_LOADMOD_IMPORT_OPS 0x4 #endif #ifndef G_METHOD # define G_METHOD 64 # ifdef call_sv # undef call_sv # endif # if (PERL_BCDVERSION < 0x5006000) # define call_sv(sv, flags) ((flags) & G_METHOD ? perl_call_method((char *) SvPV_nolen_const(sv), \ (flags) & ~G_METHOD) : perl_call_sv(sv, flags)) # else # define call_sv(sv, flags) ((flags) & G_METHOD ? Perl_call_method(aTHX_ (char *) SvPV_nolen_const(sv), \ (flags) & ~G_METHOD) : Perl_call_sv(aTHX_ sv, flags)) # endif #endif /* Replace perl_eval_pv with eval_pv */ #ifndef eval_pv #if defined(NEED_eval_pv) static SV* DPPP_(my_eval_pv)(char *p, I32 croak_on_error); static #else extern SV* DPPP_(my_eval_pv)(char *p, I32 croak_on_error); #endif #ifdef eval_pv # undef eval_pv #endif #define eval_pv(a,b) DPPP_(my_eval_pv)(aTHX_ a,b) #define Perl_eval_pv DPPP_(my_eval_pv) #if defined(NEED_eval_pv) || defined(NEED_eval_pv_GLOBAL) SV* DPPP_(my_eval_pv)(char *p, I32 croak_on_error) { dSP; SV* sv = newSVpv(p, 0); PUSHMARK(sp); eval_sv(sv, G_SCALAR); SvREFCNT_dec(sv); SPAGAIN; sv = POPs; PUTBACK; if (croak_on_error && SvTRUE(GvSV(errgv))) croak(SvPVx(GvSV(errgv), na)); return sv; } #endif #endif #ifndef vload_module #if defined(NEED_vload_module) static void DPPP_(my_vload_module)(U32 flags, SV *name, SV *ver, va_list *args); static #else extern void DPPP_(my_vload_module)(U32 flags, SV *name, SV *ver, va_list *args); #endif #ifdef vload_module # undef vload_module #endif #define vload_module(a,b,c,d) DPPP_(my_vload_module)(aTHX_ a,b,c,d) #define Perl_vload_module DPPP_(my_vload_module) #if defined(NEED_vload_module) || defined(NEED_vload_module_GLOBAL) void DPPP_(my_vload_module)(U32 flags, SV *name, SV *ver, va_list *args) { dTHR; dVAR; OP *veop, *imop; OP * const modname = newSVOP(OP_CONST, 0, name); /* 5.005 has a somewhat hacky force_normal that doesn't croak on SvREADONLY() if PL_compling is true. Current perls take care in ck_require() to correctly turn off SvREADONLY before calling force_normal_flags(). This seems a better fix than fudging PL_compling */ SvREADONLY_off(((SVOP*)modname)->op_sv); modname->op_private |= OPpCONST_BARE; if (ver) { veop = newSVOP(OP_CONST, 0, ver); } else veop = NULL; if (flags & PERL_LOADMOD_NOIMPORT) { imop = sawparens(newNULLLIST()); } else if (flags & PERL_LOADMOD_IMPORT_OPS) { imop = va_arg(*args, OP*); } else { SV *sv; imop = NULL; sv = va_arg(*args, SV*); while (sv) { imop = append_elem(OP_LIST, imop, newSVOP(OP_CONST, 0, sv)); sv = va_arg(*args, SV*); } } { const line_t ocopline = PL_copline; COP * const ocurcop = PL_curcop; const int oexpect = PL_expect; #if (PERL_BCDVERSION >= 0x5004000) utilize(!(flags & PERL_LOADMOD_DENY), start_subparse(FALSE, 0), veop, modname, imop); #else utilize(!(flags & PERL_LOADMOD_DENY), start_subparse(), modname, imop); #endif PL_expect = oexpect; PL_copline = ocopline; PL_curcop = ocurcop; } } #endif #endif #ifndef load_module #if defined(NEED_load_module) static void DPPP_(my_load_module)(U32 flags, SV *name, SV *ver, ...); static #else extern void DPPP_(my_load_module)(U32 flags, SV *name, SV *ver, ...); #endif #ifdef load_module # undef load_module #endif #define load_module DPPP_(my_load_module) #define Perl_load_module DPPP_(my_load_module) #if defined(NEED_load_module) || defined(NEED_load_module_GLOBAL) void DPPP_(my_load_module)(U32 flags, SV *name, SV *ver, ...) { va_list args; va_start(args, ver); vload_module(flags, name, ver, &args); va_end(args); } #endif #endif #ifndef newRV_inc # define newRV_inc(sv) newRV(sv) /* Replace */ #endif #ifndef newRV_noinc #if defined(NEED_newRV_noinc) static SV * DPPP_(my_newRV_noinc)(SV *sv); static #else extern SV * DPPP_(my_newRV_noinc)(SV *sv); #endif #ifdef newRV_noinc # undef newRV_noinc #endif #define newRV_noinc(a) DPPP_(my_newRV_noinc)(aTHX_ a) #define Perl_newRV_noinc DPPP_(my_newRV_noinc) #if defined(NEED_newRV_noinc) || defined(NEED_newRV_noinc_GLOBAL) SV * DPPP_(my_newRV_noinc)(SV *sv) { SV *rv = (SV *)newRV(sv); SvREFCNT_dec(sv); return rv; } #endif #endif /* Hint: newCONSTSUB * Returns a CV* as of perl-5.7.1. This return value is not supported * by Devel::PPPort. */ /* newCONSTSUB from IO.xs is in the core starting with 5.004_63 */ #if (PERL_BCDVERSION < 0x5004063) && (PERL_BCDVERSION != 0x5004005) #if defined(NEED_newCONSTSUB) static void DPPP_(my_newCONSTSUB)(HV *stash, const char *name, SV *sv); static #else extern void DPPP_(my_newCONSTSUB)(HV *stash, const char *name, SV *sv); #endif #ifdef newCONSTSUB # undef newCONSTSUB #endif #define newCONSTSUB(a,b,c) DPPP_(my_newCONSTSUB)(aTHX_ a,b,c) #define Perl_newCONSTSUB DPPP_(my_newCONSTSUB) #if defined(NEED_newCONSTSUB) || defined(NEED_newCONSTSUB_GLOBAL) /* This is just a trick to avoid a dependency of newCONSTSUB on PL_parser */ /* (There's no PL_parser in perl < 5.005, so this is completely safe) */ #define D_PPP_PL_copline PL_copline void DPPP_(my_newCONSTSUB)(HV *stash, const char *name, SV *sv) { U32 oldhints = PL_hints; HV *old_cop_stash = PL_curcop->cop_stash; HV *old_curstash = PL_curstash; line_t oldline = PL_curcop->cop_line; PL_curcop->cop_line = D_PPP_PL_copline; PL_hints &= ~HINT_BLOCK_SCOPE; if (stash) PL_curstash = PL_curcop->cop_stash = stash; newSUB( #if (PERL_BCDVERSION < 0x5003022) start_subparse(), #elif (PERL_BCDVERSION == 0x5003022) start_subparse(0), #else /* 5.003_23 onwards */ start_subparse(FALSE, 0), #endif newSVOP(OP_CONST, 0, newSVpv((char *) name, 0)), newSVOP(OP_CONST, 0, &PL_sv_no), /* SvPV(&PL_sv_no) == "" -- GMB */ newSTATEOP(0, Nullch, newSVOP(OP_CONST, 0, sv)) ); PL_hints = oldhints; PL_curcop->cop_stash = old_cop_stash; PL_curstash = old_curstash; PL_curcop->cop_line = oldline; } #endif #endif /* * Boilerplate macros for initializing and accessing interpreter-local * data from C. All statics in extensions should be reworked to use * this, if you want to make the extension thread-safe. See ext/re/re.xs * for an example of the use of these macros. * * Code that uses these macros is responsible for the following: * 1. #define MY_CXT_KEY to a unique string, e.g. "DynaLoader_guts" * 2. Declare a typedef named my_cxt_t that is a structure that contains * all the data that needs to be interpreter-local. * 3. Use the START_MY_CXT macro after the declaration of my_cxt_t. * 4. Use the MY_CXT_INIT macro such that it is called exactly once * (typically put in the BOOT: section). * 5. Use the members of the my_cxt_t structure everywhere as * MY_CXT.member. * 6. Use the dMY_CXT macro (a declaration) in all the functions that * access MY_CXT. */ #if defined(MULTIPLICITY) || defined(PERL_OBJECT) || \ defined(PERL_CAPI) || defined(PERL_IMPLICIT_CONTEXT) #ifndef START_MY_CXT /* This must appear in all extensions that define a my_cxt_t structure, * right after the definition (i.e. at file scope). The non-threads * case below uses it to declare the data as static. */ #define START_MY_CXT #if (PERL_BCDVERSION < 0x5004068) /* Fetches the SV that keeps the per-interpreter data. */ #define dMY_CXT_SV \ SV *my_cxt_sv = get_sv(MY_CXT_KEY, FALSE) #else /* >= perl5.004_68 */ #define dMY_CXT_SV \ SV *my_cxt_sv = *hv_fetch(PL_modglobal, MY_CXT_KEY, \ sizeof(MY_CXT_KEY)-1, TRUE) #endif /* < perl5.004_68 */ /* This declaration should be used within all functions that use the * interpreter-local data. */ #define dMY_CXT \ dMY_CXT_SV; \ my_cxt_t *my_cxtp = INT2PTR(my_cxt_t*,SvUV(my_cxt_sv)) /* Creates and zeroes the per-interpreter data. * (We allocate my_cxtp in a Perl SV so that it will be released when * the interpreter goes away.) */ #define MY_CXT_INIT \ dMY_CXT_SV; \ /* newSV() allocates one more than needed */ \ my_cxt_t *my_cxtp = (my_cxt_t*)SvPVX(newSV(sizeof(my_cxt_t)-1));\ Zero(my_cxtp, 1, my_cxt_t); \ sv_setuv(my_cxt_sv, PTR2UV(my_cxtp)) /* This macro must be used to access members of the my_cxt_t structure. * e.g. MYCXT.some_data */ #define MY_CXT (*my_cxtp) /* Judicious use of these macros can reduce the number of times dMY_CXT * is used. Use is similar to pTHX, aTHX etc. */ #define pMY_CXT my_cxt_t *my_cxtp #define pMY_CXT_ pMY_CXT, #define _pMY_CXT ,pMY_CXT #define aMY_CXT my_cxtp #define aMY_CXT_ aMY_CXT, #define _aMY_CXT ,aMY_CXT #endif /* START_MY_CXT */ #ifndef MY_CXT_CLONE /* Clones the per-interpreter data. */ #define MY_CXT_CLONE \ dMY_CXT_SV; \ my_cxt_t *my_cxtp = (my_cxt_t*)SvPVX(newSV(sizeof(my_cxt_t)-1));\ Copy(INT2PTR(my_cxt_t*, SvUV(my_cxt_sv)), my_cxtp, 1, my_cxt_t);\ sv_setuv(my_cxt_sv, PTR2UV(my_cxtp)) #endif #else /* single interpreter */ #ifndef START_MY_CXT #define START_MY_CXT static my_cxt_t my_cxt; #define dMY_CXT_SV dNOOP #define dMY_CXT dNOOP #define MY_CXT_INIT NOOP #define MY_CXT my_cxt #define pMY_CXT void #define pMY_CXT_ #define _pMY_CXT #define aMY_CXT #define aMY_CXT_ #define _aMY_CXT #endif /* START_MY_CXT */ #ifndef MY_CXT_CLONE #define MY_CXT_CLONE NOOP #endif #endif #ifndef IVdf # if IVSIZE == LONGSIZE # define IVdf "ld" # define UVuf "lu" # define UVof "lo" # define UVxf "lx" # define UVXf "lX" # else # if IVSIZE == INTSIZE # define IVdf "d" # define UVuf "u" # define UVof "o" # define UVxf "x" # define UVXf "X" # endif # endif #endif #ifndef NVef # if defined(USE_LONG_DOUBLE) && defined(HAS_LONG_DOUBLE) && \ defined(PERL_PRIfldbl) && (PERL_BCDVERSION != 0x5006000) /* Not very likely, but let's try anyway. */ # define NVef PERL_PRIeldbl # define NVff PERL_PRIfldbl # define NVgf PERL_PRIgldbl # else # define NVef "e" # define NVff "f" # define NVgf "g" # endif #endif #ifndef SvREFCNT_inc # ifdef PERL_USE_GCC_BRACE_GROUPS # define SvREFCNT_inc(sv) \ ({ \ SV * const _sv = (SV*)(sv); \ if (_sv) \ (SvREFCNT(_sv))++; \ _sv; \ }) # else # define SvREFCNT_inc(sv) \ ((PL_Sv=(SV*)(sv)) ? (++(SvREFCNT(PL_Sv)),PL_Sv) : NULL) # endif #endif #ifndef SvREFCNT_inc_simple # ifdef PERL_USE_GCC_BRACE_GROUPS # define SvREFCNT_inc_simple(sv) \ ({ \ if (sv) \ (SvREFCNT(sv))++; \ (SV *)(sv); \ }) # else # define SvREFCNT_inc_simple(sv) \ ((sv) ? (SvREFCNT(sv)++,(SV*)(sv)) : NULL) # endif #endif #ifndef SvREFCNT_inc_NN # ifdef PERL_USE_GCC_BRACE_GROUPS # define SvREFCNT_inc_NN(sv) \ ({ \ SV * const _sv = (SV*)(sv); \ SvREFCNT(_sv)++; \ _sv; \ }) # else # define SvREFCNT_inc_NN(sv) \ (PL_Sv=(SV*)(sv),++(SvREFCNT(PL_Sv)),PL_Sv) # endif #endif #ifndef SvREFCNT_inc_void # ifdef PERL_USE_GCC_BRACE_GROUPS # define SvREFCNT_inc_void(sv) \ ({ \ SV * const _sv = (SV*)(sv); \ if (_sv) \ (void)(SvREFCNT(_sv)++); \ }) # else # define SvREFCNT_inc_void(sv) \ (void)((PL_Sv=(SV*)(sv)) ? ++(SvREFCNT(PL_Sv)) : 0) # endif #endif #ifndef SvREFCNT_inc_simple_void # define SvREFCNT_inc_simple_void(sv) STMT_START { if (sv) SvREFCNT(sv)++; } STMT_END #endif #ifndef SvREFCNT_inc_simple_NN # define SvREFCNT_inc_simple_NN(sv) (++SvREFCNT(sv), (SV*)(sv)) #endif #ifndef SvREFCNT_inc_void_NN # define SvREFCNT_inc_void_NN(sv) (void)(++SvREFCNT((SV*)(sv))) #endif #ifndef SvREFCNT_inc_simple_void_NN # define SvREFCNT_inc_simple_void_NN(sv) (void)(++SvREFCNT((SV*)(sv))) #endif #ifndef newSV_type #if defined(NEED_newSV_type) static SV* DPPP_(my_newSV_type)(pTHX_ svtype const t); static #else extern SV* DPPP_(my_newSV_type)(pTHX_ svtype const t); #endif #ifdef newSV_type # undef newSV_type #endif #define newSV_type(a) DPPP_(my_newSV_type)(aTHX_ a) #define Perl_newSV_type DPPP_(my_newSV_type) #if defined(NEED_newSV_type) || defined(NEED_newSV_type_GLOBAL) SV* DPPP_(my_newSV_type)(pTHX_ svtype const t) { SV* const sv = newSV(0); sv_upgrade(sv, t); return sv; } #endif #endif #if (PERL_BCDVERSION < 0x5006000) # define D_PPP_CONSTPV_ARG(x) ((char *) (x)) #else # define D_PPP_CONSTPV_ARG(x) (x) #endif #ifndef newSVpvn # define newSVpvn(data,len) ((data) \ ? ((len) ? newSVpv((data), (len)) : newSVpv("", 0)) \ : newSV(0)) #endif #ifndef newSVpvn_utf8 # define newSVpvn_utf8(s, len, u) newSVpvn_flags((s), (len), (u) ? SVf_UTF8 : 0) #endif #ifndef SVf_UTF8 # define SVf_UTF8 0 #endif #ifndef newSVpvn_flags #if defined(NEED_newSVpvn_flags) static SV * DPPP_(my_newSVpvn_flags)(pTHX_ const char *s, STRLEN len, U32 flags); static #else extern SV * DPPP_(my_newSVpvn_flags)(pTHX_ const char *s, STRLEN len, U32 flags); #endif #ifdef newSVpvn_flags # undef newSVpvn_flags #endif #define newSVpvn_flags(a,b,c) DPPP_(my_newSVpvn_flags)(aTHX_ a,b,c) #define Perl_newSVpvn_flags DPPP_(my_newSVpvn_flags) #if defined(NEED_newSVpvn_flags) || defined(NEED_newSVpvn_flags_GLOBAL) SV * DPPP_(my_newSVpvn_flags)(pTHX_ const char *s, STRLEN len, U32 flags) { SV *sv = newSVpvn(D_PPP_CONSTPV_ARG(s), len); SvFLAGS(sv) |= (flags & SVf_UTF8); return (flags & SVs_TEMP) ? sv_2mortal(sv) : sv; } #endif #endif /* Backwards compatibility stuff... :-( */ #if !defined(NEED_sv_2pv_flags) && defined(NEED_sv_2pv_nolen) # define NEED_sv_2pv_flags #endif #if !defined(NEED_sv_2pv_flags_GLOBAL) && defined(NEED_sv_2pv_nolen_GLOBAL) # define NEED_sv_2pv_flags_GLOBAL #endif /* Hint: sv_2pv_nolen * Use the SvPV_nolen() or SvPV_nolen_const() macros instead of sv_2pv_nolen(). */ #ifndef sv_2pv_nolen # define sv_2pv_nolen(sv) SvPV_nolen(sv) #endif #ifdef SvPVbyte /* Hint: SvPVbyte * Does not work in perl-5.6.1, ppport.h implements a version * borrowed from perl-5.7.3. */ #if (PERL_BCDVERSION < 0x5007000) #if defined(NEED_sv_2pvbyte) static char * DPPP_(my_sv_2pvbyte)(pTHX_ SV *sv, STRLEN *lp); static #else extern char * DPPP_(my_sv_2pvbyte)(pTHX_ SV *sv, STRLEN *lp); #endif #ifdef sv_2pvbyte # undef sv_2pvbyte #endif #define sv_2pvbyte(a,b) DPPP_(my_sv_2pvbyte)(aTHX_ a,b) #define Perl_sv_2pvbyte DPPP_(my_sv_2pvbyte) #if defined(NEED_sv_2pvbyte) || defined(NEED_sv_2pvbyte_GLOBAL) char * DPPP_(my_sv_2pvbyte)(pTHX_ SV *sv, STRLEN *lp) { sv_utf8_downgrade(sv,0); return SvPV(sv,*lp); } #endif /* Hint: sv_2pvbyte * Use the SvPVbyte() macro instead of sv_2pvbyte(). */ #undef SvPVbyte #define SvPVbyte(sv, lp) \ ((SvFLAGS(sv) & (SVf_POK|SVf_UTF8)) == (SVf_POK) \ ? ((lp = SvCUR(sv)), SvPVX(sv)) : sv_2pvbyte(sv, &lp)) #endif #else # define SvPVbyte SvPV # define sv_2pvbyte sv_2pv #endif #ifndef sv_2pvbyte_nolen # define sv_2pvbyte_nolen(sv) sv_2pv_nolen(sv) #endif /* Hint: sv_pvn * Always use the SvPV() macro instead of sv_pvn(). */ /* Hint: sv_pvn_force * Always use the SvPV_force() macro instead of sv_pvn_force(). */ /* If these are undefined, they're not handled by the core anyway */ #ifndef SV_IMMEDIATE_UNREF # define SV_IMMEDIATE_UNREF 0 #endif #ifndef SV_GMAGIC # define SV_GMAGIC 0 #endif #ifndef SV_COW_DROP_PV # define SV_COW_DROP_PV 0 #endif #ifndef SV_UTF8_NO_ENCODING # define SV_UTF8_NO_ENCODING 0 #endif #ifndef SV_NOSTEAL # define SV_NOSTEAL 0 #endif #ifndef SV_CONST_RETURN # define SV_CONST_RETURN 0 #endif #ifndef SV_MUTABLE_RETURN # define SV_MUTABLE_RETURN 0 #endif #ifndef SV_SMAGIC # define SV_SMAGIC 0 #endif #ifndef SV_HAS_TRAILING_NUL # define SV_HAS_TRAILING_NUL 0 #endif #ifndef SV_COW_SHARED_HASH_KEYS # define SV_COW_SHARED_HASH_KEYS 0 #endif #if (PERL_BCDVERSION < 0x5007002) #if defined(NEED_sv_2pv_flags) static char * DPPP_(my_sv_2pv_flags)(pTHX_ SV *sv, STRLEN *lp, I32 flags); static #else extern char * DPPP_(my_sv_2pv_flags)(pTHX_ SV *sv, STRLEN *lp, I32 flags); #endif #ifdef sv_2pv_flags # undef sv_2pv_flags #endif #define sv_2pv_flags(a,b,c) DPPP_(my_sv_2pv_flags)(aTHX_ a,b,c) #define Perl_sv_2pv_flags DPPP_(my_sv_2pv_flags) #if defined(NEED_sv_2pv_flags) || defined(NEED_sv_2pv_flags_GLOBAL) char * DPPP_(my_sv_2pv_flags)(pTHX_ SV *sv, STRLEN *lp, I32 flags) { STRLEN n_a = (STRLEN) flags; return sv_2pv(sv, lp ? lp : &n_a); } #endif #if defined(NEED_sv_pvn_force_flags) static char * DPPP_(my_sv_pvn_force_flags)(pTHX_ SV *sv, STRLEN *lp, I32 flags); static #else extern char * DPPP_(my_sv_pvn_force_flags)(pTHX_ SV *sv, STRLEN *lp, I32 flags); #endif #ifdef sv_pvn_force_flags # undef sv_pvn_force_flags #endif #define sv_pvn_force_flags(a,b,c) DPPP_(my_sv_pvn_force_flags)(aTHX_ a,b,c) #define Perl_sv_pvn_force_flags DPPP_(my_sv_pvn_force_flags) #if defined(NEED_sv_pvn_force_flags) || defined(NEED_sv_pvn_force_flags_GLOBAL) char * DPPP_(my_sv_pvn_force_flags)(pTHX_ SV *sv, STRLEN *lp, I32 flags) { STRLEN n_a = (STRLEN) flags; return sv_pvn_force(sv, lp ? lp : &n_a); } #endif #endif #if (PERL_BCDVERSION < 0x5008008) || ( (PERL_BCDVERSION >= 0x5009000) && (PERL_BCDVERSION < 0x5009003) ) # define DPPP_SVPV_NOLEN_LP_ARG &PL_na #else # define DPPP_SVPV_NOLEN_LP_ARG 0 #endif #ifndef SvPV_const # define SvPV_const(sv, lp) SvPV_flags_const(sv, lp, SV_GMAGIC) #endif #ifndef SvPV_mutable # define SvPV_mutable(sv, lp) SvPV_flags_mutable(sv, lp, SV_GMAGIC) #endif #ifndef SvPV_flags # define SvPV_flags(sv, lp, flags) \ ((SvFLAGS(sv) & (SVf_POK)) == SVf_POK \ ? ((lp = SvCUR(sv)), SvPVX(sv)) : sv_2pv_flags(sv, &lp, flags)) #endif #ifndef SvPV_flags_const # define SvPV_flags_const(sv, lp, flags) \ ((SvFLAGS(sv) & (SVf_POK)) == SVf_POK \ ? ((lp = SvCUR(sv)), SvPVX_const(sv)) : \ (const char*) sv_2pv_flags(sv, &lp, flags|SV_CONST_RETURN)) #endif #ifndef SvPV_flags_const_nolen # define SvPV_flags_const_nolen(sv, flags) \ ((SvFLAGS(sv) & (SVf_POK)) == SVf_POK \ ? SvPVX_const(sv) : \ (const char*) sv_2pv_flags(sv, DPPP_SVPV_NOLEN_LP_ARG, flags|SV_CONST_RETURN)) #endif #ifndef SvPV_flags_mutable # define SvPV_flags_mutable(sv, lp, flags) \ ((SvFLAGS(sv) & (SVf_POK)) == SVf_POK \ ? ((lp = SvCUR(sv)), SvPVX_mutable(sv)) : \ sv_2pv_flags(sv, &lp, flags|SV_MUTABLE_RETURN)) #endif #ifndef SvPV_force # define SvPV_force(sv, lp) SvPV_force_flags(sv, lp, SV_GMAGIC) #endif #ifndef SvPV_force_nolen # define SvPV_force_nolen(sv) SvPV_force_flags_nolen(sv, SV_GMAGIC) #endif #ifndef SvPV_force_mutable # define SvPV_force_mutable(sv, lp) SvPV_force_flags_mutable(sv, lp, SV_GMAGIC) #endif #ifndef SvPV_force_nomg # define SvPV_force_nomg(sv, lp) SvPV_force_flags(sv, lp, 0) #endif #ifndef SvPV_force_nomg_nolen # define SvPV_force_nomg_nolen(sv) SvPV_force_flags_nolen(sv, 0) #endif #ifndef SvPV_force_flags # define SvPV_force_flags(sv, lp, flags) \ ((SvFLAGS(sv) & (SVf_POK|SVf_THINKFIRST)) == SVf_POK \ ? ((lp = SvCUR(sv)), SvPVX(sv)) : sv_pvn_force_flags(sv, &lp, flags)) #endif #ifndef SvPV_force_flags_nolen # define SvPV_force_flags_nolen(sv, flags) \ ((SvFLAGS(sv) & (SVf_POK|SVf_THINKFIRST)) == SVf_POK \ ? SvPVX(sv) : sv_pvn_force_flags(sv, DPPP_SVPV_NOLEN_LP_ARG, flags)) #endif #ifndef SvPV_force_flags_mutable # define SvPV_force_flags_mutable(sv, lp, flags) \ ((SvFLAGS(sv) & (SVf_POK|SVf_THINKFIRST)) == SVf_POK \ ? ((lp = SvCUR(sv)), SvPVX_mutable(sv)) \ : sv_pvn_force_flags(sv, &lp, flags|SV_MUTABLE_RETURN)) #endif #ifndef SvPV_nolen # define SvPV_nolen(sv) \ ((SvFLAGS(sv) & (SVf_POK)) == SVf_POK \ ? SvPVX(sv) : sv_2pv_flags(sv, DPPP_SVPV_NOLEN_LP_ARG, SV_GMAGIC)) #endif #ifndef SvPV_nolen_const # define SvPV_nolen_const(sv) \ ((SvFLAGS(sv) & (SVf_POK)) == SVf_POK \ ? SvPVX_const(sv) : sv_2pv_flags(sv, DPPP_SVPV_NOLEN_LP_ARG, SV_GMAGIC|SV_CONST_RETURN)) #endif #ifndef SvPV_nomg # define SvPV_nomg(sv, lp) SvPV_flags(sv, lp, 0) #endif #ifndef SvPV_nomg_const # define SvPV_nomg_const(sv, lp) SvPV_flags_const(sv, lp, 0) #endif #ifndef SvPV_nomg_const_nolen # define SvPV_nomg_const_nolen(sv) SvPV_flags_const_nolen(sv, 0) #endif #ifndef SvPV_renew # define SvPV_renew(sv,n) STMT_START { SvLEN_set(sv, n); \ SvPV_set((sv), (char *) saferealloc( \ (Malloc_t)SvPVX(sv), (MEM_SIZE)((n)))); \ } STMT_END #endif #ifndef SvMAGIC_set # define SvMAGIC_set(sv, val) \ STMT_START { assert(SvTYPE(sv) >= SVt_PVMG); \ (((XPVMG*) SvANY(sv))->xmg_magic = (val)); } STMT_END #endif #if (PERL_BCDVERSION < 0x5009003) #ifndef SvPVX_const # define SvPVX_const(sv) ((const char*) (0 + SvPVX(sv))) #endif #ifndef SvPVX_mutable # define SvPVX_mutable(sv) (0 + SvPVX(sv)) #endif #ifndef SvRV_set # define SvRV_set(sv, val) \ STMT_START { assert(SvTYPE(sv) >= SVt_RV); \ (((XRV*) SvANY(sv))->xrv_rv = (val)); } STMT_END #endif #else #ifndef SvPVX_const # define SvPVX_const(sv) ((const char*)((sv)->sv_u.svu_pv)) #endif #ifndef SvPVX_mutable # define SvPVX_mutable(sv) ((sv)->sv_u.svu_pv) #endif #ifndef SvRV_set # define SvRV_set(sv, val) \ STMT_START { assert(SvTYPE(sv) >= SVt_RV); \ ((sv)->sv_u.svu_rv = (val)); } STMT_END #endif #endif #ifndef SvSTASH_set # define SvSTASH_set(sv, val) \ STMT_START { assert(SvTYPE(sv) >= SVt_PVMG); \ (((XPVMG*) SvANY(sv))->xmg_stash = (val)); } STMT_END #endif #if (PERL_BCDVERSION < 0x5004000) #ifndef SvUV_set # define SvUV_set(sv, val) \ STMT_START { assert(SvTYPE(sv) == SVt_IV || SvTYPE(sv) >= SVt_PVIV); \ (((XPVIV*) SvANY(sv))->xiv_iv = (IV) (val)); } STMT_END #endif #else #ifndef SvUV_set # define SvUV_set(sv, val) \ STMT_START { assert(SvTYPE(sv) == SVt_IV || SvTYPE(sv) >= SVt_PVIV); \ (((XPVUV*) SvANY(sv))->xuv_uv = (val)); } STMT_END #endif #endif #if (PERL_BCDVERSION >= 0x5004000) && !defined(vnewSVpvf) #if defined(NEED_vnewSVpvf) static SV * DPPP_(my_vnewSVpvf)(pTHX_ const char *pat, va_list *args); static #else extern SV * DPPP_(my_vnewSVpvf)(pTHX_ const char *pat, va_list *args); #endif #ifdef vnewSVpvf # undef vnewSVpvf #endif #define vnewSVpvf(a,b) DPPP_(my_vnewSVpvf)(aTHX_ a,b) #define Perl_vnewSVpvf DPPP_(my_vnewSVpvf) #if defined(NEED_vnewSVpvf) || defined(NEED_vnewSVpvf_GLOBAL) SV * DPPP_(my_vnewSVpvf)(pTHX_ const char *pat, va_list *args) { register SV *sv = newSV(0); sv_vsetpvfn(sv, pat, strlen(pat), args, Null(SV**), 0, Null(bool*)); return sv; } #endif #endif #if (PERL_BCDVERSION >= 0x5004000) && !defined(sv_vcatpvf) # define sv_vcatpvf(sv, pat, args) sv_vcatpvfn(sv, pat, strlen(pat), args, Null(SV**), 0, Null(bool*)) #endif #if (PERL_BCDVERSION >= 0x5004000) && !defined(sv_vsetpvf) # define sv_vsetpvf(sv, pat, args) sv_vsetpvfn(sv, pat, strlen(pat), args, Null(SV**), 0, Null(bool*)) #endif #if (PERL_BCDVERSION >= 0x5004000) && !defined(sv_catpvf_mg) #if defined(NEED_sv_catpvf_mg) static void DPPP_(my_sv_catpvf_mg)(pTHX_ SV *sv, const char *pat, ...); static #else extern void DPPP_(my_sv_catpvf_mg)(pTHX_ SV *sv, const char *pat, ...); #endif #define Perl_sv_catpvf_mg DPPP_(my_sv_catpvf_mg) #if defined(NEED_sv_catpvf_mg) || defined(NEED_sv_catpvf_mg_GLOBAL) void DPPP_(my_sv_catpvf_mg)(pTHX_ SV *sv, const char *pat, ...) { va_list args; va_start(args, pat); sv_vcatpvfn(sv, pat, strlen(pat), &args, Null(SV**), 0, Null(bool*)); SvSETMAGIC(sv); va_end(args); } #endif #endif #ifdef PERL_IMPLICIT_CONTEXT #if (PERL_BCDVERSION >= 0x5004000) && !defined(sv_catpvf_mg_nocontext) #if defined(NEED_sv_catpvf_mg_nocontext) static void DPPP_(my_sv_catpvf_mg_nocontext)(SV *sv, const char *pat, ...); static #else extern void DPPP_(my_sv_catpvf_mg_nocontext)(SV *sv, const char *pat, ...); #endif #define sv_catpvf_mg_nocontext DPPP_(my_sv_catpvf_mg_nocontext) #define Perl_sv_catpvf_mg_nocontext DPPP_(my_sv_catpvf_mg_nocontext) #if defined(NEED_sv_catpvf_mg_nocontext) || defined(NEED_sv_catpvf_mg_nocontext_GLOBAL) void DPPP_(my_sv_catpvf_mg_nocontext)(SV *sv, const char *pat, ...) { dTHX; va_list args; va_start(args, pat); sv_vcatpvfn(sv, pat, strlen(pat), &args, Null(SV**), 0, Null(bool*)); SvSETMAGIC(sv); va_end(args); } #endif #endif #endif /* sv_catpvf_mg depends on sv_catpvf_mg_nocontext */ #ifndef sv_catpvf_mg # ifdef PERL_IMPLICIT_CONTEXT # define sv_catpvf_mg Perl_sv_catpvf_mg_nocontext # else # define sv_catpvf_mg Perl_sv_catpvf_mg # endif #endif #if (PERL_BCDVERSION >= 0x5004000) && !defined(sv_vcatpvf_mg) # define sv_vcatpvf_mg(sv, pat, args) \ STMT_START { \ sv_vcatpvfn(sv, pat, strlen(pat), args, Null(SV**), 0, Null(bool*)); \ SvSETMAGIC(sv); \ } STMT_END #endif #if (PERL_BCDVERSION >= 0x5004000) && !defined(sv_setpvf_mg) #if defined(NEED_sv_setpvf_mg) static void DPPP_(my_sv_setpvf_mg)(pTHX_ SV *sv, const char *pat, ...); static #else extern void DPPP_(my_sv_setpvf_mg)(pTHX_ SV *sv, const char *pat, ...); #endif #define Perl_sv_setpvf_mg DPPP_(my_sv_setpvf_mg) #if defined(NEED_sv_setpvf_mg) || defined(NEED_sv_setpvf_mg_GLOBAL) void DPPP_(my_sv_setpvf_mg)(pTHX_ SV *sv, const char *pat, ...) { va_list args; va_start(args, pat); sv_vsetpvfn(sv, pat, strlen(pat), &args, Null(SV**), 0, Null(bool*)); SvSETMAGIC(sv); va_end(args); } #endif #endif #ifdef PERL_IMPLICIT_CONTEXT #if (PERL_BCDVERSION >= 0x5004000) && !defined(sv_setpvf_mg_nocontext) #if defined(NEED_sv_setpvf_mg_nocontext) static void DPPP_(my_sv_setpvf_mg_nocontext)(SV *sv, const char *pat, ...); static #else extern void DPPP_(my_sv_setpvf_mg_nocontext)(SV *sv, const char *pat, ...); #endif #define sv_setpvf_mg_nocontext DPPP_(my_sv_setpvf_mg_nocontext) #define Perl_sv_setpvf_mg_nocontext DPPP_(my_sv_setpvf_mg_nocontext) #if defined(NEED_sv_setpvf_mg_nocontext) || defined(NEED_sv_setpvf_mg_nocontext_GLOBAL) void DPPP_(my_sv_setpvf_mg_nocontext)(SV *sv, const char *pat, ...) { dTHX; va_list args; va_start(args, pat); sv_vsetpvfn(sv, pat, strlen(pat), &args, Null(SV**), 0, Null(bool*)); SvSETMAGIC(sv); va_end(args); } #endif #endif #endif /* sv_setpvf_mg depends on sv_setpvf_mg_nocontext */ #ifndef sv_setpvf_mg # ifdef PERL_IMPLICIT_CONTEXT # define sv_setpvf_mg Perl_sv_setpvf_mg_nocontext # else # define sv_setpvf_mg Perl_sv_setpvf_mg # endif #endif #if (PERL_BCDVERSION >= 0x5004000) && !defined(sv_vsetpvf_mg) # define sv_vsetpvf_mg(sv, pat, args) \ STMT_START { \ sv_vsetpvfn(sv, pat, strlen(pat), args, Null(SV**), 0, Null(bool*)); \ SvSETMAGIC(sv); \ } STMT_END #endif #ifndef newSVpvn_share #if defined(NEED_newSVpvn_share) static SV * DPPP_(my_newSVpvn_share)(pTHX_ const char *src, I32 len, U32 hash); static #else extern SV * DPPP_(my_newSVpvn_share)(pTHX_ const char *src, I32 len, U32 hash); #endif #ifdef newSVpvn_share # undef newSVpvn_share #endif #define newSVpvn_share(a,b,c) DPPP_(my_newSVpvn_share)(aTHX_ a,b,c) #define Perl_newSVpvn_share DPPP_(my_newSVpvn_share) #if defined(NEED_newSVpvn_share) || defined(NEED_newSVpvn_share_GLOBAL) SV * DPPP_(my_newSVpvn_share)(pTHX_ const char *src, I32 len, U32 hash) { SV *sv; if (len < 0) len = -len; if (!hash) PERL_HASH(hash, (char*) src, len); sv = newSVpvn((char *) src, len); sv_upgrade(sv, SVt_PVIV); SvIVX(sv) = hash; SvREADONLY_on(sv); SvPOK_on(sv); return sv; } #endif #endif #ifndef SvSHARED_HASH # define SvSHARED_HASH(sv) (0 + SvUVX(sv)) #endif #ifndef HvNAME_get # define HvNAME_get(hv) HvNAME(hv) #endif #ifndef HvNAMELEN_get # define HvNAMELEN_get(hv) (HvNAME_get(hv) ? (I32)strlen(HvNAME_get(hv)) : 0) #endif #ifndef GvSVn # define GvSVn(gv) GvSV(gv) #endif #ifndef isGV_with_GP # define isGV_with_GP(gv) isGV(gv) #endif #ifndef WARN_ALL # define WARN_ALL 0 #endif #ifndef WARN_CLOSURE # define WARN_CLOSURE 1 #endif #ifndef WARN_DEPRECATED # define WARN_DEPRECATED 2 #endif #ifndef WARN_EXITING # define WARN_EXITING 3 #endif #ifndef WARN_GLOB # define WARN_GLOB 4 #endif #ifndef WARN_IO # define WARN_IO 5 #endif #ifndef WARN_CLOSED # define WARN_CLOSED 6 #endif #ifndef WARN_EXEC # define WARN_EXEC 7 #endif #ifndef WARN_LAYER # define WARN_LAYER 8 #endif #ifndef WARN_NEWLINE # define WARN_NEWLINE 9 #endif #ifndef WARN_PIPE # define WARN_PIPE 10 #endif #ifndef WARN_UNOPENED # define WARN_UNOPENED 11 #endif #ifndef WARN_MISC # define WARN_MISC 12 #endif #ifndef WARN_NUMERIC # define WARN_NUMERIC 13 #endif #ifndef WARN_ONCE # define WARN_ONCE 14 #endif #ifndef WARN_OVERFLOW # define WARN_OVERFLOW 15 #endif #ifndef WARN_PACK # define WARN_PACK 16 #endif #ifndef WARN_PORTABLE # define WARN_PORTABLE 17 #endif #ifndef WARN_RECURSION # define WARN_RECURSION 18 #endif #ifndef WARN_REDEFINE # define WARN_REDEFINE 19 #endif #ifndef WARN_REGEXP # define WARN_REGEXP 20 #endif #ifndef WARN_SEVERE # define WARN_SEVERE 21 #endif #ifndef WARN_DEBUGGING # define WARN_DEBUGGING 22 #endif #ifndef WARN_INPLACE # define WARN_INPLACE 23 #endif #ifndef WARN_INTERNAL # define WARN_INTERNAL 24 #endif #ifndef WARN_MALLOC # define WARN_MALLOC 25 #endif #ifndef WARN_SIGNAL # define WARN_SIGNAL 26 #endif #ifndef WARN_SUBSTR # define WARN_SUBSTR 27 #endif #ifndef WARN_SYNTAX # define WARN_SYNTAX 28 #endif #ifndef WARN_AMBIGUOUS # define WARN_AMBIGUOUS 29 #endif #ifndef WARN_BAREWORD # define WARN_BAREWORD 30 #endif #ifndef WARN_DIGIT # define WARN_DIGIT 31 #endif #ifndef WARN_PARENTHESIS # define WARN_PARENTHESIS 32 #endif #ifndef WARN_PRECEDENCE # define WARN_PRECEDENCE 33 #endif #ifndef WARN_PRINTF # define WARN_PRINTF 34 #endif #ifndef WARN_PROTOTYPE # define WARN_PROTOTYPE 35 #endif #ifndef WARN_QW # define WARN_QW 36 #endif #ifndef WARN_RESERVED # define WARN_RESERVED 37 #endif #ifndef WARN_SEMICOLON # define WARN_SEMICOLON 38 #endif #ifndef WARN_TAINT # define WARN_TAINT 39 #endif #ifndef WARN_THREADS # define WARN_THREADS 40 #endif #ifndef WARN_UNINITIALIZED # define WARN_UNINITIALIZED 41 #endif #ifndef WARN_UNPACK # define WARN_UNPACK 42 #endif #ifndef WARN_UNTIE # define WARN_UNTIE 43 #endif #ifndef WARN_UTF8 # define WARN_UTF8 44 #endif #ifndef WARN_VOID # define WARN_VOID 45 #endif #ifndef WARN_ASSERTIONS # define WARN_ASSERTIONS 46 #endif #ifndef packWARN # define packWARN(a) (a) #endif #ifndef ckWARN # ifdef G_WARN_ON # define ckWARN(a) (PL_dowarn & G_WARN_ON) # else # define ckWARN(a) PL_dowarn # endif #endif #if (PERL_BCDVERSION >= 0x5004000) && !defined(warner) #if defined(NEED_warner) static void DPPP_(my_warner)(U32 err, const char *pat, ...); static #else extern void DPPP_(my_warner)(U32 err, const char *pat, ...); #endif #define Perl_warner DPPP_(my_warner) #if defined(NEED_warner) || defined(NEED_warner_GLOBAL) void DPPP_(my_warner)(U32 err, const char *pat, ...) { SV *sv; va_list args; PERL_UNUSED_ARG(err); va_start(args, pat); sv = vnewSVpvf(pat, &args); va_end(args); sv_2mortal(sv); warn("%s", SvPV_nolen(sv)); } #define warner Perl_warner #define Perl_warner_nocontext Perl_warner #endif #endif /* concatenating with "" ensures that only literal strings are accepted as argument * note that STR_WITH_LEN() can't be used as argument to macros or functions that * under some configurations might be macros */ #ifndef STR_WITH_LEN # define STR_WITH_LEN(s) (s ""), (sizeof(s)-1) #endif #ifndef newSVpvs # define newSVpvs(str) newSVpvn(str "", sizeof(str) - 1) #endif #ifndef newSVpvs_flags # define newSVpvs_flags(str, flags) newSVpvn_flags(str "", sizeof(str) - 1, flags) #endif #ifndef sv_catpvs # define sv_catpvs(sv, str) sv_catpvn(sv, str "", sizeof(str) - 1) #endif #ifndef sv_setpvs # define sv_setpvs(sv, str) sv_setpvn(sv, str "", sizeof(str) - 1) #endif #ifndef hv_fetchs # define hv_fetchs(hv, key, lval) hv_fetch(hv, key "", sizeof(key) - 1, lval) #endif #ifndef hv_stores # define hv_stores(hv, key, val) hv_store(hv, key "", sizeof(key) - 1, val, 0) #endif #ifndef gv_fetchpvn_flags # define gv_fetchpvn_flags(name, len, flags, svt) gv_fetchpv(name, flags, svt) #endif #ifndef gv_fetchpvs # define gv_fetchpvs(name, flags, svt) gv_fetchpvn_flags(name "", sizeof(name) - 1, flags, svt) #endif #ifndef gv_stashpvs # define gv_stashpvs(name, flags) gv_stashpvn(name "", sizeof(name) - 1, flags) #endif #ifndef SvGETMAGIC # define SvGETMAGIC(x) STMT_START { if (SvGMAGICAL(x)) mg_get(x); } STMT_END #endif #ifndef PERL_MAGIC_sv # define PERL_MAGIC_sv '\0' #endif #ifndef PERL_MAGIC_overload # define PERL_MAGIC_overload 'A' #endif #ifndef PERL_MAGIC_overload_elem # define PERL_MAGIC_overload_elem 'a' #endif #ifndef PERL_MAGIC_overload_table # define PERL_MAGIC_overload_table 'c' #endif #ifndef PERL_MAGIC_bm # define PERL_MAGIC_bm 'B' #endif #ifndef PERL_MAGIC_regdata # define PERL_MAGIC_regdata 'D' #endif #ifndef PERL_MAGIC_regdatum # define PERL_MAGIC_regdatum 'd' #endif #ifndef PERL_MAGIC_env # define PERL_MAGIC_env 'E' #endif #ifndef PERL_MAGIC_envelem # define PERL_MAGIC_envelem 'e' #endif #ifndef PERL_MAGIC_fm # define PERL_MAGIC_fm 'f' #endif #ifndef PERL_MAGIC_regex_global # define PERL_MAGIC_regex_global 'g' #endif #ifndef PERL_MAGIC_isa # define PERL_MAGIC_isa 'I' #endif #ifndef PERL_MAGIC_isaelem # define PERL_MAGIC_isaelem 'i' #endif #ifndef PERL_MAGIC_nkeys # define PERL_MAGIC_nkeys 'k' #endif #ifndef PERL_MAGIC_dbfile # define PERL_MAGIC_dbfile 'L' #endif #ifndef PERL_MAGIC_dbline # define PERL_MAGIC_dbline 'l' #endif #ifndef PERL_MAGIC_mutex # define PERL_MAGIC_mutex 'm' #endif #ifndef PERL_MAGIC_shared # define PERL_MAGIC_shared 'N' #endif #ifndef PERL_MAGIC_shared_scalar # define PERL_MAGIC_shared_scalar 'n' #endif #ifndef PERL_MAGIC_collxfrm # define PERL_MAGIC_collxfrm 'o' #endif #ifndef PERL_MAGIC_tied # define PERL_MAGIC_tied 'P' #endif #ifndef PERL_MAGIC_tiedelem # define PERL_MAGIC_tiedelem 'p' #endif #ifndef PERL_MAGIC_tiedscalar # define PERL_MAGIC_tiedscalar 'q' #endif #ifndef PERL_MAGIC_qr # define PERL_MAGIC_qr 'r' #endif #ifndef PERL_MAGIC_sig # define PERL_MAGIC_sig 'S' #endif #ifndef PERL_MAGIC_sigelem # define PERL_MAGIC_sigelem 's' #endif #ifndef PERL_MAGIC_taint # define PERL_MAGIC_taint 't' #endif #ifndef PERL_MAGIC_uvar # define PERL_MAGIC_uvar 'U' #endif #ifndef PERL_MAGIC_uvar_elem # define PERL_MAGIC_uvar_elem 'u' #endif #ifndef PERL_MAGIC_vstring # define PERL_MAGIC_vstring 'V' #endif #ifndef PERL_MAGIC_vec # define PERL_MAGIC_vec 'v' #endif #ifndef PERL_MAGIC_utf8 # define PERL_MAGIC_utf8 'w' #endif #ifndef PERL_MAGIC_substr # define PERL_MAGIC_substr 'x' #endif #ifndef PERL_MAGIC_defelem # define PERL_MAGIC_defelem 'y' #endif #ifndef PERL_MAGIC_glob # define PERL_MAGIC_glob '*' #endif #ifndef PERL_MAGIC_arylen # define PERL_MAGIC_arylen '#' #endif #ifndef PERL_MAGIC_pos # define PERL_MAGIC_pos '.' #endif #ifndef PERL_MAGIC_backref # define PERL_MAGIC_backref '<' #endif #ifndef PERL_MAGIC_ext # define PERL_MAGIC_ext '~' #endif /* That's the best we can do... */ #ifndef sv_catpvn_nomg # define sv_catpvn_nomg sv_catpvn #endif #ifndef sv_catsv_nomg # define sv_catsv_nomg sv_catsv #endif #ifndef sv_setsv_nomg # define sv_setsv_nomg sv_setsv #endif #ifndef sv_pvn_nomg # define sv_pvn_nomg sv_pvn #endif #ifndef SvIV_nomg # define SvIV_nomg SvIV #endif #ifndef SvUV_nomg # define SvUV_nomg SvUV #endif #ifndef sv_catpv_mg # define sv_catpv_mg(sv, ptr) \ STMT_START { \ SV *TeMpSv = sv; \ sv_catpv(TeMpSv,ptr); \ SvSETMAGIC(TeMpSv); \ } STMT_END #endif #ifndef sv_catpvn_mg # define sv_catpvn_mg(sv, ptr, len) \ STMT_START { \ SV *TeMpSv = sv; \ sv_catpvn(TeMpSv,ptr,len); \ SvSETMAGIC(TeMpSv); \ } STMT_END #endif #ifndef sv_catsv_mg # define sv_catsv_mg(dsv, ssv) \ STMT_START { \ SV *TeMpSv = dsv; \ sv_catsv(TeMpSv,ssv); \ SvSETMAGIC(TeMpSv); \ } STMT_END #endif #ifndef sv_setiv_mg # define sv_setiv_mg(sv, i) \ STMT_START { \ SV *TeMpSv = sv; \ sv_setiv(TeMpSv,i); \ SvSETMAGIC(TeMpSv); \ } STMT_END #endif #ifndef sv_setnv_mg # define sv_setnv_mg(sv, num) \ STMT_START { \ SV *TeMpSv = sv; \ sv_setnv(TeMpSv,num); \ SvSETMAGIC(TeMpSv); \ } STMT_END #endif #ifndef sv_setpv_mg # define sv_setpv_mg(sv, ptr) \ STMT_START { \ SV *TeMpSv = sv; \ sv_setpv(TeMpSv,ptr); \ SvSETMAGIC(TeMpSv); \ } STMT_END #endif #ifndef sv_setpvn_mg # define sv_setpvn_mg(sv, ptr, len) \ STMT_START { \ SV *TeMpSv = sv; \ sv_setpvn(TeMpSv,ptr,len); \ SvSETMAGIC(TeMpSv); \ } STMT_END #endif #ifndef sv_setsv_mg # define sv_setsv_mg(dsv, ssv) \ STMT_START { \ SV *TeMpSv = dsv; \ sv_setsv(TeMpSv,ssv); \ SvSETMAGIC(TeMpSv); \ } STMT_END #endif #ifndef sv_setuv_mg # define sv_setuv_mg(sv, i) \ STMT_START { \ SV *TeMpSv = sv; \ sv_setuv(TeMpSv,i); \ SvSETMAGIC(TeMpSv); \ } STMT_END #endif #ifndef sv_usepvn_mg # define sv_usepvn_mg(sv, ptr, len) \ STMT_START { \ SV *TeMpSv = sv; \ sv_usepvn(TeMpSv,ptr,len); \ SvSETMAGIC(TeMpSv); \ } STMT_END #endif #ifndef SvVSTRING_mg # define SvVSTRING_mg(sv) (SvMAGICAL(sv) ? mg_find(sv, PERL_MAGIC_vstring) : NULL) #endif /* Hint: sv_magic_portable * This is a compatibility function that is only available with * Devel::PPPort. It is NOT in the perl core. * Its purpose is to mimic the 5.8.0 behaviour of sv_magic() when * it is being passed a name pointer with namlen == 0. In that * case, perl 5.8.0 and later store the pointer, not a copy of it. * The compatibility can be provided back to perl 5.004. With * earlier versions, the code will not compile. */ #if (PERL_BCDVERSION < 0x5004000) /* code that uses sv_magic_portable will not compile */ #elif (PERL_BCDVERSION < 0x5008000) # define sv_magic_portable(sv, obj, how, name, namlen) \ STMT_START { \ SV *SvMp_sv = (sv); \ char *SvMp_name = (char *) (name); \ I32 SvMp_namlen = (namlen); \ if (SvMp_name && SvMp_namlen == 0) \ { \ MAGIC *mg; \ sv_magic(SvMp_sv, obj, how, 0, 0); \ mg = SvMAGIC(SvMp_sv); \ mg->mg_len = -42; /* XXX: this is the tricky part */ \ mg->mg_ptr = SvMp_name; \ } \ else \ { \ sv_magic(SvMp_sv, obj, how, SvMp_name, SvMp_namlen); \ } \ } STMT_END #else # define sv_magic_portable(a, b, c, d, e) sv_magic(a, b, c, d, e) #endif #ifdef USE_ITHREADS #ifndef CopFILE # define CopFILE(c) ((c)->cop_file) #endif #ifndef CopFILEGV # define CopFILEGV(c) (CopFILE(c) ? gv_fetchfile(CopFILE(c)) : Nullgv) #endif #ifndef CopFILE_set # define CopFILE_set(c,pv) ((c)->cop_file = savepv(pv)) #endif #ifndef CopFILESV # define CopFILESV(c) (CopFILE(c) ? GvSV(gv_fetchfile(CopFILE(c))) : Nullsv) #endif #ifndef CopFILEAV # define CopFILEAV(c) (CopFILE(c) ? GvAV(gv_fetchfile(CopFILE(c))) : Nullav) #endif #ifndef CopSTASHPV # define CopSTASHPV(c) ((c)->cop_stashpv) #endif #ifndef CopSTASHPV_set # define CopSTASHPV_set(c,pv) ((c)->cop_stashpv = ((pv) ? savepv(pv) : Nullch)) #endif #ifndef CopSTASH # define CopSTASH(c) (CopSTASHPV(c) ? gv_stashpv(CopSTASHPV(c),GV_ADD) : Nullhv) #endif #ifndef CopSTASH_set # define CopSTASH_set(c,hv) CopSTASHPV_set(c, (hv) ? HvNAME(hv) : Nullch) #endif #ifndef CopSTASH_eq # define CopSTASH_eq(c,hv) ((hv) && (CopSTASHPV(c) == HvNAME(hv) \ || (CopSTASHPV(c) && HvNAME(hv) \ && strEQ(CopSTASHPV(c), HvNAME(hv))))) #endif #else #ifndef CopFILEGV # define CopFILEGV(c) ((c)->cop_filegv) #endif #ifndef CopFILEGV_set # define CopFILEGV_set(c,gv) ((c)->cop_filegv = (GV*)SvREFCNT_inc(gv)) #endif #ifndef CopFILE_set # define CopFILE_set(c,pv) CopFILEGV_set((c), gv_fetchfile(pv)) #endif #ifndef CopFILESV # define CopFILESV(c) (CopFILEGV(c) ? GvSV(CopFILEGV(c)) : Nullsv) #endif #ifndef CopFILEAV # define CopFILEAV(c) (CopFILEGV(c) ? GvAV(CopFILEGV(c)) : Nullav) #endif #ifndef CopFILE # define CopFILE(c) (CopFILESV(c) ? SvPVX(CopFILESV(c)) : Nullch) #endif #ifndef CopSTASH # define CopSTASH(c) ((c)->cop_stash) #endif #ifndef CopSTASH_set # define CopSTASH_set(c,hv) ((c)->cop_stash = (hv)) #endif #ifndef CopSTASHPV # define CopSTASHPV(c) (CopSTASH(c) ? HvNAME(CopSTASH(c)) : Nullch) #endif #ifndef CopSTASHPV_set # define CopSTASHPV_set(c,pv) CopSTASH_set((c), gv_stashpv(pv,GV_ADD)) #endif #ifndef CopSTASH_eq # define CopSTASH_eq(c,hv) (CopSTASH(c) == (hv)) #endif #endif /* USE_ITHREADS */ #ifndef IN_PERL_COMPILETIME # define IN_PERL_COMPILETIME (PL_curcop == &PL_compiling) #endif #ifndef IN_LOCALE_RUNTIME # define IN_LOCALE_RUNTIME (PL_curcop->op_private & HINT_LOCALE) #endif #ifndef IN_LOCALE_COMPILETIME # define IN_LOCALE_COMPILETIME (PL_hints & HINT_LOCALE) #endif #ifndef IN_LOCALE # define IN_LOCALE (IN_PERL_COMPILETIME ? IN_LOCALE_COMPILETIME : IN_LOCALE_RUNTIME) #endif #ifndef IS_NUMBER_IN_UV # define IS_NUMBER_IN_UV 0x01 #endif #ifndef IS_NUMBER_GREATER_THAN_UV_MAX # define IS_NUMBER_GREATER_THAN_UV_MAX 0x02 #endif #ifndef IS_NUMBER_NOT_INT # define IS_NUMBER_NOT_INT 0x04 #endif #ifndef IS_NUMBER_NEG # define IS_NUMBER_NEG 0x08 #endif #ifndef IS_NUMBER_INFINITY # define IS_NUMBER_INFINITY 0x10 #endif #ifndef IS_NUMBER_NAN # define IS_NUMBER_NAN 0x20 #endif #ifndef GROK_NUMERIC_RADIX # define GROK_NUMERIC_RADIX(sp, send) grok_numeric_radix(sp, send) #endif #ifndef PERL_SCAN_GREATER_THAN_UV_MAX # define PERL_SCAN_GREATER_THAN_UV_MAX 0x02 #endif #ifndef PERL_SCAN_SILENT_ILLDIGIT # define PERL_SCAN_SILENT_ILLDIGIT 0x04 #endif #ifndef PERL_SCAN_ALLOW_UNDERSCORES # define PERL_SCAN_ALLOW_UNDERSCORES 0x01 #endif #ifndef PERL_SCAN_DISALLOW_PREFIX # define PERL_SCAN_DISALLOW_PREFIX 0x02 #endif #ifndef grok_numeric_radix #if defined(NEED_grok_numeric_radix) static bool DPPP_(my_grok_numeric_radix)(pTHX_ const char ** sp, const char * send); static #else extern bool DPPP_(my_grok_numeric_radix)(pTHX_ const char ** sp, const char * send); #endif #ifdef grok_numeric_radix # undef grok_numeric_radix #endif #define grok_numeric_radix(a,b) DPPP_(my_grok_numeric_radix)(aTHX_ a,b) #define Perl_grok_numeric_radix DPPP_(my_grok_numeric_radix) #if defined(NEED_grok_numeric_radix) || defined(NEED_grok_numeric_radix_GLOBAL) bool DPPP_(my_grok_numeric_radix)(pTHX_ const char **sp, const char *send) { #ifdef USE_LOCALE_NUMERIC #ifdef PL_numeric_radix_sv if (PL_numeric_radix_sv && IN_LOCALE) { STRLEN len; char* radix = SvPV(PL_numeric_radix_sv, len); if (*sp + len <= send && memEQ(*sp, radix, len)) { *sp += len; return TRUE; } } #else /* older perls don't have PL_numeric_radix_sv so the radix * must manually be requested from locale.h */ #include dTHR; /* needed for older threaded perls */ struct lconv *lc = localeconv(); char *radix = lc->decimal_point; if (radix && IN_LOCALE) { STRLEN len = strlen(radix); if (*sp + len <= send && memEQ(*sp, radix, len)) { *sp += len; return TRUE; } } #endif #endif /* USE_LOCALE_NUMERIC */ /* always try "." if numeric radix didn't match because * we may have data from different locales mixed */ if (*sp < send && **sp == '.') { ++*sp; return TRUE; } return FALSE; } #endif #endif #ifndef grok_number #if defined(NEED_grok_number) static int DPPP_(my_grok_number)(pTHX_ const char * pv, STRLEN len, UV * valuep); static #else extern int DPPP_(my_grok_number)(pTHX_ const char * pv, STRLEN len, UV * valuep); #endif #ifdef grok_number # undef grok_number #endif #define grok_number(a,b,c) DPPP_(my_grok_number)(aTHX_ a,b,c) #define Perl_grok_number DPPP_(my_grok_number) #if defined(NEED_grok_number) || defined(NEED_grok_number_GLOBAL) int DPPP_(my_grok_number)(pTHX_ const char *pv, STRLEN len, UV *valuep) { const char *s = pv; const char *send = pv + len; const UV max_div_10 = UV_MAX / 10; const char max_mod_10 = UV_MAX % 10; int numtype = 0; int sawinf = 0; int sawnan = 0; while (s < send && isSPACE(*s)) s++; if (s == send) { return 0; } else if (*s == '-') { s++; numtype = IS_NUMBER_NEG; } else if (*s == '+') s++; if (s == send) return 0; /* next must be digit or the radix separator or beginning of infinity */ if (isDIGIT(*s)) { /* UVs are at least 32 bits, so the first 9 decimal digits cannot overflow. */ UV value = *s - '0'; /* This construction seems to be more optimiser friendly. (without it gcc does the isDIGIT test and the *s - '0' separately) With it gcc on arm is managing 6 instructions (6 cycles) per digit. In theory the optimiser could deduce how far to unroll the loop before checking for overflow. */ if (++s < send) { int digit = *s - '0'; if (digit >= 0 && digit <= 9) { value = value * 10 + digit; if (++s < send) { digit = *s - '0'; if (digit >= 0 && digit <= 9) { value = value * 10 + digit; if (++s < send) { digit = *s - '0'; if (digit >= 0 && digit <= 9) { value = value * 10 + digit; if (++s < send) { digit = *s - '0'; if (digit >= 0 && digit <= 9) { value = value * 10 + digit; if (++s < send) { digit = *s - '0'; if (digit >= 0 && digit <= 9) { value = value * 10 + digit; if (++s < send) { digit = *s - '0'; if (digit >= 0 && digit <= 9) { value = value * 10 + digit; if (++s < send) { digit = *s - '0'; if (digit >= 0 && digit <= 9) { value = value * 10 + digit; if (++s < send) { digit = *s - '0'; if (digit >= 0 && digit <= 9) { value = value * 10 + digit; if (++s < send) { /* Now got 9 digits, so need to check each time for overflow. */ digit = *s - '0'; while (digit >= 0 && digit <= 9 && (value < max_div_10 || (value == max_div_10 && digit <= max_mod_10))) { value = value * 10 + digit; if (++s < send) digit = *s - '0'; else break; } if (digit >= 0 && digit <= 9 && (s < send)) { /* value overflowed. skip the remaining digits, don't worry about setting *valuep. */ do { s++; } while (s < send && isDIGIT(*s)); numtype |= IS_NUMBER_GREATER_THAN_UV_MAX; goto skip_value; } } } } } } } } } } } } } } } } } } numtype |= IS_NUMBER_IN_UV; if (valuep) *valuep = value; skip_value: if (GROK_NUMERIC_RADIX(&s, send)) { numtype |= IS_NUMBER_NOT_INT; while (s < send && isDIGIT(*s)) /* optional digits after the radix */ s++; } } else if (GROK_NUMERIC_RADIX(&s, send)) { numtype |= IS_NUMBER_NOT_INT | IS_NUMBER_IN_UV; /* valuep assigned below */ /* no digits before the radix means we need digits after it */ if (s < send && isDIGIT(*s)) { do { s++; } while (s < send && isDIGIT(*s)); if (valuep) { /* integer approximation is valid - it's 0. */ *valuep = 0; } } else return 0; } else if (*s == 'I' || *s == 'i') { s++; if (s == send || (*s != 'N' && *s != 'n')) return 0; s++; if (s == send || (*s != 'F' && *s != 'f')) return 0; s++; if (s < send && (*s == 'I' || *s == 'i')) { s++; if (s == send || (*s != 'N' && *s != 'n')) return 0; s++; if (s == send || (*s != 'I' && *s != 'i')) return 0; s++; if (s == send || (*s != 'T' && *s != 't')) return 0; s++; if (s == send || (*s != 'Y' && *s != 'y')) return 0; s++; } sawinf = 1; } else if (*s == 'N' || *s == 'n') { /* XXX TODO: There are signaling NaNs and quiet NaNs. */ s++; if (s == send || (*s != 'A' && *s != 'a')) return 0; s++; if (s == send || (*s != 'N' && *s != 'n')) return 0; s++; sawnan = 1; } else return 0; if (sawinf) { numtype &= IS_NUMBER_NEG; /* Keep track of sign */ numtype |= IS_NUMBER_INFINITY | IS_NUMBER_NOT_INT; } else if (sawnan) { numtype &= IS_NUMBER_NEG; /* Keep track of sign */ numtype |= IS_NUMBER_NAN | IS_NUMBER_NOT_INT; } else if (s < send) { /* we can have an optional exponent part */ if (*s == 'e' || *s == 'E') { /* The only flag we keep is sign. Blow away any "it's UV" */ numtype &= IS_NUMBER_NEG; numtype |= IS_NUMBER_NOT_INT; s++; if (s < send && (*s == '-' || *s == '+')) s++; if (s < send && isDIGIT(*s)) { do { s++; } while (s < send && isDIGIT(*s)); } else return 0; } } while (s < send && isSPACE(*s)) s++; if (s >= send) return numtype; if (len == 10 && memEQ(pv, "0 but true", 10)) { if (valuep) *valuep = 0; return IS_NUMBER_IN_UV; } return 0; } #endif #endif /* * The grok_* routines have been modified to use warn() instead of * Perl_warner(). Also, 'hexdigit' was the former name of PL_hexdigit, * which is why the stack variable has been renamed to 'xdigit'. */ #ifndef grok_bin #if defined(NEED_grok_bin) static UV DPPP_(my_grok_bin)(pTHX_ const char * start, STRLEN * len_p, I32 * flags, NV * result); static #else extern UV DPPP_(my_grok_bin)(pTHX_ const char * start, STRLEN * len_p, I32 * flags, NV * result); #endif #ifdef grok_bin # undef grok_bin #endif #define grok_bin(a,b,c,d) DPPP_(my_grok_bin)(aTHX_ a,b,c,d) #define Perl_grok_bin DPPP_(my_grok_bin) #if defined(NEED_grok_bin) || defined(NEED_grok_bin_GLOBAL) UV DPPP_(my_grok_bin)(pTHX_ const char *start, STRLEN *len_p, I32 *flags, NV *result) { const char *s = start; STRLEN len = *len_p; UV value = 0; NV value_nv = 0; const UV max_div_2 = UV_MAX / 2; bool allow_underscores = *flags & PERL_SCAN_ALLOW_UNDERSCORES; bool overflowed = FALSE; if (!(*flags & PERL_SCAN_DISALLOW_PREFIX)) { /* strip off leading b or 0b. for compatibility silently suffer "b" and "0b" as valid binary numbers. */ if (len >= 1) { if (s[0] == 'b') { s++; len--; } else if (len >= 2 && s[0] == '0' && s[1] == 'b') { s+=2; len-=2; } } } for (; len-- && *s; s++) { char bit = *s; if (bit == '0' || bit == '1') { /* Write it in this wonky order with a goto to attempt to get the compiler to make the common case integer-only loop pretty tight. With gcc seems to be much straighter code than old scan_bin. */ redo: if (!overflowed) { if (value <= max_div_2) { value = (value << 1) | (bit - '0'); continue; } /* Bah. We're just overflowed. */ warn("Integer overflow in binary number"); overflowed = TRUE; value_nv = (NV) value; } value_nv *= 2.0; /* If an NV has not enough bits in its mantissa to * represent a UV this summing of small low-order numbers * is a waste of time (because the NV cannot preserve * the low-order bits anyway): we could just remember when * did we overflow and in the end just multiply value_nv by the * right amount. */ value_nv += (NV)(bit - '0'); continue; } if (bit == '_' && len && allow_underscores && (bit = s[1]) && (bit == '0' || bit == '1')) { --len; ++s; goto redo; } if (!(*flags & PERL_SCAN_SILENT_ILLDIGIT)) warn("Illegal binary digit '%c' ignored", *s); break; } if ( ( overflowed && value_nv > 4294967295.0) #if UVSIZE > 4 || (!overflowed && value > 0xffffffff ) #endif ) { warn("Binary number > 0b11111111111111111111111111111111 non-portable"); } *len_p = s - start; if (!overflowed) { *flags = 0; return value; } *flags = PERL_SCAN_GREATER_THAN_UV_MAX; if (result) *result = value_nv; return UV_MAX; } #endif #endif #ifndef grok_hex #if defined(NEED_grok_hex) static UV DPPP_(my_grok_hex)(pTHX_ const char * start, STRLEN * len_p, I32 * flags, NV * result); static #else extern UV DPPP_(my_grok_hex)(pTHX_ const char * start, STRLEN * len_p, I32 * flags, NV * result); #endif #ifdef grok_hex # undef grok_hex #endif #define grok_hex(a,b,c,d) DPPP_(my_grok_hex)(aTHX_ a,b,c,d) #define Perl_grok_hex DPPP_(my_grok_hex) #if defined(NEED_grok_hex) || defined(NEED_grok_hex_GLOBAL) UV DPPP_(my_grok_hex)(pTHX_ const char *start, STRLEN *len_p, I32 *flags, NV *result) { const char *s = start; STRLEN len = *len_p; UV value = 0; NV value_nv = 0; const UV max_div_16 = UV_MAX / 16; bool allow_underscores = *flags & PERL_SCAN_ALLOW_UNDERSCORES; bool overflowed = FALSE; const char *xdigit; if (!(*flags & PERL_SCAN_DISALLOW_PREFIX)) { /* strip off leading x or 0x. for compatibility silently suffer "x" and "0x" as valid hex numbers. */ if (len >= 1) { if (s[0] == 'x') { s++; len--; } else if (len >= 2 && s[0] == '0' && s[1] == 'x') { s+=2; len-=2; } } } for (; len-- && *s; s++) { xdigit = strchr((char *) PL_hexdigit, *s); if (xdigit) { /* Write it in this wonky order with a goto to attempt to get the compiler to make the common case integer-only loop pretty tight. With gcc seems to be much straighter code than old scan_hex. */ redo: if (!overflowed) { if (value <= max_div_16) { value = (value << 4) | ((xdigit - PL_hexdigit) & 15); continue; } warn("Integer overflow in hexadecimal number"); overflowed = TRUE; value_nv = (NV) value; } value_nv *= 16.0; /* If an NV has not enough bits in its mantissa to * represent a UV this summing of small low-order numbers * is a waste of time (because the NV cannot preserve * the low-order bits anyway): we could just remember when * did we overflow and in the end just multiply value_nv by the * right amount of 16-tuples. */ value_nv += (NV)((xdigit - PL_hexdigit) & 15); continue; } if (*s == '_' && len && allow_underscores && s[1] && (xdigit = strchr((char *) PL_hexdigit, s[1]))) { --len; ++s; goto redo; } if (!(*flags & PERL_SCAN_SILENT_ILLDIGIT)) warn("Illegal hexadecimal digit '%c' ignored", *s); break; } if ( ( overflowed && value_nv > 4294967295.0) #if UVSIZE > 4 || (!overflowed && value > 0xffffffff ) #endif ) { warn("Hexadecimal number > 0xffffffff non-portable"); } *len_p = s - start; if (!overflowed) { *flags = 0; return value; } *flags = PERL_SCAN_GREATER_THAN_UV_MAX; if (result) *result = value_nv; return UV_MAX; } #endif #endif #ifndef grok_oct #if defined(NEED_grok_oct) static UV DPPP_(my_grok_oct)(pTHX_ const char * start, STRLEN * len_p, I32 * flags, NV * result); static #else extern UV DPPP_(my_grok_oct)(pTHX_ const char * start, STRLEN * len_p, I32 * flags, NV * result); #endif #ifdef grok_oct # undef grok_oct #endif #define grok_oct(a,b,c,d) DPPP_(my_grok_oct)(aTHX_ a,b,c,d) #define Perl_grok_oct DPPP_(my_grok_oct) #if defined(NEED_grok_oct) || defined(NEED_grok_oct_GLOBAL) UV DPPP_(my_grok_oct)(pTHX_ const char *start, STRLEN *len_p, I32 *flags, NV *result) { const char *s = start; STRLEN len = *len_p; UV value = 0; NV value_nv = 0; const UV max_div_8 = UV_MAX / 8; bool allow_underscores = *flags & PERL_SCAN_ALLOW_UNDERSCORES; bool overflowed = FALSE; for (; len-- && *s; s++) { /* gcc 2.95 optimiser not smart enough to figure that this subtraction out front allows slicker code. */ int digit = *s - '0'; if (digit >= 0 && digit <= 7) { /* Write it in this wonky order with a goto to attempt to get the compiler to make the common case integer-only loop pretty tight. */ redo: if (!overflowed) { if (value <= max_div_8) { value = (value << 3) | digit; continue; } /* Bah. We're just overflowed. */ warn("Integer overflow in octal number"); overflowed = TRUE; value_nv = (NV) value; } value_nv *= 8.0; /* If an NV has not enough bits in its mantissa to * represent a UV this summing of small low-order numbers * is a waste of time (because the NV cannot preserve * the low-order bits anyway): we could just remember when * did we overflow and in the end just multiply value_nv by the * right amount of 8-tuples. */ value_nv += (NV)digit; continue; } if (digit == ('_' - '0') && len && allow_underscores && (digit = s[1] - '0') && (digit >= 0 && digit <= 7)) { --len; ++s; goto redo; } /* Allow \octal to work the DWIM way (that is, stop scanning * as soon as non-octal characters are seen, complain only iff * someone seems to want to use the digits eight and nine). */ if (digit == 8 || digit == 9) { if (!(*flags & PERL_SCAN_SILENT_ILLDIGIT)) warn("Illegal octal digit '%c' ignored", *s); } break; } if ( ( overflowed && value_nv > 4294967295.0) #if UVSIZE > 4 || (!overflowed && value > 0xffffffff ) #endif ) { warn("Octal number > 037777777777 non-portable"); } *len_p = s - start; if (!overflowed) { *flags = 0; return value; } *flags = PERL_SCAN_GREATER_THAN_UV_MAX; if (result) *result = value_nv; return UV_MAX; } #endif #endif #if !defined(my_snprintf) #if defined(NEED_my_snprintf) static int DPPP_(my_my_snprintf)(char * buffer, const Size_t len, const char * format, ...); static #else extern int DPPP_(my_my_snprintf)(char * buffer, const Size_t len, const char * format, ...); #endif #define my_snprintf DPPP_(my_my_snprintf) #define Perl_my_snprintf DPPP_(my_my_snprintf) #if defined(NEED_my_snprintf) || defined(NEED_my_snprintf_GLOBAL) int DPPP_(my_my_snprintf)(char *buffer, const Size_t len, const char *format, ...) { dTHX; int retval; va_list ap; va_start(ap, format); #ifdef HAS_VSNPRINTF retval = vsnprintf(buffer, len, format, ap); #else retval = vsprintf(buffer, format, ap); #endif va_end(ap); if (retval < 0 || (len > 0 && (Size_t)retval >= len)) Perl_croak(aTHX_ "panic: my_snprintf buffer overflow"); return retval; } #endif #endif #if !defined(my_sprintf) #if defined(NEED_my_sprintf) static int DPPP_(my_my_sprintf)(char * buffer, const char * pat, ...); static #else extern int DPPP_(my_my_sprintf)(char * buffer, const char * pat, ...); #endif #define my_sprintf DPPP_(my_my_sprintf) #define Perl_my_sprintf DPPP_(my_my_sprintf) #if defined(NEED_my_sprintf) || defined(NEED_my_sprintf_GLOBAL) int DPPP_(my_my_sprintf)(char *buffer, const char* pat, ...) { va_list args; va_start(args, pat); vsprintf(buffer, pat, args); va_end(args); return strlen(buffer); } #endif #endif #ifdef NO_XSLOCKS # ifdef dJMPENV # define dXCPT dJMPENV; int rEtV = 0 # define XCPT_TRY_START JMPENV_PUSH(rEtV); if (rEtV == 0) # define XCPT_TRY_END JMPENV_POP; # define XCPT_CATCH if (rEtV != 0) # define XCPT_RETHROW JMPENV_JUMP(rEtV) # else # define dXCPT Sigjmp_buf oldTOP; int rEtV = 0 # define XCPT_TRY_START Copy(top_env, oldTOP, 1, Sigjmp_buf); rEtV = Sigsetjmp(top_env, 1); if (rEtV == 0) # define XCPT_TRY_END Copy(oldTOP, top_env, 1, Sigjmp_buf); # define XCPT_CATCH if (rEtV != 0) # define XCPT_RETHROW Siglongjmp(top_env, rEtV) # endif #endif #if !defined(my_strlcat) #if defined(NEED_my_strlcat) static Size_t DPPP_(my_my_strlcat)(char * dst, const char * src, Size_t size); static #else extern Size_t DPPP_(my_my_strlcat)(char * dst, const char * src, Size_t size); #endif #define my_strlcat DPPP_(my_my_strlcat) #define Perl_my_strlcat DPPP_(my_my_strlcat) #if defined(NEED_my_strlcat) || defined(NEED_my_strlcat_GLOBAL) Size_t DPPP_(my_my_strlcat)(char *dst, const char *src, Size_t size) { Size_t used, length, copy; used = strlen(dst); length = strlen(src); if (size > 0 && used < size - 1) { copy = (length >= size - used) ? size - used - 1 : length; memcpy(dst + used, src, copy); dst[used + copy] = '\0'; } return used + length; } #endif #endif #if !defined(my_strlcpy) #if defined(NEED_my_strlcpy) static Size_t DPPP_(my_my_strlcpy)(char * dst, const char * src, Size_t size); static #else extern Size_t DPPP_(my_my_strlcpy)(char * dst, const char * src, Size_t size); #endif #define my_strlcpy DPPP_(my_my_strlcpy) #define Perl_my_strlcpy DPPP_(my_my_strlcpy) #if defined(NEED_my_strlcpy) || defined(NEED_my_strlcpy_GLOBAL) Size_t DPPP_(my_my_strlcpy)(char *dst, const char *src, Size_t size) { Size_t length, copy; length = strlen(src); if (size > 0) { copy = (length >= size) ? size - 1 : length; memcpy(dst, src, copy); dst[copy] = '\0'; } return length; } #endif #endif #ifndef PERL_PV_ESCAPE_QUOTE # define PERL_PV_ESCAPE_QUOTE 0x0001 #endif #ifndef PERL_PV_PRETTY_QUOTE # define PERL_PV_PRETTY_QUOTE PERL_PV_ESCAPE_QUOTE #endif #ifndef PERL_PV_PRETTY_ELLIPSES # define PERL_PV_PRETTY_ELLIPSES 0x0002 #endif #ifndef PERL_PV_PRETTY_LTGT # define PERL_PV_PRETTY_LTGT 0x0004 #endif #ifndef PERL_PV_ESCAPE_FIRSTCHAR # define PERL_PV_ESCAPE_FIRSTCHAR 0x0008 #endif #ifndef PERL_PV_ESCAPE_UNI # define PERL_PV_ESCAPE_UNI 0x0100 #endif #ifndef PERL_PV_ESCAPE_UNI_DETECT # define PERL_PV_ESCAPE_UNI_DETECT 0x0200 #endif #ifndef PERL_PV_ESCAPE_ALL # define PERL_PV_ESCAPE_ALL 0x1000 #endif #ifndef PERL_PV_ESCAPE_NOBACKSLASH # define PERL_PV_ESCAPE_NOBACKSLASH 0x2000 #endif #ifndef PERL_PV_ESCAPE_NOCLEAR # define PERL_PV_ESCAPE_NOCLEAR 0x4000 #endif #ifndef PERL_PV_ESCAPE_RE # define PERL_PV_ESCAPE_RE 0x8000 #endif #ifndef PERL_PV_PRETTY_NOCLEAR # define PERL_PV_PRETTY_NOCLEAR PERL_PV_ESCAPE_NOCLEAR #endif #ifndef PERL_PV_PRETTY_DUMP # define PERL_PV_PRETTY_DUMP PERL_PV_PRETTY_ELLIPSES|PERL_PV_PRETTY_QUOTE #endif #ifndef PERL_PV_PRETTY_REGPROP # define PERL_PV_PRETTY_REGPROP PERL_PV_PRETTY_ELLIPSES|PERL_PV_PRETTY_LTGT|PERL_PV_ESCAPE_RE #endif /* Hint: pv_escape * Note that unicode functionality is only backported to * those perl versions that support it. For older perl * versions, the implementation will fall back to bytes. */ #ifndef pv_escape #if defined(NEED_pv_escape) static char * DPPP_(my_pv_escape)(pTHX_ SV * dsv, char const * const str, const STRLEN count, const STRLEN max, STRLEN * const escaped, const U32 flags); static #else extern char * DPPP_(my_pv_escape)(pTHX_ SV * dsv, char const * const str, const STRLEN count, const STRLEN max, STRLEN * const escaped, const U32 flags); #endif #ifdef pv_escape # undef pv_escape #endif #define pv_escape(a,b,c,d,e,f) DPPP_(my_pv_escape)(aTHX_ a,b,c,d,e,f) #define Perl_pv_escape DPPP_(my_pv_escape) #if defined(NEED_pv_escape) || defined(NEED_pv_escape_GLOBAL) char * DPPP_(my_pv_escape)(pTHX_ SV *dsv, char const * const str, const STRLEN count, const STRLEN max, STRLEN * const escaped, const U32 flags) { const char esc = flags & PERL_PV_ESCAPE_RE ? '%' : '\\'; const char dq = flags & PERL_PV_ESCAPE_QUOTE ? '"' : esc; char octbuf[32] = "%123456789ABCDF"; STRLEN wrote = 0; STRLEN chsize = 0; STRLEN readsize = 1; #if defined(is_utf8_string) && defined(utf8_to_uvchr) bool isuni = flags & PERL_PV_ESCAPE_UNI ? 1 : 0; #endif const char *pv = str; const char * const end = pv + count; octbuf[0] = esc; if (!(flags & PERL_PV_ESCAPE_NOCLEAR)) sv_setpvs(dsv, ""); #if defined(is_utf8_string) && defined(utf8_to_uvchr) if ((flags & PERL_PV_ESCAPE_UNI_DETECT) && is_utf8_string((U8*)pv, count)) isuni = 1; #endif for (; pv < end && (!max || wrote < max) ; pv += readsize) { const UV u = #if defined(is_utf8_string) && defined(utf8_to_uvchr) isuni ? utf8_to_uvchr((U8*)pv, &readsize) : #endif (U8)*pv; const U8 c = (U8)u & 0xFF; if (u > 255 || (flags & PERL_PV_ESCAPE_ALL)) { if (flags & PERL_PV_ESCAPE_FIRSTCHAR) chsize = my_snprintf(octbuf, sizeof octbuf, "%"UVxf, u); else chsize = my_snprintf(octbuf, sizeof octbuf, "%cx{%"UVxf"}", esc, u); } else if (flags & PERL_PV_ESCAPE_NOBACKSLASH) { chsize = 1; } else { if (c == dq || c == esc || !isPRINT(c)) { chsize = 2; switch (c) { case '\\' : /* fallthrough */ case '%' : if (c == esc) octbuf[1] = esc; else chsize = 1; break; case '\v' : octbuf[1] = 'v'; break; case '\t' : octbuf[1] = 't'; break; case '\r' : octbuf[1] = 'r'; break; case '\n' : octbuf[1] = 'n'; break; case '\f' : octbuf[1] = 'f'; break; case '"' : if (dq == '"') octbuf[1] = '"'; else chsize = 1; break; default: chsize = my_snprintf(octbuf, sizeof octbuf, pv < end && isDIGIT((U8)*(pv+readsize)) ? "%c%03o" : "%c%o", esc, c); } } else { chsize = 1; } } if (max && wrote + chsize > max) { break; } else if (chsize > 1) { sv_catpvn(dsv, octbuf, chsize); wrote += chsize; } else { char tmp[2]; my_snprintf(tmp, sizeof tmp, "%c", c); sv_catpvn(dsv, tmp, 1); wrote++; } if (flags & PERL_PV_ESCAPE_FIRSTCHAR) break; } if (escaped != NULL) *escaped= pv - str; return SvPVX(dsv); } #endif #endif #ifndef pv_pretty #if defined(NEED_pv_pretty) static char * DPPP_(my_pv_pretty)(pTHX_ SV * dsv, char const * const str, const STRLEN count, const STRLEN max, char const * const start_color, char const * const end_color, const U32 flags); static #else extern char * DPPP_(my_pv_pretty)(pTHX_ SV * dsv, char const * const str, const STRLEN count, const STRLEN max, char const * const start_color, char const * const end_color, const U32 flags); #endif #ifdef pv_pretty # undef pv_pretty #endif #define pv_pretty(a,b,c,d,e,f,g) DPPP_(my_pv_pretty)(aTHX_ a,b,c,d,e,f,g) #define Perl_pv_pretty DPPP_(my_pv_pretty) #if defined(NEED_pv_pretty) || defined(NEED_pv_pretty_GLOBAL) char * DPPP_(my_pv_pretty)(pTHX_ SV *dsv, char const * const str, const STRLEN count, const STRLEN max, char const * const start_color, char const * const end_color, const U32 flags) { const U8 dq = (flags & PERL_PV_PRETTY_QUOTE) ? '"' : '%'; STRLEN escaped; if (!(flags & PERL_PV_PRETTY_NOCLEAR)) sv_setpvs(dsv, ""); if (dq == '"') sv_catpvs(dsv, "\""); else if (flags & PERL_PV_PRETTY_LTGT) sv_catpvs(dsv, "<"); if (start_color != NULL) sv_catpv(dsv, D_PPP_CONSTPV_ARG(start_color)); pv_escape(dsv, str, count, max, &escaped, flags | PERL_PV_ESCAPE_NOCLEAR); if (end_color != NULL) sv_catpv(dsv, D_PPP_CONSTPV_ARG(end_color)); if (dq == '"') sv_catpvs(dsv, "\""); else if (flags & PERL_PV_PRETTY_LTGT) sv_catpvs(dsv, ">"); if ((flags & PERL_PV_PRETTY_ELLIPSES) && escaped < count) sv_catpvs(dsv, "..."); return SvPVX(dsv); } #endif #endif #ifndef pv_display #if defined(NEED_pv_display) static char * DPPP_(my_pv_display)(pTHX_ SV * dsv, const char * pv, STRLEN cur, STRLEN len, STRLEN pvlim); static #else extern char * DPPP_(my_pv_display)(pTHX_ SV * dsv, const char * pv, STRLEN cur, STRLEN len, STRLEN pvlim); #endif #ifdef pv_display # undef pv_display #endif #define pv_display(a,b,c,d,e) DPPP_(my_pv_display)(aTHX_ a,b,c,d,e) #define Perl_pv_display DPPP_(my_pv_display) #if defined(NEED_pv_display) || defined(NEED_pv_display_GLOBAL) char * DPPP_(my_pv_display)(pTHX_ SV *dsv, const char *pv, STRLEN cur, STRLEN len, STRLEN pvlim) { pv_pretty(dsv, pv, cur, pvlim, NULL, NULL, PERL_PV_PRETTY_DUMP); if (len > cur && pv[cur] == '\0') sv_catpvs(dsv, "\\0"); return SvPVX(dsv); } #endif #endif #endif /* _P_P_PORTABILITY_H_ */ /* End of File ppport.h */ Math-Random-MT-Auto-6.23/MANIFEST0000644000175000001440000000123713377133764015635 0ustar jdheddenusersMANIFEST README Changes Makefile.PL lib/Math/Random/MT/Auto.pm lib/Math/Random/MT/Auto/Range.pm MRMA.xs ppport.h t/00-load.t t/01-mersenne.t t/02-gaussian.t t/03-threads.t t/04-win32.t t/05-dev_urandom.t t/06-dev_random.t t/07-random_org.t t/08-hotbits.t t/09-state.t t/10-deviates.t t/11-range.t t/12-rn_info.t t/13-overload.t t/14-serialize.t t/15-shared.t t/99-pod.t examples/timings.pl examples/bell.pl examples/decay.pl examples/erlang.pl examples/poisson.pl examples/binomial.pl examples/cards.pl META.yml Module YAML meta-data (added by MakeMaker) META.json Module JSON meta-data (added by MakeMaker) Math-Random-MT-Auto-6.23/lib/0000755000175000001440000000000013377133764015247 5ustar jdheddenusersMath-Random-MT-Auto-6.23/lib/Math/0000755000175000001440000000000013377133764016140 5ustar jdheddenusersMath-Random-MT-Auto-6.23/lib/Math/Random/0000755000175000001440000000000013377133764017360 5ustar jdheddenusersMath-Random-MT-Auto-6.23/lib/Math/Random/MT/0000755000175000001440000000000013377133764017700 5ustar jdheddenusersMath-Random-MT-Auto-6.23/lib/Math/Random/MT/Auto.pm0000644000175000001440000015004613377133756021155 0ustar jdheddenuserspackage Math::Random::MT::Auto; { require 5.006; use strict; use warnings; our $VERSION = '6.23'; my $XS_VERSION = $VERSION; $VERSION = eval $VERSION; require Carp; use Scalar::Util 1.18; require XSLoader; XSLoader::load('Math::Random::MT::Auto', $XS_VERSION); use Object::InsideOut 2.06 ':hash_only'; use Object::InsideOut::Util 'shared_copy'; # Exceptions thrown by this package use Exception::Class ( 'MRMA::Args' => { 'isa' => 'OIO::Args', 'description' => 'Math::Random::MT::Auto exception that indicates an argument error', }, ); ### Inside-out Object Attributes ### # Object data is stored in these attribute hashes, and is keyed to the object # by a unique ID that is stored in the object's scalar reference. For this # class, that ID is the address of the PRNG's internal memory. # # These hashes are declared using the 'Field' attribute. my %sources_for :Field; # Sources from which to obtain random seed data my %seed_for :Field; # Last seed sent to the PRNG # Seed source subroutine dispatch table my %DISPATCH = ( 'device' => \&_acq_device, 'random_org' => \&_acq_www, 'hotbits' => \&_acq_www, 'rn_info' => \&_acq_www, ); ### Module Initialization ### # Handle exportation of subroutine names, user-specified and default # seeding sources. Also, auto-seeding of the standalone PRNG. sub import { my $class = shift; # Not used # Exportable subroutines my %EXPORT_OK; @EXPORT_OK{qw(rand irand shuffle gaussian exponential erlang poisson binomial srand get_seed set_seed get_state set_state)} = undef; my $auto_seed = 1; # Flag to auto-seed the standalone PRNG # Handle entries in the import list my $caller = caller(); my @sources; while (my $sym = shift) { if (exists($EXPORT_OK{lc($sym)})) { # Export subroutine names no strict 'refs'; *{$caller.'::'.$sym} = \&{lc($sym)}; } elsif ($sym =~ /^:(no|!)?auto$/i) { # To auto-seed (:auto is default) or not (:!auto or :noauto) $auto_seed = not defined($1); } else { # User-specified seed acquisition sources # or user-defined seed acquisition subroutines push(@sources, $sym); # Add max. source count, if specified if (@_ && Scalar::Util::looks_like_number($_[0])) { push(@sources, shift); } } } # Setup default sources, if needed if (! @sources) { if (exists($DISPATCH{'win32'})) { push(@sources, 'win32'); } elsif (-e '/dev/urandom') { push(@sources, '/dev/urandom'); } elsif (-e '/dev/random') { push(@sources, '/dev/random'); } push(@sources, 'random_org'); } # Create standalone PRNG $MRMA::PRNG = Math::Random::MT::Auto->new( 'SOURCE' => \@sources, ($auto_seed) ? () : ( 'SEED' => [ $$, time(), Scalar::Util::refaddr(\$VERSION) ] ) ); } ### Dual-Interface (Functional and OO) Subroutines ### # # The subroutines below work both as regular 'functions' for the functional # interface to the standalone PRNG, as well as methods for the OO interface # to PRNG objects. # Starts PRNG with random seed using specified sources (if any) sub srand { # Generalize for both OO and standalone PRNGs my $obj = (Scalar::Util::blessed($_[0])) ? shift : $MRMA::PRNG; if (@_) { # If sent seed by mistake, then send it to set_seed() if (Scalar::Util::looks_like_number($_[0]) || ref($_[0]) eq 'ARRAY') { $obj->set_seed(@_); return; } # Save specified sources $sources_for{$$obj} = shared_copy(\@_); } # Acquire seed from sources _acquire_seed($obj); # Seed the PRNG _seed_prng($obj); } # Return ref to PRNG's saved seed (if any) sub get_seed { # Generalize for both OO and standalone PRNGs my $obj = (Scalar::Util::blessed($_[0])) ? shift : $MRMA::PRNG; if (wantarray()) { return (@{$seed_for{$$obj}}); } return ($seed_for{$$obj}); } # Apply supplied seed, if given, to the PRNG, sub set_seed { # Generalize for both OO and standalone PRNGs my $obj = (Scalar::Util::blessed($_[0])) ? shift : $MRMA::PRNG; # Check argument if (! @_) { MRMA::Args->throw('message' => q/Missing argument to '->set_seed()'/); } # Save a copy of the seed if (ref($_[0]) eq 'ARRAY') { $seed_for{$$obj} = shared_copy($_[0]); } else { $seed_for{$$obj} = shared_copy(\@_); } # Seed the PRNG _seed_prng($obj); } # Return copy of PRNG's current state sub get_state { # Generalize for both OO and standalone PRNGs my $obj = (Scalar::Util::blessed($_[0])) ? shift : $MRMA::PRNG; if (wantarray()) { return (@{Math::Random::MT::Auto::_::get_state($obj)}); } return (Math::Random::MT::Auto::_::get_state($obj)); } # Set PRNG to supplied state sub set_state { # Generalize for both OO and standalone PRNGs my $obj = (Scalar::Util::blessed($_[0])) ? shift : $MRMA::PRNG; # Input can be array ref or array if (ref($_[0]) eq 'ARRAY') { Math::Random::MT::Auto::_::set_state($obj, $_[0]); } else { Math::Random::MT::Auto::_::set_state($obj, \@_); } } ### Inside-out Object Internal Subroutines ### # Object Constructor sub _new_prng :ID { return (Math::Random::MT::Auto::_::new_prng()); } sub _clone_state :Replicate { my ($from_obj, $to_obj) = @_; my $state = Math::Random::MT::Auto::_::get_state($from_obj); Math::Random::MT::Auto::_::set_state($to_obj, $state); } sub _free_prng :Destroy { Math::Random::MT::Auto::_::free_prng(shift); } my %init_args :InitArgs = ( 'SOURCE' => { 'REGEX' => qr/^(?:source|src)s?$/i, 'FIELD' => \%sources_for, 'TYPE' => 'LIST', }, 'SEED' => { 'REGEX' => qr/^seed$/i, 'DEFAULT' => [], 'FIELD' => \%seed_for, 'TYPE' => 'LIST', }, 'STATE' => { 'REGEX' => qr/^state$/i, 'TYPE' => 'ARRAY', }, ); # Object initializer - for internal use only sub _init :Init { my $self = $_[0]; my $args = $_[1]; # Hash ref containing arguments from object # constructor as specified by %init_args above # If no sources specified, then use default sources from standalone PRNG if (! exists($sources_for{$$self})) { my @srcs = @{$sources_for{$$MRMA::PRNG}}; $self->set(\%sources_for, \@srcs); } # If state is specified, then use it if (exists($args->{'STATE'})) { $self->set_state($args->{'STATE'}); } else { # Acquire seed, if none provided if (! @{$seed_for{$$self}}) { _acquire_seed($self); } # Seed the PRNG _seed_prng($self); } } ### Overloading ### sub as_string :Stringify :Numerify { return ($_[0]->irand()); } sub bool :Boolify { return ($_[0]->irand() & 1); } sub array :Arrayify { my $self = $_[0]; my $count = $_[1] || 1; my @ary; do { push(@ary, $self->irand()); } while (--$count > 0); return (\@ary); } sub _code :Codify { my $self = $_[0]; return (sub { $self->irand(); }); } ### Serialization ### # Support for ->dump() method sub _dump :DUMPER { my $obj = shift; my @seed = @{$seed_for{$$obj}}; # Must filter out code refs from sources my @sources = grep { ref($_) ne 'CODE' } @{$sources_for{$$obj}}; my @state = $obj->get_state(); return ({ 'SOURCES' => \@sources, 'SEED' => \@seed, 'STATE' => \@state, }); } # Support for Object::InsideOut::pump() sub _pump :PUMPER { my ($obj, $data) = @_; $obj->set(\%sources_for, $$data{'SOURCES'}); $obj->set(\%seed_for, $$data{'SEED'}); $obj->set_state($$data{'STATE'}); } ### Internal Subroutines ### # Constants # # Size of Perl's integers (32- or 64-bit) and corresponding unpack code require Config; my $INT_SIZE = $Config::Config{'uvsize'}; my $UNPACK_CODE = ($INT_SIZE == 8) ? 'Q' : 'L'; # Number of ints for a full 19968-bit seed my $FULL_SEED = 2496 / $INT_SIZE; # If Windows XP and Win32::API, then make 'win32' a valid source if (($^O eq 'MSWin32') || ($^O eq 'cygwin')) { eval { require Win32; }; if (! $@) { my ($id, $major, $minor) = (Win32::GetOSVersion())[4,1,2]; if (defined($minor) && (($id > 2) || ($id == 2 && $major > 5) || ($id == 2 && $major == 5 && $minor >= 1))) { eval { # Suppress (harmless) warning about Win32::API::Type's INIT block local $SIG{__WARN__} = sub { if ($_[0] !~ /^Too late to run INIT block/) { print(STDERR "$_[0]\n"); # Output other warnings } }; require Win32::API; }; if (! $@) { $DISPATCH{'win32'} = \&_acq_win32; } } } } # Acquire seed data from specific sources sub _acquire_seed :PRIVATE { my $prng = $_[0]; my $sources = $sources_for{$$prng}; my $seed = $seed_for{$$prng}; # Acquire seed data until we have a full seed, # or until we run out of sources @{$seed} = (); for (my $ii=0; (@{$seed} < $FULL_SEED) && ($ii < @{$sources}); $ii++) { my $src = $sources->[$ii]; my $src_key = lc($src); # Suitable as hash key # Determine amount of data needed my $need = $FULL_SEED - @{$seed}; if (($ii+1 < @{$sources}) && Scalar::Util::looks_like_number($sources->[$ii+1])) { if ($sources->[++$ii] < $need) { $need = $sources->[$ii]; } } if (ref($src) eq 'CODE') { # User-supplied seeding subroutine $src->($seed, $need); } elsif (defined($DISPATCH{$src_key})) { # Module defined seeding source # Execute subroutine ref from dispatch table $DISPATCH{$src_key}->($src_key, $prng, $need); } elsif (-e $src) { # Random device or file $DISPATCH{'device'}->($src, $prng, $need); } else { Carp::carp("Unknown seeding source: $src"); } } if (! @{$seed}) { # Complain about not getting any seed data, and provide a minimal seed Carp::carp('No seed data obtained from sources - Setting minimal seed using PID and time'); push(@{$seed}, $$, time()); } elsif (@{$seed} < $FULL_SEED) { # Complain about not getting a full seed Carp::carp('Partial seed - only ' . scalar(@{$seed}) . ' of ' . $FULL_SEED); } } # Acquire seed data from a device/file sub _acq_device :PRIVATE { my $device = $_[0]; my $prng = $_[1]; my $need = $_[2]; # Try opening device/file my $FH; if (! open($FH, '<', $device)) { Carp::carp("Failure opening random device '$device': $!"); return; } binmode($FH); # Try to set non-blocking mode (but not on Windows and Haiku) if ($^O ne 'MSWin32' && $^O ne 'Haiku') { eval { require Fcntl; my $flags; $flags = fcntl($FH, &Fcntl::F_GETFL, 0) or die("Failed getting filehandle flags: $!\n"); fcntl($FH, &Fcntl::F_SETFL, $flags | &Fcntl::O_NONBLOCK) or die("Failed setting filehandle flags: $!\n"); }; if ($@) { Carp::carp("Failure setting non-blocking mode on random device '$device': $@"); } } # Read data for (1..$need) { my $data; my $cnt = read($FH, $data, $INT_SIZE); if (defined($cnt)) { # Complain if we didn't get all the data we asked for if ($cnt < $INT_SIZE) { Carp::carp("Random device '$device' exhausted"); } # Add data to seed array if ($cnt = int($cnt / $INT_SIZE)) { push(@{$seed_for{$$prng}}, unpack("$UNPACK_CODE$cnt", $data)); } } else { Carp::carp("Failure reading from random device '$device': $!"); } } close($FH); } # Cached LWP::UserAgent object my $LWP_UA; # Subroutine to acquire seed data from Internet sources sub _acq_www :PRIVATE { my $src = $_[0]; my $prng = $_[1]; my $need = $_[2]; # First, create user-agent object, if needed if (! $LWP_UA) { eval { require LWP::UserAgent; $LWP_UA = LWP::UserAgent->new('timeout' => 5, 'env_proxy' => 1); }; if ($@) { Carp::carp("Failure creating user-agent: $@"); return; } } ### Internal subroutines for processing Internet data # Process data from random.org my $random_org = sub { my $prng = $_[0]; my $content = $_[1]; # Add data to seed array push(@{$seed_for{$$prng}}, unpack("$UNPACK_CODE*", $content)); }; # Process data from HotBits my $hotbits = sub { my $prng = $_[0]; my $content = $_[1]; if ($content =~ /exceeded your 24-hour quota/) { # Complain about exceeding Hotbits quota Carp::carp('You have exceeded your 24-hour quota for HotBits.'); } else { # Add data to seed array push(@{$seed_for{$$prng}}, unpack("$UNPACK_CODE*", $content)); } }; # Process data from RandomNumbers.info my $rn_info = sub { my $prng = $_[0]; my $content = $_[1]; # Extract digits from web page my (@bytes) = $content =~ / ([\d]+)/g; # Make sure we have correct number of bytes for complete integers. # Also gets rid of copyright year that gets picked up from end of web page. do { pop(@bytes); } while (@bytes % $INT_SIZE); while (@bytes) { # Construct integers from bytes my $num = 0; for (1 .. $INT_SIZE) { $num = ($num << 8) + pop(@bytes); } # Add integer data to seed array push(@{$seed_for{$$prng}}, $num); } }; ### Internet seed source information table my %www = ( 'random_org' => { 'sitename' => 'random.org', 'URL' => 'http://www.random.org/cgi-bin/randbyte?nbytes=', 'max_bytes' => $FULL_SEED * $INT_SIZE, 'processor' => $random_org }, 'hotbits' => { 'sitename' => 'HotBits', 'URL' => 'http://www.fourmilab.ch/cgi-bin/uncgi/Hotbits?fmt=bin&nbytes=', 'max_bytes' => 2048, 'processor' => $hotbits }, 'rn_info' => { 'sitename' => 'RandomNumbers.info', 'URL' => 'http://www.randomnumbers.info/cgibin/wqrng.cgi?limit=255&amount=', 'max_bytes' => 1000, 'processor' => $rn_info } ); # Number of bytes to request (observing maximum data limit) my $bytes = $need * $INT_SIZE; if ($bytes > $www{$src}{'max_bytes'}) { $bytes = $www{$src}{'max_bytes'}; } # Request the data my $res; eval { # Create request my $req = HTTP::Request->new('GET' => $www{$src}{'URL'} . $bytes); # Send the request $res = $LWP_UA->request($req); }; # Handle the response if ($@) { Carp::carp("Failure contacting $www{$src}{'sitename'}: $@"); } elsif ($res->is_success) { # Process the data $www{$src}{'processor'}->($prng, $res->content); } else { Carp::carp("Failure getting data from $www{$src}{'sitename'}: " . $res->status_line); } } # Acquire seed data from Win XP random source sub _acq_win32 :PRIVATE { my $src = $_[0]; # Not used my $prng = $_[1]; my $need = $_[2]; my $bytes = $need * $INT_SIZE; eval { # Import the random source function my $func = Win32::API->new('ADVAPI32.DLL', 'SystemFunction036', 'PN', 'I'); if (! defined($func)) { die("Failure importing 'SystemFunction036': $!\n"); } # Acquire the random data my $buffer = chr(0) x $bytes; if (! $func->Call($buffer, $bytes)) { die("'SystemFunction036' failed: $^E\n"); } # Add data to seed array push(@{$seed_for{$$prng}}, unpack("$UNPACK_CODE*", $buffer)); }; if ($@) { Carp::carp("Failure acquiring Win XP random data: $@"); } } # Seeds a PRNG sub _seed_prng :PRIVATE { my $prng = $_[0]; my $seed = $seed_for{$$prng}; # Get the seed for the PRNG if ($Config::Config{'useithreads'} && $threads::shared::threads_shared && threads::shared::_id($seed)) { # If the seed is thread-shared, then must make a non-shared copy to # send to the PRNG my @seed = @{$seed}; Math::Random::MT::Auto::_::seed_prng($prng, \@seed); } else { # If no thread object sharing, then just send the seed Math::Random::MT::Auto::_::seed_prng($prng, $seed); } } } # End of package's lexical scope 1; __END__ =head1 NAME Math::Random::MT::Auto - Auto-seeded Mersenne Twister PRNGs =head1 VERSION This documentation refers to Math::Random::MT::Auto version 6.23 =head1 SYNOPSIS use strict; use warnings; use Math::Random::MT::Auto qw(rand irand shuffle gaussian), '/dev/urandom' => 256, 'random_org'; # Functional interface my $die_roll = 1 + int(rand(6)); my $coin_flip = (irand() & 1) ? 'heads' : 'tails'; my @deck = shuffle(1 .. 52); my $rand_IQ = gaussian(15, 100); # OO interface my $prng = Math::Random::MT::Auto->new('SOURCE' => '/dev/random'); my $angle = $prng->rand(360); my $decay_interval = $prng->exponential(12.4); =head1 DESCRIPTION The Mersenne Twister is a fast pseudorandom number generator (PRNG) that is capable of providing large volumes (> 10^6004) of "high quality" pseudorandom data to applications that may exhaust available "truly" random data sources or system-provided PRNGs such as L. This module provides PRNGs that are based on the Mersenne Twister. There is a functional interface to a single, standalone PRNG, and an OO interface (based on the inside-out object model as implemented by the L module) for generating multiple PRNG objects. The PRNGs are normally self-seeding, automatically acquiring a (19968-bit) random seed from user-selectable sources. (I seeding is optionally available.) =over =item Random Number Deviates In addition to integer and floating-point uniformly-distributed random number deviates (i.e., L<"irand"> and L<"rand">), this module implements the following non-uniform deviates as found in I: =over =over =item * Gaussian (normal) =item * Exponential =item * Erlang (gamma of integer order) =item * Poisson =item * Binomial =back =back =item Shuffling This module also provides a subroutine/method for shuffling data based on the Fisher-Yates shuffling algorithm. =item Support for 64-bit Integers If Perl has been compiled to support 64-bit integers (do L and look for C), then this module will use a 64-bit-integer version of the Mersenne Twister, thus providing 64-bit random integers and 52-bit random doubles. The size of integers returned by L, and used by L and L will be sized accordingly. Programmatically, the size of Perl's integers can be determined using the C module: use Config; print("Integers are $Config{'uvsize'} bytes in length\n"); =back The code for this module has been optimized for speed. Under Cygwin, it's 2.5 times faster than Math::Random::MT, and under Solaris, it's more than four times faster. (Math::Random::MT fails to build under Windows.) =head1 QUICKSTART To use this module as a drop-in replacement for Perl's built-in L function, just add the following to the top of your application code: use strict; use warnings; use Math::Random::MT::Auto 'rand'; and then just use L as you would normally. You don't even need to bother seeding the PRNG (i.e., you don't need to call L), as that gets done automatically when the module is loaded by Perl. If you need multiple PRNGs, then use the OO interface: use strict; use warnings; use Math::Random::MT::Auto; my $prng1 = Math::Random::MT::Auto->new(); my $prng2 = Math::Random::MT::Auto->new(); my $rand_num = $prng1->rand(); my $rand_int = $prng2->irand(); B: If you want to L this module, see the L section for important information. =head1 MODULE DECLARATION The module must always be declared such that its C<-Eimport()> method gets called: use Math::Random::MT::Auto; # Correct #use Math::Random::MT::Auto (); # Does not work because # ->import() does not get invoked =head2 Subroutine Declarations By default, this module does not automatically export any of its subroutines. If you want to use the standalone PRNG, then you should specify the subroutines you want to use when you declare the module: use Math::Random::MT::Auto qw(rand irand shuffle gaussian exponential erlang poisson binomial srand get_seed set_seed get_state set_state); Without the above declarations, it is still possible to use the standalone PRNG by accessing the subroutines using their fully-qualified names. For example: my $rand = Math::Random::MT::Auto::rand(); =head2 Module Options =over =item Seeding Sources Starting the PRNGs with a 19968-bit random seed (312 64-bit integers or 624 32-bit integers) takes advantage of their full range of possible internal vectors states. This module attempts to acquire such seeds using several user-selectable sources. (I would be interested to hear about other random data sources for possible inclusion in future versions of this module.) =over =item Random Devices Most OSs offer some sort of device for acquiring random numbers. The most common are F and F. You can specify the use of these devices for acquiring the seed for the PRNG when you declare this module: use Math::Random::MT::Auto '/dev/urandom'; # or my $prng = Math::Random::MT::Auto->new('SOURCE' => '/dev/random'); or they can be specified when using L. srand('/dev/random'); # or $prng->srand('/dev/urandom'); The devices are accessed in I mode so that if there is insufficient data when they are read, the application will not hang waiting for more. =item File of Binary Data Since the above devices are just files as far as Perl is concerned, you can also use random data previously stored in files (in binary format). srand('C:\\Temp\\RANDOM.DAT'); # or $prng->srand('/tmp/random.dat'); =item Internet Sites This module provides support for acquiring seed data from several Internet sites: random.org, HotBits and RandomNumbers.info. An Internet connection and L are required to utilize these sources. use Math::Random::MT::Auto 'random_org'; # or use Math::Random::MT::Auto 'hotbits'; # or use Math::Random::MT::Auto 'rn_info'; If you connect to the Internet through an HTTP proxy, then you must set the L variable in your environment when using these sources. (See L.) The HotBits site will only provide a maximum of 2048 bytes of data per request, and RandomNumbers.info's maximum is 1000. If you want to get the full seed from these sites, then you can specify the source multiple times: my $prng = Math::Random::MT::Auto->new('SOURCE' => ['hotbits', 'hotbits']); or specify multiple sources: use Math::Random::MT::Auto qw(rn_info hotbits random_org); =item Windows XP Random Data Under MSWin32 or Cygwin on Windows XP, you can acquire random seed data from the system. use Math::Random::MT::Auto 'win32'; To utilize this option, you must have the L module installed. =item User-defined Seeding Source A subroutine reference may be specified as a seeding source. When called, it will be passed three arguments: A array reference where seed data is to be added, and the number of integers (64- or 32-bit as the case may be) needed. sub MySeeder { my $seed = $_[0]; my $need = $_[1]; while ($need--) { my $data = ...; # Get seed data from your source ... push(@{$seed}, $data); } } my $prng = Math::Random::MT::Auto->new('SOURCE' => \&MySeeder); =back The default list of seeding sources is determined when the module is loaded. Under MSWin32 or Cygwin on Windows XP, C is added to the list if L is available. Otherwise, F and then F are checked. The first one found is added to the list. Finally, C is added. For the functional interface to the standalone PRNG, these defaults can be overridden by specifying the desired sources when the module is declared, or through the use of the L subroutine. Similarly for the OO interface, they can be overridden in the L<-Enew()|/"Math::Random::MT::Auto-Enew"> method when the PRNG is created, or later using the L method. Optionally, the maximum number of integers (64- or 32-bits as the case may be) to be acquired from a particular source may be specified: # Get at most 1024 bytes from random.org # Finish the seed using data from /dev/urandom use Math::Random::MT::Auto 'random_org' => (1024 / $Config{'uvsize'}), '/dev/urandom'; =item Delayed Seeding Normally, the standalone PRNG is automatically seeded when the module is loaded. This behavior can be modified by supplying the C<:!auto> (or C<:noauto>) flag when the module is declared. (The PRNG will still be seeded using data such as L and PID (L<$$|perlvar/"$$">), just in case.) When the C<:!auto> option is used, the L subroutine should be imported, and then run before calling any of the random number deviates. use Math::Random::MT::Auto qw(rand srand :!auto); ... srand(); ... my $rn = rand(10); =back =head2 Delayed Importation If you want to delay the importation of this module using L, then you must execute its C<-Eimport()> method to complete the module's initialization: eval { require Math::Random::MT::Auto; # You may add options to the import call, if desired. Math::Random::MT::Auto->import(); }; =head1 STANDALONE PRNG OBJECT =over =item my $obj = $MRMA::PRNG; C<$MRMA::PRNG> is the object that represents the standalone PRNG. =back =head1 OBJECT CREATION The OO interface for this module allows you to create multiple, independent PRNGs. If your application will only be using the OO interface, then declare this module using the L<:!auto|/"Delayed Seeding"> flag to forestall the automatic seeding of the standalone PRNG: use Math::Random::MT::Auto ':!auto'; =over =item Math::Random::MT::Auto->new my $prng = Math::Random::MT::Auto->new( %options ); Creates a new PRNG. With no options, the PRNG is seeded using the default sources that were determined when the module was loaded, or that were last supplied to the L subroutine. =over =item 'STATE' => $prng_state Sets the newly created PRNG to the specified state. The PRNG will then function as a clone of the RPNG that the state was obtained from (at the point when then state was obtained). When the C option is used, any other options are just stored (i.e., they are not acted upon). =item 'SEED' => $seed_array_ref When the C option is not used, this option seeds the newly created PRNG using the supplied seed data. Otherwise, the seed data is just copied to the new object. =item 'SOURCE' => 'source' =item 'SOURCE' => ['source', ...] Specifies the seeding source(s) for the PRNG. If the C and C options are not used, then seed data will be immediately fetched using the specified sources, and used to seed the PRNG. The source list is retained for later use by the L method. The source list may be replaced by calling the L method. 'SOURCES', 'SRC' and 'SRCS' can all be used as synonyms for 'SOURCE'. =back The options above are also supported using lowercase and mixed-case names (e.g., 'Seed', 'src', etc.). =item $obj->new my $prng2 = $prng1->new( %options ); Creates a new PRNG in the same manner as Lnew">. =item $obj->clone my $prng2 = $prng1->clone(); Creates a new PRNG that is a copy of the referenced PRNG. =back =head1 SUBROUTINES/METHODS When any of the I listed below are invoked as subroutines, they operates with respect to the standalone PRNG. For example: my $rand = rand(); When invoked as methods, they operate on the referenced PRNG object: my $rand = $prng->rand(); For brevity, only usage examples for the functional interface are given below. =over =item rand my $rn = rand(); my $rn = rand($num); Behaves exactly like Perl's built-in L, returning a number uniformly distributed in [0, $num). ($num defaults to 1.) NOTE: If you still need to access Perl's built-in L function, you can do so using C. =item irand my $int = irand(); Returns a random integer. For 32-bit integer Perl, the range is 0 to 2^32-1 (0xFFFFFFFF) inclusive. For 64-bit integer Perl, it's 0 to 2^64-1 inclusive. This is the fastest way to obtain random numbers using this module. =item shuffle my @shuffled = shuffle($data, ...); my @shuffled = shuffle(@data); Returns an array of the random ordering of the supplied arguments (i.e., shuffled) by using the Fisher-Yates shuffling algorithm. It can also be called to return an array reference: my $shuffled = shuffle($data, ...); my $shuffled = shuffle(@data); If called with a single array reference (fastest method), the contents of the array are shuffled in situ: shuffle(\@data); =item gaussian my $gn = gaussian(); my $gn = gaussian($sd); my $gn = gaussian($sd, $mean); Returns floating-point random numbers from a Gaussian (normal) distribution (i.e., numbers that fit a bell curve). If called with no arguments, the distribution uses a standard deviation of 1, and a mean of 0. Otherwise, the supplied argument(s) will be used for the standard deviation, and the mean. =item exponential my $xn = exponential(); my $xn = exponential($mean); Returns floating-point random numbers from an exponential distribution. If called with no arguments, the distribution uses a mean of 1. Otherwise, the supplied argument will be used for the mean. An example of an exponential distribution is the time interval between independent Poisson-random events such as radioactive decay. In this case, the mean is the average time between events. This is called the I for radioactive decay, and its inverse is the decay constant (which represents the expected number of events per unit time). The well known term I is given by C. =item erlang my $en = erlang($order); my $en = erlang($order, $mean); Returns floating-point random numbers from an Erlang distribution of specified order. The order must be a positive integer (> 0). The mean, if not specified, defaults to 1. The Erlang distribution is the distribution of the sum of C<$order> independent identically distributed random variables each having an exponential distribution. (It is a special case of the gamma distribution for which C<$order> is a positive integer.) When C<$order = 1>, it is just the exponential distribution. It is named after A. K. Erlang who developed it to predict waiting times in queuing systems. =item poisson my $pn = poisson($mean); my $pn = poisson($rate, $time); Returns integer random numbers (>= 0) from a Poisson distribution of specified mean (rate * time = mean). The mean must be a positive value (> 0). The Poisson distribution predicts the probability of the number of Poisson-random events occurring in a fixed time if these events occur with a known average rate. Examples of events that can be modeled as Poisson distributions include: =over =over =item * The number of decays from a radioactive sample within a given time period. =item * The number of cars that pass a certain point on a road within a given time period. =item * The number of phone calls to a call center per minute. =item * The number of road kill found per a given length of road. =back =back =item binomial my $bn = binomial($prob, $trials); Returns integer random numbers (>= 0) from a binomial distribution. The probability (C<$prob>) must be between 0.0 and 1.0 (inclusive), and the number of trials must be >= 0. The binomial distribution is the discrete probability distribution of the number of successes in a sequence of C<$trials> independent Bernoulli trials (i.e., yes/no experiments), each of which yields success with probability C<$prob>. If the number of trials is very large, the binomial distribution may be approximated by a Gaussian distribution. If the average number of successes is small (C<$prob * $trials < 1>), then the binomial distribution can be approximated by a Poisson distribution. =item srand srand(); srand('source', ...); This (re)seeds the PRNG. It may be called anytime reseeding of the PRNG is desired (although this should normally not be needed). When the L<:!auto|/"Delayed Seeding"> flag is used, the C subroutine should be called before any other access to the standalone PRNG. When called without arguments, the previously determined/specified seeding source(s) will be used to seed the PRNG. Optionally, seeding sources may be supplied as arguments as when using the L<'SOURCE'|/"Seeding Sources"> option. (These sources will be saved and used again if C is subsequently called without arguments). # Get 250 integers of seed data from Hotbits, # and then get the rest from /dev/random srand('hotbits' => 250, '/dev/random'); If called with integer data (a list of one or more value, or an array of values), or a reference to an array of integers, these data will be passed to L for use in reseeding the PRNG. NOTE: If you still need to access Perl's built-in L function, you can do so using C. =item get_seed my @seed = get_seed(); # or my $seed = get_seed(); Returns an array or an array reference containing the seed last sent to the PRNG. NOTE: Changing the data in the array will not cause any changes in the PRNG (i.e., it will not reseed it). You need to use L or L for that. =item set_seed set_seed($seed, ...); set_seed(@seed); set_seed(\@seed); When called with integer data (a list of one or more value, or an array of values), or a reference to an array of integers, these data will be used to reseed the PRNG. Together with L, C may be useful for setting up identical sequences of random numbers based on the same seed. It is possible to seed the PRNG with more than 19968 bits of data (312 64-bit integers or 624 32-bit integers). However, doing so does not make the PRNG "more random" as 19968 bits more than covers all the possible PRNG state vectors. =item get_state my @state = get_state(); # or my $state = get_state(); Returns an array (for list context) or an array reference (for scalar context) containing the current state vector of the PRNG. Note that the state vector is not a full serialization of the PRNG. (See L below.) =item set_state set_state(@state); # or set_state($state); Sets a PRNG to the state contained in an array or array reference containing the state previously obtained using L. # Get the current state of the PRNG my @state = get_state(); # Run the PRNG some more my $rand1 = irand(); # Restore the previous state of the PRNG set_state(@state); # Get another random number my $rand2 = irand(); # $rand1 and $rand2 will be equal. B: It should go without saying that you should not modify the values in the state vector obtained from L. Doing so and then feeding it to L would be (to say the least) naughty. =back =head1 INSIDE-OUT OBJECTS By using L, Math::Random::MT::Auto's PRNG objects support the following capabilities: =head2 Cloning Copies of PRNG objects can be created using the C<-Eclone()> method. my $prng2 = $prng->clone(); See L for more details. =head2 Serialization PRNG objects can be serialized using the C<-Edump()> method. my $array_ref = $prng->dump(); # or my $string = $prng->dump(1); Serialized object can then be converted back into PRNG objects: my $prng2 = Object::InsideOut->pump($array_ref); See L for more details. Serialization using L is also supported: use Storable qw(freeze thaw); BEGIN { $Math::Random::MT::Auto::storable = 1; } use Math::Random::MT::Auto ...; my $prng = Math::Random::MT::Auto->new(); my $tmp = $prng->freeze(); my $prng2 = thaw($tmp); See L for more details. B Code refs cannot be serialized. Therefore, any L subroutines used in conjunction with L will be filtered out from the serialized results. =head2 Coercion Various forms of object coercion are supported through the L mechanism. For instance, you can to use a PRNG object directly in a string: my $prng = Math::Random::MT::Auto->new(); print("Here's a random integer: $prng\n"); The I of the PRNG object is accomplished by calling C<-Eirand()> on the object, and returning the integer so obtained as the I result. A similar overload coercion is performed when the object is used in a numeric context: my $neg_rand = 0 - $prng; (See L regarding numeric overloading on 64-bit integer Perls prior to 5.10.) In a boolean context, the coercion returns true or false based on whether the call to C<-Eirand()> returns an odd or even result: if ($prng) { print("Heads - I win!\n"); } else { print("Tails - You lose.\n"); } In an array context, the coercion returns a single integer result: my @rands = @{$prng}; This may not be all that useful, so you can call the C<-Earray()> method directly with a integer argument for the number of random integers you'd like: # Get 20 random integers my @rands = @{$prng->array(20)}; Finally, a PRNG object can be used to produce a code reference that will return random integers each time it is invoked: my $rand = \&{$prng}; my $int = &$rand; See L for more details. =head2 Thread Support Math::Random::MT::Auto provides thread support to the extent documented in L. In a threaded application (i.e., C), the standalone PRNG and all the PRNG objects from one thread will be copied and made available in a child thread. To enable the sharing of PRNG objects between threads, do the following in your application: use threads; use threads::shared; BEGIN { $Math::Random::MT::Auto::shared = 1; } use Math::Random::MT::Auto ...; B Code refs cannot be shared between threads. Therefore, you cannot use L subroutines in conjunction with L when C is in effect. Depending on your needs, when using threads, but not enabling thread-sharing of PRNG objects as per the above, you may want to perform an C call on the standalone PRNG and/or your PRNG objects inside the threaded code so that the pseudorandom number sequences generated in each thread differs. use threads; use Math::Random:MT::Auto qw(irand srand); my $prng = Math::Random:MT::Auto->new(); sub thr_code { srand(); $prng->srand(); .... } =head1 EXAMPLES =over =item Cloning the standalone PRNG to an object use Math::Random::MT::Auto qw(get_state); my $prng = Math::Random::MT::Auto->new('STATE' => scalar(get_state())); or using the standalone PRNG object directly: my $prng = $Math::Random::MT::Auto::SA_PRNG->clone(); The standalone PRNG and the PRNG object will now return the same sequence of pseudorandom numbers. =back Included in this module's distribution are several sample programs (located in the F sub-directory) that illustrate the use of the various random number deviates and other features supported by this module. =head1 DIAGNOSTICS =head2 WARNINGS Warnings are generated by this module primarily when problems are encountered while trying to obtain random seed data for the PRNGs. This may occur after the module is loaded, after a PRNG object is created, or after calling L. These seed warnings are not critical in nature. The PRNG will still be seeded (at a minimum using data such as L and PID (L<$$|perlvar/"$$">)), and can be used safely. The following illustrates how such warnings can be trapped for programmatic handling: my @WARNINGS; BEGIN { $SIG{__WARN__} = sub { push(@WARNINGS, @_); }; } use Math::Random::MT::Auto; # Check for standalone PRNG warnings if (@WARNINGS) { # Handle warnings as desired ... # Clear warnings undef(@WARNINGS); } my $prng = Math::Random::MT::Auto->new(); # Check for PRNG object warnings if (@WARNINGS) { # Handle warnings as desired ... # Clear warnings undef(@WARNINGS); } =over =item * Failure opening random device '...': ... The specified device (e.g., /dev/random) could not be opened by the module. Further diagnostic information should be included with this warning message (e.g., device does not exist, permission problem, etc.). =item * Failure setting non-blocking mode on random device '...': ... The specified device could not be set to I mode. Further diagnostic information should be included with this warning message (e.g., permission problem, etc.). =item * Failure reading from random device '...': ... A problem occurred while trying to read from the specified device. Further diagnostic information should be included with this warning message. =item * Random device '...' exhausted The specified device did not supply the requested number of random numbers for the seed. It could possibly occur if F is used too frequently. It will occur if the specified device is a file, and it does not have enough data in it. =item * Failure creating user-agent: ... To utilize the option of acquiring seed data from Internet sources, you need to install the L module. =item * Failure contacting XXX: ... =item * Failure getting data from XXX: 500 Can't connect to ... (connect: timeout) You need to have an Internet connection to utilize L as random seed sources. If you connect to the Internet through an HTTP proxy, then you must set the L variable in your environment when using the Internet seed sources. (See L.) This module sets a 5 second timeout for Internet connections so that if something goes awry when trying to get seed data from an Internet source, your application will not hang for an inordinate amount of time. =item * You have exceeded your 24-hour quota for HotBits. The L site has a quota on the amount of data you can request in a 24-hour period. (I don't know how big the quota is.) Therefore, this source may fail to provide any data if used too often. =item * Failure acquiring Win XP random data: ... A problem occurred while trying to acquire seed data from the Window XP random source. Further diagnostic information should be included with this warning message. =item * Unknown seeding source: ... The specified seeding source is not recognized by this module. This error also occurs if you try to use the L random data source on something other than MSWin32 or Cygwin on Windows XP. See L for more information. =item * No seed data obtained from sources - Setting minimal seed using PID and time This message will occur in combination with some other message(s) above. If the module cannot acquire any seed data from the specified sources, then data such as L and PID (L<$$|perlvar/"$$">) will be used to seed the PRNG. =item * Partial seed - only X of Y This message will occur in combination with some other message(s) above. It informs you of how much seed data was acquired vs. how much was needed. =back =head2 ERRORS This module uses C for reporting errors. The base error class provided by L is C. Here is an example of the basic manner for trapping and handling errors: my $obj; eval { $obj = Math::Random::MT::Auto->new(); }; if (my $e = OIO->caught()) { print(STDERR "Failure creating new PRNG: $e\n"); exit(1); } Errors specific to this module have a base class of C, and have the following error messages: =over =item * Missing argument to 'set_seed' L must be called with an array ref, or a list of integer seed data. =item * Invalid state vector L was called with an incompatible state vector. For example, a state vector from a 32-bit integer version of Perl being used with a 64-bit integer version of Perl. =back =head1 PERFORMANCE Under Cygwin, this module is 2.5 times faster than Math::Random::MT, and under Solaris, it's more than four times faster. (Math::Random::MT fails to build under Windows.) The file F, included in this module's distribution, can be used to compare timing results. If you connect to the Internet via a phone modem, acquiring seed data may take a second or so. This delay might be apparent when your application is first started, or when creating a new PRNG object. This is especially true if you specify multiple L (so as to get the full seed from them) as this results in multiple accesses to the Internet. (If F is available on your machine, then you should definitely consider using the Internet sources only as a secondary source.) =head1 DEPENDENCIES =head2 Installation A 'C' compiler is required for building this module. This module uses the following 'standard' modules for installation: =over =over =item ExtUtils::MakeMaker =item File::Spec =item Test::More =back =back =head2 Operation Requires Perl 5.6.0 or later. This module uses the following 'standard' modules: =over =over =item Scalar::Util (1.18 or later) =item Carp =item Fcntl =item XSLoader =back =back This module uses the following modules available through CPAN: =over =over =item Object::InsideOut (2.06 or later) =item Exception::Class (1.22 or later) =back =back To utilize the option of acquiring seed data from Internet sources, you need to install the L module. To utilize the option of acquiring seed data from the system's random data source under MSWin32 or Cygwin on Windows XP, you need to install the L module. =head1 BUGS AND LIMITATIONS This module does not support multiple inheritance. For Perl prior to 5.10, there is a bug in the L code associated with 64-bit integers that causes the integer returned by the C<-Eirand()> call to be coerced into a floating-point number. The workaround in this case is to call C<-Eirand()> directly: # my $neg_rand = 0 - $prng; # Result is a floating-point number my $neg_rand = 0 - $prng->irand(); # Result is an integer number The transfer of state vector arrays and serialized objects between 32- and 64-bit integer versions of Perl is not supported, and will produce an 'Invalid state vector' error. Please submit any bugs, problems, suggestions, patches, etc. to: L =head1 SEE ALSO Math::Random::MT::Auto on MetaCPAN: L Code repository: L Sample code in the I directory of this distribution on CPAN. The Mersenne Twister is the (current) quintessential pseudorandom number generator. It is fast, and has a period of 2^19937 - 1. The Mersenne Twister algorithm was developed by Makoto Matsumoto and Takuji Nishimura. It is available in 32- and 64-bit integer versions. L Wikipedia entries on the Mersenne Twister and pseudorandom number generators, in general: L, and L random.org generates random numbers from radio frequency noise. L HotBits generates random number from a radioactive decay source. L RandomNumbers.info generates random number from a quantum optical source. L OpenBSD random devices: L FreeBSD random devices: L Man pages for F and F on Unix/Linux/Cygwin/Solaris: L Windows XP random data source: L Fisher-Yates Shuffling Algorithm: L, and L Non-uniform random number deviates in I, Chapters 7.2 and 7.3: L Inside-out Object Model: L L - Subclass of Math::Random::MT::Auto that creates range-valued PRNGs L L L =head1 AUTHOR Jerry D. Hedden, Sjdhedden AT cpan DOT orgE> =head1 COPYRIGHT AND LICENSE A C-Program for MT19937 (32- and 64-bit versions), with initialization improved 2002/1/26. Coded by Takuji Nishimura and Makoto Matsumoto, and including Shawn Cokus's optimizations. Copyright (C) 1997 - 2004, Makoto Matsumoto and Takuji Nishimura, All rights reserved. Copyright (C) 2005, Mutsuo Saito, All rights reserved. Copyright 2005 - 2009 Jerry D. Hedden Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. The names of its contributors may not be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. Any feedback is very welcome. m-mat AT math DOT sci DOT hiroshima-u DOT ac DOT jp http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/emt.html =cut Math-Random-MT-Auto-6.23/lib/Math/Random/MT/Auto/0000755000175000001440000000000013377133764020610 5ustar jdheddenusersMath-Random-MT-Auto-6.23/lib/Math/Random/MT/Auto/Range.pm0000644000175000001440000002347213377133756022213 0ustar jdheddenuserspackage Math::Random::MT::Auto::Range; { use strict; use warnings; our $VERSION = '6.23'; $VERSION = eval $VERSION; use Scalar::Util 1.18; # Declare ourself as a subclass use Object::InsideOut 'Math::Random::MT::Auto' => [ ':!auto' ]; ### Inside-out Object Attributes ### # Object data is stored in these attribute hashes, and is keyed to the object # by a unique ID that is stored in the object's scalar reference. # # These hashes are declared using the 'Field' attribute. # Range information for our objects my %type_of :Field; # Type of return value: INTEGER or DOUBLE my %low_for :Field; # Low end of the range my %high_for :Field; # High end of the range my %range_for :Field; # 'Difference' between LOW and HIGH # (used for performance considerations) ### Inside-out Object Internal Subroutines ### my %init_args :InitArgs = ( 'LOW' => { 'REGEX' => qr/^lo(?:w)?$/i, 'MANDATORY' => 1, 'TYPE' => 'NUMBER', }, 'HIGH' => { 'REGEX' => qr/^hi(?:gh)?$/i, 'MANDATORY' => 1, 'TYPE' => 'NUMBER', }, 'TYPE' => qr/^type$/i, # Range type ); # Object initializer sub _init :Init { my $self = $_[0]; my $args = $_[1]; # Hash ref containing arguments from object # constructor as specified by %init_args above # Default 'TYPE' to 'INTEGER' if 'LOW' and 'HIGH' are both integers. # Otherwise, default to 'DOUBLE'. if (! exists($$args{'TYPE'})) { my $lo = $$args{'LOW'}; my $hi = $$args{'HIGH'}; $$args{'TYPE'} = (($lo == int($lo)) && ($hi == int($hi))) ? 'INTEGER' : 'DOUBLE'; } # Initialize object $self->set_range_type($$args{'TYPE'}); $self->set_range($$args{'LOW'}, $$args{'HIGH'}); } ### Object Methods ### # Sets numeric type random values sub set_range_type { my $self = shift; # Check argument my $type = $_[0]; if (! defined($type) || $type !~ /^[ID]/i) { MRMA::Args->die( 'caller_level' => (caller() eq __PACKAGE__) ? 2 : 0, 'message' => "Bad range type: $type", 'Usage' => q/Range type must be 'INTEGER' or 'DOUBLE'/); } $type_of{$$self} = ($type =~ /^I/i) ? 'INTEGER' : 'DOUBLE'; } # Return current range type sub get_range_type { my $self = shift; return ($type_of{$$self}); } # Set random number range sub set_range { my $self = shift; # Check for arguments my ($lo, $hi) = @_; if (! Scalar::Util::looks_like_number($lo) || ! Scalar::Util::looks_like_number($hi)) { MRMA::Args->die( 'message' => q/Bad range arguments/, 'Usage' => q/Range must be specified using 2 numeric arguments/); } # Ensure arguments are of the proper type if ($type_of{$$self} eq 'INTEGER') { $lo = int($lo); $hi = int($hi); } else { $lo = 0.0 + $lo; $hi = 0.0 + $hi; } # Make sure 'LOW' and 'HIGH' are not the same if ($lo == $hi) { MRMA::Args->die( 'caller_level' => (caller() eq __PACKAGE__) ? 2 : 0, 'message' => q/Invalid arguments: LOW and HIGH are equal/, 'Usage' => q/The range must be a non-zero interval/); } # Ensure LOW < HIGH if ($lo > $hi) { ($lo, $hi) = ($hi, $lo); } # Set range parameters $low_for{$$self} = $lo; $high_for{$$self} = $hi; if ($type_of{$$self} eq 'INTEGER') { $range_for{$$self} = ($high_for{$$self} - $low_for{$$self}) + 1; } else { $range_for{$$self} = $high_for{$$self} - $low_for{$$self}; } } # Return object's random number range sub get_range { my $self = shift; return ($low_for{$$self}, $high_for{$$self}); } # Return a random number of the configured type and within the configured # range. sub rrand { my $self = $_[0]; if ($type_of{$$self} eq 'INTEGER') { # Integer random number range [LOW, HIGH] return (($self->irand() % $range_for{$$self}) + $low_for{$$self}); } else { # Floating-point random number range [LOW, HIGH) return ($self->rand($range_for{$$self}) + $low_for{$$self}); } } ### Overloading ### sub as_string :Stringify :Numerify { return ($_[0]->rrand()); } sub bool :Boolify { return ($_[0]->rrand() & 1); } sub array :Arrayify { my $self = $_[0]; my $count = $_[1] || 1; my @ary; do { push(@ary, $self->rrand()); } while (--$count > 0); return (\@ary); } sub _code :Codify { my $self = $_[0]; return (sub { $self->rrand(); }); } ### Serialization ### # Support for ->dump() method sub _dump :Dumper { my $obj = shift; return ({ 'HIGH' => $high_for{$$obj}, 'LOW' => $low_for{$$obj}, 'TYPE' => $type_of{$$obj} }); } # Support for Object::InsideOut::pump() sub _pump :Pumper { my ($obj, $data) = @_; $obj->set_range_type($$data{'TYPE'}); $obj->set_range($$data{'LOW'}, $$data{'HIGH'}); } } # End of package's lexical scope 1; __END__ =head1 NAME Math::Random::MT::Auto::Range - Range-valued PRNGs =head1 SYNOPSIS use strict; use warnings; use Math::Random::MT::Auto::Range; # Integer random number range my $die = Math::Random::MT::Auto::Range->new(LO => 1, HI => 6); my $roll = $die->rrand(); # Floating-point random number range my $compass = Math::Random::MT::Auto::Range->new(LO => 0, HI => 360, TYPE => 'DOUBLE'); my $course = $compass->rrand(); =head1 DESCRIPTION This module creates range-valued pseudorandom number generators (PRNGs) that return random values between two specified limits. While useful in itself, the primary purpose of this module is to provide an example of how to create subclasses of Math::Random::MT::Auto within L's inside-out object model. =head1 MODULE DECLARATION Add the following to the top of our application code: use strict; use warnings; use Math::Random::MT::Auto::Range; This module is strictly OO, and does not export any functions or symbols. =head1 METHODS =over =item Math::Random::MT::Auto::Range->new Creates a new range-valued PRNG. my $prng = Math::Random::MT::Auto::Range->new( %options ); Available options are: =over =item 'LOW' => $num =item 'HIGH' => $num Sets the limits over which the values return by the PRNG will range. These arguments are mandatory, and C must not be equal to C. If the C for the PRNG is C, then the range will be C to C inclusive (i.e., [LOW, HIGH]). If C, then C inclusive to C exclusive (i.e., [LOW, HIGH)). C and C can be used as synonyms for C and C, respectively. =item 'TYPE' => 'INTEGER' =item 'TYPE' => 'DOUBLE' Sets the type for the values returned from the PRNG. If C is not specified, it will default to C if both C and C are integers. =back The options above are also supported using lowercase and mixed-case (e.g., 'low', 'hi', 'Type', etc.). Additionally, objects created with this package can take any of the options supported by the L class, namely, C, C and C. =item $obj->new Creates a new PRNG in the same manner as Lnew">. my $prng2 = $prng1->new( %options ); =back In addition to the methods describe below, the objects created by this package inherit all the object methods provided by the L class, including the C<->clone()> method. =over =item $obj->rrand Returns a random number of the configured type within the configured range. my $rand = $prng->rrand(); If the C for the PRNG is C, then the range will be C to C inclusive (i.e., [LOW, HIGH]). If C, then C inclusive to C exclusive (i.e., [LOW, HIGH)). =item $obj->set_range_type Sets the numeric type for the random numbers returned by the PRNG. $prng->set_range_type('INTEGER'); # or $prng->set_range_type('DOUBLE'); =item $obj->get_range_type Returns the numeric type ('INTEGER' or 'DOUBLE') for the random numbers returned by the PRNG. my $type = $prng->get_range_type(); =item $obj->set_range Sets the limits for the PRNG's return value range. $prng->set_range($lo, $hi); C<$lo> must not be equal to C<$hi>. =item $obj->get_range Returns a list of the PRNG's range limits. my ($lo, $hi) = $prng->get_range(); =back =head1 INSIDE-OUT OBJECTS Capabilities provided by L are supported by this modules. See L for more information. =head2 Coercion Object coercion is supported in the same manner as documented in See L except that the underlying random number method is C<-Errand()>. =head1 DIAGNOSTICS =over =item * Missing parameter: LOW =item * Missing parameter: HIGH The L $num"> values for the range must be specified to L<-Enew()|/"Math::Random::MT::Auto::Range-Enew">. =item * Arg to ->set_range_type() must be 'INTEGER' or 'DOUBLE' Self explanatory. =item * ->range() requires two numeric args Self explanatory. =item * Invalid arguments: LOW and HIGH are equal You cannot specify a range of zero width. =back This module will reverse the range limits if they are specified in the wrong order (i.e., it makes sure that C). =head1 SEE ALSO L L =head1 AUTHOR Jerry D. Hedden, Sjdhedden AT cpan DOT orgE> =head1 COPYRIGHT AND LICENSE Copyright 2005 - 2009 Jerry D. Hedden. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =cut Math-Random-MT-Auto-6.23/README0000644000175000001440000001063013377133756015362 0ustar jdheddenusersMath-Random-MT-Auto version 6.23 ================================ This module provides pseudorandom number generators (PRNGs) that are based on the Mersenne Twister algorithm. There is a functional interface to a standalone PRNG, and an OO interface (based on the inside-out object model as implemented by the Object::InsideOut module) for generating multiple PRNG objects. The PRNGs are self-seeding, automatically acquiring a (19968-bit) random seed from user-selectable sources. Seed sources include local random devices (/dev/random and /dev/urandom), Internet sources (random.org, HotBits and RandomNumber.info), and Win32 XP system random data. Users may also provide their own seed sources. In addition to integer and floating-point uniformly-distributed random number deviates, this module implements the following non-uniform deviates as found in 'Numerical Recipes in C': Gaussian (normal) Exponential Erlang (gamma of integer order) Poisson Binomial This module also provides a function/method for shuffling data based on the Fisher-Yates shuffling algorithm. This module is thread-safe and supports object sharing between threads. For Perl compiled to support 64-bit integers, this module will use a 64-bit version of the Mersenne Twister algorithm, thus providing 64-bit random integers (and 53-bit random doubles). (32-bits otherwise.) The code for this module has been optimized for speed. Under Cygwin, it's 2.5 times faster than Math::Random::MT, and under Solaris, it's more than four times faster. (Math::Random::MT fails to build under Windows.) INSTALLATION A 'C' compiler is required for building this module. To install this module type the following: perl Makefile.PL make make test make install DEPENDENCIES Requires Perl 5.6.0 or later. This module uses the following 'standard' modules: Carp Fcntl XSLoader Scalar::Util (1.18 or later) ExtUtils::MakeMaker - For installation File::Spec - For installation Test::More - For installation Data::Dumper - For installation This module uses the following modules available through CPAN: Object::InsideOut (2.06 or later) Exception::Class (1.22 or later) To utilize the option of acquiring seed data from Internet sources, the following module is needed: LWP::UserAgent To utilize the option of acquiring seed data from the system's random data source under MSWin32 on Windows XP, the following module is needed: Win32::API COPYRIGHT AND LICENCE A C-Program for MT19937 (32- and 64-bit versions), with initialization improved 2002/1/26. Coded by Takuji Nishimura and Makoto Matsumoto, and including Shawn Cokus's optimizations. Copyright (C) 1997 - 2004, Makoto Matsumoto and Takuji Nishimura, All rights reserved. Copyright (C) 2005, Mutsuo Saito, All rights reserved. Copyright 2005 - 2009 Jerry D. Hedden Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. The names of its contributors may not be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. Any feedback is very welcome. http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/emt.html # EOF Math-Random-MT-Auto-6.23/META.yml0000664000175000001440000000146213377133764015757 0ustar jdheddenusers--- abstract: 'Auto-seeded Mersenne Twister PRNGs' author: - 'Jerry D. Hedden ' build_requires: ExtUtils::MakeMaker: '0' configure_requires: ExtUtils::MakeMaker: '0' dynamic_config: 1 generated_by: 'ExtUtils::MakeMaker version 7.34, CPAN::Meta::Converter version 2.150010' license: unrestricted meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: '1.4' name: Math-Random-MT-Auto no_index: directory: - t - inc requires: Carp: '0' Config: '0' Data::Dumper: '0' Exception::Class: '1.32' Fcntl: '0' Object::InsideOut: '3.88' Scalar::Util: '1.23' Test::More: '0' XSLoader: '0' strict: '0' warnings: '0' version: '6.23' x_serialization_backend: 'CPAN::Meta::YAML version 0.018' recommends: LWP::UserAgent: 0 Win32::API: 0 Math-Random-MT-Auto-6.23/examples/0000755000175000001440000000000013377133764016317 5ustar jdheddenusersMath-Random-MT-Auto-6.23/examples/cards.pl0000755000175000001440000000104713377133756017756 0ustar jdheddenusers#!/usr/bin/perl use strict; use warnings; $| = 1; use Math::Random::MT::Auto qw(shuffle); MAIN: { my $deck = shuffle(0..51); my @cards = qw(A 1 2 3 4 5 6 7 8 9 10 J Q K); my @suits = qw(C D H S); print('My hand: '); for my $card (0 .. 4) { print($cards[$$deck[$card] % 13], '-', $suits[$$deck[$card] / 13], ' '); } print("\n\n"); print('Your hand: '); for my $card (5 .. 9) { print($cards[$$deck[$card] % 13], '-', $suits[$$deck[$card] / 13], ' '); } print("\n"); } exit(0); # EOF Math-Random-MT-Auto-6.23/examples/timings.pl0000755000175000001440000002537513377133756020346 0ustar jdheddenusers#!/usr/bin/perl # Compares random number generation timings for Perl's core function, # Math::Random::MT::Auto and Math::Random::MT (if available). # Usage: timings.pl [--local] [COUNT] # --local = Don't try internet sources use strict; use warnings; no warnings 'void'; $| = 1; use Math::Random::MT::Auto qw(rand irand gaussian exponential srand get_seed set_seed :!auto); use Time::HiRes; use Config; # Warning signal handler my @WARN; $SIG{__WARN__} = sub { push(@WARN, @_); }; # Potentially available sources my %SRCS = ( '/dev/random' => 1, 'win32' => 1, 'random_org' => 1, 'hotbits' => 1, 'rn_info' => 1, ); # Internet sources my @INET = qw(random_org hotbits rn_info); my $DEFAULT_SRC = 'random_org'; MAIN: { # Command line arguments my $count = 3120000; my $local = 0; for my $arg (@ARGV) { if ($arg eq '--local') { # Local mode - no Internet sources $local = 1; } else { $count = 0 + $arg; } } # Check sources check_sources($local); my ($cnt, $start, $end); print("Random numbers generation timing\n"); print("\n- Core -\n"); # Time Perl's srand() my $seed = CORE::time() + $$; $start = Time::HiRes::time(); CORE::srand($seed); $end = Time::HiRes::time(); printf("srand:\t\t%f secs.\n", $end - $start); # Loop overhead $cnt = $count; $start = Time::HiRes::time(); while ($cnt--) { } $end = Time::HiRes::time(); my $overhead = $end - $start; # Time Perl's rand() $cnt = $count; $start = Time::HiRes::time(); while ($cnt--) { CORE::rand(); } $end = Time::HiRes::time(); printf("rand:\t\t%f secs. (%d)\n", ($end-$start)-$overhead, $count); # Reseed CORE::srand($seed); # Time Perl's rand(arg) $cnt = $count; $start = Time::HiRes::time(); while ($cnt--) { CORE::rand(5); } $end = Time::HiRes::time(); printf("rand(5):\t%f secs. (%d)\n", ($end-$start)-$overhead, $count); # Time Perl's rand() to product 64-bit randoms if ($Config{'uvsize'} == 8) { # Reseed CORE::srand($seed); $cnt = $count; $start = Time::HiRes::time(); while ($cnt--) { (int(CORE::rand(4294967296)) << 32) | int(CORE::rand(4294967296)); } $end = Time::HiRes::time(); printf("rand [64-bit]:\t%f secs. (%d)\n", ($end-$start)-$overhead, $count); } my @seed = @{get_seed()}; # Copy of existing seed print("\n- Math::Random::MT::Auto - Standalone PRNG -\n"); # Time our srand() while (my ($src, $available) = each(%SRCS)) { if ($available) { $start = Time::HiRes::time(); srand($src, $DEFAULT_SRC); $end = Time::HiRes::time(); printf("srand:\t\t%f secs. (%s %s)\n", $end - $start, $src, $DEFAULT_SRC); @seed = @{get_seed()}; } } # Time our irand() $cnt = $count; $start = Time::HiRes::time(); while ($cnt--) { irand(); } $end = Time::HiRes::time(); printf("irand:\t\t%f secs. (%d)\n", ($end-$start)-$overhead, $count); # Reseed set_seed(\@seed); # Time our rand() $cnt = $count; $start = Time::HiRes::time(); while ($cnt--) { rand(); } $end = Time::HiRes::time(); printf("rand:\t\t%f secs. (%d)\n", ($end-$start)-$overhead, $count); # Reseed set_seed(\@seed); # Time our rand(arg) $cnt = $count; $start = Time::HiRes::time(); while ($cnt--) { rand(5); } $end = Time::HiRes::time(); printf("rand(5):\t%f secs. (%d)\n", ($end-$start)-$overhead, $count); # Reseed set_seed(\@seed); # Time gaussian() $cnt = $count; $start = Time::HiRes::time(); while ($cnt--) { gaussian(); } $end = Time::HiRes::time(); printf("gaussian:\t%f secs. (%d)\n", ($end-$start)-$overhead, $count); # Reseed set_seed(\@seed); # Time gaussian(sd, mean) $cnt = $count; $start = Time::HiRes::time(); while ($cnt--) { gaussian(3, 69); } $end = Time::HiRes::time(); printf("gaussian(3,69):\t%f secs. (%d)\n", ($end-$start)-$overhead, $count); # Reseed set_seed(\@seed); # Time exponential() $cnt = $count; $start = Time::HiRes::time(); while ($cnt--) { exponential(); } $end = Time::HiRes::time(); printf("expon:\t\t%f secs. (%d)\n", ($end-$start)-$overhead, $count); # Reseed set_seed(\@seed); # Time exponential(mean) $cnt = $count; $start = Time::HiRes::time(); while ($cnt--) { exponential(5); } $end = Time::HiRes::time(); printf("expon(5):\t%f secs. (%d)\n", ($end-$start)-$overhead, $count); # Reseed set_seed(\@seed); print("\n- Math::Random::MT::Auto - OO Interface -\n"); # Time our ->new() my $rand; while (my ($src, $available) = each(%SRCS)) { if ($available) { $start = Time::HiRes::time(); $rand = Math::Random::MT::Auto->new('SOURCE' => [$src, $DEFAULT_SRC]); $end = Time::HiRes::time(); printf("new:\t\t%f secs. (%s %s)\n", $end - $start, $src, $DEFAULT_SRC); } } # Reseed $rand->set_seed(\@seed); # Time our irand() $cnt = $count; $start = Time::HiRes::time(); while ($cnt--) { $rand->irand(); } $end = Time::HiRes::time(); printf("irand:\t\t%f secs. (%d)\n", ($end-$start)-$overhead, $count); # Reseed $rand->set_seed(\@seed); # Time our rand() $cnt = $count; $start = Time::HiRes::time(); while ($cnt--) { $rand->rand(); } $end = Time::HiRes::time(); printf("rand:\t\t%f secs. (%d)\n", ($end-$start)-$overhead, $count); # Reseed $rand->set_seed(\@seed); # Time our rand(arg) $cnt = $count; $start = Time::HiRes::time(); while ($cnt--) { $rand->rand(5); } $end = Time::HiRes::time(); printf("rand(5):\t%f secs. (%d)\n", ($end-$start)-$overhead, $count); # Reseed $rand->set_seed(\@seed); # Time our gaussian() $cnt = $count; $start = Time::HiRes::time(); while ($cnt--) { $rand->gaussian(); } $end = Time::HiRes::time(); printf("gaussian:\t%f secs. (%d)\n", ($end-$start)-$overhead, $count); # Reseed $rand->set_seed(\@seed); # Time gaussian(sd, mean) $cnt = $count; $start = Time::HiRes::time(); while ($cnt--) { $rand->gaussian(3, 69); } $end = Time::HiRes::time(); printf("gaussian(3,69):\t%f secs. (%d)\n", ($end-$start)-$overhead, $count); # Reseed $rand->set_seed(\@seed); # Time our exponential() $cnt = $count; $start = Time::HiRes::time(); while ($cnt--) { $rand->exponential(); } $end = Time::HiRes::time(); printf("expon:\t\t%f secs. (%d)\n", ($end-$start)-$overhead, $count); # Reseed $rand->set_seed(\@seed); # Time exponential(mean) $cnt = $count; $start = Time::HiRes::time(); while ($cnt--) { $rand->exponential(5); } $end = Time::HiRes::time(); printf("expon(5):\t%f secs. (%d)\n", ($end-$start)-$overhead, $count); # Reseed $rand->set_seed(\@seed); # See if Math::Random::MT is available eval { require Math::Random::MT; import Math::Random::MT qw(srand rand); srand($seed); }; if (! $@) { print("\n- Math::Random::MT - Functional Interface -\n"); # Time its srand() function $start = Time::HiRes::time(); $rand = srand($seed); $end = Time::HiRes::time(); printf("srand:\t\t%f secs.\n", $end - $start); # Time its rand() $cnt = $count; $start = Time::HiRes::time(); while ($cnt--) { rand(); } $end = Time::HiRes::time(); printf("rand:\t\t%f secs. (%d)\n", ($end-$start)-$overhead, $count); # Reseed srand($seed); # Time its rand(arg) $cnt = $count; $start = Time::HiRes::time(); while ($cnt--) { rand(5); } $end = Time::HiRes::time(); printf("rand(5):\t%f secs. (%d)\n", ($end-$start)-$overhead, $count); # Time its rand() to product 64-bit randoms if ($Config{'uvsize'} == 8) { # Reseed $rand = Math::Random::MT->new(@seed); $cnt = $count; $start = Time::HiRes::time(); while ($cnt--) { (int(rand(4294967296)) << 32) | int(rand(4294967296)); } $end = Time::HiRes::time(); printf("rand [64-bit]:\t%f secs. (%d)\n", ($end-$start)-$overhead, $count); } print("\n- Math::Random::MT - OO Interface -\n"); # Time its new(@seed) method $start = Time::HiRes::time(); $rand = Math::Random::MT->new(@seed); $end = Time::HiRes::time(); printf("new:\t\t%f secs. (+ seed acquisition time)\n", $end - $start); # Time its rand() method $cnt = $count; $start = Time::HiRes::time(); while ($cnt--) { $rand->rand(); } $end = Time::HiRes::time(); printf("rand:\t\t%f secs. (%d)\n", ($end-$start)-$overhead, $count); # Reseed $rand = Math::Random::MT->new(@seed); # Time its rand(arg) method $cnt = $count; $start = Time::HiRes::time(); while ($cnt--) { $rand->rand(5); } $end = Time::HiRes::time(); printf("rand(5):\t%f secs. (%d)\n", ($end-$start)-$overhead, $count); } } exit(0); ### Subroutines ### sub check_sources { my $local = $_[0]; print('Checking seed sources...'); # Check availability of win32 source eval { srand('win32'); }; if ($@ || @WARN) { $SRCS{'win32'} = 0; undef(@WARN); } else { $SRCS{'win32'} = 1; $DEFAULT_SRC = 'win32'; } # Check availability of /dev/random source if (-e '/dev/random') { srand('/dev/random'); if (@WARN) { $SRCS{'/dev/random'} = 0; undef(@WARN); } else { $SRCS{'/dev/random'} = 1; $DEFAULT_SRC = '/dev/random'; } } else { $SRCS{'/dev/random'} = 0; } # Local mode - no Internet sources if ($local) { @SRCS{@INET} = 0; return; } # Check for LWP::UserAgent module eval { require LWP::UserAgent; }; if ($@) { @SRCS{@INET} = 0; return; } # Check availability of Internet sources for my $src (@INET) { srand($src, $DEFAULT_SRC); if (@WARN) { $SRCS{$src} = 0; undef(@WARN); } else { $SRCS{$src} = 1; } } # Done print("\n\n"); } # EOF Math-Random-MT-Auto-6.23/examples/bell.pl0000755000175000001440000000246613377133756017606 0ustar jdheddenusers#!/usr/bin/perl # Produces a bell curve using Gaussian random numbers. # Uses a standard deviation of 10 and a mean of 0.5 so that the '0' bin # contains the randoms from 0 to 1 and so on. # Plots +/- 4 standard deviations. # Usage: bell.pl [COUNT] # COUNT defaults to 1 million use strict; use warnings; $| = 1; use Math::Random::MT::Auto qw(gaussian); MAIN: { my $count = (@ARGV) ? $ARGV[0] : 1000000; my %bell; # Get random numbers and put them in bins print("Generating $count Gaussian random numbers. Please wait..."); for (1 .. $count) { my $x = gaussian(10, 0.5); # Handle 'rounding' using int() if ($x < 0) { $x = int($x-1); } else { $x = int($x); } # Make sure the tails don't overflow if ($x > 40) { $x = 40; } elsif ($x < -40) { $x = -40; } $bell{$x}++; } # Find the max bin size for scaling the output my $max = 0; while (my $key = each(%bell)) { if ($max < $bell{$key}) { $max = $bell{$key}; } } # Output the graph print("\n"); for my $key (sort { $a <=> $b } (keys(%bell))) { my $len = int(79.0 * $bell{$key}/$max); print(':', '*' x $len, "\n"); } } exit(0); # EOF Math-Random-MT-Auto-6.23/examples/erlang.pl0000755000175000001440000000212713377133756020132 0ustar jdheddenusers#!/usr/bin/perl # Produces a graph of random numbers from an Erlang distribution. # Usage: erlang.pl [ORDER [COUNT]] # ORDER defaults to 3 # COUNT defaults to 1 million use strict; use warnings; $| = 1; use Math::Random::MT::Auto qw(erlang); MAIN: { my $order = (@ARGV) ? $ARGV[0] : 3; my $count = (@ARGV > 1) ? $ARGV[1] : 1000000; my %erlang; # Get random numbers and put them in bins print("Generating $count Erlang random numbers. Please wait..."); for (1 .. $count) { my $x = int(erlang($order, 40/($order+2))); # Make sure the tail doesn't overflow if ($x > 80) { $x = 80; } $erlang{$x}++; } # Find the max bin size for scaling the output my $max = 0; while (my $key = each(%erlang)) { if ($max < $erlang{$key}) { $max = $erlang{$key}; } } # Output the graph print("\n"); for my $key (sort { $a <=> $b } (keys(%erlang))) { my $len = int(79.0 * $erlang{$key}/$max); print(':', '*' x $len, "\n"); } } exit(0); # EOF Math-Random-MT-Auto-6.23/examples/poisson.pl0000755000175000001440000000212213377133756020347 0ustar jdheddenusers#!/usr/bin/perl # Produces a graph of random numbers from a Poisson distribution. use strict; use warnings; $| = 1; use Math::Random::MT::Auto qw(poisson); MAIN: { if (! @ARGV) { print("Usage: poisson.pl MEAN [COUNT]]\n"); print("\tCOUNT defaults to 1 million\n"); } my $mean = $ARGV[0]; my $count = (@ARGV > 1) ? $ARGV[1] : 1000000; my %poisson; # Get random numbers and put them in bins print("Generating $count Poisson random numbers. Please wait..."); for (1 .. $count) { my $x = poisson($mean); # Make sure the tail doesn't overflow if ($x > 80) { $x = 80; } $poisson{$x}++; } # Find the max bin size for scaling the output my $max = 0; while (my $key = each(%poisson)) { if ($max < $poisson{$key}) { $max = $poisson{$key}; } } # Output the graph print("\n"); for my $key (sort { $a <=> $b } (keys(%poisson))) { my $len = int(79.0 * $poisson{$key}/$max); print(':', '*' x $len, "\n"); } } exit(0); # EOF Math-Random-MT-Auto-6.23/examples/decay.pl0000755000175000001440000000204313377133756017744 0ustar jdheddenusers#!/usr/bin/perl # Produces a decay curve using exponential random numbers. # Uses a mean of 15, and computes 80 'bins' of data. # Usage: decay.pl [COUNT] # COUNT defaults to 1 million use strict; use warnings; $| = 1; use Math::Random::MT::Auto qw(exponential); MAIN: { my $count = (@ARGV) ? $ARGV[0] : 1000000; my %decay; # Get random numbers and put them in bins print("Generating $count exponential random numbers. Please wait..."); for (1 .. $count) { my $x = int(exponential(15)); # Make sure the tail doesn't overflow if ($x > 80) { $x = 80; } $decay{$x}++; } # Find the max bin size for scaling the output my $max = 0; while (my $key = each(%decay)) { if ($max < $decay{$key}) { $max = $decay{$key}; } } # Output the graph print("\n"); for my $key (sort { $a <=> $b } (keys(%decay))) { my $len = int(79.0 * $decay{$key}/$max); print(':', '*' x $len, "\n"); } } exit(0); # EOF Math-Random-MT-Auto-6.23/examples/binomial.pl0000755000175000001440000000222213377133756020450 0ustar jdheddenusers#!/usr/bin/perl # Produces a graph of random numbers from a binomial distribution. use strict; use warnings; $| = 1; use Math::Random::MT::Auto qw(binomial); MAIN: { if (! @ARGV) { print("Usage: binomial.pl PROB TRIALS [COUNT]]\n"); print("\tPROB must be between 0.0 and 1.0 (inclusive)\n"); print("\tTRIALS must be >= 0\n"); print("\tCOUNT defaults to 1 million\n"); } my $prob = $ARGV[0]; my $trials = $ARGV[1]; my $count = (@ARGV > 2) ? $ARGV[2] : 1000000; my %binomial; # Get random numbers and put them in bins print("Generating $count binomial random numbers. Please wait..."); for (1 .. $count) { my $x = binomial($prob, $trials); $binomial{$x}++; } # Find the max bin size for scaling the output my $max = 0; while (my $key = each(%binomial)) { if ($max < $binomial{$key}) { $max = $binomial{$key}; } } # Output the graph print("\n"); for my $key (sort { $a <=> $b } (keys(%binomial))) { my $len = int(79.0 * $binomial{$key}/$max); print(':', '*' x $len, "\n"); } } exit(0); # EOF Math-Random-MT-Auto-6.23/t/0000755000175000001440000000000013377133764014744 5ustar jdheddenusersMath-Random-MT-Auto-6.23/t/99-pod.t0000644000175000001440000000423413377133756016156 0ustar jdheddenusersuse strict; use warnings; use Test::More; if ($ENV{RUN_MAINTAINER_TESTS}) { plan 'tests' => 6; } else { plan 'skip_all' => 'Module maintainer tests'; } SKIP: { if (! eval 'use Test::Pod 1.26; 1') { skip('Test::Pod 1.26 required for testing POD', 1); } pod_file_ok('lib/Math/Random/MT/Auto.pm'); pod_file_ok('lib/Math/Random/MT/Auto/Range.pm'); } SKIP: { if (! eval 'use Test::Pod::Coverage 1.08; 1') { skip('Test::Pod::Coverage 1.08 required for testing POD coverage', 1); } pod_coverage_ok('Math::Random::MT::Auto', { 'trustme' => [ qr/^(?:array|as_string|bool)$/, ], 'private' => [ qr/^(import|bootstrap)$/, qr/^_/ ] } ); pod_coverage_ok('Math::Random::MT::Auto::Range', { 'trustme' => [ qr/^(?:array|as_string|bool)$/, ], 'private' => [ qr/^_/, ] } ); } SKIP: { if (! eval 'use Test::Spelling; 1') { skip('Test::Spelling required for testing POD spelling', 1); } if (system('aspell help >/dev/null 2>&1')) { skip("'aspell' required for testing POD spelling", 1); } set_spell_cmd('aspell list --lang=en'); add_stopwords(); pod_file_spelling_ok('lib/Math/Random/MT/Auto.pm', 'MRMA POD spelling'); pod_file_spelling_ok('lib/Math/Random/MT/Auto/Range.pm', 'MRMA::Range POD spelling'); unlink("/home/$ENV{'USER'}/en.prepl", "/home/$ENV{'USER'}/en.pws"); } exit(0); __DATA__ Cokus's FreeBSD Hedden Cokus HotBits MSWin32 Makoto Mersenne Nishimura OO OSs OpenBSD PRNG PRNGs Programmatically QUICKSTART RPNG RandomNumbers.info RandomNumbers.info's SRCS Solaris Takuji Wikipedia XP XSLoader cpan erlang gaussian irand poisson pseudorandom src 0xFFFFFFFF MERCHANTABILITY Matsumoto Redistributions optimizations selectable situ Arg PRNG's subclasses MetaCPAN __END__ Math-Random-MT-Auto-6.23/t/14-serialize.t0000644000175000001440000011045713377133756017353 0ustar jdheddenusers# Verify serialization use strict; use warnings; use Test::More 'tests' => 2004; use Config; my @WARN; BEGIN { # Warning signal handler $SIG{__WARN__} = sub { push(@WARN, @_); }; } use_ok('Math::Random::MT::Auto', ':!auto'); use_ok('Math::Random::MT::Auto::Range'); # Known test values for irand() my @base_rint = ($Config{'uvsize'} == 8) ? ( # 64-bit randoms 7266447313870364031, 4946485549665804864, 16945909448695747420, 16394063075524226720, 4873882236456199058, 14877448043947020171, 6740343660852211943, 13857871200353263164, 5249110015610582907, 10205081126064480383, 1235879089597390050, 17320312680810499042, 16489141110565194782, 8942268601720066061, 13520575722002588570, 14226945236717732373, 9383926873555417063, 15690281668532552105, 11510704754157191257, 15864264574919463609, 6489677788245343319, 5112602299894754389, 10828930062652518694, 15942305434158995996, 15445717675088218264, 4764500002345775851, 14673753115101942098, 236502320419669032, 13670483975188204088, 14931360615268175698, 8904234204977263924, 12836915408046564963, 12120302420213647524, 15755110976537356441, 5405758943702519480, 10951858968426898805, 17251681303478610375, 4144140664012008120, 18286145806977825275, 13075804672185204371, 10831805955733617705, 6172975950399619139, 12837097014497293886, 12903857913610213846, 560691676108914154, 1074659097419704618, 14266121283820281686, 11696403736022963346, 13383246710985227247, 7132746073714321322, 10608108217231874211, 9027884570906061560, 12893913769120703138, 15675160838921962454, 2511068401785704737, 14483183001716371453, 3774730664208216065, 5083371700846102796, 9583498264570933637, 17119870085051257224, 5217910858257235075, 10612176809475689857, 1924700483125896976, 7171619684536160599, 10949279256701751503, 15596196964072664893, 14097948002655599357, 615821766635933047, 5636498760852923045, 17618792803942051220, 580805356741162327, 425267967796817241, 8381470634608387938, 13212228678420887626, 16993060308636741960, 957923366004347591, 6210242862396777185, 1012818702180800310, 15299383925974515757, 17501832009465945633, 17453794942891241229, 15807805462076484491, 8407189590930420827, 974125122787311712, 1861591264068118966, 997568339582634050, 18046771844467391493, 17981867688435687790, 3809841506498447207, 9460108917638135678, 16172980638639374310, 958022432077424298, 4393365126459778813, 13408683141069553686, 13900005529547645957, 15773550354402817866, 16475327524349230602, 6260298154874769264, 12224576659776460914, 6405294864092763507, 7585484664713203306, 5187641382818981381, 12435998400285353380, 13554353441017344755, 646091557254529188, 11393747116974949255, 16797249248413342857, 15713519023537495495, 12823504709579858843, 4738086532119935073, 4429068783387643752, 585582692562183870, 1048280754023674130, 6788940719869959076, 11670856244972073775, 2488756775360218862, 2061695363573180185, 6884655301895085032, 3566345954323888697, 12784319933059041817, 4772468691551857254, 6864898938209826895, 7198730565322227090, 2452224231472687253, 13424792606032445807, 10827695224855383989, 11016608897122070904, 14683280565151378358, 7077866519618824360, 17487079941198422333, 3956319990205097495, 5804870313319323478, 8017203611194497730, 3310931575584983808, 5009341981771541845, 6930001938490791874, 14415278059151389495, 11001114762641844083, 6715939435439735925, 411419160297131328, 4522402260441335284, 3381955501804126859, 15935778656111987797, 4345051260540166684, 13978444093099579683, 9219789505504949817, 9245142924137529075, 11628184459157386459, 7242398879359936370, 8511401943157540109, 11948130810477009827, 6865450671488705049, 13965005347172621081, 15956599226522058336, 7737868921014130584, 2107342503741411693, 15818996300425101108, 16399939197527488760, 13971145494081508107, 3910681448359868691, 4249175367970221090, 9735751321242454020, 12418107929362160460, 241792245481991138, 5806488997649497146, 10724207982663648949, 1121862814449214435, 1326996977123564236, 4902706567834759475, 12782714623891689967, 7306216312942796257, 15681656478863766664, 957364844878149318, 5651946387216554503, 8197027112357634782, 6302075516351125977, 13454588464089597862, 15638309200463515550, 10116604639722073476, 12052913535387714920, 2889379661594013754, 15383926144832314187, 7841953313015471731, 17310575136995821873, 9820021961316981626, 15319619724109527290, 15349724127275899898, 10511508162402504492, 6289553862380300393, 15046218882019267110, 11772020174577005930, 3537640779967351792, 6801855569284252424, 17687268231192623388, 12968358613633237218, 1429775571144180123, 10427377732172208413, 12155566091986788996, 16465954421598296115, 12710429690464359999, 9547226351541565595, 12156624891403410342, 2985938688676214686, 18066917785985010959, 5975570403614438776, 11541343163022500560, 11115388652389704592, 9499328389494710074, 9247163036769651820, 3688303938005101774, 2210483654336887556, 15458161910089693228, 6558785204455557683, 1288373156735958118, 18433986059948829624, 3435082195390932486, 16822351800343061990, 3120532877336962310, 16681785111062885568, 7835551710041302304, 2612798015018627203, 15083279177152657491, 6591467229462292195, 10592706450534565444, 7438147750787157163, 323186165595851698, 7444710627467609883, 8473714411329896576, 2782675857700189492, 3383567662400128329, 3200233909833521327, 12897601280285604448, 3612068790453735040, 8324209243736219497, 15789570356497723463, 1083312926512215996, 4797349136059339390, 5556729349871544986, 18266943104929747076, 1620389818516182276, 172225355691600141, 3034352936522087096, 1266779576738385285, 3906668377244742888, 6961783143042492788, 17159706887321247572, 4676208075243319061, 10315634697142985816, 13435140047933251189, 716076639492622016, 13847954035438697558, 7195811275139178570, 10815312636510328870, 6214164734784158515, 16412194511839921544, 3862249798930641332, 1005482699535576005, 4644542796609371301, 17600091057367987283, 4209958422564632034, 5419285945389823940, 11453701547564354601, 9951588026679380114, 7425168333159839689, 8436306210125134906, 11216615872596820107, 3681345096403933680, 5770016989916553752, 11102855936150871733, 11187980892339693935, 396336430216428875, 6384853777489155236, 7551613839184151117, 16527062023276943109, 13429850429024956898, 9901753960477271766, 9731501992702612259, 5217575797614661659, 10311708346636548706, 15111747519735330483, 4353415295139137513, 1845293119018433391, 11952006873430493561, 3531972641585683893, 16852246477648409827, 15956854822143321380, 12314609993579474774, 16763911684844598963, 16392145690385382634, 1545507136970403756, 17771199061862790062, 12121348462972638971, 12613068545148305776, 954203144844315208, 1257976447679270605, 3664184785462160180, 2747964788443845091, 15895917007470512307, 15552935765724302120, 16366915862261682626, 8385468783684865323, 10745343827145102946, 2485742734157099909, 916246281077683950, 15214206653637466707, 12895483149474345798, 1079510114301747843, 10718876134480663664, 1259990987526807294, 8326303777037206221, 14104661172014248293, 15531278677382192198, 3874303698666230242, 3611366553819264523, 1358753803061653874, 1552102816982246938, 14492630642488100979, 15001394966632908727, 2273140352787320862, 17843678642369606172, 2903980458593894032, 16971437123015263604, 12969653681729206264, 3593636458822318001, 9719758956915223015, 7437601263394568346, 3327758049015164431, 17851524109089292731, 14769614194455139039, 8017093497335662337, 12026985381690317404, 739616144640253634, 15535375191850690266, 2418267053891303448, 15314073759564095878, 10333316143274529509, 16565481511572123421, 16317667579273275294, 13991958187675987741, 3753596784796798785, 9078249094693663275, 8459506356724650587, 12579909555010529099, 7827737296967050903, 5489801927693999341, 10995988997350541459, 14721747867313883304, 7915884580303296560, 4105766302083365910, 12455549072515054554, 13602111324515032467, 5205971628932290989, 5034622965420036444, 9134927878875794005, 11319873529597990213, 14815445109496752058, 2266601052460299470, 5696993487088103383, 6540200741841280242, 6631495948031875490, 5328340585170897740, 17897267040961463930, 9030000260502624168, 14285709137129830926, 12854071997824681544, 15408328651008978682, 1063314403033437073, 13765209628446252802, 242013711116865605, 4772374239432528212, 2515855479965038648, 5872624715703151235, 14237704570091006662, 678604024776645862, 12329607334079533339, 17570877682732917020, 2695443415284373666, 4312672841405514468, 6454343485137106900, 8425658828390111343, 16335501385875554899, 5551095603809016713, 11781094401885925035, 9395557946368382509, 9765123360948816956, 18107191819981188154, 16049267500594757404, 16349966108299794199, 1040405303135858246, 2366386386131378192, 223761048139910454, 15375217587047847934, 15231693398695187454, 12916726640254571028, 8878036960829635584, 1626201782473074365, 5758998126998248293, 18077917959300292758, 10585588923088536745, 15072345664541731497, 3559348759319842667, 12744591691872202375, 2388494115860283059, 6414691845696331748, 3069528498807764495, 8737958486926519702, 18059264986425101074, 3139684427605102737, 12378931902986734693, 410666675039477949, 12139894855769838924, 5780722552400398675, 7039346665375142557, 3020733445712569008, 2612305843503943561, 13651771214166527665, 16478681918975800939, 566088527565499576, 4715785502295754870, 6957318344287196220, 11645756868405128885, 13139951104358618000, 17650948583490040612, 18168787973649736637, 5486282999836125542, 6122201977153895166, 17324241605502052782, 10063523107521105867, 17537430712468011382, 10828407533637104262, 10294139354198325113, 12557151830240236401, 16673044307512640231, 10918020421896090419, 11077531235278014145, 5499571814940871256, 2334252435740638702, 18177461912527387031, 2000007376901262542, 7968425560071444214, 1472650787501520648, 3115849849651526279, 7980970700139577536, 12153253535907642097, 8109716914843248719, 3154976533165008908, 5553369513523832559, 10345792701798576501, 3677445364544507875, 10637177623943913351, 7380255087060498096, 14479400372337014801, 15381362583330700960, 204531043189704802, 13699106540959723942, 3817903465872254783, 10972364467110284934, 2701394334530963810, 2931625600749229147, 16428252083632828910, 11873166501966812913, 5566810080537233762, 7840617383807795056, 10699413880206684652, 18259119259617231436, 10332714341486317526, 10137911902863059694, 669146221352346842, 8373571610024623455, 10620002450820868661, 12220730820779815970, 5902974968095412898, 7931010481705150841, 16413777368097063650, 11273457888324769727, 13719113891065284171, 8327795098009702553, 10333342364827584837, 6202832891413866653, 9137034567886143162, 14514450826524340059, 473610156015331016, 813689571029117640, 13776316799690285717, 10429708855338427756, 8995290140880620858, 2320123852041754384, 8082864073645003641, 6961777411740398590, 10008644283003991179, 3239064015890722333, 16762634970725218787, 16467281536733948427, 10563290046315192938, 5108560603794851559, 15121667220761532906, 14155440077372845941, 10050536352394623377, 15474881667376037792, 3448088038819200619, 3692020001240358871, 6444847992258394902, 8687650838094264665, 3028124591188972359, 16945232313401161629, 15547830510283682816, 3982930188609442149, 14270781928849894661, 13768475593433447867, 13815150225221307677, 8502397232429564693, 718377350715476994, 7459266877697905475, 8353375565171101521, 7807281661994435472, 16924127046922196149, 10157812396471387805, 2519858716882670232, 7384148884750265792, 8077153156180046901, 3499231286164597752, 2700106282881469611, 14679824700835879737, 14188324938219126828, 3016120398601032793, 10858152824243889420, 9412371965669250534, 4857522662584941069, 984331743838900386, 4094160040294753142, 2368635764350388458, 15101240511397838657, 15584415763303953578, 7831857200208015446, 1952643641639729063, 4184323302594028609, 16795120381104846695, 3541559381538365280, 15408472870896842474, 5628362450757896366, 16277348886873708846, 12437047172652330846, 10172715019035948149, 1999700669649752791, 6217957085626135027, 11220551167830336823, 16478747645632411810, 5437280487207382147, 11382378739613087836, 15866932785489521505, 5502694314775516684, 16440179278067648435, 15510104554374162846, 15722061259110909195, 10760687291786964354, 10736868329920212671, 4166148127664495614, 14303518358120527892, 9122250801678898571, 10028508179936801946, 216630713752669403, 10655207865433859491, 4041437116174699233, 6280982262534375348, 297501356638818866, 13976146806363377485, 13752396481560145603, 11472199956603637419, 16393728429143900496, 14752844047515986640, 1524477318846038424, 6596889774254235440, 1591982099532234960, 8065146456116391065, 3964696017750868345, 17040425970526664920, 11511165586176539991, 3443401252003315103, 16314977947073778249, 16860120454903458341, 5370503221561340846, 15362920279125264094, 2822458124714999779, 14575378304387898337, 9689406052675046032, 2872149351415175149, 13019620945255883050, 14929026760148695825, 8503417349692327218, 9677798905341573754, 828949921821462483, 16110482368362750196, 15794218816553655671, 14942910774764855088, 12026350906243760195, 13610867176871462505, 18324536557697872582, 2658962269666727629, 327225403251576027, 9207535177029277544, 8744129291351887858, 6129603385168921503, 18385497655031085907, 13024478718952333892, 14547683159720717167, 5932119629366981711, 325385464632594563, 3559879386019806291, 6629264948665231298, 14358245326238118181, 15662449672706340765, 13975503159145803297, 3609534220891499022, 4224273587485638227, 9274084767162416370, 13156843921244091998, 18284750575626858789, 14664767920489118779, 11292057742031803221, 13919998707305829132, 14473305049457001422, 9696877879685767807, 1406758246007973837, 2429517644459056881, 14361215588101587430, 11386164476149757528, 10474116023593331839, 2921165656527786564, 15604610369733358953, 12955027028676000544, 10314281035410779907, 3167047178514709947, 1088721329408346700, 17930425515478182741, 7466411836095405617, 15534027454610690575, 10879629128927506091, 11502219301371200635, 13915106894453889418, 4226784327815861027, 12335222183627106346, 3648499746356007767, 18441388887898023393, 18117929843327093625, 4237736098094830438, 14229123019768296655, 3930112058127932690, 12663879236019645778, 9281161952002617309, 4978473890680876319, 845759387067546611, 1386164484606776333, 8008554770639925512, 11159581016793288971, 18065390393740782906, 17647985458967631018, 9092379465737744314, 2914678236848656327, 4376066698447630270, 16057186499919087528, 3031333261848790078, 2926746602873431597, 7931945763526885287, 147649915388326849, 15801792398814946230, 5265900391686545347, 16173686275871890830, 7562781050481886043, 5853506575839330404, 14957980734704564792, 10944286556353523404, 1783009880614150597, 9529762028588888983, 822992871011696119, 2130074274744257510, 8000279549284809219, 3514744284158856431, 128770032569293263, 3737367602618100572, 16364836605077998543, 783266423471782696, 4569418252658970391, 11093950688157406886, 14888808512267628166, 4217786261273670948, 17047486076688645713, 14133826721458860485, 17539744882220127106, 12394675039129853905, 5757634999463277090, 9621947619435861331, 1182210208559436772, 14603391040490913939, 17481976703660945893, 14063388816234683976, 2046622692581829572, 8294969799792017441, 5293778434844788058, 17976364049306763808, 399482430848083948, 16495545010129798933, 15241340958282367519, 989828753826900814, 17616558773874893537, 2471817920909589004, 11764082277667899978, 9618755269550400950, 1240014743757147125, 1887649378641563002, 1842982574728131416, 13243531042427194002, 7688268125537013927, 3080422097287486736, 2562894809975407783, 12428984115620094788, 1355581933694478148, 9895969242586224966, 8628445623963160889, 4298916726468199239, 12773165416305557280, 5240726258301567487, 4975412836403427561, 1842172398579595303, 7812151462958058676, 17974510987263071769, 14980707022065991200, 18294903201142729875, 12911672684850242753, 8979482998667235743, 16808468362384462073, 5981317232108359798, 12373702800369335100, 16119707581920094765, 2782738549717633602, 15454155188515389391, 16495638000603654629, 16348757069342790497, 7769562861984504567, 17504300515449231559, 5557710032938318996, 11846125204788401203, 13957316349928882624, 2738350683717432043, 15738068448047700954, 6224714837294524999, 6081930777706411111, 11366312928059597928, 4355315799925031482, 12393324728734964015, 15277140291994338591, 1406052433297386355, 15859448364509213398, 1672805458341158435, 2926095111610982994, 11056431822276774455, 12083767323511977430, 3296968762229741153, 12312076899982286460, 17769284994682227273, 15349428916826953443, 1056147296359223910, 18305757538706977431, 6214378374180465222, 14279648441175008454, 17791306410319136644, 956593013486324072, 2921235772936241950, 10002890515925652606, 10399654693663712506, 6446247931049971441, 6380465770144534958, 11439178472613251620, 10131486500045494660, 3692642123868351947, 10972816599561388940, 4931112976348785580, 8213967169213816566, 15336469859637867841, 15026830342847689383, 7524668622380765825, 17309937346758783807, 372780684412666438, 5642417144539399955, 18303842993081194577, 11085303253831702827, 15658163165983586950, 8517521928922081563, 16091186344159989860, 17614656488010863910, 4736067146481515156, 13449945221374241354, 17755469346196579408, 13300502638545717375, 6611828134763118043, 14177591906740276597, 9340430243077460347, 7499765399826404087, 3409518087967832469, 9013253864026602045, 4444307427984430192, 3729283608700519712, 13642048880719588383, 16486557958022946240, 2996465014991157904, 10020049344596426576, 12302485648009883778, 8492591321344423126, 17407986443716172520, 10530482934957373052, 15740662350540828750, 1790629986901049436, 6305948377669917188, 15092985352503125323, 928505047232899787, 14404651977039851607, 7564177565277805597, 3411236815351677870, 7752718145953236134, 12315979971311483798, 12477729506691004724, 14654956300924793305, 6689803038918974388, 1540738812233000153, 13508351811701989957, 15864432023192136053, 7990997967273843917, 7424300239290765161, 39585249496300263, 3877436595063283319, 10710642254398044448, 4653804418844456375, 1232267496410380283, 3690525514009038824, 15459770765077428485, 13240346522153894145, 5674964360688390624, 16973644653010587289, 15924280764204855206, 15196708627253442662, 17596174821341373274, 16196745023027393691, 6980050627399795351, 17582264380857746637, 18170372407506856324, 12108126025631005514, 15687749089493373169, 5814107289258228434, 9381977959648494876, 15895601183088112734, 16267869075651604263, 15228381979765852785, 11949618678312581999, 4545324791131029438, 582725409406225185, 15282520250746126790, 14758446535973412711, 7605613563088071833, 1111140641057375915, 5364843095234852245, 218335432181198977, 4891472444796201742, 4564628942836375772, 15500501278323817088, 4913946328556108657, 2684786251736694229, 12090498456116310122, 5310885782157038567, 5032788439854011923, 12627401038822728242, 11869662610126430929, 17650156853043540226, 12126672500118808436, 10437658933435653256, 13133995470637873311, 4601324715591152820, 1874350460376708372, 5808688626286061164, 13777088437302430376, 5018451954762213522, 2588296738534474754, 5503414509154170711, 5230497186769951796, 13261090710400573914, 8515217303152165705, 11074538219737365303, 15481562385740613213, 12705484409881007350, 14221931471178549498, 12905633420087112297, 17337759164357146506, 14081997515778175224, 17384320185513122939, 7131793076779216692, 17483217190312403109, 900692047897995877, 14723287313048560400, 6132094372965340305, 7572797575350925726, 12725160700431903514, 380860122911632449, 1900504978569024571, 8423729759529914138, 7305587201606052334, 12446871355267313320, 4615812356515386206, 3361817115406652303, 17690418922000878428, 14632214537567910559, 2709702289926174775, 3459675155951086144, 7788364399926538150, 16043992474431955950, 15830963823784930267, 4216893617835797954, 538159724689093771, 16029152738918251363, 14444848757576686696, 12941757045272633696, 10900480525147953314, 12547307449905859302, 16001571796892398181, 407942194622690676, 13873235372903944444, 18071603799493008777, 1015646077646778622, 9387605808959554815, 11566702442022019410, 7061722181092883183, 2629032108249254109, 5271820053177594520, 12640880742139693547, 10098688629735675775, 5716304472850923064, 3312674502353063071, 7295926377425759633, 833281439103466115, 16316743519466861667, 9912050326606348167, 11651133878100804242, 18026798122431692459, 6157758321723692663, 4856021830695749349, 7074321707293278978, 10748097797809573561, 2949954440753264783, 9813922580940661152, 9949237950172138336, 15643982711269455885, 16078663425810239127, 12508044395364228880, 12920301578340189344, 15368071871011048915, 1610400750626363239, 11994736084146033126, 6042574085746186088, 4154587549267685807, 15915752367312946034, 1191196620621769193, 467437822242538360, 2836463788873877488, 10476401302029164984, 1716169985450737419, 5327734953288310341, 3994170067185955262, 884431883768190063, 11019001754831208284, 14322807384384895215, 161011537360955545, 1466223959660131656, 5227048585229497539, 12410731857504225031, 2142243279080761103, 17682826799106851430, 1792612570704179953, 14727410295243056025, 1459567192481221274, 5669760721687603135, 17507918443756456845, 10354471145847018200, 10362475129248202288, 13143844410150939443, 6861184673150072028, 18396524361124732580, 543906666394301875, 12476817828199026728, 11853496871128122868, 12747674713108891748, 7986179867749890282, 9158195177777627533, 2217320706811118570, 8631389005200569973, 5538133061362648855, 3369942850878700758, 7813559982698427184, 509051590411815948, 10197035660403006684, 13004818533162292132, 9831652587047067687, 7619315254749630976, 994412663058993407 ) : ( # 32-bit randoms 1067595299, 955945823, 477289528, 4107218783, 4228976476, 3344332714, 3355579695, 227628506, 810200273, 2591290167, 2560260675, 3242736208, 646746669, 1479517882, 4245472273, 1143372638, 3863670494, 3221021970, 1773610557, 1138697238, 1421897700, 1269916527, 2859934041, 1764463362, 3874892047, 3965319921, 72549643, 2383988930, 2600218693, 3237492380, 2792901476, 725331109, 605841842, 271258942, 715137098, 3297999536, 1322965544, 4229579109, 1395091102, 3735697720, 2101727825, 3730287744, 2950434330, 1661921839, 2895579582, 2370511479, 1004092106, 2247096681, 2111242379, 3237345263, 4082424759, 219785033, 2454039889, 3709582971, 835606218, 2411949883, 2735205030, 756421180, 2175209704, 1873865952, 2762534237, 4161807854, 3351099340, 181129879, 3269891896, 776029799, 2218161979, 3001745796, 1866825872, 2133627728, 34862734, 1191934573, 3102311354, 2916517763, 1012402762, 2184831317, 4257399449, 2899497138, 3818095062, 3030756734, 1282161629, 420003642, 2326421477, 2741455717, 1278020671, 3744179621, 271777016, 2626330018, 2560563991, 3055977700, 4233527566, 1228397661, 3595579322, 1077915006, 2395931898, 1851927286, 3013683506, 1999971931, 3006888962, 1049781534, 1488758959, 3491776230, 104418065, 2448267297, 3075614115, 3872332600, 891912190, 3936547759, 2269180963, 2633455084, 1047636807, 2604612377, 2709305729, 1952216715, 207593580, 2849898034, 670771757, 2210471108, 467711165, 263046873, 3569667915, 1042291111, 3863517079, 1464270005, 2758321352, 3790799816, 2301278724, 3106281430, 7974801, 2792461636, 555991332, 621766759, 1322453093, 853629228, 686962251, 1455120532, 957753161, 1802033300, 1021534190, 3486047311, 1902128914, 3701138056, 4176424663, 1795608698, 560858864, 3737752754, 3141170998, 1553553385, 3367807274, 711546358, 2475125503, 262969859, 251416325, 2980076994, 1806565895, 969527843, 3529327173, 2736343040, 2987196734, 1649016367, 2206175811, 3048174801, 3662503553, 3138851612, 2660143804, 1663017612, 1816683231, 411916003, 3887461314, 2347044079, 1015311755, 1203592432, 2170947766, 2569420716, 813872093, 1105387678, 1431142475, 220570551, 4243632715, 4179591855, 2607469131, 3090613241, 282341803, 1734241730, 1391822177, 1001254810, 827927915, 1886687171, 3935097347, 2631788714, 3905163266, 110554195, 2447955646, 3717202975, 3304793075, 3739614479, 3059127468, 953919171, 2590123714, 1132511021, 3795593679, 2788030429, 982155079, 3472349556, 859942552, 2681007391, 2299624053, 647443547, 233600422, 608168955, 3689327453, 1849778220, 1608438222, 3968158357, 2692977776, 2851872572, 246750393, 3582818628, 3329652309, 4036366910, 1012970930, 950780808, 3959768744, 2538550045, 191422718, 2658142375, 3276369011, 2927737484, 1234200027, 1920815603, 3536074689, 1535612501, 2184142071, 3276955054, 428488088, 2378411984, 4059769550, 3913744741, 2732139246, 64369859, 3755670074, 842839565, 2819894466, 2414718973, 1010060670, 1839715346, 2410311136, 152774329, 3485009480, 4102101512, 2852724304, 879944024, 1785007662, 2748284463, 1354768064, 3267784736, 2269127717, 3001240761, 3179796763, 895723219, 865924942, 4291570937, 89355264, 1471026971, 4114180745, 3201939751, 2867476999, 2460866060, 3603874571, 2238880432, 3308416168, 2072246611, 2755653839, 3773737248, 1709066580, 4282731467, 2746170170, 2832568330, 433439009, 3175778732, 26248366, 2551382801, 183214346, 3893339516, 1928168445, 1337157619, 3429096554, 3275170900, 1782047316, 4264403756, 1876594403, 4289659572, 3223834894, 1728705513, 4068244734, 2867840287, 1147798696, 302879820, 1730407747, 1923824407, 1180597908, 1569786639, 198796327, 560793173, 2107345620, 2705990316, 3448772106, 3678374155, 758635715, 884524671, 486356516, 1774865603, 3881226226, 2635213607, 1181121587, 1508809820, 3178988241, 1594193633, 1235154121, 326117244, 2304031425, 937054774, 2687415945, 3192389340, 2003740439, 1823766188, 2759543402, 10067710, 1533252662, 4132494984, 82378136, 420615890, 3467563163, 541562091, 3535949864, 2277319197, 3330822853, 3215654174, 4113831979, 4204996991, 2162248333, 3255093522, 2219088909, 2978279037, 255818579, 2859348628, 3097280311, 2569721123, 1861951120, 2907080079, 2719467166, 998319094, 2521935127, 2404125338, 259456032, 2086860995, 1839848496, 1893547357, 2527997525, 1489393124, 2860855349, 76448234, 2264934035, 744914583, 2586791259, 1385380501, 66529922, 1819103258, 1899300332, 2098173828, 1793831094, 276463159, 360132945, 4178212058, 595015228, 177071838, 2800080290, 1573557746, 1548998935, 378454223, 1460534296, 1116274283, 3112385063, 3709761796, 827999348, 3580042847, 1913901014, 614021289, 4278528023, 1905177404, 45407939, 3298183234, 1184848810, 3644926330, 3923635459, 1627046213, 3677876759, 969772772, 1160524753, 1522441192, 452369933, 1527502551, 832490847, 1003299676, 1071381111, 2891255476, 973747308, 4086897108, 1847554542, 3895651598, 2227820339, 1621250941, 2881344691, 3583565821, 3510404498, 849362119, 862871471, 797858058, 2867774932, 2821282612, 3272403146, 3997979905, 209178708, 1805135652, 6783381, 2823361423, 792580494, 4263749770, 776439581, 3798193823, 2853444094, 2729507474, 1071873341, 1329010206, 1289336450, 3327680758, 2011491779, 80157208, 922428856, 1158943220, 1667230961, 2461022820, 2608845159, 387516115, 3345351910, 1495629111, 4098154157, 3156649613, 3525698599, 4134908037, 446713264, 2137537399, 3617403512, 813966752, 1157943946, 3734692965, 1680301658, 3180398473, 3509854711, 2228114612, 1008102291, 486805123, 863791847, 3189125290, 1050308116, 3777341526, 4291726501, 844061465, 1347461791, 2826481581, 745465012, 2055805750, 4260209475, 2386693097, 2980646741, 447229436, 2077782664, 1232942813, 4023002732, 1399011509, 3140569849, 2579909222, 3794857471, 900758066, 2887199683, 1720257997, 3367494931, 2668921229, 955539029, 3818726432, 1105704962, 3889207255, 2277369307, 2746484505, 1761846513, 2413916784, 2685127085, 4240257943, 1166726899, 4215215715, 3082092067, 3960461946, 1663304043, 2087473241, 4162589986, 2507310778, 1579665506, 767234210, 970676017, 492207530, 1441679602, 1314785090, 3262202570, 3417091742, 1561989210, 3011406780, 1146609202, 3262321040, 1374872171, 1634688712, 1280458888, 2230023982, 419323804, 3262899800, 39783310, 1641619040, 1700368658, 2207946628, 2571300939, 2424079766, 780290914, 2715195096, 3390957695, 163151474, 2309534542, 1860018424, 555755123, 280320104, 1604831083, 2713022383, 1728987441, 3639955502, 623065489, 3828630947, 4275479050, 3516347383, 2343951195, 2430677756, 635534992, 3868699749, 808442435, 3070644069, 4282166003, 2093181383, 2023555632, 1568662086, 3422372620, 4134522350, 3016979543, 3259320234, 2888030729, 3185253876, 4258779643, 1267304371, 1022517473, 815943045, 929020012, 2995251018, 3371283296, 3608029049, 2018485115, 122123397, 2810669150, 1411365618, 1238391329, 1186786476, 3155969091, 2242941310, 1765554882, 279121160, 4279838515, 1641578514, 3796324015, 13351065, 103516986, 1609694427, 551411743, 2493771609, 1316337047, 3932650856, 4189700203, 463397996, 2937735066, 1855616529, 2626847990, 55091862, 3823351211, 753448970, 4045045500, 1274127772, 1124182256, 92039808, 2126345552, 425973257, 386287896, 2589870191, 1987762798, 4084826973, 2172456685, 3366583455, 3602966653, 2378803535, 2901764433, 3716929006, 3710159000, 2653449155, 3469742630, 3096444476, 3932564653, 2595257433, 318974657, 3146202484, 853571438, 144400272, 3768408841, 782634401, 2161109003, 570039522, 1886241521, 14249488, 2230804228, 1604941699, 3928713335, 3921942509, 2155806892, 134366254, 430507376, 1924011722, 276713377, 196481886, 3614810992, 1610021185, 1785757066, 851346168, 3761148643, 2918835642, 3364422385, 3012284466, 3735958851, 2643153892, 3778608231, 1164289832, 205853021, 2876112231, 3503398282, 3078397001, 3472037921, 1748894853, 2740861475, 316056182, 1660426908, 168885906, 956005527, 3984354789, 566521563, 1001109523, 1216710575, 2952284757, 3834433081, 3842608301, 2467352408, 3974441264, 3256601745, 1409353924, 1329904859, 2307560293, 3125217879, 3622920184, 3832785684, 3882365951, 2308537115, 2659155028, 1450441945, 3532257603, 3186324194, 1225603425, 1124246549, 175808705, 3009142319, 2796710159, 3651990107, 160762750, 1902254979, 1698648476, 1134980669, 497144426, 3302689335, 4057485630, 3603530763, 4087252587, 427812652, 286876201, 823134128, 1627554964, 3745564327, 2589226092, 4202024494, 62878473, 3275585894, 3987124064, 2791777159, 1916869511, 2585861905, 1375038919, 1403421920, 60249114, 3811870450, 3021498009, 2612993202, 528933105, 2757361321, 3341402964, 2621861700, 273128190, 4015252178, 3094781002, 1621621288, 2337611177, 1796718448, 1258965619, 4241913140, 2138560392, 3022190223, 4174180924, 450094611, 3274724580, 617150026, 2704660665, 1469700689, 1341616587, 356715071, 1188789960, 2278869135, 1766569160, 2795896635, 57824704, 2893496380, 1235723989, 1630694347, 3927960522, 428891364, 1814070806, 2287999787, 4125941184, 3968103889, 3548724050, 1025597707, 1404281500, 2002212197, 92429143, 2313943944, 2403086080, 3006180634, 3561981764, 1671860914, 1768520622, 1803542985, 844848113, 3006139921, 1410888995, 1157749833, 2125704913, 1789979528, 1799263423, 741157179, 2405862309, 767040434, 2655241390, 3663420179, 2172009096, 2511931187, 1680542666, 231857466, 1154981000, 157168255, 1454112128, 3505872099, 1929775046, 2309422350, 2143329496, 2960716902, 407610648, 2938108129, 2581749599, 538837155, 2342628867, 430543915, 740188568, 1937713272, 3315215132, 2085587024, 4030765687, 766054429, 3517641839, 689721775, 1294158986, 1753287754, 4202601348, 1974852792, 33459103, 3568087535, 3144677435, 1686130825, 4134943013, 3005738435, 3599293386, 426570142, 754104406, 3660892564, 1964545167, 829466833, 821587464, 1746693036, 1006492428, 1595312919, 1256599985, 1024482560, 1897312280, 2902903201, 691790057, 1037515867, 3176831208, 1968401055, 2173506824, 1089055278, 1748401123, 2941380082, 968412354, 1818753861, 2973200866, 3875951774, 1119354008, 3988604139, 1647155589, 2232450826, 3486058011, 3655784043, 3759258462, 847163678, 1082052057, 989516446, 2871541755, 3196311070, 3929963078, 658187585, 3664944641, 2175149170, 2203709147, 2756014689, 2456473919, 3890267390, 1293787864, 2830347984, 3059280931, 4158802520, 1561677400, 2586570938, 783570352, 1355506163, 31495586, 3789437343, 3340549429, 2092501630, 896419368, 671715824, 3530450081, 3603554138, 1055991716, 3442308219, 1499434728, 3130288473, 3639507000, 17769680, 2259741420, 487032199, 4227143402, 3693771256, 1880482820, 3924810796, 381462353, 4017855991, 2452034943, 2736680833, 2209866385, 2128986379, 437874044, 595759426, 641721026, 1636065708, 3899136933, 629879088, 3591174506, 351984326, 2638783544, 2348444281, 2341604660, 2123933692, 143443325, 1525942256, 364660499, 599149312, 939093251, 1523003209, 106601097, 376589484, 1346282236, 1297387043, 764598052, 3741218111, 933457002, 1886424424, 3219631016, 525405256, 3014235619, 323149677, 2038881721, 4100129043, 2851715101, 2984028078, 1888574695, 2014194741, 3515193880, 4180573530, 3461824363, 2641995497, 3179230245, 2902294983, 2217320456, 4040852155, 1784656905, 3311906931, 87498458, 2752971818, 2635474297, 2831215366, 3682231106, 2920043893, 3772929704, 2816374944, 309949752, 2383758854, 154870719, 385111597, 1191604312, 1840700563, 872191186, 2925548701, 1310412747, 2102066999, 1504727249, 3574298750, 1191230036, 3330575266, 3180292097, 3539347721, 681369118, 3305125752, 3648233597, 950049240, 4173257693, 1760124957, 512151405, 681175196, 580563018, 1169662867, 4015033554, 2687781101, 699691603, 2673494188, 1137221356, 123599888, 472658308, 1053598179, 1012713758, 3481064843, 3759461013, 3981457956, 3830587662, 1877191791, 3650996736, 988064871, 3515461600, 4089077232, 2225147448, 1249609188, 2643151863, 3896204135, 2416995901, 1397735321, 3460025646); # Set predetermined seed for verification test my @base_seed = ($Config{'uvsize'} == 8) ? (0x12345, 0x23456, 0x34567, 0x45678) : (0x123, 0x234, 0x345, 0x456); my $obj = Math::Random::MT::Auto->new('SEED' => \@base_seed); if (! ok(! $@, 'Create object')) { diag('Failure creating object: ' . $@); } my $dump = $obj->dump(); my $obj2 = Object::InsideOut->pump($dump); foreach my $rand (@base_rint) { is($obj2->irand, $rand => 'irand'); } my ($LO, $HI) = (1000, 9999); sub range { return (($_[0] % (($HI + 1) - $LO)) + $LO); } my $robj = Math::Random::MT::Auto::Range->new('SEED' => \@base_seed, 'LOW' => $LO, 'HIGH' => $HI, 'TYPE' => 'INTEGER'); if (! ok(! $@, 'Create object')) { diag('Failure creating object: ' . $@); } my $dump; if ($] > 5.006) { $dump = $robj->dump(1); } else { $dump = $robj->dump(); } my $robj2 = Object::InsideOut->pump($dump); foreach my $rand (@base_rint) { is($robj2->rrand, range($rand) => 'rrand'); } exit(0); # EOF Math-Random-MT-Auto-6.23/t/04-win32.t0000644000175000001440000000426213377133756016321 0ustar jdheddenusers# Tests for Windows XP random source use strict; use warnings; use Test::More; my @WARN; BEGIN { # Warning signal handler $SIG{__WARN__} = sub { push(@WARN, @_); }; } if (($^O eq 'MSWin32') || ($^O eq 'cygwin')) { eval { require Win32; }; if (! $@) { my ($id, $major, $minor) = (Win32::GetOSVersion())[4,1,2]; if (defined($minor) && (($id > 2) || ($id == 2 && $major > 5) || ($id == 2 && $major == 5 && $minor >= 1))) { eval { # Suppress (harmless) warning about Win32::API::Type's INIT block local $SIG{__WARN__} = sub { if ($_[0] !~ /^Too late to run INIT block/) { print(STDERR "# $_[0]"); # Output other warnings } }; # Load Win32::API module require Win32::API; }; if (! $@) { plan(tests => 92); } else { plan(skip_all => 'No Win32::API'); } } else { plan(skip_all => 'Not Win XP'); } } else { plan(skip_all => 'Module "Win32" missing!?!'); } } else { plan(skip_all => 'Not MSWin32 or Cygwin'); } use_ok('Math::Random::MT::Auto', qw(rand irand), 'win32'); can_ok('main', qw(rand irand)); # Check for warnings if (! ok(! @WARN, 'Acquired seed data')) { diag('Seed warnings: ' . join(' | ', @WARN)); } undef(@WARN); my ($rn, @rn); # Test rand() eval { $rn = rand(); }; ok(! $@, 'rand() died: ' . $@); ok(defined($rn), 'Got a random number'); ok(Scalar::Util::looks_like_number($rn), 'Is a number: ' . $rn); ok($rn >= 0.0 && $rn < 1.0, 'In range: ' . $rn); # Test several values from irand() for my $ii (0 .. 9) { eval { $rn[$ii] = irand(); }; ok(! $@, 'irand() died: ' . $@); ok(defined($rn[$ii]), 'Got a random number'); ok(Scalar::Util::looks_like_number($rn[$ii]), 'Is a number: ' . $rn[$ii]); ok(int($rn[$ii]) == $rn[$ii], 'Integer: ' . $rn[$ii]); for my $jj (0 .. $ii-1) { ok($rn[$jj] != $rn[$ii], 'Randomized'); } } exit(0); # EOF Math-Random-MT-Auto-6.23/t/07-random_org.t0000644000175000001440000000303113377133756017502 0ustar jdheddenusers# Tests for random.org site use strict; use warnings; use Test::More; # Warning signal handler my @WARN; BEGIN { $SIG{__WARN__} = sub { push(@WARN, @_); }; } use Math::Random::MT::Auto qw(rand irand), 'random_org'; if (grep(/^Failure creating user-agent/, @WARN)) { plan skip_all => 'LWP::Useragent not available'; } elsif (grep(/^Failure contacting/, @WARN)) { plan skip_all => 'random.org not reachable'; } elsif ((grep(/^Failure getting data/, @WARN)) || (grep(/^No seed data/, @WARN))) { plan skip_all => 'Seed not obtained from random.org'; } plan tests => 91; @WARN = grep(!/^Partial seed/, @WARN); @WARN = grep(!/only once/, @WARN); # Ingnore 'once' warnings from other modules ok(! @WARN, 'No warnings'); diag('Warnings: ' . join(' | ', @WARN)) if (@WARN); can_ok('main', qw(rand irand)); # Test rand() my ($rn, @rn); eval { $rn = rand(); }; ok(! $@, 'rand() died: ' . $@); ok(defined($rn), 'Got a random number'); ok(Scalar::Util::looks_like_number($rn), 'Is a number: ' . $rn); ok($rn >= 0.0 && $rn < 1.0, 'In range: ' . $rn); # Test several values from irand() for my $ii (0 .. 9) { eval { $rn[$ii] = irand(); }; ok(! $@, 'irand() died: ' . $@); ok(defined($rn[$ii]), 'Got a random number'); ok(Scalar::Util::looks_like_number($rn[$ii]), 'Is a number: ' . $rn[$ii]); ok(int($rn[$ii]) == $rn[$ii], 'Integer: ' . $rn[$ii]); for my $jj (0 .. $ii-1) { ok($rn[$jj] != $rn[$ii], 'Randomized'); } } exit(0); # EOF Math-Random-MT-Auto-6.23/t/11-range.t0000644000175000001440000001360513377133756016452 0ustar jdheddenusers# Tests the Math::Random::MT::Auto::Range class use strict; use warnings; use Config; my @WARN; BEGIN { # Warning signal handler $SIG{__WARN__} = sub { push(@WARN, @_); }; # Try to use threads if ($Config{useithreads} && $] > 5.008) { require threads; threads->import(); } } use Test::More 'tests' => 227; use Math::Random::MT::Auto; use Math::Random::MT::Auto::Range; # Create PRNG object my $prng; eval { $prng = Math::Random::MT::Auto::Range->new(lo=>100, hi=>199); }; if (! ok(! $@, '->new works')) { diag('->new died: ' . $@); } isa_ok($prng, 'Math::Random::MT::Auto'); isa_ok($prng, 'Math::Random::MT::Auto::Range'); can_ok($prng, qw(rand irand gaussian exponential erlang poisson binomial shuffle srand get_seed set_seed get_state set_state new get_range_type set_range_type get_range set_range rrand)); # Verify hidden 'init' subroutine if ($] > 5.006) { eval { $prng->_init({}); }; if (my $e = OIO->caught()) { ok($e->error =~ /hidden/i, '->_init() hidden: ' . $e->error); } else { ok($@, '->_init() visible - this is bad'); } } else { ok(1, 'SKIPPED'); } # Check for warnings if (! ok(! @WARN, 'Acquired seed data')) { diag('Seed warnings: ' . join(' | ', @WARN)); } undef(@WARN); ok($prng->get_range_type() eq 'INTEGER', 'Int range type'); my ($lo, $hi) = $prng->get_range(); ok($lo == 100 && $hi == 199, "Range: $lo $hi"); # Test several values from rrand() my $rr; for my $ii (0 .. 9) { eval { $rr = $prng->rrand(); }; ok(! $@, '$prng->rrand() died: ' . $@); ok(defined($rr), 'Got a random number'); ok(Scalar::Util::looks_like_number($rr), 'Is a number: ' . $rr); ok(int($rr) == $rr, 'Integer: ' . $rr); ok($rr >= 100 && $rr <= 199, 'In range: ' . $rr); } # Test several values from irand() for my $ii (0 .. 9) { eval { $rr = $prng->irand(); }; ok(! $@, '$prng->irand() died: ' . $@); ok(defined($rr), 'Got a random number'); ok(Scalar::Util::looks_like_number($rr), 'Is a number: ' . $rr); ok(int($rr) == $rr, 'Integer: ' . $rr); ok($rr >= 0, 'Postive int: ' . $rr); } # New PRNG my $prng2 = $prng->new(lo=>100, hi=>199, type=>'double'); isa_ok($prng2, 'Math::Random::MT::Auto'); isa_ok($prng2, 'Math::Random::MT::Auto::Range'); can_ok($prng2, qw(rand irand gaussian exponential erlang poisson binomial shuffle srand get_seed set_seed get_state set_state new get_range_type set_range_type get_range set_range rrand)); # Check for warnings if (! ok(! @WARN, 'Acquired seed data')) { diag('Seed warnings: ' . join(' | ', @WARN)); } undef(@WARN); ok($prng2->get_range_type() eq 'DOUBLE', 'Double range type'); ($lo, $hi) = $prng2->get_range(); ok($lo == 100 && $hi == 199, "Range: $lo $hi"); # Test several values from rrand() my $ints = 0; for my $ii (0 .. 9) { eval { $rr = $prng2->rrand(); }; ok(! $@, '$prng2->rrand() died: ' . $@); ok(defined($rr), 'Got a random number'); ok(Scalar::Util::looks_like_number($rr), 'Is a number: ' . $rr); if (int($rr) == $rr) { $ints++; } ok($rr >= 100 && $rr < 199, 'In range: ' . $rr); } ok($ints < 10, 'Rands not ints: ' . $ints); ### Clone # New PRNG my $prng3 = $prng2->clone(); isa_ok($prng3, 'Math::Random::MT::Auto'); isa_ok($prng3, 'Math::Random::MT::Auto::Range'); can_ok($prng3, qw(rand irand gaussian exponential erlang poisson binomial shuffle srand get_seed set_seed get_state set_state new get_range_type set_range_type get_range set_range rrand)); ok($prng3->get_range_type() eq 'DOUBLE', 'Double range type'); ($lo, $hi) = $prng3->get_range(); ok($lo == 100 && $hi == 199, "Range: $lo $hi"); # Get rands from parent my @rands2; for (0 .. 9) { push(@rands2, $prng2->rrand()); } # Get rands from clone my @rands3; for (0 .. 9) { push(@rands3, $prng3->rrand()); } # Compare is_deeply(\@rands2, \@rands3); ### Subclassing a subclass # 'Empty subclass' test (cf. perlmodlib) { package Math::Random::MT::Auto::Range::Sub; use Object::InsideOut qw(Math::Random::MT::Auto::Range); } # Create PRNG object my $prng4; eval { $prng4 = Math::Random::MT::Auto::Range::Sub->new(lo=>-100, hi=>100); }; if (! ok(! $@, '->new works')) { diag('->new died: ' . $@); } isa_ok($prng4, 'Math::Random::MT::Auto'); isa_ok($prng4, 'Math::Random::MT::Auto::Range'); isa_ok($prng4, 'Math::Random::MT::Auto::Range::Sub'); can_ok($prng4, qw(rand irand gaussian exponential erlang poisson binomial shuffle srand get_seed set_seed get_state set_state new get_range_type set_range_type get_range set_range rrand)); # Check for warnings if (! ok(! @WARN, 'Acquired seed data')) { diag('Seed warnings: ' . join(' | ', @WARN)); } undef(@WARN); ### Threads with subclass SKIP: { if (! $threads::threads) { skip 'Threads not supported', 60; } # Get random numbers from thread my $rands = threads->create( sub { my @rands; for (0 .. 9) { push(@rands, $prng4->rrand()); } return (\@rands); } )->join(); # Check that parent gets the same numbers my $rand; for my $ii (0 .. 9) { eval { $rand = $prng4->rrand(); }; ok(! $@, '$prng->rrand() died: ' . $@); ok(defined($rand), 'Got a random number'); ok(Scalar::Util::looks_like_number($rand), 'Is a number: ' . $rand); ok(int($rand) == $rand, 'Integer: ' . $rand); ok($rand >= -100 && $rand <= 100, 'In range: ' . $rand); ok($$rands[$ii] == $rand, 'Values equal: ' . $$rands[$ii] . ' ' . $rand); } } exit(0); # EOF Math-Random-MT-Auto-6.23/t/00-load.t0000644000175000001440000000036113377133756016266 0ustar jdheddenusersuse strict; use warnings; use Test::More 'tests' => 1; use_ok('Math::Random::MT::Auto', ':!auto'); if ($Math::Random::MT::Auto::VERSION) { diag('Testing Math::Random::MT::Auto ' . $Math::Random::MT::Auto::VERSION); } exit(0); # EOF Math-Random-MT-Auto-6.23/t/02-gaussian.t0000644000175000001440000000552313377133756017170 0ustar jdheddenusers# Test gaussian() use strict; use warnings; use Test::More 'tests' => 7; my $CNT = 500000; use_ok('Math::Random::MT::Auto', qw/gaussian/); can_ok('Math::Random::MT::Auto', qw/gaussian/); can_ok('main', qw/gaussian/); # Cumulative distribution function sub cdf { my $z = $_[0]; my $sum = 1.0 * $z; my $k = 1; my $factK = 1.0; my $term; do { $term = ($z**($k+$k+1)) / (($k+$k+1) * (2.0**$k) * $factK); $sum -= $term; $k++; $factK *= $k; $term = ($z**($k+$k+1)) / (($k+$k+1) * (2.0**$k) * $factK); $sum += $term; $k++; $factK *= $k; } while (abs($term) > 1e-50); $sum *= .398942280401432678; $sum += 0.5; return ($sum); } my %df; for my $ii (-40 .. 39) { $df{$ii} = cdf(($ii+1)/10) * $CNT; } for (my $ii=39; $ii > -40; $ii--) { $df{$ii} -= $df{$ii-1}; } ### - Gaussian Function - ### my (%bell, $x, $dev); # Get random numbers and put them in bins my $loops = 3; LOOP1: undef(%bell); for (1 .. $CNT) { eval { $x = gaussian(10); }; if ($@) { fail('gaussian(10) failed: ' . $@); exit(1); } # Handle 'rounding' using int() if ($x < 0) { $x = int($x) - 1; } else { $x = int($x); } # Make sure the tails don't overflow if ($x > 39) { $x = 40; } elsif ($x < -39) { $x = -40; } $bell{$x}++; } $dev = 0; for my $ii (-40 .. 39) { my $bar1 = 3 * sqrt($df{$ii}); my $bar2 = .025 * $df{$ii}; my $bar = ($bar1 < $bar2) ? $bar2 : $bar1; if (($bell{$ii} < ($df{$ii}-$bar)) || (($df{$ii}+$bar) < $bell{$ii})) { $dev++; } } if (($dev > 3) && $loops--) { goto LOOP1; } ok($dev <= 3, 'Looks like a bell curve'); ### - Gaussian OO - ### my $prng; eval { $prng = Math::Random::MT::Auto->new(); }; if (! ok(! $@, '->new() worked')) { diag('->new() died: ' . $@); } can_ok($prng, qw/rand irand gaussian exponential erlang poisson binomial shuffle srand get_seed set_seed get_state set_state/); # Get random numbers and put them in bins $loops = 3; LOOP2: undef(%bell); for (1 .. $CNT) { eval { $x = $prng->gaussian(10); }; if ($@) { fail('$prng->gaussian(10) failed: ' . $@); exit(1); } # Handle 'rounding' using int() if ($x < 0) { $x = int($x) - 1; } else { $x = int($x); } # Make sure the tails don't overflow if ($x > 39) { $x = 40; } elsif ($x < -39) { $x = -40; } $bell{$x}++; } $dev=0; for my $ii (-40 .. 39) { my $bar1 = 3 * sqrt($df{$ii}); my $bar2 = .025 * $df{$ii}; my $bar = ($bar1 < $bar2) ? $bar2 : $bar1; if (($bell{$ii} < ($df{$ii}-$bar)) || (($df{$ii}+$bar) < $bell{$ii})) { $dev++; } } if (($dev > 3) && $loops--) { goto LOOP2; } ok($dev <= 3, 'Looks like a bell curve'); exit(0); # EOF Math-Random-MT-Auto-6.23/t/01-mersenne.t0000644000175000001440000020000013377133756017154 0ustar jdheddenusers# Verify Mersenne Twister algorithm # Test standalone PRNG - srand(\&sub), get_/set_seed() and get_/set_state() # Test OO interface - seeding from file, $obj->get_/set_seed() and # $obj->get_/set_state() # Test PRNG 'cloning' use strict; use warnings; use Test::More 'tests' => 33; use Config; my @WARN; BEGIN { # Warning signal handler $SIG{__WARN__} = sub { push(@WARN, @_); }; use_ok('Math::Random::MT::Auto', qw(rand irand srand get_seed set_seed get_state set_state :!auto)); } can_ok('Math::Random::MT::Auto', qw(rand irand srand get_seed set_seed get_state set_state)); can_ok('main', qw(rand irand srand get_seed set_seed get_state set_state)); # Known test values for irand() my @base_rint = ($Config{'uvsize'} == 8) ? ( # 64-bit randoms 7266447313870364031, 4946485549665804864, 16945909448695747420, 16394063075524226720, 4873882236456199058, 14877448043947020171, 6740343660852211943, 13857871200353263164, 5249110015610582907, 10205081126064480383, 1235879089597390050, 17320312680810499042, 16489141110565194782, 8942268601720066061, 13520575722002588570, 14226945236717732373, 9383926873555417063, 15690281668532552105, 11510704754157191257, 15864264574919463609, 6489677788245343319, 5112602299894754389, 10828930062652518694, 15942305434158995996, 15445717675088218264, 4764500002345775851, 14673753115101942098, 236502320419669032, 13670483975188204088, 14931360615268175698, 8904234204977263924, 12836915408046564963, 12120302420213647524, 15755110976537356441, 5405758943702519480, 10951858968426898805, 17251681303478610375, 4144140664012008120, 18286145806977825275, 13075804672185204371, 10831805955733617705, 6172975950399619139, 12837097014497293886, 12903857913610213846, 560691676108914154, 1074659097419704618, 14266121283820281686, 11696403736022963346, 13383246710985227247, 7132746073714321322, 10608108217231874211, 9027884570906061560, 12893913769120703138, 15675160838921962454, 2511068401785704737, 14483183001716371453, 3774730664208216065, 5083371700846102796, 9583498264570933637, 17119870085051257224, 5217910858257235075, 10612176809475689857, 1924700483125896976, 7171619684536160599, 10949279256701751503, 15596196964072664893, 14097948002655599357, 615821766635933047, 5636498760852923045, 17618792803942051220, 580805356741162327, 425267967796817241, 8381470634608387938, 13212228678420887626, 16993060308636741960, 957923366004347591, 6210242862396777185, 1012818702180800310, 15299383925974515757, 17501832009465945633, 17453794942891241229, 15807805462076484491, 8407189590930420827, 974125122787311712, 1861591264068118966, 997568339582634050, 18046771844467391493, 17981867688435687790, 3809841506498447207, 9460108917638135678, 16172980638639374310, 958022432077424298, 4393365126459778813, 13408683141069553686, 13900005529547645957, 15773550354402817866, 16475327524349230602, 6260298154874769264, 12224576659776460914, 6405294864092763507, 7585484664713203306, 5187641382818981381, 12435998400285353380, 13554353441017344755, 646091557254529188, 11393747116974949255, 16797249248413342857, 15713519023537495495, 12823504709579858843, 4738086532119935073, 4429068783387643752, 585582692562183870, 1048280754023674130, 6788940719869959076, 11670856244972073775, 2488756775360218862, 2061695363573180185, 6884655301895085032, 3566345954323888697, 12784319933059041817, 4772468691551857254, 6864898938209826895, 7198730565322227090, 2452224231472687253, 13424792606032445807, 10827695224855383989, 11016608897122070904, 14683280565151378358, 7077866519618824360, 17487079941198422333, 3956319990205097495, 5804870313319323478, 8017203611194497730, 3310931575584983808, 5009341981771541845, 6930001938490791874, 14415278059151389495, 11001114762641844083, 6715939435439735925, 411419160297131328, 4522402260441335284, 3381955501804126859, 15935778656111987797, 4345051260540166684, 13978444093099579683, 9219789505504949817, 9245142924137529075, 11628184459157386459, 7242398879359936370, 8511401943157540109, 11948130810477009827, 6865450671488705049, 13965005347172621081, 15956599226522058336, 7737868921014130584, 2107342503741411693, 15818996300425101108, 16399939197527488760, 13971145494081508107, 3910681448359868691, 4249175367970221090, 9735751321242454020, 12418107929362160460, 241792245481991138, 5806488997649497146, 10724207982663648949, 1121862814449214435, 1326996977123564236, 4902706567834759475, 12782714623891689967, 7306216312942796257, 15681656478863766664, 957364844878149318, 5651946387216554503, 8197027112357634782, 6302075516351125977, 13454588464089597862, 15638309200463515550, 10116604639722073476, 12052913535387714920, 2889379661594013754, 15383926144832314187, 7841953313015471731, 17310575136995821873, 9820021961316981626, 15319619724109527290, 15349724127275899898, 10511508162402504492, 6289553862380300393, 15046218882019267110, 11772020174577005930, 3537640779967351792, 6801855569284252424, 17687268231192623388, 12968358613633237218, 1429775571144180123, 10427377732172208413, 12155566091986788996, 16465954421598296115, 12710429690464359999, 9547226351541565595, 12156624891403410342, 2985938688676214686, 18066917785985010959, 5975570403614438776, 11541343163022500560, 11115388652389704592, 9499328389494710074, 9247163036769651820, 3688303938005101774, 2210483654336887556, 15458161910089693228, 6558785204455557683, 1288373156735958118, 18433986059948829624, 3435082195390932486, 16822351800343061990, 3120532877336962310, 16681785111062885568, 7835551710041302304, 2612798015018627203, 15083279177152657491, 6591467229462292195, 10592706450534565444, 7438147750787157163, 323186165595851698, 7444710627467609883, 8473714411329896576, 2782675857700189492, 3383567662400128329, 3200233909833521327, 12897601280285604448, 3612068790453735040, 8324209243736219497, 15789570356497723463, 1083312926512215996, 4797349136059339390, 5556729349871544986, 18266943104929747076, 1620389818516182276, 172225355691600141, 3034352936522087096, 1266779576738385285, 3906668377244742888, 6961783143042492788, 17159706887321247572, 4676208075243319061, 10315634697142985816, 13435140047933251189, 716076639492622016, 13847954035438697558, 7195811275139178570, 10815312636510328870, 6214164734784158515, 16412194511839921544, 3862249798930641332, 1005482699535576005, 4644542796609371301, 17600091057367987283, 4209958422564632034, 5419285945389823940, 11453701547564354601, 9951588026679380114, 7425168333159839689, 8436306210125134906, 11216615872596820107, 3681345096403933680, 5770016989916553752, 11102855936150871733, 11187980892339693935, 396336430216428875, 6384853777489155236, 7551613839184151117, 16527062023276943109, 13429850429024956898, 9901753960477271766, 9731501992702612259, 5217575797614661659, 10311708346636548706, 15111747519735330483, 4353415295139137513, 1845293119018433391, 11952006873430493561, 3531972641585683893, 16852246477648409827, 15956854822143321380, 12314609993579474774, 16763911684844598963, 16392145690385382634, 1545507136970403756, 17771199061862790062, 12121348462972638971, 12613068545148305776, 954203144844315208, 1257976447679270605, 3664184785462160180, 2747964788443845091, 15895917007470512307, 15552935765724302120, 16366915862261682626, 8385468783684865323, 10745343827145102946, 2485742734157099909, 916246281077683950, 15214206653637466707, 12895483149474345798, 1079510114301747843, 10718876134480663664, 1259990987526807294, 8326303777037206221, 14104661172014248293, 15531278677382192198, 3874303698666230242, 3611366553819264523, 1358753803061653874, 1552102816982246938, 14492630642488100979, 15001394966632908727, 2273140352787320862, 17843678642369606172, 2903980458593894032, 16971437123015263604, 12969653681729206264, 3593636458822318001, 9719758956915223015, 7437601263394568346, 3327758049015164431, 17851524109089292731, 14769614194455139039, 8017093497335662337, 12026985381690317404, 739616144640253634, 15535375191850690266, 2418267053891303448, 15314073759564095878, 10333316143274529509, 16565481511572123421, 16317667579273275294, 13991958187675987741, 3753596784796798785, 9078249094693663275, 8459506356724650587, 12579909555010529099, 7827737296967050903, 5489801927693999341, 10995988997350541459, 14721747867313883304, 7915884580303296560, 4105766302083365910, 12455549072515054554, 13602111324515032467, 5205971628932290989, 5034622965420036444, 9134927878875794005, 11319873529597990213, 14815445109496752058, 2266601052460299470, 5696993487088103383, 6540200741841280242, 6631495948031875490, 5328340585170897740, 17897267040961463930, 9030000260502624168, 14285709137129830926, 12854071997824681544, 15408328651008978682, 1063314403033437073, 13765209628446252802, 242013711116865605, 4772374239432528212, 2515855479965038648, 5872624715703151235, 14237704570091006662, 678604024776645862, 12329607334079533339, 17570877682732917020, 2695443415284373666, 4312672841405514468, 6454343485137106900, 8425658828390111343, 16335501385875554899, 5551095603809016713, 11781094401885925035, 9395557946368382509, 9765123360948816956, 18107191819981188154, 16049267500594757404, 16349966108299794199, 1040405303135858246, 2366386386131378192, 223761048139910454, 15375217587047847934, 15231693398695187454, 12916726640254571028, 8878036960829635584, 1626201782473074365, 5758998126998248293, 18077917959300292758, 10585588923088536745, 15072345664541731497, 3559348759319842667, 12744591691872202375, 2388494115860283059, 6414691845696331748, 3069528498807764495, 8737958486926519702, 18059264986425101074, 3139684427605102737, 12378931902986734693, 410666675039477949, 12139894855769838924, 5780722552400398675, 7039346665375142557, 3020733445712569008, 2612305843503943561, 13651771214166527665, 16478681918975800939, 566088527565499576, 4715785502295754870, 6957318344287196220, 11645756868405128885, 13139951104358618000, 17650948583490040612, 18168787973649736637, 5486282999836125542, 6122201977153895166, 17324241605502052782, 10063523107521105867, 17537430712468011382, 10828407533637104262, 10294139354198325113, 12557151830240236401, 16673044307512640231, 10918020421896090419, 11077531235278014145, 5499571814940871256, 2334252435740638702, 18177461912527387031, 2000007376901262542, 7968425560071444214, 1472650787501520648, 3115849849651526279, 7980970700139577536, 12153253535907642097, 8109716914843248719, 3154976533165008908, 5553369513523832559, 10345792701798576501, 3677445364544507875, 10637177623943913351, 7380255087060498096, 14479400372337014801, 15381362583330700960, 204531043189704802, 13699106540959723942, 3817903465872254783, 10972364467110284934, 2701394334530963810, 2931625600749229147, 16428252083632828910, 11873166501966812913, 5566810080537233762, 7840617383807795056, 10699413880206684652, 18259119259617231436, 10332714341486317526, 10137911902863059694, 669146221352346842, 8373571610024623455, 10620002450820868661, 12220730820779815970, 5902974968095412898, 7931010481705150841, 16413777368097063650, 11273457888324769727, 13719113891065284171, 8327795098009702553, 10333342364827584837, 6202832891413866653, 9137034567886143162, 14514450826524340059, 473610156015331016, 813689571029117640, 13776316799690285717, 10429708855338427756, 8995290140880620858, 2320123852041754384, 8082864073645003641, 6961777411740398590, 10008644283003991179, 3239064015890722333, 16762634970725218787, 16467281536733948427, 10563290046315192938, 5108560603794851559, 15121667220761532906, 14155440077372845941, 10050536352394623377, 15474881667376037792, 3448088038819200619, 3692020001240358871, 6444847992258394902, 8687650838094264665, 3028124591188972359, 16945232313401161629, 15547830510283682816, 3982930188609442149, 14270781928849894661, 13768475593433447867, 13815150225221307677, 8502397232429564693, 718377350715476994, 7459266877697905475, 8353375565171101521, 7807281661994435472, 16924127046922196149, 10157812396471387805, 2519858716882670232, 7384148884750265792, 8077153156180046901, 3499231286164597752, 2700106282881469611, 14679824700835879737, 14188324938219126828, 3016120398601032793, 10858152824243889420, 9412371965669250534, 4857522662584941069, 984331743838900386, 4094160040294753142, 2368635764350388458, 15101240511397838657, 15584415763303953578, 7831857200208015446, 1952643641639729063, 4184323302594028609, 16795120381104846695, 3541559381538365280, 15408472870896842474, 5628362450757896366, 16277348886873708846, 12437047172652330846, 10172715019035948149, 1999700669649752791, 6217957085626135027, 11220551167830336823, 16478747645632411810, 5437280487207382147, 11382378739613087836, 15866932785489521505, 5502694314775516684, 16440179278067648435, 15510104554374162846, 15722061259110909195, 10760687291786964354, 10736868329920212671, 4166148127664495614, 14303518358120527892, 9122250801678898571, 10028508179936801946, 216630713752669403, 10655207865433859491, 4041437116174699233, 6280982262534375348, 297501356638818866, 13976146806363377485, 13752396481560145603, 11472199956603637419, 16393728429143900496, 14752844047515986640, 1524477318846038424, 6596889774254235440, 1591982099532234960, 8065146456116391065, 3964696017750868345, 17040425970526664920, 11511165586176539991, 3443401252003315103, 16314977947073778249, 16860120454903458341, 5370503221561340846, 15362920279125264094, 2822458124714999779, 14575378304387898337, 9689406052675046032, 2872149351415175149, 13019620945255883050, 14929026760148695825, 8503417349692327218, 9677798905341573754, 828949921821462483, 16110482368362750196, 15794218816553655671, 14942910774764855088, 12026350906243760195, 13610867176871462505, 18324536557697872582, 2658962269666727629, 327225403251576027, 9207535177029277544, 8744129291351887858, 6129603385168921503, 18385497655031085907, 13024478718952333892, 14547683159720717167, 5932119629366981711, 325385464632594563, 3559879386019806291, 6629264948665231298, 14358245326238118181, 15662449672706340765, 13975503159145803297, 3609534220891499022, 4224273587485638227, 9274084767162416370, 13156843921244091998, 18284750575626858789, 14664767920489118779, 11292057742031803221, 13919998707305829132, 14473305049457001422, 9696877879685767807, 1406758246007973837, 2429517644459056881, 14361215588101587430, 11386164476149757528, 10474116023593331839, 2921165656527786564, 15604610369733358953, 12955027028676000544, 10314281035410779907, 3167047178514709947, 1088721329408346700, 17930425515478182741, 7466411836095405617, 15534027454610690575, 10879629128927506091, 11502219301371200635, 13915106894453889418, 4226784327815861027, 12335222183627106346, 3648499746356007767, 18441388887898023393, 18117929843327093625, 4237736098094830438, 14229123019768296655, 3930112058127932690, 12663879236019645778, 9281161952002617309, 4978473890680876319, 845759387067546611, 1386164484606776333, 8008554770639925512, 11159581016793288971, 18065390393740782906, 17647985458967631018, 9092379465737744314, 2914678236848656327, 4376066698447630270, 16057186499919087528, 3031333261848790078, 2926746602873431597, 7931945763526885287, 147649915388326849, 15801792398814946230, 5265900391686545347, 16173686275871890830, 7562781050481886043, 5853506575839330404, 14957980734704564792, 10944286556353523404, 1783009880614150597, 9529762028588888983, 822992871011696119, 2130074274744257510, 8000279549284809219, 3514744284158856431, 128770032569293263, 3737367602618100572, 16364836605077998543, 783266423471782696, 4569418252658970391, 11093950688157406886, 14888808512267628166, 4217786261273670948, 17047486076688645713, 14133826721458860485, 17539744882220127106, 12394675039129853905, 5757634999463277090, 9621947619435861331, 1182210208559436772, 14603391040490913939, 17481976703660945893, 14063388816234683976, 2046622692581829572, 8294969799792017441, 5293778434844788058, 17976364049306763808, 399482430848083948, 16495545010129798933, 15241340958282367519, 989828753826900814, 17616558773874893537, 2471817920909589004, 11764082277667899978, 9618755269550400950, 1240014743757147125, 1887649378641563002, 1842982574728131416, 13243531042427194002, 7688268125537013927, 3080422097287486736, 2562894809975407783, 12428984115620094788, 1355581933694478148, 9895969242586224966, 8628445623963160889, 4298916726468199239, 12773165416305557280, 5240726258301567487, 4975412836403427561, 1842172398579595303, 7812151462958058676, 17974510987263071769, 14980707022065991200, 18294903201142729875, 12911672684850242753, 8979482998667235743, 16808468362384462073, 5981317232108359798, 12373702800369335100, 16119707581920094765, 2782738549717633602, 15454155188515389391, 16495638000603654629, 16348757069342790497, 7769562861984504567, 17504300515449231559, 5557710032938318996, 11846125204788401203, 13957316349928882624, 2738350683717432043, 15738068448047700954, 6224714837294524999, 6081930777706411111, 11366312928059597928, 4355315799925031482, 12393324728734964015, 15277140291994338591, 1406052433297386355, 15859448364509213398, 1672805458341158435, 2926095111610982994, 11056431822276774455, 12083767323511977430, 3296968762229741153, 12312076899982286460, 17769284994682227273, 15349428916826953443, 1056147296359223910, 18305757538706977431, 6214378374180465222, 14279648441175008454, 17791306410319136644, 956593013486324072, 2921235772936241950, 10002890515925652606, 10399654693663712506, 6446247931049971441, 6380465770144534958, 11439178472613251620, 10131486500045494660, 3692642123868351947, 10972816599561388940, 4931112976348785580, 8213967169213816566, 15336469859637867841, 15026830342847689383, 7524668622380765825, 17309937346758783807, 372780684412666438, 5642417144539399955, 18303842993081194577, 11085303253831702827, 15658163165983586950, 8517521928922081563, 16091186344159989860, 17614656488010863910, 4736067146481515156, 13449945221374241354, 17755469346196579408, 13300502638545717375, 6611828134763118043, 14177591906740276597, 9340430243077460347, 7499765399826404087, 3409518087967832469, 9013253864026602045, 4444307427984430192, 3729283608700519712, 13642048880719588383, 16486557958022946240, 2996465014991157904, 10020049344596426576, 12302485648009883778, 8492591321344423126, 17407986443716172520, 10530482934957373052, 15740662350540828750, 1790629986901049436, 6305948377669917188, 15092985352503125323, 928505047232899787, 14404651977039851607, 7564177565277805597, 3411236815351677870, 7752718145953236134, 12315979971311483798, 12477729506691004724, 14654956300924793305, 6689803038918974388, 1540738812233000153, 13508351811701989957, 15864432023192136053, 7990997967273843917, 7424300239290765161, 39585249496300263, 3877436595063283319, 10710642254398044448, 4653804418844456375, 1232267496410380283, 3690525514009038824, 15459770765077428485, 13240346522153894145, 5674964360688390624, 16973644653010587289, 15924280764204855206, 15196708627253442662, 17596174821341373274, 16196745023027393691, 6980050627399795351, 17582264380857746637, 18170372407506856324, 12108126025631005514, 15687749089493373169, 5814107289258228434, 9381977959648494876, 15895601183088112734, 16267869075651604263, 15228381979765852785, 11949618678312581999, 4545324791131029438, 582725409406225185, 15282520250746126790, 14758446535973412711, 7605613563088071833, 1111140641057375915, 5364843095234852245, 218335432181198977, 4891472444796201742, 4564628942836375772, 15500501278323817088, 4913946328556108657, 2684786251736694229, 12090498456116310122, 5310885782157038567, 5032788439854011923, 12627401038822728242, 11869662610126430929, 17650156853043540226, 12126672500118808436, 10437658933435653256, 13133995470637873311, 4601324715591152820, 1874350460376708372, 5808688626286061164, 13777088437302430376, 5018451954762213522, 2588296738534474754, 5503414509154170711, 5230497186769951796, 13261090710400573914, 8515217303152165705, 11074538219737365303, 15481562385740613213, 12705484409881007350, 14221931471178549498, 12905633420087112297, 17337759164357146506, 14081997515778175224, 17384320185513122939, 7131793076779216692, 17483217190312403109, 900692047897995877, 14723287313048560400, 6132094372965340305, 7572797575350925726, 12725160700431903514, 380860122911632449, 1900504978569024571, 8423729759529914138, 7305587201606052334, 12446871355267313320, 4615812356515386206, 3361817115406652303, 17690418922000878428, 14632214537567910559, 2709702289926174775, 3459675155951086144, 7788364399926538150, 16043992474431955950, 15830963823784930267, 4216893617835797954, 538159724689093771, 16029152738918251363, 14444848757576686696, 12941757045272633696, 10900480525147953314, 12547307449905859302, 16001571796892398181, 407942194622690676, 13873235372903944444, 18071603799493008777, 1015646077646778622, 9387605808959554815, 11566702442022019410, 7061722181092883183, 2629032108249254109, 5271820053177594520, 12640880742139693547, 10098688629735675775, 5716304472850923064, 3312674502353063071, 7295926377425759633, 833281439103466115, 16316743519466861667, 9912050326606348167, 11651133878100804242, 18026798122431692459, 6157758321723692663, 4856021830695749349, 7074321707293278978, 10748097797809573561, 2949954440753264783, 9813922580940661152, 9949237950172138336, 15643982711269455885, 16078663425810239127, 12508044395364228880, 12920301578340189344, 15368071871011048915, 1610400750626363239, 11994736084146033126, 6042574085746186088, 4154587549267685807, 15915752367312946034, 1191196620621769193, 467437822242538360, 2836463788873877488, 10476401302029164984, 1716169985450737419, 5327734953288310341, 3994170067185955262, 884431883768190063, 11019001754831208284, 14322807384384895215, 161011537360955545, 1466223959660131656, 5227048585229497539, 12410731857504225031, 2142243279080761103, 17682826799106851430, 1792612570704179953, 14727410295243056025, 1459567192481221274, 5669760721687603135, 17507918443756456845, 10354471145847018200, 10362475129248202288, 13143844410150939443, 6861184673150072028, 18396524361124732580, 543906666394301875, 12476817828199026728, 11853496871128122868, 12747674713108891748, 7986179867749890282, 9158195177777627533, 2217320706811118570, 8631389005200569973, 5538133061362648855, 3369942850878700758, 7813559982698427184, 509051590411815948, 10197035660403006684, 13004818533162292132, 9831652587047067687, 7619315254749630976, 994412663058993407 ) : ( # 32-bit randoms 1067595299, 955945823, 477289528, 4107218783, 4228976476, 3344332714, 3355579695, 227628506, 810200273, 2591290167, 2560260675, 3242736208, 646746669, 1479517882, 4245472273, 1143372638, 3863670494, 3221021970, 1773610557, 1138697238, 1421897700, 1269916527, 2859934041, 1764463362, 3874892047, 3965319921, 72549643, 2383988930, 2600218693, 3237492380, 2792901476, 725331109, 605841842, 271258942, 715137098, 3297999536, 1322965544, 4229579109, 1395091102, 3735697720, 2101727825, 3730287744, 2950434330, 1661921839, 2895579582, 2370511479, 1004092106, 2247096681, 2111242379, 3237345263, 4082424759, 219785033, 2454039889, 3709582971, 835606218, 2411949883, 2735205030, 756421180, 2175209704, 1873865952, 2762534237, 4161807854, 3351099340, 181129879, 3269891896, 776029799, 2218161979, 3001745796, 1866825872, 2133627728, 34862734, 1191934573, 3102311354, 2916517763, 1012402762, 2184831317, 4257399449, 2899497138, 3818095062, 3030756734, 1282161629, 420003642, 2326421477, 2741455717, 1278020671, 3744179621, 271777016, 2626330018, 2560563991, 3055977700, 4233527566, 1228397661, 3595579322, 1077915006, 2395931898, 1851927286, 3013683506, 1999971931, 3006888962, 1049781534, 1488758959, 3491776230, 104418065, 2448267297, 3075614115, 3872332600, 891912190, 3936547759, 2269180963, 2633455084, 1047636807, 2604612377, 2709305729, 1952216715, 207593580, 2849898034, 670771757, 2210471108, 467711165, 263046873, 3569667915, 1042291111, 3863517079, 1464270005, 2758321352, 3790799816, 2301278724, 3106281430, 7974801, 2792461636, 555991332, 621766759, 1322453093, 853629228, 686962251, 1455120532, 957753161, 1802033300, 1021534190, 3486047311, 1902128914, 3701138056, 4176424663, 1795608698, 560858864, 3737752754, 3141170998, 1553553385, 3367807274, 711546358, 2475125503, 262969859, 251416325, 2980076994, 1806565895, 969527843, 3529327173, 2736343040, 2987196734, 1649016367, 2206175811, 3048174801, 3662503553, 3138851612, 2660143804, 1663017612, 1816683231, 411916003, 3887461314, 2347044079, 1015311755, 1203592432, 2170947766, 2569420716, 813872093, 1105387678, 1431142475, 220570551, 4243632715, 4179591855, 2607469131, 3090613241, 282341803, 1734241730, 1391822177, 1001254810, 827927915, 1886687171, 3935097347, 2631788714, 3905163266, 110554195, 2447955646, 3717202975, 3304793075, 3739614479, 3059127468, 953919171, 2590123714, 1132511021, 3795593679, 2788030429, 982155079, 3472349556, 859942552, 2681007391, 2299624053, 647443547, 233600422, 608168955, 3689327453, 1849778220, 1608438222, 3968158357, 2692977776, 2851872572, 246750393, 3582818628, 3329652309, 4036366910, 1012970930, 950780808, 3959768744, 2538550045, 191422718, 2658142375, 3276369011, 2927737484, 1234200027, 1920815603, 3536074689, 1535612501, 2184142071, 3276955054, 428488088, 2378411984, 4059769550, 3913744741, 2732139246, 64369859, 3755670074, 842839565, 2819894466, 2414718973, 1010060670, 1839715346, 2410311136, 152774329, 3485009480, 4102101512, 2852724304, 879944024, 1785007662, 2748284463, 1354768064, 3267784736, 2269127717, 3001240761, 3179796763, 895723219, 865924942, 4291570937, 89355264, 1471026971, 4114180745, 3201939751, 2867476999, 2460866060, 3603874571, 2238880432, 3308416168, 2072246611, 2755653839, 3773737248, 1709066580, 4282731467, 2746170170, 2832568330, 433439009, 3175778732, 26248366, 2551382801, 183214346, 3893339516, 1928168445, 1337157619, 3429096554, 3275170900, 1782047316, 4264403756, 1876594403, 4289659572, 3223834894, 1728705513, 4068244734, 2867840287, 1147798696, 302879820, 1730407747, 1923824407, 1180597908, 1569786639, 198796327, 560793173, 2107345620, 2705990316, 3448772106, 3678374155, 758635715, 884524671, 486356516, 1774865603, 3881226226, 2635213607, 1181121587, 1508809820, 3178988241, 1594193633, 1235154121, 326117244, 2304031425, 937054774, 2687415945, 3192389340, 2003740439, 1823766188, 2759543402, 10067710, 1533252662, 4132494984, 82378136, 420615890, 3467563163, 541562091, 3535949864, 2277319197, 3330822853, 3215654174, 4113831979, 4204996991, 2162248333, 3255093522, 2219088909, 2978279037, 255818579, 2859348628, 3097280311, 2569721123, 1861951120, 2907080079, 2719467166, 998319094, 2521935127, 2404125338, 259456032, 2086860995, 1839848496, 1893547357, 2527997525, 1489393124, 2860855349, 76448234, 2264934035, 744914583, 2586791259, 1385380501, 66529922, 1819103258, 1899300332, 2098173828, 1793831094, 276463159, 360132945, 4178212058, 595015228, 177071838, 2800080290, 1573557746, 1548998935, 378454223, 1460534296, 1116274283, 3112385063, 3709761796, 827999348, 3580042847, 1913901014, 614021289, 4278528023, 1905177404, 45407939, 3298183234, 1184848810, 3644926330, 3923635459, 1627046213, 3677876759, 969772772, 1160524753, 1522441192, 452369933, 1527502551, 832490847, 1003299676, 1071381111, 2891255476, 973747308, 4086897108, 1847554542, 3895651598, 2227820339, 1621250941, 2881344691, 3583565821, 3510404498, 849362119, 862871471, 797858058, 2867774932, 2821282612, 3272403146, 3997979905, 209178708, 1805135652, 6783381, 2823361423, 792580494, 4263749770, 776439581, 3798193823, 2853444094, 2729507474, 1071873341, 1329010206, 1289336450, 3327680758, 2011491779, 80157208, 922428856, 1158943220, 1667230961, 2461022820, 2608845159, 387516115, 3345351910, 1495629111, 4098154157, 3156649613, 3525698599, 4134908037, 446713264, 2137537399, 3617403512, 813966752, 1157943946, 3734692965, 1680301658, 3180398473, 3509854711, 2228114612, 1008102291, 486805123, 863791847, 3189125290, 1050308116, 3777341526, 4291726501, 844061465, 1347461791, 2826481581, 745465012, 2055805750, 4260209475, 2386693097, 2980646741, 447229436, 2077782664, 1232942813, 4023002732, 1399011509, 3140569849, 2579909222, 3794857471, 900758066, 2887199683, 1720257997, 3367494931, 2668921229, 955539029, 3818726432, 1105704962, 3889207255, 2277369307, 2746484505, 1761846513, 2413916784, 2685127085, 4240257943, 1166726899, 4215215715, 3082092067, 3960461946, 1663304043, 2087473241, 4162589986, 2507310778, 1579665506, 767234210, 970676017, 492207530, 1441679602, 1314785090, 3262202570, 3417091742, 1561989210, 3011406780, 1146609202, 3262321040, 1374872171, 1634688712, 1280458888, 2230023982, 419323804, 3262899800, 39783310, 1641619040, 1700368658, 2207946628, 2571300939, 2424079766, 780290914, 2715195096, 3390957695, 163151474, 2309534542, 1860018424, 555755123, 280320104, 1604831083, 2713022383, 1728987441, 3639955502, 623065489, 3828630947, 4275479050, 3516347383, 2343951195, 2430677756, 635534992, 3868699749, 808442435, 3070644069, 4282166003, 2093181383, 2023555632, 1568662086, 3422372620, 4134522350, 3016979543, 3259320234, 2888030729, 3185253876, 4258779643, 1267304371, 1022517473, 815943045, 929020012, 2995251018, 3371283296, 3608029049, 2018485115, 122123397, 2810669150, 1411365618, 1238391329, 1186786476, 3155969091, 2242941310, 1765554882, 279121160, 4279838515, 1641578514, 3796324015, 13351065, 103516986, 1609694427, 551411743, 2493771609, 1316337047, 3932650856, 4189700203, 463397996, 2937735066, 1855616529, 2626847990, 55091862, 3823351211, 753448970, 4045045500, 1274127772, 1124182256, 92039808, 2126345552, 425973257, 386287896, 2589870191, 1987762798, 4084826973, 2172456685, 3366583455, 3602966653, 2378803535, 2901764433, 3716929006, 3710159000, 2653449155, 3469742630, 3096444476, 3932564653, 2595257433, 318974657, 3146202484, 853571438, 144400272, 3768408841, 782634401, 2161109003, 570039522, 1886241521, 14249488, 2230804228, 1604941699, 3928713335, 3921942509, 2155806892, 134366254, 430507376, 1924011722, 276713377, 196481886, 3614810992, 1610021185, 1785757066, 851346168, 3761148643, 2918835642, 3364422385, 3012284466, 3735958851, 2643153892, 3778608231, 1164289832, 205853021, 2876112231, 3503398282, 3078397001, 3472037921, 1748894853, 2740861475, 316056182, 1660426908, 168885906, 956005527, 3984354789, 566521563, 1001109523, 1216710575, 2952284757, 3834433081, 3842608301, 2467352408, 3974441264, 3256601745, 1409353924, 1329904859, 2307560293, 3125217879, 3622920184, 3832785684, 3882365951, 2308537115, 2659155028, 1450441945, 3532257603, 3186324194, 1225603425, 1124246549, 175808705, 3009142319, 2796710159, 3651990107, 160762750, 1902254979, 1698648476, 1134980669, 497144426, 3302689335, 4057485630, 3603530763, 4087252587, 427812652, 286876201, 823134128, 1627554964, 3745564327, 2589226092, 4202024494, 62878473, 3275585894, 3987124064, 2791777159, 1916869511, 2585861905, 1375038919, 1403421920, 60249114, 3811870450, 3021498009, 2612993202, 528933105, 2757361321, 3341402964, 2621861700, 273128190, 4015252178, 3094781002, 1621621288, 2337611177, 1796718448, 1258965619, 4241913140, 2138560392, 3022190223, 4174180924, 450094611, 3274724580, 617150026, 2704660665, 1469700689, 1341616587, 356715071, 1188789960, 2278869135, 1766569160, 2795896635, 57824704, 2893496380, 1235723989, 1630694347, 3927960522, 428891364, 1814070806, 2287999787, 4125941184, 3968103889, 3548724050, 1025597707, 1404281500, 2002212197, 92429143, 2313943944, 2403086080, 3006180634, 3561981764, 1671860914, 1768520622, 1803542985, 844848113, 3006139921, 1410888995, 1157749833, 2125704913, 1789979528, 1799263423, 741157179, 2405862309, 767040434, 2655241390, 3663420179, 2172009096, 2511931187, 1680542666, 231857466, 1154981000, 157168255, 1454112128, 3505872099, 1929775046, 2309422350, 2143329496, 2960716902, 407610648, 2938108129, 2581749599, 538837155, 2342628867, 430543915, 740188568, 1937713272, 3315215132, 2085587024, 4030765687, 766054429, 3517641839, 689721775, 1294158986, 1753287754, 4202601348, 1974852792, 33459103, 3568087535, 3144677435, 1686130825, 4134943013, 3005738435, 3599293386, 426570142, 754104406, 3660892564, 1964545167, 829466833, 821587464, 1746693036, 1006492428, 1595312919, 1256599985, 1024482560, 1897312280, 2902903201, 691790057, 1037515867, 3176831208, 1968401055, 2173506824, 1089055278, 1748401123, 2941380082, 968412354, 1818753861, 2973200866, 3875951774, 1119354008, 3988604139, 1647155589, 2232450826, 3486058011, 3655784043, 3759258462, 847163678, 1082052057, 989516446, 2871541755, 3196311070, 3929963078, 658187585, 3664944641, 2175149170, 2203709147, 2756014689, 2456473919, 3890267390, 1293787864, 2830347984, 3059280931, 4158802520, 1561677400, 2586570938, 783570352, 1355506163, 31495586, 3789437343, 3340549429, 2092501630, 896419368, 671715824, 3530450081, 3603554138, 1055991716, 3442308219, 1499434728, 3130288473, 3639507000, 17769680, 2259741420, 487032199, 4227143402, 3693771256, 1880482820, 3924810796, 381462353, 4017855991, 2452034943, 2736680833, 2209866385, 2128986379, 437874044, 595759426, 641721026, 1636065708, 3899136933, 629879088, 3591174506, 351984326, 2638783544, 2348444281, 2341604660, 2123933692, 143443325, 1525942256, 364660499, 599149312, 939093251, 1523003209, 106601097, 376589484, 1346282236, 1297387043, 764598052, 3741218111, 933457002, 1886424424, 3219631016, 525405256, 3014235619, 323149677, 2038881721, 4100129043, 2851715101, 2984028078, 1888574695, 2014194741, 3515193880, 4180573530, 3461824363, 2641995497, 3179230245, 2902294983, 2217320456, 4040852155, 1784656905, 3311906931, 87498458, 2752971818, 2635474297, 2831215366, 3682231106, 2920043893, 3772929704, 2816374944, 309949752, 2383758854, 154870719, 385111597, 1191604312, 1840700563, 872191186, 2925548701, 1310412747, 2102066999, 1504727249, 3574298750, 1191230036, 3330575266, 3180292097, 3539347721, 681369118, 3305125752, 3648233597, 950049240, 4173257693, 1760124957, 512151405, 681175196, 580563018, 1169662867, 4015033554, 2687781101, 699691603, 2673494188, 1137221356, 123599888, 472658308, 1053598179, 1012713758, 3481064843, 3759461013, 3981457956, 3830587662, 1877191791, 3650996736, 988064871, 3515461600, 4089077232, 2225147448, 1249609188, 2643151863, 3896204135, 2416995901, 1397735321, 3460025646); # Known test values for rand() my @base_doub = ($Config{'uvsize'} == 8) ? # 64-bit randoms qw/ 0.35252031 0.51052342 0.79771733 0.39300273 0.27216673 0.72151068 0.43144703 0.38522290 0.20270676 0.58227313 0.80812143 0.83767297 0.92401619 0.84065425 0.00852052 0.13975395 0.35250930 0.71196972 0.14627395 0.17775331 0.61046382 0.49623272 0.23292425 0.25038837 0.04380664 0.43275994 0.74540936 0.33830700 0.68832616 0.68744230 0.63626548 0.85932936 0.37089670 0.50756304 0.69925960 0.83481025 0.09053196 0.09523253 0.17783108 0.78027239 0.70071054 0.51879252 0.83027285 0.92895011 0.72144803 0.18868644 0.83655674 0.20358945 0.99852143 0.88340103 0.46729949 0.96993433 0.00162682 0.46829774 0.59080423 0.54921999 0.42516462 0.54952196 0.99534722 0.04473888 0.71139235 0.91881407 0.33781561 0.45746234 0.78292126 0.69206723 0.66175448 0.07091147 0.18179208 0.38168454 0.38819527 0.42452711 0.22732724 0.16191307 0.36842667 0.13060083 0.68833248 0.60498705 0.19195304 0.26628584 0.17030858 0.23892426 0.38430236 0.28034283 0.76069020 0.21560653 0.78101667 0.90847812 0.06467974 0.18487868 0.23570471 0.29475460 0.65563767 0.10066446 0.57272419 0.88731391 0.60650995 0.96346079 0.32940100 0.29977746 0.03798193 0.18026822 0.22402746 0.45480119 0.98114604 0.25800668 0.94362433 0.17901062 0.36019313 0.45933644 0.68309457 0.28175454 0.00774729 0.77054527 0.99723413 0.59807532 0.10294164 0.32429228 0.54928986 0.18410980 0.08441555 0.14230333 0.58892064 0.94030475 0.35378784 0.77584320 0.71222448 0.83565208 0.47309248 0.23810761 0.74408520 0.08891527 0.09729786 0.38377368 0.05092308 0.69065638 0.10449489 0.45050670 0.92209534 0.80083714 0.27902692 0.26897142 0.50650468 0.80111472 0.54590012 0.96406097 0.63779553 0.81054357 0.75369248 0.47473037 0.89100315 0.89395984 0.09985519 0.34087631 0.22293557 0.24375510 0.31764191 0.04076993 0.06160830 0.41333434 0.11883030 0.04548820 0.01008040 0.25336184 0.07325432 0.49860151 0.07148695 0.89483338 0.87054457 0.15116809 0.59650469 0.47487776 0.43490298 0.36684681 0.16470796 0.76865078 0.42920071 0.20545481 0.87615922 0.80332404 0.36462506 0.49571309 0.51904488 0.15534589 0.43719893 0.16562157 0.37290862 0.91842631 0.21310523 0.87849154 0.18532269 0.81713354 0.52182344 0.51845619 0.96261204 0.18758718 0.68897600 0.61484764 0.46752993 0.05865458 0.11614359 0.90386866 0.45781805 0.70649579 0.50917048 0.21210656 0.97818608 0.00788342 0.61375222 0.67366318 0.24197878 0.66177985 0.10463932 0.67390799 0.50025262 0.88332650 0.77966851 0.13403622 0.54357114 0.97664854 0.06540961 0.24013176 0.67234032 0.91347883 0.35486839 0.87207865 0.43036581 0.23652488 0.81238450 0.72058432 0.42239916 0.80265764 0.03552838 0.61939480 0.50972420 0.21053832 0.59952743 0.36821802 0.45659617 0.12529468 0.76941623 0.99878168 0.08602783 0.81825937 0.39350710 0.86090923 0.36090230 0.75628888 0.45036982 0.44602266 0.20595631 0.62241953 0.36777732 0.47523727 0.50248178 0.73570362 0.48237781 0.45590948 0.73580783 0.96403851 0.94586342 0.48819868 0.48102038 0.94618182 0.90279924 0.78396650 0.85182389 0.92149394 0.32679198 0.83554856 0.28320609 0.34598409 0.82090005 0.40177958 0.38888785 0.77873931 0.23297931 0.75329335 0.30770340 0.71417540 0.68939065 0.36577776 0.50784857 0.50928090 0.02552055 0.85999075 0.26692089 0.01402799 0.67550392 0.48305605 0.74608351 0.63408891 0.58904230 0.44337996 0.42174728 0.74041679 0.72719148 0.19801992 0.66263633 0.10381594 0.32818760 0.68369661 0.56076212 0.68681921 0.91616269 0.39836106 0.39685027 0.97507945 0.91010563 0.27447360 0.95538357 0.76758522 0.60091060 0.37734461 0.82948248 0.06598078 0.50147615 0.08417763 0.18910044 0.51661735 0.55011011 0.64888175 0.82986845 0.15126656 0.92649390 0.25494941 0.73275293 0.94184393 0.84755226 0.45921936 0.72934054 0.43722403 0.34305596 0.10827860 0.29026676 0.01935431 0.46668573 0.83247509 0.26349603 0.01938542 0.43222250 0.18109983 0.29337450 0.16721917 0.94751650 0.67795254 0.56666228 0.20699452 0.23247262 0.19138610 0.73495506 0.85893600 0.83411526 0.93689655 0.91804752 0.99352333 0.03207550 0.28386071 0.48029543 0.18736013 0.31736452 0.72542230 0.57530912 0.04229918 0.84798296 0.21886935 0.98655615 0.52243102 0.22611020 0.42975741 0.21726739 0.10912048 0.96684473 0.01092456 0.12461901 0.57989070 0.39848707 0.06330277 0.62826828 0.01159081 0.23157320 0.64690912 0.44876902 0.04463930 0.18933780 0.21284518 0.61363480 0.67144845 0.38625586 0.75719122 0.40361050 0.26708873 0.54534727 0.90174015 0.58654140 0.44885346 0.35505544 0.65317830 0.26074572 0.39472912 0.54366914 0.75020660 0.76113614 0.24595582 0.03941247 0.60356153 0.23615721 0.01603475 0.72432457 0.39837424 0.04195329 0.81561058 0.34208440 0.00513953 0.92826234 0.11410393 0.86692030 0.25238726 0.98258626 0.53353856 0.72269001 0.71850984 0.66829681 0.03540769 0.01676450 0.23557835 0.78758497 0.85969589 0.14673207 0.28013860 0.17796942 0.69924087 0.44663597 0.62112513 0.44079883 0.48995231 0.18411497 0.18440877 0.74016388 0.28845694 0.22969080 0.76851164 0.15551473 0.28980810 0.40906710 0.47619039 0.72611392 0.55802939 0.69365597 0.85736313 0.83343150 0.21324760 0.45327806 0.33053855 0.98198279 0.53279389 0.76877035 0.20548656 0.37065042 0.59026910 0.67418036 0.23585843 0.98156397 0.27849804 0.56198954 0.68752287 0.30073445 0.69348664 0.72515585 0.40629047 0.09320027 0.24334978 0.91407662 0.97226538 0.33904970 0.01717092 0.60155725 0.03001652 0.50979706 0.80531036 0.17450719 0.84984399 0.00498130 0.51636405 0.14080868 0.62289701 0.07853030 0.70567541 0.79844050 0.63766566 0.03559031 0.40994535 0.08423996 0.00389626 0.50608347 0.19622681 0.90537903 0.75458034 0.75102094 0.81491673 0.92925931 0.38074332 0.54817053 0.72593246 0.02146791 0.57990460 0.87921074 0.59913886 0.66726893 0.24269154 0.73344575 0.71826052 0.92313935 0.05212996 0.93771536 0.69489385 0.57581887 0.48106155 0.06808800 0.33633940 0.69142320 0.46566781 0.70654143 0.16541368 0.76257631 0.82777900 0.62958327 0.34757935 0.10891487 0.79912728 0.01156543 0.23111261 0.58535640 0.87461956 0.21723454 0.80409615 0.33169686 0.72800785 0.31218099 0.13729737 0.41637635 0.01234597 0.58313811 0.66746028 0.05105595 0.14930937 0.56044864 0.76196851 0.98800104 0.37075949 0.88740864 0.40697115 0.96598278 0.86013661 0.85386784 0.23986516 0.39027464 0.59593927 0.00161530 0.31768197 0.65702729 0.66461914 0.62937471 0.92120758 0.87578958 0.37539860 0.59182615 0.12092214 0.55130437 0.86365117 0.38725162 0.28757657 0.42803199 0.39014405 0.50253853 0.85306128 0.92018995 0.71421618 0.54236780 0.96221157 0.22956898 0.96519876 0.06694102 0.11915854 0.01354308 0.24720070 0.71671739 0.00604305 0.65012352 0.71151390 0.46616159 0.99228224 0.20684576 0.62941006 0.84535326 0.30678993 0.55264568 0.50094784 0.39409122 0.15479416 0.36536318 0.51925656 0.65567178 0.67255519 0.55089659 0.42194295 0.27172413 0.79540954 0.71594806 0.88372598 0.29179452 0.66411306 0.57064687 0.42494633 0.73389255 0.12097313 0.53338622 0.38493233 0.79348021 0.01851341 0.58594454 0.88396240 0.04410730 0.67419924 0.62770011 0.64644200 0.40335135 0.17952644 0.55564678 0.56643922 0.37715015 0.87092180 0.56726159 0.34011210 0.13661819 0.11474177 0.93930097 0.48549077 0.28484289 0.13374371 0.40966056 0.73662873 0.37355323 0.65216092 0.27372469 0.56032082 0.14882684 0.95462890 0.17090266 0.92374766 0.98368259 0.68448367 0.02872548 0.68598279 0.04601084 0.17170501 0.08906644 0.23730372 0.02929037 0.38566261 0.68957569 0.53021050 0.44200157 0.32085701 0.72520053 0.17454174 0.19676599 0.88243877 0.87030228 0.15124486 0.78670160 0.51731632 0.56674531 0.20910664 0.84962640 0.05220467 0.91783159 0.19138968 0.68126378 0.79574471 0.14910848 0.28030331 0.98067264 0.31263980 0.67448964 0.69266650 0.40033551 0.22789781 0.78317066 0.55815261 0.11247054 0.47337901 0.46310033 0.53192452 0.56164078 0.41750378 0.43880622 0.69739327 0.11092778 0.18333765 0.67222441 0.12789170 0.88316806 0.37891271 0.14935268 0.64522185 0.93902079 0.62481092 0.21794927 0.71535266 0.62169579 0.65147153 0.01411645 0.96413465 0.01021578 0.50605180 0.51595053 0.03308040 0.01497870 0.07809658 0.35743383 0.58079701 0.11785557 0.89568677 0.38793964 0.37117709 0.13994133 0.11032813 0.99998594 0.06695042 0.79774786 0.11093584 0.23879095 0.85918615 0.16109636 0.63479696 0.75023359 0.29061187 0.53764772 0.30652318 0.51387302 0.81620973 0.82433610 0.18302488 0.79048957 0.07598187 0.27887732 0.37061042 0.36441016 0.93736882 0.77480946 0.02269132 0.40309874 0.16427650 0.13969296 0.57605029 0.00242426 0.56626691 0.84390990 0.87455806 0.12321023 0.87561663 0.60431578 0.35880839 0.50426282 0.50697689 0.06631164 0.14976092 0.89356018 0.91473662 0.04235237 0.50073724 0.75969690 0.91743994 0.79352335 0.58078351 0.91819984 0.53520520 0.18267367 0.05608828 0.68315721 0.27264599 0.41245634 0.69706222 0.69666203 0.08967342 0.64081905 0.22576796 0.69315628 0.53981640 0.76059129 0.56712344 0.94318621 0.44081094 0.31699284 0.29477911 0.80069824 0.28366921 0.96718081 0.85345644 0.11681215 0.47600710 0.33448255 0.31217271 0.35469241 0.59511650 0.49583692 0.48922303 0.20215259 0.60159380 0.17882055 0.77601258 0.71020391 0.41833503 0.71522856 0.87534517 0.43703394 0.43056077 0.64828071 0.43069441 0.39356849 0.32063367 0.92788963 0.16878266 0.56762591 0.56042446 0.84958464 0.79408949 0.08220340 0.13922856 0.82529019 0.27134959 0.00278080 0.66192389 0.01782933 0.95404763 0.50787645 0.85320521 0.83690362 0.83771227 0.46268665 0.31716742 0.01716647 0.68264674 0.01789888 0.30446846 0.14942271 0.26982182 0.74933947 0.50394161 0.78444542 0.40009256 0.40333422 0.16627342 0.01898760 0.04221829 0.77960213 0.66230976 0.56015996 0.49535426 0.38536259 0.40406773 0.99930568 0.00857945 0.16158390 0.64805163 0.20237524 0.59106326 0.76968277 0.96887042 0.29264851 0.97373775 0.16767633 0.33014482 0.27426548 0.10947014 0.75920652 0.37757457 0.13125207 0.00826451 0.96684342 0.69362226 0.22763554 0.20717541 0.42112268 0.22803038 0.33481806 0.14968742 0.71598558 0.55126711 0.64518015 0.65170197 0.89103003 0.72728361 0.24485454 0.09410780 0.79818029 0.54212409 0.17790462 0.64442619 0.62193511 0.51193256 0.02848781 0.05719604 0.45795152 0.03219332 0.28310254 0.85746127 0.64890240 0.20658356 0.50946422 0.80432490 0.08354468 0.09222723 0.67455943 0.44638771 0.76366629 0.99677267 0.89311242 0.11627279 0.09181302 0.44767077 0.16448724 0.26005539 0.28670391 0.52465703 0.43598116 0.41869096 0.98043420 0.01497272 0.51791571 0.61825308 0.85503436 0.63025655 0.02719292 0.09865668 0.30321729 0.56998039 0.14946350 0.64823918 0.19931639 0.14623555 0.54169913 0.68944135 0.73551005 0.46743658 0.04109096 0.26625801 0.09537298 0.98207890 0.58109721 0.70793680 0.84379365 0.42774726 0.12653597 0.08566633 0.53366781 0.33960092 0.11036831 0.84464510 0.16493476 0.92493443 0.87640673 0.52727644 0.57181349 0.65071340 0.00978637 0.31700693 0.69148222 0.85063311 0.06781819 0.30794534 0.65541667 0.16400484 0.06886223 0.96227205 0.09633060 0.34513153 0.31013900 0.78165882 0.39583699 0.86327936 0.69269199 0.11016575 0.67358419 0.81775427 0.50052824 0.30068582 0.16606837 0.62243724 0.47863741 0.68796498 0.31526949 0.41180883 0.23022147 0.82342139 0.83003381 0.53571829 0.41081533 0.48600142/ : # 32-bit randoms qw/ 0.76275443 0.99000644 0.98670464 0.10143112 0.27933125 0.69867227 0.94218740 0.03427201 0.78842173 0.28180608 0.92179002 0.20785655 0.54534773 0.69644020 0.38107718 0.23978165 0.65286910 0.07514568 0.22765211 0.94872929 0.74557914 0.62664415 0.54708246 0.90959343 0.42043116 0.86334511 0.19189126 0.14718544 0.70259889 0.63426346 0.77408121 0.04531601 0.04605807 0.88595519 0.69398270 0.05377184 0.61711170 0.05565708 0.10133577 0.41500776 0.91810699 0.22320679 0.23353705 0.92871862 0.98897234 0.19786706 0.80558809 0.06961067 0.55840445 0.90479405 0.63288060 0.95009721 0.54948447 0.20645042 0.45000959 0.87050869 0.70806991 0.19406895 0.79286390 0.49332866 0.78483914 0.75145146 0.12341941 0.42030252 0.16728160 0.59906494 0.37575460 0.97815160 0.39815952 0.43595080 0.04952478 0.33917805 0.76509902 0.61034321 0.90654701 0.92915732 0.85365931 0.18812377 0.65913428 0.28814566 0.59476081 0.27835931 0.60722542 0.68310435 0.69387186 0.03699800 0.65897714 0.17527003 0.02889304 0.86777366 0.12352068 0.91439461 0.32022990 0.44445731 0.34903686 0.74639273 0.65918367 0.92492794 0.31872642 0.77749724 0.85413832 0.76385624 0.32744211 0.91326300 0.27458185 0.22190155 0.19865383 0.31227402 0.85321225 0.84243342 0.78544200 0.71854080 0.92503892 0.82703064 0.88306297 0.47284073 0.70059042 0.48003761 0.38671694 0.60465770 0.41747204 0.47163243 0.72750808 0.65830223 0.10955369 0.64215401 0.23456345 0.95944940 0.72822249 0.40888451 0.69980355 0.26677428 0.57333635 0.39791582 0.85377858 0.76962816 0.72004885 0.90903087 0.51376506 0.37732665 0.12691640 0.71249738 0.81217908 0.37037313 0.32772374 0.14238259 0.05614811 0.74363008 0.39773267 0.94859135 0.31452454 0.11730313 0.62962618 0.33334237 0.45547255 0.10089665 0.56550662 0.60539371 0.16027624 0.13245301 0.60959939 0.04671662 0.99356286 0.57660859 0.40269560 0.45274629 0.06699735 0.85064246 0.87742744 0.54508392 0.87242982 0.29321385 0.67660627 0.68230715 0.79052073 0.48592054 0.25186266 0.93769755 0.28565487 0.47219067 0.99054882 0.13155240 0.47110470 0.98556600 0.84397623 0.12875246 0.90953202 0.49129015 0.23792727 0.79481194 0.44337770 0.96564297 0.67749118 0.55684872 0.27286897 0.79538393 0.61965356 0.22487929 0.02226018 0.49248200 0.42247006 0.91797788 0.99250134 0.23449967 0.52531508 0.10246337 0.78685622 0.34310922 0.89892996 0.40454552 0.68608407 0.30752487 0.83601319 0.54956031 0.63777550 0.82199797 0.24890696 0.48801123 0.48661910 0.51223987 0.32969635 0.31075073 0.21393155 0.73453207 0.15565705 0.58584522 0.28976728 0.97621478 0.61498701 0.23891470 0.28518540 0.46809591 0.18371914 0.37597910 0.13492176 0.66849449 0.82811466 0.56240330 0.37548956 0.27562998 0.27521910 0.74096121 0.77176757 0.13748143 0.99747138 0.92504502 0.09175241 0.21389176 0.21766512 0.31183245 0.23271221 0.21207367 0.57903312 0.77523344 0.13242613 0.31037988 0.01204835 0.71652949 0.84487594 0.14982178 0.57423142 0.45677888 0.48420169 0.53465428 0.52667473 0.46880526 0.49849733 0.05670710 0.79022476 0.03872047 0.21697212 0.20443086 0.28949326 0.81678186 0.87629474 0.92297064 0.27373097 0.84625273 0.51505586 0.00582792 0.33295971 0.91848412 0.92537226 0.91760033 0.07541125 0.71745848 0.61158698 0.00941650 0.03135554 0.71527471 0.24821915 0.63636652 0.86159918 0.26450229 0.60160194 0.35557725 0.24477500 0.07186456 0.51757096 0.62120362 0.97981062 0.69954667 0.21065616 0.13382753 0.27693186 0.59644095 0.71500764 0.04110751 0.95730081 0.91600724 0.47704678 0.26183479 0.34706971 0.07545431 0.29398385 0.93236070 0.60486023 0.48015011 0.08870451 0.45548581 0.91872718 0.38142712 0.10668643 0.01397541 0.04520355 0.93822273 0.18011940 0.57577277 0.91427606 0.30911399 0.95853475 0.23611214 0.69619891 0.69601980 0.76765372 0.58515930 0.49479057 0.11288752 0.97187699 0.32095365 0.57563608 0.40760618 0.78703383 0.43261152 0.90877651 0.84686346 0.10599030 0.72872803 0.19315490 0.66152912 0.10210518 0.06257876 0.47950688 0.47062066 0.72701157 0.48915116 0.66110261 0.60170685 0.24516994 0.12726050 0.03451185 0.90864994 0.83494878 0.94800035 0.91035206 0.14480751 0.88458997 0.53498312 0.15963215 0.55378627 0.35171349 0.28719791 0.09097957 0.00667896 0.32309622 0.87561479 0.42534520 0.91748977 0.73908457 0.41793223 0.99279792 0.87908370 0.28458072 0.59132853 0.98672190 0.28547393 0.09452165 0.89910674 0.53681109 0.37931425 0.62683489 0.56609740 0.24801549 0.52948179 0.98328855 0.66403523 0.55523786 0.75886666 0.84784685 0.86829981 0.71448906 0.84670080 0.43922919 0.20771016 0.64157936 0.25664246 0.73055695 0.86395782 0.65852932 0.99061803 0.40280575 0.39146298 0.07291005 0.97200603 0.20555729 0.59616495 0.08138254 0.45796388 0.33681125 0.33989127 0.18717090 0.53545811 0.60550838 0.86520709 0.34290701 0.72743276 0.73023855 0.34195926 0.65019733 0.02765254 0.72575740 0.32709576 0.03420866 0.26061893 0.56997511 0.28439072 0.84422744 0.77637570 0.55982168 0.06720327 0.58449067 0.71657369 0.15819609 0.58042821 0.07947911 0.40193792 0.11376012 0.88762938 0.67532159 0.71223735 0.27829114 0.04806073 0.21144026 0.58830274 0.04140071 0.43215628 0.12952729 0.94668759 0.87391019 0.98382450 0.27750768 0.90849647 0.90962737 0.59269720 0.96102026 0.49544979 0.32007095 0.62585546 0.03119821 0.85953001 0.22017528 0.05834068 0.80731217 0.53799961 0.74166948 0.77426600 0.43938444 0.54862081 0.58575513 0.15886492 0.73214332 0.11649057 0.77463977 0.85788827 0.17061997 0.66838056 0.96076133 0.07949296 0.68521946 0.89986254 0.05667410 0.12741385 0.83470977 0.63969104 0.46612929 0.10200126 0.01194925 0.10476340 0.90285217 0.31221221 0.32980614 0.46041971 0.52024973 0.05425470 0.28330912 0.60426543 0.00598243 0.97244013 0.21135841 0.78561597 0.78428734 0.63422849 0.32909934 0.44771136 0.27380750 0.14966697 0.18156268 0.65686758 0.28726350 0.97074787 0.63676171 0.96649494 0.24526295 0.08297372 0.54257548 0.03166785 0.33735355 0.15946671 0.02102971 0.46228045 0.11892296 0.33408336 0.29875681 0.29847692 0.73767569 0.02080745 0.62980060 0.08082293 0.22993106 0.25031439 0.87787525 0.45150053 0.13673441 0.63407612 0.97907688 0.52241942 0.50580158 0.06273902 0.05270283 0.77031811 0.05113352 0.24393329 0.75036441 0.37436336 0.22877652 0.59975358 0.85707591 0.88691457 0.85547165 0.36641027 0.58720133 0.45462835 0.09243817 0.32981586 0.07820411 0.25421519 0.36004706 0.60092307 0.46192412 0.36758683 0.98424170 0.08019934 0.68594024 0.45826386 0.29962317 0.79365413 0.89231296 0.49478547 0.87645944 0.23590734 0.28106737 0.75026285 0.08136314 0.79582424 0.76010628 0.82792971 0.27947652 0.72482861 0.82191216 0.46171689 0.79189752 0.96043686 0.51609668 0.88995725 0.28998963 0.55191845 0.03934737 0.83033700 0.49553013 0.98009549 0.19017594 0.98347750 0.33452066 0.87144372 0.72106301 0.71272114 0.71465963 0.88361677 0.85571283 0.73782329 0.20920458 0.34855153 0.46766817 0.02780062 0.74898344 0.03680650 0.44866557 0.77426312 0.91025891 0.25195236 0.87319953 0.63265037 0.25552148 0.27422476 0.95217406 0.39281839 0.66441573 0.09158900 0.94515992 0.07800798 0.02507888 0.39901462 0.17382573 0.12141278 0.85502334 0.19902911 0.02160210 0.44460522 0.14688742 0.68020336 0.71323733 0.60922473 0.95400380 0.99611159 0.90897777 0.41073520 0.66206647 0.32064685 0.62805003 0.50677209 0.52690101 0.87473387 0.73918362 0.39826974 0.43683919 0.80459118 0.32422684 0.01958019 0.95319576 0.98326137 0.83931735 0.69060863 0.33671416 0.68062550 0.65152380 0.33392969 0.03451730 0.95227244 0.68200635 0.85074171 0.64721009 0.51234433 0.73402047 0.00969637 0.93835057 0.80803854 0.31485260 0.20089527 0.01323282 0.59933780 0.31584602 0.20209563 0.33754800 0.68604181 0.24443049 0.19952227 0.78162632 0.10336988 0.11360736 0.23536740 0.23262256 0.67803776 0.48749791 0.74658435 0.92156640 0.56706407 0.36683221 0.99157136 0.23421374 0.45183767 0.91609720 0.85573315 0.37706276 0.77042618 0.30891908 0.40709595 0.06944866 0.61342849 0.88817388 0.58734506 0.98711323 0.14744128 0.63242656 0.87704136 0.68347125 0.84446569 0.43265239 0.25146321 0.04130111 0.34259839 0.92697368 0.40878778 0.56990338 0.76204273 0.19820348 0.66314909 0.02482844 0.06669207 0.50205581 0.26084093 0.65139159 0.41650223 0.09733904 0.56344203 0.62651696 0.67332139 0.58037374 0.47258086 0.21010758 0.05713135 0.89390629 0.10781246 0.32037450 0.07628388 0.34227964 0.42190597 0.58201860 0.77363549 0.49595133 0.86031236 0.83906769 0.81098161 0.26694195 0.14215941 0.88210306 0.53634237 0.12090720 0.82480459 0.75930318 0.31847147 0.92768077 0.01037616 0.56201727 0.88107122 0.35925856 0.85860762 0.61109408 0.70408301 0.58434977 0.92192494 0.62667915 0.75988365 0.06858761 0.36156496 0.58057195 0.13636150 0.57719713 0.59340255 0.63530602 0.22976282 0.71915530 0.41162531 0.63979565 0.09931342 0.79344045 0.10893790 0.84450224 0.23122236 0.99485593 0.73637397 0.17276368 0.13357764 0.74965804 0.64991737 0.61990341 0.41523170 0.05878239 0.05687301 0.05497131 0.42868366 0.42571090 0.25810502 0.89642955 0.30439758 0.39310223 0.11357431 0.04288255 0.23397550 0.11200634 0.85621396 0.89733974 0.37508865 0.42077265 0.68597384 0.72781399 0.19296476 0.61699087 0.31667128 0.67756410 0.00177323 0.05725176 0.79474693 0.18885238 0.06724856 0.68193156 0.42202167 0.22082041 0.28554673 0.64995708 0.87851940 0.29124547 0.61009521 0.87374537 0.05743712 0.69902994 0.81925115 0.45653873 0.37236821 0.31118709 0.52734307 0.39672836 0.38185294 0.30163915 0.17374510 0.04913278 0.90404879 0.25742801 0.58266467 0.97663209 0.79823377 0.36437958 0.15206043 0.26529938 0.22690047 0.05839021 0.84721160 0.18622435 0.37809403 0.55706977 0.49828704 0.47659049 0.24289680 0.88477595 0.07807463 0.56245739 0.73490635 0.21099431 0.13164942 0.75840044 0.66877037 0.28988183 0.44046090 0.24967434 0.80048356 0.26029740 0.30416821 0.64151867 0.52067892 0.12880774 0.85465381 0.02690525 0.19149288 0.49630295 0.79682619 0.43566145 0.00288078 0.81484193 0.03763639 0.68529083 0.01339574 0.38405386 0.30537067 0.22994703 0.44000045 0.27217985 0.53831243 0.02870435 0.86282045 0.61831306 0.09164956 0.25609707 0.07445781 0.72185784 0.90058883 0.30070608 0.94476583 0.56822213 0.21933909 0.96772793 0.80063440 0.26307906 0.31183306 0.16501252 0.55436179 0.68562285 0.23829083 0.86511559 0.57868991 0.81888344 0.20126869 0.93172350 0.66028129 0.21786948 0.78515828 0.10262106 0.35390326 0.79303876 0.63427924 0.90479631 0.31024934 0.60635447 0.56198079 0.63573813 0.91854197 0.99701497 0.83085849 0.31692291 0.01925964 0.97446405 0.98751283 0.60944293 0.13751018 0.69519957 0.68956636 0.56969015 0.46440193 0.88341765 0.36754434 0.89223647 0.39786427 0.85055280 0.12749961 0.79452122 0.89449784 0.14567830 0.45716830 0.74822309 0.28200437 0.42546044 0.17464886 0.68308746 0.65496587 0.52935411 0.12736159 0.61523955 0.81590528 0.63107864 0.39786553 0.20102294 0.53292914 0.75485590 0.59847044 0.32861691 0.12125866 0.58917183 0.07638293 0.86845380 0.29192617 0.03989733 0.52180460 0.32503407 0.64071852 0.69516575 0.74254998 0.54587026 0.48713246 0.32920155 0.08719954 0.63497059 0.54328459 0.64178757 0.45583809 0.70694291 0.85212760 0.86074305 0.33163422 0.85739792 0.59908488 0.74566046 0.72157152/; ### - Standalone PRNG - ### # Set predetermined seed for verification test my @base_seed = ($Config{'uvsize'} == 8) ? (0x12345, 0x23456, 0x34567, 0x45678) : (0x123, 0x234, 0x345, 0x456); sub myseed { my $seed = $_[0]; my $need = $_[1]; # Ignored push(@$seed, @base_seed); } eval { srand(\&myseed); }; if (! ok(! $@, 'srand(\&sub) works')) { diag('srand(\&sub) died: ' . $@); } # Check for warnings @WARN = grep { $_ !~ /Partial seed/ } @WARN; if (! ok(! @WARN, 'Acquired seed data')) { diag('Seed warnings: ' . join(' | ', @WARN)); } undef(@WARN); # Fetch and verify seed my @seed; eval { @seed = get_seed(); }; if (! ok(! $@, 'get_seed() works')) { diag('get_seed() died: ' . $@); } is_deeply(\@base_seed, \@seed, 'Seed is correct'); # Create PRNG object using state of standalone PRNG my $prng2; eval { my @state = get_state(); $prng2 = Math::Random::MT::Auto->new('STATE' => \@state); }; if (! ok(! $@, 'SA cloning works')) { diag('SA cloning died: ' . $@); } isa_ok($prng2, 'Math::Random::MT::Auto'); can_ok($prng2, qw(rand irand gaussian exponential erlang poisson binomial shuffle srand get_seed set_seed get_state set_state)); # Verify hidden 'init' subroutine if ($] > 5.006) { eval { $prng2->_init({}); }; if (my $e = OIO->caught()) { ok($e->error =~ /hidden/i, '->_init() hidden: ' . $e->error); } else { ok($@, '->_init() visible - this is bad'); } } else { ok(1, 'SKIPPED'); } # Test for known output from PRNG for irand() my @test_rint; for (1 .. 500) { push(@test_rint, irand()); } # Save the current PRNG state my @state; eval { @state = get_state(); }; ok(! $@, 'get_state() died: ' . $@); # Reset the seed eval { set_seed(\@seed); }; ok(! $@, 'set_seed() died: ' . $@); # Test again with reset seed my @test2_rint; for (1 .. 1000) { push(@test2_rint, irand()); } is_deeply(\@test2_rint, \@base_rint, '1000 ints'); # Restore previous state eval { set_state(\@state); }; ok(! $@, 'set_state() died: ' . $@); # Continue from previous state for (501 .. 1000) { push(@test_rint, Math::Random::MT::Auto::irand()); } is_deeply(\@test_rint, \@base_rint, '500 ints'); # Test for known output from PRNG # for rand() and Math::Random::MT::Auto::rand() my @test_doub; for (1 .. 500) { push(@test_doub, sprintf('%0.8f', rand())); } for (501 .. 1000) { push(@test_doub, sprintf('%0.8f', Math::Random::MT::Auto::rand())); } is_deeply(\@test_doub, \@base_doub, '1000 doubles'); ### - OO INterface - ### # Create binary seed file if (open(FH, '>seed_data.tmp')) { if ($Config{'uvsize'} == 8) { print(FH pack('Q4', 0x12345, 0x23456, 0x34567, 0x45678)); } else { print(FH pack('L4', 0x123, 0x234, 0x345, 0x456)); } close(FH); } else { diag('Failure writing seed to file'); } # Create PRNG object my $prng; eval { $prng = Math::Random::MT::Auto->new('src' => 'seed_data.tmp'); }; unlink('seed_data.tmp'); if (! ok(! $@, '->new works')) { diag('->new died: ' . $@); } isa_ok($prng, 'Math::Random::MT::Auto'); # Check for warnings @WARN = grep { $_ !~ /exhausted/ && $_ !~ /Partial seed/ } @WARN; if (! ok(! @WARN, 'Acquired seed data')) { diag('Seed warnings: ' . join(' | ', @WARN)); } undef(@WARN); # Fetch and verify seed eval { @seed = @{$prng->get_seed()}; }; if (! ok(! $@, '$prng->get_seed() works')) { diag('$prng->get_seed() died: ' . $@); } is_deeply(\@base_seed, \@seed, 'Seed is correct'); # Test for known output from PRNG for $prng->irand() @test_rint = (); for (1 .. 500) { push(@test_rint, $prng->irand()); } # Save the current PRNG state eval { @state = $prng->get_state(); }; ok(! $@, '$prng->get_state() died: ' . $@); # Reset the seed eval { $prng->set_seed(\@seed); }; ok(! $@, '$prng->set_seed() died: ' . $@); # Test again with reset seed @test2_rint = (); for (1 .. 1000) { push(@test2_rint, $prng->irand()); } is_deeply(\@test2_rint, \@base_rint, '1000 ints'); # Restore previous state eval { $prng->set_state(\@state); }; ok(! $@, '$prng->set_state() died: ' . $@); # Continue from previous state for (501 .. 1000) { push(@test_rint, $prng->irand()); } is_deeply(\@test_rint, \@base_rint, '1000 ints'); # Test for known output from PRNG for $prng->rand() @test_doub = (); for (1 .. 1000) { push(@test_doub, sprintf('%0.8f', $prng->rand())); } is_deeply(\@test_doub, \@base_doub, '1000 doubles'); ### - Cloning Tests - ### # Create PRNG object using state of another PRNG object my $prng3; eval { $prng3 = $prng2->clone(); }; unlink('seed_data.tmp'); if (! ok(! $@, '->clone() works')) { diag('->clone() died: ' . $@); } isa_ok($prng3, 'Math::Random::MT::Auto'); # Test OO copy of SA PRNG @test_rint = (); for (1 .. 1000) { push(@test_rint, $prng2->irand()); } is_deeply(\@test_rint, \@base_rint, '1000 ints'); # Test OO copy of OO PRNG @test_rint = (); for (1 .. 1000) { push(@test_rint, $prng3->irand()); } is_deeply(\@test_rint, \@base_rint, '1000 ints'); ### Test 'readonly' if ($] >= 5.008003) { eval{ my $old = $$prng; $$prng = 99; $$prng = $old; # Just in case }; ok($@, "Readonly: $@"); } else { ok(1, 'SKIPPED'); } exit(0); # EOF Math-Random-MT-Auto-6.23/t/05-dev_urandom.t0000644000175000001440000000232713377133756017663 0ustar jdheddenusers# Tests for /dev/urandom use strict; use warnings; use Test::More; my @WARN; BEGIN { # Warning signal handler $SIG{__WARN__} = sub { push(@WARN, @_); }; } if (! -e '/dev/urandom') { plan skip_all => '/dev/urandom not available'; } else { plan tests => 92; } use_ok('Math::Random::MT::Auto', qw(rand irand), '/dev/urandom'); can_ok('main', qw(rand irand)); # Check for warnings if (! ok(! @WARN, 'Acquired seed data')) { diag('Seed warnings: ' . join(' | ', @WARN)); } undef(@WARN); my ($rn, @rn); # Test rand() eval { $rn = rand(); }; ok(! $@, 'rand() died: ' . $@); ok(defined($rn), 'Got a random number'); ok(Scalar::Util::looks_like_number($rn), 'Is a number: ' . $rn); ok($rn >= 0.0 && $rn < 1.0, 'In range: ' . $rn); # Test several values from irand() for my $ii (0 .. 9) { eval { $rn[$ii] = irand(); }; ok(! $@, 'irand() died: ' . $@); ok(defined($rn[$ii]), 'Got a random number'); ok(Scalar::Util::looks_like_number($rn[$ii]), 'Is a number: ' . $rn[$ii]); ok(int($rn[$ii]) == $rn[$ii], 'Integer: ' . $rn[$ii]); for my $jj (0 .. $ii-1) { ok($rn[$jj] != $rn[$ii], 'Randomized'); } } exit(0); # EOF Math-Random-MT-Auto-6.23/t/12-rn_info.t0000644000175000001440000000305613377133756017010 0ustar jdheddenusers# Tests for RandomNumbers.info site use strict; use warnings; use Test::More; # Warning signal handler my @WARN; BEGIN { $SIG{__WARN__} = sub { push(@WARN, @_); }; } use Math::Random::MT::Auto qw(rand irand), 'rn_info'; if (grep(/^Failure creating user-agent/, @WARN)) { plan skip_all => 'LWP::Useragent not available'; } elsif (grep(/^Failure contacting/, @WARN)) { plan skip_all => 'RandomNumbers.info not reachable'; } elsif ((grep(/^Failure getting data/, @WARN)) || (grep(/^No seed data/, @WARN))) { plan skip_all => 'Seed not obtained from RandomNumbers.info'; } plan tests => 91; @WARN = grep(!/^Partial seed/, @WARN); @WARN = grep(!/only once/, @WARN); # Ingnore 'once' warnings from other modules ok(! @WARN, 'No warnings'); diag('Warnings: ' . join(' | ', @WARN)) if (@WARN); can_ok('main', qw(rand irand)); # Test rand() my ($rn, @rn); eval { $rn = rand(); }; ok(! $@, 'rand() died: ' . $@); ok(defined($rn), 'Got a random number'); ok(Scalar::Util::looks_like_number($rn), 'Is a number: ' . $rn); ok($rn >= 0.0 && $rn < 1.0, 'In range: ' . $rn); # Test several values from irand() for my $ii (0 .. 9) { eval { $rn[$ii] = irand(); }; ok(! $@, 'irand() died: ' . $@); ok(defined($rn[$ii]), 'Got a random number'); ok(Scalar::Util::looks_like_number($rn[$ii]), 'Is a number: ' . $rn[$ii]); ok(int($rn[$ii]) == $rn[$ii], 'Integer: ' . $rn[$ii]); for my $jj (0 .. $ii-1) { ok($rn[$jj] != $rn[$ii], 'Randomized'); } } exit(0); # EOF Math-Random-MT-Auto-6.23/t/08-hotbits.t0000644000175000001440000000310313377133756017030 0ustar jdheddenusers# Tests for HotBits site use strict; use warnings; use Test::More; # Warning signal handler my @WARN; BEGIN { $SIG{__WARN__} = sub { push(@WARN, @_); }; } use Math::Random::MT::Auto qw(rand irand), 'hotbits'; if (grep(/^Failure creating user-agent/, @WARN)) { plan skip_all => 'LWP::Useragent not available'; } elsif (grep(/^Failure contacting/, @WARN)) { plan skip_all => 'HotBits site not reachable'; } elsif ((grep(/^Failure getting data/, @WARN)) || (grep(/^No seed data/, @WARN))) { plan skip_all => 'Seed not obtained from HotBits site'; } plan tests => 91; @WARN = grep(!/^Partial seed/, @WARN); @WARN = grep(!/^You have exceeded/, @WARN); @WARN = grep(!/only once/, @WARN); # Ingnore 'once' warnings from other modules ok(! @WARN, 'No warnings'); diag('Warnings: ' . join(' | ', @WARN)) if (@WARN); can_ok('main', qw(rand irand)); # Test rand() my ($rn, @rn); eval { $rn = rand(); }; ok(! $@, 'rand() died: ' . $@); ok(defined($rn), 'Got a random number'); ok(Scalar::Util::looks_like_number($rn), 'Is a number: ' . $rn); ok($rn >= 0.0 && $rn < 1.0, 'In range: ' . $rn); # Test several values from irand() for my $ii (0 .. 9) { eval { $rn[$ii] = irand(); }; ok(! $@, 'irand() died: ' . $@); ok(defined($rn[$ii]), 'Got a random number'); ok(Scalar::Util::looks_like_number($rn[$ii]), 'Is a number: ' . $rn[$ii]); ok(int($rn[$ii]) == $rn[$ii], 'Integer: ' . $rn[$ii]); for my $jj (0 .. $ii-1) { ok($rn[$jj] != $rn[$ii], 'Randomized'); } } exit(0); # EOF Math-Random-MT-Auto-6.23/t/06-dev_random.t0000644000175000001440000000371113377133756017475 0ustar jdheddenusers# Tests for /dev/random use strict; use warnings; use Test::More; my @WARN; BEGIN { # Warning signal handler $SIG{__WARN__} = sub { push(@WARN, @_); }; } if (-e '/dev/random') { my $FH; if (open($FH, '<', '/dev/random')) { binmode($FH); my $data; my $cnt = read($FH, $data, 8); if (! defined($cnt)) { plan skip_all => "Couldn't read from /dev/random: $!"; } elsif ($cnt == 8) { plan tests => 92; } else { plan skip_all => "/dev/random exhausted ($cnt of 8 bytes)"; } close($FH); } else { plan skip_all => "/dev/random not usable: $!"; } } else { plan skip_all => '/dev/random not available'; } use_ok('Math::Random::MT::Auto', qw(rand irand), '/dev/random'); can_ok('main', qw(rand irand)); # Check for warnings if (grep { /exhausted/ } @WARN) { diag('/dev/random exhausted'); undef(@WARN); } if (grep { /unavailable/ } @WARN) { diag('/dev/random unavailable'); undef(@WARN); } if (grep { /Failure reading/ } @WARN) { diag('Seed warning ignored: ' . join(' | ', @WARN)); undef(@WARN); } if (! ok(! @WARN, 'Acquired seed data')) { diag('Seed warnings: ' . join(' | ', @WARN)); } undef(@WARN); my ($rn, @rn); # Test rand() eval { $rn = rand(); }; ok(! $@, 'rand() died: ' . $@); ok(defined($rn), 'Got a random number'); ok(Scalar::Util::looks_like_number($rn), 'Is a number: ' . $rn); ok($rn >= 0.0 && $rn < 1.0, 'In range: ' . $rn); # Test several values from irand() for my $ii (0 .. 9) { eval { $rn[$ii] = irand(); }; ok(! $@, 'irand() died: ' . $@); ok(defined($rn[$ii]), 'Got a random number'); ok(Scalar::Util::looks_like_number($rn[$ii]), 'Is a number: ' . $rn[$ii]); ok(int($rn[$ii]) == $rn[$ii], 'Integer: ' . $rn[$ii]); for my $jj (0 .. $ii-1) { ok($rn[$jj] != $rn[$ii], 'Randomized'); } } exit(0); # EOF Math-Random-MT-Auto-6.23/t/09-state.t0000644000175000001440000000276113377133756016506 0ustar jdheddenusers# Verify state() Function Part 1: The Saving use strict; use warnings; use Test::More 'tests' => 2007; use Data::Dumper; use_ok('Math::Random::MT::Auto', qw(irand get_state set_state)); can_ok('main', qw(irand get_state set_state)); # Work the PRNG a bit my $rn; for (1 .. 500) { eval { $rn = irand(); }; ok(! $@, 'irand() died: ' . $@); ok(defined($rn), 'Got a random number'); ok(Scalar::Util::looks_like_number($rn),'Is a number: ' . $rn); ok(int($rn) == $rn, 'Integer: ' . $rn); } # Get state my @my_state; eval { @my_state = get_state(); }; ok(! $@, 'get_state() died: ' . $@); # Get some numbers to save my @rn; for (1 .. 500) { push(@rn, irand()); } our @state = @my_state; if ($] > 5.006) { # Save state to file if (open(FH, '>state_data.tmp')) { print(FH Data::Dumper->Dump([\@my_state], ['*state'])); print(FH "1;\n"); close(FH); } else { diag('Failure writing state to file'); } # Read state and numbers from file my $rc = do('state_data.tmp'); unlink('state_data.tmp'); } is_deeply(\@state, \@my_state => 'state from file'); # Set state eval { set_state(\@state); }; ok(! $@, 'set_state() died: ' . $@); # Check state my @got_state = get_state(); is_deeply(\@got_state, \@state, => 'get_state ok'); # Compare numbers after restoration of state my @rn2; for (1 .. 500) { push(@rn2, irand()); } is_deeply(\@rn, \@rn2, 'Same results after state restored'); exit(0); # EOF Math-Random-MT-Auto-6.23/t/13-overload.t0000644000175000001440000000535013377133756017171 0ustar jdheddenusers# Tests for overloading use strict; use warnings; $| = 1; use Test::More 'tests' => 16; use Config; my @WARN; BEGIN { # Warning signal handler $SIG{__WARN__} = sub { push(@WARN, @_); }; } use_ok('Math::Random::MT::Auto', ':!auto'); use_ok('Math::Random::MT::Auto::Range'); # Set predetermined seed for verification test my @seed = ($Config{'uvsize'} == 8) ? (0x12345, 0x23456, 0x34567, 0x45678) : (0x123, 0x234, 0x345, 0x456); my @rand = ($Config{'uvsize'} == 8) ? ( # 64-bit randoms 7266447313870364031, 4946485549665804864, 16945909448695747420, 16394063075524226720, 4873882236456199058, 14877448043947020171, 6740343660852211943, 13857871200353263164 ) : ( # 32-bit randoms 1067595299, 955945823, 477289528, 4107218783, 4228976476, 3344332714, 3355579695, 227628506 ); # Create PRNG object my $prng; eval { $prng = Math::Random::MT::Auto->new('SEED' => \@seed); }; if (my $e = OIO->caught()) { fail('MRMA->new(): ' . $e->error()); } elsif ($@) { fail('MRMA->new(): ' . $@); } else { pass('MRMA->new()'); } is("$prng", $rand[0] => ':Stringify'); SKIP: { my $rnd = 0+$prng; skip('64-bit overload bug', 1) if (($] < 5.010) && ($Config{'uvsize'} == 8)); is($rnd, $rand[1] => ':Numerify'); } is(($prng) ? 'odd' : 'even', ($rand[2] & 1) ? 'odd' : 'even', => ':Boolify'); my $x = \&{$prng}; is($x->(), $rand[3] => ':Codify'); my @x = @{$prng}; is($x[0], $rand[4] => ':Arrayify'); @x = @{$prng->array(3)}; my @results = @rand[5..7]; is_deeply(\@x, \@results => '->array()'); ### MRMA::Range my ($LO, $HI) = (1000, 9999); sub range { return (($_[0] % (($HI + 1) - $LO)) + $LO); } my $rand; eval { $rand = Math::Random::MT::Auto::Range->new('SEED' => \@seed, 'LOW' => $LO, 'HIGH' => $HI, 'TYPE' => 'INTEGER'); }; if (my $e = OIO->caught()) { fail('MRMAR->new(): ' . $e->error()); } elsif ($@) { fail('MRMAR->new(): ' . $@); } else { pass('MRMAR->new()'); } is("$rand", range($rand[0]) => ':Stringify'); is(0+$rand, range($rand[1]) => ':Numerify'); is(($rand) ? 'odd' : 'even', (range($rand[2]) & 1) ? 'odd' : 'even', => ':Boolify'); my $x = \&{$rand}; is($x->(), range($rand[3]) => ':Codify'); my @x = @{$rand}; is($x[0], range($rand[4]) => ':Arrayify'); @x = @{$rand->array(3)}; my @results = map { range($_) } @rand[5..7]; is_deeply(\@x, \@results => '->array()'); exit(0); # EOF Math-Random-MT-Auto-6.23/t/15-shared.t0000644000175000001440000000513513377133756016627 0ustar jdheddenusers# Tests for thread sharing use strict; use warnings; use Config; BEGIN { if (! $Config{useithreads} || $] < 5.008) { print("1..0 # Skip Threads not supported\n"); exit(0); } if ($] == 5.008) { print("1..0 # Skip Thread sharing support not working for Perl 5.8.0\n"); exit(0); } if ($^O eq 'MSWin32' && $] == 5.008001) { print("1..0 # Skip threads::shared not working for MSWin32 5.8.1\n"); exit(0); } } use threads; use threads::shared; use Test::More 'tests' => 89; BEGIN { $Math::Random::MT::Auto::shared = 1; } use Math::Random::MT::Auto qw(set_seed get_seed set_state get_state); can_ok('main', qw(set_seed get_seed set_state get_state)); # 'Empty subclass' test (cf. perlmodlib) { package IMA::Subclass; use Object::InsideOut qw(Math::Random::MT::Auto); } # Create PRNG my $prng; eval { $prng = IMA::Subclass->new(); }; if (! ok(! $@, '->new worked')) { diag('->new died: ' . $@); } isa_ok($prng, 'Math::Random::MT::Auto'); isa_ok($prng, 'IMA::Subclass'); can_ok($prng, qw(rand irand gaussian exponential erlang poisson binomial shuffle srand get_seed set_seed get_state set_state)); my $rand; for my $ii (0 .. 9) { eval { $rand = $prng->irand(); }; ok(! $@, '$prng->irand() died: ' . $@); ok(defined($rand), 'Got a random number'); ok(Scalar::Util::looks_like_number($rand), 'Is a number: ' . $rand); ok(int($rand) == $rand, 'Integer: ' . $rand); } set_seed(1, 2, 4); my @main_state = get_state(); # Get random numbers from thread my $thr_state = threads->create(sub { my @seed = get_seed(); is_deeply(\@seed, [1,2,4] => 'SA seed'); my @state = get_state(); is_deeply(\@state, \@main_state => 'SA state'); set_seed(99, 99, 99); my $rand; for my $ii (0 .. 9) { eval { $rand = $prng->irand(); }; ok(! $@, '$prng->irand() died: ' . $@); ok(defined($rand), 'Got a random number'); ok(Scalar::Util::looks_like_number($rand), 'Is a number: ' . $rand); ok(int($rand) == $rand, 'Integer: ' . $rand); } for my $ii (0 .. 2000) { $rand = $prng->irand(); } my @thr_state = $prng->get_state(); return (\@thr_state); } )->join(); my @state = $prng->get_state(); is_deeply($thr_state, \@state => 'States equal'); my @seed = get_seed(); is_deeply(\@seed, [99,99,99] => 'SA seed'); exit(0); # EOF Math-Random-MT-Auto-6.23/t/10-deviates.t0000644000175000001440000003224513377133756017162 0ustar jdheddenusers# Tests the various random deviates use strict; use warnings; use Test::More 'tests' => 950; my @WARN; BEGIN { # Warning signal handler $SIG{__WARN__} = sub { push(@WARN, @_); }; } use_ok('Math::Random::MT::Auto', qw(exponential erlang poisson binomial shuffle)); can_ok('Math::Random::MT::Auto', qw(exponential erlang poisson binomial shuffle)); can_ok('main', qw(exponential erlang poisson binomial shuffle)); # Check for warnings if (! ok(! @WARN, 'Acquired seed data')) { diag('Seed warnings: ' . join(' | ', @WARN)); } undef(@WARN); my (@rn); # Test several values from exponential() undef(@rn); for my $ii (0 .. 9) { eval { $rn[$ii] = exponential(); }; ok(! $@, 'exponential() died: ' . $@); ok(defined($rn[$ii]), 'Got a random number'); ok(Scalar::Util::looks_like_number($rn[$ii]), 'Is a number: ' . $rn[$ii]); ok($rn[$ii] > 0.0, 'Positive: ' . $rn[$ii]); for my $jj (0 .. $ii-1) { ok($rn[$jj] != $rn[$ii], 'Randomized'); } } # Test several values from erlang() for small order undef(@rn); for my $ii (0 .. 9) { eval { $rn[$ii] = erlang(3); }; ok(! $@, 'erlang(3) died: ' . $@); ok(defined($rn[$ii]), 'Got a random number'); ok(Scalar::Util::looks_like_number($rn[$ii]), 'Is a number: ' . $rn[$ii]); ok($rn[$ii] > 0.0, 'Positive: ' . $rn[$ii]); for my $jj (0 .. $ii-1) { ok($rn[$jj] != $rn[$ii], 'Randomized'); } } # Test several values from erlang() for larger order undef(@rn); for my $ii (0 .. 9) { eval { $rn[$ii] = erlang(10); }; ok(! $@, 'erlang(10) died: ' . $@); ok(defined($rn[$ii]), 'Got a random number'); ok(Scalar::Util::looks_like_number($rn[$ii]), 'Is a number: ' . $rn[$ii]); ok($rn[$ii] > 0.0, 'Positive: ' . $rn[$ii]); for my $jj (0 .. $ii-1) { ok($rn[$jj] != $rn[$ii], 'Randomized'); } } # Test several values from poisson() for small order undef(@rn); for my $ii (0 .. 9) { eval { $rn[$ii] = poisson(3); }; ok(! $@, 'poisson(3) died: ' . $@); ok(defined($rn[$ii]), 'Got a random number'); ok(Scalar::Util::looks_like_number($rn[$ii]), 'Is a number: ' . $rn[$ii]); ok(int($rn[$ii]) == $rn[$ii] && $rn[$ii] >= 0, 'Non-neg integer: ' . $rn[$ii]); } # Test several values from poisson() for large order undef(@rn); for my $ii (0 .. 9) { eval { $rn[$ii] = poisson(30); }; ok(! $@, 'poisson(30) died: ' . $@); ok(defined($rn[$ii]), 'Got a random number'); ok(Scalar::Util::looks_like_number($rn[$ii]), 'Is a number: ' . $rn[$ii]); ok(int($rn[$ii]) == $rn[$ii] && $rn[$ii] >= 0, 'Non-neg integer: ' . $rn[$ii]); } # Test several values from binomial() for small trial count undef(@rn); for my $ii (0 .. 9) { eval { $rn[$ii] = binomial(0.5, 15); }; ok(! $@, 'binomial(0.5, 15) died: ' . $@); ok(defined($rn[$ii]), 'Got a random number'); ok(Scalar::Util::looks_like_number($rn[$ii]), 'Is a number: ' . $rn[$ii]); ok(int($rn[$ii]) == $rn[$ii] && $rn[$ii] >= 0, 'Non-neg integer: ' . $rn[$ii]); } # Test several values from binomial() for small mean undef(@rn); for my $ii (0 .. 9) { eval { $rn[$ii] = binomial(0.01, 30); }; ok(! $@, 'binomial(0.01, 30) died: ' . $@); ok(defined($rn[$ii]), 'Got a random number'); ok(Scalar::Util::looks_like_number($rn[$ii]), 'Is a number: ' . $rn[$ii]); ok(int($rn[$ii]) == $rn[$ii] && $rn[$ii] >= 0, 'Non-neg integer: ' . $rn[$ii]); } # Test several values from binomial() undef(@rn); for my $ii (0 .. 9) { eval { $rn[$ii] = binomial(0.8, 50); }; ok(! $@, 'binomial(0.8, 50) died: ' . $@); ok(defined($rn[$ii]), 'Got a random number'); ok(Scalar::Util::looks_like_number($rn[$ii]), 'Is a number: ' . $rn[$ii]); ok(int($rn[$ii]) == $rn[$ii] && $rn[$ii] >= 0, 'Non-neg integer: ' . $rn[$ii]); } # Test of shuffle() my @data = ( [ 'xyz' ], 'abc', 1, 0.0, 1e-3, { 'q' => 42 }, sub { return (99); } ); my $shuf; eval { $shuf = shuffle(@data); }; ok(! $@, 'shuffle okay'); for my $x (@$shuf) { my $found = 0; for my $y (@data) { if (ref($x) eq 'CODE') { if (ref($y) eq 'CODE') { pass('shuffle - code ref okay'); $found = 1; last; } } elsif (ref($x) eq 'ARRAY') { if (ref($y) eq 'ARRAY') { is_deeply($x, $y, 'shuffle - array okay'); $found = 1; last; } } elsif (ref($x) eq 'HASH') { if (ref($y) eq 'HASH') { is_deeply($x, $y, 'shuffle - hash okay'); $found = 1; last; } } elsif (Scalar::Util::looks_like_number($x)) { if (Scalar::Util::looks_like_number($y) && ($x == $y)) { pass("shuffle - $x okay"); $found = 1; last; } } elsif (! ref($y) && ! Scalar::Util::looks_like_number($y) && ($x eq $y)) { pass("shuffle - $x okay"); $found = 1; last; } } if (! $found) { fail('shuffle element not found'); } } my @shuf; eval { @shuf = shuffle(@data); }; ok(! $@, 'shuffle okay'); for my $x (@shuf) { my $found = 0; for my $y (@data) { if (ref($x) eq 'CODE') { if (ref($y) eq 'CODE') { pass('shuffle - code ref okay'); $found = 1; last; } } elsif (ref($x) eq 'ARRAY') { if (ref($y) eq 'ARRAY') { is_deeply($x, $y, 'shuffle - array okay'); $found = 1; last; } } elsif (ref($x) eq 'HASH') { if (ref($y) eq 'HASH') { is_deeply($x, $y, 'shuffle - hash okay'); $found = 1; last; } } elsif (Scalar::Util::looks_like_number($x)) { if (Scalar::Util::looks_like_number($y) && ($x == $y)) { pass("shuffle - $x okay"); $found = 1; last; } } elsif (! ref($y) && ! Scalar::Util::looks_like_number($y) && ($x eq $y)) { pass("shuffle - $x okay"); $found = 1; last; } } if (! $found) { fail('shuffle element not found'); } } eval { shuffle(\@data); }; ok(! $@, 'shuffle okay'); for my $x (@data) { my $found = 0; for my $y (@data) { if (ref($x) eq 'CODE') { if (ref($y) eq 'CODE') { pass('shuffle - code ref okay'); $found = 1; last; } } elsif (ref($x) eq 'ARRAY') { if (ref($y) eq 'ARRAY') { is_deeply($x, $y, 'shuffle - array okay'); $found = 1; last; } } elsif (ref($x) eq 'HASH') { if (ref($y) eq 'HASH') { is_deeply($x, $y, 'shuffle - hash okay'); $found = 1; last; } } elsif (Scalar::Util::looks_like_number($x)) { if (Scalar::Util::looks_like_number($y) && ($x == $y)) { pass("shuffle - $x okay"); $found = 1; last; } } elsif (! ref($y) && ! Scalar::Util::looks_like_number($y) && ($x eq $y)) { pass("shuffle - $x okay"); $found = 1; last; } } if (! $found) { fail('shuffle element not found'); } } # Create PRNG object my $prng; eval { $prng = Math::Random::MT::Auto->new(); }; if (! ok(! $@, '->new works')) { diag('->new died: ' . $@); } isa_ok($prng, 'Math::Random::MT::Auto'); can_ok($prng, qw(rand irand gaussian exponential erlang poisson binomial shuffle get_seed set_seed get_state set_state)); # Check for warnings if (! ok(! @WARN, 'Acquired seed data')) { diag('Seed warnings: ' . join(' | ', @WARN)); } undef(@WARN); # Test several values from exponential() undef(@rn); for my $ii (0 .. 9) { eval { $rn[$ii] = $prng->exponential(2); }; ok(! $@, '$prng->exponential() died: ' . $@); ok(defined($rn[$ii]), 'Got a random number'); ok(Scalar::Util::looks_like_number($rn[$ii]), 'Is a number: ' . $rn[$ii]); ok($rn[$ii] > 0.0, 'Positive: ' . $rn[$ii]); for my $jj (0 .. $ii-1) { ok($rn[$jj] != $rn[$ii], 'Randomized'); } } # Test several values from erlang() for small order undef(@rn); for my $ii (0 .. 9) { eval { $rn[$ii] = $prng->erlang(3); }; ok(! $@, '$prng->erlang(3) died: ' . $@); ok(defined($rn[$ii]), 'Got a random number'); ok(Scalar::Util::looks_like_number($rn[$ii]), 'Is a number: ' . $rn[$ii]); ok($rn[$ii] > 0.0, 'Positive: ' . $rn[$ii]); for my $jj (0 .. $ii-1) { ok($rn[$jj] != $rn[$ii], 'Randomized'); } } # Test several values from erlang() for larger order undef(@rn); for my $ii (0 .. 9) { eval { $rn[$ii] = $prng->erlang(10); }; ok(! $@, '$prng->erlang(10) died: ' . $@); ok(defined($rn[$ii]), 'Got a random number'); ok(Scalar::Util::looks_like_number($rn[$ii]), 'Is a number: ' . $rn[$ii]); ok($rn[$ii] > 0.0, 'Positive: ' . $rn[$ii]); for my $jj (0 .. $ii-1) { ok($rn[$jj] != $rn[$ii], 'Randomized'); } } # Test several values from poisson() for small order undef(@rn); for my $ii (0 .. 9) { eval { $rn[$ii] = $prng->poisson(3); }; ok(! $@, '$prng->poisson(3) died: ' . $@); ok(defined($rn[$ii]), 'Got a random number'); ok(Scalar::Util::looks_like_number($rn[$ii]), 'Is a number: ' . $rn[$ii]); ok(int($rn[$ii]) == $rn[$ii] && $rn[$ii] >= 0, 'Non-neg integer: ' . $rn[$ii]); } # Test several values from poisson() for large order undef(@rn); for my $ii (0 .. 9) { eval { $rn[$ii] = $prng->poisson(30); }; ok(! $@, '$prng->poisson(30) died: ' . $@); ok(defined($rn[$ii]), 'Got a random number'); ok(Scalar::Util::looks_like_number($rn[$ii]), 'Is a number: ' . $rn[$ii]); ok(int($rn[$ii]) == $rn[$ii] && $rn[$ii] >= 0, 'Non-neg integer: ' . $rn[$ii]); } # Test several values from binomial() for small trial count undef(@rn); for my $ii (0 .. 9) { eval { $rn[$ii] = $prng->binomial(0.5, 15); }; ok(! $@, '$prng->binomial(0.5, 15) died: ' . $@); ok(defined($rn[$ii]), 'Got a random number'); ok(Scalar::Util::looks_like_number($rn[$ii]), 'Is a number: ' . $rn[$ii]); ok(int($rn[$ii]) == $rn[$ii] && $rn[$ii] >= 0, 'Non-neg integer: ' . $rn[$ii]); } # Test several values from binomial() for small mean undef(@rn); for my $ii (0 .. 9) { eval { $rn[$ii] = $prng->binomial(0.01, 30); }; ok(! $@, '$prng->binomial(0.01, 30) died: ' . $@); ok(defined($rn[$ii]), 'Got a random number'); ok(Scalar::Util::looks_like_number($rn[$ii]), 'Is a number: ' . $rn[$ii]); ok(int($rn[$ii]) == $rn[$ii] && $rn[$ii] >= 0, 'Non-neg integer: ' . $rn[$ii]); } # Test several values from binomial() undef(@rn); for my $ii (0 .. 9) { eval { $rn[$ii] = $prng->binomial(0.8, 50); }; ok(! $@, '$prng->binomial(0.8, 50) died: ' . $@); ok(defined($rn[$ii]), 'Got a random number'); ok(Scalar::Util::looks_like_number($rn[$ii]), 'Is a number: ' . $rn[$ii]); ok(int($rn[$ii]) == $rn[$ii] && $rn[$ii] >= 0, 'Non-neg integer: ' . $rn[$ii]); } # Test of shuffle() eval { $shuf = $prng->shuffle($shuf); }; ok(! $@, '$prng->shuffle okay'); for my $x (@$shuf) { my $found = 0; for my $y (@data) { if (ref($x) eq 'CODE') { if (ref($y) eq 'CODE') { pass('$prng->shuffle - code ref okay'); $found = 1; last; } } elsif (ref($x) eq 'ARRAY') { if (ref($y) eq 'ARRAY') { is_deeply($x, $y, '$prng->shuffle - array okay'); $found = 1; last; } } elsif (ref($x) eq 'HASH') { if (ref($y) eq 'HASH') { is_deeply($x, $y, '$prng->shuffle - hash okay'); $found = 1; last; } } elsif (Scalar::Util::looks_like_number($x)) { if (Scalar::Util::looks_like_number($y) && ($x == $y)) { pass("\$prng->shuffle - $x okay"); $found = 1; last; } } elsif (! ref($y) && ! Scalar::Util::looks_like_number($y) && ($x eq $y)) { pass("\$prng->shuffle - $x okay"); $found = 1; last; } } if (! $found) { fail('shuffle element not found'); } } exit(0); # EOF Math-Random-MT-Auto-6.23/t/03-threads.t0000644000175000001440000000435213377133756017010 0ustar jdheddenusers# Tests for OO thread safety use strict; use warnings; use Config; BEGIN { if (! $Config{useithreads} || $] < 5.008) { print("1..0 # Skip Threads not supported\n"); exit(0); } if ($] == 5.008) { print("1..0 # Skip Thread support not working for Perl 5.8.0\n"); exit(0); } } use threads; use Test::More 'tests' => 94; use Math::Random::MT::Auto; # 'Empty subclass' test (cf. perlmodlib) { package IMA::Subclass; use Object::InsideOut qw(Math::Random::MT::Auto); } # Create PRNG my $prng; eval { $prng = IMA::Subclass->new(); }; if (! ok(! $@, '->new worked')) { diag('->new died: ' . $@); } isa_ok($prng, 'Math::Random::MT::Auto'); isa_ok($prng, 'IMA::Subclass'); can_ok($prng, qw(rand irand gaussian exponential erlang poisson binomial shuffle srand get_seed set_seed get_state set_state)); # Get random numbers from thread my $rands = threads->create( sub { my @rands; for (0 .. 9) { my $rand = $prng->irand(); push(@rands, $rand); } for (0 .. 9) { my $rand = $prng->rand(3); push(@rands, $rand); } return (\@rands); } )->join(); # Check that parent gets the same numbers my $rand; for my $ii (0 .. 9) { eval { $rand = $prng->irand(); }; ok(! $@, '$prng->irand() died: ' . $@); ok(defined($rand), 'Got a random number'); ok(Scalar::Util::looks_like_number($rand), 'Is a number: ' . $rand); ok(int($rand) == $rand, 'Integer: ' . $rand); ok($$rands[$ii] == $rand, 'Values equal: ' . $$rands[$ii] . ' ' . $rand); } for my $ii (10 .. 19) { eval { $rand = $prng->rand(3); }; ok(! $@, '$prng->rand(3) died: ' . $@); ok(defined($rand), 'Got a random number'); ok(Scalar::Util::looks_like_number($rand), 'Is a number: ' . $rand); ok($$rands[$ii] == $rand, 'Values equal: ' . $$rands[$ii] . ' ' . $rand); } exit(0); # EOF Math-Random-MT-Auto-6.23/Makefile.PL0000644000175000001440000000556413377133756016466 0ustar jdheddenusers# Module makefile for Math::Random::MT::Auto (using ExtUtils::MakeMaker) require 5.006; use strict; use warnings; use ExtUtils::MakeMaker; # Check for C compiler sub check_cc { require File::Spec; my $cmd = $_[0]; if (-x $cmd or MM->maybe_command($cmd)) { return (1); # CC command found } for my $dir (File::Spec->path(), '.') { my $abs = File::Spec->catfile($dir, $cmd); if (-x $abs or MM->maybe_command($abs)) { return (1); # CC command found } } return; } sub have_cc { eval { require Config_m; }; # ExtUtils::FakeConfig (+ MSWin32) if ($@) { eval { require Config; }; # Everyone else } my @chunks = split(/ /, $Config::Config{cc}); # $Config{cc} may contain args; try to find out the program part while (@chunks) { if (check_cc("@chunks")) { return (1); # CC command found } pop(@chunks); } return; } if (! have_cc()) { die("OS unsupported: ERROR: No 'C' compiler found to build Math::Random::MT::Auto\n"); } # Construct make file WriteMakefile( 'NAME' => 'Math::Random::MT::Auto', 'AUTHOR' => 'Jerry D. Hedden ', 'VERSION_FROM' => 'lib/Math/Random/MT/Auto.pm', 'ABSTRACT_FROM' => 'lib/Math/Random/MT/Auto.pm', 'PREREQ_PM' => { 'Exception::Class' => 1.32, 'Object::InsideOut' => 3.88, 'strict' => 0, 'warnings' => 0, 'Carp' => 0, 'Fcntl' => 0, 'XSLoader' => 0, 'Test::More' => 0, 'Scalar::Util' => 1.23, 'Data::Dumper' => 0, 'Config' => 0, }, 'OBJECT' => 'MRMA.o', (($ExtUtils::MakeMaker::VERSION lt '6.25') ? ('PL_FILES' => { }) : ()), (($ExtUtils::MakeMaker::VERSION gt '6.30') ? ('LICENSE' => 'unrestricted') : ()), ); package MY; # Add to metafile target sub metafile { my $inherited = shift->SUPER::metafile_target(@_); $inherited .= <<'_MOREMETA_'; $(NOECHO) $(ECHO) 'recommends:' >>$(DISTVNAME)/META.yml $(NOECHO) $(ECHO) ' LWP::UserAgent: 0' >>$(DISTVNAME)/META.yml $(NOECHO) $(ECHO) ' Win32::API: 0' >>$(DISTVNAME)/META.yml _MOREMETA_ return $inherited; } # Additional 'make' targets sub postamble { return <<'_EXTRAS_'; fixfiles: @dos2unix `cat MANIFEST` @$(CHMOD) 644 `cat MANIFEST` @$(CHMOD) 755 examples/*.pl ppport: @( cd /tmp; perl -e 'use Devel::PPPort; Devel::PPPort::WriteFile("ppport.h");' ) @if ! cmp -s ppport.h /tmp/ppport.h; then \ ( tkdiff ppport.h /tmp/ppport.h & ); \ perl /tmp/ppport.h; \ fi _EXTRAS_ } # EOF Math-Random-MT-Auto-6.23/MRMA.xs0000644000175000001440000006073313377133756015623 0ustar jdheddenusers/* Mersenne Twister PRNG A C-Program for MT19937 (32- and 64-bit versions), with initialization improved 2002/1/26. Coded by Takuji Nishimura and Makoto Matsumoto, and including Shawn Cokus's optimizations. Copyright (C) 1997 - 2004, Makoto Matsumoto and Takuji Nishimura, All rights reserved. Copyright (C) 2005, Mutsuo Saito, All rights reserved. Copyright 2005 - 2009 Jerry D. Hedden Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. The names of its contributors may not be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. Any feedback is very welcome. http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/emt.html */ #include "EXTERN.h" #include "perl.h" #include "XSUB.h" #define NEED_newRV_noinc #include "ppport.h" #include #if UVSIZE == 8 /* Constants related to the Mersenne Twister */ # define N 312 /* Number of 64-bit ints in state vector */ # define M 156 /* Macros used inside Mersenne Twister algorithm */ # define MIXBITS(u,v) ( ((u) & 0xFFFFFFFF80000000ULL) | ((v) & 0x7FFFFFFFULL) ) # define TWIST(u,v) ((MIXBITS(u,v) >> 1) ^ ((v)&1UL ? 0xB5026F5AA96619E9ULL : 0ULL)) /* Final randomization of integer extracted from state vector */ # define TEMPER_ELEM(x) \ x ^= (x >> 29) & 0x0000000555555555ULL; \ x ^= (x << 17) & 0x71D67FFFEDA60000ULL; \ x ^= (x << 37) & 0xFFF7EEE000000000ULL; \ x ^= (x >> 43) /* Seed routine constants */ # define BIT_SHIFT 62 # define MAGIC1 6364136223846793005ULL # define MAGIC2 3935559000370003845ULL # define MAGIC3 2862933555777941757ULL # define HI_BIT 1ULL<<63 /* Various powers of 2 */ # define TWOeMINUS51 4.44089209850062616169452667236328125e-16 # define TWOeMINUS52 2.220446049250313080847263336181640625e-16 # define TWOeMINUS53 1.1102230246251565404236316680908203125e-16 /* Make a double between 0 (inclusive) and 1 (exclusive) */ # define RAND_0i_1x(x) (((NV)((x) >> 12)) * TWOeMINUS52) /* Make a double between 0 and 1 (exclusive) */ # define RAND_0x_1x(x) (RAND_0i_1x(x) + TWOeMINUS53) /* Make a double between 0 (exclusive) and 1 (inclusive) */ # define RAND_0x_1i(x) (((NV)(((x) >> 12) + 1)) * TWOeMINUS52) /* Make a double between -1 and 1 (exclusive) */ # define RAND_NEG1x_1x(x) ((((NV)(((IV)(x)) >> 11)) * TWOeMINUS52) + TWOeMINUS53) #else /* Constants related to the Mersenne Twister */ # define N 624 /* Number of 32-bit ints in state vector */ # define M 397 /* Macros used inside Mersenne Twister algorithm */ # define MIXBITS(u,v) ( ((u) & 0x80000000) | ((v) & 0x7FFFFFFF) ) # define TWIST(u,v) ((MIXBITS((u),(v)) >> 1) ^ (((v)&1UL) ? 0x9908B0DF : 0UL)) /* Final randomization of integer extracted from state vector */ # define TEMPER_ELEM(x) \ x ^= (x >> 11); \ x ^= (x << 7) & 0x9D2C5680; \ x ^= (x << 15) & 0xEFC60000; \ x ^= (x >> 18) /* Seed routine constants */ # define BIT_SHIFT 30 # define MAGIC1 1812433253 # define MAGIC2 1664525 # define MAGIC3 1566083941 # define HI_BIT 0x80000000 /* Various powers of 2 */ # define TWOeMINUS31 4.656612873077392578125e-10 # define TWOeMINUS32 2.3283064365386962890625e-10 # define TWOeMINUS33 1.16415321826934814453125e-10 /* Make a double between 0 (inclusive) and 1 (exclusive) */ # define RAND_0i_1x(x) ((NV)(x) * TWOeMINUS32) /* Make a double between 0 and 1 (exclusive) */ # define RAND_0x_1x(x) (RAND_0i_1x(x) + TWOeMINUS33) /* Make a double between 0 (exclusive) and 1 (inclusive) */ # define RAND_0x_1i(x) ((((NV)(x)) + 1.0) * TWOeMINUS32) /* Make a double between -1 and 1 (exclusive) */ # define RAND_NEG1x_1x(x) ((((NV)((IV)(x))) * TWOeMINUS31) + TWOeMINUS32) #endif /* Standalone PRNG */ #define SA_PRNG "MRMA::PRNG" /* Definitions for getting PRNG context */ #define PRNG_VARS SV *addr #define PRNG_PREP addr = SvRV(ST(0)) #define GET_PRNG INT2PTR(struct mt *, SvUV(addr)) /* Variable declarations for the dual (OO and functional) interface */ #define DUAL_VARS \ PRNG_VARS; \ struct mt *prng; \ int idx /* Sets up PRNG for dual-interface */ /* A ref check for an object call is good enough, * and much faster than object or 'isa' checking. */ #define DUAL_PRNG \ if (items && SvROK(ST(0))) { \ /* OO interface */ \ PRNG_PREP; \ items--; \ idx = 1; \ } else { \ /* Standalone PRNG */ \ addr = SvRV(get_sv(SA_PRNG, 0));\ idx = 0; \ } \ prng = GET_PRNG; /* Get next random from a PRNG */ #define IRAND(x,y) \ x = ((--y->left == 0) ? _mt_algo(y) : *y->next++); \ TEMPER_ELEM(x) /* The PRNG state structure (AKA the PRNG context) */ struct mt { UV state[N]; UV *next; IV left; struct { IV have; NV value; } gaussian; struct { NV mean; NV log_mean; NV sqrt2mean; NV term; } poisson; struct { IV trials; NV term; NV prob; NV plog; NV pclog; } binomial; }; /* The state mixing algorithm for the Mersenne Twister */ static UV _mt_algo(struct mt *prng) { UV *st = prng->state; UV *sn = &st[2]; UV *sx = &st[M]; UV n0 = st[0]; UV n1 = st[1]; int kk; for (kk = N-M+1; --kk; n0 = n1, n1 = *sn++) { *st++ = *sx++ ^ TWIST(n0, n1); } sx = prng->state; for (kk = M; --kk; n0 = n1, n1 = *sn++) { *st++ = *sx++ ^ TWIST(n0, n1); } n1 = *prng->state; *st = *sx ^ TWIST(n0, n1); prng->next = &prng->state[1]; prng->left = N; return (n1); } /* Helper function to get next random double */ static NV _rand(struct mt *prng) { UV x; IRAND(x, prng); return (RAND_0x_1x(x)); } /* Helper function to calculate a random tan(angle) */ static NV _tan(struct mt *prng) { UV x1, y1; NV x2, y2; do { IRAND(x1, prng); IRAND(y1, prng); x2 = RAND_NEG1x_1x(x1); y2 = RAND_NEG1x_1x(y1); } while (x2*x2 + y2*y2 > 1.0); return (y2/x2); /* The above is faster than the following: UV x; IRAND(x, prng); return (tan(3.1415926535897932 * RAND_0x_1x(x))); */ } /* Helper function that returns the value ln(gamma(x)) for x > 0 */ /* Optimized from 'Numerical Recipes in C', Chapter 6.1 */ static NV _ln_gamma(NV x) { NV qq, ser; qq = x + 4.5; qq -= (x - 0.5) * log(qq); ser = 1.000000000190015 + (76.18009172947146 / x) - (86.50532032941677 / (x + 1.0)) + (24.01409824083091 / (x + 2.0)) - (1.231739572450155 / (x + 3.0)) + (1.208650973866179e-3 / (x + 4.0)) - (5.395239384953e-6 / (x + 5.0)); return (log(2.5066282746310005 * ser) - qq); } MODULE = Math::Random::MT::Auto PACKAGE = Math::Random::MT::Auto PROTOTYPES: DISABLE # The functions below are the random number deviates for the module. # They work both as regular 'functions' for the functional interface to the # standalone PRNG, as well as methods for the OO interface to PRNG objects. # irand # # Returns a random integer. UV irand(...) PREINIT: DUAL_VARS; CODE: DUAL_PRNG IRAND(RETVAL, prng); OUTPUT: RETVAL # rand # # Returns a random number on the range [0,1), # or [0,X) if an argument is supplied. double rand(...) PREINIT: DUAL_VARS; UV rand; CODE: DUAL_PRNG /* Random number on [0,1) interval */ IRAND(rand, prng); RETVAL = RAND_0i_1x(rand); if (items) { /* Random number on [0,X) interval */ RETVAL *= SvNV(ST(idx)); } OUTPUT: RETVAL # shuffle # # Shuffles input data using the Fisher-Yates shuffle algorithm. SV * shuffle(...) PREINIT: DUAL_VARS; AV *ary; I32 ii, jj; UV rand; SV *elem; CODE: /* Same as DUAL_PRNG except needs more stringent object check */ if (items && sv_isobject(ST(0))) { /* OO interface */ PRNG_PREP; items--; idx = 1; } else { /* Standalone PRNG */ addr = SvRV(get_sv(SA_PRNG, 0)); idx = 0; } prng = GET_PRNG; /* Handle arguments */ if (items == 1 && SvROK(ST(idx)) && SvTYPE(SvRV(ST(idx)))==SVt_PVAV) { /* User supplied an array reference */ ary = (AV*)SvRV(ST(idx)); RETVAL = newRV_inc((SV *)ary); } else if (GIMME_V == G_ARRAY) { /* If called in array context, shuffle directly on stack */ for (ii = items-1 ; ii > 0 ; ii--) { /* Pick a random element from the beginning of the array to the current element */ IRAND(rand, prng); jj = rand % (ii + 1); /* Swap elements */ SV *elem = ST(jj); ST(jj) = ST(ii); ST(ii) = elem; } XSRETURN(items); } else { /* Create an array from user supplied values */ ary = newAV(); av_extend(ary, items); while (items--) { av_push(ary, newSVsv(ST(idx++))); } RETVAL = newRV_noinc((SV *)ary); } /* Process elements from last to second */ for (ii=av_len(ary); ii > 0; ii--) { /* Pick a random element from the beginning of the array to the current element */ IRAND(rand, prng); jj = rand % (ii + 1); /* Swap elements */ elem = AvARRAY(ary)[ii]; AvARRAY(ary)[ii] = AvARRAY(ary)[jj]; AvARRAY(ary)[jj] = elem; } OUTPUT: RETVAL # gaussian # # Returns random numbers from a Gaussian distribution. # # On the first pass it calculates two numbers, returning one and saving the # other. On the next pass, it just returns the previously saved number. double gaussian(...) PREINIT: DUAL_VARS; UV u1, u2; NV v1, v2, r, factor; CODE: DUAL_PRNG if (prng->gaussian.have) { /* Use number generated during previous call */ RETVAL = prng->gaussian.value; prng->gaussian.have = 0; } else { /* Marsaglia's polar method for the Box-Muller transformation */ /* See 'Numerical Recipes in C', Chapter 7.2 */ do { IRAND(u1, prng); IRAND(u2, prng); v1 = RAND_NEG1x_1x(u1); v2 = RAND_NEG1x_1x(u2); r = v1*v1 + v2*v2; } while (r >= 1.0); factor = sqrt((-2.0 * log(r)) / r); RETVAL = v1 * factor; /* Save 2nd value for later */ prng->gaussian.value = v2 * factor; prng->gaussian.have = 1; } if (items) { /* Gaussian distribution with SD = X */ RETVAL *= SvNV(ST(idx)); if (items > 1) { /* Gaussian distribution with mean = Y */ RETVAL += SvNV(ST(idx+1)); } } OUTPUT: RETVAL # exponential # # Returns random numbers from an exponential distribution. double exponential(...) PREINIT: DUAL_VARS; CODE: DUAL_PRNG /* Exponential distribution with mean = 1 */ RETVAL = -log(_rand(prng)); if (items) { /* Exponential distribution with mean = X */ RETVAL *= SvNV(ST(idx)); } OUTPUT: RETVAL # erlang # # Returns random numbers from an Erlang distribution. double erlang(...) PREINIT: DUAL_VARS; IV order; IV ii; NV am, ss, tang, bound; CODE: DUAL_PRNG /* Check argument */ if (! items) { Perl_croak(aTHX_ "Missing argument to 'erlang'"); } if ((order = SvIV(ST(idx))) < 1) { Perl_croak(aTHX_ "Bad argument (< 1) to 'erlang'"); } if (order < 6) { /* Direct method of 'adding exponential randoms' */ RETVAL = 1.0; for (ii=0; ii < order; ii++) { RETVAL *= _rand(prng); } RETVAL = -log(RETVAL); } else { /* Use J. H. Ahren's rejection method */ /* See 'Numerical Recipes in C', Chapter 7.3 */ am = order - 1; ss = sqrt(2.0 * am + 1.0); do { do { tang = _tan(prng); RETVAL = (tang * ss) + am; } while (RETVAL <= 0.0); bound = (1.0 + tang*tang) * exp(am * log(RETVAL/am) - ss*tang); } while (_rand(prng) > bound); } if (items > 1) { /* Erlang distribution with mean = X */ RETVAL *= SvNV(ST(idx+1)); } OUTPUT: RETVAL # poisson # # Returns random numbers from a Poisson distribution. IV poisson(...) PREINIT: DUAL_VARS; NV mean; NV em, tang, bound, limit; CODE: DUAL_PRNG /* Check argument(s) */ if (! items) { Perl_croak(aTHX_ "Missing argument(s) to 'poisson'"); } if (items == 1) { if ((mean = SvNV(ST(idx))) <= 0.0) { Perl_croak(aTHX_ "Bad argument (<= 0) to 'poisson'"); } } else { if ((mean = SvNV(ST(idx)) * SvNV(ST(idx+1))) < 1.0) { Perl_croak(aTHX_ "Bad arguments (rate*time <= 0) to 'poisson'"); } } if (mean < 12.0) { /* Direct method */ bound = 1.0; limit = exp(-mean); for (RETVAL=0; ; RETVAL++) { bound *= _rand(prng); if (bound < limit) { break; } } } else { /* Rejection method */ /* See 'Numerical Recipes in C', Chapter 7.3 */ if (prng->poisson.mean != mean) { prng->poisson.mean = mean; prng->poisson.log_mean = log(mean); prng->poisson.sqrt2mean = sqrt(2.0 * mean); prng->poisson.term = (mean * prng->poisson.log_mean) - _ln_gamma(mean + 1.0); } do { do { tang = _tan(prng); em = (tang * prng->poisson.sqrt2mean) + mean; } while (em < 0.0); em = floor(em); bound = 0.9 * (1.0 + tang*tang) * exp((em * prng->poisson.log_mean) - _ln_gamma(em+1.0) - prng->poisson.term); } while (_rand(prng) > bound); RETVAL = (int)em; } OUTPUT: RETVAL # binomial # # Returns random numbers from a binomial distribution. IV binomial(...) PREINIT: DUAL_VARS; NV prob; IV trials; int ii; NV p, pc, mean; NV en, em, tang, bound, limit, sq; CODE: DUAL_PRNG /* Check argument(s) */ if (items < 2) { Perl_croak(aTHX_ "Missing argument(s) to 'binomial'"); } if (((prob = SvNV(ST(idx))) < 0.0 || prob > 1.0) || ((trials = SvIV(ST(idx+1))) < 0)) { Perl_croak(aTHX_ "Invalid argument(s) to 'binomial'"); } /* If probability > .5, then calculate based on non-occurance */ p = (prob <= 0.5) ? prob : 1.0-prob; if (trials < 25) { /* Direct method */ RETVAL = 0; for (ii=1; ii <= trials; ii++) { if (_rand(prng) < p) { RETVAL++; } } } else { if ((mean = p * trials) < 1.0) { /* Use direct Poisson method */ bound = 1.0; limit = exp(-mean); for (RETVAL=0; RETVAL < trials; RETVAL++) { bound *= _rand(prng); if (bound < limit) { break; } } } else { /* Rejection method */ /* See 'Numerical Recipes in C', Chapter 7.3 */ en = (NV)trials; pc = 1.0 - p; sq = sqrt(2.0 * mean * pc); if (trials != prng->binomial.trials) { prng->binomial.trials = trials; prng->binomial.term = _ln_gamma(en + 1.0); } if (p != prng->binomial.prob) { prng->binomial.prob = p; prng->binomial.plog = log(p); prng->binomial.pclog = log(pc); } do { do { tang = _tan(prng); em = (sq * tang) + mean; } while (em < 0.0 || em >= (en+1.0)); em = floor(em); bound = 1.2 * sq * (1.0 + tang*tang) * exp(prng->binomial.term - _ln_gamma(em + 1.0) - _ln_gamma(en - em + 1.0) + em * prng->binomial.plog + (en - em) * prng->binomial.pclog); } while (_rand(prng) > bound); RETVAL = (IV)em; } } /* Adjust results for occurance vs. non-occurance */ if (p < prob) { RETVAL = trials - RETVAL; } OUTPUT: RETVAL # The functions below are for internal use by the Math::Random::MT::Auto # package. MODULE = Math::Random::MT::Auto PACKAGE = Math::Random::MT::Auto::_ # new_prng # # Creates a new PRNG context for the OO Interface, and returns a pointer to it. SV * new_prng(...) PREINIT: struct mt *prng; CODE: Newxz(prng, 1, struct mt); /* Initializes with minimal data to ensure it's 'safe' */ prng->state[0] = HI_BIT; prng->left = 1; prng->poisson.mean = -1; prng->binomial.trials = -1; prng->binomial.prob = -1.0; RETVAL = newSVuv(PTR2UV(prng)); OUTPUT: RETVAL # free_prng # # Frees the PRNG context as part of object destruction. void free_prng(...) PREINIT: PRNG_VARS; struct mt *prng; CODE: PRNG_PREP; if ((prng = GET_PRNG)) { Safefree(prng); } # seed_prng # # Applies a supplied seed to a specified PRNG. # # The specified PRNG may be either the standalone PRNG or an object's PRNG. void seed_prng(...) PREINIT: PRNG_VARS; struct mt *prng; AV *myseed; int len; UV *st; int ii, jj, kk; CODE: PRNG_PREP; prng = GET_PRNG; /* Extract argument */ myseed = (AV*)SvRV(ST(1)); len = av_len(myseed)+1; st = prng->state; /* Initialize */ st[0]= 19650218; for (ii=1; ii> BIT_SHIFT)) + ii); } /* Add supplied seed */ ii=1; jj=0; for (kk = ((N>len) ? N : len); kk; kk--) { st[ii] = (st[ii] ^ ((st[ii-1] ^ (st[ii-1] >> BIT_SHIFT)) * MAGIC2)) + SvUV(*av_fetch(myseed, jj, 0)) + jj; if (++ii >= N) { st[0] = st[N-1]; ii=1; } if (++jj >= len) jj=0; } /* Final shuffle */ for (kk=N-1; kk; kk--) { st[ii] = (st[ii] ^ ((st[ii-1] ^ (st[ii-1] >> BIT_SHIFT)) * MAGIC3)) - ii; if (++ii >= N) { st[0] = st[N-1]; ii=1; } } /* Guarantee non-zero initial state */ st[0] = HI_BIT; /* Forces twist when first random is requested */ prng->left = 1; # get_state # # Returns an array ref containing the state vector and internal data for a # specified PRNG. # # The specified PRNG may be either the standalone PRNG or an object's PRNG. SV * get_state(...) PREINIT: PRNG_VARS; struct mt *prng; AV *state; int ii; CODE: PRNG_PREP; prng = GET_PRNG; /* Create state array */ state = newAV(); av_extend(state, N+12); /* Add internal PRNG state to array */ for (ii=0; iistate[ii])); } av_push(state, newSViv(prng->left)); /* Add non-uniform deviate function data to array */ av_push(state, newSViv(prng->gaussian.have)); av_push(state, newSVnv(prng->gaussian.value)); av_push(state, newSVnv(prng->poisson.mean)); av_push(state, newSVnv(prng->poisson.log_mean)); av_push(state, newSVnv(prng->poisson.sqrt2mean)); av_push(state, newSVnv(prng->poisson.term)); av_push(state, newSViv(prng->binomial.trials)); av_push(state, newSVnv(prng->binomial.term)); av_push(state, newSVnv(prng->binomial.prob)); av_push(state, newSVnv(prng->binomial.plog)); av_push(state, newSVnv(prng->binomial.pclog)); RETVAL = newRV_noinc((SV *)state); OUTPUT: RETVAL # set_state # # Sets the specified PRNG's state vector and internal data from a supplied # array ref. # # The specified PRNG may be either the standalone PRNG or an object's PRNG. void set_state(...) PREINIT: PRNG_VARS; struct mt *prng; AV *state; int ii; CODE: PRNG_PREP; prng = GET_PRNG; /* Extract argument */ state = (AV*)SvRV(ST(1)); /* Validate size of argument */ if (av_len(state) != N+11) { Perl_croak(aTHX_ "Invalid state vector"); } /* Extract internal PRNG state from array */ for (ii=0; iistate[ii] = SvUV(*av_fetch(state, ii, 0)); } prng->left = SvIV(*av_fetch(state, ii, 0)); ii++; if (prng->left > 1) { prng->next = &prng->state[(N+1) - prng->left]; } /* Extract non-uniform deviate function data from array */ prng->gaussian.have = SvIV(*av_fetch(state, ii, 0)); ii++; prng->gaussian.value = SvNV(*av_fetch(state, ii, 0)); ii++; prng->poisson.mean = SvNV(*av_fetch(state, ii, 0)); ii++; prng->poisson.log_mean = SvNV(*av_fetch(state, ii, 0)); ii++; prng->poisson.sqrt2mean = SvNV(*av_fetch(state, ii, 0)); ii++; prng->poisson.term = SvNV(*av_fetch(state, ii, 0)); ii++; prng->binomial.trials = SvIV(*av_fetch(state, ii, 0)); ii++; prng->binomial.term = SvNV(*av_fetch(state, ii, 0)); ii++; prng->binomial.prob = SvNV(*av_fetch(state, ii, 0)); ii++; prng->binomial.plog = SvNV(*av_fetch(state, ii, 0)); ii++; prng->binomial.pclog = SvNV(*av_fetch(state, ii, 0)); /* EOF */