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 $config_sh = "config.sh";
33 my $config_h = "config.h";
34 my $thrdvar_h = "thrdvar.h";
35 my $intrpvar_h = "intrpvar.h";
36 my $perlvars_h = "perlvars.h";
37 my $global_sym = "global.sym";
38 my $pp_sym = "pp.sym";
39 my $globvar_sym = "globvar.sym";
40 my $perlio_sym = "perlio.sym";
42 if ($PLATFORM eq 'aix') {
45 elsif ($PLATFORM =~ /^win(?:32|ce)$/ || $PLATFORM eq 'netware') {
46 $CCTYPE = "MSVC" unless defined $CCTYPE;
47 foreach ($thrdvar_h, $intrpvar_h, $perlvars_h, $global_sym,
48 $pp_sym, $globvar_sym, $perlio_sym) {
52 elsif ($PLATFORM eq 'MacOS') {
53 foreach ($thrdvar_h, $intrpvar_h, $perlvars_h, $global_sym,
54 $pp_sym, $globvar_sym, $perlio_sym) {
59 unless ($PLATFORM eq 'win32' || $PLATFORM eq 'wince' || $PLATFORM eq 'MacOS' || $PLATFORM eq 'netware') {
60 open(CFG,$config_sh) || die "Cannot open $config_sh: $!\n";
62 if (/^(?:ccflags|optimize)='(.+)'$/) {
64 $define{$1} = 1 while /-D(\w+)/g;
66 if ($PLATFORM eq 'os2') {
67 $CONFIG_ARGS = $1 if /^config_args='(.+)'$/;
68 $ARCHNAME = $1 if /^archname='(.+)'$/;
69 $PATCHLEVEL = $1 if /^perl_patchlevel='(.+)'$/;
75 open(CFG,$config_h) || die "Cannot open $config_h: $!\n";
77 $define{$1} = 1 if /^\s*#\s*define\s+(MYMALLOC)\b/;
78 $define{$1} = 1 if /^\s*#\s*define\s+(MULTIPLICITY)\b/;
79 $define{$1} = 1 if /^\s*#\s*define\s+(PERL_\w+)\b/;
80 $define{$1} = 1 if /^\s*#\s*define\s+(USE_\w+)\b/;
84 # perl.h logic duplication begins
86 if ($define{PERL_IMPLICIT_SYS}) {
87 $define{PL_OP_SLAB_ALLOC} = 1;
90 if ($define{USE_ITHREADS}) {
91 if (!$define{MULTIPLICITY}) {
92 $define{MULTIPLICITY} = 1;
96 $define{PERL_IMPLICIT_CONTEXT} ||=
97 $define{USE_ITHREADS} ||
98 $define{USE_5005THREADS} ||
99 $define{MULTIPLICITY} ;
101 if ($define{USE_ITHREADS} && $PLATFORM ne 'win32' && $^O ne 'darwin') {
102 $define{USE_REENTRANT_API} = 1;
105 # perl.h logic duplication ends
109 if ($PLATFORM =~ /^win(?:32|ce)$/) {
110 warn join(' ',keys %define)."\n";
111 ($dll = ($define{PERL_DLL} || "perl58")) =~ s/\.dll$//i;
112 print "LIBRARY $dll\n";
113 print "DESCRIPTION 'Perl interpreter'\n";
115 if ($define{PERL_IMPLICIT_SYS}) {
116 output_symbol("perl_get_host_info");
117 output_symbol("perl_alloc_override");
119 if ($define{USE_ITHREADS} and $define{PERL_IMPLICIT_SYS}) {
120 output_symbol("perl_clone_host");
123 elsif ($PLATFORM eq 'os2') {
124 if (open my $fh, '<', 'perl5.def') {
126 last if /^\s*EXPORTS\b/;
129 $ordinal{$1} = $2 if /^\s*"(\w+)"\s*\@(\d+)\s*$/;
130 # This allows skipping ordinals which were used in older versions
131 $sym_ord = $1 if /^\s*;\s*LAST_ORDINAL\s*=\s*(\d+)\s*$/;
133 $sym_ord < $_ and $sym_ord = $_ for values %ordinal; # Take the max
135 ($v = $]) =~ s/(\d\.\d\d\d)(\d\d)$/$1_$2/;
136 $v .= '-thread' if $ARCHNAME =~ /-thread/;
137 ($dll = $define{PERL_DLL}) =~ s/\.dll$//i;
138 $v .= "\@$PATCHLEVEL" if $PATCHLEVEL;
139 $d = "DESCRIPTION '\@#perl5-porters\@perl.org:$v#\@ Perl interpreter, configured as $CONFIG_ARGS'";
140 $d = substr($d, 0, 249) . "...'" if length $d > 253;
142 LIBRARY '$dll' INITINSTANCE TERMINSTANCE
146 DATA LOADONCALL NONSHARED MULTIPLE
150 elsif ($PLATFORM eq 'aix') {
155 if ($OSVER > 4 || ($OSVER == 4 && $OSREL >= 3)) {
161 elsif ($PLATFORM eq 'netware') {
162 if ($FILETYPE eq 'def') {
163 print "LIBRARY perl58\n";
164 print "DESCRIPTION 'Perl interpreter for NetWare'\n";
167 if ($define{PERL_IMPLICIT_SYS}) {
168 output_symbol("perl_get_host_info");
169 output_symbol("perl_alloc_override");
170 output_symbol("perl_clone_host");
179 foreach my $symbol (@$list) {
186 foreach my $symbol (@$list) {
187 my $skipsym = $symbol;
189 if ($define{MULTIPLICITY}) {
190 $skipsym =~ s/^Perl_[GIT](\w+)_ptr$/PL_$1/;
192 emit_symbol($symbol) unless exists $skip{$skipsym};
196 if ($PLATFORM eq 'win32') {
221 Perl_init_thread_intern
254 if ($PLATFORM eq 'wince') {
270 PL_collation_standard
299 Perl_init_thread_intern
325 elsif ($PLATFORM eq 'aix') {
344 Perl_sys_intern_clear
353 elsif ($PLATFORM eq 'os2') {
390 XS_Cwd_extLibpath_set
394 XS_Cwd_sys_is_absolute
395 XS_Cwd_sys_is_relative
397 XS_DynaLoader_mod2fname
398 XS_File__Copy_syscopy
402 Perl_Process_Messages
413 elsif ($PLATFORM eq 'MacOS') {
437 Perl_sys_intern_clear
441 elsif ($PLATFORM eq 'netware') {
466 Perl_init_thread_intern
491 Perl_sys_intern_clear
499 Perl_PerlIO_setlinebuf
500 Perl_PerlIO_set_ptrcnt
506 Perl_PerlIO_get_bufsiz
519 unless ($define{'DEBUGGING'}) {
533 if ($define{'PERL_IMPLICIT_SYS'}) {
554 unless ($define{'PERL_FLEXIBLE_EXCEPTIONS'}) {
558 Perl_vdefault_protect
562 unless ($define{'USE_REENTRANT_API'}) {
568 if ($define{'MYMALLOC'}) {
575 if ($define{'USE_5005THREADS'} || $define{'USE_ITHREADS'}) {
595 unless ($define{'USE_5005THREADS'} || $define{'USE_ITHREADS'}) {
601 unless ($define{'USE_5005THREADS'}) {
620 Perl_new_struct_thread
621 Perl_per_thread_magicals
630 unless ($define{'USE_ITHREADS'}) {
637 PL_sharedsv_space_mutex
664 Perl_sharedsv_thrcnt_dec
665 Perl_sharedsv_thrcnt_inc
670 unless ($define{'PERL_IMPLICIT_CONTEXT'}) {
676 Perl_load_module_nocontext
679 Perl_warner_nocontext
680 Perl_newSVpvf_nocontext
681 Perl_sv_catpvf_nocontext
682 Perl_sv_setpvf_nocontext
683 Perl_sv_catpvf_mg_nocontext
684 Perl_sv_setpvf_mg_nocontext
688 unless ($define{'PERL_IMPLICIT_SYS'}) {
695 unless ($define{'FAKE_THREADS'}) {
696 skip_symbols [qw(PL_curthr)];
699 unless ($define{'PL_OP_SLAB_ALLOC'}) {
709 my $proc = shift || sub { "PL_$_[2]" };
710 open(VARS,$file) || die "Cannot open $file: $!\n";
713 # All symbols have a Perl_ prefix because that's what embed.h
714 # sticks in front of them.
715 push(@syms, &$proc($1,$2,$3)) if (/\bPERLVAR(A?I?C?)\(([IGT])(\w+)/);
721 if ($define{'USE_5005THREADS'}) {
722 my $thrd = readvar($thrdvar_h);
726 if ($define{'PERL_GLOBAL_STRUCT'}) {
727 my $global = readvar($perlvars_h);
728 skip_symbols $global;
729 emit_symbol('Perl_GetVars');
730 emit_symbols [qw(PL_Vars PL_VarsPtr)] unless $CCTYPE eq 'GCC';
733 # functions from *.sym files
735 my @syms = ($global_sym, $globvar_sym); # $pp_sym is not part of the API
737 # Symbols that are the public face of the PerlIO layers implementation
738 # These are in _addition to_ the public face of the abstraction
739 # and need to be exported to allow XS modules to implement layers
751 PerlIOBase_setlinebuf
793 Perl_PerlIO_get_bufsiz
799 Perl_PerlIO_set_ptrcnt
800 Perl_PerlIO_setlinebuf
809 if ($PLATFORM eq 'netware') {
810 push(@layer_syms,'PL_def_layerlist','PL_known_layers','PL_perlio');
813 if ($define{'USE_PERLIO'}) {
814 # Export the symols that make up the PerlIO abstraction, regardless
815 # of its implementation - read from a file
816 push @syms, $perlio_sym;
818 # This part is then dependent on how the abstraction is implemented
819 if ($define{'USE_SFIO'}) {
820 # Old legacy non-stdio "PerlIO"
821 skip_symbols \@layer_syms;
822 # SFIO defines most of the PerlIO routines as macros
823 # So undo most of what $perlio_sym has just done - d'oh !
824 # Perhaps it would be better to list the ones which do exist
877 Perl_PerlIO_get_bufsiz
883 Perl_PerlIO_set_ptrcnt
884 Perl_PerlIO_setlinebuf
897 # PerlIO with layers - export implementation
898 emit_symbols \@layer_syms;
902 # Skip the PerlIO layer symbols - although
903 # nothing should have exported them any way
904 skip_symbols \@layer_syms;
905 skip_symbols [qw(PL_def_layerlist PL_known_layers PL_perlio)];
907 # Also do NOT add abstraction symbols from $perlio_sym
908 # abstraction is done as #define to stdio
909 # Remaining remnants that _may_ be functions
910 # are handled in <DATA>
913 for my $syms (@syms) {
914 open (GLOBAL, "<$syms") || die "failed to open $syms: $!\n";
916 next if (!/^[A-Za-z]/);
917 # Functions have a Perl_ prefix
918 # Variables have a PL_ prefix
920 my $symbol = ($syms =~ /var\.sym$/i ? "PL_" : "");
922 emit_symbol($symbol) unless exists $skip{$symbol};
929 if ($define{'MULTIPLICITY'}) {
930 for my $f ($perlvars_h, $intrpvar_h, $thrdvar_h) {
931 my $glob = readvar($f, sub { "Perl_" . $_[1] . $_[2] . "_ptr" });
934 # XXX AIX seems to want the perlvars.h symbols, for some reason
935 if ($PLATFORM eq 'aix') {
936 my $glob = readvar($perlvars_h);
941 unless ($define{'PERL_GLOBAL_STRUCT'}) {
942 my $glob = readvar($perlvars_h);
945 unless ($define{'MULTIPLICITY'}) {
946 my $glob = readvar($intrpvar_h);
949 unless ($define{'MULTIPLICITY'} || $define{'USE_5005THREADS'}) {
950 my $glob = readvar($thrdvar_h);
958 return if $symbol !~ /^[A-Za-z_]/;
959 return if $symbol =~ /^\#/;
962 return if exists $skip{$symbol};
963 emit_symbol($symbol);
970 if ($PLATFORM =~ /^win(?:32|ce)$/) {
971 foreach my $symbol (qw(
1031 win32_getprotobyname
1032 win32_getprotobynumber
1061 win32_open_osfhandle
1131 try_symbol($symbol);
1134 elsif ($PLATFORM eq 'os2') {
1135 open MAP, 'miniperl.map' or die 'Cannot read miniperl.map';
1136 /^\s*[\da-f:]+\s+(\w+)/i and $mapped{$1}++ foreach <MAP>;
1137 close MAP or die 'Cannot close miniperl.map';
1139 @missing = grep { !exists $mapped{$_} }
1141 delete $export{$_} foreach @missing;
1143 elsif ($PLATFORM eq 'MacOS') {
1144 open MACSYMS, 'macperl.sym' or die 'Cannot read macperl.sym';
1152 elsif ($PLATFORM eq 'netware') {
1153 foreach my $symbol (qw(
1280 fnInsertHashListAddrs
1291 try_symbol($symbol);
1295 # Now all symbols should be defined because
1296 # next we are going to output them.
1298 foreach my $symbol (sort keys %export) {
1299 output_symbol($symbol);
1302 if ($PLATFORM eq 'os2') {
1303 print "; LAST_ORDINAL=$sym_ord\n";
1309 $export{$symbol} = 1;
1314 if ($PLATFORM =~ /^win(?:32|ce)$/) {
1315 $symbol = "_$symbol" if $CCTYPE eq 'BORLAND';
1316 print "\t$symbol\n";
1317 # XXX: binary compatibility between compilers is an exercise
1318 # in frustration :-(
1319 # if ($CCTYPE eq "BORLAND") {
1320 # # workaround Borland quirk by exporting both the straight
1321 # # name and a name with leading underscore. Note the
1322 # # alias *must* come after the symbol itself, if both
1323 # # are to be exported. (Linker bug?)
1324 # print "\t_$symbol\n";
1325 # print "\t$symbol = _$symbol\n";
1327 # elsif ($CCTYPE eq 'GCC') {
1328 # # Symbols have leading _ whole process is $%@"% slow
1329 # # so skip aliases for now
1330 # nprint "\t$symbol\n";
1333 # # for binary coexistence, export both the symbol and
1334 # # alias with leading underscore
1335 # print "\t$symbol\n";
1336 # print "\t_$symbol = $symbol\n";
1339 elsif ($PLATFORM eq 'os2') {
1340 printf qq( %-31s \@%s\n),
1341 qq("$symbol"), $ordinal{$symbol} || ++$sym_ord;
1343 elsif ($PLATFORM eq 'aix' || $PLATFORM eq 'MacOS') {
1346 elsif ($PLATFORM eq 'netware') {
1347 print "\t$symbol,\n";
1353 # extra globals not included above.
1364 # Oddities from PerlIO