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} || "perl59")) =~ 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*(?:=\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 perl59\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
264 if ($PLATFORM eq 'wince') {
280 PL_collation_standard
309 Perl_init_thread_intern
335 elsif ($PLATFORM eq 'aix') {
354 Perl_sys_intern_clear
363 elsif ($PLATFORM eq 'os2') {
400 XS_Cwd_extLibpath_set
404 XS_Cwd_sys_is_absolute
405 XS_Cwd_sys_is_relative
407 XS_DynaLoader_mod2fname
408 XS_File__Copy_syscopy
412 Perl_Process_Messages
423 elsif ($PLATFORM eq 'MacOS') {
447 Perl_sys_intern_clear
451 elsif ($PLATFORM eq 'netware') {
476 Perl_init_thread_intern
501 Perl_sys_intern_clear
509 Perl_PerlIO_setlinebuf
510 Perl_PerlIO_set_ptrcnt
516 Perl_PerlIO_get_bufsiz
529 unless ($define{'DEBUGGING'}) {
543 if ($define{'PERL_IMPLICIT_SYS'}) {
564 unless ($define{'PERL_FLEXIBLE_EXCEPTIONS'}) {
568 Perl_vdefault_protect
572 unless ($define{'USE_REENTRANT_API'}) {
578 if ($define{'MYMALLOC'}) {
585 if ($define{'USE_5005THREADS'} || $define{'USE_ITHREADS'}) {
605 unless ($define{'USE_5005THREADS'} || $define{'USE_ITHREADS'}) {
611 unless ($define{'USE_5005THREADS'}) {
630 Perl_new_struct_thread
631 Perl_per_thread_magicals
640 unless ($define{'USE_ITHREADS'}) {
647 PL_sharedsv_space_mutex
674 Perl_sharedsv_thrcnt_dec
675 Perl_sharedsv_thrcnt_inc
680 unless ($define{'PERL_IMPLICIT_CONTEXT'}) {
686 Perl_load_module_nocontext
689 Perl_warner_nocontext
690 Perl_newSVpvf_nocontext
691 Perl_sv_catpvf_nocontext
692 Perl_sv_setpvf_nocontext
693 Perl_sv_catpvf_mg_nocontext
694 Perl_sv_setpvf_mg_nocontext
698 unless ($define{'PERL_IMPLICIT_SYS'}) {
705 unless ($define{'FAKE_THREADS'}) {
706 skip_symbols [qw(PL_curthr)];
709 unless ($define{'PL_OP_SLAB_ALLOC'}) {
717 unless ($define{'THREADS_HAVE_PIDS'}) {
718 skip_symbols [qw(PL_ppid)];
723 my $proc = shift || sub { "PL_$_[2]" };
724 open(VARS,$file) || die "Cannot open $file: $!\n";
727 # All symbols have a Perl_ prefix because that's what embed.h
728 # sticks in front of them.
729 push(@syms, &$proc($1,$2,$3)) if (/\bPERLVAR(A?I?C?)\(([IGT])(\w+)/);
735 if ($define{'USE_5005THREADS'}) {
736 my $thrd = readvar($thrdvar_h);
740 if ($define{'PERL_GLOBAL_STRUCT'}) {
741 my $global = readvar($perlvars_h);
742 skip_symbols $global;
743 emit_symbol('Perl_GetVars');
744 emit_symbols [qw(PL_Vars PL_VarsPtr)] unless $CCTYPE eq 'GCC';
747 # functions from *.sym files
749 my @syms = ($global_sym, $globvar_sym); # $pp_sym is not part of the API
751 # Symbols that are the public face of the PerlIO layers implementation
752 # These are in _addition to_ the public face of the abstraction
753 # and need to be exported to allow XS modules to implement layers
765 PerlIOBase_setlinebuf
807 Perl_PerlIO_get_bufsiz
813 Perl_PerlIO_set_ptrcnt
814 Perl_PerlIO_setlinebuf
823 if ($PLATFORM eq 'netware') {
824 push(@layer_syms,'PL_def_layerlist','PL_known_layers','PL_perlio');
827 if ($define{'USE_PERLIO'}) {
828 # Export the symols that make up the PerlIO abstraction, regardless
829 # of its implementation - read from a file
830 push @syms, $perlio_sym;
832 # This part is then dependent on how the abstraction is implemented
833 if ($define{'USE_SFIO'}) {
834 # Old legacy non-stdio "PerlIO"
835 skip_symbols \@layer_syms;
836 # SFIO defines most of the PerlIO routines as macros
837 # So undo most of what $perlio_sym has just done - d'oh !
838 # Perhaps it would be better to list the ones which do exist
891 Perl_PerlIO_get_bufsiz
897 Perl_PerlIO_set_ptrcnt
898 Perl_PerlIO_setlinebuf
911 # PerlIO with layers - export implementation
912 emit_symbols \@layer_syms;
916 # Skip the PerlIO layer symbols - although
917 # nothing should have exported them any way
918 skip_symbols \@layer_syms;
919 skip_symbols [qw(PL_def_layerlist PL_known_layers PL_perlio)];
921 # Also do NOT add abstraction symbols from $perlio_sym
922 # abstraction is done as #define to stdio
923 # Remaining remnants that _may_ be functions
924 # are handled in <DATA>
927 for my $syms (@syms) {
928 open (GLOBAL, "<$syms") || die "failed to open $syms: $!\n";
930 next if (!/^[A-Za-z]/);
931 # Functions have a Perl_ prefix
932 # Variables have a PL_ prefix
934 my $symbol = ($syms =~ /var\.sym$/i ? "PL_" : "");
936 emit_symbol($symbol) unless exists $skip{$symbol};
943 if ($define{'MULTIPLICITY'}) {
944 for my $f ($perlvars_h, $intrpvar_h, $thrdvar_h) {
945 my $glob = readvar($f, sub { "Perl_" . $_[1] . $_[2] . "_ptr" });
948 # XXX AIX seems to want the perlvars.h symbols, for some reason
949 if ($PLATFORM eq 'aix') {
950 my $glob = readvar($perlvars_h);
955 unless ($define{'PERL_GLOBAL_STRUCT'}) {
956 my $glob = readvar($perlvars_h);
959 unless ($define{'MULTIPLICITY'}) {
960 my $glob = readvar($intrpvar_h);
963 unless ($define{'MULTIPLICITY'} || $define{'USE_5005THREADS'}) {
964 my $glob = readvar($thrdvar_h);
972 return if $symbol !~ /^[A-Za-z_]/;
973 return if $symbol =~ /^\#/;
976 return if exists $skip{$symbol};
977 emit_symbol($symbol);
984 if ($PLATFORM =~ /^win(?:32|ce)$/) {
985 foreach my $symbol (qw(
1045 win32_getprotobyname
1046 win32_getprotobynumber
1075 win32_open_osfhandle
1145 try_symbol($symbol);
1148 elsif ($PLATFORM eq 'os2') {
1149 open MAP, 'miniperl.map' or die 'Cannot read miniperl.map';
1150 /^\s*[\da-f:]+\s+(\w+)/i and $mapped{$1}++ foreach <MAP>;
1151 close MAP or die 'Cannot close miniperl.map';
1153 @missing = grep { !exists $mapped{$_} }
1155 @missing = grep { !exists $exportperlmalloc{$_} } @missing;
1156 delete $export{$_} foreach @missing;
1158 elsif ($PLATFORM eq 'MacOS') {
1159 open MACSYMS, 'macperl.sym' or die 'Cannot read macperl.sym';
1167 elsif ($PLATFORM eq 'netware') {
1168 foreach my $symbol (qw(
1295 fnInsertHashListAddrs
1306 try_symbol($symbol);
1310 # Now all symbols should be defined because
1311 # next we are going to output them.
1313 foreach my $symbol (sort keys %export) {
1314 output_symbol($symbol);
1317 if ($PLATFORM eq 'os2') {
1318 print "; LAST_ORDINAL=$sym_ord\n";
1324 $export{$symbol} = 1;
1329 if ($PLATFORM =~ /^win(?:32|ce)$/) {
1330 $symbol = "_$symbol" if $CCTYPE eq 'BORLAND';
1331 print "\t$symbol\n";
1332 # XXX: binary compatibility between compilers is an exercise
1333 # in frustration :-(
1334 # if ($CCTYPE eq "BORLAND") {
1335 # # workaround Borland quirk by exporting both the straight
1336 # # name and a name with leading underscore. Note the
1337 # # alias *must* come after the symbol itself, if both
1338 # # are to be exported. (Linker bug?)
1339 # print "\t_$symbol\n";
1340 # print "\t$symbol = _$symbol\n";
1342 # elsif ($CCTYPE eq 'GCC') {
1343 # # Symbols have leading _ whole process is $%@"% slow
1344 # # so skip aliases for now
1345 # nprint "\t$symbol\n";
1348 # # for binary coexistence, export both the symbol and
1349 # # alias with leading underscore
1350 # print "\t$symbol\n";
1351 # print "\t_$symbol = $symbol\n";
1354 elsif ($PLATFORM eq 'os2') {
1355 printf qq( %-31s \@%s\n),
1356 qq("$symbol"), $ordinal{$symbol} || ++$sym_ord;
1357 printf qq( %-31s \@%s\n),
1358 qq("$exportperlmalloc{$symbol}" = "$symbol"),
1359 $ordinal{$exportperlmalloc{$symbol}} || ++$sym_ord
1360 if $exportperlmalloc and exists $exportperlmalloc{$symbol};
1362 elsif ($PLATFORM eq 'aix' || $PLATFORM eq 'MacOS') {
1365 elsif ($PLATFORM eq 'netware') {
1366 print "\t$symbol,\n";
1372 # extra globals not included above.
1383 # Oddities from PerlIO