5 ----------------------------------------------------------------------
7 ppport.h -- Perl/Pollution/Portability Version 3.06_01
9 Automatically created by Devel::PPPort running under
10 perl 5.008008 on Fri Apr 6 14:13:45 2007.
12 Do NOT edit this file directly! -- Edit PPPort_pm.PL and the
13 includes in parts/inc/ instead.
15 Use 'perldoc ppport.h' to view the documentation below.
17 ----------------------------------------------------------------------
25 ppport.h - Perl/Pollution/Portability version 3.06_01
29 perl ppport.h [options] [source files]
31 Searches current directory for files if no [source files] are given
33 --help show short help
35 --patch=file write one patch file with changes
36 --copy=suffix write changed copies with suffix
37 --diff=program use diff program and options
39 --compat-version=version provide compatibility with Perl version
40 --cplusplus accept C++ comments
42 --quiet don't output anything except fatal errors
43 --nodiag don't show diagnostics
44 --nohints don't show hints
45 --nochanges don't suggest changes
46 --nofilter don't filter input files
48 --list-provided list provided API
49 --list-unsupported list unsupported API
50 --api-info=name show Perl API portability information
54 This version of F<ppport.h> is designed to support operation with Perl
55 installations back to 5.003, and has been tested up to 5.9.3.
61 Display a brief usage summary.
63 =head2 --patch=I<file>
65 If this option is given, a single patch file will be created if
66 any changes are suggested. This requires a working diff program
67 to be installed on your system.
69 =head2 --copy=I<suffix>
71 If this option is given, a copy of each file will be saved with
72 the given suffix that contains the suggested changes. This does
73 not require any external programs.
75 If neither C<--patch> or C<--copy> are given, the default is to
76 simply print the diffs for each file. This requires either
77 C<Text::Diff> or a C<diff> program to be installed.
79 =head2 --diff=I<program>
81 Manually set the diff program and options to use. The default
82 is to use C<Text::Diff>, when installed, and output unified
85 =head2 --compat-version=I<version>
87 Tell F<ppport.h> to check for compatibility with the given
88 Perl version. The default is to check for compatibility with Perl
89 version 5.003. You can use this option to reduce the output
90 of F<ppport.h> if you intend to be backward compatible only
91 up to a certain Perl version.
95 Usually, F<ppport.h> will detect C++ style comments and
96 replace them with C style comments for portability reasons.
97 Using this option instructs F<ppport.h> to leave C++
102 Be quiet. Don't print anything except fatal errors.
106 Don't output any diagnostic messages. Only portability
107 alerts will be printed.
111 Don't output any hints. Hints often contain useful portability
116 Don't suggest any changes. Only give diagnostic output and hints
117 unless these are also deactivated.
121 Don't filter the list of input files. By default, files not looking
122 like source code (i.e. not *.xs, *.c, *.cc, *.cpp or *.h) are skipped.
124 =head2 --list-provided
126 Lists the API elements for which compatibility is provided by
127 F<ppport.h>. Also lists if it must be explicitly requested,
128 if it has dependencies, and if there are hints for it.
130 =head2 --list-unsupported
132 Lists the API elements that are known not to be supported by
133 F<ppport.h> and below which version of Perl they probably
134 won't be available or work.
136 =head2 --api-info=I<name>
138 Show portability information for API elements matching I<name>.
139 If I<name> is surrounded by slashes, it is interpreted as a regular
144 In order for a Perl extension (XS) module to be as portable as possible
145 across differing versions of Perl itself, certain steps need to be taken.
151 Including this header is the first major one. This alone will give you
152 access to a large part of the Perl API that hasn't been available in
153 earlier Perl releases. Use
155 perl ppport.h --list-provided
157 to see which API elements are provided by ppport.h.
161 You should avoid using deprecated parts of the API. For example, using
162 global Perl variables without the C<PL_> prefix is deprecated. Also,
163 some API functions used to have a C<perl_> prefix. Using this form is
164 also deprecated. You can safely use the supported API, as F<ppport.h>
165 will provide wrappers for older Perl versions.
169 If you use one of a few functions that were not present in earlier
170 versions of Perl, and that can't be provided using a macro, you have
171 to explicitly request support for these functions by adding one or
172 more C<#define>s in your source code before the inclusion of F<ppport.h>.
174 These functions will be marked C<explicit> in the list shown by
177 Depending on whether you module has a single or multiple files that
178 use such functions, you want either C<static> or global variants.
180 For a C<static> function, use:
182 #define NEED_function
184 For a global function, use:
186 #define NEED_function_GLOBAL
188 Note that you mustn't have more than one global request for one
189 function in your project.
191 Function Static Request Global Request
192 -----------------------------------------------------------------------------------------
193 eval_pv() NEED_eval_pv NEED_eval_pv_GLOBAL
194 grok_bin() NEED_grok_bin NEED_grok_bin_GLOBAL
195 grok_hex() NEED_grok_hex NEED_grok_hex_GLOBAL
196 grok_number() NEED_grok_number NEED_grok_number_GLOBAL
197 grok_numeric_radix() NEED_grok_numeric_radix NEED_grok_numeric_radix_GLOBAL
198 grok_oct() NEED_grok_oct NEED_grok_oct_GLOBAL
199 newCONSTSUB() NEED_newCONSTSUB NEED_newCONSTSUB_GLOBAL
200 newRV_noinc() NEED_newRV_noinc NEED_newRV_noinc_GLOBAL
201 sv_2pv_nolen() NEED_sv_2pv_nolen NEED_sv_2pv_nolen_GLOBAL
202 sv_2pvbyte() NEED_sv_2pvbyte NEED_sv_2pvbyte_GLOBAL
203 sv_catpvf_mg() NEED_sv_catpvf_mg NEED_sv_catpvf_mg_GLOBAL
204 sv_catpvf_mg_nocontext() NEED_sv_catpvf_mg_nocontext NEED_sv_catpvf_mg_nocontext_GLOBAL
205 sv_setpvf_mg() NEED_sv_setpvf_mg NEED_sv_setpvf_mg_GLOBAL
206 sv_setpvf_mg_nocontext() NEED_sv_setpvf_mg_nocontext NEED_sv_setpvf_mg_nocontext_GLOBAL
207 vnewSVpvf() NEED_vnewSVpvf NEED_vnewSVpvf_GLOBAL
209 To avoid namespace conflicts, you can change the namespace of the
210 explicitly exported functions using the C<DPPP_NAMESPACE> macro.
211 Just C<#define> the macro before including C<ppport.h>:
213 #define DPPP_NAMESPACE MyOwnNamespace_
216 The default namespace is C<DPPP_>.
220 The good thing is that most of the above can be checked by running
221 F<ppport.h> on your source code. See the next section for
226 To verify whether F<ppport.h> is needed for your module, whether you
227 should make any changes to your code, and whether any special defines
228 should be used, F<ppport.h> can be run as a Perl script to check your
229 source code. Simply say:
233 The result will usually be a list of patches suggesting changes
234 that should at least be acceptable, if not necessarily the most
235 efficient solution, or a fix for all possible problems.
237 If you know that your XS module uses features only available in
238 newer Perl releases, if you're aware that it uses C++ comments,
239 and if you want all suggestions as a single patch file, you could
240 use something like this:
242 perl ppport.h --compat-version=5.6.0 --cplusplus --patch=test.diff
244 If you only want your code to be scanned without any suggestions
247 perl ppport.h --nochanges
249 You can specify a different C<diff> program or options, using
250 the C<--diff> option:
252 perl ppport.h --diff='diff -C 10'
254 This would output context diffs with 10 lines of context.
256 To display portability information for the C<newSVpvn> function,
259 perl ppport.h --api-info=newSVpvn
261 Since the argument to C<--api-info> can be a regular expression,
264 perl ppport.h --api-info=/_nomg$/
266 to display portability information for all C<_nomg> functions or
268 perl ppport.h --api-info=/./
270 to display information for all known API elements.
274 If this version of F<ppport.h> is causing failure during
275 the compilation of this module, please check if newer versions
276 of either this module or C<Devel::PPPort> are available on CPAN
277 before sending a bug report.
279 If F<ppport.h> was generated using the latest version of
280 C<Devel::PPPort> and is causing failure of this module, please
281 file a bug report using the CPAN Request Tracker at L<http://rt.cpan.org/>.
283 Please include the following information:
289 The complete output from running "perl -V"
297 The name and version of the module you were trying to build.
301 A full log of the build that failed.
305 Any other information that you think could be relevant.
309 For the latest version of this code, please get the C<Devel::PPPort>
314 Version 3.x, Copyright (c) 2004-2005, Marcus Holland-Moritz.
316 Version 2.x, Copyright (C) 2001, Paul Marquess.
318 Version 1.x, Copyright (C) 1999, Kenneth Albanowski.
320 This program is free software; you can redistribute it and/or
321 modify it under the same terms as Perl itself.
325 See L<Devel::PPPort>.
340 my($ppport) = $0 =~ /([\w.]+)$/;
341 my $LF = '(?:\r\n|[\r\n])'; # line feed
342 my $HS = "[ \t]"; # horizontal whitespace
345 require Getopt::Long;
346 Getopt::Long::GetOptions(\%opt, qw(
347 help quiet diag! filter! hints! changes! cplusplus
348 patch=s copy=s diff=s compat-version=s
349 list-provided list-unsupported api-info=s
353 if ($@ and grep /^-/, @ARGV) {
354 usage() if "@ARGV" =~ /^--?h(?:elp)?$/;
355 die "Getopt::Long not found. Please don't use any options.\n";
358 usage() if $opt{help};
360 if (exists $opt{'compat-version'}) {
361 my($r,$v,$s) = eval { parse_version($opt{'compat-version'}) };
363 die "Invalid version number format: '$opt{'compat-version'}'\n";
365 die "Only Perl 5 is supported\n" if $r != 5;
366 die "Invalid version number: $opt{'compat-version'}\n" if $v >= 1000 || $s >= 1000;
367 $opt{'compat-version'} = sprintf "%d.%03d%03d", $r, $v, $s;
370 $opt{'compat-version'} = 5;
373 # Never use C comments in this file!!!!!
376 my $rccs = quotemeta $ccs;
377 my $rcce = quotemeta $cce;
379 my %API = map { /^(\w+)\|([^|]*)\|([^|]*)\|(\w*)$/
381 ($2 ? ( base => $2 ) : ()),
382 ($3 ? ( todo => $3 ) : ()),
383 (index($4, 'v') >= 0 ? ( varargs => 1 ) : ()),
384 (index($4, 'p') >= 0 ? ( provided => 1 ) : ()),
385 (index($4, 'n') >= 0 ? ( nothxarg => 1 ) : ()),
387 : die "invalid spec: $_" } qw(
393 CopFILEAV|5.006000||p
394 CopFILEGV_set|5.006000||p
395 CopFILEGV|5.006000||p
396 CopFILESV|5.006000||p
397 CopFILE_set|5.006000||p
399 CopSTASHPV_set|5.006000||p
400 CopSTASHPV|5.006000||p
401 CopSTASH_eq|5.006000||p
402 CopSTASH_set|5.006000||p
410 END_EXTERN_C|5.005000||p
418 GROK_NUMERIC_RADIX|5.007002||p
433 HeSVKEY_force||5.004000|
434 HeSVKEY_set||5.004000|
439 IN_LOCALE_COMPILETIME|5.007002||p
440 IN_LOCALE_RUNTIME|5.007002||p
441 IN_LOCALE|5.007002||p
442 IN_PERL_COMPILETIME|5.008001||p
443 IS_NUMBER_GREATER_THAN_UV_MAX|5.007002||p
444 IS_NUMBER_INFINITY|5.007002||p
445 IS_NUMBER_IN_UV|5.007002||p
446 IS_NUMBER_NAN|5.007003||p
447 IS_NUMBER_NEG|5.007002||p
448 IS_NUMBER_NOT_INT|5.007002||p
455 MY_CXT_CLONE|5.009002||p
456 MY_CXT_INIT|5.007003||p
478 PAD_COMPNAME_FLAGS|||
479 PAD_COMPNAME_GEN_set|||
481 PAD_COMPNAME_OURSTASH|||
486 PAD_SAVE_SETNULLPAD|||
488 PAD_SET_CUR_NOSAVE|||
492 PERL_BCDVERSION|5.009003||p
493 PERL_GCC_BRACE_GROUPS_FORBIDDEN|5.008001||p
494 PERL_INT_MAX|5.004000||p
495 PERL_INT_MIN|5.004000||p
496 PERL_LONG_MAX|5.004000||p
497 PERL_LONG_MIN|5.004000||p
498 PERL_MAGIC_arylen|5.007002||p
499 PERL_MAGIC_backref|5.007002||p
500 PERL_MAGIC_bm|5.007002||p
501 PERL_MAGIC_collxfrm|5.007002||p
502 PERL_MAGIC_dbfile|5.007002||p
503 PERL_MAGIC_dbline|5.007002||p
504 PERL_MAGIC_defelem|5.007002||p
505 PERL_MAGIC_envelem|5.007002||p
506 PERL_MAGIC_env|5.007002||p
507 PERL_MAGIC_ext|5.007002||p
508 PERL_MAGIC_fm|5.007002||p
509 PERL_MAGIC_glob|5.007002||p
510 PERL_MAGIC_isaelem|5.007002||p
511 PERL_MAGIC_isa|5.007002||p
512 PERL_MAGIC_mutex|5.007002||p
513 PERL_MAGIC_nkeys|5.007002||p
514 PERL_MAGIC_overload_elem|5.007002||p
515 PERL_MAGIC_overload_table|5.007002||p
516 PERL_MAGIC_overload|5.007002||p
517 PERL_MAGIC_pos|5.007002||p
518 PERL_MAGIC_qr|5.007002||p
519 PERL_MAGIC_regdata|5.007002||p
520 PERL_MAGIC_regdatum|5.007002||p
521 PERL_MAGIC_regex_global|5.007002||p
522 PERL_MAGIC_shared_scalar|5.007003||p
523 PERL_MAGIC_shared|5.007003||p
524 PERL_MAGIC_sigelem|5.007002||p
525 PERL_MAGIC_sig|5.007002||p
526 PERL_MAGIC_substr|5.007002||p
527 PERL_MAGIC_sv|5.007002||p
528 PERL_MAGIC_taint|5.007002||p
529 PERL_MAGIC_tiedelem|5.007002||p
530 PERL_MAGIC_tiedscalar|5.007002||p
531 PERL_MAGIC_tied|5.007002||p
532 PERL_MAGIC_utf8|5.008001||p
533 PERL_MAGIC_uvar_elem|5.007003||p
534 PERL_MAGIC_uvar|5.007002||p
535 PERL_MAGIC_vec|5.007002||p
536 PERL_MAGIC_vstring|5.008001||p
537 PERL_QUAD_MAX|5.004000||p
538 PERL_QUAD_MIN|5.004000||p
539 PERL_REVISION|5.006000||p
540 PERL_SCAN_ALLOW_UNDERSCORES|5.007003||p
541 PERL_SCAN_DISALLOW_PREFIX|5.007003||p
542 PERL_SCAN_GREATER_THAN_UV_MAX|5.007003||p
543 PERL_SCAN_SILENT_ILLDIGIT|5.008001||p
544 PERL_SHORT_MAX|5.004000||p
545 PERL_SHORT_MIN|5.004000||p
546 PERL_SUBVERSION|5.006000||p
547 PERL_UCHAR_MAX|5.004000||p
548 PERL_UCHAR_MIN|5.004000||p
549 PERL_UINT_MAX|5.004000||p
550 PERL_UINT_MIN|5.004000||p
551 PERL_ULONG_MAX|5.004000||p
552 PERL_ULONG_MIN|5.004000||p
553 PERL_UNUSED_DECL|5.007002||p
554 PERL_UQUAD_MAX|5.004000||p
555 PERL_UQUAD_MIN|5.004000||p
556 PERL_USHORT_MAX|5.004000||p
557 PERL_USHORT_MIN|5.004000||p
558 PERL_VERSION|5.006000||p
563 PL_compiling|5.004050||p
564 PL_copline|5.005000||p
565 PL_curcop|5.004050||p
566 PL_curstash|5.004050||p
567 PL_debstash|5.004050||p
569 PL_diehook|5.004050||p
573 PL_hexdigit|5.005000||p
576 PL_modglobal||5.005000|n
578 PL_no_modify|5.006000||p
580 PL_perl_destruct_level|5.004050||p
581 PL_perldb|5.004050||p
582 PL_ppaddr|5.006000||p
583 PL_rsfp_filters|5.004050||p
586 PL_stack_base|5.004050||p
587 PL_stack_sp|5.004050||p
588 PL_stdingv|5.004050||p
589 PL_sv_arenaroot|5.004050||p
590 PL_sv_no|5.004050||pn
591 PL_sv_undef|5.004050||pn
592 PL_sv_yes|5.004050||pn
593 PL_tainted|5.004050||p
594 PL_tainting|5.004050||p
598 POPpbytex||5.007001|n
609 PUSHmortal|5.009002||p
615 PerlIO_clearerr||5.007003|
616 PerlIO_close||5.007003|
617 PerlIO_eof||5.007003|
618 PerlIO_error||5.007003|
619 PerlIO_fileno||5.007003|
620 PerlIO_fill||5.007003|
621 PerlIO_flush||5.007003|
622 PerlIO_get_base||5.007003|
623 PerlIO_get_bufsiz||5.007003|
624 PerlIO_get_cnt||5.007003|
625 PerlIO_get_ptr||5.007003|
626 PerlIO_read||5.007003|
627 PerlIO_seek||5.007003|
628 PerlIO_set_cnt||5.007003|
629 PerlIO_set_ptrcnt||5.007003|
630 PerlIO_setlinebuf||5.007003|
631 PerlIO_stderr||5.007003|
632 PerlIO_stdin||5.007003|
633 PerlIO_stdout||5.007003|
634 PerlIO_tell||5.007003|
635 PerlIO_unread||5.007003|
636 PerlIO_write||5.007003|
645 SAVE_DEFSV|5.004050||p
648 START_EXTERN_C|5.005000||p
649 START_MY_CXT|5.007003||p
667 SvGETMAGIC|5.004050||p
670 SvIOK_notUV||5.006000|
672 SvIOK_only_UV||5.006000|
678 SvIV_nomg|5.009001||p
682 SvIsCOW_shared_hash||5.008003|
687 SvMAGIC_set||5.009003|
703 SvPOK_only_UTF8||5.006000|
709 SvPV_force_nomg|5.007002||p
711 SvPV_nolen|5.006000||p
712 SvPV_nomg|5.007002||p
714 SvPVbyte_force||5.009002|
715 SvPVbyte_nolen||5.006000|
716 SvPVbytex_force||5.006000|
719 SvPVutf8_force||5.006000|
720 SvPVutf8_nolen||5.006000|
721 SvPVutf8x_force||5.006000|
736 SvSTASH_set||5.009003|
738 SvSetMagicSV_nosteal||5.004000|
739 SvSetMagicSV||5.004000|
740 SvSetSV_nosteal||5.004000|
742 SvTAINTED_off||5.004000|
743 SvTAINTED_on||5.004000|
751 SvUTF8_off||5.006000|
756 SvUV_nomg|5.009001||p
769 XCPT_CATCH|5.009002||p
770 XCPT_RETHROW|5.009002||p
771 XCPT_TRY_END|5.009002||p
772 XCPT_TRY_START|5.009002||p
774 XPUSHmortal|5.009002||p
785 XSRETURN_UV|5.008001||p
795 XS_VERSION_BOOTCHECK|||
814 apply_attrs_string||5.006001|
819 atfork_lock||5.007003|n
820 atfork_unlock||5.007003|n
821 av_arylen_p||5.009003|
842 block_gimme||5.004000|
846 boot_core_UNIVERSAL|||
848 bytes_from_utf8||5.007001|
849 bytes_to_utf8||5.006001|
851 call_argv|5.006000||p
852 call_atexit||5.006000|
856 call_method|5.006000||p
863 cast_ulong||5.006000|
921 csighandler||5.007001|n
922 custom_op_desc||5.007003|
923 custom_op_name||5.007003|
926 cv_const_sv||5.004000|
936 dMY_CXT_SV|5.007003||p
945 dUNDERBAR|5.009002||p
955 debprofdump||5.005000|
957 debstackptrs||5.007003|
966 despatch_signals||5.007001|
976 do_binmode||5.004050|
985 do_gv_dump||5.006000|
986 do_gvgv_dump||5.006000|
987 do_hv_dump||5.006000|
992 do_magic_dump||5.006000|
996 do_op_dump||5.006000|
1001 do_pmop_dump||5.006000|
1010 do_sv_dump||5.006000|
1013 do_trans_complex_utf8|||
1015 do_trans_count_utf8|||
1017 do_trans_simple_utf8|||
1029 doing_taint||5.008001|n
1041 dump_eval||5.006000|
1043 dump_form||5.006000|
1044 dump_indent||5.006000|v
1046 dump_packsubs||5.006000|
1048 dump_vindent||5.006000|
1055 fbm_compile||5.005000|
1056 fbm_instr||5.005000|
1066 find_rundefsvoffset||5.009002|
1079 fprintf_nocontext|||vn
1080 free_global_struct|||
1081 free_tied_hv_pool|||
1083 gen_constant_list|||
1085 get_context||5.006000|n
1094 get_op_descs||5.005000|
1095 get_op_names||5.005000|
1097 get_ppaddr||5.006000|
1100 getcwd_sv||5.007002|
1105 grok_bin|5.007003||p
1106 grok_hex|5.007003||p
1107 grok_number|5.007002||p
1108 grok_numeric_radix|5.007002||p
1109 grok_oct|5.007003||p
1114 gv_autoload4||5.004000|
1117 gv_efullname3||5.004000|
1118 gv_efullname4||5.006001|
1122 gv_fetchmeth_autoload||5.007003|
1123 gv_fetchmethod_autoload||5.004000|
1126 gv_fetchpvn_flags||5.009002|
1128 gv_fetchsv||5.009002|
1129 gv_fullname3||5.004000|
1130 gv_fullname4||5.006001|
1132 gv_handler||5.007001|
1136 gv_stashpvn|5.006000||p
1143 hv_assert||5.009001|
1145 hv_clear_placeholders||5.009001|
1147 hv_delayfree_ent||5.004000|
1149 hv_delete_ent||5.004000|
1151 hv_eiter_p||5.009003|
1152 hv_eiter_set||5.009003|
1153 hv_exists_ent||5.004000|
1156 hv_fetch_ent||5.004000|
1158 hv_free_ent||5.004000|
1160 hv_iterkeysv||5.004000|
1162 hv_iternext_flags||5.008000|
1166 hv_ksplit||5.004000|
1169 hv_name_set||5.009003|
1171 hv_placeholders_get||5.009003|
1172 hv_placeholders_p||5.009003|
1173 hv_placeholders_set||5.009003|
1174 hv_riter_p||5.009003|
1175 hv_riter_set||5.009003|
1176 hv_scalar||5.009001|
1177 hv_store_ent||5.004000|
1178 hv_store_flags||5.008000|
1181 ibcmp_locale||5.004000|
1182 ibcmp_utf8||5.007003|
1188 init_argv_symbols|||
1190 init_global_struct|||
1191 init_i18nl10n||5.006000|
1192 init_i18nl14n||5.006000|
1198 init_postdump_symbols|||
1199 init_predump_symbols|||
1200 init_stacks||5.005000|
1217 is_handle_constructor|||
1218 is_list_assignment|||
1219 is_lvalue_sub||5.007001|
1220 is_uni_alnum_lc||5.006000|
1221 is_uni_alnumc_lc||5.006000|
1222 is_uni_alnumc||5.006000|
1223 is_uni_alnum||5.006000|
1224 is_uni_alpha_lc||5.006000|
1225 is_uni_alpha||5.006000|
1226 is_uni_ascii_lc||5.006000|
1227 is_uni_ascii||5.006000|
1228 is_uni_cntrl_lc||5.006000|
1229 is_uni_cntrl||5.006000|
1230 is_uni_digit_lc||5.006000|
1231 is_uni_digit||5.006000|
1232 is_uni_graph_lc||5.006000|
1233 is_uni_graph||5.006000|
1234 is_uni_idfirst_lc||5.006000|
1235 is_uni_idfirst||5.006000|
1236 is_uni_lower_lc||5.006000|
1237 is_uni_lower||5.006000|
1238 is_uni_print_lc||5.006000|
1239 is_uni_print||5.006000|
1240 is_uni_punct_lc||5.006000|
1241 is_uni_punct||5.006000|
1242 is_uni_space_lc||5.006000|
1243 is_uni_space||5.006000|
1244 is_uni_upper_lc||5.006000|
1245 is_uni_upper||5.006000|
1246 is_uni_xdigit_lc||5.006000|
1247 is_uni_xdigit||5.006000|
1248 is_utf8_alnumc||5.006000|
1249 is_utf8_alnum||5.006000|
1250 is_utf8_alpha||5.006000|
1251 is_utf8_ascii||5.006000|
1252 is_utf8_char_slow|||
1253 is_utf8_char||5.006000|
1254 is_utf8_cntrl||5.006000|
1255 is_utf8_digit||5.006000|
1256 is_utf8_graph||5.006000|
1257 is_utf8_idcont||5.008000|
1258 is_utf8_idfirst||5.006000|
1259 is_utf8_lower||5.006000|
1260 is_utf8_mark||5.006000|
1261 is_utf8_print||5.006000|
1262 is_utf8_punct||5.006000|
1263 is_utf8_space||5.006000|
1264 is_utf8_string_loclen||5.009003|
1265 is_utf8_string_loc||5.008001|
1266 is_utf8_string||5.006001|
1267 is_utf8_upper||5.006000|
1268 is_utf8_xdigit||5.006000|
1280 load_module_nocontext|||vn
1281 load_module||5.006000|v
1283 looks_like_number|||
1293 magic_clear_all_env|||
1297 magic_dump||5.006000|
1299 magic_freearylen_p|||
1314 magic_killbackrefs|||
1319 magic_regdata_cnt|||
1320 magic_regdatum_get|||
1321 magic_regdatum_set|||
1323 magic_set_all_env|||
1327 magic_setcollxfrm|||
1368 mg_length||5.005000|
1373 mini_mktime||5.007002|
1375 mode_from_discipline|||
1395 my_failure_exit||5.004000|
1396 my_fflush_all||5.006000|
1419 my_memcmp||5.004000|n
1422 my_pclose||5.004000|
1423 my_popen_list||5.007001|
1426 my_socketpair||5.007003|n
1428 my_strftime||5.007002|
1433 newANONATTRSUB||5.006000|
1438 newATTRSUB||5.006000|
1443 newCONSTSUB|5.006000||p
1467 newRV_inc|5.004000||p
1468 newRV_noinc|5.006000||p
1478 newSVpvf_nocontext|||vn
1479 newSVpvf||5.004000|v
1480 newSVpvn_share||5.007001|
1481 newSVpvn|5.006000||p
1488 newWHILEOP||5.009003|
1489 newXSproto||5.006000|
1491 new_collate||5.006000|
1493 new_ctype||5.006000|
1496 new_numeric||5.006000|
1497 new_stackinfo||5.005000|
1498 new_version||5.009000|
1503 no_bareword_allowed|||
1507 nothreadhook||5.008000|
1518 op_refcnt_lock||5.009002|
1519 op_refcnt_unlock||5.009002|
1521 pMY_CXT_|5.007003||p
1534 pad_compname_type|||
1537 pad_fixup_inner_anons|||
1549 parse_unicode_opts|||
1553 perl_alloc_using|||n
1555 perl_clone_using|||n
1558 perl_destruct||5.007003|n
1560 perl_parse||5.006000|n
1564 pmop_dump||5.006000|
1572 printf_nocontext|||vn
1581 pv_display||5.006000|
1582 pv_uni_display||5.007003|
1586 re_intuit_start||5.006000|
1587 re_intuit_string||5.006000|
1591 reentrant_retry|||vn
1600 regclass_swash||5.007003|
1607 regexec_flags||5.005000|
1613 reginitcolors||5.006000|
1632 require_pv||5.006000|
1636 rsignal_state||5.004000|
1639 runops_debug||5.005000|
1640 runops_standard||5.005000|
1645 safesyscalloc||5.006000|n
1646 safesysfree||5.006000|n
1647 safesysmalloc||5.006000|n
1648 safesysrealloc||5.006000|n
1653 save_aelem||5.004050|
1654 save_alloc||5.006000|
1657 save_bool||5.008001|
1660 save_destructor_x||5.006000|
1661 save_destructor||5.006000|
1665 save_generic_pvref||5.006001|
1666 save_generic_svref||5.005030|
1670 save_helem||5.004050|
1671 save_hints||5.005000|
1680 save_mortalizesv||5.007001|
1683 save_padsv||5.007001|
1685 save_re_context||5.006000|
1688 save_set_svflags||5.009000|
1689 save_shared_pvref||5.007003|
1692 save_threadsv||5.005000|
1693 save_vptr||5.006000|
1696 savesharedpv||5.007003|
1697 savestack_grow_cnt||5.008001|
1721 scan_version||5.009001|
1722 scan_vstring||5.008001|
1725 screaminstr||5.005000|
1727 set_context||5.006000|n
1729 set_numeric_local||5.006000|
1730 set_numeric_radix||5.006000|
1731 set_numeric_standard||5.006000|
1744 start_subparse||5.004000|
1745 stashpv_hvname_match||5.009003|
1753 str_to_version||5.006000|
1764 sv_2iuv_non_preserve|||
1765 sv_2iv_flags||5.009001|
1769 sv_2pv_flags||5.007002|
1770 sv_2pv_nolen|5.006000||p
1772 sv_2pvbyte|5.006000||p
1773 sv_2pvutf8_nolen||5.006000|
1774 sv_2pvutf8||5.006000|
1776 sv_2uv_flags||5.009001|
1782 sv_cat_decode||5.008001|
1783 sv_catpv_mg|5.006000||p
1784 sv_catpvf_mg_nocontext|||pvn
1785 sv_catpvf_mg|5.006000|5.004000|pv
1786 sv_catpvf_nocontext|||vn
1787 sv_catpvf||5.004000|v
1788 sv_catpvn_flags||5.007002|
1789 sv_catpvn_mg|5.006000||p
1790 sv_catpvn_nomg|5.007002||p
1793 sv_catsv_flags||5.007002|
1794 sv_catsv_mg|5.006000||p
1795 sv_catsv_nomg|5.007002||p
1801 sv_cmp_locale||5.004000|
1804 sv_compile_2op||5.008001|
1805 sv_copypv||5.007003|
1808 sv_derived_from||5.004000|
1812 sv_force_normal_flags||5.007001|
1813 sv_force_normal||5.006000|
1824 sv_len_utf8||5.006000|
1826 sv_magicext||5.007003|
1831 sv_nolocking||5.007003|
1832 sv_nosharing||5.007003|
1833 sv_nounlocking||5.007003|
1836 sv_pos_b2u||5.006000|
1837 sv_pos_u2b||5.006000|
1838 sv_pvbyten_force||5.006000|
1839 sv_pvbyten||5.006000|
1840 sv_pvbyte||5.006000|
1841 sv_pvn_force_flags||5.007002|
1843 sv_pvn_nomg|5.007003||p
1845 sv_pvutf8n_force||5.006000|
1846 sv_pvutf8n||5.006000|
1847 sv_pvutf8||5.006000|
1849 sv_recode_to_utf8||5.007003|
1856 sv_rvweaken||5.006000|
1857 sv_setiv_mg|5.006000||p
1859 sv_setnv_mg|5.006000||p
1861 sv_setpv_mg|5.006000||p
1862 sv_setpvf_mg_nocontext|||pvn
1863 sv_setpvf_mg|5.006000|5.004000|pv
1864 sv_setpvf_nocontext|||vn
1865 sv_setpvf||5.004000|v
1866 sv_setpviv_mg||5.008001|
1867 sv_setpviv||5.008001|
1868 sv_setpvn_mg|5.006000||p
1875 sv_setref_uv||5.007001|
1877 sv_setsv_flags||5.007002|
1878 sv_setsv_mg|5.006000||p
1879 sv_setsv_nomg|5.007002||p
1881 sv_setuv_mg|5.006000||p
1882 sv_setuv|5.006000||p
1883 sv_tainted||5.004000|
1887 sv_uni_display||5.007003|
1889 sv_unref_flags||5.007001|
1891 sv_untaint||5.004000|
1893 sv_usepvn_mg|5.006000||p
1895 sv_utf8_decode||5.006000|
1896 sv_utf8_downgrade||5.006000|
1897 sv_utf8_encode||5.006000|
1898 sv_utf8_upgrade_flags||5.007002|
1899 sv_utf8_upgrade||5.007001|
1901 sv_vcatpvf_mg|5.006000|5.004000|p
1902 sv_vcatpvfn||5.004000|
1903 sv_vcatpvf|5.006000|5.004000|p
1904 sv_vsetpvf_mg|5.006000|5.004000|p
1905 sv_vsetpvfn||5.004000|
1906 sv_vsetpvf|5.006000|5.004000|p
1909 swash_fetch||5.007002|
1910 swash_init||5.006000|
1916 tmps_grow||5.006000|
1920 to_uni_fold||5.007003|
1921 to_uni_lower_lc||5.006000|
1922 to_uni_lower||5.007003|
1923 to_uni_title_lc||5.006000|
1924 to_uni_title||5.007003|
1925 to_uni_upper_lc||5.006000|
1926 to_uni_upper||5.007003|
1927 to_utf8_case||5.007003|
1928 to_utf8_fold||5.007003|
1929 to_utf8_lower||5.007003|
1931 to_utf8_title||5.007003|
1932 to_utf8_upper||5.007003|
1935 too_few_arguments|||
1936 too_many_arguments|||
1939 unpack_str||5.007003|
1940 unpackstring||5.008001|
1941 unshare_hek_or_pvn|||
1943 unsharepvn||5.004000|
1944 upg_version||5.009000|
1947 utf16_to_utf8_reversed||5.006001|
1948 utf16_to_utf8||5.006001|
1949 utf16rev_textfilter|||
1950 utf8_distance||5.006000|
1952 utf8_length||5.007001|
1955 utf8_to_bytes||5.006001|
1956 utf8_to_uvchr||5.007001|
1957 utf8_to_uvuni||5.007001|
1958 utf8n_to_uvchr||5.007001|
1959 utf8n_to_uvuni||5.007001|
1961 uvchr_to_utf8_flags||5.007003|
1962 uvchr_to_utf8||5.007001|
1963 uvuni_to_utf8_flags||5.007003|
1964 uvuni_to_utf8||5.007001|
1975 vload_module||5.006000|
1977 vnewSVpvf|5.006000|5.004000|p
1980 vstringify||5.009000|
1985 warner_nocontext|||vn
1997 if (exists $opt{'list-unsupported'}) {
1999 for $f (sort { lc $a cmp lc $b } keys %API) {
2000 next unless $API{$f}{todo};
2001 print "$f ", '.'x(40-length($f)), " ", format_version($API{$f}{todo}), "\n";
2006 # Scan for possible replacement candidates
2008 my(%replace, %need, %hints, %depends);
2014 if (m{^\s*\*\s(.*?)\s*$}) {
2015 $hints{$hint} ||= ''; # suppress warning with older perls
2016 $hints{$hint} .= "$1\n";
2022 $hint = $1 if m{^\s*$rccs\sHint:\s+(\w+)\s*$};
2024 $replace = $1 if m{^\s*$rccs\s+Replace:\s+(\d+)\s+$rcce\s*$};
2025 $replace{$2} = $1 if $replace and m{^\s*#\s*define\s+(\w+)(?:\([^)]*\))?\s+(\w+)};
2026 $replace{$2} = $1 if m{^\s*#\s*define\s+(\w+)(?:\([^)]*\))?\s+(\w+).*$rccs\s+Replace\s+$rcce};
2027 $replace{$1} = $2 if m{^\s*$rccs\s+Replace (\w+) with (\w+)\s+$rcce\s*$};
2029 if (m{^\s*$rccs\s+(\w+)\s+depends\s+on\s+(\w+(\s*,\s*\w+)*)\s+$rcce\s*$}) {
2030 push @{$depends{$1}}, map { s/\s+//g; $_ } split /,/, $2;
2033 $need{$1} = 1 if m{^#if\s+defined\(NEED_(\w+)(?:_GLOBAL)?\)};
2036 if (exists $opt{'api-info'}) {
2039 my $match = $opt{'api-info'} =~ m!^/(.*)/$! ? $1 : "^\Q$opt{'api-info'}\E\$";
2040 for $f (sort { lc $a cmp lc $b } keys %API) {
2041 next unless $f =~ /$match/;
2042 print "\n=== $f ===\n\n";
2044 if ($API{$f}{base} || $API{$f}{todo}) {
2045 my $base = format_version($API{$f}{base} || $API{$f}{todo});
2046 print "Supported at least starting from perl-$base.\n";
2049 if ($API{$f}{provided}) {
2050 my $todo = $API{$f}{todo} ? format_version($API{$f}{todo}) : "5.003";
2051 print "Support by $ppport provided back to perl-$todo.\n";
2052 print "Support needs to be explicitly requested by NEED_$f.\n" if exists $need{$f};
2053 print "Depends on: ", join(', ', @{$depends{$f}}), ".\n" if exists $depends{$f};
2054 print "$hints{$f}" if exists $hints{$f};
2058 print "No portability information available.\n";
2066 print "Found no API matching '$opt{'api-info'}'.\n";
2071 if (exists $opt{'list-provided'}) {
2073 for $f (sort { lc $a cmp lc $b } keys %API) {
2074 next unless $API{$f}{provided};
2076 push @flags, 'explicit' if exists $need{$f};
2077 push @flags, 'depend' if exists $depends{$f};
2078 push @flags, 'hint' if exists $hints{$f};
2079 my $flags = @flags ? ' ['.join(', ', @flags).']' : '';
2086 my @srcext = qw( xs c h cc cpp );
2087 my $srcext = join '|', @srcext;
2091 @files = grep { -f && !exists $seen{$_} } map { glob $_ } @ARGV;
2096 File::Find::find(sub {
2097 $File::Find::name =~ /\.($srcext)$/i
2098 and push @files, $File::Find::name;
2102 @files = map { glob "*.$_" } @srcext;
2106 if (!@ARGV || $opt{filter}) {
2108 my %xsc = map { /(.*)\.xs$/ ? ("$1.c" => 1, "$1.cc" => 1) : () } @files;
2110 my $out = exists $xsc{$_} || /\b\Q$ppport\E$/i || !/\.($srcext)$/i;
2111 push @{ $out ? \@out : \@in }, $_;
2113 if (@ARGV && @out) {
2114 warning("Skipping the following files (use --nofilter to avoid this):\n| ", join "\n| ", @out);
2120 die "No input files given!\n";
2123 my(%files, %global, %revreplace);
2124 %revreplace = reverse %replace;
2126 my $patch_opened = 0;
2128 for $filename (@files) {
2129 unless (open IN, "<$filename") {
2130 warn "Unable to read from $filename: $!\n";
2134 info("Scanning $filename ...");
2136 my $c = do { local $/; <IN> };
2139 my %file = (orig => $c, changes => 0);
2141 # temporarily remove C comments from the code
2147 (?:"[^"\\]*(?:\\.[^"\\]*)*" [^"'/]*)+
2149 (?:'[^'\\]*(?:\\.[^'\\]*)*' [^"'/]*)+
2153 \*[^*]*\*+(?:[^$ccs][^*]*\*+)* /
2158 defined $2 and push @ccom, $2;
2159 defined $1 ? $1 : "$ccs$#ccom$cce";
2162 $file{ccom} = \@ccom;
2164 $file{has_inc_ppport} = ($c =~ /#.*include.*\Q$ppport\E/);
2168 for $func (keys %API) {
2170 $match .= "|$revreplace{$func}" if exists $revreplace{$func};
2171 if ($c =~ /\b(?:Perl_)?($match)\b/) {
2172 $file{uses_replace}{$1}++ if exists $revreplace{$func} && $1 eq $revreplace{$func};
2173 $file{uses_Perl}{$func}++ if $c =~ /\bPerl_$func\b/;
2174 if (exists $API{$func}{provided}) {
2175 if (!exists $API{$func}{base} || $API{$func}{base} > $opt{'compat-version'}) {
2176 $file{uses}{$func}++;
2177 my @deps = rec_depend($func);
2179 $file{uses_deps}{$func} = \@deps;
2181 $file{uses}{$_} = 0 unless exists $file{uses}{$_};
2184 for ($func, @deps) {
2185 if (exists $need{$_}) {
2186 $file{needs}{$_} = 'static';
2191 if (exists $API{$func}{todo} && $API{$func}{todo} > $opt{'compat-version'}) {
2192 if ($c =~ /\b$func\b/) {
2193 $file{uses_todo}{$func}++;
2199 while ($c =~ /^$HS*#$HS*define$HS+(NEED_(\w+?)(_GLOBAL)?)\b/mg) {
2200 if (exists $need{$2}) {
2201 $file{defined $3 ? 'needed_global' : 'needed_static'}{$2}++;
2204 warning("Possibly wrong #define $1 in $filename");
2208 for (qw(uses needs uses_todo needed_global needed_static)) {
2209 for $func (keys %{$file{$_}}) {
2210 push @{$global{$_}{$func}}, $filename;
2214 $files{$filename} = \%file;
2217 # Globally resolve NEED_'s
2219 for $need (keys %{$global{needs}}) {
2220 if (@{$global{needs}{$need}} > 1) {
2221 my @targets = @{$global{needs}{$need}};
2222 my @t = grep $files{$_}{needed_global}{$need}, @targets;
2223 @targets = @t if @t;
2224 @t = grep /\.xs$/i, @targets;
2225 @targets = @t if @t;
2226 my $target = shift @targets;
2227 $files{$target}{needs}{$need} = 'global';
2228 for (@{$global{needs}{$need}}) {
2229 $files{$_}{needs}{$need} = 'extern' if $_ ne $target;
2234 for $filename (@files) {
2235 exists $files{$filename} or next;
2237 info("=== Analyzing $filename ===");
2239 my %file = %{$files{$filename}};
2241 my $c = $file{code};
2243 for $func (sort keys %{$file{uses_Perl}}) {
2244 if ($API{$func}{varargs}) {
2245 my $changes = ($c =~ s{\b(Perl_$func\s*\(\s*)(?!aTHX_?)(\)|[^\s)]*\))}
2246 { $1 . ($2 eq ')' ? 'aTHX' : 'aTHX_ ') . $2 }ge);
2248 warning("Doesn't pass interpreter argument aTHX to Perl_$func");
2249 $file{changes} += $changes;
2253 warning("Uses Perl_$func instead of $func");
2254 $file{changes} += ($c =~ s{\bPerl_$func(\s*)\((\s*aTHX_?)?\s*}
2259 for $func (sort keys %{$file{uses_replace}}) {
2260 warning("Uses $func instead of $replace{$func}");
2261 $file{changes} += ($c =~ s/\b$func\b/$replace{$func}/g);
2264 for $func (sort keys %{$file{uses}}) {
2265 next unless $file{uses}{$func}; # if it's only a dependency
2266 if (exists $file{uses_deps}{$func}) {
2267 diag("Uses $func, which depends on ", join(', ', @{$file{uses_deps}{$func}}));
2269 elsif (exists $replace{$func}) {
2270 warning("Uses $func instead of $replace{$func}");
2271 $file{changes} += ($c =~ s/\b$func\b/$replace{$func}/g);
2279 for $func (sort keys %{$file{uses_todo}}) {
2280 warning("Uses $func, which may not be portable below perl ",
2281 format_version($API{$func}{todo}));
2284 for $func (sort keys %{$file{needed_static}}) {
2286 if (not exists $file{uses}{$func}) {
2287 $message = "No need to define NEED_$func if $func is never used";
2289 elsif (exists $file{needs}{$func} && $file{needs}{$func} ne 'static') {
2290 $message = "No need to define NEED_$func when already needed globally";
2294 $file{changes} += ($c =~ s/^$HS*#$HS*define$HS+NEED_$func\b.*$LF//mg);
2298 for $func (sort keys %{$file{needed_global}}) {
2300 if (not exists $global{uses}{$func}) {
2301 $message = "No need to define NEED_${func}_GLOBAL if $func is never used";
2303 elsif (exists $file{needs}{$func}) {
2304 if ($file{needs}{$func} eq 'extern') {
2305 $message = "No need to define NEED_${func}_GLOBAL when already needed globally";
2307 elsif ($file{needs}{$func} eq 'static') {
2308 $message = "No need to define NEED_${func}_GLOBAL when only used in this file";
2313 $file{changes} += ($c =~ s/^$HS*#$HS*define$HS+NEED_${func}_GLOBAL\b.*$LF//mg);
2317 $file{needs_inc_ppport} = keys %{$file{uses}};
2319 if ($file{needs_inc_ppport}) {
2322 for $func (sort keys %{$file{needs}}) {
2323 my $type = $file{needs}{$func};
2324 next if $type eq 'extern';
2325 my $suffix = $type eq 'global' ? '_GLOBAL' : '';
2326 unless (exists $file{"needed_$type"}{$func}) {
2327 if ($type eq 'global') {
2328 diag("Files [@{$global{needs}{$func}}] need $func, adding global request");
2331 diag("File needs $func, adding static request");
2333 $pp .= "#define NEED_$func$suffix\n";
2337 if ($pp && ($c =~ s/^(?=$HS*#$HS*define$HS+NEED_\w+)/$pp/m)) {
2342 unless ($file{has_inc_ppport}) {
2343 diag("Needs to include '$ppport'");
2344 $pp .= qq(#include "$ppport"\n)
2348 $file{changes} += ($c =~ s/^($HS*#$HS*define$HS+NEED_\w+.*?)^/$1$pp/ms)
2349 || ($c =~ s/^(?=$HS*#$HS*include.*\Q$ppport\E)/$pp/m)
2350 || ($c =~ s/^($HS*#$HS*include.*XSUB.*\s*?)^/$1$pp/m)
2351 || ($c =~ s/^/$pp/);
2355 if ($file{has_inc_ppport}) {
2356 diag("No need to include '$ppport'");
2357 $file{changes} += ($c =~ s/^$HS*?#$HS*include.*\Q$ppport\E.*?$LF//m);
2361 # put back in our C comments
2364 my @ccom = @{$file{ccom}};
2365 for $ix (0 .. $#ccom) {
2366 if (!$opt{cplusplus} && $ccom[$ix] =~ s!^//!!) {
2368 $file{changes} += $c =~ s/$rccs$ix$rcce/$ccs$ccom[$ix] $cce/;
2371 $c =~ s/$rccs$ix$rcce/$ccom[$ix]/;
2376 my $s = $cppc != 1 ? 's' : '';
2377 warning("Uses $cppc C++ style comment$s, which is not portable");
2380 if ($file{changes}) {
2381 if (exists $opt{copy}) {
2382 my $newfile = "$filename$opt{copy}";
2384 error("'$newfile' already exists, refusing to write copy of '$filename'");
2388 if (open F, ">$newfile") {
2389 info("Writing copy of '$filename' with changes to '$newfile'");
2394 error("Cannot open '$newfile' for writing: $!");
2398 elsif (exists $opt{patch} || $opt{changes}) {
2399 if (exists $opt{patch}) {
2400 unless ($patch_opened) {
2401 if (open PATCH, ">$opt{patch}") {
2405 error("Cannot open '$opt{patch}' for writing: $!");
2411 mydiff(\*PATCH, $filename, $c);
2415 info("Suggested changes:");
2416 mydiff(\*STDOUT, $filename, $c);
2420 my $s = $file{changes} == 1 ? '' : 's';
2421 info("$file{changes} potentially required change$s detected");
2429 close PATCH if $patch_opened;
2437 my($file, $str) = @_;
2440 if (exists $opt{diff}) {
2441 $diff = run_diff($opt{diff}, $file, $str);
2444 if (!defined $diff and can_use('Text::Diff')) {
2445 $diff = Text::Diff::diff($file, \$str, { STYLE => 'Unified' });
2446 $diff = <<HEADER . $diff;
2452 if (!defined $diff) {
2453 $diff = run_diff('diff -u', $file, $str);
2456 if (!defined $diff) {
2457 $diff = run_diff('diff', $file, $str);
2460 if (!defined $diff) {
2461 error("Cannot generate a diff. Please install Text::Diff or use --copy.");
2471 my($prog, $file, $str) = @_;
2472 my $tmp = 'dppptemp';
2477 while (-e "$tmp.$suf") { $suf++ }
2480 if (open F, ">$tmp") {
2484 if (open F, "$prog $file $tmp |") {
2486 s/\Q$tmp\E/$file.patched/;
2497 error("Cannot open '$tmp' for writing: $!");
2513 return () unless exists $depends{$func};
2514 grep !$seen{$_}++, map { ($_, rec_depend($_)) } @{$depends{$func}};
2521 if ($ver =~ /^(\d+)\.(\d+)\.(\d+)$/) {
2522 return ($1, $2, $3);
2524 elsif ($ver !~ /^\d+\.[\d_]+$/) {
2525 die "cannot parse version '$ver'\n";
2529 $ver =~ s/$/000000/;
2531 my($r,$v,$s) = $ver =~ /(\d+)\.(\d{3})(\d{3})/;
2536 if ($r < 5 || ($r == 5 && $v < 6)) {
2538 die "cannot parse version '$ver'\n";
2542 return ($r, $v, $s);
2549 $ver =~ s/$/000000/;
2550 my($r,$v,$s) = $ver =~ /(\d+)\.(\d{3})(\d{3})/;
2555 if ($r < 5 || ($r == 5 && $v < 6)) {
2557 die "invalid version '$ver'\n";
2561 $ver = sprintf "%d.%03d", $r, $v;
2562 $s > 0 and $ver .= sprintf "_%02d", $s;
2567 return sprintf "%d.%d.%d", $r, $v, $s;
2572 $opt{quiet} and return;
2578 $opt{quiet} and return;
2579 $opt{diag} and print @_, "\n";
2584 $opt{quiet} and return;
2585 print "*** ", @_, "\n";
2590 print "*** ERROR: ", @_, "\n";
2596 $opt{quiet} and return;
2597 $opt{hints} or return;
2599 exists $hints{$func} or return;
2600 $given_hints{$func}++ and return;
2601 my $hint = $hints{$func};
2603 print " --- hint for $func ---\n", $hint;
2608 my($usage) = do { local(@ARGV,$/)=($0); <> } =~ /^=head\d$HS+SYNOPSIS\s*^(.*?)\s*^=/ms;
2609 my %M = ( 'I' => '*' );
2610 $usage =~ s/^\s*perl\s+\S+/$^X $0/;
2611 $usage =~ s/([A-Z])<([^>]+)>/$M{$1}$2$M{$1}/g;
2617 See perldoc $0 for details.
2627 #ifndef _P_P_PORTABILITY_H_
2628 #define _P_P_PORTABILITY_H_
2630 #ifndef DPPP_NAMESPACE
2631 # define DPPP_NAMESPACE DPPP_
2634 #define DPPP_CAT2(x,y) CAT2(x,y)
2635 #define DPPP_(name) DPPP_CAT2(DPPP_NAMESPACE, name)
2637 #ifndef PERL_REVISION
2638 # if !defined(__PATCHLEVEL_H_INCLUDED__) && !(defined(PATCHLEVEL) && defined(SUBVERSION))
2639 # define PERL_PATCHLEVEL_H_IMPLICIT
2640 # include <patchlevel.h>
2642 # if !(defined(PERL_VERSION) || (defined(SUBVERSION) && defined(PATCHLEVEL)))
2643 # include <could_not_find_Perl_patchlevel.h>
2645 # ifndef PERL_REVISION
2646 # define PERL_REVISION (5)
2648 # define PERL_VERSION PATCHLEVEL
2649 # define PERL_SUBVERSION SUBVERSION
2650 /* Replace PERL_PATCHLEVEL with PERL_VERSION */
2655 #define PERL_BCDVERSION ((PERL_REVISION * 0x1000000L) + (PERL_VERSION * 0x1000L) + PERL_SUBVERSION)
2657 /* It is very unlikely that anyone will try to use this with Perl 6
2658 (or greater), but who knows.
2660 #if PERL_REVISION != 5
2661 # error ppport.h only works with Perl version 5
2662 #endif /* PERL_REVISION != 5 */
2665 # include <limits.h>
2668 #ifndef PERL_UCHAR_MIN
2669 # define PERL_UCHAR_MIN ((unsigned char)0)
2672 #ifndef PERL_UCHAR_MAX
2674 # define PERL_UCHAR_MAX ((unsigned char)UCHAR_MAX)
2677 # define PERL_UCHAR_MAX ((unsigned char)MAXUCHAR)
2679 # define PERL_UCHAR_MAX ((unsigned char)~(unsigned)0)
2684 #ifndef PERL_USHORT_MIN
2685 # define PERL_USHORT_MIN ((unsigned short)0)
2688 #ifndef PERL_USHORT_MAX
2690 # define PERL_USHORT_MAX ((unsigned short)USHORT_MAX)
2693 # define PERL_USHORT_MAX ((unsigned short)MAXUSHORT)
2696 # define PERL_USHORT_MAX ((unsigned short)USHRT_MAX)
2698 # define PERL_USHORT_MAX ((unsigned short)~(unsigned)0)
2704 #ifndef PERL_SHORT_MAX
2706 # define PERL_SHORT_MAX ((short)SHORT_MAX)
2708 # ifdef MAXSHORT /* Often used in <values.h> */
2709 # define PERL_SHORT_MAX ((short)MAXSHORT)
2712 # define PERL_SHORT_MAX ((short)SHRT_MAX)
2714 # define PERL_SHORT_MAX ((short) (PERL_USHORT_MAX >> 1))
2720 #ifndef PERL_SHORT_MIN
2722 # define PERL_SHORT_MIN ((short)SHORT_MIN)
2725 # define PERL_SHORT_MIN ((short)MINSHORT)
2728 # define PERL_SHORT_MIN ((short)SHRT_MIN)
2730 # define PERL_SHORT_MIN (-PERL_SHORT_MAX - ((3 & -1) == 3))
2736 #ifndef PERL_UINT_MAX
2738 # define PERL_UINT_MAX ((unsigned int)UINT_MAX)
2741 # define PERL_UINT_MAX ((unsigned int)MAXUINT)
2743 # define PERL_UINT_MAX (~(unsigned int)0)
2748 #ifndef PERL_UINT_MIN
2749 # define PERL_UINT_MIN ((unsigned int)0)
2752 #ifndef PERL_INT_MAX
2754 # define PERL_INT_MAX ((int)INT_MAX)
2756 # ifdef MAXINT /* Often used in <values.h> */
2757 # define PERL_INT_MAX ((int)MAXINT)
2759 # define PERL_INT_MAX ((int)(PERL_UINT_MAX >> 1))
2764 #ifndef PERL_INT_MIN
2766 # define PERL_INT_MIN ((int)INT_MIN)
2769 # define PERL_INT_MIN ((int)MININT)
2771 # define PERL_INT_MIN (-PERL_INT_MAX - ((3 & -1) == 3))
2776 #ifndef PERL_ULONG_MAX
2778 # define PERL_ULONG_MAX ((unsigned long)ULONG_MAX)
2781 # define PERL_ULONG_MAX ((unsigned long)MAXULONG)
2783 # define PERL_ULONG_MAX (~(unsigned long)0)
2788 #ifndef PERL_ULONG_MIN
2789 # define PERL_ULONG_MIN ((unsigned long)0L)
2792 #ifndef PERL_LONG_MAX
2794 # define PERL_LONG_MAX ((long)LONG_MAX)
2797 # define PERL_LONG_MAX ((long)MAXLONG)
2799 # define PERL_LONG_MAX ((long) (PERL_ULONG_MAX >> 1))
2804 #ifndef PERL_LONG_MIN
2806 # define PERL_LONG_MIN ((long)LONG_MIN)
2809 # define PERL_LONG_MIN ((long)MINLONG)
2811 # define PERL_LONG_MIN (-PERL_LONG_MAX - ((3 & -1) == 3))
2816 #if defined(HAS_QUAD) && (defined(convex) || defined(uts))
2817 # ifndef PERL_UQUAD_MAX
2818 # ifdef ULONGLONG_MAX
2819 # define PERL_UQUAD_MAX ((unsigned long long)ULONGLONG_MAX)
2821 # ifdef MAXULONGLONG
2822 # define PERL_UQUAD_MAX ((unsigned long long)MAXULONGLONG)
2824 # define PERL_UQUAD_MAX (~(unsigned long long)0)
2829 # ifndef PERL_UQUAD_MIN
2830 # define PERL_UQUAD_MIN ((unsigned long long)0L)
2833 # ifndef PERL_QUAD_MAX
2834 # ifdef LONGLONG_MAX
2835 # define PERL_QUAD_MAX ((long long)LONGLONG_MAX)
2838 # define PERL_QUAD_MAX ((long long)MAXLONGLONG)
2840 # define PERL_QUAD_MAX ((long long) (PERL_UQUAD_MAX >> 1))
2845 # ifndef PERL_QUAD_MIN
2846 # ifdef LONGLONG_MIN
2847 # define PERL_QUAD_MIN ((long long)LONGLONG_MIN)
2850 # define PERL_QUAD_MIN ((long long)MINLONGLONG)
2852 # define PERL_QUAD_MIN (-PERL_QUAD_MAX - ((3 & -1) == 3))
2858 /* This is based on code from 5.003 perl.h */
2866 # define IV_MIN PERL_INT_MIN
2870 # define IV_MAX PERL_INT_MAX
2874 # define UV_MIN PERL_UINT_MIN
2878 # define UV_MAX PERL_UINT_MAX
2883 # define IVSIZE INTSIZE
2888 # if defined(convex) || defined(uts)
2890 # define IVTYPE long long
2894 # define IV_MIN PERL_QUAD_MIN
2898 # define IV_MAX PERL_QUAD_MAX
2902 # define UV_MIN PERL_UQUAD_MIN
2906 # define UV_MAX PERL_UQUAD_MAX
2909 # ifdef LONGLONGSIZE
2911 # define IVSIZE LONGLONGSIZE
2917 # define IVTYPE long
2921 # define IV_MIN PERL_LONG_MIN
2925 # define IV_MAX PERL_LONG_MAX
2929 # define UV_MIN PERL_ULONG_MIN
2933 # define UV_MAX PERL_ULONG_MAX
2938 # define IVSIZE LONGSIZE
2948 #ifndef PERL_QUAD_MIN
2949 # define PERL_QUAD_MIN IV_MIN
2952 #ifndef PERL_QUAD_MAX
2953 # define PERL_QUAD_MAX IV_MAX
2956 #ifndef PERL_UQUAD_MIN
2957 # define PERL_UQUAD_MIN UV_MIN
2960 #ifndef PERL_UQUAD_MAX
2961 # define PERL_UQUAD_MAX UV_MAX
2966 # define IVTYPE long
2970 # define IV_MIN PERL_LONG_MIN
2974 # define IV_MAX PERL_LONG_MAX
2978 # define UV_MIN PERL_ULONG_MIN
2982 # define UV_MAX PERL_ULONG_MAX
2989 # define IVSIZE LONGSIZE
2991 # define IVSIZE 4 /* A bold guess, but the best we can make. */
2995 # define UVTYPE unsigned IVTYPE
2999 # define UVSIZE IVSIZE
3003 # define sv_setuv(sv, uv) \
3006 if (TeMpUv <= IV_MAX) \
3007 sv_setiv(sv, TeMpUv); \
3009 sv_setnv(sv, (double)TeMpUv); \
3014 # define newSVuv(uv) ((uv) <= IV_MAX ? newSViv((IV)uv) : newSVnv((NV)uv))
3017 # define sv_2uv(sv) ((PL_Sv = (sv)), (UV) (SvNOK(PL_Sv) ? SvNV(PL_Sv) : sv_2nv(PL_Sv)))
3021 # define SvUVX(sv) ((UV)SvIVX(sv))
3025 # define SvUVXx(sv) SvUVX(sv)
3029 # define SvUV(sv) (SvIOK(sv) ? SvUVX(sv) : sv_2uv(sv))
3033 # define SvUVx(sv) ((PL_Sv = (sv)), SvUV(PL_Sv))
3037 * Always use the SvUVx() macro instead of sv_uv().
3040 # define sv_uv(sv) SvUVx(sv)
3043 # define XST_mUV(i,v) (ST(i) = sv_2mortal(newSVuv(v)) )
3047 # define XSRETURN_UV(v) STMT_START { XST_mUV(0,v); XSRETURN(1); } STMT_END
3050 # define PUSHu(u) STMT_START { sv_setuv(TARG, (UV)(u)); PUSHTARG; } STMT_END
3054 # define XPUSHu(u) STMT_START { sv_setuv(TARG, (UV)(u)); XPUSHTARG; } STMT_END
3057 #if (PERL_VERSION < 4) || ((PERL_VERSION == 4) && (PERL_SUBVERSION <= 5))
3059 # define PL_DBsingle DBsingle
3060 # define PL_DBsub DBsub
3062 # define PL_compiling compiling
3063 # define PL_copline copline
3064 # define PL_curcop curcop
3065 # define PL_curstash curstash
3066 # define PL_debstash debstash
3067 # define PL_defgv defgv
3068 # define PL_diehook diehook
3069 # define PL_dirty dirty
3070 # define PL_dowarn dowarn
3071 # define PL_errgv errgv
3072 # define PL_hexdigit hexdigit
3073 # define PL_hints hints
3075 # define PL_no_modify no_modify
3076 # define PL_perl_destruct_level perl_destruct_level
3077 # define PL_perldb perldb
3078 # define PL_ppaddr ppaddr
3079 # define PL_rsfp_filters rsfp_filters
3080 # define PL_rsfp rsfp
3081 # define PL_stack_base stack_base
3082 # define PL_stack_sp stack_sp
3083 # define PL_stdingv stdingv
3084 # define PL_sv_arenaroot sv_arenaroot
3085 # define PL_sv_no sv_no
3086 # define PL_sv_undef sv_undef
3087 # define PL_sv_yes sv_yes
3088 # define PL_tainted tainted
3089 # define PL_tainting tainting
3093 #ifndef PERL_UNUSED_DECL
3094 # ifdef HASATTRIBUTE
3095 # if (defined(__GNUC__) && defined(__cplusplus)) || defined(__INTEL_COMPILER)
3096 # define PERL_UNUSED_DECL
3098 # define PERL_UNUSED_DECL __attribute__((unused))
3101 # define PERL_UNUSED_DECL
3105 # define NOOP (void)0
3109 # define dNOOP extern int Perl___notused PERL_UNUSED_DECL
3113 # if defined(USE_LONG_DOUBLE) && defined(HAS_LONG_DOUBLE)
3114 # define NVTYPE long double
3116 # define NVTYPE double
3123 # if (IVSIZE == PTRSIZE) && (UVSIZE == PTRSIZE)
3125 # define INT2PTR(any,d) (any)(d)
3127 # if PTRSIZE == LONGSIZE
3128 # define PTRV unsigned long
3130 # define PTRV unsigned
3132 # define INT2PTR(any,d) (any)(PTRV)(d)
3135 # define NUM2PTR(any,d) (any)(PTRV)(d)
3136 # define PTR2IV(p) INT2PTR(IV,p)
3137 # define PTR2UV(p) INT2PTR(UV,p)
3138 # define PTR2NV(p) NUM2PTR(NV,p)
3140 # if PTRSIZE == LONGSIZE
3141 # define PTR2ul(p) (unsigned long)(p)
3143 # define PTR2ul(p) INT2PTR(unsigned long,p)
3146 #endif /* !INT2PTR */
3148 #undef START_EXTERN_C
3152 # define START_EXTERN_C extern "C" {
3153 # define END_EXTERN_C }
3154 # define EXTERN_C extern "C"
3156 # define START_EXTERN_C
3157 # define END_EXTERN_C
3158 # define EXTERN_C extern
3161 #ifndef PERL_GCC_BRACE_GROUPS_FORBIDDEN
3162 # if defined(__STRICT_ANSI__) && defined(PERL_GCC_PEDANTIC)
3163 # define PERL_GCC_BRACE_GROUPS_FORBIDDEN
3169 #if defined(__GNUC__) && !defined(PERL_GCC_BRACE_GROUPS_FORBIDDEN) && !defined(__cplusplus)
3170 # define STMT_START (void)( /* gcc supports ``({ STATEMENTS; })'' */
3173 # if defined(VOIDFLAGS) && (VOIDFLAGS) && (defined(sun) || defined(__sun__)) && !defined(__GNUC__)
3174 # define STMT_START if (1)
3175 # define STMT_END else (void)0
3177 # define STMT_START do
3178 # define STMT_END while (0)
3182 # define boolSV(b) ((b) ? &PL_sv_yes : &PL_sv_no)
3185 /* DEFSV appears first in 5.004_56 */
3187 # define DEFSV GvSV(PL_defgv)
3191 # define SAVE_DEFSV SAVESPTR(GvSV(PL_defgv))
3194 /* Older perls (<=5.003) lack AvFILLp */
3196 # define AvFILLp AvFILL
3199 # define ERRSV get_sv("@",FALSE)
3202 # define newSVpvn(data,len) ((data) \
3203 ? ((len) ? newSVpv((data), (len)) : newSVpv("", 0)) \
3207 /* Hint: gv_stashpvn
3208 * This function's backport doesn't support the length parameter, but
3209 * rather ignores it. Portability can only be ensured if the length
3210 * parameter is used for speed reasons, but the length can always be
3211 * correctly computed from the string argument.
3214 # define gv_stashpvn(str,len,create) gv_stashpv(str,create)
3219 # define get_cv perl_get_cv
3223 # define get_sv perl_get_sv
3227 # define get_av perl_get_av
3231 # define get_hv perl_get_hv
3238 # define memNE(s1,s2,l) (memcmp(s1,s2,l))
3242 # define memEQ(s1,s2,l) (!memcmp(s1,s2,l))
3247 # define memNE(s1,s2,l) (bcmp(s1,s2,l))
3251 # define memEQ(s1,s2,l) (!bcmp(s1,s2,l))
3256 # define MoveD(s,d,n,t) memmove((char*)(d),(char*)(s), (n) * sizeof(t))
3260 # define CopyD(s,d,n,t) memcpy((char*)(d),(char*)(s), (n) * sizeof(t))
3265 # define ZeroD(d,n,t) memzero((char*)(d), (n) * sizeof(t))
3270 # define ZeroD(d,n,t) ((void)memzero((char*)(d), (n) * sizeof(t)),d)
3275 # define Poison(d,n,t) (void)memset((char*)(d), 0xAB, (n) * sizeof(t))
3278 # define dUNDERBAR dNOOP
3282 # define UNDERBAR DEFSV
3285 # define dAX I32 ax = MARK - PL_stack_base + 1
3289 # define dITEMS I32 items = SP - MARK
3292 # define dXSTARG SV * targ = sv_newmortal()
3302 # define dTHXa(x) dNOOP
3320 # define dTHXoa(x) dTHXa(x)
3323 # define PUSHmortal PUSHs(sv_newmortal())
3327 # define mPUSHp(p,l) sv_setpvn_mg(PUSHmortal, (p), (l))
3331 # define mPUSHn(n) sv_setnv_mg(PUSHmortal, (NV)(n))
3335 # define mPUSHi(i) sv_setiv_mg(PUSHmortal, (IV)(i))
3339 # define mPUSHu(u) sv_setuv_mg(PUSHmortal, (UV)(u))
3342 # define XPUSHmortal XPUSHs(sv_newmortal())
3346 # define mXPUSHp(p,l) STMT_START { EXTEND(sp,1); sv_setpvn_mg(PUSHmortal, (p), (l)); } STMT_END
3350 # define mXPUSHn(n) STMT_START { EXTEND(sp,1); sv_setnv_mg(PUSHmortal, (NV)(n)); } STMT_END
3354 # define mXPUSHi(i) STMT_START { EXTEND(sp,1); sv_setiv_mg(PUSHmortal, (IV)(i)); } STMT_END
3358 # define mXPUSHu(u) STMT_START { EXTEND(sp,1); sv_setuv_mg(PUSHmortal, (UV)(u)); } STMT_END
3363 # define call_sv perl_call_sv
3367 # define call_pv perl_call_pv
3371 # define call_argv perl_call_argv
3375 # define call_method perl_call_method
3378 # define eval_sv perl_eval_sv
3383 /* Replace perl_eval_pv with eval_pv */
3384 /* eval_pv depends on eval_sv */
3387 #if defined(NEED_eval_pv)
3388 static SV* DPPP_(my_eval_pv)(char *p, I32 croak_on_error);
3391 extern SV* DPPP_(my_eval_pv)(char *p, I32 croak_on_error);
3397 #define eval_pv(a,b) DPPP_(my_eval_pv)(aTHX_ a,b)
3398 #define Perl_eval_pv DPPP_(my_eval_pv)
3400 #if defined(NEED_eval_pv) || defined(NEED_eval_pv_GLOBAL)
3403 DPPP_(my_eval_pv)(char *p, I32 croak_on_error)
3406 SV* sv = newSVpv(p, 0);
3409 eval_sv(sv, G_SCALAR);
3416 if (croak_on_error && SvTRUE(GvSV(errgv)))
3417 croak(SvPVx(GvSV(errgv), na));
3425 # define newRV_inc(sv) newRV(sv) /* Replace */
3429 #if defined(NEED_newRV_noinc)
3430 static SV * DPPP_(my_newRV_noinc)(SV *sv);
3433 extern SV * DPPP_(my_newRV_noinc)(SV *sv);
3439 #define newRV_noinc(a) DPPP_(my_newRV_noinc)(aTHX_ a)
3440 #define Perl_newRV_noinc DPPP_(my_newRV_noinc)
3442 #if defined(NEED_newRV_noinc) || defined(NEED_newRV_noinc_GLOBAL)
3444 DPPP_(my_newRV_noinc)(SV *sv)
3446 SV *rv = (SV *)newRV(sv);
3453 /* Hint: newCONSTSUB
3454 * Returns a CV* as of perl-5.7.1. This return value is not supported
3458 /* newCONSTSUB from IO.xs is in the core starting with 5.004_63 */
3459 #if ((PERL_VERSION < 4) || ((PERL_VERSION == 4) && (PERL_SUBVERSION < 63))) && ((PERL_VERSION != 4) || (PERL_SUBVERSION != 5))
3460 #if defined(NEED_newCONSTSUB)
3461 static void DPPP_(my_newCONSTSUB)(HV *stash, char *name, SV *sv);
3464 extern void DPPP_(my_newCONSTSUB)(HV *stash, char *name, SV *sv);
3470 #define newCONSTSUB(a,b,c) DPPP_(my_newCONSTSUB)(aTHX_ a,b,c)
3471 #define Perl_newCONSTSUB DPPP_(my_newCONSTSUB)
3473 #if defined(NEED_newCONSTSUB) || defined(NEED_newCONSTSUB_GLOBAL)
3476 DPPP_(my_newCONSTSUB)(HV *stash, char *name, SV *sv)
3478 U32 oldhints = PL_hints;
3479 HV *old_cop_stash = PL_curcop->cop_stash;
3480 HV *old_curstash = PL_curstash;
3481 line_t oldline = PL_curcop->cop_line;
3482 PL_curcop->cop_line = PL_copline;
3484 PL_hints &= ~HINT_BLOCK_SCOPE;
3486 PL_curstash = PL_curcop->cop_stash = stash;
3490 #if ((PERL_VERSION < 3) || ((PERL_VERSION == 3) && (PERL_SUBVERSION < 22)))
3492 #elif ((PERL_VERSION == 3) && (PERL_SUBVERSION == 22))
3494 #else /* 5.003_23 onwards */
3495 start_subparse(FALSE, 0),
3498 newSVOP(OP_CONST, 0, newSVpv(name,0)),
3499 newSVOP(OP_CONST, 0, &PL_sv_no), /* SvPV(&PL_sv_no) == "" -- GMB */
3500 newSTATEOP(0, Nullch, newSVOP(OP_CONST, 0, sv))
3503 PL_hints = oldhints;
3504 PL_curcop->cop_stash = old_cop_stash;
3505 PL_curstash = old_curstash;
3506 PL_curcop->cop_line = oldline;
3512 * Boilerplate macros for initializing and accessing interpreter-local
3513 * data from C. All statics in extensions should be reworked to use
3514 * this, if you want to make the extension thread-safe. See ext/re/re.xs
3515 * for an example of the use of these macros.
3517 * Code that uses these macros is responsible for the following:
3518 * 1. #define MY_CXT_KEY to a unique string, e.g. "DynaLoader_guts"
3519 * 2. Declare a typedef named my_cxt_t that is a structure that contains
3520 * all the data that needs to be interpreter-local.
3521 * 3. Use the START_MY_CXT macro after the declaration of my_cxt_t.
3522 * 4. Use the MY_CXT_INIT macro such that it is called exactly once
3523 * (typically put in the BOOT: section).
3524 * 5. Use the members of the my_cxt_t structure everywhere as
3526 * 6. Use the dMY_CXT macro (a declaration) in all the functions that
3530 #if defined(MULTIPLICITY) || defined(PERL_OBJECT) || \
3531 defined(PERL_CAPI) || defined(PERL_IMPLICIT_CONTEXT)
3533 #ifndef START_MY_CXT
3535 /* This must appear in all extensions that define a my_cxt_t structure,
3536 * right after the definition (i.e. at file scope). The non-threads
3537 * case below uses it to declare the data as static. */
3538 #define START_MY_CXT
3540 #if (PERL_VERSION < 4 || (PERL_VERSION == 4 && PERL_SUBVERSION < 68 ))
3541 /* Fetches the SV that keeps the per-interpreter data. */
3542 #define dMY_CXT_SV \
3543 SV *my_cxt_sv = get_sv(MY_CXT_KEY, FALSE)
3544 #else /* >= perl5.004_68 */
3545 #define dMY_CXT_SV \
3546 SV *my_cxt_sv = *hv_fetch(PL_modglobal, MY_CXT_KEY, \
3547 sizeof(MY_CXT_KEY)-1, TRUE)
3548 #endif /* < perl5.004_68 */
3550 /* This declaration should be used within all functions that use the
3551 * interpreter-local data. */
3554 my_cxt_t *my_cxtp = INT2PTR(my_cxt_t*,SvUV(my_cxt_sv))
3556 /* Creates and zeroes the per-interpreter data.
3557 * (We allocate my_cxtp in a Perl SV so that it will be released when
3558 * the interpreter goes away.) */
3559 #define MY_CXT_INIT \
3561 /* newSV() allocates one more than needed */ \
3562 my_cxt_t *my_cxtp = (my_cxt_t*)SvPVX(newSV(sizeof(my_cxt_t)-1));\
3563 Zero(my_cxtp, 1, my_cxt_t); \
3564 sv_setuv(my_cxt_sv, PTR2UV(my_cxtp))
3566 /* This macro must be used to access members of the my_cxt_t structure.
3567 * e.g. MYCXT.some_data */
3568 #define MY_CXT (*my_cxtp)
3570 /* Judicious use of these macros can reduce the number of times dMY_CXT
3571 * is used. Use is similar to pTHX, aTHX etc. */
3572 #define pMY_CXT my_cxt_t *my_cxtp
3573 #define pMY_CXT_ pMY_CXT,
3574 #define _pMY_CXT ,pMY_CXT
3575 #define aMY_CXT my_cxtp
3576 #define aMY_CXT_ aMY_CXT,
3577 #define _aMY_CXT ,aMY_CXT
3579 #endif /* START_MY_CXT */
3581 #ifndef MY_CXT_CLONE
3582 /* Clones the per-interpreter data. */
3583 #define MY_CXT_CLONE \
3585 my_cxt_t *my_cxtp = (my_cxt_t*)SvPVX(newSV(sizeof(my_cxt_t)-1));\
3586 Copy(INT2PTR(my_cxt_t*, SvUV(my_cxt_sv)), my_cxtp, 1, my_cxt_t);\
3587 sv_setuv(my_cxt_sv, PTR2UV(my_cxtp))
3590 #else /* single interpreter */
3592 #ifndef START_MY_CXT
3594 #define START_MY_CXT static my_cxt_t my_cxt;
3595 #define dMY_CXT_SV dNOOP
3596 #define dMY_CXT dNOOP
3597 #define MY_CXT_INIT NOOP
3598 #define MY_CXT my_cxt
3600 #define pMY_CXT void
3607 #endif /* START_MY_CXT */
3609 #ifndef MY_CXT_CLONE
3610 #define MY_CXT_CLONE NOOP
3616 # if IVSIZE == LONGSIZE
3623 # if IVSIZE == INTSIZE
3634 # if defined(USE_LONG_DOUBLE) && defined(HAS_LONG_DOUBLE) && \
3635 defined(PERL_PRIfldbl) /* Not very likely, but let's try anyway. */
3636 # define NVef PERL_PRIeldbl
3637 # define NVff PERL_PRIfldbl
3638 # define NVgf PERL_PRIgldbl
3648 #if defined(NEED_sv_2pv_nolen)
3649 static char * DPPP_(my_sv_2pv_nolen)(pTHX_ register SV *sv);
3652 extern char * DPPP_(my_sv_2pv_nolen)(pTHX_ register SV *sv);
3656 # undef sv_2pv_nolen
3658 #define sv_2pv_nolen(a) DPPP_(my_sv_2pv_nolen)(aTHX_ a)
3659 #define Perl_sv_2pv_nolen DPPP_(my_sv_2pv_nolen)
3661 #if defined(NEED_sv_2pv_nolen) || defined(NEED_sv_2pv_nolen_GLOBAL)
3664 DPPP_(my_sv_2pv_nolen)(pTHX_ register SV *sv)
3667 return sv_2pv(sv, &n_a);
3672 /* Hint: sv_2pv_nolen
3673 * Use the SvPV_nolen() macro instead of sv_2pv_nolen().
3676 /* SvPV_nolen depends on sv_2pv_nolen */
3677 #define SvPV_nolen(sv) \
3678 ((SvFLAGS(sv) & (SVf_POK)) == SVf_POK \
3679 ? SvPVX(sv) : sv_2pv_nolen(sv))
3686 * Does not work in perl-5.6.1, ppport.h implements a version
3687 * borrowed from perl-5.7.3.
3690 #if ((PERL_VERSION < 7) || ((PERL_VERSION == 7) && (PERL_SUBVERSION < 0)))
3692 #if defined(NEED_sv_2pvbyte)
3693 static char * DPPP_(my_sv_2pvbyte)(pTHX_ register SV *sv, STRLEN *lp);
3696 extern char * DPPP_(my_sv_2pvbyte)(pTHX_ register SV *sv, STRLEN *lp);
3702 #define sv_2pvbyte(a,b) DPPP_(my_sv_2pvbyte)(aTHX_ a,b)
3703 #define Perl_sv_2pvbyte DPPP_(my_sv_2pvbyte)
3705 #if defined(NEED_sv_2pvbyte) || defined(NEED_sv_2pvbyte_GLOBAL)
3708 DPPP_(my_sv_2pvbyte)(pTHX_ register SV *sv, STRLEN *lp)
3710 sv_utf8_downgrade(sv,0);
3711 return SvPV(sv,*lp);
3717 * Use the SvPVbyte() macro instead of sv_2pvbyte().
3722 /* SvPVbyte depends on sv_2pvbyte */
3723 #define SvPVbyte(sv, lp) \
3724 ((SvFLAGS(sv) & (SVf_POK|SVf_UTF8)) == (SVf_POK) \
3725 ? ((lp = SvCUR(sv)), SvPVX(sv)) : sv_2pvbyte(sv, &lp))
3731 # define SvPVbyte SvPV
3732 # define sv_2pvbyte sv_2pv
3736 /* sv_2pvbyte_nolen depends on sv_2pv_nolen */
3737 #ifndef sv_2pvbyte_nolen
3738 # define sv_2pvbyte_nolen sv_2pv_nolen
3742 * Always use the SvPV() macro instead of sv_pvn().
3745 # define sv_pvn(sv, len) SvPV(sv, len)
3748 /* Hint: sv_pvn_force
3749 * Always use the SvPV_force() macro instead of sv_pvn_force().
3751 #ifndef sv_pvn_force
3752 # define sv_pvn_force(sv, len) SvPV_force(sv, len)
3755 #if ((PERL_VERSION > 4) || ((PERL_VERSION == 4) && (PERL_SUBVERSION >= 0))) && !defined(vnewSVpvf)
3756 #if defined(NEED_vnewSVpvf)
3757 static SV * DPPP_(my_vnewSVpvf)(pTHX_ const char * pat, va_list * args);
3760 extern SV * DPPP_(my_vnewSVpvf)(pTHX_ const char * pat, va_list * args);
3766 #define vnewSVpvf(a,b) DPPP_(my_vnewSVpvf)(aTHX_ a,b)
3767 #define Perl_vnewSVpvf DPPP_(my_vnewSVpvf)
3769 #if defined(NEED_vnewSVpvf) || defined(NEED_vnewSVpvf_GLOBAL)
3772 DPPP_(my_vnewSVpvf)(pTHX_ const char *pat, va_list *args)
3774 register SV *sv = newSV(0);
3775 sv_vsetpvfn(sv, pat, strlen(pat), args, Null(SV**), 0, Null(bool*));
3782 /* sv_vcatpvf depends on sv_vcatpvfn */
3783 #if ((PERL_VERSION > 4) || ((PERL_VERSION == 4) && (PERL_SUBVERSION >= 0))) && !defined(sv_vcatpvf)
3784 # define sv_vcatpvf(sv, pat, args) sv_vcatpvfn(sv, pat, strlen(pat), args, Null(SV**), 0, Null(bool*))
3787 /* sv_vsetpvf depends on sv_vsetpvfn */
3788 #if ((PERL_VERSION > 4) || ((PERL_VERSION == 4) && (PERL_SUBVERSION >= 0))) && !defined(sv_vsetpvf)
3789 # define sv_vsetpvf(sv, pat, args) sv_vsetpvfn(sv, pat, strlen(pat), args, Null(SV**), 0, Null(bool*))
3792 /* sv_catpvf_mg depends on sv_vcatpvfn, sv_catpvf_mg_nocontext */
3793 #if ((PERL_VERSION > 4) || ((PERL_VERSION == 4) && (PERL_SUBVERSION >= 0))) && !defined(sv_catpvf_mg)
3794 #if defined(NEED_sv_catpvf_mg)
3795 static void DPPP_(my_sv_catpvf_mg)(pTHX_ SV * sv, const char * pat, ...);
3798 extern void DPPP_(my_sv_catpvf_mg)(pTHX_ SV * sv, const char * pat, ...);
3801 #define Perl_sv_catpvf_mg DPPP_(my_sv_catpvf_mg)
3803 #if defined(NEED_sv_catpvf_mg) || defined(NEED_sv_catpvf_mg_GLOBAL)
3806 DPPP_(my_sv_catpvf_mg)(pTHX_ SV *sv, const char *pat, ...)
3809 va_start(args, pat);
3810 sv_vcatpvfn(sv, pat, strlen(pat), &args, Null(SV**), 0, Null(bool*));
3818 /* sv_catpvf_mg_nocontext depends on sv_vcatpvfn */
3819 #ifdef PERL_IMPLICIT_CONTEXT
3820 #if ((PERL_VERSION > 4) || ((PERL_VERSION == 4) && (PERL_SUBVERSION >= 0))) && !defined(sv_catpvf_mg_nocontext)
3821 #if defined(NEED_sv_catpvf_mg_nocontext)
3822 static void DPPP_(my_sv_catpvf_mg_nocontext)(SV * sv, const char * pat, ...);
3825 extern void DPPP_(my_sv_catpvf_mg_nocontext)(SV * sv, const char * pat, ...);
3828 #define sv_catpvf_mg_nocontext DPPP_(my_sv_catpvf_mg_nocontext)
3829 #define Perl_sv_catpvf_mg_nocontext DPPP_(my_sv_catpvf_mg_nocontext)
3831 #if defined(NEED_sv_catpvf_mg_nocontext) || defined(NEED_sv_catpvf_mg_nocontext_GLOBAL)
3834 DPPP_(my_sv_catpvf_mg_nocontext)(SV *sv, const char *pat, ...)
3838 va_start(args, pat);
3839 sv_vcatpvfn(sv, pat, strlen(pat), &args, Null(SV**), 0, Null(bool*));
3848 #ifndef sv_catpvf_mg
3849 # ifdef PERL_IMPLICIT_CONTEXT
3850 # define sv_catpvf_mg Perl_sv_catpvf_mg_nocontext
3852 # define sv_catpvf_mg Perl_sv_catpvf_mg
3856 /* sv_vcatpvf_mg depends on sv_vcatpvfn */
3857 #if ((PERL_VERSION > 4) || ((PERL_VERSION == 4) && (PERL_SUBVERSION >= 0))) && !defined(sv_vcatpvf_mg)
3858 # define sv_vcatpvf_mg(sv, pat, args) \
3860 sv_vcatpvfn(sv, pat, strlen(pat), args, Null(SV**), 0, Null(bool*)); \
3865 /* sv_setpvf_mg depends on sv_vsetpvfn, sv_setpvf_mg_nocontext */
3866 #if ((PERL_VERSION > 4) || ((PERL_VERSION == 4) && (PERL_SUBVERSION >= 0))) && !defined(sv_setpvf_mg)
3867 #if defined(NEED_sv_setpvf_mg)
3868 static void DPPP_(my_sv_setpvf_mg)(pTHX_ SV * sv, const char * pat, ...);
3871 extern void DPPP_(my_sv_setpvf_mg)(pTHX_ SV * sv, const char * pat, ...);
3874 #define Perl_sv_setpvf_mg DPPP_(my_sv_setpvf_mg)
3876 #if defined(NEED_sv_setpvf_mg) || defined(NEED_sv_setpvf_mg_GLOBAL)
3879 DPPP_(my_sv_setpvf_mg)(pTHX_ SV *sv, const char *pat, ...)
3882 va_start(args, pat);
3883 sv_vsetpvfn(sv, pat, strlen(pat), &args, Null(SV**), 0, Null(bool*));
3891 /* sv_setpvf_mg_nocontext depends on sv_vsetpvfn */
3892 #ifdef PERL_IMPLICIT_CONTEXT
3893 #if ((PERL_VERSION > 4) || ((PERL_VERSION == 4) && (PERL_SUBVERSION >= 0))) && !defined(sv_setpvf_mg_nocontext)
3894 #if defined(NEED_sv_setpvf_mg_nocontext)
3895 static void DPPP_(my_sv_setpvf_mg_nocontext)(SV * sv, const char * pat, ...);
3898 extern void DPPP_(my_sv_setpvf_mg_nocontext)(SV * sv, const char * pat, ...);
3901 #define sv_setpvf_mg_nocontext DPPP_(my_sv_setpvf_mg_nocontext)
3902 #define Perl_sv_setpvf_mg_nocontext DPPP_(my_sv_setpvf_mg_nocontext)
3904 #if defined(NEED_sv_setpvf_mg_nocontext) || defined(NEED_sv_setpvf_mg_nocontext_GLOBAL)
3907 DPPP_(my_sv_setpvf_mg_nocontext)(SV *sv, const char *pat, ...)
3911 va_start(args, pat);
3912 sv_vsetpvfn(sv, pat, strlen(pat), &args, Null(SV**), 0, Null(bool*));
3921 #ifndef sv_setpvf_mg
3922 # ifdef PERL_IMPLICIT_CONTEXT
3923 # define sv_setpvf_mg Perl_sv_setpvf_mg_nocontext
3925 # define sv_setpvf_mg Perl_sv_setpvf_mg
3929 /* sv_vsetpvf_mg depends on sv_vsetpvfn */
3930 #if ((PERL_VERSION > 4) || ((PERL_VERSION == 4) && (PERL_SUBVERSION >= 0))) && !defined(sv_vsetpvf_mg)
3931 # define sv_vsetpvf_mg(sv, pat, args) \
3933 sv_vsetpvfn(sv, pat, strlen(pat), args, Null(SV**), 0, Null(bool*)); \
3938 # define SvGETMAGIC(x) STMT_START { if (SvGMAGICAL(x)) mg_get(x); } STMT_END
3940 #ifndef PERL_MAGIC_sv
3941 # define PERL_MAGIC_sv '\0'
3944 #ifndef PERL_MAGIC_overload
3945 # define PERL_MAGIC_overload 'A'
3948 #ifndef PERL_MAGIC_overload_elem
3949 # define PERL_MAGIC_overload_elem 'a'
3952 #ifndef PERL_MAGIC_overload_table
3953 # define PERL_MAGIC_overload_table 'c'
3956 #ifndef PERL_MAGIC_bm
3957 # define PERL_MAGIC_bm 'B'
3960 #ifndef PERL_MAGIC_regdata
3961 # define PERL_MAGIC_regdata 'D'
3964 #ifndef PERL_MAGIC_regdatum
3965 # define PERL_MAGIC_regdatum 'd'
3968 #ifndef PERL_MAGIC_env
3969 # define PERL_MAGIC_env 'E'
3972 #ifndef PERL_MAGIC_envelem
3973 # define PERL_MAGIC_envelem 'e'
3976 #ifndef PERL_MAGIC_fm
3977 # define PERL_MAGIC_fm 'f'
3980 #ifndef PERL_MAGIC_regex_global
3981 # define PERL_MAGIC_regex_global 'g'
3984 #ifndef PERL_MAGIC_isa
3985 # define PERL_MAGIC_isa 'I'
3988 #ifndef PERL_MAGIC_isaelem
3989 # define PERL_MAGIC_isaelem 'i'
3992 #ifndef PERL_MAGIC_nkeys
3993 # define PERL_MAGIC_nkeys 'k'
3996 #ifndef PERL_MAGIC_dbfile
3997 # define PERL_MAGIC_dbfile 'L'
4000 #ifndef PERL_MAGIC_dbline
4001 # define PERL_MAGIC_dbline 'l'
4004 #ifndef PERL_MAGIC_mutex
4005 # define PERL_MAGIC_mutex 'm'
4008 #ifndef PERL_MAGIC_shared
4009 # define PERL_MAGIC_shared 'N'
4012 #ifndef PERL_MAGIC_shared_scalar
4013 # define PERL_MAGIC_shared_scalar 'n'
4016 #ifndef PERL_MAGIC_collxfrm
4017 # define PERL_MAGIC_collxfrm 'o'
4020 #ifndef PERL_MAGIC_tied
4021 # define PERL_MAGIC_tied 'P'
4024 #ifndef PERL_MAGIC_tiedelem
4025 # define PERL_MAGIC_tiedelem 'p'
4028 #ifndef PERL_MAGIC_tiedscalar
4029 # define PERL_MAGIC_tiedscalar 'q'
4032 #ifndef PERL_MAGIC_qr
4033 # define PERL_MAGIC_qr 'r'
4036 #ifndef PERL_MAGIC_sig
4037 # define PERL_MAGIC_sig 'S'
4040 #ifndef PERL_MAGIC_sigelem
4041 # define PERL_MAGIC_sigelem 's'
4044 #ifndef PERL_MAGIC_taint
4045 # define PERL_MAGIC_taint 't'
4048 #ifndef PERL_MAGIC_uvar
4049 # define PERL_MAGIC_uvar 'U'
4052 #ifndef PERL_MAGIC_uvar_elem
4053 # define PERL_MAGIC_uvar_elem 'u'
4056 #ifndef PERL_MAGIC_vstring
4057 # define PERL_MAGIC_vstring 'V'
4060 #ifndef PERL_MAGIC_vec
4061 # define PERL_MAGIC_vec 'v'
4064 #ifndef PERL_MAGIC_utf8
4065 # define PERL_MAGIC_utf8 'w'
4068 #ifndef PERL_MAGIC_substr
4069 # define PERL_MAGIC_substr 'x'
4072 #ifndef PERL_MAGIC_defelem
4073 # define PERL_MAGIC_defelem 'y'
4076 #ifndef PERL_MAGIC_glob
4077 # define PERL_MAGIC_glob '*'
4080 #ifndef PERL_MAGIC_arylen
4081 # define PERL_MAGIC_arylen '#'
4084 #ifndef PERL_MAGIC_pos
4085 # define PERL_MAGIC_pos '.'
4088 #ifndef PERL_MAGIC_backref
4089 # define PERL_MAGIC_backref '<'
4092 #ifndef PERL_MAGIC_ext
4093 # define PERL_MAGIC_ext '~'
4096 /* That's the best we can do... */
4097 #ifndef SvPV_force_nomg
4098 # define SvPV_force_nomg SvPV_force
4102 # define SvPV_nomg SvPV
4105 #ifndef sv_catpvn_nomg
4106 # define sv_catpvn_nomg sv_catpvn
4109 #ifndef sv_catsv_nomg
4110 # define sv_catsv_nomg sv_catsv
4113 #ifndef sv_setsv_nomg
4114 # define sv_setsv_nomg sv_setsv
4118 # define sv_pvn_nomg sv_pvn
4122 # define SvIV_nomg SvIV
4126 # define SvUV_nomg SvUV
4130 # define sv_catpv_mg(sv, ptr) \
4133 sv_catpv(TeMpSv,ptr); \
4134 SvSETMAGIC(TeMpSv); \
4138 #ifndef sv_catpvn_mg
4139 # define sv_catpvn_mg(sv, ptr, len) \
4142 sv_catpvn(TeMpSv,ptr,len); \
4143 SvSETMAGIC(TeMpSv); \
4148 # define sv_catsv_mg(dsv, ssv) \
4151 sv_catsv(TeMpSv,ssv); \
4152 SvSETMAGIC(TeMpSv); \
4157 # define sv_setiv_mg(sv, i) \
4160 sv_setiv(TeMpSv,i); \
4161 SvSETMAGIC(TeMpSv); \
4166 # define sv_setnv_mg(sv, num) \
4169 sv_setnv(TeMpSv,num); \
4170 SvSETMAGIC(TeMpSv); \
4175 # define sv_setpv_mg(sv, ptr) \
4178 sv_setpv(TeMpSv,ptr); \
4179 SvSETMAGIC(TeMpSv); \
4183 #ifndef sv_setpvn_mg
4184 # define sv_setpvn_mg(sv, ptr, len) \
4187 sv_setpvn(TeMpSv,ptr,len); \
4188 SvSETMAGIC(TeMpSv); \
4193 # define sv_setsv_mg(dsv, ssv) \
4196 sv_setsv(TeMpSv,ssv); \
4197 SvSETMAGIC(TeMpSv); \
4202 # define sv_setuv_mg(sv, i) \
4205 sv_setuv(TeMpSv,i); \
4206 SvSETMAGIC(TeMpSv); \
4210 #ifndef sv_usepvn_mg
4211 # define sv_usepvn_mg(sv, ptr, len) \
4214 sv_usepvn(TeMpSv,ptr,len); \
4215 SvSETMAGIC(TeMpSv); \
4221 # define CopFILE(c) ((c)->cop_file)
4225 # define CopFILEGV(c) (CopFILE(c) ? gv_fetchfile(CopFILE(c)) : Nullgv)
4229 # define CopFILE_set(c,pv) ((c)->cop_file = savepv(pv))
4233 # define CopFILESV(c) (CopFILE(c) ? GvSV(gv_fetchfile(CopFILE(c))) : Nullsv)
4237 # define CopFILEAV(c) (CopFILE(c) ? GvAV(gv_fetchfile(CopFILE(c))) : Nullav)
4241 # define CopSTASHPV(c) ((c)->cop_stashpv)
4244 #ifndef CopSTASHPV_set
4245 # define CopSTASHPV_set(c,pv) ((c)->cop_stashpv = ((pv) ? savepv(pv) : Nullch))
4249 # define CopSTASH(c) (CopSTASHPV(c) ? gv_stashpv(CopSTASHPV(c),GV_ADD) : Nullhv)
4252 #ifndef CopSTASH_set
4253 # define CopSTASH_set(c,hv) CopSTASHPV_set(c, (hv) ? HvNAME(hv) : Nullch)
4257 # define CopSTASH_eq(c,hv) ((hv) && (CopSTASHPV(c) == HvNAME(hv) \
4258 || (CopSTASHPV(c) && HvNAME(hv) \
4259 && strEQ(CopSTASHPV(c), HvNAME(hv)))))
4264 # define CopFILEGV(c) ((c)->cop_filegv)
4267 #ifndef CopFILEGV_set
4268 # define CopFILEGV_set(c,gv) ((c)->cop_filegv = (GV*)SvREFCNT_inc(gv))
4272 # define CopFILE_set(c,pv) CopFILEGV_set((c), gv_fetchfile(pv))
4276 # define CopFILESV(c) (CopFILEGV(c) ? GvSV(CopFILEGV(c)) : Nullsv)
4280 # define CopFILEAV(c) (CopFILEGV(c) ? GvAV(CopFILEGV(c)) : Nullav)
4284 # define CopFILE(c) (CopFILESV(c) ? SvPVX(CopFILESV(c)) : Nullch)
4288 # define CopSTASH(c) ((c)->cop_stash)
4291 #ifndef CopSTASH_set
4292 # define CopSTASH_set(c,hv) ((c)->cop_stash = (hv))
4296 # define CopSTASHPV(c) (CopSTASH(c) ? HvNAME(CopSTASH(c)) : Nullch)
4299 #ifndef CopSTASHPV_set
4300 # define CopSTASHPV_set(c,pv) CopSTASH_set((c), gv_stashpv(pv,GV_ADD))
4304 # define CopSTASH_eq(c,hv) (CopSTASH(c) == (hv))
4307 #endif /* USE_ITHREADS */
4308 #ifndef IN_PERL_COMPILETIME
4309 # define IN_PERL_COMPILETIME (PL_curcop == &PL_compiling)
4312 #ifndef IN_LOCALE_RUNTIME
4313 # define IN_LOCALE_RUNTIME (PL_curcop->op_private & HINT_LOCALE)
4316 #ifndef IN_LOCALE_COMPILETIME
4317 # define IN_LOCALE_COMPILETIME (PL_hints & HINT_LOCALE)
4321 # define IN_LOCALE (IN_PERL_COMPILETIME ? IN_LOCALE_COMPILETIME : IN_LOCALE_RUNTIME)
4323 #ifndef IS_NUMBER_IN_UV
4324 # define IS_NUMBER_IN_UV 0x01
4327 #ifndef IS_NUMBER_GREATER_THAN_UV_MAX
4328 # define IS_NUMBER_GREATER_THAN_UV_MAX 0x02
4331 #ifndef IS_NUMBER_NOT_INT
4332 # define IS_NUMBER_NOT_INT 0x04
4335 #ifndef IS_NUMBER_NEG
4336 # define IS_NUMBER_NEG 0x08
4339 #ifndef IS_NUMBER_INFINITY
4340 # define IS_NUMBER_INFINITY 0x10
4343 #ifndef IS_NUMBER_NAN
4344 # define IS_NUMBER_NAN 0x20
4347 /* GROK_NUMERIC_RADIX depends on grok_numeric_radix */
4348 #ifndef GROK_NUMERIC_RADIX
4349 # define GROK_NUMERIC_RADIX(sp, send) grok_numeric_radix(sp, send)
4351 #ifndef PERL_SCAN_GREATER_THAN_UV_MAX
4352 # define PERL_SCAN_GREATER_THAN_UV_MAX 0x02
4355 #ifndef PERL_SCAN_SILENT_ILLDIGIT
4356 # define PERL_SCAN_SILENT_ILLDIGIT 0x04
4359 #ifndef PERL_SCAN_ALLOW_UNDERSCORES
4360 # define PERL_SCAN_ALLOW_UNDERSCORES 0x01
4363 #ifndef PERL_SCAN_DISALLOW_PREFIX
4364 # define PERL_SCAN_DISALLOW_PREFIX 0x02
4367 #ifndef grok_numeric_radix
4368 #if defined(NEED_grok_numeric_radix)
4369 static bool DPPP_(my_grok_numeric_radix)(pTHX_ const char ** sp, const char * send);
4372 extern bool DPPP_(my_grok_numeric_radix)(pTHX_ const char ** sp, const char * send);
4375 #ifdef grok_numeric_radix
4376 # undef grok_numeric_radix
4378 #define grok_numeric_radix(a,b) DPPP_(my_grok_numeric_radix)(aTHX_ a,b)
4379 #define Perl_grok_numeric_radix DPPP_(my_grok_numeric_radix)
4381 #if defined(NEED_grok_numeric_radix) || defined(NEED_grok_numeric_radix_GLOBAL)
4383 DPPP_(my_grok_numeric_radix)(pTHX_ const char **sp, const char *send)
4385 #ifdef USE_LOCALE_NUMERIC
4386 #ifdef PL_numeric_radix_sv
4387 if (PL_numeric_radix_sv && IN_LOCALE) {
4389 char* radix = SvPV(PL_numeric_radix_sv, len);
4390 if (*sp + len <= send && memEQ(*sp, radix, len)) {
4396 /* older perls don't have PL_numeric_radix_sv so the radix
4397 * must manually be requested from locale.h
4400 dTHR; /* needed for older threaded perls */
4401 struct lconv *lc = localeconv();
4402 char *radix = lc->decimal_point;
4403 if (radix && IN_LOCALE) {
4404 STRLEN len = strlen(radix);
4405 if (*sp + len <= send && memEQ(*sp, radix, len)) {
4410 #endif /* PERL_VERSION */
4411 #endif /* USE_LOCALE_NUMERIC */
4412 /* always try "." if numeric radix didn't match because
4413 * we may have data from different locales mixed */
4414 if (*sp < send && **sp == '.') {
4423 /* grok_number depends on grok_numeric_radix */
4426 #if defined(NEED_grok_number)
4427 static int DPPP_(my_grok_number)(pTHX_ const char * pv, STRLEN len, UV * valuep);
4430 extern int DPPP_(my_grok_number)(pTHX_ const char * pv, STRLEN len, UV * valuep);
4436 #define grok_number(a,b,c) DPPP_(my_grok_number)(aTHX_ a,b,c)
4437 #define Perl_grok_number DPPP_(my_grok_number)
4439 #if defined(NEED_grok_number) || defined(NEED_grok_number_GLOBAL)
4441 DPPP_(my_grok_number)(pTHX_ const char *pv, STRLEN len, UV *valuep)
4444 const char *send = pv + len;
4445 const UV max_div_10 = UV_MAX / 10;
4446 const char max_mod_10 = UV_MAX % 10;
4451 while (s < send && isSPACE(*s))
4455 } else if (*s == '-') {
4457 numtype = IS_NUMBER_NEG;
4465 /* next must be digit or the radix separator or beginning of infinity */
4467 /* UVs are at least 32 bits, so the first 9 decimal digits cannot
4469 UV value = *s - '0';
4470 /* This construction seems to be more optimiser friendly.
4471 (without it gcc does the isDIGIT test and the *s - '0' separately)
4472 With it gcc on arm is managing 6 instructions (6 cycles) per digit.
4473 In theory the optimiser could deduce how far to unroll the loop
4474 before checking for overflow. */
4476 int digit = *s - '0';
4477 if (digit >= 0 && digit <= 9) {
4478 value = value * 10 + digit;
4481 if (digit >= 0 && digit <= 9) {
4482 value = value * 10 + digit;
4485 if (digit >= 0 && digit <= 9) {
4486 value = value * 10 + digit;
4489 if (digit >= 0 && digit <= 9) {
4490 value = value * 10 + digit;
4493 if (digit >= 0 && digit <= 9) {
4494 value = value * 10 + digit;
4497 if (digit >= 0 && digit <= 9) {
4498 value = value * 10 + digit;
4501 if (digit >= 0 && digit <= 9) {
4502 value = value * 10 + digit;
4505 if (digit >= 0 && digit <= 9) {
4506 value = value * 10 + digit;
4508 /* Now got 9 digits, so need to check
4509 each time for overflow. */
4511 while (digit >= 0 && digit <= 9
4512 && (value < max_div_10
4513 || (value == max_div_10
4514 && digit <= max_mod_10))) {
4515 value = value * 10 + digit;
4521 if (digit >= 0 && digit <= 9
4523 /* value overflowed.
4524 skip the remaining digits, don't
4525 worry about setting *valuep. */
4528 } while (s < send && isDIGIT(*s));
4530 IS_NUMBER_GREATER_THAN_UV_MAX;
4550 numtype |= IS_NUMBER_IN_UV;
4555 if (GROK_NUMERIC_RADIX(&s, send)) {
4556 numtype |= IS_NUMBER_NOT_INT;
4557 while (s < send && isDIGIT(*s)) /* optional digits after the radix */
4561 else if (GROK_NUMERIC_RADIX(&s, send)) {
4562 numtype |= IS_NUMBER_NOT_INT | IS_NUMBER_IN_UV; /* valuep assigned below */
4563 /* no digits before the radix means we need digits after it */
4564 if (s < send && isDIGIT(*s)) {
4567 } while (s < send && isDIGIT(*s));
4569 /* integer approximation is valid - it's 0. */
4575 } else if (*s == 'I' || *s == 'i') {
4576 s++; if (s == send || (*s != 'N' && *s != 'n')) return 0;
4577 s++; if (s == send || (*s != 'F' && *s != 'f')) return 0;
4578 s++; if (s < send && (*s == 'I' || *s == 'i')) {
4579 s++; if (s == send || (*s != 'N' && *s != 'n')) return 0;
4580 s++; if (s == send || (*s != 'I' && *s != 'i')) return 0;
4581 s++; if (s == send || (*s != 'T' && *s != 't')) return 0;
4582 s++; if (s == send || (*s != 'Y' && *s != 'y')) return 0;
4586 } else if (*s == 'N' || *s == 'n') {
4587 /* XXX TODO: There are signaling NaNs and quiet NaNs. */
4588 s++; if (s == send || (*s != 'A' && *s != 'a')) return 0;
4589 s++; if (s == send || (*s != 'N' && *s != 'n')) return 0;
4596 numtype &= IS_NUMBER_NEG; /* Keep track of sign */
4597 numtype |= IS_NUMBER_INFINITY | IS_NUMBER_NOT_INT;
4598 } else if (sawnan) {
4599 numtype &= IS_NUMBER_NEG; /* Keep track of sign */
4600 numtype |= IS_NUMBER_NAN | IS_NUMBER_NOT_INT;
4601 } else if (s < send) {
4602 /* we can have an optional exponent part */
4603 if (*s == 'e' || *s == 'E') {
4604 /* The only flag we keep is sign. Blow away any "it's UV" */
4605 numtype &= IS_NUMBER_NEG;
4606 numtype |= IS_NUMBER_NOT_INT;
4608 if (s < send && (*s == '-' || *s == '+'))
4610 if (s < send && isDIGIT(*s)) {
4613 } while (s < send && isDIGIT(*s));
4619 while (s < send && isSPACE(*s))
4623 if (len == 10 && memEQ(pv, "0 but true", 10)) {
4626 return IS_NUMBER_IN_UV;
4634 * The grok_* routines have been modified to use warn() instead of
4635 * Perl_warner(). Also, 'hexdigit' was the former name of PL_hexdigit,
4636 * which is why the stack variable has been renamed to 'xdigit'.
4640 #if defined(NEED_grok_bin)
4641 static UV DPPP_(my_grok_bin)(pTHX_ char *start, STRLEN *len_p, I32 *flags, NV *result);
4644 extern UV DPPP_(my_grok_bin)(pTHX_ char *start, STRLEN *len_p, I32 *flags, NV *result);
4650 #define grok_bin(a,b,c,d) DPPP_(my_grok_bin)(aTHX_ a,b,c,d)
4651 #define Perl_grok_bin DPPP_(my_grok_bin)
4653 #if defined(NEED_grok_bin) || defined(NEED_grok_bin_GLOBAL)
4655 DPPP_(my_grok_bin)(pTHX_ char *start, STRLEN *len_p, I32 *flags, NV *result)
4657 const char *s = start;
4658 STRLEN len = *len_p;
4662 const UV max_div_2 = UV_MAX / 2;
4663 bool allow_underscores = *flags & PERL_SCAN_ALLOW_UNDERSCORES;
4664 bool overflowed = FALSE;
4666 if (!(*flags & PERL_SCAN_DISALLOW_PREFIX)) {
4667 /* strip off leading b or 0b.
4668 for compatibility silently suffer "b" and "0b" as valid binary
4675 else if (len >= 2 && s[0] == '0' && s[1] == 'b') {
4682 for (; len-- && *s; s++) {
4684 if (bit == '0' || bit == '1') {
4685 /* Write it in this wonky order with a goto to attempt to get the
4686 compiler to make the common case integer-only loop pretty tight.
4687 With gcc seems to be much straighter code than old scan_bin. */
4690 if (value <= max_div_2) {
4691 value = (value << 1) | (bit - '0');
4694 /* Bah. We're just overflowed. */
4695 warn("Integer overflow in binary number");
4697 value_nv = (NV) value;
4700 /* If an NV has not enough bits in its mantissa to
4701 * represent a UV this summing of small low-order numbers
4702 * is a waste of time (because the NV cannot preserve
4703 * the low-order bits anyway): we could just remember when
4704 * did we overflow and in the end just multiply value_nv by the
4706 value_nv += (NV)(bit - '0');
4709 if (bit == '_' && len && allow_underscores && (bit = s[1])
4710 && (bit == '0' || bit == '1'))
4716 if (!(*flags & PERL_SCAN_SILENT_ILLDIGIT))
4717 warn("Illegal binary digit '%c' ignored", *s);
4721 if ( ( overflowed && value_nv > 4294967295.0)
4723 || (!overflowed && value > 0xffffffff )
4726 warn("Binary number > 0b11111111111111111111111111111111 non-portable");
4733 *flags = PERL_SCAN_GREATER_THAN_UV_MAX;
4742 #if defined(NEED_grok_hex)
4743 static UV DPPP_(my_grok_hex)(pTHX_ char *start, STRLEN *len_p, I32 *flags, NV *result);
4746 extern UV DPPP_(my_grok_hex)(pTHX_ char *start, STRLEN *len_p, I32 *flags, NV *result);
4752 #define grok_hex(a,b,c,d) DPPP_(my_grok_hex)(aTHX_ a,b,c,d)
4753 #define Perl_grok_hex DPPP_(my_grok_hex)
4755 #if defined(NEED_grok_hex) || defined(NEED_grok_hex_GLOBAL)
4757 DPPP_(my_grok_hex)(pTHX_ char *start, STRLEN *len_p, I32 *flags, NV *result)
4759 const char *s = start;
4760 STRLEN len = *len_p;
4764 const UV max_div_16 = UV_MAX / 16;
4765 bool allow_underscores = *flags & PERL_SCAN_ALLOW_UNDERSCORES;
4766 bool overflowed = FALSE;
4769 if (!(*flags & PERL_SCAN_DISALLOW_PREFIX)) {
4770 /* strip off leading x or 0x.
4771 for compatibility silently suffer "x" and "0x" as valid hex numbers.
4778 else if (len >= 2 && s[0] == '0' && s[1] == 'x') {
4785 for (; len-- && *s; s++) {
4786 xdigit = strchr((char *) PL_hexdigit, *s);
4788 /* Write it in this wonky order with a goto to attempt to get the
4789 compiler to make the common case integer-only loop pretty tight.
4790 With gcc seems to be much straighter code than old scan_hex. */
4793 if (value <= max_div_16) {
4794 value = (value << 4) | ((xdigit - PL_hexdigit) & 15);
4797 warn("Integer overflow in hexadecimal number");
4799 value_nv = (NV) value;
4802 /* If an NV has not enough bits in its mantissa to
4803 * represent a UV this summing of small low-order numbers
4804 * is a waste of time (because the NV cannot preserve
4805 * the low-order bits anyway): we could just remember when
4806 * did we overflow and in the end just multiply value_nv by the
4807 * right amount of 16-tuples. */
4808 value_nv += (NV)((xdigit - PL_hexdigit) & 15);
4811 if (*s == '_' && len && allow_underscores && s[1]
4812 && (xdigit = strchr((char *) PL_hexdigit, s[1])))
4818 if (!(*flags & PERL_SCAN_SILENT_ILLDIGIT))
4819 warn("Illegal hexadecimal digit '%c' ignored", *s);
4823 if ( ( overflowed && value_nv > 4294967295.0)
4825 || (!overflowed && value > 0xffffffff )
4828 warn("Hexadecimal number > 0xffffffff non-portable");
4835 *flags = PERL_SCAN_GREATER_THAN_UV_MAX;
4844 #if defined(NEED_grok_oct)
4845 static UV DPPP_(my_grok_oct)(pTHX_ char *start, STRLEN *len_p, I32 *flags, NV *result);
4848 extern UV DPPP_(my_grok_oct)(pTHX_ char *start, STRLEN *len_p, I32 *flags, NV *result);
4854 #define grok_oct(a,b,c,d) DPPP_(my_grok_oct)(aTHX_ a,b,c,d)
4855 #define Perl_grok_oct DPPP_(my_grok_oct)
4857 #if defined(NEED_grok_oct) || defined(NEED_grok_oct_GLOBAL)
4859 DPPP_(my_grok_oct)(pTHX_ char *start, STRLEN *len_p, I32 *flags, NV *result)
4861 const char *s = start;
4862 STRLEN len = *len_p;
4866 const UV max_div_8 = UV_MAX / 8;
4867 bool allow_underscores = *flags & PERL_SCAN_ALLOW_UNDERSCORES;
4868 bool overflowed = FALSE;
4870 for (; len-- && *s; s++) {
4871 /* gcc 2.95 optimiser not smart enough to figure that this subtraction
4872 out front allows slicker code. */
4873 int digit = *s - '0';
4874 if (digit >= 0 && digit <= 7) {
4875 /* Write it in this wonky order with a goto to attempt to get the
4876 compiler to make the common case integer-only loop pretty tight.
4880 if (value <= max_div_8) {
4881 value = (value << 3) | digit;
4884 /* Bah. We're just overflowed. */
4885 warn("Integer overflow in octal number");
4887 value_nv = (NV) value;
4890 /* If an NV has not enough bits in its mantissa to
4891 * represent a UV this summing of small low-order numbers
4892 * is a waste of time (because the NV cannot preserve
4893 * the low-order bits anyway): we could just remember when
4894 * did we overflow and in the end just multiply value_nv by the
4895 * right amount of 8-tuples. */
4896 value_nv += (NV)digit;
4899 if (digit == ('_' - '0') && len && allow_underscores
4900 && (digit = s[1] - '0') && (digit >= 0 && digit <= 7))
4906 /* Allow \octal to work the DWIM way (that is, stop scanning
4907 * as soon as non-octal characters are seen, complain only iff
4908 * someone seems to want to use the digits eight and nine). */
4909 if (digit == 8 || digit == 9) {
4910 if (!(*flags & PERL_SCAN_SILENT_ILLDIGIT))
4911 warn("Illegal octal digit '%c' ignored", *s);
4916 if ( ( overflowed && value_nv > 4294967295.0)
4918 || (!overflowed && value > 0xffffffff )
4921 warn("Octal number > 037777777777 non-portable");
4928 *flags = PERL_SCAN_GREATER_THAN_UV_MAX;
4938 # define dXCPT dJMPENV; int rEtV = 0
4939 # define XCPT_TRY_START JMPENV_PUSH(rEtV); if (rEtV == 0)
4940 # define XCPT_TRY_END JMPENV_POP;
4941 # define XCPT_CATCH if (rEtV != 0)
4942 # define XCPT_RETHROW JMPENV_JUMP(rEtV)
4944 # define dXCPT Sigjmp_buf oldTOP; int rEtV = 0
4945 # define XCPT_TRY_START Copy(top_env, oldTOP, 1, Sigjmp_buf); rEtV = Sigsetjmp(top_env, 1); if (rEtV == 0)
4946 # define XCPT_TRY_END Copy(oldTOP, top_env, 1, Sigjmp_buf);
4947 # define XCPT_CATCH if (rEtV != 0)
4948 # define XCPT_RETHROW Siglongjmp(top_env, rEtV)
4952 #endif /* _P_P_PORTABILITY_H_ */
4954 /* End of File ppport.h */