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 if ($PLATFORM eq 'win32' or $PLATFORM eq 'wince' or $PLATFORM eq "aix") {
40 # Add the compile-time options that miniperl was built with to %define.
41 # On Win32 these are not the same options as perl itself will be built
42 # with since miniperl is built with a canned config (one of the win32/
43 # config_H.*) and none of the BUILDOPT's that are set in the makefiles,
44 # but they do include some #define's that are hard-coded in various
45 # source files and header files and don't include any BUILDOPT's that
46 # the user might have chosen to disable because the canned configs are
47 # minimal configs that don't include any of those options.
48 my $opts = ($PLATFORM eq 'wince' ? '-MCross' : ''); # for wince need Cross.pm to get Config.pm
49 my $config = `$^X $opts -Ilib -V`;
50 my($options) = $config =~ /^ Compile-time options: (.*?)\n^ \S/ms;
51 $options =~ s/\s+/ /g;
52 print STDERR "Options: ($options)\n";
53 foreach (split /\s+/, $options) {
58 my %exportperlmalloc =
60 Perl_malloc => "malloc",
62 Perl_realloc => "realloc",
63 Perl_calloc => "calloc",
66 my $exportperlmalloc = $PLATFORM eq 'os2';
68 my $config_sh = "config.sh";
69 my $config_h = "config.h";
70 my $thrdvar_h = "thrdvar.h";
71 my $intrpvar_h = "intrpvar.h";
72 my $perlvars_h = "perlvars.h";
73 my $global_sym = "global.sym";
74 my $pp_sym = "pp.sym";
75 my $globvar_sym = "globvar.sym";
76 my $perlio_sym = "perlio.sym";
79 if ($PLATFORM eq 'aix') {
82 elsif ($PLATFORM =~ /^win(?:32|ce)$/ || $PLATFORM eq 'netware') {
83 $CCTYPE = "MSVC" unless defined $CCTYPE;
84 foreach ($thrdvar_h, $intrpvar_h, $perlvars_h, $global_sym,
85 $pp_sym, $globvar_sym, $perlio_sym) {
89 elsif ($PLATFORM eq 'MacOS') {
90 foreach ($thrdvar_h, $intrpvar_h, $perlvars_h, $global_sym,
91 $pp_sym, $globvar_sym, $perlio_sym) {
96 unless ($PLATFORM eq 'win32' || $PLATFORM eq 'wince' || $PLATFORM eq 'MacOS' || $PLATFORM eq 'netware') {
97 open(CFG,$config_sh) || die "Cannot open $config_sh: $!\n";
99 if (/^(?:ccflags|optimize)='(.+)'$/) {
101 $define{$1} = 1 while /-D(\w+)/g;
103 if ($PLATFORM eq 'os2') {
104 $CONFIG_ARGS = $1 if /^config_args='(.+)'$/;
105 $ARCHNAME = $1 if /^archname='(.+)'$/;
106 $PATCHLEVEL = $1 if /^perl_patchlevel='(.+)'$/;
111 if ($PLATFORM eq 'win32' || $PLATFORM eq 'wince') {
112 open(CFG,"<..\\$config_sh") || die "Cannot open ..\\$config_sh: $!\n";
113 if ((join '', <CFG>) =~ /^static_ext='(.*)'$/m) {
119 open(CFG,$config_h) || die "Cannot open $config_h: $!\n";
121 $define{$1} = 1 if /^\s*#\s*define\s+(MYMALLOC)\b/;
122 $define{$1} = 1 if /^\s*#\s*define\s+(MULTIPLICITY)\b/;
123 $define{$1} = 1 if /^\s*#\s*define\s+(PERL_\w+)\b/;
124 $define{$1} = 1 if /^\s*#\s*define\s+(USE_\w+)\b/;
128 # perl.h logic duplication begins
130 if ($define{PERL_IMPLICIT_SYS}) {
131 $define{PL_OP_SLAB_ALLOC} = 1;
134 if ($define{USE_ITHREADS}) {
135 if (!$define{MULTIPLICITY}) {
136 $define{MULTIPLICITY} = 1;
140 $define{PERL_IMPLICIT_CONTEXT} ||=
141 $define{USE_ITHREADS} ||
142 $define{USE_5005THREADS} ||
143 $define{MULTIPLICITY} ;
145 if ($define{USE_ITHREADS} && $PLATFORM ne 'win32' && $^O ne 'darwin') {
146 $define{USE_REENTRANT_API} = 1;
149 # perl.h logic duplication ends
153 print STDERR "Defines: (" . join(' ', sort keys %define) . ")\n";
155 if ($PLATFORM =~ /^win(?:32|ce)$/) {
156 ($dll = ($define{PERL_DLL} || "perl58")) =~ s/\.dll$//i;
157 print "LIBRARY $dll\n";
158 print "DESCRIPTION 'Perl interpreter'\n";
160 if ($define{PERL_IMPLICIT_SYS}) {
161 output_symbol("perl_get_host_info");
162 output_symbol("perl_alloc_override");
164 if ($define{USE_ITHREADS} and $define{PERL_IMPLICIT_SYS}) {
165 output_symbol("perl_clone_host");
168 elsif ($PLATFORM eq 'os2') {
169 if (open my $fh, '<', 'perl5.def') {
171 last if /^\s*EXPORTS\b/;
174 $ordinal{$1} = $2 if /^\s*"(\w+)"\s*(?:=\s*"\w+"\s*)?\@(\d+)\s*$/;
175 # This allows skipping ordinals which were used in older versions
176 $sym_ord = $1 if /^\s*;\s*LAST_ORDINAL\s*=\s*(\d+)\s*$/;
178 $sym_ord < $_ and $sym_ord = $_ for values %ordinal; # Take the max
180 ($v = $]) =~ s/(\d\.\d\d\d)(\d\d)$/$1_$2/;
181 $v .= '-thread' if $ARCHNAME =~ /-thread/;
182 ($dll = $define{PERL_DLL}) =~ s/\.dll$//i;
183 $v .= "\@$PATCHLEVEL" if $PATCHLEVEL;
184 $d = "DESCRIPTION '\@#perl5-porters\@perl.org:$v#\@ Perl interpreter, configured as $CONFIG_ARGS'";
185 $d = substr($d, 0, 249) . "...'" if length $d > 253;
187 LIBRARY '$dll' INITINSTANCE TERMINSTANCE
191 DATA LOADONCALL NONSHARED MULTIPLE
195 elsif ($PLATFORM eq 'aix') {
200 if ($OSVER > 4 || ($OSVER == 4 && $OSREL >= 3)) {
206 elsif ($PLATFORM eq 'netware') {
207 if ($FILETYPE eq 'def') {
208 print "LIBRARY perl58\n";
209 print "DESCRIPTION 'Perl interpreter for NetWare'\n";
212 if ($define{PERL_IMPLICIT_SYS}) {
213 output_symbol("perl_get_host_info");
214 output_symbol("perl_alloc_override");
215 output_symbol("perl_clone_host");
224 foreach my $symbol (@$list) {
231 foreach my $symbol (@$list) {
232 my $skipsym = $symbol;
234 if ($define{MULTIPLICITY}) {
235 $skipsym =~ s/^Perl_[GIT](\w+)_ptr$/PL_$1/;
237 emit_symbol($symbol) unless exists $skip{$skipsym};
241 if ($PLATFORM eq 'win32') {
265 Perl_init_thread_intern
299 if ($PLATFORM eq 'wince') {
314 PL_collation_standard
342 Perl_init_thread_intern
369 elsif ($PLATFORM eq 'aix') {
388 Perl_sys_intern_clear
397 elsif ($PLATFORM eq 'os2') {
442 XS_Cwd_extLibpath_set
446 XS_Cwd_sys_is_absolute
447 XS_Cwd_sys_is_relative
449 XS_DynaLoader_mod2fname
450 XS_File__Copy_syscopy
454 Perl_Process_Messages
465 emit_symbols([qw(os2_cond_wait
470 if $define{'USE_5005THREADS'} or $define{'USE_ITHREADS'};
472 elsif ($PLATFORM eq 'MacOS') {
496 Perl_sys_intern_clear
500 elsif ($PLATFORM eq 'netware') {
524 Perl_init_thread_intern
549 Perl_sys_intern_clear
557 Perl_PerlIO_setlinebuf
558 Perl_PerlIO_set_ptrcnt
564 Perl_PerlIO_get_bufsiz
577 unless ($define{'DEBUGGING'}) {
592 if ($define{'PERL_IMPLICIT_CONTEXT'}) {
598 if ($define{'PERL_IMPLICIT_SYS'}) {
619 unless ($define{'PERL_FLEXIBLE_EXCEPTIONS'}) {
623 Perl_vdefault_protect
627 unless ($define{'USE_REENTRANT_API'}) {
633 if ($define{'MYMALLOC'}) {
642 if ($define{'USE_5005THREADS'} || $define{'USE_ITHREADS'}) {
664 if ($define{'PERL_USE_SAFE_PUTENV'}) {
670 unless ($define{'USE_5005THREADS'} || $define{'USE_ITHREADS'}) {
676 unless ($define{'USE_5005THREADS'}) {
695 Perl_new_struct_thread
696 Perl_per_thread_magicals
705 unless ($define{'USE_ITHREADS'}) {
714 PL_sharedsv_space_mutex
743 Perl_sharedsv_thrcnt_dec
744 Perl_sharedsv_thrcnt_inc
746 Perl_stashpv_hvname_match
750 unless ($define{'PERL_IMPLICIT_CONTEXT'}) {
756 Perl_load_module_nocontext
759 Perl_warner_nocontext
760 Perl_newSVpvf_nocontext
761 Perl_sv_catpvf_nocontext
762 Perl_sv_setpvf_nocontext
763 Perl_sv_catpvf_mg_nocontext
764 Perl_sv_setpvf_mg_nocontext
768 unless ($define{'PERL_IMPLICIT_SYS'}) {
775 unless ($define{'FAKE_THREADS'}) {
776 skip_symbols [qw(PL_curthr)];
779 unless ($define{'PL_OP_SLAB_ALLOC'}) {
789 unless ($define{'THREADS_HAVE_PIDS'}) {
790 skip_symbols [qw(PL_ppid)];
793 unless ($define{'DEBUG_LEAKING_SCALARS_FORK_DUMP'}) {
798 unless ($define{'PERL_DONT_CREATE_GVSV'}) {
803 if ($define{'SPRINTF_RETURNS_STRLEN'}) {
809 unless ($define{'PERL_TRACK_MEMPOOL'}) {
811 PL_memory_debug_header
815 # Ideally this would also check SA_SIGINFO, but there doesn't seem to be an
816 # easy way to find that out from here. Fix it if it breaks because there is
817 # a platform where the logic here doesn't work, *and* the export lists have to
819 unless ($define{'d_sigaction'}) {
827 my $proc = shift || sub { "PL_$_[2]" };
828 open(VARS,$file) || die "Cannot open $file: $!\n";
831 # All symbols have a Perl_ prefix because that's what embed.h
832 # sticks in front of them.
833 push(@syms, &$proc($1,$2,$3)) if (/\bPERLVAR(A?I?C?)\(([IGT])(\w+)/);
839 if ($define{'USE_5005THREADS'}) {
840 my $thrd = readvar($thrdvar_h);
844 if ($define{'PERL_GLOBAL_STRUCT'}) {
845 my $global = readvar($perlvars_h);
846 skip_symbols $global;
847 emit_symbol('Perl_GetVars');
848 emit_symbols [qw(PL_Vars PL_VarsPtr)] unless $CCTYPE eq 'GCC';
851 # functions from *.sym files
853 my @syms = ($global_sym, $globvar_sym); # $pp_sym is not part of the API
855 # Symbols that are the public face of the PerlIO layers implementation
856 # These are in _addition to_ the public face of the abstraction
857 # and need to be exported to allow XS modules to implement layers
871 PerlIOBase_setlinebuf
914 Perl_PerlIO_get_bufsiz
920 Perl_PerlIO_set_ptrcnt
921 Perl_PerlIO_setlinebuf
929 if ($PLATFORM eq 'netware') {
930 push(@layer_syms,'PL_def_layerlist','PL_known_layers','PL_perlio');
933 if ($define{'USE_PERLIO'}) {
934 # Export the symols that make up the PerlIO abstraction, regardless
935 # of its implementation - read from a file
936 push @syms, $perlio_sym;
938 # This part is then dependent on how the abstraction is implemented
939 if ($define{'USE_SFIO'}) {
940 # Old legacy non-stdio "PerlIO"
941 skip_symbols \@layer_syms;
942 skip_symbols [qw(perlsio_binmode)];
943 # SFIO defines most of the PerlIO routines as macros
944 # So undo most of what $perlio_sym has just done - d'oh !
945 # Perhaps it would be better to list the ones which do exist
998 Perl_PerlIO_get_bufsiz
1004 Perl_PerlIO_set_ptrcnt
1005 Perl_PerlIO_setlinebuf
1018 # PerlIO with layers - export implementation
1019 emit_symbols \@layer_syms;
1020 emit_symbols [qw(perlsio_binmode)];
1024 # Skip the PerlIO layer symbols - although
1025 # nothing should have exported them any way
1026 skip_symbols \@layer_syms;
1027 skip_symbols [qw(perlsio_binmode)];
1028 skip_symbols [qw(PL_def_layerlist PL_known_layers PL_perlio)];
1030 # Also do NOT add abstraction symbols from $perlio_sym
1031 # abstraction is done as #define to stdio
1032 # Remaining remnants that _may_ be functions
1033 # are handled in <DATA>
1036 for my $syms (@syms) {
1037 open (GLOBAL, "<$syms") || die "failed to open $syms: $!\n";
1039 next if (!/^[A-Za-z]/);
1040 # Functions have a Perl_ prefix
1041 # Variables have a PL_ prefix
1043 my $symbol = ($syms =~ /var\.sym$/i ? "PL_" : "");
1045 emit_symbol($symbol) unless exists $skip{$symbol};
1052 if ($define{'MULTIPLICITY'}) {
1053 for my $f ($perlvars_h, $intrpvar_h, $thrdvar_h) {
1054 my $glob = readvar($f, sub { "Perl_" . $_[1] . $_[2] . "_ptr" });
1057 # XXX AIX seems to want the perlvars.h symbols, for some reason
1058 if ($PLATFORM eq 'aix' or $PLATFORM eq 'os2') { # OS/2 needs PL_thr_key
1059 my $glob = readvar($perlvars_h);
1064 unless ($define{'PERL_GLOBAL_STRUCT'}) {
1065 my $glob = readvar($perlvars_h);
1068 unless ($define{'MULTIPLICITY'}) {
1069 my $glob = readvar($intrpvar_h);
1072 unless ($define{'MULTIPLICITY'} || $define{'USE_5005THREADS'}) {
1073 my $glob = readvar($thrdvar_h);
1081 return if $symbol !~ /^[A-Za-z_]/;
1082 return if $symbol =~ /^\#/;
1085 return if exists $skip{$symbol};
1086 emit_symbol($symbol);
1093 if ($PLATFORM =~ /^win(?:32|ce)$/) {
1094 foreach my $symbol (qw(
1156 win32_getprotobyname
1157 win32_getprotobynumber
1186 win32_open_osfhandle
1256 try_symbol($symbol);
1258 if ($CCTYPE eq "BORLAND") {
1259 try_symbol('_matherr');
1262 elsif ($PLATFORM eq 'os2') {
1263 open MAP, 'miniperl.map' or die 'Cannot read miniperl.map';
1264 /^\s*[\da-f:]+\s+(\w+)/i and $mapped{$1}++ foreach <MAP>;
1265 close MAP or die 'Cannot close miniperl.map';
1267 @missing = grep { !exists $mapped{$_} }
1269 @missing = grep { !exists $exportperlmalloc{$_} } @missing;
1270 delete $export{$_} foreach @missing;
1272 elsif ($PLATFORM eq 'MacOS') {
1273 open MACSYMS, 'macperl.sym' or die 'Cannot read macperl.sym';
1281 elsif ($PLATFORM eq 'netware') {
1282 foreach my $symbol (qw(
1409 fnInsertHashListAddrs
1420 try_symbol($symbol);
1424 # records of type boot_module for statically linked modules (except Dynaloader)
1425 $static_ext =~ s/\//__/g;
1426 $static_ext =~ s/\bDynaLoader\b//;
1427 my @stat_mods = map {"boot_$_"} grep {/\S/} split /\s+/, $static_ext;
1428 foreach my $symbol (@stat_mods)
1430 try_symbol($symbol);
1433 # Now all symbols should be defined because
1434 # next we are going to output them.
1436 foreach my $symbol (sort keys %export) {
1437 output_symbol($symbol);
1440 if ($PLATFORM eq 'os2') {
1445 Perl_OS2_handler_install
1447 ; LAST_ORDINAL=$sym_ord
1454 $export{$symbol} = 1;
1459 if ($PLATFORM =~ /^win(?:32|ce)$/) {
1460 $symbol = "_$symbol" if $CCTYPE eq 'BORLAND';
1461 print "\t$symbol\n";
1462 # XXX: binary compatibility between compilers is an exercise
1463 # in frustration :-(
1464 # if ($CCTYPE eq "BORLAND") {
1465 # # workaround Borland quirk by exporting both the straight
1466 # # name and a name with leading underscore. Note the
1467 # # alias *must* come after the symbol itself, if both
1468 # # are to be exported. (Linker bug?)
1469 # print "\t_$symbol\n";
1470 # print "\t$symbol = _$symbol\n";
1472 # elsif ($CCTYPE eq 'GCC') {
1473 # # Symbols have leading _ whole process is $%@"% slow
1474 # # so skip aliases for now
1475 # nprint "\t$symbol\n";
1478 # # for binary coexistence, export both the symbol and
1479 # # alias with leading underscore
1480 # print "\t$symbol\n";
1481 # print "\t_$symbol = $symbol\n";
1484 elsif ($PLATFORM eq 'os2') {
1485 printf qq( %-31s \@%s\n),
1486 qq("$symbol"), $ordinal{$symbol} || ++$sym_ord;
1487 printf qq( %-31s \@%s\n),
1488 qq("$exportperlmalloc{$symbol}" = "$symbol"),
1489 $ordinal{$exportperlmalloc{$symbol}} || ++$sym_ord
1490 if $exportperlmalloc and exists $exportperlmalloc{$symbol};
1492 elsif ($PLATFORM eq 'aix' || $PLATFORM eq 'MacOS') {
1495 elsif ($PLATFORM eq 'netware') {
1496 print "\t$symbol,\n";
1502 # extra globals not included above.
1513 # Oddities from PerlIO