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 ($PLATFORM eq 'os2') {
85 $CONFIG_ARGS = $1 if /^config_args='(.+)'$/;
86 $ARCHNAME = $1 if /^archname='(.+)'$/;
87 $PATCHLEVEL = $1 if /^perl_patchlevel='(.+)'$/;
92 if ($PLATFORM eq 'win32' || $PLATFORM eq 'wince') {
93 open(CFG,"<..\\$config_sh") || die "Cannot open ..\\$config_sh: $!\n";
94 if ((join '', <CFG>) =~ /^static_ext='(.*)'$/m) {
100 open(CFG,$config_h) || die "Cannot open $config_h: $!\n";
102 $define{$1} = 1 if /^\s*#\s*define\s+(MYMALLOC)\b/;
103 $define{$1} = 1 if /^\s*#\s*define\s+(MULTIPLICITY)\b/;
104 $define{$1} = 1 if /^\s*#\s*define\s+(PERL_\w+)\b/;
105 $define{$1} = 1 if /^\s*#\s*define\s+(USE_\w+)\b/;
109 # perl.h logic duplication begins
111 if ($define{PERL_IMPLICIT_SYS}) {
112 $define{PL_OP_SLAB_ALLOC} = 1;
115 if ($define{USE_ITHREADS}) {
116 if (!$define{MULTIPLICITY}) {
117 $define{MULTIPLICITY} = 1;
121 $define{PERL_IMPLICIT_CONTEXT} ||=
122 $define{USE_ITHREADS} ||
123 $define{MULTIPLICITY} ;
125 if ($define{USE_ITHREADS} && $PLATFORM ne 'win32' && $^O ne 'darwin') {
126 $define{USE_REENTRANT_API} = 1;
129 # perl.h logic duplication ends
133 if ($PLATFORM =~ /^win(?:32|ce)$/) {
134 warn join(' ',keys %define)."\n";
135 ($dll = ($define{PERL_DLL} || "perl59")) =~ s/\.dll$//i;
136 print "LIBRARY $dll\n";
137 print "DESCRIPTION 'Perl interpreter'\n";
139 if ($define{PERL_IMPLICIT_SYS}) {
140 output_symbol("perl_get_host_info");
141 output_symbol("perl_alloc_override");
143 if ($define{USE_ITHREADS} and $define{PERL_IMPLICIT_SYS}) {
144 output_symbol("perl_clone_host");
147 elsif ($PLATFORM eq 'os2') {
148 if (open my $fh, '<', 'perl5.def') {
150 last if /^\s*EXPORTS\b/;
153 $ordinal{$1} = $2 if /^\s*"(\w+)"\s*(?:=\s*"\w+"\s*)?\@(\d+)\s*$/;
154 # This allows skipping ordinals which were used in older versions
155 $sym_ord = $1 if /^\s*;\s*LAST_ORDINAL\s*=\s*(\d+)\s*$/;
157 $sym_ord < $_ and $sym_ord = $_ for values %ordinal; # Take the max
159 ($v = $]) =~ s/(\d\.\d\d\d)(\d\d)$/$1_$2/;
160 $v .= '-thread' if $ARCHNAME =~ /-thread/;
161 ($dll = $define{PERL_DLL}) =~ s/\.dll$//i;
162 $v .= "\@$PATCHLEVEL" if $PATCHLEVEL;
163 $d = "DESCRIPTION '\@#perl5-porters\@perl.org:$v#\@ Perl interpreter, configured as $CONFIG_ARGS'";
164 $d = substr($d, 0, 249) . "...'" if length $d > 253;
166 LIBRARY '$dll' INITINSTANCE TERMINSTANCE
170 DATA LOADONCALL NONSHARED MULTIPLE
174 elsif ($PLATFORM eq 'aix') {
179 if ($OSVER > 4 || ($OSVER == 4 && $OSREL >= 3)) {
185 elsif ($PLATFORM eq 'netware') {
186 if ($FILETYPE eq 'def') {
187 print "LIBRARY perl59\n";
188 print "DESCRIPTION 'Perl interpreter for NetWare'\n";
191 if ($define{PERL_IMPLICIT_SYS}) {
192 output_symbol("perl_get_host_info");
193 output_symbol("perl_alloc_override");
194 output_symbol("perl_clone_host");
203 foreach my $symbol (@$list) {
210 foreach my $symbol (@$list) {
211 my $skipsym = $symbol;
213 if ($define{MULTIPLICITY}) {
214 $skipsym =~ s/^Perl_[GIT](\w+)_ptr$/PL_$1/;
216 emit_symbol($symbol) unless exists $skip{$skipsym};
220 if ($PLATFORM eq 'win32') {
245 Perl_init_thread_intern
278 if ($PLATFORM eq 'wince') {
294 PL_collation_standard
322 Perl_init_thread_intern
348 elsif ($PLATFORM eq 'aix') {
367 Perl_sys_intern_clear
376 elsif ($PLATFORM eq 'os2') {
421 XS_Cwd_extLibpath_set
425 XS_Cwd_sys_is_absolute
426 XS_Cwd_sys_is_relative
428 XS_DynaLoader_mod2fname
429 XS_File__Copy_syscopy
433 Perl_Process_Messages
444 emit_symbols([qw(os2_cond_wait
449 if $define{'USE_5005THREADS'} or $define{'USE_ITHREADS'};
451 elsif ($PLATFORM eq 'MacOS') {
475 Perl_sys_intern_clear
479 elsif ($PLATFORM eq 'netware') {
504 Perl_init_thread_intern
529 Perl_sys_intern_clear
537 Perl_PerlIO_setlinebuf
538 Perl_PerlIO_set_ptrcnt
544 Perl_PerlIO_get_bufsiz
557 unless ($define{'DEBUGGING'}) {
572 if ($define{'PERL_IMPLICIT_SYS'}) {
593 unless ($define{'PERL_COPY_ON_WRITE'}) {
600 unless ($define{'USE_REENTRANT_API'}) {
606 if ($define{'MYMALLOC'}) {
615 if ($define{'USE_ITHREADS'}) {
637 if ($define{'PERL_MALLOC_WRAP'}) {
643 unless ($define{'HAS_MMAP'}) {
649 unless ($define{'HAS_TIMES'} || $define{'PERL_NEED_TIMESBASE'}) {
655 unless ($define{'PERL_NEED_APPCTX'}) {
661 unless ($define{'USE_ITHREADS'}) {
667 # USE_5005THREADS symbols. Kept as reference for easier removal
686 Perl_new_struct_thread
687 Perl_per_thread_magicals
695 unless ($define{'USE_ITHREADS'}) {
702 PL_sharedsv_space_mutex
731 Perl_sharedsv_thrcnt_dec
732 Perl_sharedsv_thrcnt_inc
737 unless ($define{'PERL_IMPLICIT_CONTEXT'}) {
743 Perl_load_module_nocontext
746 Perl_warner_nocontext
747 Perl_newSVpvf_nocontext
748 Perl_sv_catpvf_nocontext
749 Perl_sv_setpvf_nocontext
750 Perl_sv_catpvf_mg_nocontext
751 Perl_sv_setpvf_mg_nocontext
755 if ($define{'PERL_IMPLICIT_CONTEXT'}) {
761 unless ($define{'PERL_IMPLICIT_SYS'}) {
768 unless ($define{'FAKE_THREADS'}) {
769 skip_symbols [qw(PL_curthr)];
772 unless ($define{'FAKE_DEFAULT_SIGNAL_HANDLERS'}) {
778 unless ($define{'FAKE_PERSISTENT_SIGNAL_HANDLERS'}) {
784 unless ($define{'FAKE_DEFAULT_SIGNAL_HANDLERS'} ||
785 $define{'FAKE_PERSISTENT_SIGNAL_HANDLERS'})
788 PL_sig_handlers_initted
792 unless ($define{'PL_OP_SLAB_ALLOC'}) {
802 unless ($define{'THREADS_HAVE_PIDS'}) {
803 skip_symbols [qw(PL_ppid)];
808 my $proc = shift || sub { "PL_$_[2]" };
809 open(VARS,$file) || die "Cannot open $file: $!\n";
812 # All symbols have a Perl_ prefix because that's what embed.h
813 # sticks in front of them.
814 push(@syms, &$proc($1,$2,$3)) if (/\bPERLVAR(A?I?C?)\(([IGT])(\w+)/);
820 if ($define{'PERL_GLOBAL_STRUCT'}) {
821 my $global = readvar($perlvars_h);
822 skip_symbols $global;
823 emit_symbol('Perl_GetVars');
824 emit_symbols [qw(PL_Vars PL_VarsPtr)] unless $CCTYPE eq 'GCC';
827 # functions from *.sym files
829 my @syms = ($global_sym, $globvar_sym); # $pp_sym is not part of the API
831 # Symbols that are the public face of the PerlIO layers implementation
832 # These are in _addition to_ the public face of the abstraction
833 # and need to be exported to allow XS modules to implement layers
847 PerlIOBase_setlinebuf
890 Perl_PerlIO_get_bufsiz
896 Perl_PerlIO_set_ptrcnt
897 Perl_PerlIO_setlinebuf
905 if ($PLATFORM eq 'netware') {
906 push(@layer_syms,'PL_def_layerlist','PL_known_layers','PL_perlio');
909 if ($define{'USE_PERLIO'}) {
910 # Export the symols that make up the PerlIO abstraction, regardless
911 # of its implementation - read from a file
912 push @syms, $perlio_sym;
914 # This part is then dependent on how the abstraction is implemented
915 if ($define{'USE_SFIO'}) {
916 # Old legacy non-stdio "PerlIO"
917 skip_symbols \@layer_syms;
918 # SFIO defines most of the PerlIO routines as macros
919 # So undo most of what $perlio_sym has just done - d'oh !
920 # Perhaps it would be better to list the ones which do exist
973 Perl_PerlIO_get_bufsiz
979 Perl_PerlIO_set_ptrcnt
980 Perl_PerlIO_setlinebuf
993 # PerlIO with layers - export implementation
994 emit_symbols \@layer_syms;
998 # Skip the PerlIO layer symbols - although
999 # nothing should have exported them any way
1000 skip_symbols \@layer_syms;
1001 skip_symbols [qw(PL_def_layerlist PL_known_layers PL_perlio)];
1003 # Also do NOT add abstraction symbols from $perlio_sym
1004 # abstraction is done as #define to stdio
1005 # Remaining remnants that _may_ be functions
1006 # are handled in <DATA>
1009 for my $syms (@syms) {
1010 open (GLOBAL, "<$syms") || die "failed to open $syms: $!\n";
1012 next if (!/^[A-Za-z]/);
1013 # Functions have a Perl_ prefix
1014 # Variables have a PL_ prefix
1016 my $symbol = ($syms =~ /var\.sym$/i ? "PL_" : "");
1018 emit_symbol($symbol) unless exists $skip{$symbol};
1025 if ($define{'MULTIPLICITY'}) {
1026 for my $f ($perlvars_h, $intrpvar_h, $thrdvar_h) {
1027 my $glob = readvar($f, sub { "Perl_" . $_[1] . $_[2] . "_ptr" });
1030 # XXX AIX seems to want the perlvars.h symbols, for some reason
1031 if ($PLATFORM eq 'aix' or $PLATFORM eq 'os2') { # OS/2 needs PL_thr_key
1032 my $glob = readvar($perlvars_h);
1037 unless ($define{'PERL_GLOBAL_STRUCT'}) {
1038 my $glob = readvar($perlvars_h);
1041 unless ($define{'MULTIPLICITY'}) {
1042 my $glob = readvar($intrpvar_h);
1045 unless ($define{'MULTIPLICITY'}) {
1046 my $glob = readvar($thrdvar_h);
1054 return if $symbol !~ /^[A-Za-z_]/;
1055 return if $symbol =~ /^\#/;
1058 return if exists $skip{$symbol};
1059 emit_symbol($symbol);
1066 if ($PLATFORM =~ /^win(?:32|ce)$/) {
1067 foreach my $symbol (qw(
1129 win32_getprotobyname
1130 win32_getprotobynumber
1159 win32_open_osfhandle
1229 try_symbol($symbol);
1232 elsif ($PLATFORM eq 'os2') {
1233 open MAP, 'miniperl.map' or die 'Cannot read miniperl.map';
1234 /^\s*[\da-f:]+\s+(\w+)/i and $mapped{$1}++ foreach <MAP>;
1235 close MAP or die 'Cannot close miniperl.map';
1237 @missing = grep { !exists $mapped{$_} }
1239 @missing = grep { !exists $exportperlmalloc{$_} } @missing;
1240 delete $export{$_} foreach @missing;
1242 elsif ($PLATFORM eq 'MacOS') {
1243 open MACSYMS, 'macperl.sym' or die 'Cannot read macperl.sym';
1251 elsif ($PLATFORM eq 'netware') {
1252 foreach my $symbol (qw(
1379 fnInsertHashListAddrs
1390 try_symbol($symbol);
1394 # records of type boot_module for statically linked modules (except Dynaloader)
1395 $static_ext =~ s/\//__/g;
1396 $static_ext =~ s/\bDynaLoader\b//;
1397 my @stat_mods = map {"boot_$_"} grep {/\S/} split /\s+/, $static_ext;
1398 foreach my $symbol (@stat_mods)
1400 try_symbol($symbol);
1403 # Now all symbols should be defined because
1404 # next we are going to output them.
1406 foreach my $symbol (sort keys %export) {
1407 output_symbol($symbol);
1410 if ($PLATFORM eq 'os2') {
1415 Perl_OS2_handler_install
1417 ; LAST_ORDINAL=$sym_ord
1424 $export{$symbol} = 1;
1429 if ($PLATFORM =~ /^win(?:32|ce)$/) {
1430 $symbol = "_$symbol" if $CCTYPE eq 'BORLAND';
1431 print "\t$symbol\n";
1432 # XXX: binary compatibility between compilers is an exercise
1433 # in frustration :-(
1434 # if ($CCTYPE eq "BORLAND") {
1435 # # workaround Borland quirk by exporting both the straight
1436 # # name and a name with leading underscore. Note the
1437 # # alias *must* come after the symbol itself, if both
1438 # # are to be exported. (Linker bug?)
1439 # print "\t_$symbol\n";
1440 # print "\t$symbol = _$symbol\n";
1442 # elsif ($CCTYPE eq 'GCC') {
1443 # # Symbols have leading _ whole process is $%@"% slow
1444 # # so skip aliases for now
1445 # nprint "\t$symbol\n";
1448 # # for binary coexistence, export both the symbol and
1449 # # alias with leading underscore
1450 # print "\t$symbol\n";
1451 # print "\t_$symbol = $symbol\n";
1454 elsif ($PLATFORM eq 'os2') {
1455 printf qq( %-31s \@%s\n),
1456 qq("$symbol"), $ordinal{$symbol} || ++$sym_ord;
1457 printf qq( %-31s \@%s\n),
1458 qq("$exportperlmalloc{$symbol}" = "$symbol"),
1459 $ordinal{$exportperlmalloc{$symbol}} || ++$sym_ord
1460 if $exportperlmalloc and exists $exportperlmalloc{$symbol};
1462 elsif ($PLATFORM eq 'aix' || $PLATFORM eq 'MacOS') {
1465 elsif ($PLATFORM eq 'netware') {
1466 print "\t$symbol,\n";
1472 # extra globals not included above.
1483 # Oddities from PerlIO