2 # Create the export list for perl.
4 # Needed by WIN32 and OS/2 for creating perl.dll,
5 # and by AIX for creating libperl.a when -Dusershrplib is in effect,
6 # and by MacOS Classic.
8 # reads global.sym, pp.sym, perlvars.h, intrpvar.h, thrdvar.h, config.h
9 # On OS/2 reads miniperl.map and the previous version of perl5.def as well
16 if ($flag =~ s/^CC_FLAGS=/ /) {
17 for my $fflag ($flag =~ /(?:^|\s)-D(\S+)/g) {
18 $fflag .= '=1' unless $fflag =~ /^(\w+)=/;
19 $define{$1} = $2 if $fflag =~ /^(\w+)=(.+)$/;
23 $define{$1} = 1 if ($flag =~ /^-D(\w+)$/);
24 $define{$1} = $2 if ($flag =~ /^-D(\w+)=(.+)$/);
25 $CCTYPE = $1 if ($flag =~ /^CCTYPE=(\w+)$/);
26 $PLATFORM = $1 if ($flag =~ /^PLATFORM=(\w+)$/);
27 if ($PLATFORM eq 'netware') {
28 $FILETYPE = $1 if ($flag =~ /^FILETYPE=(\w+)$/);
32 my @PLATFORM = qw(aix win32 wince os2 MacOS netware);
34 @PLATFORM{@PLATFORM} = ();
36 defined $PLATFORM || die "PLATFORM undefined, must be one of: @PLATFORM\n";
37 exists $PLATFORM{$PLATFORM} || die "PLATFORM must be one of: @PLATFORM\n";
39 my %exportperlmalloc =
41 Perl_malloc => "malloc",
43 Perl_realloc => "realloc",
44 Perl_calloc => "calloc",
47 my $exportperlmalloc = $PLATFORM eq 'os2';
49 my $config_sh = "config.sh";
50 my $config_h = "config.h";
51 my $thrdvar_h = "thrdvar.h";
52 my $intrpvar_h = "intrpvar.h";
53 my $perlvars_h = "perlvars.h";
54 my $global_sym = "global.sym";
55 my $pp_sym = "pp.sym";
56 my $globvar_sym = "globvar.sym";
57 my $perlio_sym = "perlio.sym";
60 if ($PLATFORM eq 'aix') {
63 elsif ($PLATFORM =~ /^win(?:32|ce)$/ || $PLATFORM eq 'netware') {
64 $CCTYPE = "MSVC" unless defined $CCTYPE;
65 foreach ($thrdvar_h, $intrpvar_h, $perlvars_h, $global_sym,
66 $pp_sym, $globvar_sym, $perlio_sym) {
70 elsif ($PLATFORM eq 'MacOS') {
71 foreach ($thrdvar_h, $intrpvar_h, $perlvars_h, $global_sym,
72 $pp_sym, $globvar_sym, $perlio_sym) {
77 unless ($PLATFORM eq 'win32' || $PLATFORM eq 'wince' || $PLATFORM eq 'MacOS' || $PLATFORM eq 'netware') {
78 open(CFG,$config_sh) || die "Cannot open $config_sh: $!\n";
80 if (/^(?:ccflags|optimize)='(.+)'$/) {
82 $define{$1} = 1 while /-D(\w+)/g;
84 if (/^(d_(?:mmap|sigaction))='(.+)'$/) {
87 if ($PLATFORM eq 'os2') {
88 $CONFIG_ARGS = $1 if /^config_args='(.+)'$/;
89 $ARCHNAME = $1 if /^archname='(.+)'$/;
90 $PATCHLEVEL = $1 if /^perl_patchlevel='(.+)'$/;
95 if ($PLATFORM eq 'win32' || $PLATFORM eq 'wince') {
96 open(CFG,"<..\\$config_sh") || die "Cannot open ..\\$config_sh: $!\n";
97 if ((join '', <CFG>) =~ /^static_ext='(.*)'$/m) {
103 open(CFG,$config_h) || die "Cannot open $config_h: $!\n";
105 $define{$1} = 1 if /^\s*#\s*define\s+(MYMALLOC)\b/;
106 $define{$1} = 1 if /^\s*#\s*define\s+(MULTIPLICITY)\b/;
107 $define{$1} = 1 if /^\s*#\s*define\s+(PERL_\w+)\b/;
108 $define{$1} = 1 if /^\s*#\s*define\s+(USE_\w+)\b/;
112 # perl.h logic duplication begins
114 if ($define{PERL_IMPLICIT_SYS}) {
115 $define{PL_OP_SLAB_ALLOC} = 1;
118 if ($define{USE_ITHREADS}) {
119 if (!$define{MULTIPLICITY}) {
120 $define{MULTIPLICITY} = 1;
124 $define{PERL_IMPLICIT_CONTEXT} ||=
125 $define{USE_ITHREADS} ||
126 $define{MULTIPLICITY} ;
128 if ($define{USE_ITHREADS} && $PLATFORM ne 'win32' && $^O ne 'darwin') {
129 $define{USE_REENTRANT_API} = 1;
132 # perl.h logic duplication ends
136 if ($PLATFORM =~ /^win(?:32|ce)$/) {
137 warn join(' ',keys %define)."\n";
138 ($dll = ($define{PERL_DLL} || "perl59")) =~ s/\.dll$//i;
139 print "LIBRARY $dll\n";
140 print "DESCRIPTION 'Perl interpreter'\n";
142 if ($define{PERL_IMPLICIT_SYS}) {
143 output_symbol("perl_get_host_info");
144 output_symbol("perl_alloc_override");
146 if ($define{USE_ITHREADS} and $define{PERL_IMPLICIT_SYS}) {
147 output_symbol("perl_clone_host");
150 elsif ($PLATFORM eq 'os2') {
151 if (open my $fh, '<', 'perl5.def') {
153 last if /^\s*EXPORTS\b/;
156 $ordinal{$1} = $2 if /^\s*"(\w+)"\s*(?:=\s*"\w+"\s*)?\@(\d+)\s*$/;
157 # This allows skipping ordinals which were used in older versions
158 $sym_ord = $1 if /^\s*;\s*LAST_ORDINAL\s*=\s*(\d+)\s*$/;
160 $sym_ord < $_ and $sym_ord = $_ for values %ordinal; # Take the max
162 ($v = $]) =~ s/(\d\.\d\d\d)(\d\d)$/$1_$2/;
163 $v .= '-thread' if $ARCHNAME =~ /-thread/;
164 ($dll = $define{PERL_DLL}) =~ s/\.dll$//i;
165 $v .= "\@$PATCHLEVEL" if $PATCHLEVEL;
166 $d = "DESCRIPTION '\@#perl5-porters\@perl.org:$v#\@ Perl interpreter, configured as $CONFIG_ARGS'";
167 $d = substr($d, 0, 249) . "...'" if length $d > 253;
169 LIBRARY '$dll' INITINSTANCE TERMINSTANCE
173 DATA LOADONCALL NONSHARED MULTIPLE
177 elsif ($PLATFORM eq 'aix') {
182 if ($OSVER > 4 || ($OSVER == 4 && $OSREL >= 3)) {
188 elsif ($PLATFORM eq 'netware') {
189 if ($FILETYPE eq 'def') {
190 print "LIBRARY perl59\n";
191 print "DESCRIPTION 'Perl interpreter for NetWare'\n";
194 if ($define{PERL_IMPLICIT_SYS}) {
195 output_symbol("perl_get_host_info");
196 output_symbol("perl_alloc_override");
197 output_symbol("perl_clone_host");
206 foreach my $symbol (@$list) {
213 foreach my $symbol (@$list) {
214 my $skipsym = $symbol;
216 if ($define{MULTIPLICITY}) {
217 $skipsym =~ s/^Perl_[GIT](\w+)_ptr$/PL_$1/;
219 emit_symbol($symbol) unless exists $skip{$skipsym};
223 if ($PLATFORM eq 'win32') {
248 Perl_init_thread_intern
281 if ($PLATFORM eq 'wince') {
297 PL_collation_standard
325 Perl_init_thread_intern
351 elsif ($PLATFORM eq 'aix') {
370 Perl_sys_intern_clear
379 elsif ($PLATFORM eq 'os2') {
424 XS_Cwd_extLibpath_set
428 XS_Cwd_sys_is_absolute
429 XS_Cwd_sys_is_relative
431 XS_DynaLoader_mod2fname
432 XS_File__Copy_syscopy
436 Perl_Process_Messages
447 emit_symbols([qw(os2_cond_wait
452 if $define{'USE_5005THREADS'} or $define{'USE_ITHREADS'};
454 elsif ($PLATFORM eq 'MacOS') {
478 Perl_sys_intern_clear
482 elsif ($PLATFORM eq 'netware') {
507 Perl_init_thread_intern
532 Perl_sys_intern_clear
540 Perl_PerlIO_setlinebuf
541 Perl_PerlIO_set_ptrcnt
547 Perl_PerlIO_get_bufsiz
560 unless ($define{'DEBUGGING'}) {
575 if ($define{'PERL_IMPLICIT_CONTEXT'}) {
581 if ($define{'PERL_IMPLICIT_SYS'}) {
602 unless ($define{'PERL_OLD_COPY_ON_WRITE'}) {
609 unless ($define{'USE_REENTRANT_API'}) {
615 if ($define{'MYMALLOC'}) {
624 if ($define{'USE_ITHREADS'}) {
646 unless ($define{'PERL_MALLOC_WRAP'}) {
652 unless ($define{'USE_ITHREADS'}) {
658 # USE_5005THREADS symbols. Kept as reference for easier removal
677 Perl_new_struct_thread
678 Perl_per_thread_magicals
686 unless ($define{'USE_ITHREADS'}) {
695 PL_sharedsv_space_mutex
725 Perl_sharedsv_thrcnt_dec
726 Perl_sharedsv_thrcnt_inc
728 Perl_stashpv_hvname_match
732 unless ($define{'PERL_IMPLICIT_CONTEXT'}) {
738 Perl_load_module_nocontext
741 Perl_warner_nocontext
742 Perl_newSVpvf_nocontext
743 Perl_sv_catpvf_nocontext
744 Perl_sv_setpvf_nocontext
745 Perl_sv_catpvf_mg_nocontext
746 Perl_sv_setpvf_mg_nocontext
750 unless ($define{'PERL_IMPLICIT_SYS'}) {
757 unless ($define{'FAKE_THREADS'}) {
758 skip_symbols [qw(PL_curthr)];
761 unless ($define{'PL_OP_SLAB_ALLOC'}) {
771 unless ($define{'THREADS_HAVE_PIDS'}) {
772 skip_symbols [qw(PL_ppid)];
775 unless ($define{'PERL_NEED_APPCTX'}) {
781 unless ($define{'PERL_NEED_TIMESBASE'}) {
787 unless ($define{'DEBUG_LEAKING_SCALARS_FORK_DUMP'}) {
792 unless ($define{'PERL_DONT_CREATE_GVSV'}) {
798 unless ($define{'d_mmap'}) {
804 if ($define{'d_sigaction'}) {
811 # VMS does its own thing for these symbols.
812 skip_symbols [qw(PL_sig_handlers_initted
819 my $proc = shift || sub { "PL_$_[2]" };
820 open(VARS,$file) || die "Cannot open $file: $!\n";
823 # All symbols have a Perl_ prefix because that's what embed.h
824 # sticks in front of them. The A?I?S?C? is strictly speaking
826 push(@syms, &$proc($1,$2,$3)) if (/\bPERLVAR(A?I?S?C?)\(([IGT])(\w+)/);
832 if ($define{'PERL_GLOBAL_STRUCT'}) {
833 my $global = readvar($perlvars_h);
834 skip_symbols $global;
835 emit_symbol('Perl_GetVars');
836 emit_symbols [qw(PL_Vars PL_VarsPtr)] unless $CCTYPE eq 'GCC';
838 skip_symbols [qw(Perl_init_global_struct Perl_free_global_struct)];
841 # functions from *.sym files
843 my @syms = ($global_sym, $globvar_sym); # $pp_sym is not part of the API
845 # Symbols that are the public face of the PerlIO layers implementation
846 # These are in _addition to_ the public face of the abstraction
847 # and need to be exported to allow XS modules to implement layers
861 PerlIOBase_setlinebuf
904 Perl_PerlIO_get_bufsiz
910 Perl_PerlIO_set_ptrcnt
911 Perl_PerlIO_setlinebuf
919 if ($PLATFORM eq 'netware') {
920 push(@layer_syms,'PL_def_layerlist','PL_known_layers','PL_perlio');
923 if ($define{'USE_PERLIO'}) {
924 # Export the symols that make up the PerlIO abstraction, regardless
925 # of its implementation - read from a file
926 push @syms, $perlio_sym;
928 # This part is then dependent on how the abstraction is implemented
929 if ($define{'USE_SFIO'}) {
930 # Old legacy non-stdio "PerlIO"
931 skip_symbols \@layer_syms;
932 skip_symbols [qw(perlsio_binmode)];
933 # SFIO defines most of the PerlIO routines as macros
934 # So undo most of what $perlio_sym has just done - d'oh !
935 # Perhaps it would be better to list the ones which do exist
988 Perl_PerlIO_get_bufsiz
994 Perl_PerlIO_set_ptrcnt
995 Perl_PerlIO_setlinebuf
1008 # PerlIO with layers - export implementation
1009 emit_symbols \@layer_syms;
1010 emit_symbols [qw(perlsio_binmode)];
1014 # Skip the PerlIO layer symbols - although
1015 # nothing should have exported them anyway.
1016 skip_symbols \@layer_syms;
1017 skip_symbols [qw(perlsio_binmode)];
1018 skip_symbols [qw(PL_def_layerlist PL_known_layers PL_perlio)];
1020 # Also do NOT add abstraction symbols from $perlio_sym
1021 # abstraction is done as #define to stdio
1022 # Remaining remnants that _may_ be functions
1023 # are handled in <DATA>
1026 for my $syms (@syms) {
1027 open (GLOBAL, "<$syms") || die "failed to open $syms: $!\n";
1029 next if (!/^[A-Za-z]/);
1030 # Functions have a Perl_ prefix
1031 # Variables have a PL_ prefix
1033 my $symbol = ($syms =~ /var\.sym$/i ? "PL_" : "");
1035 emit_symbol($symbol) unless exists $skip{$symbol};
1042 if ($define{'MULTIPLICITY'}) {
1043 for my $f ($perlvars_h, $intrpvar_h, $thrdvar_h) {
1044 my $glob = readvar($f, sub { "Perl_" . $_[1] . $_[2] . "_ptr" });
1047 # XXX AIX seems to want the perlvars.h symbols, for some reason
1048 if ($PLATFORM eq 'aix' or $PLATFORM eq 'os2') { # OS/2 needs PL_thr_key
1049 my $glob = readvar($perlvars_h);
1054 unless ($define{'PERL_GLOBAL_STRUCT'}) {
1055 my $glob = readvar($perlvars_h);
1058 unless ($define{'MULTIPLICITY'}) {
1059 my $glob = readvar($intrpvar_h);
1062 unless ($define{'MULTIPLICITY'}) {
1063 my $glob = readvar($thrdvar_h);
1071 return if $symbol !~ /^[A-Za-z_]/;
1072 return if $symbol =~ /^\#/;
1075 return if exists $skip{$symbol};
1076 emit_symbol($symbol);
1083 if ($PLATFORM =~ /^win(?:32|ce)$/) {
1084 foreach my $symbol (qw(
1146 win32_getprotobyname
1147 win32_getprotobynumber
1176 win32_open_osfhandle
1246 try_symbol($symbol);
1248 if ($CCTYPE eq "BORLAND") {
1249 try_symbol('_matherr');
1252 elsif ($PLATFORM eq 'os2') {
1253 open MAP, 'miniperl.map' or die 'Cannot read miniperl.map';
1254 /^\s*[\da-f:]+\s+(\w+)/i and $mapped{$1}++ foreach <MAP>;
1255 close MAP or die 'Cannot close miniperl.map';
1257 @missing = grep { !exists $mapped{$_} }
1259 @missing = grep { !exists $exportperlmalloc{$_} } @missing;
1260 delete $export{$_} foreach @missing;
1262 elsif ($PLATFORM eq 'MacOS') {
1263 open MACSYMS, 'macperl.sym' or die 'Cannot read macperl.sym';
1271 elsif ($PLATFORM eq 'netware') {
1272 foreach my $symbol (qw(
1399 fnInsertHashListAddrs
1410 try_symbol($symbol);
1414 # records of type boot_module for statically linked modules (except Dynaloader)
1415 $static_ext =~ s/\//__/g;
1416 $static_ext =~ s/\bDynaLoader\b//;
1417 my @stat_mods = map {"boot_$_"} grep {/\S/} split /\s+/, $static_ext;
1418 foreach my $symbol (@stat_mods)
1420 try_symbol($symbol);
1423 # Now all symbols should be defined because
1424 # next we are going to output them.
1426 foreach my $symbol (sort keys %export) {
1427 output_symbol($symbol);
1430 if ($PLATFORM eq 'os2') {
1435 Perl_OS2_handler_install
1437 ; LAST_ORDINAL=$sym_ord
1444 $export{$symbol} = 1;
1449 if ($PLATFORM =~ /^win(?:32|ce)$/) {
1450 $symbol = "_$symbol" if $CCTYPE eq 'BORLAND';
1451 print "\t$symbol\n";
1452 # XXX: binary compatibility between compilers is an exercise
1453 # in frustration :-(
1454 # if ($CCTYPE eq "BORLAND") {
1455 # # workaround Borland quirk by exporting both the straight
1456 # # name and a name with leading underscore. Note the
1457 # # alias *must* come after the symbol itself, if both
1458 # # are to be exported. (Linker bug?)
1459 # print "\t_$symbol\n";
1460 # print "\t$symbol = _$symbol\n";
1462 # elsif ($CCTYPE eq 'GCC') {
1463 # # Symbols have leading _ whole process is $%@"% slow
1464 # # so skip aliases for now
1465 # nprint "\t$symbol\n";
1468 # # for binary coexistence, export both the symbol and
1469 # # alias with leading underscore
1470 # print "\t$symbol\n";
1471 # print "\t_$symbol = $symbol\n";
1474 elsif ($PLATFORM eq 'os2') {
1475 printf qq( %-31s \@%s\n),
1476 qq("$symbol"), $ordinal{$symbol} || ++$sym_ord;
1477 printf qq( %-31s \@%s\n),
1478 qq("$exportperlmalloc{$symbol}" = "$symbol"),
1479 $ordinal{$exportperlmalloc{$symbol}} || ++$sym_ord
1480 if $exportperlmalloc and exists $exportperlmalloc{$symbol};
1482 elsif ($PLATFORM eq 'aix' || $PLATFORM eq 'MacOS') {
1485 elsif ($PLATFORM eq 'netware') {
1486 print "\t$symbol,\n";
1492 # extra globals not included above.
1503 # Oddities from PerlIO