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 as well
16 $define{$1} = 1 if ($flag =~ /^-D(\w+)$/);
17 $define{$1} = $2 if ($flag =~ /^-D(\w+)=(.+)$/);
18 $CCTYPE = $1 if ($flag =~ /^CCTYPE=(\w+)$/);
19 $PLATFORM = $1 if ($flag =~ /^PLATFORM=(\w+)$/);
20 if ($PLATFORM eq 'netware') {
21 $FILETYPE = $1 if ($flag =~ /^FILETYPE=(\w+)$/);
25 my @PLATFORM = qw(aix win32 wince os2 MacOS netware);
27 @PLATFORM{@PLATFORM} = ();
29 defined $PLATFORM || die "PLATFORM undefined, must be one of: @PLATFORM\n";
30 exists $PLATFORM{$PLATFORM} || die "PLATFORM must be one of: @PLATFORM\n";
32 my %exportperlmalloc =
34 Perl_malloc => "malloc",
36 Perl_realloc => "realloc",
37 Perl_calloc => "calloc",
40 my $exportperlmalloc = $PLATFORM eq 'os2';
42 my $config_sh = "config.sh";
43 my $config_h = "config.h";
44 my $thrdvar_h = "thrdvar.h";
45 my $intrpvar_h = "intrpvar.h";
46 my $perlvars_h = "perlvars.h";
47 my $global_sym = "global.sym";
48 my $pp_sym = "pp.sym";
49 my $globvar_sym = "globvar.sym";
50 my $perlio_sym = "perlio.sym";
52 if ($PLATFORM eq 'aix') {
55 elsif ($PLATFORM =~ /^win(?:32|ce)$/ || $PLATFORM eq 'netware') {
56 $CCTYPE = "MSVC" unless defined $CCTYPE;
57 foreach ($thrdvar_h, $intrpvar_h, $perlvars_h, $global_sym,
58 $pp_sym, $globvar_sym, $perlio_sym) {
62 elsif ($PLATFORM eq 'MacOS') {
63 foreach ($thrdvar_h, $intrpvar_h, $perlvars_h, $global_sym,
64 $pp_sym, $globvar_sym, $perlio_sym) {
69 unless ($PLATFORM eq 'win32' || $PLATFORM eq 'wince' || $PLATFORM eq 'MacOS' || $PLATFORM eq 'netware') {
70 open(CFG,$config_sh) || die "Cannot open $config_sh: $!\n";
72 if (/^(?:ccflags|optimize)='(.+)'$/) {
74 $define{$1} = 1 while /-D(\w+)/g;
76 if ($PLATFORM eq 'os2') {
77 $CONFIG_ARGS = $1 if /^config_args='(.+)'$/;
78 $ARCHNAME = $1 if /^archname='(.+)'$/;
79 $PATCHLEVEL = $1 if /^perl_patchlevel='(.+)'$/;
85 open(CFG,$config_h) || die "Cannot open $config_h: $!\n";
87 $define{$1} = 1 if /^\s*#\s*define\s+(MYMALLOC)\b/;
88 $define{$1} = 1 if /^\s*#\s*define\s+(MULTIPLICITY)\b/;
89 $define{$1} = 1 if /^\s*#\s*define\s+(PERL_\w+)\b/;
90 $define{$1} = 1 if /^\s*#\s*define\s+(USE_\w+)\b/;
94 # perl.h logic duplication begins
96 if ($define{PERL_IMPLICIT_SYS}) {
97 $define{PL_OP_SLAB_ALLOC} = 1;
100 if ($define{USE_ITHREADS}) {
101 if (!$define{MULTIPLICITY}) {
102 $define{MULTIPLICITY} = 1;
106 $define{PERL_IMPLICIT_CONTEXT} ||=
107 $define{USE_ITHREADS} ||
108 $define{USE_5005THREADS} ||
109 $define{MULTIPLICITY} ;
111 if ($define{USE_ITHREADS} && $PLATFORM ne 'win32' && $^O ne 'darwin') {
112 $define{USE_REENTRANT_API} = 1;
115 # perl.h logic duplication ends
119 if ($PLATFORM =~ /^win(?:32|ce)$/) {
120 warn join(' ',keys %define)."\n";
121 ($dll = ($define{PERL_DLL} || "perl58")) =~ s/\.dll$//i;
122 print "LIBRARY $dll\n";
123 print "DESCRIPTION 'Perl interpreter'\n";
125 if ($define{PERL_IMPLICIT_SYS}) {
126 output_symbol("perl_get_host_info");
127 output_symbol("perl_alloc_override");
129 if ($define{USE_ITHREADS} and $define{PERL_IMPLICIT_SYS}) {
130 output_symbol("perl_clone_host");
133 elsif ($PLATFORM eq 'os2') {
134 if (open my $fh, '<', 'perl5.def') {
136 last if /^\s*EXPORTS\b/;
139 $ordinal{$1} = $2 if /^\s*"(\w+)"\s*\@(\d+)\s*$/;
140 # This allows skipping ordinals which were used in older versions
141 $sym_ord = $1 if /^\s*;\s*LAST_ORDINAL\s*=\s*(\d+)\s*$/;
143 $sym_ord < $_ and $sym_ord = $_ for values %ordinal; # Take the max
145 ($v = $]) =~ s/(\d\.\d\d\d)(\d\d)$/$1_$2/;
146 $v .= '-thread' if $ARCHNAME =~ /-thread/;
147 ($dll = $define{PERL_DLL}) =~ s/\.dll$//i;
148 $v .= "\@$PATCHLEVEL" if $PATCHLEVEL;
149 $d = "DESCRIPTION '\@#perl5-porters\@perl.org:$v#\@ Perl interpreter, configured as $CONFIG_ARGS'";
150 $d = substr($d, 0, 249) . "...'" if length $d > 253;
152 LIBRARY '$dll' INITINSTANCE TERMINSTANCE
156 DATA LOADONCALL NONSHARED MULTIPLE
160 elsif ($PLATFORM eq 'aix') {
165 if ($OSVER > 4 || ($OSVER == 4 && $OSREL >= 3)) {
171 elsif ($PLATFORM eq 'netware') {
172 if ($FILETYPE eq 'def') {
173 print "LIBRARY perl58\n";
174 print "DESCRIPTION 'Perl interpreter for NetWare'\n";
177 if ($define{PERL_IMPLICIT_SYS}) {
178 output_symbol("perl_get_host_info");
179 output_symbol("perl_alloc_override");
180 output_symbol("perl_clone_host");
189 foreach my $symbol (@$list) {
196 foreach my $symbol (@$list) {
197 my $skipsym = $symbol;
199 if ($define{MULTIPLICITY}) {
200 $skipsym =~ s/^Perl_[GIT](\w+)_ptr$/PL_$1/;
202 emit_symbol($symbol) unless exists $skip{$skipsym};
206 if ($PLATFORM eq 'win32') {
231 Perl_init_thread_intern
257 elsif ($PLATFORM eq 'wince') {
273 PL_collation_standard
302 Perl_init_thread_intern
328 elsif ($PLATFORM eq 'aix') {
347 Perl_sys_intern_clear
356 elsif ($PLATFORM eq 'os2') {
393 XS_Cwd_extLibpath_set
397 XS_Cwd_sys_is_absolute
398 XS_Cwd_sys_is_relative
400 XS_DynaLoader_mod2fname
401 XS_File__Copy_syscopy
405 Perl_Process_Messages
416 elsif ($PLATFORM eq 'MacOS') {
440 Perl_sys_intern_clear
444 elsif ($PLATFORM eq 'netware') {
469 Perl_init_thread_intern
494 Perl_sys_intern_clear
502 Perl_PerlIO_setlinebuf
503 Perl_PerlIO_set_ptrcnt
509 Perl_PerlIO_get_bufsiz
522 unless ($define{'DEBUGGING'}) {
536 if ($define{'PERL_IMPLICIT_SYS'}) {
557 unless ($define{'PERL_FLEXIBLE_EXCEPTIONS'}) {
561 Perl_vdefault_protect
565 unless ($define{'USE_REENTRANT_API'}) {
571 if ($define{'MYMALLOC'}) {
578 if ($define{'USE_5005THREADS'} || $define{'USE_ITHREADS'}) {
598 unless ($define{'USE_5005THREADS'} || $define{'USE_ITHREADS'}) {
604 unless ($define{'USE_5005THREADS'}) {
623 Perl_new_struct_thread
624 Perl_per_thread_magicals
633 unless ($define{'USE_ITHREADS'}) {
640 PL_sharedsv_space_mutex
667 Perl_sharedsv_thrcnt_dec
668 Perl_sharedsv_thrcnt_inc
673 unless ($define{'PERL_IMPLICIT_CONTEXT'}) {
679 Perl_load_module_nocontext
682 Perl_warner_nocontext
683 Perl_newSVpvf_nocontext
684 Perl_sv_catpvf_nocontext
685 Perl_sv_setpvf_nocontext
686 Perl_sv_catpvf_mg_nocontext
687 Perl_sv_setpvf_mg_nocontext
691 unless ($define{'PERL_IMPLICIT_SYS'}) {
698 unless ($define{'FAKE_THREADS'}) {
699 skip_symbols [qw(PL_curthr)];
702 unless ($define{'PL_OP_SLAB_ALLOC'}) {
712 my $proc = shift || sub { "PL_$_[2]" };
713 open(VARS,$file) || die "Cannot open $file: $!\n";
716 # All symbols have a Perl_ prefix because that's what embed.h
717 # sticks in front of them.
718 push(@syms, &$proc($1,$2,$3)) if (/\bPERLVAR(A?I?C?)\(([IGT])(\w+)/);
724 if ($define{'USE_5005THREADS'}) {
725 my $thrd = readvar($thrdvar_h);
729 if ($define{'PERL_GLOBAL_STRUCT'}) {
730 my $global = readvar($perlvars_h);
731 skip_symbols $global;
732 emit_symbol('Perl_GetVars');
733 emit_symbols [qw(PL_Vars PL_VarsPtr)] unless $CCTYPE eq 'GCC';
736 # functions from *.sym files
738 my @syms = ($global_sym, $globvar_sym); # $pp_sym is not part of the API
740 # Symbols that are the public face of the PerlIO layers implementation
741 # These are in _addition to_ the public face of the abstraction
742 # and need to be exported to allow XS modules to implement layers
754 PerlIOBase_setlinebuf
796 Perl_PerlIO_get_bufsiz
802 Perl_PerlIO_set_ptrcnt
803 Perl_PerlIO_setlinebuf
812 if ($PLATFORM eq 'netware') {
813 push(@layer_syms,'PL_def_layerlist','PL_known_layers','PL_perlio');
816 if ($define{'USE_PERLIO'}) {
817 # Export the symols that make up the PerlIO abstraction, regardless
818 # of its implementation - read from a file
819 push @syms, $perlio_sym;
821 # This part is then dependent on how the abstraction is implemented
822 if ($define{'USE_SFIO'}) {
823 # Old legacy non-stdio "PerlIO"
824 skip_symbols \@layer_syms;
825 # SFIO defines most of the PerlIO routines as macros
826 # So undo most of what $perlio_sym has just done - d'oh !
827 # Perhaps it would be better to list the ones which do exist
880 Perl_PerlIO_get_bufsiz
886 Perl_PerlIO_set_ptrcnt
887 Perl_PerlIO_setlinebuf
900 # PerlIO with layers - export implementation
901 emit_symbols \@layer_syms;
905 # Skip the PerlIO layer symbols - although
906 # nothing should have exported them any way
907 skip_symbols \@layer_syms;
908 skip_symbols [qw(PL_def_layerlist PL_known_layers PL_perlio)];
910 # Also do NOT add abstraction symbols from $perlio_sym
911 # abstraction is done as #define to stdio
912 # Remaining remnants that _may_ be functions
913 # are handled in <DATA>
916 for my $syms (@syms) {
917 open (GLOBAL, "<$syms") || die "failed to open $syms: $!\n";
919 next if (!/^[A-Za-z]/);
920 # Functions have a Perl_ prefix
921 # Variables have a PL_ prefix
923 my $symbol = ($syms =~ /var\.sym$/i ? "PL_" : "");
925 emit_symbol($symbol) unless exists $skip{$symbol};
932 if ($define{'MULTIPLICITY'}) {
933 for my $f ($perlvars_h, $intrpvar_h, $thrdvar_h) {
934 my $glob = readvar($f, sub { "Perl_" . $_[1] . $_[2] . "_ptr" });
937 # XXX AIX seems to want the perlvars.h symbols, for some reason
938 if ($PLATFORM eq 'aix') {
939 my $glob = readvar($perlvars_h);
944 unless ($define{'PERL_GLOBAL_STRUCT'}) {
945 my $glob = readvar($perlvars_h);
948 unless ($define{'MULTIPLICITY'}) {
949 my $glob = readvar($intrpvar_h);
952 unless ($define{'MULTIPLICITY'} || $define{'USE_5005THREADS'}) {
953 my $glob = readvar($thrdvar_h);
961 return if $symbol !~ /^[A-Za-z_]/;
962 return if $symbol =~ /^\#/;
965 return if exists $skip{$symbol};
966 emit_symbol($symbol);
973 if ($PLATFORM =~ /^win(?:32|ce)$/) {
974 foreach my $symbol (qw(
1034 win32_getprotobyname
1035 win32_getprotobynumber
1064 win32_open_osfhandle
1134 try_symbol($symbol);
1137 elsif ($PLATFORM eq 'os2') {
1138 open MAP, 'miniperl.map' or die 'Cannot read miniperl.map';
1139 /^\s*[\da-f:]+\s+(\w+)/i and $mapped{$1}++ foreach <MAP>;
1140 close MAP or die 'Cannot close miniperl.map';
1142 @missing = grep { !exists $mapped{$_} }
1144 @missing = grep { !exists $exportperlmalloc{$_} } @missing;
1145 delete $export{$_} foreach @missing;
1147 elsif ($PLATFORM eq 'MacOS') {
1148 open MACSYMS, 'macperl.sym' or die 'Cannot read macperl.sym';
1156 elsif ($PLATFORM eq 'netware') {
1157 foreach my $symbol (qw(
1284 fnInsertHashListAddrs
1295 try_symbol($symbol);
1299 # Now all symbols should be defined because
1300 # next we are going to output them.
1302 foreach my $symbol (sort keys %export) {
1303 output_symbol($symbol);
1306 if ($PLATFORM eq 'os2') {
1307 print "; LAST_ORDINAL=$sym_ord\n";
1313 $export{$symbol} = 1;
1318 $symbol = $exportperlmalloc{$symbol}
1319 if $exportperlmalloc and exists $exportperlmalloc{$symbol};
1320 if ($PLATFORM =~ /^win(?:32|ce)$/) {
1321 $symbol = "_$symbol" if $CCTYPE eq 'BORLAND';
1322 print "\t$symbol\n";
1323 # XXX: binary compatibility between compilers is an exercise
1324 # in frustration :-(
1325 # if ($CCTYPE eq "BORLAND") {
1326 # # workaround Borland quirk by exporting both the straight
1327 # # name and a name with leading underscore. Note the
1328 # # alias *must* come after the symbol itself, if both
1329 # # are to be exported. (Linker bug?)
1330 # print "\t_$symbol\n";
1331 # print "\t$symbol = _$symbol\n";
1333 # elsif ($CCTYPE eq 'GCC') {
1334 # # Symbols have leading _ whole process is $%@"% slow
1335 # # so skip aliases for now
1336 # nprint "\t$symbol\n";
1339 # # for binary coexistence, export both the symbol and
1340 # # alias with leading underscore
1341 # print "\t$symbol\n";
1342 # print "\t_$symbol = $symbol\n";
1345 elsif ($PLATFORM eq 'os2') {
1346 printf qq( %-31s \@%s\n),
1347 qq("$symbol"), $ordinal{$symbol} || ++$sym_ord;
1349 elsif ($PLATFORM eq 'aix' || $PLATFORM eq 'MacOS') {
1352 elsif ($PLATFORM eq 'netware') {
1353 print "\t$symbol,\n";
1359 # extra globals not included above.
1370 # Oddities from PerlIO