Upgrade to Devel::PPPort 3.02.
[p5sagit/p5-mst-13.2.git] / ext / Devel / PPPort / PPPort.pm
1 ################################################################################
2 #
3 #  !!!!! Do NOT edit this file directly! -- Edit PPPort_pm.PL instead. !!!!!
4 #
5 ################################################################################
6 #
7 #  Perl/Pollution/Portability
8 #
9 ################################################################################
10 #
11 #  $Revision: 30 $
12 #  $Author: mhx $
13 #  $Date: 2004/08/17 20:01:49 +0200 $
14 #
15 ################################################################################
16 #
17 #  Version 3.x, Copyright (C) 2004, Marcus Holland-Moritz.
18 #  Version 2.x, Copyright (C) 2001, Paul Marquess.
19 #  Version 1.x, Copyright (C) 1999, Kenneth Albanowski.
20 #
21 #  This program is free software; you can redistribute it and/or
22 #  modify it under the same terms as Perl itself.
23 #
24 ################################################################################
25
26 =head1 NAME
27
28 Devel::PPPort - Perl/Pollution/Portability
29
30 =head1 SYNOPSIS
31
32     Devel::PPPort::WriteFile();   # defaults to ./ppport.h
33     Devel::PPPort::WriteFile('someheader.h');
34
35 =head1 DESCRIPTION
36
37 Perl's API has changed over time, gaining new features, new functions,
38 increasing its flexibility, and reducing the impact on the C namespace
39 environment (reduced pollution). The header file written by this module,
40 typically F<ppport.h>, attempts to bring some of the newer Perl API
41 features to older versions of Perl, so that you can worry less about
42 keeping track of old releases, but users can still reap the benefit.
43
44 C<Devel::PPPort> contains a single function, called C<WriteFile>. Its
45 only purpose is to write the F<ppport.h> C header file. This file
46 contains a series of macros and, if explicitly requested, functions that
47 allow XS modules to be built using older versions of Perl. Currently,
48 Perl versions from 5.003 to 5.9.2 are supported.
49
50 This module is used by C<h2xs> to write the file F<ppport.h>. 
51
52 =head2 Why use ppport.h?
53  
54 You should use F<ppport.h> in modern code so that your code will work
55 with the widest range of Perl interpreters possible, without significant
56 additional work.
57
58 You should attempt older code to fully use F<ppport.h>, because the
59 reduced pollution of newer Perl versions is an important thing. It's so
60 important that the old polluting ways of original Perl modules will not be
61 supported very far into the future, and your module will almost certainly
62 break! By adapting to it now, you'll gain compatibility and a sense of
63 having done the electronic ecology some good.
64
65 =head2 How to use ppport.h
66
67 Don't direct the users of your module to download C<Devel::PPPort>.
68 They are most probably no XS writers. Also, don't make F<ppport.h>
69 optional. Rather, just take the most recent copy of F<ppport.h> that
70 you can find (e.g. by generating it with the latest C<Devel::PPPort>
71 release from CPAN), copy it into your project, adjust your project to
72 use it, and distribute the header along with your module. 
73
74 =head2 Running ppport.h
75
76 But F<ppport.h> is more than just a C header. It's also a Perl script
77 that can check your source code. It will suggest hints and portability
78 notes, and can even make suggestions on how to change your code. You
79 can run it like any other Perl program:
80
81     perl ppport.h
82
83 It also has embedded documentation, so you can use
84
85     perldoc ppport.h
86
87 to find out more about how to use it.
88
89 =head1 FUNCTIONS
90
91 =head2 WriteFile
92
93 C<WriteFile> takes one optional argument. When called with one
94 argument, it expects to be passed a filename. When called with
95 no arguments, it defaults to the filename F<ppport.h>.
96
97 The function returns a true value if the file was written successfully.
98 Otherwise it returns a false value.
99
100 =head1 COMPATIBILITY
101
102 F<ppport.h> supports Perl versions from 5.003 to 5.9.2
103 in threaded and non-threaded configurations.
104
105 =head2 Provided Perl compatibility API
106
107 The header file written by this module, typically F<ppport.h>, provides
108 access to the following elements of the Perl API that is not available
109 in older Perl releases:
110
111     _aMY_CXT
112     _pMY_CXT
113     aMY_CXT
114     aMY_CXT_
115     aTHX
116     aTHX_
117     AvFILLp
118     boolSV
119     call_argv
120     call_method
121     call_pv
122     call_sv
123     CopFILE
124     CopFILE_set
125     CopFILEAV
126     CopFILEGV
127     CopFILEGV_set
128     CopFILESV
129     CopSTASH
130     CopSTASH_eq
131     CopSTASH_set
132     CopSTASHPV
133     CopSTASHPV_set
134     CopyD
135     dAX
136     DEFSV
137     dITEMS
138     dMY_CXT
139     dMY_CXT_SV
140     dNOOP
141     dTHR
142     dTHX
143     dTHXa
144     dTHXoa
145     dUNDERBAR
146     END_EXTERN_C
147     ERRSV
148     eval_pv
149     eval_sv
150     EXTERN_C
151     get_av
152     get_cv
153     get_hv
154     get_sv
155     grok_bin
156     grok_hex
157     grok_number
158     GROK_NUMERIC_RADIX
159     grok_numeric_radix
160     grok_oct
161     gv_stashpvn
162     IN_LOCALE
163     IN_LOCALE_COMPILETIME
164     IN_LOCALE_RUNTIME
165     IN_PERL_COMPILETIME
166     INT2PTR
167     IS_NUMBER_GREATER_THAN_UV_MAX
168     IS_NUMBER_IN_UV
169     IS_NUMBER_INFINITY
170     IS_NUMBER_NAN
171     IS_NUMBER_NEG
172     IS_NUMBER_NOT_INT
173     IVdf
174     IVSIZE
175     IVTYPE
176     memEQ
177     memNE
178     MoveD
179     mPUSHi
180     mPUSHn
181     mPUSHp
182     mPUSHu
183     mXPUSHi
184     mXPUSHn
185     mXPUSHp
186     mXPUSHu
187     MY_CXT
188     MY_CXT_CLONE
189     MY_CXT_INIT
190     newCONSTSUB
191     newRV_inc
192     newRV_noinc
193     newSVpvn
194     newSVuv
195     NOOP
196     NUM2PTR
197     NVef
198     NVff
199     NVgf
200     NVTYPE
201     PERL_BCDVERSION
202     PERL_GCC_BRACE_GROUPS_FORBIDDEN
203     PERL_INT_MAX
204     PERL_INT_MIN
205     PERL_LONG_MAX
206     PERL_LONG_MIN
207     PERL_MAGIC_arylen
208     PERL_MAGIC_backref
209     PERL_MAGIC_bm
210     PERL_MAGIC_collxfrm
211     PERL_MAGIC_dbfile
212     PERL_MAGIC_dbline
213     PERL_MAGIC_defelem
214     PERL_MAGIC_env
215     PERL_MAGIC_envelem
216     PERL_MAGIC_ext
217     PERL_MAGIC_fm
218     PERL_MAGIC_glob
219     PERL_MAGIC_isa
220     PERL_MAGIC_isaelem
221     PERL_MAGIC_mutex
222     PERL_MAGIC_nkeys
223     PERL_MAGIC_overload
224     PERL_MAGIC_overload_elem
225     PERL_MAGIC_overload_table
226     PERL_MAGIC_pos
227     PERL_MAGIC_qr
228     PERL_MAGIC_regdata
229     PERL_MAGIC_regdatum
230     PERL_MAGIC_regex_global
231     PERL_MAGIC_shared
232     PERL_MAGIC_shared_scalar
233     PERL_MAGIC_sig
234     PERL_MAGIC_sigelem
235     PERL_MAGIC_substr
236     PERL_MAGIC_sv
237     PERL_MAGIC_taint
238     PERL_MAGIC_tied
239     PERL_MAGIC_tiedelem
240     PERL_MAGIC_tiedscalar
241     PERL_MAGIC_utf8
242     PERL_MAGIC_uvar
243     PERL_MAGIC_uvar_elem
244     PERL_MAGIC_vec
245     PERL_MAGIC_vstring
246     PERL_QUAD_MAX
247     PERL_QUAD_MIN
248     PERL_REVISION
249     PERL_SCAN_ALLOW_UNDERSCORES
250     PERL_SCAN_DISALLOW_PREFIX
251     PERL_SCAN_GREATER_THAN_UV_MAX
252     PERL_SCAN_SILENT_ILLDIGIT
253     PERL_SHORT_MAX
254     PERL_SHORT_MIN
255     PERL_SUBVERSION
256     PERL_UCHAR_MAX
257     PERL_UCHAR_MIN
258     PERL_UINT_MAX
259     PERL_UINT_MIN
260     PERL_ULONG_MAX
261     PERL_ULONG_MIN
262     PERL_UNUSED_DECL
263     PERL_UQUAD_MAX
264     PERL_UQUAD_MIN
265     PERL_USHORT_MAX
266     PERL_USHORT_MIN
267     PERL_VERSION
268     PL_compiling
269     PL_copline
270     PL_curcop
271     PL_curstash
272     PL_DBsingle
273     PL_DBsub
274     PL_debstash
275     PL_defgv
276     PL_diehook
277     PL_dirty
278     PL_dowarn
279     PL_errgv
280     PL_hexdigit
281     PL_hints
282     PL_na
283     PL_no_modify
284     PL_perl_destruct_level
285     PL_perldb
286     PL_ppaddr
287     PL_rsfp
288     PL_rsfp_filters
289     PL_stack_base
290     PL_stack_sp
291     PL_stdingv
292     PL_Sv
293     PL_sv_arenaroot
294     PL_sv_no
295     PL_sv_undef
296     PL_sv_yes
297     PL_tainted
298     PL_tainting
299     pMY_CXT
300     pMY_CXT_
301     Poison
302     pTHX
303     pTHX_
304     PTR2IV
305     PTR2NV
306     PTR2ul
307     PTR2UV
308     PTRV
309     PUSHmortal
310     PUSHu
311     SAVE_DEFSV
312     START_EXTERN_C
313     START_MY_CXT
314     STMT_END
315     STMT_START
316     sv_2pv_nolen
317     sv_2pvbyte
318     sv_2uv
319     sv_catpv_mg
320     sv_catpvf_mg
321     sv_catpvf_mg_nocontext
322     sv_catpvn_mg
323     sv_catpvn_nomg
324     sv_catsv_mg
325     sv_catsv_nomg
326     sv_pvn
327     sv_pvn_force
328     sv_pvn_nomg
329     sv_setiv_mg
330     sv_setnv_mg
331     sv_setpv_mg
332     sv_setpvf_mg
333     sv_setpvf_mg_nocontext
334     sv_setpvn_mg
335     sv_setsv_mg
336     sv_setsv_nomg
337     sv_setuv
338     sv_setuv_mg
339     sv_usepvn_mg
340     sv_uv
341     sv_vcatpvf
342     sv_vcatpvf_mg
343     sv_vsetpvf
344     sv_vsetpvf_mg
345     SvGETMAGIC
346     SvIV_nomg
347     SvPV_force_nomg
348     SvPV_nolen
349     SvPV_nomg
350     SvPVbyte
351     SvUV
352     SvUV_nomg
353     SvUVX
354     SvUVx
355     SvUVXx
356     UNDERBAR
357     UVof
358     UVSIZE
359     UVTYPE
360     UVuf
361     UVXf
362     UVxf
363     vnewSVpvf
364     XPUSHmortal
365     XPUSHu
366     XSRETURN_UV
367     XST_mUV
368     ZeroD
369
370 =head2 Perl API not supported by ppport.h
371
372 There is still a big part of the API not supported by F<ppport.h>.
373 Either because it doesn't make sense to back-port that part of the API,
374 or simply because it hasn't been implemented yet. Patches welcome!
375
376 Here's a list of the currently unsupported API, and also the version of
377 Perl below which it is unsupported:
378
379 =over 4
380
381 =item perl 5.9.2
382
383   SvPVbyte_force
384   find_rundefsvoffset
385   vnormal
386
387 =item perl 5.9.1
388
389   hv_assert
390   hv_clear_placeholders
391   hv_scalar
392   scan_version
393   sv_2iv_flags
394   sv_2uv_flags
395
396 =item perl 5.9.0
397
398   new_version
399   save_set_svflags
400   upg_version
401   vcmp
402   vnumify
403   vstringify
404
405 =item perl 5.8.3
406
407   SvIsCOW
408   SvIsCOW_shared_hash
409
410 =item perl 5.8.1
411
412   SvVOK
413   doing_taint
414   is_utf8_string_loc
415   packlist
416   save_bool
417   savestack_grow_cnt
418   scan_vstring
419   sv_cat_decode
420   sv_compile_2op
421   sv_setpviv
422   sv_setpviv_mg
423   unpackstring
424
425 =item perl 5.8.0
426
427   hv_iternext_flags
428   hv_store_flags
429   is_utf8_idcont
430   nothreadhook
431
432 =item perl 5.7.3
433
434   PerlIO_clearerr
435   PerlIO_close
436   PerlIO_eof
437   PerlIO_error
438   PerlIO_fileno
439   PerlIO_fill
440   PerlIO_flush
441   PerlIO_get_base
442   PerlIO_get_bufsiz
443   PerlIO_get_cnt
444   PerlIO_get_ptr
445   PerlIO_read
446   PerlIO_seek
447   PerlIO_set_cnt
448   PerlIO_set_ptrcnt
449   PerlIO_setlinebuf
450   PerlIO_stderr
451   PerlIO_stdin
452   PerlIO_stdout
453   PerlIO_tell
454   PerlIO_unread
455   PerlIO_write
456   SvLOCK
457   SvSHARE
458   SvUNLOCK
459   atfork_lock
460   atfork_unlock
461   custom_op_desc
462   custom_op_name
463   deb
464   debstack
465   debstackptrs
466   gv_fetchmeth_autoload
467   ibcmp_utf8
468   my_fork
469   my_socketpair
470   pack_cat
471   perl_destruct
472   pv_uni_display
473   regclass_swash
474   save_shared_pvref
475   savesharedpv
476   sortsv
477   sv_copypv
478   sv_magicext
479   sv_nolocking
480   sv_nosharing
481   sv_nounlocking
482   sv_recode_to_utf8
483   sv_uni_display
484   to_uni_fold
485   to_uni_lower
486   to_uni_title
487   to_uni_upper
488   to_utf8_case
489   to_utf8_fold
490   to_utf8_lower
491   to_utf8_title
492   to_utf8_upper
493   unpack_str
494   uvchr_to_utf8_flags
495   uvuni_to_utf8_flags
496   vdeb
497
498 =item perl 5.7.2
499
500   calloc
501   getcwd_sv
502   init_tm
503   malloc
504   mfree
505   mini_mktime
506   my_atof2
507   my_strftime
508   op_null
509   realloc
510   sv_2pv_flags
511   sv_catpvn_flags
512   sv_catsv_flags
513   sv_pvn_force_flags
514   sv_setsv_flags
515   sv_utf8_upgrade_flags
516   swash_fetch
517
518 =item perl 5.7.1
519
520   POPpbytex
521   SvUOK
522   bytes_from_utf8
523   csighandler
524   despatch_signals
525   do_openn
526   gv_handler
527   is_lvalue_sub
528   my_popen_list
529   newSVpvn_share
530   save_mortalizesv
531   save_padsv
532   scan_num
533   sv_force_normal_flags
534   sv_setref_uv
535   sv_unref_flags
536   sv_utf8_upgrade
537   utf8_length
538   utf8_to_uvchr
539   utf8_to_uvuni
540   utf8n_to_uvchr
541   utf8n_to_uvuni
542   uvchr_to_utf8
543   uvuni_to_utf8
544
545 =item perl 5.6.1
546
547   apply_attrs_string
548   bytes_to_utf8
549   gv_efullname4
550   gv_fullname4
551   is_utf8_string
552   save_generic_pvref
553   utf16_to_utf8
554   utf16_to_utf8_reversed
555   utf8_to_bytes
556
557 =item perl 5.6.0
558
559   SvIOK_UV
560   SvIOK_notUV
561   SvIOK_only_UV
562   SvPOK_only_UTF8
563   SvPVbyte_nolen
564   SvPVbytex
565   SvPVbytex_force
566   SvPVutf8
567   SvPVutf8_force
568   SvPVutf8_nolen
569   SvPVutf8x
570   SvPVutf8x_force
571   SvUTF8
572   SvUTF8_off
573   SvUTF8_on
574   av_delete
575   av_exists
576   call_atexit
577   cast_i32
578   cast_iv
579   cast_ulong
580   cast_uv
581   do_gv_dump
582   do_gvgv_dump
583   do_hv_dump
584   do_magic_dump
585   do_op_dump
586   do_open9
587   do_pmop_dump
588   do_sv_dump
589   dump_all
590   dump_eval
591   dump_form
592   dump_indent
593   dump_packsubs
594   dump_sub
595   dump_vindent
596   get_context
597   get_ppaddr
598   gv_dump
599   init_i18nl10n
600   init_i18nl14n
601   is_uni_alnum
602   is_uni_alnum_lc
603   is_uni_alnumc
604   is_uni_alnumc_lc
605   is_uni_alpha
606   is_uni_alpha_lc
607   is_uni_ascii
608   is_uni_ascii_lc
609   is_uni_cntrl
610   is_uni_cntrl_lc
611   is_uni_digit
612   is_uni_digit_lc
613   is_uni_graph
614   is_uni_graph_lc
615   is_uni_idfirst
616   is_uni_idfirst_lc
617   is_uni_lower
618   is_uni_lower_lc
619   is_uni_print
620   is_uni_print_lc
621   is_uni_punct
622   is_uni_punct_lc
623   is_uni_space
624   is_uni_space_lc
625   is_uni_upper
626   is_uni_upper_lc
627   is_uni_xdigit
628   is_uni_xdigit_lc
629   is_utf8_alnum
630   is_utf8_alnumc
631   is_utf8_alpha
632   is_utf8_ascii
633   is_utf8_char
634   is_utf8_cntrl
635   is_utf8_digit
636   is_utf8_graph
637   is_utf8_idfirst
638   is_utf8_lower
639   is_utf8_mark
640   is_utf8_print
641   is_utf8_punct
642   is_utf8_space
643   is_utf8_upper
644   is_utf8_xdigit
645   load_module
646   magic_dump
647   mess
648   my_atof
649   my_fflush_all
650   newANONATTRSUB
651   newATTRSUB
652   newMYSUB
653   newPADOP
654   newXS
655   newXSproto
656   new_collate
657   new_ctype
658   new_numeric
659   op_dump
660   perl_parse
661   pmop_dump
662   pv_display
663   re_intuit_start
664   re_intuit_string
665   reginitcolors
666   require_pv
667   safesyscalloc
668   safesysfree
669   safesysmalloc
670   safesysrealloc
671   save_I8
672   save_alloc
673   save_destructor
674   save_destructor_x
675   save_re_context
676   save_vptr
677   scan_bin
678   set_context
679   set_numeric_local
680   set_numeric_radix
681   set_numeric_standard
682   str_to_version
683   sv_2pvutf8
684   sv_2pvutf8_nolen
685   sv_force_normal
686   sv_len_utf8
687   sv_pos_b2u
688   sv_pos_u2b
689   sv_pv
690   sv_pvbyte
691   sv_pvbyten
692   sv_pvbyten_force
693   sv_pvutf8
694   sv_pvutf8n
695   sv_pvutf8n_force
696   sv_rvweaken
697   sv_utf8_decode
698   sv_utf8_downgrade
699   sv_utf8_encode
700   swash_init
701   tmps_grow
702   to_uni_lower_lc
703   to_uni_title_lc
704   to_uni_upper_lc
705   utf8_distance
706   utf8_hop
707   vcroak
708   vform
709   vload_module
710   vmess
711   vwarn
712   vwarner
713   warner
714
715 =item perl 5.005_03
716
717   POPpx
718   get_vtbl
719   save_generic_svref
720
721 =item perl 5.005
722
723   PL_modglobal
724   cx_dump
725   debop
726   debprofdump
727   fbm_compile
728   fbm_instr
729   get_op_descs
730   get_op_names
731   init_stacks
732   mg_length
733   mg_size
734   newHVhv
735   new_stackinfo
736   regdump
737   regexec_flags
738   regnext
739   runops_debug
740   runops_standard
741   save_hints
742   save_iv
743   save_threadsv
744   screaminstr
745   sv_iv
746   sv_nv
747   sv_peek
748   sv_true
749
750 =item perl 5.004_05
751
752   do_binmode
753   save_aelem
754   save_helem
755
756 =item perl 5.004_04
757
758   newWHILEOP
759
760 =item perl 5.004
761
762   GIMME_V
763   G_VOID
764   HEf_SVKEY
765   HeHASH
766   HeKEY
767   HeKLEN
768   HePV
769   HeSVKEY
770   HeSVKEY_force
771   HeSVKEY_set
772   HeVAL
773   SvSetMagicSV
774   SvSetMagicSV_nosteal
775   SvSetSV_nosteal
776   SvTAINTED
777   SvTAINTED_off
778   SvTAINTED_on
779   block_gimme
780   call_list
781   cv_const_sv
782   delimcpy
783   do_open
784   form
785   gv_autoload4
786   gv_efullname3
787   gv_fetchmethod_autoload
788   gv_fullname3
789   hv_delayfree_ent
790   hv_delete_ent
791   hv_exists_ent
792   hv_fetch_ent
793   hv_free_ent
794   hv_iterkeysv
795   hv_ksplit
796   hv_store_ent
797   ibcmp_locale
798   my_failure_exit
799   my_memcmp
800   my_pclose
801   my_popen
802   newSVpvf
803   rsignal
804   rsignal_state
805   save_I16
806   save_gp
807   start_subparse
808   sv_catpvf
809   sv_catpvf_mg
810   sv_cmp_locale
811   sv_derived_from
812   sv_gets
813   sv_setpvf
814   sv_setpvf_mg
815   sv_taint
816   sv_tainted
817   sv_untaint
818   sv_vcatpvf
819   sv_vcatpvf_mg
820   sv_vcatpvfn
821   sv_vsetpvf
822   sv_vsetpvf_mg
823   sv_vsetpvfn
824   unsharepvn
825   vnewSVpvf
826
827 =back
828
829 =head1 BUGS
830
831 If you find any bugs, C<Devel::PPPort> doesn't seem to build on your
832 system or any of its tests fail, please use the CPAN Request Tracker
833 at L<http://rt.cpan.org/> to create a ticket for the module.
834
835 =head1 AUTHORS
836
837 =over 2
838
839 =item *
840
841 Version 1.x of Devel::PPPort was written by Kenneth Albanowski.
842
843 =item *
844
845 Version 2.x was ported to the Perl core by Paul Marquess.
846
847 =item *
848
849 Version 3.x was ported back to CPAN by Marcus Holland-Moritz.
850
851 =back
852
853 =head1 COPYRIGHT
854
855 Version 3.x, Copyright (C) 2004, Marcus Holland-Moritz.
856
857 Version 2.x, Copyright (C) 2001, Paul Marquess.
858
859 Version 1.x, Copyright (C) 1999, Kenneth Albanowski.
860
861 This program is free software; you can redistribute it and/or
862 modify it under the same terms as Perl itself.
863
864 =head1 SEE ALSO
865
866 See L<h2xs>, L<ppport.h>.
867
868 =cut
869
870 package Devel::PPPort;
871
872 require DynaLoader;
873 use strict;
874 use vars qw($VERSION @ISA $data);
875
876 $VERSION = do { my @r = '$Snapshot: /Devel-PPPort/3.02 $' =~ /(\d+\.\d+(?:_\d+)?)/; @r ? $r[0] : '9.99' };
877
878 @ISA = qw(DynaLoader);
879
880 bootstrap Devel::PPPort;
881
882 {
883   $data = do { local $/; <DATA> };
884   my $now = localtime;
885   my $pkg = 'Devel::PPPort';
886   $data =~ s/__PERL_VERSION__/$]/g;
887   $data =~ s/__VERSION__/$VERSION/g;
888   $data =~ s/__DATE__/$now/g;
889   $data =~ s/__PKG__/$pkg/g;
890   $data =~ s/^POD\s//gm;
891 }
892
893 sub WriteFile
894 {
895   my $file = shift || 'ppport.h';
896   my $copy = $data;
897   $copy =~ s/\bppport\.h\b/$file/g;
898
899   open F, ">$file" or return undef;
900   print F $copy;
901   close F;
902
903   return 1;
904 }
905
906 1;
907
908 __DATA__
909 #if 0
910 <<'SKIP';
911 #endif
912 /*
913 ----------------------------------------------------------------------
914
915     ppport.h -- Perl/Pollution/Portability Version __VERSION__ 
916    
917     Automatically created by __PKG__ running under
918     perl __PERL_VERSION__ on __DATE__.
919     
920     Do NOT edit this file directly! -- Edit PPPort_pm.PL and the
921     includes in parts/inc/ instead.
922  
923     Use 'perldoc ppport.h' to view the documentation below.
924
925 ----------------------------------------------------------------------
926
927 SKIP
928
929 POD =pod
930 POD 
931 POD =head1 NAME
932 POD 
933 POD ppport.h - Perl/Pollution/Portability version __VERSION__
934 POD 
935 POD =head1 SYNOPSIS
936 POD 
937 POD   perl ppport.h [options] [files]
938 POD 
939 POD   --help                      show short help
940 POD 
941 POD   --patch=file                write one patch file with changes
942 POD   --copy=suffix               write changed copies with suffix
943 POD   --diff=program              use diff program and options
944 POD 
945 POD   --compat-version=version    provide compatibility with Perl version
946 POD   --cplusplus                 accept C++ comments
947 POD 
948 POD   --quiet                     don't output anything except fatal errors
949 POD   --nodiag                    don't show diagnostics
950 POD   --nohints                   don't show hints
951 POD   --nochanges                 don't suggest changes
952 POD 
953 POD   --list-provided             list provided API
954 POD   --list-unsupported          list unsupported API
955 POD 
956 POD =head1 COMPATIBILITY
957 POD 
958 POD This version of F<ppport.h> is designed to support operation with Perl
959 POD installations back to 5.003, and has been tested up to 5.9.2.
960 POD 
961 POD =head1 OPTIONS
962 POD 
963 POD =head2 --help
964 POD 
965 POD Display a brief usage summary.
966 POD 
967 POD =head2 --patch=I<file>
968 POD 
969 POD If this option is given, a single patch file will be created if
970 POD any changes are suggested. This requires a working diff program
971 POD to be installed on your system.
972 POD 
973 POD =head2 --copy=I<suffix>
974 POD 
975 POD If this option is given, a copy of each file will be saved with
976 POD the given suffix that contains the suggested changes. This does
977 POD not require any external programs.
978 POD 
979 POD If neither C<--patch> or C<--copy> are given, the default is to
980 POD simply print the diffs for each file. This requires either
981 POD C<Text::Diff> or a C<diff> program to be installed.
982 POD 
983 POD =head2 --diff=I<program>
984 POD 
985 POD Manually set the diff program and options to use. The default
986 POD is to use C<Text::Diff>, when installed, and output unified
987 POD context diffs.
988 POD 
989 POD =head2 --compat-version=I<version>
990 POD 
991 POD Tell F<ppport.h> to check for compatibility with the given
992 POD Perl version. The default is to check for compatibility with Perl
993 POD version 5.003. You can use this option to reduce the output
994 POD of F<ppport.h> if you intend to be backward compatible only
995 POD up to a certain Perl version.
996 POD 
997 POD =head2 --cplusplus
998 POD 
999 POD Usually, F<ppport.h> will detect C++ style comments and
1000 POD replace them with C style comments for portability reasons.
1001 POD Using this option instructs F<ppport.h> to leave C++
1002 POD comments untouched.
1003 POD 
1004 POD =head2 --quiet
1005 POD 
1006 POD Be quiet. Don't print anything except fatal errors.
1007 POD 
1008 POD =head2 --nodiag
1009 POD 
1010 POD Don't output any diagnostic messages. Only portability
1011 POD alerts will be printed.
1012 POD 
1013 POD =head2 --nohints
1014 POD 
1015 POD Don't output any hints. Hints often contain useful portability
1016 POD notes.
1017 POD 
1018 POD =head2 --nochanges
1019 POD 
1020 POD Don't suggest any changes. Only give diagnostic output and hints
1021 POD unless these are also deactivated.
1022 POD 
1023 POD =head2 --list-provided
1024 POD 
1025 POD Lists the API elements for which compatibility is provided by
1026 POD F<ppport.h>. Also lists if it must be explicitly requested,
1027 POD if it has dependencies, and if there are hints for it.
1028 POD 
1029 POD =head2 --list-unsupported
1030 POD 
1031 POD Lists the API elements that are known not to be supported by
1032 POD F<ppport.h> and below which version of Perl they probably
1033 POD won't be available or work.
1034 POD 
1035 POD =head1 DESCRIPTION
1036 POD 
1037 POD In order for a Perl extension (XS) module to be as portable as possible
1038 POD across differing versions of Perl itself, certain steps need to be taken.
1039 POD 
1040 POD =over 4
1041 POD 
1042 POD =item *
1043 POD 
1044 POD Including this header is the first major one. This alone will give you
1045 POD access to a large part of the Perl API that hasn't been available in
1046 POD earlier Perl releases. Use
1047 POD 
1048 POD     perl ppport.h --list-provided
1049 POD 
1050 POD to see which API elements are provided by ppport.h.
1051 POD 
1052 POD =item *
1053 POD 
1054 POD You should avoid using deprecated parts of the API. For example, using
1055 POD global Perl variables without the C<PL_> prefix is deprecated. Also,
1056 POD some API functions used to have a C<perl_> prefix. Using this form is
1057 POD also deprecated. You can safely use the supported API, as F<ppport.h>
1058 POD will provide wrappers for older Perl versions.
1059 POD 
1060 POD =item *
1061 POD 
1062 POD If you use one of a few functions that were not present in earlier
1063 POD versions of Perl, and that can't be provided using a macro, you have
1064 POD to explicitly request support for these functions by adding one or
1065 POD more C<#define>s in your source code before the inclusion of F<ppport.h>.
1066 POD 
1067 POD These functions will be marked C<explicit> in the list shown by
1068 POD C<--list-provided>.
1069 POD 
1070 POD Depending on whether you module has a single or multiple files that
1071 POD use such functions, you want either C<static> or global variants.
1072 POD 
1073 POD For a C<static> function, use:
1074 POD 
1075 POD     #define NEED_function
1076 POD 
1077 POD For a global function, use:
1078 POD 
1079 POD     #define NEED_function_GLOBAL
1080 POD 
1081 POD Note that you mustn't have more than one global request for one
1082 POD function in your project.
1083 POD 
1084 POD     Function                  Static Request               Global Request                    
1085 POD     -----------------------------------------------------------------------------------------
1086 POD     eval_pv()                 NEED_eval_pv                 NEED_eval_pv_GLOBAL               
1087 POD     grok_bin()                NEED_grok_bin                NEED_grok_bin_GLOBAL              
1088 POD     grok_hex()                NEED_grok_hex                NEED_grok_hex_GLOBAL              
1089 POD     grok_number()             NEED_grok_number             NEED_grok_number_GLOBAL           
1090 POD     grok_numeric_radix()      NEED_grok_numeric_radix      NEED_grok_numeric_radix_GLOBAL    
1091 POD     grok_oct()                NEED_grok_oct                NEED_grok_oct_GLOBAL              
1092 POD     newCONSTSUB()             NEED_newCONSTSUB             NEED_newCONSTSUB_GLOBAL           
1093 POD     newRV_noinc()             NEED_newRV_noinc             NEED_newRV_noinc_GLOBAL           
1094 POD     sv_2pv_nolen()            NEED_sv_2pv_nolen            NEED_sv_2pv_nolen_GLOBAL          
1095 POD     sv_2pvbyte()              NEED_sv_2pvbyte              NEED_sv_2pvbyte_GLOBAL            
1096 POD     sv_catpvf_mg()            NEED_sv_catpvf_mg            NEED_sv_catpvf_mg_GLOBAL          
1097 POD     sv_catpvf_mg_nocontext()  NEED_sv_catpvf_mg_nocontext  NEED_sv_catpvf_mg_nocontext_GLOBAL
1098 POD     sv_setpvf_mg()            NEED_sv_setpvf_mg            NEED_sv_setpvf_mg_GLOBAL          
1099 POD     sv_setpvf_mg_nocontext()  NEED_sv_setpvf_mg_nocontext  NEED_sv_setpvf_mg_nocontext_GLOBAL
1100 POD     vnewSVpvf()               NEED_vnewSVpvf               NEED_vnewSVpvf_GLOBAL             
1101 POD 
1102 POD To avoid namespace conflicts, you can change the namespace of the
1103 POD explicitly exported functions using the C<DPPP_NAMESPACE> macro.
1104 POD Just C<#define> the macro before including C<ppport.h>:
1105 POD 
1106 POD     #define DPPP_NAMESPACE MyOwnNamespace_
1107 POD     #include "ppport.h"
1108 POD 
1109 POD The default namespace is C<DPPP_>.
1110 POD 
1111 POD =back
1112 POD 
1113 POD The good thing is that most of the above can be checked by running
1114 POD F<ppport.h> on your source code. See the next section for
1115 POD details.
1116 POD 
1117 POD =head1 EXAMPLES
1118 POD 
1119 POD To verify whether F<ppport.h> is needed for your module, whether you
1120 POD should make any changes to your code, and whether any special defines
1121 POD should be used, F<ppport.h> can be run as a Perl script to check your
1122 POD source code. Simply say:
1123 POD 
1124 POD     perl ppport.h
1125 POD 
1126 POD The result will usually be a list of patches suggesting changes
1127 POD that should at least be acceptable, if not necessarily the most
1128 POD efficient solution, or a fix for all possible problems.
1129 POD 
1130 POD If you know that your XS module uses features only available in
1131 POD newer Perl releases, if you're aware that it uses C++ comments,
1132 POD and if you want all suggestions as a single patch file, you could
1133 POD use something like this:
1134 POD 
1135 POD     perl ppport.h --compat-version=5.6.0 --cplusplus --patch=test.diff
1136 POD 
1137 POD If you only want your code to be scanned without any suggestions
1138 POD for changes, use:
1139 POD 
1140 POD     perl ppport.h --nochanges
1141 POD 
1142 POD You can specify a different C<diff> program or options, using
1143 POD the C<--diff> option:
1144 POD 
1145 POD     perl ppport.h --diff='diff -C 10'
1146 POD 
1147 POD This would output context diffs with 10 lines of context.
1148 POD 
1149 POD =head1 BUGS
1150 POD 
1151 POD If this version of F<ppport.h> is causing failure during
1152 POD the compilation of this module, please check if newer versions
1153 POD of either this module or C<Devel::PPPort> are available on CPAN
1154 POD before sending a bug report.
1155 POD 
1156 POD If F<ppport.h> was generated using the latest version of
1157 POD C<Devel::PPPort> and is causing failure of this module, please
1158 POD file a bug report using the CPAN Request Tracker at L<http://rt.cpan.org/>.
1159 POD 
1160 POD Please include the following information:
1161 POD 
1162 POD =over 4
1163 POD 
1164 POD =item 1.
1165 POD 
1166 POD The complete output from running "perl -V"
1167 POD 
1168 POD =item 2.
1169 POD 
1170 POD This file.
1171 POD 
1172 POD =item 3.
1173 POD 
1174 POD The name and version of the module you were trying to build.
1175 POD 
1176 POD =item 4.
1177 POD 
1178 POD A full log of the build that failed.
1179 POD 
1180 POD =item 5.
1181 POD 
1182 POD Any other information that you think could be relevant.
1183 POD 
1184 POD =back
1185 POD 
1186 POD For the latest version of this code, please get the C<Devel::PPPort>
1187 POD module from CPAN.
1188 POD 
1189 POD =head1 COPYRIGHT
1190 POD 
1191 POD Version 3.x, Copyright (c) 2004, Marcus Holland-Moritz.
1192 POD 
1193 POD Version 2.x, Copyright (C) 2001, Paul Marquess.
1194 POD 
1195 POD Version 1.x, Copyright (C) 1999, Kenneth Albanowski.
1196 POD 
1197 POD This program is free software; you can redistribute it and/or
1198 POD modify it under the same terms as Perl itself.
1199 POD 
1200 POD =head1 SEE ALSO
1201 POD 
1202 POD See L<Devel::PPPort>.
1203
1204 =cut
1205
1206 use strict;
1207
1208 my %opt = (
1209   quiet     => 0,
1210   diag      => 1,
1211   hints     => 1,
1212   changes   => 1,
1213   cplusplus => 0,
1214 );
1215
1216 my($ppport) = $0 =~ /([\w.]+)$/;
1217 my $LF = '(?:\r\n|[\r\n])';   # line feed
1218 my $HS = "[ \t]";             # horizontal whitespace
1219
1220 eval {
1221   require Getopt::Long;
1222   Getopt::Long::GetOptions(\%opt, qw(
1223     help quiet diag! hints! changes! cplusplus
1224     patch=s copy=s diff=s compat-version=s
1225     list-provided list-unsupported
1226   )) or usage();
1227 };
1228
1229 if ($@ and grep /^-/, @ARGV) {
1230   usage() if "@ARGV" =~ /^--?h(?:elp)?$/;
1231   die "Getopt::Long not found. Please don't use any options.\n";
1232 }
1233
1234 usage() if $opt{help};
1235
1236 if (exists $opt{'compat-version'}) {
1237   my($r,$v,$s) = eval { parse_version($opt{'compat-version'}) };
1238   if ($@) {
1239     die "Invalid version number format: '$opt{'compat-version'}'\n";
1240   }
1241   die "Only Perl 5 is supported\n" if $r != 5;
1242   die "Invalid version number: $opt{'compat-version'}\n" if $v >= 1000 || $v >= 1000;
1243   $opt{'compat-version'} = sprintf "%d.%03d%03d", $r, $v, $s;
1244 }
1245 else {
1246   $opt{'compat-version'} = 5;
1247 }
1248
1249 # Never use C comments in this file!!!!!
1250 my $ccs  = '/'.'*';
1251 my $cce  = '*'.'/';
1252 my $rccs = quotemeta $ccs;
1253 my $rcce = quotemeta $cce;
1254
1255 my @files;
1256
1257 if (@ARGV) {
1258   @files = map { glob $_ } @ARGV;
1259 }
1260 else {
1261   eval {
1262     require File::Find;
1263     File::Find::find(sub {
1264       $File::Find::name =~ /\.(xs|c|h|cc)$/i
1265           and push @files, $File::Find::name;
1266     }, '.');
1267   };
1268   if ($@) {
1269     @files = map { glob $_ } qw(*.xs *.c *.h *.cc);
1270   }
1271   my %filter = map { /(.*)\.xs$/ ? ("$1.c" => 1) : () } @files;
1272   @files = grep { !/\b\Q$ppport\E$/i && !exists $filter{$_} } @files;
1273 }
1274
1275 unless (@files) {
1276   die "No input files given!\n";
1277 }
1278
1279 my %API = map { /^(\w+)\|([^|]*)\|([^|]*)\|(\w*)$/
1280                 ? ( $1 => { 
1281                       ($2                  ? ( base     => $2 ) : ()),
1282                       ($3                  ? ( todo     => $3 ) : ()),
1283                       (index($4, 'v') >= 0 ? ( varargs  => 1  ) : ()),
1284                       (index($4, 'p') >= 0 ? ( provided => 1  ) : ()),
1285                       (index($4, 'n') >= 0 ? ( nothxarg => 1  ) : ()),
1286                     } )
1287                 : die "invalid spec: $_" } qw(
1288 AvFILLp|5.004050||p
1289 AvFILL|||
1290 CLASS|||n
1291 CX_CURPAD_SAVE|||
1292 CX_CURPAD_SV|||
1293 CopFILEAV|5.006000||p
1294 CopFILEGV_set|5.006000||p
1295 CopFILEGV|5.006000||p
1296 CopFILESV|5.006000||p
1297 CopFILE_set|5.006000||p
1298 CopFILE|5.006000||p
1299 CopSTASHPV_set|5.006000||p
1300 CopSTASHPV|5.006000||p
1301 CopSTASH_eq|5.006000||p
1302 CopSTASH_set|5.006000||p
1303 CopSTASH|5.006000||p
1304 CopyD|5.009002||p
1305 Copy|||
1306 CvPADLIST|||
1307 CvSTASH|||
1308 CvWEAKOUTSIDE|||
1309 DEFSV|5.004050||p
1310 END_EXTERN_C|5.005000||p
1311 ENTER|||
1312 ERRSV|5.004050||p
1313 EXTEND|||
1314 EXTERN_C|5.005000||p
1315 FREETMPS|||
1316 GIMME_V||5.004000|n
1317 GIMME|||n
1318 GROK_NUMERIC_RADIX|5.007002||p
1319 G_ARRAY|||
1320 G_DISCARD|||
1321 G_EVAL|||
1322 G_NOARGS|||
1323 G_SCALAR|||
1324 G_VOID||5.004000|
1325 GetVars|||
1326 GvSV|||
1327 Gv_AMupdate|||
1328 HEf_SVKEY||5.004000|
1329 HeHASH||5.004000|
1330 HeKEY||5.004000|
1331 HeKLEN||5.004000|
1332 HePV||5.004000|
1333 HeSVKEY_force||5.004000|
1334 HeSVKEY_set||5.004000|
1335 HeSVKEY||5.004000|
1336 HeVAL||5.004000|
1337 HvNAME|||
1338 INT2PTR|5.006000||p
1339 IN_LOCALE_COMPILETIME|5.007002||p
1340 IN_LOCALE_RUNTIME|5.007002||p
1341 IN_LOCALE|5.007002||p
1342 IN_PERL_COMPILETIME|5.008001||p
1343 IS_NUMBER_GREATER_THAN_UV_MAX|5.007002||p
1344 IS_NUMBER_INFINITY|5.007002||p
1345 IS_NUMBER_IN_UV|5.007002||p
1346 IS_NUMBER_NAN|5.007003||p
1347 IS_NUMBER_NEG|5.007002||p
1348 IS_NUMBER_NOT_INT|5.007002||p
1349 IVSIZE|5.006000||p
1350 IVTYPE|5.006000||p
1351 IVdf|5.006000||p
1352 LEAVE|||
1353 LVRET|||
1354 MARK|||
1355 MY_CXT_CLONE|5.009002||p
1356 MY_CXT_INIT|5.007003||p
1357 MY_CXT|5.007003||p
1358 MoveD|5.009002||p
1359 Move|||
1360 NEWSV|||
1361 NOOP|5.005000||p
1362 NUM2PTR|5.006000||p
1363 NVTYPE|5.006000||p
1364 NVef|5.006001||p
1365 NVff|5.006001||p
1366 NVgf|5.006001||p
1367 Newc|||
1368 Newz|||
1369 New|||
1370 Nullav|||
1371 Nullch|||
1372 Nullcv|||
1373 Nullhv|||
1374 Nullsv|||
1375 ORIGMARK|||
1376 PAD_BASE_SV|||
1377 PAD_CLONE_VARS|||
1378 PAD_COMPNAME_FLAGS|||
1379 PAD_COMPNAME_GEN|||
1380 PAD_COMPNAME_OURSTASH|||
1381 PAD_COMPNAME_PV|||
1382 PAD_COMPNAME_TYPE|||
1383 PAD_RESTORE_LOCAL|||
1384 PAD_SAVE_LOCAL|||
1385 PAD_SAVE_SETNULLPAD|||
1386 PAD_SETSV|||
1387 PAD_SET_CUR_NOSAVE|||
1388 PAD_SET_CUR|||
1389 PAD_SVl|||
1390 PAD_SV|||
1391 PERL_BCDVERSION|5.009002||p
1392 PERL_GCC_BRACE_GROUPS_FORBIDDEN|5.008001||p
1393 PERL_INT_MAX|5.004000||p
1394 PERL_INT_MIN|5.004000||p
1395 PERL_LONG_MAX|5.004000||p
1396 PERL_LONG_MIN|5.004000||p
1397 PERL_MAGIC_arylen|5.007002||p
1398 PERL_MAGIC_backref|5.007002||p
1399 PERL_MAGIC_bm|5.007002||p
1400 PERL_MAGIC_collxfrm|5.007002||p
1401 PERL_MAGIC_dbfile|5.007002||p
1402 PERL_MAGIC_dbline|5.007002||p
1403 PERL_MAGIC_defelem|5.007002||p
1404 PERL_MAGIC_envelem|5.007002||p
1405 PERL_MAGIC_env|5.007002||p
1406 PERL_MAGIC_ext|5.007002||p
1407 PERL_MAGIC_fm|5.007002||p
1408 PERL_MAGIC_glob|5.007002||p
1409 PERL_MAGIC_isaelem|5.007002||p
1410 PERL_MAGIC_isa|5.007002||p
1411 PERL_MAGIC_mutex|5.007002||p
1412 PERL_MAGIC_nkeys|5.007002||p
1413 PERL_MAGIC_overload_elem|5.007002||p
1414 PERL_MAGIC_overload_table|5.007002||p
1415 PERL_MAGIC_overload|5.007002||p
1416 PERL_MAGIC_pos|5.007002||p
1417 PERL_MAGIC_qr|5.007002||p
1418 PERL_MAGIC_regdata|5.007002||p
1419 PERL_MAGIC_regdatum|5.007002||p
1420 PERL_MAGIC_regex_global|5.007002||p
1421 PERL_MAGIC_shared_scalar|5.007003||p
1422 PERL_MAGIC_shared|5.007003||p
1423 PERL_MAGIC_sigelem|5.007002||p
1424 PERL_MAGIC_sig|5.007002||p
1425 PERL_MAGIC_substr|5.007002||p
1426 PERL_MAGIC_sv|5.007002||p
1427 PERL_MAGIC_taint|5.007002||p
1428 PERL_MAGIC_tiedelem|5.007002||p
1429 PERL_MAGIC_tiedscalar|5.007002||p
1430 PERL_MAGIC_tied|5.007002||p
1431 PERL_MAGIC_utf8|5.008001||p
1432 PERL_MAGIC_uvar_elem|5.007003||p
1433 PERL_MAGIC_uvar|5.007002||p
1434 PERL_MAGIC_vec|5.007002||p
1435 PERL_MAGIC_vstring|5.008001||p
1436 PERL_QUAD_MAX|5.004000||p
1437 PERL_QUAD_MIN|5.004000||p
1438 PERL_REVISION|5.006000||p
1439 PERL_SCAN_ALLOW_UNDERSCORES|5.007003||p
1440 PERL_SCAN_DISALLOW_PREFIX|5.007003||p
1441 PERL_SCAN_GREATER_THAN_UV_MAX|5.007003||p
1442 PERL_SCAN_SILENT_ILLDIGIT|5.008001||p
1443 PERL_SHORT_MAX|5.004000||p
1444 PERL_SHORT_MIN|5.004000||p
1445 PERL_SUBVERSION|5.006000||p
1446 PERL_UCHAR_MAX|5.004000||p
1447 PERL_UCHAR_MIN|5.004000||p
1448 PERL_UINT_MAX|5.004000||p
1449 PERL_UINT_MIN|5.004000||p
1450 PERL_ULONG_MAX|5.004000||p
1451 PERL_ULONG_MIN|5.004000||p
1452 PERL_UNUSED_DECL|5.007002||p
1453 PERL_UQUAD_MAX|5.004000||p
1454 PERL_UQUAD_MIN|5.004000||p
1455 PERL_USHORT_MAX|5.004000||p
1456 PERL_USHORT_MIN|5.004000||p
1457 PERL_VERSION|5.006000||p
1458 PL_DBsingle|||pn
1459 PL_DBsub|||pn
1460 PL_DBtrace|||n
1461 PL_Sv|5.005000||p
1462 PL_compiling|5.004050||p
1463 PL_copline|5.005000||p
1464 PL_curcop|5.004050||p
1465 PL_curstash|5.004050||p
1466 PL_debstash|5.004050||p
1467 PL_defgv|5.004050||p
1468 PL_diehook|5.004050||p
1469 PL_dirty|5.004050||p
1470 PL_dowarn|||pn
1471 PL_errgv|5.004050||p
1472 PL_hexdigit|5.005000||p
1473 PL_hints|5.005000||p
1474 PL_last_in_gv|||n
1475 PL_modglobal||5.005000|n
1476 PL_na|5.004050||pn
1477 PL_no_modify|5.006000||p
1478 PL_ofs_sv|||n
1479 PL_perl_destruct_level|5.004050||p
1480 PL_perldb|5.004050||p
1481 PL_ppaddr|5.006000||p
1482 PL_rsfp_filters|5.004050||p
1483 PL_rsfp|5.004050||p
1484 PL_rs|||n
1485 PL_stack_base|5.004050||p
1486 PL_stack_sp|5.004050||p
1487 PL_stdingv|5.004050||p
1488 PL_sv_arenaroot|5.004050||p
1489 PL_sv_no|5.004050||pn
1490 PL_sv_undef|5.004050||pn
1491 PL_sv_yes|5.004050||pn
1492 PL_tainted|5.004050||p
1493 PL_tainting|5.004050||p
1494 POPi|||n
1495 POPl|||n
1496 POPn|||n
1497 POPpbytex||5.007001|n
1498 POPpx||5.005030|n
1499 POPp|||n
1500 POPs|||n
1501 PTR2IV|5.006000||p
1502 PTR2NV|5.006000||p
1503 PTR2UV|5.006000||p
1504 PTR2ul|5.007001||p
1505 PTRV|5.006000||p
1506 PUSHMARK|||
1507 PUSHi|||
1508 PUSHmortal|5.009002||p
1509 PUSHn|||
1510 PUSHp|||
1511 PUSHs|||
1512 PUSHu|5.004000||p
1513 PUTBACK|||
1514 PerlIO_clearerr||5.007003|
1515 PerlIO_close||5.007003|
1516 PerlIO_eof||5.007003|
1517 PerlIO_error||5.007003|
1518 PerlIO_fileno||5.007003|
1519 PerlIO_fill||5.007003|
1520 PerlIO_flush||5.007003|
1521 PerlIO_get_base||5.007003|
1522 PerlIO_get_bufsiz||5.007003|
1523 PerlIO_get_cnt||5.007003|
1524 PerlIO_get_ptr||5.007003|
1525 PerlIO_read||5.007003|
1526 PerlIO_seek||5.007003|
1527 PerlIO_set_cnt||5.007003|
1528 PerlIO_set_ptrcnt||5.007003|
1529 PerlIO_setlinebuf||5.007003|
1530 PerlIO_stderr||5.007003|
1531 PerlIO_stdin||5.007003|
1532 PerlIO_stdout||5.007003|
1533 PerlIO_tell||5.007003|
1534 PerlIO_unread||5.007003|
1535 PerlIO_write||5.007003|
1536 Poison|5.008000||p
1537 RETVAL|||n
1538 Renewc|||
1539 Renew|||
1540 SAVECLEARSV|||
1541 SAVECOMPPAD|||
1542 SAVEPADSV|||
1543 SAVETMPS|||
1544 SAVE_DEFSV|5.004050||p
1545 SPAGAIN|||
1546 SP|||
1547 START_EXTERN_C|5.005000||p
1548 START_MY_CXT|5.007003||p
1549 STMT_END|||p
1550 STMT_START|||p
1551 ST|||
1552 SVt_IV|||
1553 SVt_NV|||
1554 SVt_PVAV|||
1555 SVt_PVCV|||
1556 SVt_PVHV|||
1557 SVt_PVMG|||
1558 SVt_PV|||
1559 Safefree|||
1560 Slab_Alloc|||
1561 Slab_Free|||
1562 StructCopy|||
1563 SvCUR_set|||
1564 SvCUR|||
1565 SvEND|||
1566 SvGETMAGIC|5.004050||p
1567 SvGROW|||
1568 SvIOK_UV||5.006000|
1569 SvIOK_notUV||5.006000|
1570 SvIOK_off|||
1571 SvIOK_only_UV||5.006000|
1572 SvIOK_only|||
1573 SvIOK_on|||
1574 SvIOKp|||
1575 SvIOK|||
1576 SvIVX|||
1577 SvIV_nomg|5.009001||p
1578 SvIVx|||
1579 SvIV|||
1580 SvIsCOW_shared_hash||5.008003|
1581 SvIsCOW||5.008003|
1582 SvLEN|||
1583 SvLOCK||5.007003|
1584 SvNIOK_off|||
1585 SvNIOKp|||
1586 SvNIOK|||
1587 SvNOK_off|||
1588 SvNOK_only|||
1589 SvNOK_on|||
1590 SvNOKp|||
1591 SvNOK|||
1592 SvNVX|||
1593 SvNVx|||
1594 SvNV|||
1595 SvOK|||
1596 SvOOK|||
1597 SvPOK_off|||
1598 SvPOK_only_UTF8||5.006000|
1599 SvPOK_only|||
1600 SvPOK_on|||
1601 SvPOKp|||
1602 SvPOK|||
1603 SvPVX|||
1604 SvPV_force_nomg|5.007002||p
1605 SvPV_force|||
1606 SvPV_nolen|5.006000||p
1607 SvPV_nomg|5.007002||p
1608 SvPVbyte_force||5.009002|
1609 SvPVbyte_nolen||5.006000|
1610 SvPVbytex_force||5.006000|
1611 SvPVbytex||5.006000|
1612 SvPVbyte|5.006000||p
1613 SvPVutf8_force||5.006000|
1614 SvPVutf8_nolen||5.006000|
1615 SvPVutf8x_force||5.006000|
1616 SvPVutf8x||5.006000|
1617 SvPVutf8||5.006000|
1618 SvPVx|||
1619 SvPV|||
1620 SvREFCNT_dec|||
1621 SvREFCNT_inc|||
1622 SvREFCNT|||
1623 SvROK_off|||
1624 SvROK_on|||
1625 SvROK|||
1626 SvRV|||
1627 SvSETMAGIC|||
1628 SvSHARE||5.007003|
1629 SvSTASH|||
1630 SvSetMagicSV_nosteal||5.004000|
1631 SvSetMagicSV||5.004000|
1632 SvSetSV_nosteal||5.004000|
1633 SvSetSV|||
1634 SvTAINTED_off||5.004000|
1635 SvTAINTED_on||5.004000|
1636 SvTAINTED||5.004000|
1637 SvTAINT|||
1638 SvTRUE|||
1639 SvTYPE|||
1640 SvUNLOCK||5.007003|
1641 SvUOK||5.007001|
1642 SvUPGRADE|||
1643 SvUTF8_off||5.006000|
1644 SvUTF8_on||5.006000|
1645 SvUTF8||5.006000|
1646 SvUVXx|5.004000||p
1647 SvUVX|5.004000||p
1648 SvUV_nomg|5.009001||p
1649 SvUVx|5.004000||p
1650 SvUV|5.004000||p
1651 SvVOK||5.008001|
1652 THIS|||n
1653 UNDERBAR|5.009002||p
1654 UVSIZE|5.006000||p
1655 UVTYPE|5.006000||p
1656 UVXf|5.007001||p
1657 UVof|5.006000||p
1658 UVuf|5.006000||p
1659 UVxf|5.006000||p
1660 XPUSHi|||
1661 XPUSHmortal|5.009002||p
1662 XPUSHn|||
1663 XPUSHp|||
1664 XPUSHs|||
1665 XPUSHu|5.004000||p
1666 XSRETURN_EMPTY|||
1667 XSRETURN_IV|||
1668 XSRETURN_NO|||
1669 XSRETURN_NV|||
1670 XSRETURN_PV|||
1671 XSRETURN_UNDEF|||
1672 XSRETURN_UV|5.008001||p
1673 XSRETURN_YES|||
1674 XSRETURN|||
1675 XST_mIV|||
1676 XST_mNO|||
1677 XST_mNV|||
1678 XST_mPV|||
1679 XST_mUNDEF|||
1680 XST_mUV|5.008001||p
1681 XST_mYES|||
1682 XS_VERSION_BOOTCHECK|||
1683 XS_VERSION|||
1684 XS|||
1685 ZeroD|5.009002||p
1686 Zero|||
1687 _aMY_CXT|5.007003||p
1688 _pMY_CXT|5.007003||p
1689 aMY_CXT_|5.007003||p
1690 aMY_CXT|5.007003||p
1691 aTHX_|5.006000||p
1692 aTHX|5.006000||p
1693 add_data|||
1694 allocmy|||
1695 amagic_call|||
1696 any_dup|||
1697 ao|||
1698 append_elem|||
1699 append_list|||
1700 apply_attrs_my|||
1701 apply_attrs_string||5.006001|
1702 apply_attrs|||
1703 apply|||
1704 asIV|||
1705 asUV|||
1706 atfork_lock||5.007003|n
1707 atfork_unlock||5.007003|n
1708 av_clear|||
1709 av_delete||5.006000|
1710 av_exists||5.006000|
1711 av_extend|||
1712 av_fake|||
1713 av_fetch|||
1714 av_fill|||
1715 av_len|||
1716 av_make|||
1717 av_pop|||
1718 av_push|||
1719 av_reify|||
1720 av_shift|||
1721 av_store|||
1722 av_undef|||
1723 av_unshift|||
1724 ax|||n
1725 bad_type|||
1726 bind_match|||
1727 block_end|||
1728 block_gimme||5.004000|
1729 block_start|||
1730 boolSV|5.004000||p
1731 boot_core_PerlIO|||
1732 boot_core_UNIVERSAL|||
1733 boot_core_xsutils|||
1734 bytes_from_utf8||5.007001|
1735 bytes_to_utf8||5.006001|
1736 cache_re|||
1737 call_argv|5.006000||p
1738 call_atexit||5.006000|
1739 call_body|||
1740 call_list_body|||
1741 call_list||5.004000|
1742 call_method|5.006000||p
1743 call_pv|5.006000||p
1744 call_sv|5.006000||p
1745 calloc||5.007002|n
1746 cando|||
1747 cast_i32||5.006000|
1748 cast_iv||5.006000|
1749 cast_ulong||5.006000|
1750 cast_uv||5.006000|
1751 check_uni|||
1752 checkcomma|||
1753 checkposixcc|||
1754 cl_and|||
1755 cl_anything|||
1756 cl_init_zero|||
1757 cl_init|||
1758 cl_is_anything|||
1759 cl_or|||
1760 closest_cop|||
1761 convert|||
1762 cop_free|||
1763 cr_textfilter|||
1764 croak_nocontext|||vn
1765 croak|||v
1766 csighandler||5.007001|n
1767 custom_op_desc||5.007003|
1768 custom_op_name||5.007003|
1769 cv_ckproto|||
1770 cv_clone|||
1771 cv_const_sv||5.004000|
1772 cv_dump|||
1773 cv_undef|||
1774 cx_dump||5.005000|
1775 cx_dup|||
1776 cxinc|||
1777 dAX|5.007002||p
1778 dITEMS|5.007002||p
1779 dMARK|||
1780 dMY_CXT_SV|5.007003||p
1781 dMY_CXT|5.007003||p
1782 dNOOP|5.006000||p
1783 dORIGMARK|||
1784 dSP|||
1785 dTHR|5.004050||p
1786 dTHXa|5.006000||p
1787 dTHXoa|5.006000||p
1788 dTHX|5.006000||p
1789 dUNDERBAR|5.009002||p
1790 dXSARGS|||
1791 dXSI32|||
1792 deb_curcv|||
1793 deb_nocontext|||vn
1794 deb_stack_all|||
1795 deb_stack_n|||
1796 debop||5.005000|
1797 debprofdump||5.005000|
1798 debprof|||
1799 debstackptrs||5.007003|
1800 debstack||5.007003|
1801 deb||5.007003|v
1802 default_protect|||v
1803 del_he|||
1804 del_sv|||
1805 del_xiv|||
1806 del_xnv|||
1807 del_xpvav|||
1808 del_xpvbm|||
1809 del_xpvcv|||
1810 del_xpvhv|||
1811 del_xpviv|||
1812 del_xpvlv|||
1813 del_xpvmg|||
1814 del_xpvnv|||
1815 del_xpv|||
1816 del_xrv|||
1817 delimcpy||5.004000|
1818 depcom|||
1819 deprecate_old|||
1820 deprecate|||
1821 despatch_signals||5.007001|
1822 die_nocontext|||vn
1823 die_where|||
1824 die|||v
1825 dirp_dup|||
1826 div128|||
1827 djSP|||
1828 do_aexec5|||
1829 do_aexec|||
1830 do_aspawn|||
1831 do_binmode||5.004050|
1832 do_chomp|||
1833 do_chop|||
1834 do_close|||
1835 do_dump_pad|||
1836 do_eof|||
1837 do_exec3|||
1838 do_execfree|||
1839 do_exec|||
1840 do_gv_dump||5.006000|
1841 do_gvgv_dump||5.006000|
1842 do_hv_dump||5.006000|
1843 do_ipcctl|||
1844 do_ipcget|||
1845 do_join|||
1846 do_kv|||
1847 do_magic_dump||5.006000|
1848 do_msgrcv|||
1849 do_msgsnd|||
1850 do_oddball|||
1851 do_op_dump||5.006000|
1852 do_open9||5.006000|
1853 do_openn||5.007001|
1854 do_open||5.004000|
1855 do_pipe|||
1856 do_pmop_dump||5.006000|
1857 do_print|||
1858 do_readline|||
1859 do_seek|||
1860 do_semop|||
1861 do_shmio|||
1862 do_spawn_nowait|||
1863 do_spawn|||
1864 do_sprintf|||
1865 do_sv_dump||5.006000|
1866 do_sysseek|||
1867 do_tell|||
1868 do_trans_complex_utf8|||
1869 do_trans_complex|||
1870 do_trans_count_utf8|||
1871 do_trans_count|||
1872 do_trans_simple_utf8|||
1873 do_trans_simple|||
1874 do_trans|||
1875 do_vecget|||
1876 do_vecset|||
1877 do_vop|||
1878 docatch_body|||
1879 docatch|||
1880 doencodes|||
1881 doeval|||
1882 dofile|||
1883 dofindlabel|||
1884 doform|||
1885 doing_taint||5.008001|n
1886 dooneliner|||
1887 doopen_pm|||
1888 doparseform|||
1889 dopoptoeval|||
1890 dopoptolabel|||
1891 dopoptoloop|||
1892 dopoptosub_at|||
1893 dopoptosub|||
1894 dounwind|||
1895 dowantarray|||
1896 dump_all||5.006000|
1897 dump_eval||5.006000|
1898 dump_fds|||
1899 dump_form||5.006000|
1900 dump_indent||5.006000|v
1901 dump_mstats|||
1902 dump_packsubs||5.006000|
1903 dump_sub||5.006000|
1904 dump_vindent||5.006000|
1905 dumpuntil|||
1906 dup_attrlist|||
1907 emulate_eaccess|||
1908 eval_pv|5.006000||p
1909 eval_sv|5.006000||p
1910 expect_number|||
1911 fbm_compile||5.005000|
1912 fbm_instr||5.005000|
1913 fd_on_nosuid_fs|||
1914 filter_add|||
1915 filter_del|||
1916 filter_gets|||
1917 filter_read|||
1918 find_beginning|||
1919 find_byclass|||
1920 find_in_my_stash|||
1921 find_runcv|||
1922 find_rundefsvoffset||5.009002|
1923 find_script|||
1924 find_uninit_var|||
1925 fold_constants|||
1926 forbid_setid|||
1927 force_ident|||
1928 force_list|||
1929 force_next|||
1930 force_version|||
1931 force_word|||
1932 form_nocontext|||vn
1933 form||5.004000|v
1934 fp_dup|||
1935 fprintf_nocontext|||vn
1936 free_tied_hv_pool|||
1937 free_tmps|||
1938 gen_constant_list|||
1939 get_av|5.006000||p
1940 get_context||5.006000|n
1941 get_cv|5.006000||p
1942 get_db_sub|||
1943 get_debug_opts|||
1944 get_hash_seed|||
1945 get_hv|5.006000||p
1946 get_mstats|||
1947 get_no_modify|||
1948 get_num|||
1949 get_op_descs||5.005000|
1950 get_op_names||5.005000|
1951 get_opargs|||
1952 get_ppaddr||5.006000|
1953 get_sv|5.006000||p
1954 get_vtbl||5.005030|
1955 getcwd_sv||5.007002|
1956 getenv_len|||
1957 gp_dup|||
1958 gp_free|||
1959 gp_ref|||
1960 grok_bin|5.007003||p
1961 grok_hex|5.007003||p
1962 grok_number|5.007002||p
1963 grok_numeric_radix|5.007002||p
1964 grok_oct|5.007003||p
1965 group_end|||
1966 gv_AVadd|||
1967 gv_HVadd|||
1968 gv_IOadd|||
1969 gv_autoload4||5.004000|
1970 gv_check|||
1971 gv_dump||5.006000|
1972 gv_efullname3||5.004000|
1973 gv_efullname4||5.006001|
1974 gv_efullname|||
1975 gv_ename|||
1976 gv_fetchfile|||
1977 gv_fetchmeth_autoload||5.007003|
1978 gv_fetchmethod_autoload||5.004000|
1979 gv_fetchmethod|||
1980 gv_fetchmeth|||
1981 gv_fetchpv|||
1982 gv_fullname3||5.004000|
1983 gv_fullname4||5.006001|
1984 gv_fullname|||
1985 gv_handler||5.007001|
1986 gv_init_sv|||
1987 gv_init|||
1988 gv_share|||
1989 gv_stashpvn|5.006000||p
1990 gv_stashpv|||
1991 gv_stashsv|||
1992 he_dup|||
1993 hfreeentries|||
1994 hsplit|||
1995 hv_assert||5.009001|
1996 hv_clear_placeholders||5.009001|
1997 hv_clear|||
1998 hv_delayfree_ent||5.004000|
1999 hv_delete_common|||
2000 hv_delete_ent||5.004000|
2001 hv_delete|||
2002 hv_exists_ent||5.004000|
2003 hv_exists|||
2004 hv_fetch_common|||
2005 hv_fetch_ent||5.004000|
2006 hv_fetch|||
2007 hv_free_ent||5.004000|
2008 hv_iterinit|||
2009 hv_iterkeysv||5.004000|
2010 hv_iterkey|||
2011 hv_iternext_flags||5.008000|
2012 hv_iternextsv|||
2013 hv_iternext|||
2014 hv_iterval|||
2015 hv_ksplit||5.004000|
2016 hv_magic_check|||
2017 hv_magic|||
2018 hv_notallowed|||
2019 hv_scalar||5.009001|
2020 hv_store_ent||5.004000|
2021 hv_store_flags||5.008000|
2022 hv_store|||
2023 hv_undef|||
2024 ibcmp_locale||5.004000|
2025 ibcmp_utf8||5.007003|
2026 ibcmp|||
2027 incl_perldb|||
2028 incline|||
2029 incpush|||
2030 ingroup|||
2031 init_argv_symbols|||
2032 init_debugger|||
2033 init_i18nl10n||5.006000|
2034 init_i18nl14n||5.006000|
2035 init_ids|||
2036 init_interp|||
2037 init_lexer|||
2038 init_main_stash|||
2039 init_perllib|||
2040 init_postdump_symbols|||
2041 init_predump_symbols|||
2042 init_stacks||5.005000|
2043 init_tm||5.007002|
2044 instr|||
2045 intro_my|||
2046 intuit_method|||
2047 intuit_more|||
2048 invert|||
2049 io_close|||
2050 isALNUM|||
2051 isALPHA|||
2052 isDIGIT|||
2053 isLOWER|||
2054 isSPACE|||
2055 isUPPER|||
2056 is_an_int|||
2057 is_gv_magical|||
2058 is_handle_constructor|||
2059 is_lvalue_sub||5.007001|
2060 is_uni_alnum_lc||5.006000|
2061 is_uni_alnumc_lc||5.006000|
2062 is_uni_alnumc||5.006000|
2063 is_uni_alnum||5.006000|
2064 is_uni_alpha_lc||5.006000|
2065 is_uni_alpha||5.006000|
2066 is_uni_ascii_lc||5.006000|
2067 is_uni_ascii||5.006000|
2068 is_uni_cntrl_lc||5.006000|
2069 is_uni_cntrl||5.006000|
2070 is_uni_digit_lc||5.006000|
2071 is_uni_digit||5.006000|
2072 is_uni_graph_lc||5.006000|
2073 is_uni_graph||5.006000|
2074 is_uni_idfirst_lc||5.006000|
2075 is_uni_idfirst||5.006000|
2076 is_uni_lower_lc||5.006000|
2077 is_uni_lower||5.006000|
2078 is_uni_print_lc||5.006000|
2079 is_uni_print||5.006000|
2080 is_uni_punct_lc||5.006000|
2081 is_uni_punct||5.006000|
2082 is_uni_space_lc||5.006000|
2083 is_uni_space||5.006000|
2084 is_uni_upper_lc||5.006000|
2085 is_uni_upper||5.006000|
2086 is_uni_xdigit_lc||5.006000|
2087 is_uni_xdigit||5.006000|
2088 is_utf8_alnumc||5.006000|
2089 is_utf8_alnum||5.006000|
2090 is_utf8_alpha||5.006000|
2091 is_utf8_ascii||5.006000|
2092 is_utf8_char||5.006000|
2093 is_utf8_cntrl||5.006000|
2094 is_utf8_digit||5.006000|
2095 is_utf8_graph||5.006000|
2096 is_utf8_idcont||5.008000|
2097 is_utf8_idfirst||5.006000|
2098 is_utf8_lower||5.006000|
2099 is_utf8_mark||5.006000|
2100 is_utf8_print||5.006000|
2101 is_utf8_punct||5.006000|
2102 is_utf8_space||5.006000|
2103 is_utf8_string_loc||5.008001|
2104 is_utf8_string||5.006001|
2105 is_utf8_upper||5.006000|
2106 is_utf8_xdigit||5.006000|
2107 isa_lookup|||
2108 items|||n
2109 ix|||n
2110 jmaybe|||
2111 keyword|||
2112 leave_scope|||
2113 lex_end|||
2114 lex_start|||
2115 linklist|||
2116 list_assignment|||
2117 listkids|||
2118 list|||
2119 load_module_nocontext|||vn
2120 load_module||5.006000|v
2121 localize|||
2122 looks_like_number|||
2123 lop|||
2124 mPUSHi|5.009002||p
2125 mPUSHn|5.009002||p
2126 mPUSHp|5.009002||p
2127 mPUSHu|5.009002||p
2128 mXPUSHi|5.009002||p
2129 mXPUSHn|5.009002||p
2130 mXPUSHp|5.009002||p
2131 mXPUSHu|5.009002||p
2132 magic_clear_all_env|||
2133 magic_clearenv|||
2134 magic_clearpack|||
2135 magic_clearsig|||
2136 magic_dump||5.006000|
2137 magic_existspack|||
2138 magic_freeovrld|||
2139 magic_freeregexp|||
2140 magic_getarylen|||
2141 magic_getdefelem|||
2142 magic_getglob|||
2143 magic_getnkeys|||
2144 magic_getpack|||
2145 magic_getpos|||
2146 magic_getsig|||
2147 magic_getsubstr|||
2148 magic_gettaint|||
2149 magic_getuvar|||
2150 magic_getvec|||
2151 magic_get|||
2152 magic_killbackrefs|||
2153 magic_len|||
2154 magic_methcall|||
2155 magic_methpack|||
2156 magic_nextpack|||
2157 magic_regdata_cnt|||
2158 magic_regdatum_get|||
2159 magic_regdatum_set|||
2160 magic_scalarpack|||
2161 magic_set_all_env|||
2162 magic_setamagic|||
2163 magic_setarylen|||
2164 magic_setbm|||
2165 magic_setcollxfrm|||
2166 magic_setdbline|||
2167 magic_setdefelem|||
2168 magic_setenv|||
2169 magic_setfm|||
2170 magic_setglob|||
2171 magic_setisa|||
2172 magic_setmglob|||
2173 magic_setnkeys|||
2174 magic_setpack|||
2175 magic_setpos|||
2176 magic_setregexp|||
2177 magic_setsig|||
2178 magic_setsubstr|||
2179 magic_settaint|||
2180 magic_setutf8|||
2181 magic_setuvar|||
2182 magic_setvec|||
2183 magic_set|||
2184 magic_sizepack|||
2185 magic_wipepack|||
2186 magicname|||
2187 malloced_size|||n
2188 malloc||5.007002|n
2189 markstack_grow|||
2190 measure_struct|||
2191 memEQ|5.004000||p
2192 memNE|5.004000||p
2193 mem_collxfrm|||
2194 mess_alloc|||
2195 mess_nocontext|||vn
2196 mess||5.006000|v
2197 method_common|||
2198 mfree||5.007002|n
2199 mg_clear|||
2200 mg_copy|||
2201 mg_dup|||
2202 mg_find|||
2203 mg_free|||
2204 mg_get|||
2205 mg_length||5.005000|
2206 mg_magical|||
2207 mg_set|||
2208 mg_size||5.005000|
2209 mini_mktime||5.007002|
2210 missingterm|||
2211 mode_from_discipline|||
2212 modkids|||
2213 mod|||
2214 more_he|||
2215 more_sv|||
2216 more_xiv|||
2217 more_xnv|||
2218 more_xpvav|||
2219 more_xpvbm|||
2220 more_xpvcv|||
2221 more_xpvhv|||
2222 more_xpviv|||
2223 more_xpvlv|||
2224 more_xpvmg|||
2225 more_xpvnv|||
2226 more_xpv|||
2227 more_xrv|||
2228 moreswitches|||
2229 mul128|||
2230 mulexp10|||n
2231 my_atof2||5.007002|
2232 my_atof||5.006000|
2233 my_attrs|||
2234 my_bcopy|||n
2235 my_betoh16|||n
2236 my_betoh32|||n
2237 my_betoh64|||n
2238 my_betohi|||n
2239 my_betohl|||n
2240 my_betohs|||n
2241 my_bzero|||n
2242 my_chsize|||
2243 my_exit_jump|||
2244 my_exit|||
2245 my_failure_exit||5.004000|
2246 my_fflush_all||5.006000|
2247 my_fork||5.007003|n
2248 my_htobe16|||n
2249 my_htobe32|||n
2250 my_htobe64|||n
2251 my_htobei|||n
2252 my_htobel|||n
2253 my_htobes|||n
2254 my_htole16|||n
2255 my_htole32|||n
2256 my_htole64|||n
2257 my_htolei|||n
2258 my_htolel|||n
2259 my_htoles|||n
2260 my_htonl|||
2261 my_kid|||
2262 my_letoh16|||n
2263 my_letoh32|||n
2264 my_letoh64|||n
2265 my_letohi|||n
2266 my_letohl|||n
2267 my_letohs|||n
2268 my_lstat|||
2269 my_memcmp||5.004000|n
2270 my_memset|||n
2271 my_ntohl|||
2272 my_pclose||5.004000|
2273 my_popen_list||5.007001|
2274 my_popen||5.004000|
2275 my_setenv|||
2276 my_socketpair||5.007003|n
2277 my_stat|||
2278 my_strftime||5.007002|
2279 my_swabn|||n
2280 my_swap|||
2281 my_unexec|||
2282 my|||
2283 newANONATTRSUB||5.006000|
2284 newANONHASH|||
2285 newANONLIST|||
2286 newANONSUB|||
2287 newASSIGNOP|||
2288 newATTRSUB||5.006000|
2289 newAVREF|||
2290 newAV|||
2291 newBINOP|||
2292 newCONDOP|||
2293 newCONSTSUB|5.006000||p
2294 newCVREF|||
2295 newDEFSVOP|||
2296 newFORM|||
2297 newFOROP|||
2298 newGVOP|||
2299 newGVREF|||
2300 newGVgen|||
2301 newHVREF|||
2302 newHVhv||5.005000|
2303 newHV|||
2304 newIO|||
2305 newLISTOP|||
2306 newLOGOP|||
2307 newLOOPEX|||
2308 newLOOPOP|||
2309 newMYSUB||5.006000|
2310 newNULLLIST|||
2311 newOP|||
2312 newPADOP||5.006000|
2313 newPMOP|||
2314 newPROG|||
2315 newPVOP|||
2316 newRANGE|||
2317 newRV_inc|5.004000||p
2318 newRV_noinc|5.006000||p
2319 newRV|||
2320 newSLICEOP|||
2321 newSTATEOP|||
2322 newSUB|||
2323 newSVOP|||
2324 newSVREF|||
2325 newSViv|||
2326 newSVnv|||
2327 newSVpvf_nocontext|||vn
2328 newSVpvf||5.004000|v
2329 newSVpvn_share||5.007001|
2330 newSVpvn|5.006000||p
2331 newSVpv|||
2332 newSVrv|||
2333 newSVsv|||
2334 newSVuv|5.006000||p
2335 newSV|||
2336 newUNOP|||
2337 newWHILEOP||5.004040|
2338 newXSproto||5.006000|
2339 newXS||5.006000|
2340 new_collate||5.006000|
2341 new_constant|||
2342 new_ctype||5.006000|
2343 new_he|||
2344 new_logop|||
2345 new_numeric||5.006000|
2346 new_stackinfo||5.005000|
2347 new_version||5.009000|
2348 new_xiv|||
2349 new_xnv|||
2350 new_xpvav|||
2351 new_xpvbm|||
2352 new_xpvcv|||
2353 new_xpvhv|||
2354 new_xpviv|||
2355 new_xpvlv|||
2356 new_xpvmg|||
2357 new_xpvnv|||
2358 new_xpv|||
2359 new_xrv|||
2360 next_symbol|||
2361 nextargv|||
2362 nextchar|||
2363 ninstr|||
2364 no_bareword_allowed|||
2365 no_fh_allowed|||
2366 no_op|||
2367 not_a_number|||
2368 nothreadhook||5.008000|
2369 nuke_stacks|||
2370 num_overflow|||n
2371 oopsAV|||
2372 oopsCV|||
2373 oopsHV|||
2374 op_clear|||
2375 op_const_sv|||
2376 op_dump||5.006000|
2377 op_free|||
2378 op_null||5.007002|
2379 open_script|||
2380 pMY_CXT_|5.007003||p
2381 pMY_CXT|5.007003||p
2382 pTHX_|5.006000||p
2383 pTHX|5.006000||p
2384 pack_cat||5.007003|
2385 pack_rec|||
2386 package|||
2387 packlist||5.008001|
2388 pad_add_anon|||
2389 pad_add_name|||
2390 pad_alloc|||
2391 pad_block_start|||
2392 pad_check_dup|||
2393 pad_findlex|||
2394 pad_findmy|||
2395 pad_fixup_inner_anons|||
2396 pad_free|||
2397 pad_leavemy|||
2398 pad_new|||
2399 pad_push|||
2400 pad_reset|||
2401 pad_setsv|||
2402 pad_sv|||
2403 pad_swipe|||
2404 pad_tidy|||
2405 pad_undef|||
2406 parse_body|||
2407 parse_unicode_opts|||
2408 path_is_absolute|||
2409 peep|||
2410 pending_ident|||
2411 perl_alloc_using|||n
2412 perl_alloc|||n
2413 perl_clone_using|||n
2414 perl_clone|||n
2415 perl_construct|||n
2416 perl_destruct||5.007003|n
2417 perl_free|||n
2418 perl_parse||5.006000|n
2419 perl_run|||n
2420 pidgone|||
2421 pmflag|||
2422 pmop_dump||5.006000|
2423 pmruntime|||
2424 pmtrans|||
2425 pop_scope|||
2426 pregcomp|||
2427 pregexec|||
2428 pregfree|||
2429 prepend_elem|||
2430 printf_nocontext|||vn
2431 ptr_table_clear|||
2432 ptr_table_fetch|||
2433 ptr_table_free|||
2434 ptr_table_new|||
2435 ptr_table_split|||
2436 ptr_table_store|||
2437 push_scope|||
2438 put_byte|||
2439 pv_display||5.006000|
2440 pv_uni_display||5.007003|
2441 qerror|||
2442 re_croak2|||
2443 re_dup|||
2444 re_intuit_start||5.006000|
2445 re_intuit_string||5.006000|
2446 realloc||5.007002|n
2447 reentrant_free|||
2448 reentrant_init|||
2449 reentrant_retry|||vn
2450 reentrant_size|||
2451 refkids|||
2452 refto|||
2453 ref|||
2454 reg_node|||
2455 reganode|||
2456 regatom|||
2457 regbranch|||
2458 regclass_swash||5.007003|
2459 regclass|||
2460 regcp_set_to|||
2461 regcppop|||
2462 regcppush|||
2463 regcurly|||
2464 regdump||5.005000|
2465 regexec_flags||5.005000|
2466 reghop3|||
2467 reghopmaybe3|||
2468 reghopmaybe|||
2469 reghop|||
2470 reginclass|||
2471 reginitcolors||5.006000|
2472 reginsert|||
2473 regmatch|||
2474 regnext||5.005000|
2475 regoptail|||
2476 regpiece|||
2477 regpposixcc|||
2478 regprop|||
2479 regrepeat_hard|||
2480 regrepeat|||
2481 regtail|||
2482 regtry|||
2483 reguni|||
2484 regwhite|||
2485 reg|||
2486 repeatcpy|||
2487 report_evil_fh|||
2488 report_uninit|||
2489 require_errno|||
2490 require_pv||5.006000|
2491 rninstr|||
2492 rsignal_restore|||
2493 rsignal_save|||
2494 rsignal_state||5.004000|
2495 rsignal||5.004000|
2496 run_body|||
2497 runops_debug||5.005000|
2498 runops_standard||5.005000|
2499 rxres_free|||
2500 rxres_restore|||
2501 rxres_save|||
2502 safesyscalloc||5.006000|n
2503 safesysfree||5.006000|n
2504 safesysmalloc||5.006000|n
2505 safesysrealloc||5.006000|n
2506 same_dirent|||
2507 save_I16||5.004000|
2508 save_I32|||
2509 save_I8||5.006000|
2510 save_aelem||5.004050|
2511 save_alloc||5.006000|
2512 save_aptr|||
2513 save_ary|||
2514 save_bool||5.008001|
2515 save_clearsv|||
2516 save_delete|||
2517 save_destructor_x||5.006000|
2518 save_destructor||5.006000|
2519 save_freeop|||
2520 save_freepv|||
2521 save_freesv|||
2522 save_generic_pvref||5.006001|
2523 save_generic_svref||5.005030|
2524 save_gp||5.004000|
2525 save_hash|||
2526 save_hek_flags|||
2527 save_helem||5.004050|
2528 save_hints||5.005000|
2529 save_hptr|||
2530 save_int|||
2531 save_item|||
2532 save_iv||5.005000|
2533 save_lines|||
2534 save_list|||
2535 save_long|||
2536 save_magic|||
2537 save_mortalizesv||5.007001|
2538 save_nogv|||
2539 save_op|||
2540 save_padsv||5.007001|
2541 save_pptr|||
2542 save_re_context||5.006000|
2543 save_scalar_at|||
2544 save_scalar|||
2545 save_set_svflags||5.009000|
2546 save_shared_pvref||5.007003|
2547 save_sptr|||
2548 save_svref|||
2549 save_threadsv||5.005000|
2550 save_vptr||5.006000|
2551 savepvn|||
2552 savepv|||
2553 savesharedpv||5.007003|
2554 savestack_grow_cnt||5.008001|
2555 savestack_grow|||
2556 sawparens|||
2557 scalar_mod_type|||
2558 scalarboolean|||
2559 scalarkids|||
2560 scalarseq|||
2561 scalarvoid|||
2562 scalar|||
2563 scan_bin||5.006000|
2564 scan_commit|||
2565 scan_const|||
2566 scan_formline|||
2567 scan_heredoc|||
2568 scan_hex|||
2569 scan_ident|||
2570 scan_inputsymbol|||
2571 scan_num||5.007001|
2572 scan_oct|||
2573 scan_pat|||
2574 scan_str|||
2575 scan_subst|||
2576 scan_trans|||
2577 scan_version||5.009001|
2578 scan_vstring||5.008001|
2579 scan_word|||
2580 scope|||
2581 screaminstr||5.005000|
2582 seed|||
2583 set_context||5.006000|n
2584 set_csh|||
2585 set_numeric_local||5.006000|
2586 set_numeric_radix||5.006000|
2587 set_numeric_standard||5.006000|
2588 setdefout|||
2589 setenv_getix|||
2590 share_hek_flags|||
2591 share_hek|||
2592 si_dup|||
2593 sighandler|||n
2594 simplify_sort|||
2595 skipspace|||
2596 sortsv||5.007003|
2597 ss_dup|||
2598 stack_grow|||
2599 start_glob|||
2600 start_subparse||5.004000|
2601 stdize_locale|||
2602 strEQ|||
2603 strGE|||
2604 strGT|||
2605 strLE|||
2606 strLT|||
2607 strNE|||
2608 str_to_version||5.006000|
2609 strnEQ|||
2610 strnNE|||
2611 study_chunk|||
2612 sub_crush_depth|||
2613 sublex_done|||
2614 sublex_push|||
2615 sublex_start|||
2616 sv_2bool|||
2617 sv_2cv|||
2618 sv_2io|||
2619 sv_2iuv_non_preserve|||
2620 sv_2iv_flags||5.009001|
2621 sv_2iv|||
2622 sv_2mortal|||
2623 sv_2nv|||
2624 sv_2pv_flags||5.007002|
2625 sv_2pv_nolen|5.006000||p
2626 sv_2pvbyte_nolen|||
2627 sv_2pvbyte|5.006000||p
2628 sv_2pvutf8_nolen||5.006000|
2629 sv_2pvutf8||5.006000|
2630 sv_2pv|||
2631 sv_2uv_flags||5.009001|
2632 sv_2uv|5.004000||p
2633 sv_add_arena|||
2634 sv_add_backref|||
2635 sv_backoff|||
2636 sv_bless|||
2637 sv_cat_decode||5.008001|
2638 sv_catpv_mg|5.006000||p
2639 sv_catpvf_mg_nocontext|||pvn
2640 sv_catpvf_mg|5.006000|5.004000|pv
2641 sv_catpvf_nocontext|||vn
2642 sv_catpvf||5.004000|v
2643 sv_catpvn_flags||5.007002|
2644 sv_catpvn_mg|5.006000||p
2645 sv_catpvn_nomg|5.007002||p
2646 sv_catpvn|||
2647 sv_catpv|||
2648 sv_catsv_flags||5.007002|
2649 sv_catsv_mg|5.006000||p
2650 sv_catsv_nomg|5.007002||p
2651 sv_catsv|||
2652 sv_chop|||
2653 sv_clean_all|||
2654 sv_clean_objs|||
2655 sv_clear|||
2656 sv_cmp_locale||5.004000|
2657 sv_cmp|||
2658 sv_collxfrm|||
2659 sv_compile_2op||5.008001|
2660 sv_copypv||5.007003|
2661 sv_dec|||
2662 sv_del_backref|||
2663 sv_derived_from||5.004000|
2664 sv_dump|||
2665 sv_dup|||
2666 sv_eq|||
2667 sv_force_normal_flags||5.007001|
2668 sv_force_normal||5.006000|
2669 sv_free2|||
2670 sv_free_arenas|||
2671 sv_free|||
2672 sv_gets||5.004000|
2673 sv_grow|||
2674 sv_inc|||
2675 sv_insert|||
2676 sv_isa|||
2677 sv_isobject|||
2678 sv_iv||5.005000|
2679 sv_len_utf8||5.006000|
2680 sv_len|||
2681 sv_magicext||5.007003|
2682 sv_magic|||
2683 sv_mortalcopy|||
2684 sv_newmortal|||
2685 sv_newref|||
2686 sv_nolocking||5.007003|
2687 sv_nosharing||5.007003|
2688 sv_nounlocking||5.007003|
2689 sv_nv||5.005000|
2690 sv_peek||5.005000|
2691 sv_pos_b2u||5.006000|
2692 sv_pos_u2b||5.006000|
2693 sv_pvbyten_force||5.006000|
2694 sv_pvbyten||5.006000|
2695 sv_pvbyte||5.006000|
2696 sv_pvn_force_flags||5.007002|
2697 sv_pvn_force|||p
2698 sv_pvn_nomg|5.007003||p
2699 sv_pvn|5.006000||p
2700 sv_pvutf8n_force||5.006000|
2701 sv_pvutf8n||5.006000|
2702 sv_pvutf8||5.006000|
2703 sv_pv||5.006000|
2704 sv_recode_to_utf8||5.007003|
2705 sv_reftype|||
2706 sv_release_COW|||
2707 sv_release_IVX|||
2708 sv_replace|||
2709 sv_report_used|||
2710 sv_reset|||
2711 sv_rvweaken||5.006000|
2712 sv_setiv_mg|5.006000||p
2713 sv_setiv|||
2714 sv_setnv_mg|5.006000||p
2715 sv_setnv|||
2716 sv_setpv_mg|5.006000||p
2717 sv_setpvf_mg_nocontext|||pvn
2718 sv_setpvf_mg|5.006000|5.004000|pv
2719 sv_setpvf_nocontext|||vn
2720 sv_setpvf||5.004000|v
2721 sv_setpviv_mg||5.008001|
2722 sv_setpviv||5.008001|
2723 sv_setpvn_mg|5.006000||p
2724 sv_setpvn|||
2725 sv_setpv|||
2726 sv_setref_iv|||
2727 sv_setref_nv|||
2728 sv_setref_pvn|||
2729 sv_setref_pv|||
2730 sv_setref_uv||5.007001|
2731 sv_setsv_cow|||
2732 sv_setsv_flags||5.007002|
2733 sv_setsv_mg|5.006000||p
2734 sv_setsv_nomg|5.007002||p
2735 sv_setsv|||
2736 sv_setuv_mg|5.006000||p
2737 sv_setuv|5.006000||p
2738 sv_tainted||5.004000|
2739 sv_taint||5.004000|
2740 sv_true||5.005000|
2741 sv_unglob|||
2742 sv_uni_display||5.007003|
2743 sv_unmagic|||
2744 sv_unref_flags||5.007001|
2745 sv_unref|||
2746 sv_untaint||5.004000|
2747 sv_upgrade|||
2748 sv_usepvn_mg|5.006000||p
2749 sv_usepvn|||
2750 sv_utf8_decode||5.006000|
2751 sv_utf8_downgrade||5.006000|
2752 sv_utf8_encode||5.006000|
2753 sv_utf8_upgrade_flags||5.007002|
2754 sv_utf8_upgrade||5.007001|
2755 sv_uv|5.006000||p
2756 sv_vcatpvf_mg|5.006000|5.004000|p
2757 sv_vcatpvfn||5.004000|
2758 sv_vcatpvf|5.006000|5.004000|p
2759 sv_vsetpvf_mg|5.006000|5.004000|p
2760 sv_vsetpvfn||5.004000|
2761 sv_vsetpvf|5.006000|5.004000|p
2762 svtype|||
2763 swallow_bom|||
2764 swash_fetch||5.007002|
2765 swash_init||5.006000|
2766 sys_intern_clear|||
2767 sys_intern_dup|||
2768 sys_intern_init|||
2769 taint_env|||
2770 taint_proper|||
2771 tmps_grow||5.006000|
2772 toLOWER|||
2773 toUPPER|||
2774 to_byte_substr|||
2775 to_uni_fold||5.007003|
2776 to_uni_lower_lc||5.006000|
2777 to_uni_lower||5.007003|
2778 to_uni_title_lc||5.006000|
2779 to_uni_title||5.007003|
2780 to_uni_upper_lc||5.006000|
2781 to_uni_upper||5.007003|
2782 to_utf8_case||5.007003|
2783 to_utf8_fold||5.007003|
2784 to_utf8_lower||5.007003|
2785 to_utf8_substr|||
2786 to_utf8_title||5.007003|
2787 to_utf8_upper||5.007003|
2788 tokeq|||
2789 tokereport|||
2790 too_few_arguments|||
2791 too_many_arguments|||
2792 unlnk|||
2793 unpack_rec|||
2794 unpack_str||5.007003|
2795 unpackstring||5.008001|
2796 unshare_hek_or_pvn|||
2797 unshare_hek|||
2798 unsharepvn||5.004000|
2799 upg_version||5.009000|
2800 usage|||
2801 utf16_textfilter|||
2802 utf16_to_utf8_reversed||5.006001|
2803 utf16_to_utf8||5.006001|
2804 utf16rev_textfilter|||
2805 utf8_distance||5.006000|
2806 utf8_hop||5.006000|
2807 utf8_length||5.007001|
2808 utf8_mg_pos_init|||
2809 utf8_mg_pos|||
2810 utf8_to_bytes||5.006001|
2811 utf8_to_uvchr||5.007001|
2812 utf8_to_uvuni||5.007001|
2813 utf8n_to_uvchr||5.007001|
2814 utf8n_to_uvuni||5.007001|
2815 utilize|||
2816 uvchr_to_utf8_flags||5.007003|
2817 uvchr_to_utf8||5.007001|
2818 uvuni_to_utf8_flags||5.007003|
2819 uvuni_to_utf8||5.007001|
2820 validate_suid|||
2821 vcall_body|||
2822 vcall_list_body|||
2823 vcmp||5.009000|
2824 vcroak||5.006000|
2825 vdeb||5.007003|
2826 vdefault_protect|||
2827 vdie|||
2828 vdocatch_body|||
2829 vform||5.006000|
2830 visit|||
2831 vivify_defelem|||
2832 vivify_ref|||
2833 vload_module||5.006000|
2834 vmess||5.006000|
2835 vnewSVpvf|5.006000|5.004000|p
2836 vnormal||5.009002|
2837 vnumify||5.009000|
2838 vparse_body|||
2839 vrun_body|||
2840 vstringify||5.009000|
2841 vwarner||5.006000|
2842 vwarn||5.006000|
2843 wait4pid|||
2844 warn_nocontext|||vn
2845 warner_nocontext|||vn
2846 warner||5.006000|v
2847 warn|||v
2848 watch|||
2849 whichsig|||
2850 write_to_stderr|||
2851 yyerror|||
2852 yylex|||
2853 yyparse|||
2854 yywarn|||
2855 );
2856
2857 if (exists $opt{'list-unsupported'}) {
2858   my $f;
2859   for $f (sort { lc $a cmp lc $b } keys %API) {
2860     next unless $API{$f}{todo};
2861     print "$f ", '.'x(40-length($f)), " ", format_version($API{$f}{todo}), "\n";
2862   }
2863   exit 0;
2864 }
2865
2866 # Scan for possible replacement candidates
2867
2868 my(%replace, %need, %hints, %depends);
2869 my $replace = 0;
2870 my $hint = '';
2871
2872 while (<DATA>) {
2873   if ($hint) {
2874     if (m{^\s*\*\s(.*?)\s*$}) {
2875       $hints{$hint} ||= '';  # suppress warning with older perls
2876       $hints{$hint} .= "$1\n";
2877     }
2878     else {
2879       $hint = '';
2880     }
2881   }
2882   $hint = $1 if m{^\s*$rccs\sHint:\s+(\w+)\s*$};
2883
2884   $replace     = $1 if m{^\s*$rccs\s+Replace:\s+(\d+)\s+$rcce\s*$};
2885   $replace{$2} = $1 if $replace and m{^\s*#\s*define\s+(\w+)(?:\([^)]*\))?\s+(\w+)};
2886   $replace{$2} = $1 if m{^\s*#\s*define\s+(\w+)(?:\([^)]*\))?\s+(\w+).*$rccs\s+Replace\s+$rcce};
2887   $replace{$1} = $2 if m{^\s*$rccs\s+Replace (\w+) with (\w+)\s+$rcce\s*$};
2888
2889   if (m{^\s*$rccs\s+(\w+)\s+depends\s+on\s+(\w+(\s*,\s*\w+)*)\s+$rcce\s*$}) {
2890     push @{$depends{$1}}, map { s/\s+//g; $_ } split /,/, $2;
2891   }
2892
2893   $need{$1} = 1 if m{^#if\s+defined\(NEED_(\w+)(?:_GLOBAL)?\)};
2894 }
2895
2896 if (exists $opt{'list-provided'}) {
2897   my $f;
2898   for $f (sort { lc $a cmp lc $b } keys %API) {
2899     next unless $API{$f}{provided};
2900     my @flags;
2901     push @flags, 'explicit' if exists $need{$f};
2902     push @flags, 'depend'   if exists $depends{$f};
2903     push @flags, 'hint'     if exists $hints{$f};
2904     my $flags = @flags ? '  ['.join(', ', @flags).']' : '';
2905     print "$f$flags\n";
2906   }
2907   exit 0;
2908 }
2909
2910 my(%files, %global, %revreplace);
2911 %revreplace = reverse %replace;
2912 my $filename;
2913 my $patch_opened = 0;
2914
2915 for $filename (@files) {
2916   unless (open IN, "<$filename") {
2917     warn "Unable to read from $filename: $!\n";
2918     next;
2919   }
2920
2921   info("Scanning $filename ...");
2922
2923   my $c = do { local $/; <IN> };
2924   close IN;
2925
2926   my %file = (orig => $c, changes => 0);
2927
2928   # temporarily remove C comments from the code
2929   my @ccom;
2930   $c =~ s{
2931     (
2932         [^"'/]+
2933       |
2934         (?:"[^"\\]*(?:\\.[^"\\]*)*" [^"'/]*)+
2935       |
2936         (?:'[^'\\]*(?:\\.[^'\\]*)*' [^"'/]*)+
2937     )
2938   |
2939     (/ (?:
2940         \*[^*]*\*+(?:[^$ccs][^*]*\*+)* /
2941         |
2942         /[^\r\n]*
2943       ))
2944   }{
2945     defined $2 and push @ccom, $2;
2946     defined $1 ? $1 : "$ccs$#ccom$cce";
2947   }egsx;
2948
2949   $file{ccom} = \@ccom;
2950   $file{code} = $c;
2951   $file{has_inc_ppport} = ($c =~ /#.*include.*\Q$ppport\E/);
2952
2953   my $func;
2954
2955   for $func (keys %API) {
2956     my $match = $func;
2957     $match .= "|$revreplace{$func}" if exists $revreplace{$func};
2958     if ($c =~ /\b(?:Perl_)?($match)\b/) {
2959       $file{uses_replace}{$1}++ if exists $revreplace{$func} && $1 eq $revreplace{$func};
2960       $file{uses_Perl}{$func}++ if $c =~ /\bPerl_$func\b/;
2961       if (exists $API{$func}{provided}) {
2962         if (!exists $API{$func}{base} || $API{$func}{base} > $opt{'compat-version'}) {
2963           $file{uses}{$func}++;
2964           my @deps = rec_depend($func);
2965           if (@deps) {
2966             $file{uses_deps}{$func} = \@deps;
2967             for (@deps) {
2968               $file{uses}{$_} = 0 unless exists $file{uses}{$_};
2969             }
2970           }
2971           for ($func, @deps) {
2972             if (exists $need{$_}) {
2973               $file{needs}{$_} = 'static';
2974             }
2975           }
2976         }
2977       }
2978       if (exists $API{$func}{todo} && $API{$func}{todo} > $opt{'compat-version'}) {
2979         if ($c =~ /\b$func\b/) {
2980           $file{uses_todo}{$func}++;
2981         }
2982       }
2983     }
2984   }
2985
2986   while ($c =~ /^$HS*#$HS*define$HS+(NEED_(\w+?)(_GLOBAL)?)\b/mg) {
2987     if (exists $need{$2}) {
2988       $file{defined $3 ? 'needed_global' : 'needed_static'}{$2}++;
2989     }
2990     else {
2991       warning("Possibly wrong #define $1 in $filename");
2992     }
2993   }
2994
2995   for (qw(uses needs uses_todo needed_global needed_static)) {
2996     for $func (keys %{$file{$_}}) {
2997       push @{$global{$_}{$func}}, $filename;
2998     }
2999   }
3000
3001   $files{$filename} = \%file;
3002 }
3003
3004 # Globally resolve NEED_'s
3005 my $need;
3006 for $need (keys %{$global{needs}}) {
3007   if (@{$global{needs}{$need}} > 1) {
3008     my @targets = @{$global{needs}{$need}};
3009     my @t = grep $files{$_}{needed_global}{$need}, @targets;
3010     @targets = @t if @t;
3011     @t = grep /\.xs$/i, @targets;
3012     @targets = @t if @t;
3013     my $target = shift @targets;
3014     $files{$target}{needs}{$need} = 'global';
3015     for (@{$global{needs}{$need}}) {
3016       $files{$_}{needs}{$need} = 'extern' if $_ ne $target;
3017     }
3018   }
3019 }
3020
3021 for $filename (@files) {
3022   exists $files{$filename} or next;
3023
3024   info("=== Analyzing $filename ===");
3025
3026   my %file = %{$files{$filename}};
3027   my $func;
3028   my $c = $file{code};
3029
3030   for $func (sort keys %{$file{uses_Perl}}) {
3031     if ($API{$func}{varargs}) {
3032       my $changes = ($c =~ s{\b(Perl_$func\s*\(\s*)(?!aTHX_?)(\)|[^\s)]*\))}
3033                             { $1 . ($2 eq ')' ? 'aTHX' : 'aTHX_ ') . $2 }ge);
3034       if ($changes) {
3035         warning("Doesn't pass interpreter argument aTHX to Perl_$func");
3036         $file{changes} += $changes;
3037       }
3038     }
3039     else {
3040       warning("Uses Perl_$func instead of $func");
3041       $file{changes} += ($c =~ s{\bPerl_$func(\s*)\((\s*aTHX_?)?\s*}
3042                                 {$func$1(}g);
3043     }
3044   }
3045
3046   for $func (sort keys %{$file{uses_replace}}) {
3047     warning("Uses $func instead of $replace{$func}");
3048     $file{changes} += ($c =~ s/\b$func\b/$replace{$func}/g);
3049   }
3050
3051   for $func (sort keys %{$file{uses}}) {
3052     next unless $file{uses}{$func};   # if it's only a dependency
3053     if (exists $file{uses_deps}{$func}) {
3054       diag("Uses $func, which depends on ", join(', ', @{$file{uses_deps}{$func}}));
3055     }
3056     elsif (exists $replace{$func}) {
3057       warning("Uses $func instead of $replace{$func}");
3058       $file{changes} += ($c =~ s/\b$func\b/$replace{$func}/g);
3059     }
3060     else {
3061       diag("Uses $func");
3062     }
3063     hint($func);
3064   }
3065
3066   for $func (sort keys %{$file{uses_todo}}) {
3067     warning("Uses $func, which may not be portable below perl ",
3068             format_version($API{$func}{todo}));
3069   }
3070
3071   for $func (sort keys %{$file{needed_static}}) {
3072     my $message = '';
3073     if (not exists $file{uses}{$func}) {
3074       $message = "No need to define NEED_$func if $func is never used";
3075     }
3076     elsif (exists $file{needs}{$func} && $file{needs}{$func} ne 'static') {
3077       $message = "No need to define NEED_$func when already needed globally";
3078     }
3079     if ($message) {
3080       diag($message);
3081       $file{changes} += ($c =~ s/^$HS*#$HS*define$HS+NEED_$func\b.*$LF//mg);
3082     }
3083   }
3084
3085   for $func (sort keys %{$file{needed_global}}) {
3086     my $message = '';
3087     if (not exists $global{uses}{$func}) {
3088       $message = "No need to define NEED_${func}_GLOBAL if $func is never used";
3089     }
3090     elsif (exists $file{needs}{$func}) {
3091       if ($file{needs}{$func} eq 'extern') {
3092         $message = "No need to define NEED_${func}_GLOBAL when already needed globally";
3093       }
3094       elsif ($file{needs}{$func} eq 'static') {
3095         $message = "No need to define NEED_${func}_GLOBAL when only used in this file";
3096       }
3097     }
3098     if ($message) {
3099       diag($message);
3100       $file{changes} += ($c =~ s/^$HS*#$HS*define$HS+NEED_${func}_GLOBAL\b.*$LF//mg);
3101     }
3102   }
3103
3104   $file{needs_inc_ppport} = keys %{$file{uses}};
3105
3106   if ($file{needs_inc_ppport}) {
3107     my $pp = '';
3108
3109     for $func (sort keys %{$file{needs}}) {
3110       my $type = $file{needs}{$func};
3111       next if $type eq 'extern';
3112       my $suffix = $type eq 'global' ? '_GLOBAL' : '';
3113       unless (exists $file{"needed_$type"}{$func}) {
3114         if ($type eq 'global') {
3115           diag("Files [@{$global{needs}{$func}}] need $func, adding global request");
3116         }
3117         else {
3118           diag("File needs $func, adding static request");
3119         }
3120         $pp .= "#define NEED_$func$suffix\n";
3121       }
3122     }
3123
3124     if ($pp && ($c =~ s/^(?=$HS*#$HS*define$HS+NEED_\w+)/$pp/m)) {
3125       $pp = '';
3126       $file{changes}++;
3127     }
3128
3129     unless ($file{has_inc_ppport}) {
3130       diag("Needs to include '$ppport'");
3131       $pp .= qq(#include "$ppport"\n)
3132     }
3133
3134     if ($pp) {
3135       $file{changes} += ($c =~ s/^($HS*#$HS*define$HS+NEED_\w+.*?)^/$1$pp/ms)
3136                      || ($c =~ s/^(?=$HS*#$HS*include.*\Q$ppport\E)/$pp/m)
3137                      || ($c =~ s/^($HS*#$HS*include.*XSUB.*\s*?)^/$1$pp/m)
3138                      || ($c =~ s/^/$pp/);
3139     }
3140   }
3141   else {
3142     if ($file{has_inc_ppport}) {
3143       diag("No need to include '$ppport'");
3144       $file{changes} += ($c =~ s/^$HS*?#$HS*include.*\Q$ppport\E.*?$LF//m);
3145     }
3146   }
3147
3148   # put back in our C comments
3149   my $ix;
3150   my $cppc = 0;
3151   my @ccom = @{$file{ccom}};
3152   for $ix (0 .. $#ccom) {
3153     if (!$opt{cplusplus} && $ccom[$ix] =~ s!^//!!) {
3154       $cppc++;
3155       $file{changes} += $c =~ s/$rccs$ix$rcce/$ccs$ccom[$ix] $cce/;
3156     }
3157     else {
3158       $c =~ s/$rccs$ix$rcce/$ccom[$ix]/;
3159     }
3160   }
3161
3162   if ($cppc) {
3163     my $s = $cppc != 1 ? 's' : '';
3164     warning("Uses $cppc C++ style comment$s, which is not portable");
3165   }
3166
3167   if ($file{changes}) {
3168     if (exists $opt{copy}) {
3169       my $newfile = "$filename$opt{copy}";
3170       if (-e $newfile) {
3171         error("'$newfile' already exists, refusing to write copy of '$filename'");
3172       }
3173       else {
3174         local *F;
3175         if (open F, ">$newfile") {
3176           info("Writing copy of '$filename' with changes to '$newfile'");
3177           print F $c;
3178           close F;
3179         }
3180         else {
3181           error("Cannot open '$newfile' for writing: $!");
3182         }
3183       }
3184     }
3185     elsif (exists $opt{patch} || $opt{changes}) {
3186       if (exists $opt{patch}) {
3187         unless ($patch_opened) {
3188           if (open PATCH, ">$opt{patch}") {
3189             $patch_opened = 1;
3190           }
3191           else {
3192             error("Cannot open '$opt{patch}' for writing: $!");
3193             delete $opt{patch};
3194             $opt{changes} = 1;
3195             goto fallback;
3196           }
3197         }
3198         mydiff(\*PATCH, $filename, $c);
3199       }
3200       else {
3201 fallback:
3202         info("Suggested changes:");
3203         mydiff(\*STDOUT, $filename, $c);
3204       }
3205     }
3206     else {
3207       my $s = $file{changes} == 1 ? '' : 's';
3208       info("$file{changes} potentially required change$s detected");
3209     }
3210   }
3211   else {
3212     info("Looks good");
3213   }
3214 }
3215
3216 close PATCH if $patch_opened;
3217
3218 exit 0;
3219
3220
3221 sub mydiff
3222 {
3223   local *F = shift;
3224   my($file, $str) = @_;
3225   my $diff;
3226
3227   if (exists $opt{diff}) {
3228     $diff = run_diff($opt{diff}, $file, $str);
3229   }
3230
3231   if (!defined $diff and can_use('Text::Diff')) {
3232     $diff = Text::Diff::diff($file, \$str, { STYLE => 'Unified' });
3233     $diff = <<HEADER . $diff;
3234 --- $file
3235 +++ $file.patched
3236 HEADER
3237   }
3238
3239   if (!defined $diff) {
3240     $diff = run_diff('diff -u', $file, $str);
3241   }
3242
3243   if (!defined $diff) {
3244     $diff = run_diff('diff', $file, $str);
3245   }
3246
3247   if (!defined $diff) {
3248     error("Cannot generate a diff. Please install Text::Diff or use --copy.");
3249     return;
3250   }
3251
3252   print F $diff;
3253
3254 }
3255
3256 sub run_diff
3257 {
3258   my($prog, $file, $str) = @_;
3259   my $tmp = 'dppptemp';
3260   my $suf = 'aaa';
3261   my $diff = '';
3262   local *F;
3263
3264   while (-e "$tmp.$suf") { $suf++ }
3265   $tmp = "$tmp.$suf";
3266
3267   if (open F, ">$tmp") {
3268     print F $str;
3269     close F;
3270
3271     if (open F, "$prog $file $tmp |") {
3272       while (<F>) {
3273         s/\Q$tmp\E/$file.patched/;
3274         $diff .= $_;
3275       }
3276       close F;
3277       unlink $tmp;
3278       return $diff;
3279     }
3280
3281     unlink $tmp;
3282   }
3283   else {
3284     error("Cannot open '$tmp' for writing: $!");
3285   }
3286
3287   return undef;
3288 }
3289
3290 sub can_use
3291 {
3292   eval "use @_;";
3293   return $@ eq '';
3294 }
3295
3296 sub rec_depend
3297 {
3298   my $func = shift;
3299   my %seen;
3300   return () unless exists $depends{$func};
3301   grep !$seen{$_}++, map { ($_, rec_depend($_)) } @{$depends{$func}};
3302 }
3303
3304 sub parse_version
3305 {
3306   my $ver = shift;
3307
3308   if ($ver =~ /^(\d+)\.(\d+)\.(\d+)$/) {
3309     return ($1, $2, $3);
3310   }
3311   elsif ($ver !~ /^\d+\.[\d_]+$/) {
3312     die "cannot parse version '$ver'\n";
3313   }
3314
3315   $ver =~ s/_//g;
3316   $ver =~ s/$/000000/;
3317
3318   my($r,$v,$s) = $ver =~ /(\d+)\.(\d{3})(\d{3})/;
3319
3320   $v = int $v;
3321   $s = int $s;
3322
3323   if ($r < 5 || ($r == 5 && $v < 6)) {
3324     if ($s % 10) {
3325       die "cannot parse version '$ver'\n";
3326     }
3327   }
3328
3329   return ($r, $v, $s);
3330 }
3331
3332 sub format_version
3333 {
3334   my $ver = shift;
3335
3336   $ver =~ s/$/000000/;
3337   my($r,$v,$s) = $ver =~ /(\d+)\.(\d{3})(\d{3})/;
3338
3339   $v = int $v;
3340   $s = int $s;
3341
3342   if ($r < 5 || ($r == 5 && $v < 6)) {
3343     if ($s % 10) {
3344       die "invalid version '$ver'\n";
3345     }
3346     $s /= 10;
3347
3348     $ver = sprintf "%d.%03d", $r, $v;
3349     $s > 0 and $ver .= sprintf "_%02d", $s;
3350
3351     return $ver;
3352   }
3353
3354   return sprintf "%d.%d.%d", $r, $v, $s;
3355 }
3356
3357 sub info
3358 {
3359   $opt{quiet} and return;
3360   print @_, "\n";
3361 }
3362
3363 sub diag
3364 {
3365   $opt{quiet} and return;
3366   $opt{diag} and print @_, "\n";
3367 }
3368
3369 sub warning
3370 {
3371   $opt{quiet} and return;
3372   print "*** ", @_, "\n";
3373 }
3374
3375 sub error
3376 {
3377   print "*** ERROR: ", @_, "\n";
3378 }
3379
3380 my %given_hints;
3381 sub hint
3382 {
3383   $opt{quiet} and return;
3384   $opt{hints} or return;
3385   my $func = shift;
3386   exists $hints{$func} or return;
3387   $given_hints{$func}++ and return;
3388   my $hint = $hints{$func};
3389   $hint =~ s/^/   /mg;
3390   print "   --- hint for $func ---\n", $hint;
3391 }
3392
3393 sub usage
3394 {
3395   my($usage) = do { local(@ARGV,$/)=($0); <> } =~ /^=head\d$HS+SYNOPSIS\s*^(.*?)\s*^=/ms;
3396   my %M = ( 'I' => '*' );
3397   $usage =~ s/^\s*perl\s+\S+/$^X $0/;
3398   $usage =~ s/([A-Z])<([^>]+)>/$M{$1}$2$M{$1}/g;
3399
3400   print <<ENDUSAGE;
3401
3402 Usage: $usage
3403
3404 See perldoc $0 for details.
3405
3406 ENDUSAGE
3407
3408   exit 2;
3409 }
3410
3411 __DATA__
3412 */
3413
3414 #ifndef _P_P_PORTABILITY_H_
3415 #define _P_P_PORTABILITY_H_
3416
3417 #ifndef DPPP_NAMESPACE
3418 #  define DPPP_NAMESPACE DPPP_
3419 #endif
3420
3421 #define DPPP_CAT2(x,y) CAT2(x,y)
3422 #define DPPP_(name) DPPP_CAT2(DPPP_NAMESPACE, name)
3423
3424 #ifndef PERL_REVISION
3425 #  if !defined(__PATCHLEVEL_H_INCLUDED__) && !(defined(PATCHLEVEL) && defined(SUBVERSION))
3426 #    define PERL_PATCHLEVEL_H_IMPLICIT
3427 #    include <patchlevel.h>
3428 #  endif
3429 #  if !(defined(PERL_VERSION) || (defined(SUBVERSION) && defined(PATCHLEVEL)))
3430 #    include <could_not_find_Perl_patchlevel.h>
3431 #  endif
3432 #  ifndef PERL_REVISION
3433 #    define PERL_REVISION       (5)
3434      /* Replace: 1 */
3435 #    define PERL_VERSION        PATCHLEVEL
3436 #    define PERL_SUBVERSION     SUBVERSION
3437      /* Replace PERL_PATCHLEVEL with PERL_VERSION */
3438      /* Replace: 0 */
3439 #  endif
3440 #endif
3441
3442 #define PERL_BCDVERSION ((PERL_REVISION * 0x1000000L) + (PERL_VERSION * 0x1000L) + PERL_SUBVERSION)
3443
3444 /* It is very unlikely that anyone will try to use this with Perl 6 
3445    (or greater), but who knows.
3446  */
3447 #if PERL_REVISION != 5
3448 #  error ppport.h only works with Perl version 5
3449 #endif /* PERL_REVISION != 5 */
3450
3451 #ifdef I_LIMITS
3452 #  include <limits.h>
3453 #endif
3454
3455 #ifndef PERL_UCHAR_MIN
3456 #  define PERL_UCHAR_MIN ((unsigned char)0)
3457 #endif
3458
3459 #ifndef PERL_UCHAR_MAX
3460 #  ifdef UCHAR_MAX
3461 #    define PERL_UCHAR_MAX ((unsigned char)UCHAR_MAX)
3462 #  else
3463 #    ifdef MAXUCHAR
3464 #      define PERL_UCHAR_MAX ((unsigned char)MAXUCHAR)
3465 #    else
3466 #      define PERL_UCHAR_MAX ((unsigned char)~(unsigned)0)
3467 #    endif
3468 #  endif
3469 #endif
3470
3471 #ifndef PERL_USHORT_MIN
3472 #  define PERL_USHORT_MIN ((unsigned short)0)
3473 #endif
3474
3475 #ifndef PERL_USHORT_MAX
3476 #  ifdef USHORT_MAX
3477 #    define PERL_USHORT_MAX ((unsigned short)USHORT_MAX)
3478 #  else
3479 #    ifdef MAXUSHORT
3480 #      define PERL_USHORT_MAX ((unsigned short)MAXUSHORT)
3481 #    else
3482 #      ifdef USHRT_MAX
3483 #        define PERL_USHORT_MAX ((unsigned short)USHRT_MAX)
3484 #      else
3485 #        define PERL_USHORT_MAX ((unsigned short)~(unsigned)0)
3486 #      endif
3487 #    endif
3488 #  endif
3489 #endif
3490
3491 #ifndef PERL_SHORT_MAX
3492 #  ifdef SHORT_MAX
3493 #    define PERL_SHORT_MAX ((short)SHORT_MAX)
3494 #  else
3495 #    ifdef MAXSHORT    /* Often used in <values.h> */
3496 #      define PERL_SHORT_MAX ((short)MAXSHORT)
3497 #    else
3498 #      ifdef SHRT_MAX
3499 #        define PERL_SHORT_MAX ((short)SHRT_MAX)
3500 #      else
3501 #        define PERL_SHORT_MAX ((short) (PERL_USHORT_MAX >> 1))
3502 #      endif
3503 #    endif
3504 #  endif
3505 #endif
3506
3507 #ifndef PERL_SHORT_MIN
3508 #  ifdef SHORT_MIN
3509 #    define PERL_SHORT_MIN ((short)SHORT_MIN)
3510 #  else
3511 #    ifdef MINSHORT
3512 #      define PERL_SHORT_MIN ((short)MINSHORT)
3513 #    else
3514 #      ifdef SHRT_MIN
3515 #        define PERL_SHORT_MIN ((short)SHRT_MIN)
3516 #      else
3517 #        define PERL_SHORT_MIN (-PERL_SHORT_MAX - ((3 & -1) == 3))
3518 #      endif
3519 #    endif
3520 #  endif
3521 #endif
3522
3523 #ifndef PERL_UINT_MAX
3524 #  ifdef UINT_MAX
3525 #    define PERL_UINT_MAX ((unsigned int)UINT_MAX)
3526 #  else
3527 #    ifdef MAXUINT
3528 #      define PERL_UINT_MAX ((unsigned int)MAXUINT)
3529 #    else
3530 #      define PERL_UINT_MAX (~(unsigned int)0)
3531 #    endif
3532 #  endif
3533 #endif
3534
3535 #ifndef PERL_UINT_MIN
3536 #  define PERL_UINT_MIN ((unsigned int)0)
3537 #endif
3538
3539 #ifndef PERL_INT_MAX
3540 #  ifdef INT_MAX
3541 #    define PERL_INT_MAX ((int)INT_MAX)
3542 #  else
3543 #    ifdef MAXINT    /* Often used in <values.h> */
3544 #      define PERL_INT_MAX ((int)MAXINT)
3545 #    else
3546 #      define PERL_INT_MAX ((int)(PERL_UINT_MAX >> 1))
3547 #    endif
3548 #  endif
3549 #endif
3550
3551 #ifndef PERL_INT_MIN
3552 #  ifdef INT_MIN
3553 #    define PERL_INT_MIN ((int)INT_MIN)
3554 #  else
3555 #    ifdef MININT
3556 #      define PERL_INT_MIN ((int)MININT)
3557 #    else
3558 #      define PERL_INT_MIN (-PERL_INT_MAX - ((3 & -1) == 3))
3559 #    endif
3560 #  endif
3561 #endif
3562
3563 #ifndef PERL_ULONG_MAX
3564 #  ifdef ULONG_MAX
3565 #    define PERL_ULONG_MAX ((unsigned long)ULONG_MAX)
3566 #  else
3567 #    ifdef MAXULONG
3568 #      define PERL_ULONG_MAX ((unsigned long)MAXULONG)
3569 #    else
3570 #      define PERL_ULONG_MAX (~(unsigned long)0)
3571 #    endif
3572 #  endif
3573 #endif
3574
3575 #ifndef PERL_ULONG_MIN
3576 #  define PERL_ULONG_MIN ((unsigned long)0L)
3577 #endif
3578
3579 #ifndef PERL_LONG_MAX
3580 #  ifdef LONG_MAX
3581 #    define PERL_LONG_MAX ((long)LONG_MAX)
3582 #  else
3583 #    ifdef MAXLONG
3584 #      define PERL_LONG_MAX ((long)MAXLONG)
3585 #    else
3586 #      define PERL_LONG_MAX ((long) (PERL_ULONG_MAX >> 1))
3587 #    endif
3588 #  endif
3589 #endif
3590
3591 #ifndef PERL_LONG_MIN
3592 #  ifdef LONG_MIN
3593 #    define PERL_LONG_MIN ((long)LONG_MIN)
3594 #  else
3595 #    ifdef MINLONG
3596 #      define PERL_LONG_MIN ((long)MINLONG)
3597 #    else
3598 #      define PERL_LONG_MIN (-PERL_LONG_MAX - ((3 & -1) == 3))
3599 #    endif
3600 #  endif
3601 #endif
3602
3603 #if defined(HAS_QUAD) && (defined(convex) || defined(uts))
3604 #  ifndef PERL_UQUAD_MAX
3605 #    ifdef ULONGLONG_MAX
3606 #      define PERL_UQUAD_MAX ((unsigned long long)ULONGLONG_MAX)
3607 #    else
3608 #      ifdef MAXULONGLONG
3609 #        define PERL_UQUAD_MAX ((unsigned long long)MAXULONGLONG)
3610 #      else
3611 #        define PERL_UQUAD_MAX (~(unsigned long long)0)
3612 #      endif
3613 #    endif
3614 #  endif
3615
3616 #  ifndef PERL_UQUAD_MIN
3617 #    define PERL_UQUAD_MIN ((unsigned long long)0L)
3618 #  endif
3619
3620 #  ifndef PERL_QUAD_MAX
3621 #    ifdef LONGLONG_MAX
3622 #      define PERL_QUAD_MAX ((long long)LONGLONG_MAX)
3623 #    else
3624 #      ifdef MAXLONGLONG
3625 #        define PERL_QUAD_MAX ((long long)MAXLONGLONG)
3626 #      else
3627 #        define PERL_QUAD_MAX ((long long) (PERL_UQUAD_MAX >> 1))
3628 #      endif
3629 #    endif
3630 #  endif
3631
3632 #  ifndef PERL_QUAD_MIN
3633 #    ifdef LONGLONG_MIN
3634 #      define PERL_QUAD_MIN ((long long)LONGLONG_MIN)
3635 #    else
3636 #      ifdef MINLONGLONG
3637 #        define PERL_QUAD_MIN ((long long)MINLONGLONG)
3638 #      else
3639 #        define PERL_QUAD_MIN (-PERL_QUAD_MAX - ((3 & -1) == 3))
3640 #      endif
3641 #    endif
3642 #  endif
3643 #endif
3644
3645 /* This is based on code from 5.003 perl.h */
3646 #ifdef HAS_QUAD
3647 #  ifdef cray
3648 #ifndef IVTYPE
3649 #  define IVTYPE                         int
3650 #endif
3651
3652 #ifndef IV_MIN
3653 #  define IV_MIN                         PERL_INT_MIN
3654 #endif
3655
3656 #ifndef IV_MAX
3657 #  define IV_MAX                         PERL_INT_MAX
3658 #endif
3659
3660 #ifndef UV_MIN
3661 #  define UV_MIN                         PERL_UINT_MIN
3662 #endif
3663
3664 #ifndef UV_MAX
3665 #  define UV_MAX                         PERL_UINT_MAX
3666 #endif
3667
3668 #    ifdef INTSIZE
3669 #ifndef IVSIZE
3670 #  define IVSIZE                         INTSIZE
3671 #endif
3672
3673 #    endif
3674 #  else
3675 #    if defined(convex) || defined(uts)
3676 #ifndef IVTYPE
3677 #  define IVTYPE                         long long
3678 #endif
3679
3680 #ifndef IV_MIN
3681 #  define IV_MIN                         PERL_QUAD_MIN
3682 #endif
3683
3684 #ifndef IV_MAX
3685 #  define IV_MAX                         PERL_QUAD_MAX
3686 #endif
3687
3688 #ifndef UV_MIN
3689 #  define UV_MIN                         PERL_UQUAD_MIN
3690 #endif
3691
3692 #ifndef UV_MAX
3693 #  define UV_MAX                         PERL_UQUAD_MAX
3694 #endif
3695
3696 #      ifdef LONGLONGSIZE
3697 #ifndef IVSIZE
3698 #  define IVSIZE                         LONGLONGSIZE
3699 #endif
3700
3701 #      endif
3702 #    else
3703 #ifndef IVTYPE
3704 #  define IVTYPE                         long
3705 #endif
3706
3707 #ifndef IV_MIN
3708 #  define IV_MIN                         PERL_LONG_MIN
3709 #endif
3710
3711 #ifndef IV_MAX
3712 #  define IV_MAX                         PERL_LONG_MAX
3713 #endif
3714
3715 #ifndef UV_MIN
3716 #  define UV_MIN                         PERL_ULONG_MIN
3717 #endif
3718
3719 #ifndef UV_MAX
3720 #  define UV_MAX                         PERL_ULONG_MAX
3721 #endif
3722
3723 #      ifdef LONGSIZE
3724 #ifndef IVSIZE
3725 #  define IVSIZE                         LONGSIZE
3726 #endif
3727
3728 #      endif
3729 #    endif
3730 #  endif
3731 #ifndef IVSIZE
3732 #  define IVSIZE                         8
3733 #endif
3734
3735 #ifndef PERL_QUAD_MIN
3736 #  define PERL_QUAD_MIN                  IV_MIN
3737 #endif
3738
3739 #ifndef PERL_QUAD_MAX
3740 #  define PERL_QUAD_MAX                  IV_MAX
3741 #endif
3742
3743 #ifndef PERL_UQUAD_MIN
3744 #  define PERL_UQUAD_MIN                 UV_MIN
3745 #endif
3746
3747 #ifndef PERL_UQUAD_MAX
3748 #  define PERL_UQUAD_MAX                 UV_MAX
3749 #endif
3750
3751 #else
3752 #ifndef IVTYPE
3753 #  define IVTYPE                         long
3754 #endif
3755
3756 #ifndef IV_MIN
3757 #  define IV_MIN                         PERL_LONG_MIN
3758 #endif
3759
3760 #ifndef IV_MAX
3761 #  define IV_MAX                         PERL_LONG_MAX
3762 #endif
3763
3764 #ifndef UV_MIN
3765 #  define UV_MIN                         PERL_ULONG_MIN
3766 #endif
3767
3768 #ifndef UV_MAX
3769 #  define UV_MAX                         PERL_ULONG_MAX
3770 #endif
3771
3772 #endif
3773
3774 #ifndef IVSIZE
3775 #  ifdef LONGSIZE
3776 #    define IVSIZE LONGSIZE
3777 #  else
3778 #    define IVSIZE 4 /* A bold guess, but the best we can make. */
3779 #  endif
3780 #endif
3781 #ifndef UVTYPE
3782 #  define UVTYPE                         unsigned IVTYPE
3783 #endif
3784
3785 #ifndef UVSIZE
3786 #  define UVSIZE                         IVSIZE
3787 #endif
3788
3789 #ifndef sv_setuv
3790 #  define sv_setuv(sv, uv)                  \
3791    STMT_START {                             \
3792        UV TeMpUv = uv;                      \
3793        if (TeMpUv <= IV_MAX)                \
3794            sv_setiv(sv, TeMpUv);            \
3795        else                                 \
3796            sv_setnv(sv, (double)TeMpUv);    \
3797    } STMT_END
3798 #endif
3799
3800 #ifndef newSVuv
3801 #  define newSVuv(uv) ((uv) <= IV_MAX ? newSViv((IV)uv) : newSVnv((NV)uv))
3802 #endif
3803 #ifndef sv_2uv
3804 #  define sv_2uv(sv)                     ((PL_Sv = (sv)), (UV) (SvNOK(PL_Sv) ? SvNV(PL_Sv) : sv_2nv(PL_Sv)))
3805 #endif
3806
3807 #ifndef SvUVX
3808 #  define SvUVX(sv)                      ((UV)SvIVX(sv))
3809 #endif
3810
3811 #ifndef SvUVXx
3812 #  define SvUVXx(sv)                     SvUVX(sv)
3813 #endif
3814
3815 #ifndef SvUV
3816 #  define SvUV(sv)                       (SvIOK(sv) ? SvUVX(sv) : sv_2uv(sv))
3817 #endif
3818
3819 #ifndef SvUVx
3820 #  define SvUVx(sv)                      ((PL_Sv = (sv)), SvUV(PL_Sv))
3821 #endif
3822
3823 /* Hint: sv_uv
3824  * Always use the SvUVx() macro instead of sv_uv().
3825  */
3826 #ifndef sv_uv
3827 #  define sv_uv(sv)                      SvUVx(sv)
3828 #endif
3829 #ifndef XST_mUV
3830 #  define XST_mUV(i,v)                   (ST(i) = sv_2mortal(newSVuv(v))  )
3831 #endif
3832
3833 #ifndef XSRETURN_UV
3834 #  define XSRETURN_UV(v)                 STMT_START { XST_mUV(0,v);  XSRETURN(1); } STMT_END
3835 #endif
3836 #ifndef PUSHu
3837 #  define PUSHu(u)                       STMT_START { sv_setuv(TARG, (UV)(u)); PUSHTARG;  } STMT_END
3838 #endif
3839
3840 #ifndef XPUSHu
3841 #  define XPUSHu(u)                      STMT_START { sv_setuv(TARG, (UV)(u)); XPUSHTARG; } STMT_END
3842 #endif
3843
3844 #if (PERL_VERSION < 4) || ((PERL_VERSION == 4) && (PERL_SUBVERSION <= 5))
3845 /* Replace: 1 */
3846 #  define PL_DBsingle               DBsingle
3847 #  define PL_DBsub                  DBsub
3848 #  define PL_Sv                     Sv
3849 #  define PL_compiling              compiling
3850 #  define PL_copline                copline
3851 #  define PL_curcop                 curcop
3852 #  define PL_curstash               curstash
3853 #  define PL_debstash               debstash
3854 #  define PL_defgv                  defgv
3855 #  define PL_diehook                diehook
3856 #  define PL_dirty                  dirty
3857 #  define PL_dowarn                 dowarn
3858 #  define PL_errgv                  errgv
3859 #  define PL_hexdigit               hexdigit
3860 #  define PL_hints                  hints
3861 #  define PL_na                     na
3862 #  define PL_no_modify              no_modify
3863 #  define PL_perl_destruct_level    perl_destruct_level
3864 #  define PL_perldb                 perldb
3865 #  define PL_ppaddr                 ppaddr
3866 #  define PL_rsfp_filters           rsfp_filters
3867 #  define PL_rsfp                   rsfp
3868 #  define PL_stack_base             stack_base
3869 #  define PL_stack_sp               stack_sp
3870 #  define PL_stdingv                stdingv
3871 #  define PL_sv_arenaroot           sv_arenaroot
3872 #  define PL_sv_no                  sv_no
3873 #  define PL_sv_undef               sv_undef
3874 #  define PL_sv_yes                 sv_yes
3875 #  define PL_tainted                tainted
3876 #  define PL_tainting               tainting
3877 /* Replace: 0 */
3878 #endif
3879
3880 #ifdef HASATTRIBUTE
3881 #  if (defined(__GNUC__) && defined(__cplusplus)) || defined(__INTEL_COMPILER)
3882 #    define PERL_UNUSED_DECL
3883 #  else
3884 #    define PERL_UNUSED_DECL __attribute__((unused))
3885 #  endif
3886 #else
3887 #  define PERL_UNUSED_DECL
3888 #endif
3889 #ifndef NOOP
3890 #  define NOOP                           (void)0
3891 #endif
3892
3893 #ifndef dNOOP
3894 #  define dNOOP                          extern int Perl___notused PERL_UNUSED_DECL
3895 #endif
3896
3897 #ifndef NVTYPE
3898 #  if defined(USE_LONG_DOUBLE) && defined(HAS_LONG_DOUBLE)
3899 #    define NVTYPE long double
3900 #  else
3901 #    define NVTYPE double
3902 #  endif
3903 typedef NVTYPE NV;
3904 #endif
3905
3906 #ifndef INT2PTR
3907
3908 #  if (IVSIZE == PTRSIZE) && (UVSIZE == PTRSIZE)
3909 #    define PTRV                  UV
3910 #    define INT2PTR(any,d)        (any)(d)
3911 #  else
3912 #    if PTRSIZE == LONGSIZE
3913 #      define PTRV                unsigned long
3914 #    else
3915 #      define PTRV                unsigned
3916 #    endif
3917 #    define INT2PTR(any,d)        (any)(PTRV)(d)
3918 #  endif
3919
3920 #  define NUM2PTR(any,d)  (any)(PTRV)(d)
3921 #  define PTR2IV(p)       INT2PTR(IV,p)
3922 #  define PTR2UV(p)       INT2PTR(UV,p)
3923 #  define PTR2NV(p)       NUM2PTR(NV,p)
3924
3925 #  if PTRSIZE == LONGSIZE
3926 #    define PTR2ul(p)     (unsigned long)(p)
3927 #  else
3928 #    define PTR2ul(p)     INT2PTR(unsigned long,p)        
3929 #  endif
3930
3931 #endif /* !INT2PTR */
3932
3933 #undef START_EXTERN_C
3934 #undef END_EXTERN_C
3935 #undef EXTERN_C
3936 #ifdef __cplusplus
3937 #  define START_EXTERN_C extern "C" {
3938 #  define END_EXTERN_C }
3939 #  define EXTERN_C extern "C"
3940 #else
3941 #  define START_EXTERN_C
3942 #  define END_EXTERN_C
3943 #  define EXTERN_C extern
3944 #endif
3945
3946 #ifndef PERL_GCC_BRACE_GROUPS_FORBIDDEN
3947 #  if defined(__STRICT_ANSI__) && defined(PERL_GCC_PEDANTIC)
3948 #    define PERL_GCC_BRACE_GROUPS_FORBIDDEN
3949 #  endif
3950 #endif
3951
3952 #undef STMT_START
3953 #undef STMT_END
3954 #if defined(__GNUC__) && !defined(PERL_GCC_BRACE_GROUPS_FORBIDDEN) && !defined(__cplusplus)
3955 #  define STMT_START    (void)( /* gcc supports ``({ STATEMENTS; })'' */
3956 #  define STMT_END      )
3957 #else
3958 #  if defined(VOIDFLAGS) && (VOIDFLAGS) && (defined(sun) || defined(__sun__)) && !defined(__GNUC__)
3959 #    define STMT_START  if (1)
3960 #    define STMT_END    else (void)0
3961 #  else
3962 #    define STMT_START  do
3963 #    define STMT_END    while (0)
3964 #  endif
3965 #endif
3966 #ifndef boolSV
3967 #  define boolSV(b)                      ((b) ? &PL_sv_yes : &PL_sv_no)
3968 #endif
3969
3970 /* DEFSV appears first in 5.004_56 */
3971 #ifndef DEFSV
3972 #  define DEFSV                          GvSV(PL_defgv)
3973 #endif
3974
3975 #ifndef SAVE_DEFSV
3976 #  define SAVE_DEFSV                     SAVESPTR(GvSV(PL_defgv))
3977 #endif
3978
3979 /* Older perls (<=5.003) lack AvFILLp */
3980 #ifndef AvFILLp
3981 #  define AvFILLp                        AvFILL
3982 #endif
3983 #ifndef ERRSV
3984 #  define ERRSV                          get_sv("@",FALSE)
3985 #endif
3986 #ifndef newSVpvn
3987 #  define newSVpvn(data,len)             ((data)                                              \
3988                                     ? ((len) ? newSVpv((data), (len)) : newSVpv("", 0)) \
3989                                     : newSV(0))
3990 #endif
3991
3992 /* Hint: gv_stashpvn
3993  * This function's backport doesn't support the length parameter, but
3994  * rather ignores it. Portability can only be ensured if the length
3995  * parameter is used for speed reasons, but the length can always be
3996  * correctly computed from the string argument.
3997  */
3998 #ifndef gv_stashpvn
3999 #  define gv_stashpvn(str,len,create)    gv_stashpv(str,create)
4000 #endif
4001
4002 /* Replace: 1 */
4003 #ifndef get_cv
4004 #  define get_cv                         perl_get_cv
4005 #endif
4006
4007 #ifndef get_sv
4008 #  define get_sv                         perl_get_sv
4009 #endif
4010
4011 #ifndef get_av
4012 #  define get_av                         perl_get_av
4013 #endif
4014
4015 #ifndef get_hv
4016 #  define get_hv                         perl_get_hv
4017 #endif
4018
4019 /* Replace: 0 */
4020
4021 #ifdef HAS_MEMCMP
4022 #ifndef memNE
4023 #  define memNE(s1,s2,l)                 (memcmp(s1,s2,l))
4024 #endif
4025
4026 #ifndef memEQ
4027 #  define memEQ(s1,s2,l)                 (!memcmp(s1,s2,l))
4028 #endif
4029
4030 #else
4031 #ifndef memNE
4032 #  define memNE(s1,s2,l)                 (bcmp(s1,s2,l))
4033 #endif
4034
4035 #ifndef memEQ
4036 #  define memEQ(s1,s2,l)                 (!bcmp(s1,s2,l))
4037 #endif
4038
4039 #endif
4040 #ifndef MoveD
4041 #  define MoveD(s,d,n,t)                 memmove((char*)(d),(char*)(s), (n) * sizeof(t))
4042 #endif
4043
4044 #ifndef CopyD
4045 #  define CopyD(s,d,n,t)                 memcpy((char*)(d),(char*)(s), (n) * sizeof(t))
4046 #endif
4047
4048 #ifdef HAS_MEMSET
4049 #ifndef ZeroD
4050 #  define ZeroD(d,n,t)                   memzero((char*)(d), (n) * sizeof(t))
4051 #endif
4052
4053 #else
4054 #ifndef ZeroD
4055 #  define ZeroD(d,n,t)                   ((void)memzero((char*)(d), (n) * sizeof(t)),d)
4056 #endif
4057
4058 #endif
4059 #ifndef Poison
4060 #  define Poison(d,n,t)                  (void)memset((char*)(d), 0xAB, (n) * sizeof(t))
4061 #endif
4062 #ifndef dUNDERBAR
4063 #  define dUNDERBAR                      dNOOP
4064 #endif
4065
4066 #ifndef UNDERBAR
4067 #  define UNDERBAR                       DEFSV
4068 #endif
4069 #ifndef dAX
4070 #  define dAX                            I32 ax = MARK - PL_stack_base + 1
4071 #endif
4072
4073 #ifndef dITEMS
4074 #  define dITEMS                         I32 items = SP - MARK
4075 #endif
4076 #ifndef dTHR
4077 #  define dTHR                           dNOOP
4078 #endif
4079 #ifndef dTHX
4080 #  define dTHX                           dNOOP
4081 #endif
4082
4083 #ifndef dTHXa
4084 #  define dTHXa(x)                       dNOOP
4085 #endif
4086 #ifndef pTHX
4087 #  define pTHX                           void
4088 #endif
4089
4090 #ifndef pTHX_
4091 #  define pTHX_                          
4092 #endif
4093
4094 #ifndef aTHX
4095 #  define aTHX                           
4096 #endif
4097
4098 #ifndef aTHX_
4099 #  define aTHX_                          
4100 #endif
4101 #ifndef dTHXoa
4102 #  define dTHXoa(x)                      dTHXa(x)
4103 #endif
4104 #ifndef PUSHmortal
4105 #  define PUSHmortal                     PUSHs(sv_newmortal())
4106 #endif
4107
4108 #ifndef mPUSHp
4109 #  define mPUSHp(p,l)                    sv_setpvn_mg(PUSHmortal, (p), (l))
4110 #endif
4111
4112 #ifndef mPUSHn
4113 #  define mPUSHn(n)                      sv_setnv_mg(PUSHmortal, (NV)(n))
4114 #endif
4115
4116 #ifndef mPUSHi
4117 #  define mPUSHi(i)                      sv_setiv_mg(PUSHmortal, (IV)(i))
4118 #endif
4119
4120 #ifndef mPUSHu
4121 #  define mPUSHu(u)                      sv_setuv_mg(PUSHmortal, (UV)(u))
4122 #endif
4123 #ifndef XPUSHmortal
4124 #  define XPUSHmortal                    XPUSHs(sv_newmortal())
4125 #endif
4126
4127 #ifndef mXPUSHp
4128 #  define mXPUSHp(p,l)                   STMT_START { EXTEND(sp,1); sv_setpvn_mg(PUSHmortal, (p), (l)); } STMT_END
4129 #endif
4130
4131 #ifndef mXPUSHn
4132 #  define mXPUSHn(n)                     STMT_START { EXTEND(sp,1); sv_setnv_mg(PUSHmortal, (NV)(n)); } STMT_END
4133 #endif
4134
4135 #ifndef mXPUSHi
4136 #  define mXPUSHi(i)                     STMT_START { EXTEND(sp,1); sv_setiv_mg(PUSHmortal, (IV)(i)); } STMT_END
4137 #endif
4138
4139 #ifndef mXPUSHu
4140 #  define mXPUSHu(u)                     STMT_START { EXTEND(sp,1); sv_setuv_mg(PUSHmortal, (UV)(u)); } STMT_END
4141 #endif
4142
4143 /* Replace: 1 */
4144 #ifndef call_sv
4145 #  define call_sv                        perl_call_sv
4146 #endif
4147
4148 #ifndef call_pv
4149 #  define call_pv                        perl_call_pv
4150 #endif
4151
4152 #ifndef call_argv
4153 #  define call_argv                      perl_call_argv
4154 #endif
4155
4156 #ifndef call_method
4157 #  define call_method                    perl_call_method
4158 #endif
4159 #ifndef eval_sv
4160 #  define eval_sv                        perl_eval_sv
4161 #endif
4162
4163 /* Replace: 0 */
4164
4165 /* Replace perl_eval_pv with eval_pv */
4166 /* eval_pv depends on eval_sv */
4167
4168 #ifndef eval_pv
4169 #if defined(NEED_eval_pv)
4170 static SV* DPPP_(my_eval_pv)(char *p, I32 croak_on_error);
4171 static
4172 #else
4173 extern SV* DPPP_(my_eval_pv)(char *p, I32 croak_on_error);
4174 #endif
4175
4176 #ifdef eval_pv
4177 #  undef eval_pv
4178 #endif
4179 #define eval_pv(a,b) DPPP_(my_eval_pv)(aTHX_ a,b)
4180 #define Perl_eval_pv DPPP_(my_eval_pv)
4181
4182 #if defined(NEED_eval_pv) || defined(NEED_eval_pv_GLOBAL)
4183
4184 SV*
4185 DPPP_(my_eval_pv)(char *p, I32 croak_on_error)
4186 {
4187     dSP;
4188     SV* sv = newSVpv(p, 0);
4189
4190     PUSHMARK(sp);
4191     eval_sv(sv, G_SCALAR);
4192     SvREFCNT_dec(sv);
4193
4194     SPAGAIN;
4195     sv = POPs;
4196     PUTBACK;
4197
4198     if (croak_on_error && SvTRUE(GvSV(errgv)))
4199         croak(SvPVx(GvSV(errgv), na));
4200
4201     return sv;
4202 }
4203
4204 #endif
4205 #endif
4206 #ifndef newRV_inc
4207 #  define newRV_inc(sv)                  newRV(sv)   /* Replace */
4208 #endif
4209
4210 #ifndef newRV_noinc
4211 #if defined(NEED_newRV_noinc)
4212 static SV * DPPP_(my_newRV_noinc)(SV *sv);
4213 static
4214 #else
4215 extern SV * DPPP_(my_newRV_noinc)(SV *sv);
4216 #endif
4217
4218 #ifdef newRV_noinc
4219 #  undef newRV_noinc
4220 #endif
4221 #define newRV_noinc(a) DPPP_(my_newRV_noinc)(aTHX_ a)
4222 #define Perl_newRV_noinc DPPP_(my_newRV_noinc)
4223
4224 #if defined(NEED_newRV_noinc) || defined(NEED_newRV_noinc_GLOBAL)
4225 SV *
4226 DPPP_(my_newRV_noinc)(SV *sv)
4227 {
4228   SV *rv = (SV *)newRV(sv);
4229   SvREFCNT_dec(sv);
4230   return rv;
4231 }
4232 #endif
4233 #endif
4234
4235 /* Hint: newCONSTSUB
4236  * Returns a CV* as of perl-5.7.1. This return value is not supported
4237  * by Devel::PPPort.
4238  */
4239
4240 /* newCONSTSUB from IO.xs is in the core starting with 5.004_63 */
4241 #if ((PERL_VERSION < 4) || ((PERL_VERSION == 4) && (PERL_SUBVERSION < 63))) && ((PERL_VERSION != 4) || (PERL_SUBVERSION != 5))
4242 #if defined(NEED_newCONSTSUB)
4243 static void DPPP_(my_newCONSTSUB)(HV *stash, char *name, SV *sv);
4244 static
4245 #else
4246 extern void DPPP_(my_newCONSTSUB)(HV *stash, char *name, SV *sv);
4247 #endif
4248
4249 #ifdef newCONSTSUB
4250 #  undef newCONSTSUB
4251 #endif
4252 #define newCONSTSUB(a,b,c) DPPP_(my_newCONSTSUB)(aTHX_ a,b,c)
4253 #define Perl_newCONSTSUB DPPP_(my_newCONSTSUB)
4254
4255 #if defined(NEED_newCONSTSUB) || defined(NEED_newCONSTSUB_GLOBAL)
4256
4257 void
4258 DPPP_(my_newCONSTSUB)(HV *stash, char *name, SV *sv)
4259 {
4260         U32 oldhints = PL_hints;
4261         HV *old_cop_stash = PL_curcop->cop_stash;
4262         HV *old_curstash = PL_curstash;
4263         line_t oldline = PL_curcop->cop_line;
4264         PL_curcop->cop_line = PL_copline;
4265
4266         PL_hints &= ~HINT_BLOCK_SCOPE;
4267         if (stash)
4268                 PL_curstash = PL_curcop->cop_stash = stash;
4269
4270         newSUB(
4271
4272 #if   ((PERL_VERSION < 3) || ((PERL_VERSION == 3) && (PERL_SUBVERSION < 22)))
4273                 start_subparse(),
4274 #elif ((PERL_VERSION == 3) && (PERL_SUBVERSION == 22))
4275                 start_subparse(0),
4276 #else  /* 5.003_23  onwards */
4277                 start_subparse(FALSE, 0),
4278 #endif
4279
4280                 newSVOP(OP_CONST, 0, newSVpv(name,0)),
4281                 newSVOP(OP_CONST, 0, &PL_sv_no),   /* SvPV(&PL_sv_no) == "" -- GMB */
4282                 newSTATEOP(0, Nullch, newSVOP(OP_CONST, 0, sv))
4283         );
4284
4285         PL_hints = oldhints;
4286         PL_curcop->cop_stash = old_cop_stash;
4287         PL_curstash = old_curstash;
4288         PL_curcop->cop_line = oldline;
4289 }
4290 #endif
4291 #endif
4292
4293 #ifndef START_MY_CXT
4294
4295 /*
4296  * Boilerplate macros for initializing and accessing interpreter-local
4297  * data from C.  All statics in extensions should be reworked to use
4298  * this, if you want to make the extension thread-safe.  See ext/re/re.xs
4299  * for an example of the use of these macros.
4300  *
4301  * Code that uses these macros is responsible for the following:
4302  * 1. #define MY_CXT_KEY to a unique string, e.g. "DynaLoader_guts"
4303  * 2. Declare a typedef named my_cxt_t that is a structure that contains
4304  *    all the data that needs to be interpreter-local.
4305  * 3. Use the START_MY_CXT macro after the declaration of my_cxt_t.
4306  * 4. Use the MY_CXT_INIT macro such that it is called exactly once
4307  *    (typically put in the BOOT: section).
4308  * 5. Use the members of the my_cxt_t structure everywhere as
4309  *    MY_CXT.member.
4310  * 6. Use the dMY_CXT macro (a declaration) in all the functions that
4311  *    access MY_CXT.
4312  */
4313
4314 #if defined(MULTIPLICITY) || defined(PERL_OBJECT) || \
4315     defined(PERL_CAPI)    || defined(PERL_IMPLICIT_CONTEXT)
4316
4317 /* This must appear in all extensions that define a my_cxt_t structure,
4318  * right after the definition (i.e. at file scope).  The non-threads
4319  * case below uses it to declare the data as static. */
4320 #define START_MY_CXT
4321
4322 #if (PERL_VERSION < 4 || (PERL_VERSION == 4 && PERL_SUBVERSION < 68 ))
4323 /* Fetches the SV that keeps the per-interpreter data. */
4324 #define dMY_CXT_SV \
4325         SV *my_cxt_sv = get_sv(MY_CXT_KEY, FALSE)
4326 #else /* >= perl5.004_68 */
4327 #define dMY_CXT_SV \
4328         SV *my_cxt_sv = *hv_fetch(PL_modglobal, MY_CXT_KEY,             \
4329                                   sizeof(MY_CXT_KEY)-1, TRUE)
4330 #endif /* < perl5.004_68 */
4331
4332 /* This declaration should be used within all functions that use the
4333  * interpreter-local data. */
4334 #define dMY_CXT \
4335         dMY_CXT_SV;                                                     \
4336         my_cxt_t *my_cxtp = INT2PTR(my_cxt_t*,SvUV(my_cxt_sv))
4337
4338 /* Creates and zeroes the per-interpreter data.
4339  * (We allocate my_cxtp in a Perl SV so that it will be released when
4340  * the interpreter goes away.) */
4341 #define MY_CXT_INIT \
4342         dMY_CXT_SV;                                                     \
4343         /* newSV() allocates one more than needed */                    \
4344         my_cxt_t *my_cxtp = (my_cxt_t*)SvPVX(newSV(sizeof(my_cxt_t)-1));\
4345         Zero(my_cxtp, 1, my_cxt_t);                                     \
4346         sv_setuv(my_cxt_sv, PTR2UV(my_cxtp))
4347
4348 /* Clones the per-interpreter data. */
4349 #define MY_CXT_CLONE \
4350         dMY_CXT_SV;                                                     \
4351         my_cxt_t *my_cxtp = (my_cxt_t*)SvPVX(newSV(sizeof(my_cxt_t)-1));\
4352         Copy(INT2PTR(my_cxt_t*, SvUV(my_cxt_sv)), my_cxtp, 1, my_cxt_t);\
4353         sv_setuv(my_cxt_sv, PTR2UV(my_cxtp))
4354
4355 /* This macro must be used to access members of the my_cxt_t structure.
4356  * e.g. MYCXT.some_data */
4357 #define MY_CXT          (*my_cxtp)
4358
4359 /* Judicious use of these macros can reduce the number of times dMY_CXT
4360  * is used.  Use is similar to pTHX, aTHX etc. */
4361 #define pMY_CXT         my_cxt_t *my_cxtp
4362 #define pMY_CXT_        pMY_CXT,
4363 #define _pMY_CXT        ,pMY_CXT
4364 #define aMY_CXT         my_cxtp
4365 #define aMY_CXT_        aMY_CXT,
4366 #define _aMY_CXT        ,aMY_CXT
4367
4368 #else /* single interpreter */
4369
4370 #define START_MY_CXT    static my_cxt_t my_cxt;
4371 #define dMY_CXT_SV      dNOOP
4372 #define dMY_CXT         dNOOP
4373 #define MY_CXT_INIT     NOOP
4374 #define MY_CXT_CLONE    NOOP
4375 #define MY_CXT          my_cxt
4376
4377 #define pMY_CXT         void
4378 #define pMY_CXT_
4379 #define _pMY_CXT
4380 #define aMY_CXT
4381 #define aMY_CXT_
4382 #define _aMY_CXT
4383
4384 #endif 
4385
4386 #endif /* START_MY_CXT */
4387
4388 #ifndef IVdf
4389 #  if IVSIZE == LONGSIZE
4390 #    define     IVdf      "ld"
4391 #    define     UVuf      "lu"
4392 #    define     UVof      "lo"
4393 #    define     UVxf      "lx"
4394 #    define     UVXf      "lX"
4395 #  else
4396 #    if IVSIZE == INTSIZE
4397 #      define   IVdf      "d"
4398 #      define   UVuf      "u"
4399 #      define   UVof      "o"
4400 #      define   UVxf      "x"
4401 #      define   UVXf      "X"
4402 #    endif
4403 #  endif
4404 #endif
4405
4406 #ifndef NVef
4407 #  if defined(USE_LONG_DOUBLE) && defined(HAS_LONG_DOUBLE) && \
4408       defined(PERL_PRIfldbl) /* Not very likely, but let's try anyway. */ 
4409 #    define NVef          PERL_PRIeldbl
4410 #    define NVff          PERL_PRIfldbl
4411 #    define NVgf          PERL_PRIgldbl
4412 #  else
4413 #    define NVef          "e"
4414 #    define NVff          "f"
4415 #    define NVgf          "g"
4416 #  endif
4417 #endif
4418
4419 #ifndef SvPV_nolen
4420
4421 #if defined(NEED_sv_2pv_nolen)
4422 static char * DPPP_(my_sv_2pv_nolen)(pTHX_ register SV *sv);
4423 static
4424 #else
4425 extern char * DPPP_(my_sv_2pv_nolen)(pTHX_ register SV *sv);
4426 #endif
4427
4428 #ifdef sv_2pv_nolen
4429 #  undef sv_2pv_nolen
4430 #endif
4431 #define sv_2pv_nolen(a) DPPP_(my_sv_2pv_nolen)(aTHX_ a)
4432 #define Perl_sv_2pv_nolen DPPP_(my_sv_2pv_nolen)
4433
4434 #if defined(NEED_sv_2pv_nolen) || defined(NEED_sv_2pv_nolen_GLOBAL)
4435
4436 char *
4437 DPPP_(my_sv_2pv_nolen)(pTHX_ register SV *sv)
4438 {   
4439   STRLEN n_a;
4440   return sv_2pv(sv, &n_a);
4441 }
4442
4443 #endif
4444
4445 /* Hint: sv_2pv_nolen
4446  * Use the SvPV_nolen() macro instead of sv_2pv_nolen().
4447  */
4448
4449 /* SvPV_nolen depends on sv_2pv_nolen */
4450 #define SvPV_nolen(sv) \
4451           ((SvFLAGS(sv) & (SVf_POK)) == SVf_POK \
4452            ? SvPVX(sv) : sv_2pv_nolen(sv))
4453
4454 #endif
4455
4456 #ifdef SvPVbyte
4457
4458 /* Hint: SvPVbyte
4459  * Does not work in perl-5.6.1, ppport.h implements a version
4460  * borrowed from perl-5.7.3.
4461  */
4462
4463 #if ((PERL_VERSION < 7) || ((PERL_VERSION == 7) && (PERL_SUBVERSION < 0)))
4464
4465 #if defined(NEED_sv_2pvbyte)
4466 static char * DPPP_(my_sv_2pvbyte)(pTHX_ register SV *sv, STRLEN *lp);
4467 static
4468 #else
4469 extern char * DPPP_(my_sv_2pvbyte)(pTHX_ register SV *sv, STRLEN *lp);
4470 #endif
4471
4472 #ifdef sv_2pvbyte
4473 #  undef sv_2pvbyte
4474 #endif
4475 #define sv_2pvbyte(a,b) DPPP_(my_sv_2pvbyte)(aTHX_ a,b)
4476 #define Perl_sv_2pvbyte DPPP_(my_sv_2pvbyte)
4477
4478 #if defined(NEED_sv_2pvbyte) || defined(NEED_sv_2pvbyte_GLOBAL)
4479
4480 char *
4481 DPPP_(my_sv_2pvbyte)(pTHX_ register SV *sv, STRLEN *lp)
4482 {   
4483   sv_utf8_downgrade(sv,0);
4484   return SvPV(sv,*lp);
4485 }
4486
4487 #endif
4488
4489 /* Hint: sv_2pvbyte
4490  * Use the SvPVbyte() macro instead of sv_2pvbyte().
4491  */
4492
4493 #undef SvPVbyte
4494
4495 /* SvPVbyte depends on sv_2pvbyte */
4496 #define SvPVbyte(sv, lp)                                                \
4497         ((SvFLAGS(sv) & (SVf_POK|SVf_UTF8)) == (SVf_POK)                \
4498          ? ((lp = SvCUR(sv)), SvPVX(sv)) : sv_2pvbyte(sv, &lp))
4499
4500 #endif
4501
4502 #else
4503
4504 #  define SvPVbyte          SvPV
4505 #  define sv_2pvbyte        sv_2pv
4506
4507 #endif
4508
4509 /* sv_2pvbyte_nolen depends on sv_2pv_nolen */
4510 #ifndef sv_2pvbyte_nolen
4511 #  define sv_2pvbyte_nolen               sv_2pv_nolen
4512 #endif
4513
4514 /* Hint: sv_pvn
4515  * Always use the SvPV() macro instead of sv_pvn().
4516  */
4517 #ifndef sv_pvn
4518 #  define sv_pvn(sv, len)                SvPV(sv, len)
4519 #endif
4520
4521 /* Hint: sv_pvn
4522  * Always use the SvPV_force() macro instead of sv_pvn_force().
4523  */
4524 #ifndef sv_pvn_force
4525 #  define sv_pvn_force(sv, len)          SvPV_force(sv, len)
4526 #endif
4527
4528 #if ((PERL_VERSION > 4) || ((PERL_VERSION == 4) && (PERL_SUBVERSION >= 0))) && !defined(vnewSVpvf)
4529 #if defined(NEED_vnewSVpvf)
4530 static SV * DPPP_(my_vnewSVpvf)(pTHX_ const char * pat, va_list * args);
4531 static
4532 #else
4533 extern SV * DPPP_(my_vnewSVpvf)(pTHX_ const char * pat, va_list * args);
4534 #endif
4535
4536 #ifdef vnewSVpvf
4537 #  undef vnewSVpvf
4538 #endif
4539 #define vnewSVpvf(a,b) DPPP_(my_vnewSVpvf)(aTHX_ a,b)
4540 #define Perl_vnewSVpvf DPPP_(my_vnewSVpvf)
4541
4542 #if defined(NEED_vnewSVpvf) || defined(NEED_vnewSVpvf_GLOBAL)
4543
4544 SV *
4545 DPPP_(my_vnewSVpvf)(pTHX_ const char *pat, va_list *args)
4546 {
4547   register SV *sv = newSV(0);
4548   sv_vsetpvfn(sv, pat, strlen(pat), args, Null(SV**), 0, Null(bool*));
4549   return sv;
4550 }
4551
4552 #endif
4553 #endif
4554
4555 /* sv_vcatpvf depends on sv_vcatpvfn */
4556 #if ((PERL_VERSION > 4) || ((PERL_VERSION == 4) && (PERL_SUBVERSION >= 0))) && !defined(sv_vcatpvf)
4557 #  define sv_vcatpvf(sv, pat, args)  sv_vcatpvfn(sv, pat, strlen(pat), args, Null(SV**), 0, Null(bool*))
4558 #endif
4559
4560 /* sv_vsetpvf depends on sv_vsetpvfn */
4561 #if ((PERL_VERSION > 4) || ((PERL_VERSION == 4) && (PERL_SUBVERSION >= 0))) && !defined(sv_vsetpvf)
4562 #  define sv_vsetpvf(sv, pat, args)  sv_vsetpvfn(sv, pat, strlen(pat), args, Null(SV**), 0, Null(bool*))
4563 #endif
4564
4565 /* sv_catpvf_mg depends on sv_vcatpvfn, sv_catpvf_mg_nocontext */
4566 #if ((PERL_VERSION > 4) || ((PERL_VERSION == 4) && (PERL_SUBVERSION >= 0))) && !defined(sv_catpvf_mg)
4567 #if defined(NEED_sv_catpvf_mg)
4568 static void DPPP_(my_sv_catpvf_mg)(pTHX_ SV * sv, const char * pat, ...);
4569 static
4570 #else
4571 extern void DPPP_(my_sv_catpvf_mg)(pTHX_ SV * sv, const char * pat, ...);
4572 #endif
4573
4574 #define Perl_sv_catpvf_mg DPPP_(my_sv_catpvf_mg)
4575
4576 #if defined(NEED_sv_catpvf_mg) || defined(NEED_sv_catpvf_mg_GLOBAL)
4577
4578 void
4579 DPPP_(my_sv_catpvf_mg)(pTHX_ SV *sv, const char *pat, ...)
4580 {
4581   va_list args;
4582   va_start(args, pat);
4583   sv_vcatpvfn(sv, pat, strlen(pat), &args, Null(SV**), 0, Null(bool*));
4584   SvSETMAGIC(sv);
4585   va_end(args);
4586 }
4587
4588 #endif
4589 #endif
4590
4591 /* sv_catpvf_mg_nocontext depends on sv_vcatpvfn */
4592 #ifdef PERL_IMPLICIT_CONTEXT
4593 #if ((PERL_VERSION > 4) || ((PERL_VERSION == 4) && (PERL_SUBVERSION >= 0))) && !defined(sv_catpvf_mg_nocontext)
4594 #if defined(NEED_sv_catpvf_mg_nocontext)
4595 static void DPPP_(my_sv_catpvf_mg_nocontext)(SV * sv, const char * pat, ...);
4596 static
4597 #else
4598 extern void DPPP_(my_sv_catpvf_mg_nocontext)(SV * sv, const char * pat, ...);
4599 #endif
4600
4601 #define sv_catpvf_mg_nocontext DPPP_(my_sv_catpvf_mg_nocontext)
4602 #define Perl_sv_catpvf_mg_nocontext DPPP_(my_sv_catpvf_mg_nocontext)
4603
4604 #if defined(NEED_sv_catpvf_mg_nocontext) || defined(NEED_sv_catpvf_mg_nocontext_GLOBAL)
4605
4606 void
4607 DPPP_(my_sv_catpvf_mg_nocontext)(SV *sv, const char *pat, ...)
4608 {
4609   dTHX;
4610   va_list args;
4611   va_start(args, pat);
4612   sv_vcatpvfn(sv, pat, strlen(pat), &args, Null(SV**), 0, Null(bool*));
4613   SvSETMAGIC(sv);
4614   va_end(args);
4615 }
4616
4617 #endif
4618 #endif
4619 #endif
4620
4621 #ifndef sv_catpvf_mg
4622 #  ifdef PERL_IMPLICIT_CONTEXT
4623 #    define sv_catpvf_mg   Perl_sv_catpvf_mg_nocontext
4624 #  else
4625 #    define sv_catpvf_mg   Perl_sv_catpvf_mg
4626 #  endif
4627 #endif
4628
4629 /* sv_vcatpvf_mg depends on sv_vcatpvfn */
4630 #if ((PERL_VERSION > 4) || ((PERL_VERSION == 4) && (PERL_SUBVERSION >= 0))) && !defined(sv_vcatpvf_mg)
4631 #  define sv_vcatpvf_mg(sv, pat, args)                                     \
4632    STMT_START {                                                            \
4633      sv_vcatpvfn(sv, pat, strlen(pat), args, Null(SV**), 0, Null(bool*));  \
4634      SvSETMAGIC(sv);                                                       \
4635    } STMT_END
4636 #endif
4637
4638 /* sv_setpvf_mg depends on sv_vsetpvfn, sv_setpvf_mg_nocontext */
4639 #if ((PERL_VERSION > 4) || ((PERL_VERSION == 4) && (PERL_SUBVERSION >= 0))) && !defined(sv_setpvf_mg)
4640 #if defined(NEED_sv_setpvf_mg)
4641 static void DPPP_(my_sv_setpvf_mg)(pTHX_ SV * sv, const char * pat, ...);
4642 static
4643 #else
4644 extern void DPPP_(my_sv_setpvf_mg)(pTHX_ SV * sv, const char * pat, ...);
4645 #endif
4646
4647 #define Perl_sv_setpvf_mg DPPP_(my_sv_setpvf_mg)
4648
4649 #if defined(NEED_sv_setpvf_mg) || defined(NEED_sv_setpvf_mg_GLOBAL)
4650
4651 void
4652 DPPP_(my_sv_setpvf_mg)(pTHX_ SV *sv, const char *pat, ...)
4653 {
4654   va_list args;
4655   va_start(args, pat);
4656   sv_vsetpvfn(sv, pat, strlen(pat), &args, Null(SV**), 0, Null(bool*));
4657   SvSETMAGIC(sv);
4658   va_end(args);
4659 }
4660
4661 #endif
4662 #endif
4663
4664 /* sv_setpvf_mg_nocontext depends on sv_vsetpvfn */
4665 #ifdef PERL_IMPLICIT_CONTEXT
4666 #if ((PERL_VERSION > 4) || ((PERL_VERSION == 4) && (PERL_SUBVERSION >= 0))) && !defined(sv_setpvf_mg_nocontext)
4667 #if defined(NEED_sv_setpvf_mg_nocontext)
4668 static void DPPP_(my_sv_setpvf_mg_nocontext)(SV * sv, const char * pat, ...);
4669 static
4670 #else
4671 extern void DPPP_(my_sv_setpvf_mg_nocontext)(SV * sv, const char * pat, ...);
4672 #endif
4673
4674 #define sv_setpvf_mg_nocontext DPPP_(my_sv_setpvf_mg_nocontext)
4675 #define Perl_sv_setpvf_mg_nocontext DPPP_(my_sv_setpvf_mg_nocontext)
4676
4677 #if defined(NEED_sv_setpvf_mg_nocontext) || defined(NEED_sv_setpvf_mg_nocontext_GLOBAL)
4678
4679 void
4680 DPPP_(my_sv_setpvf_mg_nocontext)(SV *sv, const char *pat, ...)
4681 {
4682   dTHX;
4683   va_list args;
4684   va_start(args, pat);
4685   sv_vsetpvfn(sv, pat, strlen(pat), &args, Null(SV**), 0, Null(bool*));
4686   SvSETMAGIC(sv);
4687   va_end(args);
4688 }
4689
4690 #endif
4691 #endif
4692 #endif
4693
4694 #ifndef sv_setpvf_mg
4695 #  ifdef PERL_IMPLICIT_CONTEXT
4696 #    define sv_setpvf_mg   Perl_sv_setpvf_mg_nocontext
4697 #  else
4698 #    define sv_setpvf_mg   Perl_sv_setpvf_mg
4699 #  endif
4700 #endif
4701
4702 /* sv_vsetpvf_mg depends on sv_vsetpvfn */
4703 #if ((PERL_VERSION > 4) || ((PERL_VERSION == 4) && (PERL_SUBVERSION >= 0))) && !defined(sv_vsetpvf_mg)
4704 #  define sv_vsetpvf_mg(sv, pat, args)                                     \
4705    STMT_START {                                                            \
4706      sv_vsetpvfn(sv, pat, strlen(pat), args, Null(SV**), 0, Null(bool*));  \
4707      SvSETMAGIC(sv);                                                       \
4708    } STMT_END
4709 #endif
4710 #ifndef SvGETMAGIC
4711 #  define SvGETMAGIC(x)                  STMT_START { if (SvGMAGICAL(x)) mg_get(x); } STMT_END
4712 #endif
4713 #ifndef PERL_MAGIC_sv
4714 #  define PERL_MAGIC_sv                  '\0'
4715 #endif
4716
4717 #ifndef PERL_MAGIC_overload
4718 #  define PERL_MAGIC_overload            'A'
4719 #endif
4720
4721 #ifndef PERL_MAGIC_overload_elem
4722 #  define PERL_MAGIC_overload_elem       'a'
4723 #endif
4724
4725 #ifndef PERL_MAGIC_overload_table
4726 #  define PERL_MAGIC_overload_table      'c'
4727 #endif
4728
4729 #ifndef PERL_MAGIC_bm
4730 #  define PERL_MAGIC_bm                  'B'
4731 #endif
4732
4733 #ifndef PERL_MAGIC_regdata
4734 #  define PERL_MAGIC_regdata             'D'
4735 #endif
4736
4737 #ifndef PERL_MAGIC_regdatum
4738 #  define PERL_MAGIC_regdatum            'd'
4739 #endif
4740
4741 #ifndef PERL_MAGIC_env
4742 #  define PERL_MAGIC_env                 'E'
4743 #endif
4744
4745 #ifndef PERL_MAGIC_envelem
4746 #  define PERL_MAGIC_envelem             'e'
4747 #endif
4748
4749 #ifndef PERL_MAGIC_fm
4750 #  define PERL_MAGIC_fm                  'f'
4751 #endif
4752
4753 #ifndef PERL_MAGIC_regex_global
4754 #  define PERL_MAGIC_regex_global        'g'
4755 #endif
4756
4757 #ifndef PERL_MAGIC_isa
4758 #  define PERL_MAGIC_isa                 'I'
4759 #endif
4760
4761 #ifndef PERL_MAGIC_isaelem
4762 #  define PERL_MAGIC_isaelem             'i'
4763 #endif
4764
4765 #ifndef PERL_MAGIC_nkeys
4766 #  define PERL_MAGIC_nkeys               'k'
4767 #endif
4768
4769 #ifndef PERL_MAGIC_dbfile
4770 #  define PERL_MAGIC_dbfile              'L'
4771 #endif
4772
4773 #ifndef PERL_MAGIC_dbline
4774 #  define PERL_MAGIC_dbline              'l'
4775 #endif
4776
4777 #ifndef PERL_MAGIC_mutex
4778 #  define PERL_MAGIC_mutex               'm'
4779 #endif
4780
4781 #ifndef PERL_MAGIC_shared
4782 #  define PERL_MAGIC_shared              'N'
4783 #endif
4784
4785 #ifndef PERL_MAGIC_shared_scalar
4786 #  define PERL_MAGIC_shared_scalar       'n'
4787 #endif
4788
4789 #ifndef PERL_MAGIC_collxfrm
4790 #  define PERL_MAGIC_collxfrm            'o'
4791 #endif
4792
4793 #ifndef PERL_MAGIC_tied
4794 #  define PERL_MAGIC_tied                'P'
4795 #endif
4796
4797 #ifndef PERL_MAGIC_tiedelem
4798 #  define PERL_MAGIC_tiedelem            'p'
4799 #endif
4800
4801 #ifndef PERL_MAGIC_tiedscalar
4802 #  define PERL_MAGIC_tiedscalar          'q'
4803 #endif
4804
4805 #ifndef PERL_MAGIC_qr
4806 #  define PERL_MAGIC_qr                  'r'
4807 #endif
4808
4809 #ifndef PERL_MAGIC_sig
4810 #  define PERL_MAGIC_sig                 'S'
4811 #endif
4812
4813 #ifndef PERL_MAGIC_sigelem
4814 #  define PERL_MAGIC_sigelem             's'
4815 #endif
4816
4817 #ifndef PERL_MAGIC_taint
4818 #  define PERL_MAGIC_taint               't'
4819 #endif
4820
4821 #ifndef PERL_MAGIC_uvar
4822 #  define PERL_MAGIC_uvar                'U'
4823 #endif
4824
4825 #ifndef PERL_MAGIC_uvar_elem
4826 #  define PERL_MAGIC_uvar_elem           'u'
4827 #endif
4828
4829 #ifndef PERL_MAGIC_vstring
4830 #  define PERL_MAGIC_vstring             'V'
4831 #endif
4832
4833 #ifndef PERL_MAGIC_vec
4834 #  define PERL_MAGIC_vec                 'v'
4835 #endif
4836
4837 #ifndef PERL_MAGIC_utf8
4838 #  define PERL_MAGIC_utf8                'w'
4839 #endif
4840
4841 #ifndef PERL_MAGIC_substr
4842 #  define PERL_MAGIC_substr              'x'
4843 #endif
4844
4845 #ifndef PERL_MAGIC_defelem
4846 #  define PERL_MAGIC_defelem             'y'
4847 #endif
4848
4849 #ifndef PERL_MAGIC_glob
4850 #  define PERL_MAGIC_glob                '*'
4851 #endif
4852
4853 #ifndef PERL_MAGIC_arylen
4854 #  define PERL_MAGIC_arylen              '#'
4855 #endif
4856
4857 #ifndef PERL_MAGIC_pos
4858 #  define PERL_MAGIC_pos                 '.'
4859 #endif
4860
4861 #ifndef PERL_MAGIC_backref
4862 #  define PERL_MAGIC_backref             '<'
4863 #endif
4864
4865 #ifndef PERL_MAGIC_ext
4866 #  define PERL_MAGIC_ext                 '~'
4867 #endif
4868
4869 /* That's the best we can do... */
4870 #ifndef SvPV_force_nomg
4871 #  define SvPV_force_nomg                SvPV_force
4872 #endif
4873
4874 #ifndef SvPV_nomg
4875 #  define SvPV_nomg                      SvPV
4876 #endif
4877
4878 #ifndef sv_catpvn_nomg
4879 #  define sv_catpvn_nomg                 sv_catpvn
4880 #endif
4881
4882 #ifndef sv_catsv_nomg
4883 #  define sv_catsv_nomg                  sv_catsv
4884 #endif
4885
4886 #ifndef sv_setsv_nomg
4887 #  define sv_setsv_nomg                  sv_setsv
4888 #endif
4889
4890 #ifndef sv_pvn_nomg
4891 #  define sv_pvn_nomg                    sv_pvn
4892 #endif
4893
4894 #ifndef SvIV_nomg
4895 #  define SvIV_nomg                      SvIV
4896 #endif
4897
4898 #ifndef SvUV_nomg
4899 #  define SvUV_nomg                      SvUV
4900 #endif
4901
4902 #ifndef sv_catpv_mg
4903 #  define sv_catpv_mg(sv, ptr)          \
4904    STMT_START {                         \
4905      SV *TeMpSv = sv;                   \
4906      sv_catpv(TeMpSv,ptr);              \
4907      SvSETMAGIC(TeMpSv);                \
4908    } STMT_END
4909 #endif
4910
4911 #ifndef sv_catpvn_mg
4912 #  define sv_catpvn_mg(sv, ptr, len)    \
4913    STMT_START {                         \
4914      SV *TeMpSv = sv;                   \
4915      sv_catpvn(TeMpSv,ptr,len);         \
4916      SvSETMAGIC(TeMpSv);                \
4917    } STMT_END
4918 #endif
4919
4920 #ifndef sv_catsv_mg
4921 #  define sv_catsv_mg(dsv, ssv)         \
4922    STMT_START {                         \
4923      SV *TeMpSv = dsv;                  \
4924      sv_catsv(TeMpSv,ssv);              \
4925      SvSETMAGIC(TeMpSv);                \
4926    } STMT_END
4927 #endif
4928
4929 #ifndef sv_setiv_mg
4930 #  define sv_setiv_mg(sv, i)            \
4931    STMT_START {                         \
4932      SV *TeMpSv = sv;                   \
4933      sv_setiv(TeMpSv,i);                \
4934      SvSETMAGIC(TeMpSv);                \
4935    } STMT_END
4936 #endif
4937
4938 #ifndef sv_setnv_mg
4939 #  define sv_setnv_mg(sv, num)          \
4940    STMT_START {                         \
4941      SV *TeMpSv = sv;                   \
4942      sv_setnv(TeMpSv,num);              \
4943      SvSETMAGIC(TeMpSv);                \
4944    } STMT_END
4945 #endif
4946
4947 #ifndef sv_setpv_mg
4948 #  define sv_setpv_mg(sv, ptr)          \
4949    STMT_START {                         \
4950      SV *TeMpSv = sv;                   \
4951      sv_setpv(TeMpSv,ptr);              \
4952      SvSETMAGIC(TeMpSv);                \
4953    } STMT_END
4954 #endif
4955
4956 #ifndef sv_setpvn_mg
4957 #  define sv_setpvn_mg(sv, ptr, len)    \
4958    STMT_START {                         \
4959      SV *TeMpSv = sv;                   \
4960      sv_setpvn(TeMpSv,ptr,len);         \
4961      SvSETMAGIC(TeMpSv);                \
4962    } STMT_END
4963 #endif
4964
4965 #ifndef sv_setsv_mg
4966 #  define sv_setsv_mg(dsv, ssv)         \
4967    STMT_START {                         \
4968      SV *TeMpSv = dsv;                  \
4969      sv_setsv(TeMpSv,ssv);              \
4970      SvSETMAGIC(TeMpSv);                \
4971    } STMT_END
4972 #endif
4973
4974 #ifndef sv_setuv_mg
4975 #  define sv_setuv_mg(sv, i)            \
4976    STMT_START {                         \
4977      SV *TeMpSv = sv;                   \
4978      sv_setuv(TeMpSv,i);                \
4979      SvSETMAGIC(TeMpSv);                \
4980    } STMT_END
4981 #endif
4982
4983 #ifndef sv_usepvn_mg
4984 #  define sv_usepvn_mg(sv, ptr, len)    \
4985    STMT_START {                         \
4986      SV *TeMpSv = sv;                   \
4987      sv_usepvn(TeMpSv,ptr,len);         \
4988      SvSETMAGIC(TeMpSv);                \
4989    } STMT_END
4990 #endif
4991
4992 #ifdef USE_ITHREADS
4993 #ifndef CopFILE
4994 #  define CopFILE(c)                     ((c)->cop_file)
4995 #endif
4996
4997 #ifndef CopFILEGV
4998 #  define CopFILEGV(c)                   (CopFILE(c) ? gv_fetchfile(CopFILE(c)) : Nullgv)
4999 #endif
5000
5001 #ifndef CopFILE_set
5002 #  define CopFILE_set(c,pv)              ((c)->cop_file = savepv(pv))
5003 #endif
5004
5005 #ifndef CopFILESV
5006 #  define CopFILESV(c)                   (CopFILE(c) ? GvSV(gv_fetchfile(CopFILE(c))) : Nullsv)
5007 #endif
5008
5009 #ifndef CopFILEAV
5010 #  define CopFILEAV(c)                   (CopFILE(c) ? GvAV(gv_fetchfile(CopFILE(c))) : Nullav)
5011 #endif
5012
5013 #ifndef CopSTASHPV
5014 #  define CopSTASHPV(c)                  ((c)->cop_stashpv)
5015 #endif
5016
5017 #ifndef CopSTASHPV_set
5018 #  define CopSTASHPV_set(c,pv)           ((c)->cop_stashpv = ((pv) ? savepv(pv) : Nullch))
5019 #endif
5020
5021 #ifndef CopSTASH
5022 #  define CopSTASH(c)                    (CopSTASHPV(c) ? gv_stashpv(CopSTASHPV(c),GV_ADD) : Nullhv)
5023 #endif
5024
5025 #ifndef CopSTASH_set
5026 #  define CopSTASH_set(c,hv)             CopSTASHPV_set(c, (hv) ? HvNAME(hv) : Nullch)
5027 #endif
5028
5029 #ifndef CopSTASH_eq
5030 #  define CopSTASH_eq(c,hv)              ((hv) && (CopSTASHPV(c) == HvNAME(hv) \
5031                                         || (CopSTASHPV(c) && HvNAME(hv) \
5032                                         && strEQ(CopSTASHPV(c), HvNAME(hv)))))
5033 #endif
5034
5035 #else
5036 #ifndef CopFILEGV
5037 #  define CopFILEGV(c)                   ((c)->cop_filegv)
5038 #endif
5039
5040 #ifndef CopFILEGV_set
5041 #  define CopFILEGV_set(c,gv)            ((c)->cop_filegv = (GV*)SvREFCNT_inc(gv))
5042 #endif
5043
5044 #ifndef CopFILE_set
5045 #  define CopFILE_set(c,pv)              CopFILEGV_set((c), gv_fetchfile(pv))
5046 #endif
5047
5048 #ifndef CopFILESV
5049 #  define CopFILESV(c)                   (CopFILEGV(c) ? GvSV(CopFILEGV(c)) : Nullsv)
5050 #endif
5051
5052 #ifndef CopFILEAV
5053 #  define CopFILEAV(c)                   (CopFILEGV(c) ? GvAV(CopFILEGV(c)) : Nullav)
5054 #endif
5055
5056 #ifndef CopFILE
5057 #  define CopFILE(c)                     (CopFILESV(c) ? SvPVX(CopFILESV(c)) : Nullch)
5058 #endif
5059
5060 #ifndef CopSTASH
5061 #  define CopSTASH(c)                    ((c)->cop_stash)
5062 #endif
5063
5064 #ifndef CopSTASH_set
5065 #  define CopSTASH_set(c,hv)             ((c)->cop_stash = (hv))
5066 #endif
5067
5068 #ifndef CopSTASHPV
5069 #  define CopSTASHPV(c)                  (CopSTASH(c) ? HvNAME(CopSTASH(c)) : Nullch)
5070 #endif
5071
5072 #ifndef CopSTASHPV_set
5073 #  define CopSTASHPV_set(c,pv)           CopSTASH_set((c), gv_stashpv(pv,GV_ADD))
5074 #endif
5075
5076 #ifndef CopSTASH_eq
5077 #  define CopSTASH_eq(c,hv)              (CopSTASH(c) == (hv))
5078 #endif
5079
5080 #endif /* USE_ITHREADS */
5081 #ifndef IN_PERL_COMPILETIME
5082 #  define IN_PERL_COMPILETIME            (PL_curcop == &PL_compiling)
5083 #endif
5084
5085 #ifndef IN_LOCALE_RUNTIME
5086 #  define IN_LOCALE_RUNTIME              (PL_curcop->op_private & HINT_LOCALE)
5087 #endif
5088
5089 #ifndef IN_LOCALE_COMPILETIME
5090 #  define IN_LOCALE_COMPILETIME          (PL_hints & HINT_LOCALE)
5091 #endif
5092
5093 #ifndef IN_LOCALE
5094 #  define IN_LOCALE                      (IN_PERL_COMPILETIME ? IN_LOCALE_COMPILETIME : IN_LOCALE_RUNTIME)
5095 #endif
5096 #ifndef IS_NUMBER_IN_UV
5097 #  define IS_NUMBER_IN_UV                0x01
5098 #endif
5099
5100 #ifndef IS_NUMBER_GREATER_THAN_UV_MAX
5101 #  define IS_NUMBER_GREATER_THAN_UV_MAX  0x02
5102 #endif
5103
5104 #ifndef IS_NUMBER_NOT_INT
5105 #  define IS_NUMBER_NOT_INT              0x04
5106 #endif
5107
5108 #ifndef IS_NUMBER_NEG
5109 #  define IS_NUMBER_NEG                  0x08
5110 #endif
5111
5112 #ifndef IS_NUMBER_INFINITY
5113 #  define IS_NUMBER_INFINITY             0x10
5114 #endif
5115
5116 #ifndef IS_NUMBER_NAN
5117 #  define IS_NUMBER_NAN                  0x20
5118 #endif
5119
5120 /* GROK_NUMERIC_RADIX depends on grok_numeric_radix */
5121 #ifndef GROK_NUMERIC_RADIX
5122 #  define GROK_NUMERIC_RADIX(sp, send)   grok_numeric_radix(sp, send)
5123 #endif
5124 #ifndef PERL_SCAN_GREATER_THAN_UV_MAX
5125 #  define PERL_SCAN_GREATER_THAN_UV_MAX  0x02
5126 #endif
5127
5128 #ifndef PERL_SCAN_SILENT_ILLDIGIT
5129 #  define PERL_SCAN_SILENT_ILLDIGIT      0x04
5130 #endif
5131
5132 #ifndef PERL_SCAN_ALLOW_UNDERSCORES
5133 #  define PERL_SCAN_ALLOW_UNDERSCORES    0x01
5134 #endif
5135
5136 #ifndef PERL_SCAN_DISALLOW_PREFIX
5137 #  define PERL_SCAN_DISALLOW_PREFIX      0x02
5138 #endif
5139
5140 #ifndef grok_numeric_radix
5141 #if defined(NEED_grok_numeric_radix)
5142 static bool DPPP_(my_grok_numeric_radix)(pTHX_ const char ** sp, const char * send);
5143 static
5144 #else
5145 extern bool DPPP_(my_grok_numeric_radix)(pTHX_ const char ** sp, const char * send);
5146 #endif
5147
5148 #ifdef grok_numeric_radix
5149 #  undef grok_numeric_radix
5150 #endif
5151 #define grok_numeric_radix(a,b) DPPP_(my_grok_numeric_radix)(aTHX_ a,b)
5152 #define Perl_grok_numeric_radix DPPP_(my_grok_numeric_radix)
5153
5154 #if defined(NEED_grok_numeric_radix) || defined(NEED_grok_numeric_radix_GLOBAL)
5155 bool
5156 DPPP_(my_grok_numeric_radix)(pTHX_ const char **sp, const char *send)
5157 {
5158 #ifdef USE_LOCALE_NUMERIC
5159 #ifdef PL_numeric_radix_sv
5160     if (PL_numeric_radix_sv && IN_LOCALE) { 
5161         STRLEN len;
5162         char* radix = SvPV(PL_numeric_radix_sv, len);
5163         if (*sp + len <= send && memEQ(*sp, radix, len)) {
5164             *sp += len;
5165             return TRUE; 
5166         }
5167     }
5168 #else
5169     /* older perls don't have PL_numeric_radix_sv so the radix
5170      * must manually be requested from locale.h
5171      */
5172 #include <locale.h>
5173     dTHR;  /* needed for older threaded perls */
5174     struct lconv *lc = localeconv();
5175     char *radix = lc->decimal_point;
5176     if (radix && IN_LOCALE) { 
5177         STRLEN len = strlen(radix);
5178         if (*sp + len <= send && memEQ(*sp, radix, len)) {
5179             *sp += len;
5180             return TRUE; 
5181         }
5182     }
5183 #endif /* PERL_VERSION */
5184 #endif /* USE_LOCALE_NUMERIC */
5185     /* always try "." if numeric radix didn't match because
5186      * we may have data from different locales mixed */
5187     if (*sp < send && **sp == '.') {
5188         ++*sp;
5189         return TRUE;
5190     }
5191     return FALSE;
5192 }
5193 #endif
5194 #endif
5195
5196 /* grok_number depends on grok_numeric_radix */
5197
5198 #ifndef grok_number
5199 #if defined(NEED_grok_number)
5200 static int DPPP_(my_grok_number)(pTHX_ const char * pv, STRLEN len, UV * valuep);
5201 static
5202 #else
5203 extern int DPPP_(my_grok_number)(pTHX_ const char * pv, STRLEN len, UV * valuep);
5204 #endif
5205
5206 #ifdef grok_number
5207 #  undef grok_number
5208 #endif
5209 #define grok_number(a,b,c) DPPP_(my_grok_number)(aTHX_ a,b,c)
5210 #define Perl_grok_number DPPP_(my_grok_number)
5211
5212 #if defined(NEED_grok_number) || defined(NEED_grok_number_GLOBAL)
5213 int
5214 DPPP_(my_grok_number)(pTHX_ const char *pv, STRLEN len, UV *valuep)
5215 {
5216   const char *s = pv;
5217   const char *send = pv + len;
5218   const UV max_div_10 = UV_MAX / 10;
5219   const char max_mod_10 = UV_MAX % 10;
5220   int numtype = 0;
5221   int sawinf = 0;
5222   int sawnan = 0;
5223
5224   while (s < send && isSPACE(*s))
5225     s++;
5226   if (s == send) {
5227     return 0;
5228   } else if (*s == '-') {
5229     s++;
5230     numtype = IS_NUMBER_NEG;
5231   }
5232   else if (*s == '+')
5233   s++;
5234
5235   if (s == send)
5236     return 0;
5237
5238   /* next must be digit or the radix separator or beginning of infinity */
5239   if (isDIGIT(*s)) {
5240     /* UVs are at least 32 bits, so the first 9 decimal digits cannot
5241        overflow.  */
5242     UV value = *s - '0';
5243     /* This construction seems to be more optimiser friendly.
5244        (without it gcc does the isDIGIT test and the *s - '0' separately)
5245        With it gcc on arm is managing 6 instructions (6 cycles) per digit.
5246        In theory the optimiser could deduce how far to unroll the loop
5247        before checking for overflow.  */
5248     if (++s < send) {
5249       int digit = *s - '0';
5250       if (digit >= 0 && digit <= 9) {
5251         value = value * 10 + digit;
5252         if (++s < send) {
5253           digit = *s - '0';
5254           if (digit >= 0 && digit <= 9) {
5255             value = value * 10 + digit;
5256             if (++s < send) {
5257               digit = *s - '0';
5258               if (digit >= 0 && digit <= 9) {
5259                 value = value * 10 + digit;
5260                 if (++s < send) {
5261                   digit = *s - '0';
5262                   if (digit >= 0 && digit <= 9) {
5263                     value = value * 10 + digit;
5264                     if (++s < send) {
5265                       digit = *s - '0';
5266                       if (digit >= 0 && digit <= 9) {
5267                         value = value * 10 + digit;
5268                         if (++s < send) {
5269                           digit = *s - '0';
5270                           if (digit >= 0 && digit <= 9) {
5271                             value = value * 10 + digit;
5272                             if (++s < send) {
5273                               digit = *s - '0';
5274                               if (digit >= 0 && digit <= 9) {
5275                                 value = value * 10 + digit;
5276                                 if (++s < send) {
5277                                   digit = *s - '0';
5278                                   if (digit >= 0 && digit <= 9) {
5279                                     value = value * 10 + digit;
5280                                     if (++s < send) {
5281                                       /* Now got 9 digits, so need to check
5282                                          each time for overflow.  */
5283                                       digit = *s - '0';
5284                                       while (digit >= 0 && digit <= 9
5285                                              && (value < max_div_10
5286                                                  || (value == max_div_10
5287                                                      && digit <= max_mod_10))) {
5288                                         value = value * 10 + digit;
5289                                         if (++s < send)
5290                                           digit = *s - '0';
5291                                         else
5292                                           break;
5293                                       }
5294                                       if (digit >= 0 && digit <= 9
5295                                           && (s < send)) {
5296                                         /* value overflowed.
5297                                            skip the remaining digits, don't
5298                                            worry about setting *valuep.  */
5299                                         do {
5300                                           s++;
5301                                         } while (s < send && isDIGIT(*s));
5302                                         numtype |=
5303                                           IS_NUMBER_GREATER_THAN_UV_MAX;
5304                                         goto skip_value;
5305                                       }
5306                                     }
5307                                   }
5308                                 }
5309                               }
5310                             }
5311                           }
5312                         }
5313                       }
5314                     }
5315                   }
5316                 }
5317               }
5318             }
5319           }
5320         }
5321       }
5322     }
5323     numtype |= IS_NUMBER_IN_UV;
5324     if (valuep)
5325       *valuep = value;
5326
5327   skip_value:
5328     if (GROK_NUMERIC_RADIX(&s, send)) {
5329       numtype |= IS_NUMBER_NOT_INT;
5330       while (s < send && isDIGIT(*s))  /* optional digits after the radix */
5331         s++;
5332     }
5333   }
5334   else if (GROK_NUMERIC_RADIX(&s, send)) {
5335     numtype |= IS_NUMBER_NOT_INT | IS_NUMBER_IN_UV; /* valuep assigned below */
5336     /* no digits before the radix means we need digits after it */
5337     if (s < send && isDIGIT(*s)) {
5338       do {
5339         s++;
5340       } while (s < send && isDIGIT(*s));
5341       if (valuep) {
5342         /* integer approximation is valid - it's 0.  */
5343         *valuep = 0;
5344       }
5345     }
5346     else
5347       return 0;
5348   } else if (*s == 'I' || *s == 'i') {
5349     s++; if (s == send || (*s != 'N' && *s != 'n')) return 0;
5350     s++; if (s == send || (*s != 'F' && *s != 'f')) return 0;
5351     s++; if (s < send && (*s == 'I' || *s == 'i')) {
5352       s++; if (s == send || (*s != 'N' && *s != 'n')) return 0;
5353       s++; if (s == send || (*s != 'I' && *s != 'i')) return 0;
5354       s++; if (s == send || (*s != 'T' && *s != 't')) return 0;
5355       s++; if (s == send || (*s != 'Y' && *s != 'y')) return 0;
5356       s++;
5357     }
5358     sawinf = 1;
5359   } else if (*s == 'N' || *s == 'n') {
5360     /* XXX TODO: There are signaling NaNs and quiet NaNs. */
5361     s++; if (s == send || (*s != 'A' && *s != 'a')) return 0;
5362     s++; if (s == send || (*s != 'N' && *s != 'n')) return 0;
5363     s++;
5364     sawnan = 1;
5365   } else
5366     return 0;
5367
5368   if (sawinf) {
5369     numtype &= IS_NUMBER_NEG; /* Keep track of sign  */
5370     numtype |= IS_NUMBER_INFINITY | IS_NUMBER_NOT_INT;
5371   } else if (sawnan) {
5372     numtype &= IS_NUMBER_NEG; /* Keep track of sign  */
5373     numtype |= IS_NUMBER_NAN | IS_NUMBER_NOT_INT;
5374   } else if (s < send) {
5375     /* we can have an optional exponent part */
5376     if (*s == 'e' || *s == 'E') {
5377       /* The only flag we keep is sign.  Blow away any "it's UV"  */
5378       numtype &= IS_NUMBER_NEG;
5379       numtype |= IS_NUMBER_NOT_INT;
5380       s++;
5381       if (s < send && (*s == '-' || *s == '+'))
5382         s++;
5383       if (s < send && isDIGIT(*s)) {
5384         do {
5385           s++;
5386         } while (s < send && isDIGIT(*s));
5387       }
5388       else
5389       return 0;
5390     }
5391   }
5392   while (s < send && isSPACE(*s))
5393     s++;
5394   if (s >= send)
5395     return numtype;
5396   if (len == 10 && memEQ(pv, "0 but true", 10)) {
5397     if (valuep)
5398       *valuep = 0;
5399     return IS_NUMBER_IN_UV;
5400   }
5401   return 0;
5402 }
5403 #endif
5404 #endif
5405
5406 /*
5407  * The grok_* routines have been modified to use warn() instead of
5408  * Perl_warner(). Also, 'hexdigit' was the former name of PL_hexdigit,
5409  * which is why the stack variable has been renamed to 'xdigit'.
5410  */
5411
5412 #ifndef grok_bin
5413 #if defined(NEED_grok_bin)
5414 static UV DPPP_(my_grok_bin)(pTHX_ char *start, STRLEN *len_p, I32 *flags, NV *result);
5415 static
5416 #else
5417 extern UV DPPP_(my_grok_bin)(pTHX_ char *start, STRLEN *len_p, I32 *flags, NV *result);
5418 #endif
5419
5420 #ifdef grok_bin
5421 #  undef grok_bin
5422 #endif
5423 #define grok_bin(a,b,c,d) DPPP_(my_grok_bin)(aTHX_ a,b,c,d)
5424 #define Perl_grok_bin DPPP_(my_grok_bin)
5425
5426 #if defined(NEED_grok_bin) || defined(NEED_grok_bin_GLOBAL)
5427 UV
5428 DPPP_(my_grok_bin)(pTHX_ char *start, STRLEN *len_p, I32 *flags, NV *result)
5429 {
5430     const char *s = start;
5431     STRLEN len = *len_p;
5432     UV value = 0;
5433     NV value_nv = 0;
5434
5435     const UV max_div_2 = UV_MAX / 2;
5436     bool allow_underscores = *flags & PERL_SCAN_ALLOW_UNDERSCORES;
5437     bool overflowed = FALSE;
5438
5439     if (!(*flags & PERL_SCAN_DISALLOW_PREFIX)) {
5440         /* strip off leading b or 0b.
5441            for compatibility silently suffer "b" and "0b" as valid binary
5442            numbers. */
5443         if (len >= 1) {
5444             if (s[0] == 'b') {
5445                 s++;
5446                 len--;
5447             }
5448             else if (len >= 2 && s[0] == '0' && s[1] == 'b') {
5449                 s+=2;
5450                 len-=2;
5451             }
5452         }
5453     }
5454
5455     for (; len-- && *s; s++) {
5456         char bit = *s;
5457         if (bit == '0' || bit == '1') {
5458             /* Write it in this wonky order with a goto to attempt to get the
5459                compiler to make the common case integer-only loop pretty tight.
5460                With gcc seems to be much straighter code than old scan_bin.  */
5461           redo:
5462             if (!overflowed) {
5463                 if (value <= max_div_2) {
5464                     value = (value << 1) | (bit - '0');
5465                     continue;
5466                 }
5467                 /* Bah. We're just overflowed.  */
5468                 warn("Integer overflow in binary number");
5469                 overflowed = TRUE;
5470                 value_nv = (NV) value;
5471             }
5472             value_nv *= 2.0;
5473             /* If an NV has not enough bits in its mantissa to
5474              * represent a UV this summing of small low-order numbers
5475              * is a waste of time (because the NV cannot preserve
5476              * the low-order bits anyway): we could just remember when
5477              * did we overflow and in the end just multiply value_nv by the
5478              * right amount. */
5479             value_nv += (NV)(bit - '0');
5480             continue;
5481         }
5482         if (bit == '_' && len && allow_underscores && (bit = s[1])
5483             && (bit == '0' || bit == '1'))
5484             {
5485                 --len;
5486                 ++s;
5487                 goto redo;
5488             }
5489         if (!(*flags & PERL_SCAN_SILENT_ILLDIGIT))
5490             warn("Illegal binary digit '%c' ignored", *s);
5491         break;
5492     }
5493     
5494     if (   ( overflowed && value_nv > 4294967295.0)
5495 #if UVSIZE > 4
5496         || (!overflowed && value > 0xffffffff  )
5497 #endif
5498         ) {
5499         warn("Binary number > 0b11111111111111111111111111111111 non-portable");
5500     }
5501     *len_p = s - start;
5502     if (!overflowed) {
5503         *flags = 0;
5504         return value;
5505     }
5506     *flags = PERL_SCAN_GREATER_THAN_UV_MAX;
5507     if (result)
5508         *result = value_nv;
5509     return UV_MAX;
5510 }
5511 #endif
5512 #endif
5513
5514 #ifndef grok_hex
5515 #if defined(NEED_grok_hex)
5516 static UV DPPP_(my_grok_hex)(pTHX_ char *start, STRLEN *len_p, I32 *flags, NV *result);
5517 static
5518 #else
5519 extern UV DPPP_(my_grok_hex)(pTHX_ char *start, STRLEN *len_p, I32 *flags, NV *result);
5520 #endif
5521
5522 #ifdef grok_hex
5523 #  undef grok_hex
5524 #endif
5525 #define grok_hex(a,b,c,d) DPPP_(my_grok_hex)(aTHX_ a,b,c,d)
5526 #define Perl_grok_hex DPPP_(my_grok_hex)
5527
5528 #if defined(NEED_grok_hex) || defined(NEED_grok_hex_GLOBAL)
5529 UV
5530 DPPP_(my_grok_hex)(pTHX_ char *start, STRLEN *len_p, I32 *flags, NV *result)
5531 {
5532     const char *s = start;
5533     STRLEN len = *len_p;
5534     UV value = 0;
5535     NV value_nv = 0;
5536
5537     const UV max_div_16 = UV_MAX / 16;
5538     bool allow_underscores = *flags & PERL_SCAN_ALLOW_UNDERSCORES;
5539     bool overflowed = FALSE;
5540     const char *xdigit;
5541
5542     if (!(*flags & PERL_SCAN_DISALLOW_PREFIX)) {
5543         /* strip off leading x or 0x.
5544            for compatibility silently suffer "x" and "0x" as valid hex numbers.
5545         */
5546         if (len >= 1) {
5547             if (s[0] == 'x') {
5548                 s++;
5549                 len--;
5550             }
5551             else if (len >= 2 && s[0] == '0' && s[1] == 'x') {
5552                 s+=2;
5553                 len-=2;
5554             }
5555         }
5556     }
5557
5558     for (; len-- && *s; s++) {
5559         xdigit = strchr((char *) PL_hexdigit, *s);
5560         if (xdigit) {
5561             /* Write it in this wonky order with a goto to attempt to get the
5562                compiler to make the common case integer-only loop pretty tight.
5563                With gcc seems to be much straighter code than old scan_hex.  */
5564           redo:
5565             if (!overflowed) {
5566                 if (value <= max_div_16) {
5567                     value = (value << 4) | ((xdigit - PL_hexdigit) & 15);
5568                     continue;
5569                 }
5570                 warn("Integer overflow in hexadecimal number");
5571                 overflowed = TRUE;
5572                 value_nv = (NV) value;
5573             }
5574             value_nv *= 16.0;
5575             /* If an NV has not enough bits in its mantissa to
5576              * represent a UV this summing of small low-order numbers
5577              * is a waste of time (because the NV cannot preserve
5578              * the low-order bits anyway): we could just remember when
5579              * did we overflow and in the end just multiply value_nv by the
5580              * right amount of 16-tuples. */
5581             value_nv += (NV)((xdigit - PL_hexdigit) & 15);
5582             continue;
5583         }
5584         if (*s == '_' && len && allow_underscores && s[1]
5585                 && (xdigit = strchr((char *) PL_hexdigit, s[1])))
5586             {
5587                 --len;
5588                 ++s;
5589                 goto redo;
5590             }
5591         if (!(*flags & PERL_SCAN_SILENT_ILLDIGIT))
5592             warn("Illegal hexadecimal digit '%c' ignored", *s);
5593         break;
5594     }
5595     
5596     if (   ( overflowed && value_nv > 4294967295.0)
5597 #if UVSIZE > 4
5598         || (!overflowed && value > 0xffffffff  )
5599 #endif
5600         ) {
5601         warn("Hexadecimal number > 0xffffffff non-portable");
5602     }
5603     *len_p = s - start;
5604     if (!overflowed) {
5605         *flags = 0;
5606         return value;
5607     }
5608     *flags = PERL_SCAN_GREATER_THAN_UV_MAX;
5609     if (result)
5610         *result = value_nv;
5611     return UV_MAX;
5612 }
5613 #endif
5614 #endif
5615
5616 #ifndef grok_oct
5617 #if defined(NEED_grok_oct)
5618 static UV DPPP_(my_grok_oct)(pTHX_ char *start, STRLEN *len_p, I32 *flags, NV *result);
5619 static
5620 #else
5621 extern UV DPPP_(my_grok_oct)(pTHX_ char *start, STRLEN *len_p, I32 *flags, NV *result);
5622 #endif
5623
5624 #ifdef grok_oct
5625 #  undef grok_oct
5626 #endif
5627 #define grok_oct(a,b,c,d) DPPP_(my_grok_oct)(aTHX_ a,b,c,d)
5628 #define Perl_grok_oct DPPP_(my_grok_oct)
5629
5630 #if defined(NEED_grok_oct) || defined(NEED_grok_oct_GLOBAL)
5631 UV
5632 DPPP_(my_grok_oct)(pTHX_ char *start, STRLEN *len_p, I32 *flags, NV *result)
5633 {
5634     const char *s = start;
5635     STRLEN len = *len_p;
5636     UV value = 0;
5637     NV value_nv = 0;
5638
5639     const UV max_div_8 = UV_MAX / 8;
5640     bool allow_underscores = *flags & PERL_SCAN_ALLOW_UNDERSCORES;
5641     bool overflowed = FALSE;
5642
5643     for (; len-- && *s; s++) {
5644          /* gcc 2.95 optimiser not smart enough to figure that this subtraction
5645             out front allows slicker code.  */
5646         int digit = *s - '0';
5647         if (digit >= 0 && digit <= 7) {
5648             /* Write it in this wonky order with a goto to attempt to get the
5649                compiler to make the common case integer-only loop pretty tight.
5650             */
5651           redo:
5652             if (!overflowed) {
5653                 if (value <= max_div_8) {
5654                     value = (value << 3) | digit;
5655                     continue;
5656                 }
5657                 /* Bah. We're just overflowed.  */
5658                 warn("Integer overflow in octal number");
5659                 overflowed = TRUE;
5660                 value_nv = (NV) value;
5661             }
5662             value_nv *= 8.0;
5663             /* If an NV has not enough bits in its mantissa to
5664              * represent a UV this summing of small low-order numbers
5665              * is a waste of time (because the NV cannot preserve
5666              * the low-order bits anyway): we could just remember when
5667              * did we overflow and in the end just multiply value_nv by the
5668              * right amount of 8-tuples. */
5669             value_nv += (NV)digit;
5670             continue;
5671         }
5672         if (digit == ('_' - '0') && len && allow_underscores
5673             && (digit = s[1] - '0') && (digit >= 0 && digit <= 7))
5674             {
5675                 --len;
5676                 ++s;
5677                 goto redo;
5678             }
5679         /* Allow \octal to work the DWIM way (that is, stop scanning
5680          * as soon as non-octal characters are seen, complain only iff
5681          * someone seems to want to use the digits eight and nine). */
5682         if (digit == 8 || digit == 9) {
5683             if (!(*flags & PERL_SCAN_SILENT_ILLDIGIT))
5684                 warn("Illegal octal digit '%c' ignored", *s);
5685         }
5686         break;
5687     }
5688     
5689     if (   ( overflowed && value_nv > 4294967295.0)
5690 #if UVSIZE > 4
5691         || (!overflowed && value > 0xffffffff  )
5692 #endif
5693         ) {
5694         warn("Octal number > 037777777777 non-portable");
5695     }
5696     *len_p = s - start;
5697     if (!overflowed) {
5698         *flags = 0;
5699         return value;
5700     }
5701     *flags = PERL_SCAN_GREATER_THAN_UV_MAX;
5702     if (result)
5703         *result = value_nv;
5704     return UV_MAX;
5705 }
5706 #endif
5707 #endif
5708
5709 #endif /* _P_P_PORTABILITY_H_ */
5710
5711 /* End of File ppport.h */