22#
33# Create the export list for perl.
44#
5+ # WARNING: This file duplicates information from some of its source files, and
6+ # must be kept in sync with changes to them.
7+ #
58# Needed by WIN32 and OS/2 for creating perl.dll,
69# and by AIX for creating libperl.a when -Duseshrplib is in effect,
710# and by VMS for creating perlshr.exe.
1922# perlvars.h
2023# regen/opcodes
2124#
22- # plus long lists of function names hard-coded directly in this script.
25+ # plus long lists of function names (sadly) hard-coded directly in this script.
2326#
2427# Writes the result to STDOUT.
2528#
3740
3841my $fold ;
3942my %ARGS ;
40- my %define ;
43+ our %define ;
4144BEGIN {
4245 %ARGS = (CCTYPE => ' MSVC' , TARG_DIR => ' ' );
4346
@@ -273,15 +276,6 @@ sub readvar {
273276if (PLATFORM ne ' os2' ) {
274277 ++$skip {$_ } foreach qw(
275278 PL_opsave
276- Perl_dump_fds
277- Perl_my_bcopy
278- Perl_my_bzero
279- Perl_my_chsize
280- Perl_my_htonl
281- Perl_my_memcmp
282- Perl_my_memset
283- Perl_my_ntohl
284- Perl_my_swap
285279 ) ;
286280 if (PLATFORM eq ' vms' ) {
287281 ++$skip {PL_statusvalue_posix };
@@ -310,48 +304,16 @@ sub readvar {
310304 PL_sig_ignoring
311305 PL_sig_defaulting
312306 ) ;
313- if (PLATFORM ne ' win32' ) {
314- ++$skip {$_ } foreach qw(
315- Perl_do_spawn
316- Perl_do_spawn_nowait
317- Perl_do_aspawn
318- ) ;
319- }
320- }
321-
322- if (PLATFORM ne ' win32' ) {
323- ++$skip {$_ } foreach qw(
324- Perl_get_context
325- Perl_get_win32_message_utf8ness
326- Perl_Win_utf8_string_to_wstring
327- Perl_Win_wstring_to_utf8_string
328- ) ;
329- }
330-
331- unless ($define {UNLINK_ALL_VERSIONS }) {
332- ++$skip {Perl_unlnk };
333307}
334308
335309unless ($define {' DEBUGGING' }) {
336310 ++$skip {$_ } foreach qw(
337- Perl_debop
338- Perl_debprofdump
339- Perl_debstack
340- Perl_debstackptrs
341- Perl_pad_sv
342- Perl_pad_setsv
343- Perl_set_padlist
344- Perl_hv_assert
345311 PL_watchaddr
346312 PL_watchok
347313 ) ;
348314}
349315
350316if ($define {' PERL_IMPLICIT_SYS' }) {
351- ++$skip {$_ } foreach qw(
352- Perl_my_popen
353- Perl_my_pclose
354- ) ;
355317 ++$export {$_ } foreach qw( perl_get_host_info perl_alloc_override) ;
356318 ++$export {perl_clone_host } if $define {USE_ITHREADS };
357319}
@@ -366,8 +328,6 @@ sub readvar {
366328 PL_Dir
367329 PL_Sock
368330 PL_Proc
369- perl_alloc_using
370- perl_clone_using
371331 ) ;
372332}
373333
@@ -385,10 +345,6 @@ sub readvar {
385345
386346if ($define {' MYMALLOC' }) {
387347 try_symbols(qw(
388- Perl_dump_mstats
389- Perl_get_mstats
390- Perl_strdup
391- Perl_putenv
392348 MallocCfg_ptr
393349 MallocCfgP_ptr
394350 ) );
@@ -399,8 +355,6 @@ sub readvar {
399355else {
400356 ++$skip {$_ } foreach qw(
401357 PL_malloc_mutex
402- Perl_dump_mstats
403- Perl_get_mstats
404358 MallocCfg_ptr
405359 MallocCfgP_ptr
406360 ) ;
@@ -431,39 +385,9 @@ sub readvar {
431385 PL_stashpadix
432386 PL_stashpadmax
433387 PL_veto_switch_non_tTHX_context
434- Perl_alloccopstash
435- Perl_allocfilegv
436- Perl_clone_params_del
437- Perl_clone_params_new
438- Perl_parser_dup
439- Perl_dirp_dup
440- Perl_cx_dup
441- Perl_si_dup
442- Perl_any_dup
443- Perl_ss_dup
444- Perl_fp_dup
445- Perl_gp_dup
446- Perl_he_dup
447- Perl_mg_dup
448- Perl_re_dup_guts
449- Perl_sv_dup
450- Perl_sv_dup_inc
451- Perl_rvpv_dup
452- Perl_hek_dup
453- Perl_sys_intern_dup
454- perl_clone
455- perl_clone_using
456- Perl_stashpv_hvname_match
457- Perl_regdupe_internal
458- Perl_newPADOP
459388 ) ;
460389}
461390
462- unless ($define {' USE_THREADS' }) {
463- ++$skip {Perl_thread_locale_init };
464- ++$skip {Perl_thread_locale_term };
465- }
466-
467391if (!$define {USE_ITHREADS } || $define {WIN32 }) {
468392 ++$skip {PL_main_thread };
469393}
@@ -490,13 +414,6 @@ sub readvar {
490414 ) ;
491415}
492416
493- unless ($define {USE_PERL_SWITCH_LOCALE_CONTEXT })
494- {
495- ++$skip {$_ } foreach qw(
496- Perl_switch_locale_context
497- ) ;
498- }
499-
500417unless ($define {' MULTIPLICITY' }) {
501418 ++$skip {$_ } foreach qw(
502419 PL_cur_locale_obj
@@ -505,33 +422,9 @@ sub readvar {
505422 PL_my_cxt_size
506423 PL_my_cxt_keys
507424 PL_my_cxt_keys_size
508- Perl_croak_nocontext
509- Perl_die_nocontext
510- Perl_deb_nocontext
511- Perl_form_nocontext
512- Perl_load_module_nocontext
513- Perl_mess_nocontext
514- Perl_warn_nocontext
515- Perl_warner_nocontext
516- Perl_newSVpvf_nocontext
517- Perl_sv_catpvf_nocontext
518- Perl_sv_setpvf_nocontext
519- Perl_sv_catpvf_mg_nocontext
520- Perl_sv_setpvf_mg_nocontext
521- Perl_my_cxt_init
522- Perl_my_cxt_index
523425 ) ;
524426}
525427
526- unless ($define {' USE_DTRACE' }) {
527- ++$skip {$_ } foreach qw(
528- Perl_dtrace_probe_call
529- Perl_dtrace_probe_load
530- Perl_dtrace_probe_op
531- Perl_dtrace_probe_phase
532- ) ;
533- }
534-
535428unless ($define {' DEBUG_LEAKING_SCALARS' }) {
536429 ++$skip {PL_sv_serial };
537430}
@@ -540,10 +433,6 @@ sub readvar {
540433 ++$skip {PL_dumper_fd };
541434}
542435
543- unless ($define {' PERL_DONT_CREATE_GVSV' }) {
544- ++$skip {Perl_gv_SVadd };
545- }
546-
547436unless ($define {' PERL_USES_PL_PIDSTATUS' }) {
548437 ++$skip {PL_pidstatus };
549438}
@@ -555,11 +444,6 @@ sub readvar {
555444unless ($define {' PERL_MEM_LOG' }) {
556445 ++$skip {$_ } foreach qw(
557446 PL_mem_log
558- Perl_mem_log_alloc
559- Perl_mem_log_realloc
560- Perl_mem_log_free
561- Perl_mem_log_new_sv
562- Perl_mem_log_del_sv
563447 ) ;
564448}
565449
@@ -597,20 +481,13 @@ sub readvar {
597481 ++$skip {PL_sig_handlers_initted } unless !$define {HAS_SIGACTION };
598482}
599483
600- if ($define {' HAS_STRNLEN' })
601- {
602- ++$skip {Perl_my_strnlen };
603- }
604-
605484unless ($define {USE_LOCALE_COLLATE }) {
606485 ++$skip {$_ } foreach qw(
607486 PL_collation_ix
608487 PL_collation_name
609488 PL_collation_standard
610489 PL_collxfrm_base
611490 PL_collxfrm_mult
612- Perl_sv_collxfrm
613- Perl_sv_collxfrm_flags
614491 PL_strxfrm_NUL_replacement
615492 PL_strxfrm_is_behaved
616493 PL_strxfrm_max_cp
@@ -644,38 +521,17 @@ sub readvar {
644521 ) ;
645522 }
646523
647- unless ($define {' USE_C_BACKTRACE' }) {
648- ++$skip {Perl_get_c_backtrace_dump };
649- ++$skip {Perl_dump_c_backtrace };
650- }
651-
652524unless ($define {HAVE_INTERP_INTERN }) {
653525 ++$skip {$_ } foreach qw(
654- Perl_sys_intern_clear
655- Perl_sys_intern_dup
656- Perl_sys_intern_init
657526 PL_sys_intern
658527 ) ;
659528}
660-
661- if ($define {HAS_SIGNBIT }) {
662- ++$skip {Perl_signbit };
663- }
664-
665529++$skip {PL_op_exec_cnt }
666530 unless $define {PERL_TRACE_OPS };
667531
668532++$skip {PL_hash_chars }
669533 unless $define {PERL_USE_SINGLE_CHAR_HASH_CACHE };
670534
671- unless ($define {PERL_RC_STACK }) {
672- ++$skip {$_ } foreach qw(
673- Perl_pp_wrap
674- Perl_xs_wrap
675- Perl_runops_wrap
676- ) ;
677- }
678-
679535# functions from *.sym files
680536
681537my @syms = qw( globvar.sym) ;
@@ -768,12 +624,6 @@ sub readvar {
768624# PerlIO with layers - export implementation
769625try_symbols(@layer_syms , ' perlsio_binmode' );
770626
771-
772- unless ($define {' USE_QUADMATH' }) {
773- ++$skip {Perl_quadmath_format_needed };
774- ++$skip {Perl_quadmath_format_single };
775- }
776-
777627unless ($Config {d_mbrlen }) {
778628 ++$skip {PL_mbrlen_ps };
779629}
@@ -817,8 +667,66 @@ sub readvar {
817667 : ($flags =~ / O/ ) ? ' perl_'
818668 : " " ;
819669 $func = " $prefix$func " if $prefix && $func !~ / ^$prefix / ;
820- ++$export {$func } unless exists $skip {$func };
821670
671+ # If no conditions, export unconditionally.
672+ if ($entry -> {cond }-> @* == 0) {
673+ ++$export {$func } unless exists $skip {$func };
674+ }
675+ else {
676+ # Replace what the HeaderLine object thinks is the output line
677+ # with this trailing portion of a condition, with a marker
678+ $entry -> {line } =
679+ " ) { ++\$ export{$func } unless exists \$ skip{$func } }MAKEDEF_XXX" ;
680+
681+ # And get HeaderParser to surround that with any #if's that it
682+ # found when parsing embed.fnc
683+ my $hp = HeaderParser-> new();
684+ my $group = $hp -> group_content([$entry ]);
685+ my $lines = $hp -> lines_as_str($group );
686+
687+ # What that returns is something like
688+ # #if defined(USE_THREADS
689+ # ) { ++$export{foo} }MAKEDEF_XXX
690+ # #endif
691+
692+ # The #if may have continuations; get rid of them; they
693+ # confuse perl
694+ $lines =~ s / \\ $ // mxg ;
695+
696+ # Get rid of everything after the marker
697+ $lines =~ s / MAKEDEF_XXX .* // xs ;
698+
699+ # Convert the C conditional(s) to be like
700+ # $define{USE_THREADS}
701+ $lines =~ s : \b defined \( ( [^)]+ ) \) : \$ define{$1 }: xg ;
702+
703+ # And change the #if so that the result (on a single line)
704+ # looks like
705+ # if ($define{USE_THREADS} { ++export{foo}; }
706+ $lines =~ s / \# if / if ( / x ;
707+
708+ # Unfortunately, we have to deal specially with some functions
709+ # that have both the E and X flags.
710+ my $is_EX = $flags =~ tr / EX// > 1;
711+
712+ # These should be visible to Perl extensions, so they need to
713+ # be exported. And the regular expression handling is quite
714+ # special. That is turned into a special module that has
715+ # copies of the related .c files, and those need access to
716+ # certain functions that normally aren't enabled outside those
717+ # .c files. What we do here is to locally override these few
718+ # %define entries for just these flags. (It might be that
719+ # this could globally be done, but it is safer to restrict it
720+ # to here.)
721+ local $define {PERL_EXT } = 1 if $is_EX ;
722+ local $define {PERL_IN_REGCOMP_C } = 1 if $is_EX ;
723+ local $define {PERL_IN_REGEXEC_C } = 1 if $is_EX ;
724+ local $define {PERL_IN_REGCOMP_ANY } = 1 if $is_EX ;
725+
726+ # And eval to do the export depending on the conditions
727+ eval $lines ;
728+ die " eval '$lines ' failed: $@ " if $@ ;
729+ }
822730 }
823731 }
824732}
0 commit comments