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 (/^(d_(?:mmap|sigaction))='(.+)'$/) {
87 if ($PLATFORM eq 'os2') {
88 $CONFIG_ARGS = $1 if /^config_args='(.+)'$/;
89 $ARCHNAME = $1 if /^archname='(.+)'$/;
90 $PATCHLEVEL = $1 if /^perl_patchlevel='(.+)'$/;
95 if ($PLATFORM eq 'win32' || $PLATFORM eq 'wince') {
96 open(CFG,"<..\\$config_sh") || die "Cannot open ..\\$config_sh: $!\n";
97 if ((join '', <CFG>) =~ /^static_ext='(.*)'$/m) {
103 open(CFG,$config_h) || die "Cannot open $config_h: $!\n";
105 $define{$1} = 1 if /^\s*#\s*define\s+(MYMALLOC)\b/;
106 $define{$1} = 1 if /^\s*#\s*define\s+(MULTIPLICITY)\b/;
107 $define{$1} = 1 if /^\s*#\s*define\s+(PERL_\w+)\b/;
108 $define{$1} = 1 if /^\s*#\s*define\s+(USE_\w+)\b/;
112 # perl.h logic duplication begins
114 if ($define{PERL_IMPLICIT_SYS}) {
115 $define{PL_OP_SLAB_ALLOC} = 1;
118 if ($define{USE_ITHREADS}) {
119 if (!$define{MULTIPLICITY}) {
120 $define{MULTIPLICITY} = 1;
124 $define{PERL_IMPLICIT_CONTEXT} ||=
125 $define{USE_ITHREADS} ||
126 $define{MULTIPLICITY} ;
128 if ($define{USE_ITHREADS} && $PLATFORM ne 'win32' && $^O ne 'darwin') {
129 $define{USE_REENTRANT_API} = 1;
132 # perl.h logic duplication ends
136 if ($PLATFORM =~ /^win(?:32|ce)$/) {
137 warn join(' ',keys %define)."\n";
138 ($dll = ($define{PERL_DLL} || "perl59")) =~ s/\.dll$//i;
139 print "LIBRARY $dll\n";
140 print "DESCRIPTION 'Perl interpreter'\n";
142 if ($define{PERL_IMPLICIT_SYS}) {
143 output_symbol("perl_get_host_info");
144 output_symbol("perl_alloc_override");
146 if ($define{USE_ITHREADS} and $define{PERL_IMPLICIT_SYS}) {
147 output_symbol("perl_clone_host");
150 elsif ($PLATFORM eq 'os2') {
151 if (open my $fh, '<', 'perl5.def') {
153 last if /^\s*EXPORTS\b/;
156 $ordinal{$1} = $2 if /^\s*"(\w+)"\s*(?:=\s*"\w+"\s*)?\@(\d+)\s*$/;
157 # This allows skipping ordinals which were used in older versions
158 $sym_ord = $1 if /^\s*;\s*LAST_ORDINAL\s*=\s*(\d+)\s*$/;
160 $sym_ord < $_ and $sym_ord = $_ for values %ordinal; # Take the max
162 ($v = $]) =~ s/(\d\.\d\d\d)(\d\d)$/$1_$2/;
163 $v .= '-thread' if $ARCHNAME =~ /-thread/;
164 ($dll = $define{PERL_DLL}) =~ s/\.dll$//i;
165 $v .= "\@$PATCHLEVEL" if $PATCHLEVEL;
166 $d = "DESCRIPTION '\@#perl5-porters\@perl.org:$v#\@ Perl interpreter, configured as $CONFIG_ARGS'";
167 $d = substr($d, 0, 249) . "...'" if length $d > 253;
169 LIBRARY '$dll' INITINSTANCE TERMINSTANCE
173 DATA LOADONCALL NONSHARED MULTIPLE
177 elsif ($PLATFORM eq 'aix') {
182 if ($OSVER > 4 || ($OSVER == 4 && $OSREL >= 3)) {
188 elsif ($PLATFORM eq 'netware') {
189 if ($FILETYPE eq 'def') {
190 print "LIBRARY perl59\n";
191 print "DESCRIPTION 'Perl interpreter for NetWare'\n";
194 if ($define{PERL_IMPLICIT_SYS}) {
195 output_symbol("perl_get_host_info");
196 output_symbol("perl_alloc_override");
197 output_symbol("perl_clone_host");
206 foreach my $symbol (@$list) {
213 foreach my $symbol (@$list) {
214 my $skipsym = $symbol;
216 if ($define{MULTIPLICITY}) {
217 $skipsym =~ s/^Perl_[GIT](\w+)_ptr$/PL_$1/;
219 emit_symbol($symbol) unless exists $skip{$skipsym};
223 if ($PLATFORM eq 'win32') {
248 Perl_init_thread_intern
281 if ($PLATFORM eq 'wince') {
297 PL_collation_standard
325 Perl_init_thread_intern
351 elsif ($PLATFORM eq 'aix') {
370 Perl_sys_intern_clear
379 elsif ($PLATFORM eq 'os2') {
424 XS_Cwd_extLibpath_set
428 XS_Cwd_sys_is_absolute
429 XS_Cwd_sys_is_relative
431 XS_DynaLoader_mod2fname
432 XS_File__Copy_syscopy
436 Perl_Process_Messages
447 emit_symbols([qw(os2_cond_wait
452 if $define{'USE_5005THREADS'} or $define{'USE_ITHREADS'};
454 elsif ($PLATFORM eq 'MacOS') {
478 Perl_sys_intern_clear
482 elsif ($PLATFORM eq 'netware') {
507 Perl_init_thread_intern
532 Perl_sys_intern_clear
540 Perl_PerlIO_setlinebuf
541 Perl_PerlIO_set_ptrcnt
547 Perl_PerlIO_get_bufsiz
560 unless ($define{'DEBUGGING'}) {
575 if ($define{'PERL_IMPLICIT_CONTEXT'}) {
581 if ($define{'PERL_IMPLICIT_SYS'}) {
602 unless ($define{'PERL_COPY_ON_WRITE'}) {
609 unless ($define{'USE_REENTRANT_API'}) {
615 if ($define{'MYMALLOC'}) {
624 if ($define{'USE_ITHREADS'}) {
646 unless ($define{'PERL_MALLOC_WRAP'}) {
652 unless ($define{'USE_ITHREADS'}) {
658 # USE_5005THREADS symbols. Kept as reference for easier removal
677 Perl_new_struct_thread
678 Perl_per_thread_magicals
686 unless ($define{'USE_ITHREADS'}) {
696 PL_sharedsv_space_mutex
726 Perl_sharedsv_thrcnt_dec
727 Perl_sharedsv_thrcnt_inc
732 unless ($define{'PERL_IMPLICIT_CONTEXT'}) {
738 Perl_load_module_nocontext
741 Perl_warner_nocontext
742 Perl_newSVpvf_nocontext
743 Perl_sv_catpvf_nocontext
744 Perl_sv_setpvf_nocontext
745 Perl_sv_catpvf_mg_nocontext
746 Perl_sv_setpvf_mg_nocontext
750 unless ($define{'PERL_IMPLICIT_SYS'}) {
757 unless ($define{'FAKE_THREADS'}) {
758 skip_symbols [qw(PL_curthr)];
761 unless ($define{'PL_OP_SLAB_ALLOC'}) {
771 unless ($define{'THREADS_HAVE_PIDS'}) {
772 skip_symbols [qw(PL_ppid)];
775 unless ($define{'PERL_NEED_APPCTX'}) {
781 unless ($define{'PERL_NEED_TIMESBASE'}) {
787 unless ($define{'d_mmap'}) {
793 if ($define{'d_sigaction'}) {
800 # VMS does its own thing for these symbols.
801 skip_symbols [qw(PL_sig_handlers_initted
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. The A?I?S?C? is strictly speaking
815 push(@syms, &$proc($1,$2,$3)) if (/\bPERLVAR(A?I?S?C?)\(([IGT])(\w+)/);
821 if ($define{'PERL_GLOBAL_STRUCT'}) {
822 my $global = readvar($perlvars_h);
823 skip_symbols $global;
824 emit_symbol('Perl_GetVars');
825 emit_symbols [qw(PL_Vars PL_VarsPtr)] unless $CCTYPE eq 'GCC';
827 skip_symbols [qw(Perl_init_global_struct Perl_free_global_struct)];
830 # functions from *.sym files
832 my @syms = ($global_sym, $globvar_sym); # $pp_sym is not part of the API
834 # Symbols that are the public face of the PerlIO layers implementation
835 # These are in _addition to_ the public face of the abstraction
836 # and need to be exported to allow XS modules to implement layers
850 PerlIOBase_setlinebuf
893 Perl_PerlIO_get_bufsiz
899 Perl_PerlIO_set_ptrcnt
900 Perl_PerlIO_setlinebuf
908 if ($PLATFORM eq 'netware') {
909 push(@layer_syms,'PL_def_layerlist','PL_known_layers','PL_perlio');
912 if ($define{'USE_PERLIO'}) {
913 # Export the symols that make up the PerlIO abstraction, regardless
914 # of its implementation - read from a file
915 push @syms, $perlio_sym;
917 # This part is then dependent on how the abstraction is implemented
918 if ($define{'USE_SFIO'}) {
919 # Old legacy non-stdio "PerlIO"
920 skip_symbols \@layer_syms;
921 skip_symbols [qw(perlsio_binmode)];
922 # SFIO defines most of the PerlIO routines as macros
923 # So undo most of what $perlio_sym has just done - d'oh !
924 # Perhaps it would be better to list the ones which do exist
977 Perl_PerlIO_get_bufsiz
983 Perl_PerlIO_set_ptrcnt
984 Perl_PerlIO_setlinebuf
997 # PerlIO with layers - export implementation
998 emit_symbols \@layer_syms;
999 emit_symbols [qw(perlsio_binmode)];
1003 # Skip the PerlIO layer symbols - although
1004 # nothing should have exported them anyway.
1005 skip_symbols \@layer_syms;
1006 skip_symbols [qw(perlsio_binmode)];
1007 skip_symbols [qw(PL_def_layerlist PL_known_layers PL_perlio)];
1009 # Also do NOT add abstraction symbols from $perlio_sym
1010 # abstraction is done as #define to stdio
1011 # Remaining remnants that _may_ be functions
1012 # are handled in <DATA>
1015 for my $syms (@syms) {
1016 open (GLOBAL, "<$syms") || die "failed to open $syms: $!\n";
1018 next if (!/^[A-Za-z]/);
1019 # Functions have a Perl_ prefix
1020 # Variables have a PL_ prefix
1022 my $symbol = ($syms =~ /var\.sym$/i ? "PL_" : "");
1024 emit_symbol($symbol) unless exists $skip{$symbol};
1031 if ($define{'MULTIPLICITY'}) {
1032 for my $f ($perlvars_h, $intrpvar_h, $thrdvar_h) {
1033 my $glob = readvar($f, sub { "Perl_" . $_[1] . $_[2] . "_ptr" });
1036 # XXX AIX seems to want the perlvars.h symbols, for some reason
1037 if ($PLATFORM eq 'aix' or $PLATFORM eq 'os2') { # OS/2 needs PL_thr_key
1038 my $glob = readvar($perlvars_h);
1043 unless ($define{'PERL_GLOBAL_STRUCT'}) {
1044 my $glob = readvar($perlvars_h);
1047 unless ($define{'MULTIPLICITY'}) {
1048 my $glob = readvar($intrpvar_h);
1051 unless ($define{'MULTIPLICITY'}) {
1052 my $glob = readvar($thrdvar_h);
1060 return if $symbol !~ /^[A-Za-z_]/;
1061 return if $symbol =~ /^\#/;
1064 return if exists $skip{$symbol};
1065 emit_symbol($symbol);
1072 if ($PLATFORM =~ /^win(?:32|ce)$/) {
1073 foreach my $symbol (qw(
1135 win32_getprotobyname
1136 win32_getprotobynumber
1165 win32_open_osfhandle
1235 try_symbol($symbol);
1238 elsif ($PLATFORM eq 'os2') {
1239 open MAP, 'miniperl.map' or die 'Cannot read miniperl.map';
1240 /^\s*[\da-f:]+\s+(\w+)/i and $mapped{$1}++ foreach <MAP>;
1241 close MAP or die 'Cannot close miniperl.map';
1243 @missing = grep { !exists $mapped{$_} }
1245 @missing = grep { !exists $exportperlmalloc{$_} } @missing;
1246 delete $export{$_} foreach @missing;
1248 elsif ($PLATFORM eq 'MacOS') {
1249 open MACSYMS, 'macperl.sym' or die 'Cannot read macperl.sym';
1257 elsif ($PLATFORM eq 'netware') {
1258 foreach my $symbol (qw(
1385 fnInsertHashListAddrs
1396 try_symbol($symbol);
1400 # records of type boot_module for statically linked modules (except Dynaloader)
1401 $static_ext =~ s/\//__/g;
1402 $static_ext =~ s/\bDynaLoader\b//;
1403 my @stat_mods = map {"boot_$_"} grep {/\S/} split /\s+/, $static_ext;
1404 foreach my $symbol (@stat_mods)
1406 try_symbol($symbol);
1409 # Now all symbols should be defined because
1410 # next we are going to output them.
1412 foreach my $symbol (sort keys %export) {
1413 output_symbol($symbol);
1416 if ($PLATFORM eq 'os2') {
1421 Perl_OS2_handler_install
1423 ; LAST_ORDINAL=$sym_ord
1430 $export{$symbol} = 1;
1435 if ($PLATFORM =~ /^win(?:32|ce)$/) {
1436 $symbol = "_$symbol" if $CCTYPE eq 'BORLAND';
1437 print "\t$symbol\n";
1438 # XXX: binary compatibility between compilers is an exercise
1439 # in frustration :-(
1440 # if ($CCTYPE eq "BORLAND") {
1441 # # workaround Borland quirk by exporting both the straight
1442 # # name and a name with leading underscore. Note the
1443 # # alias *must* come after the symbol itself, if both
1444 # # are to be exported. (Linker bug?)
1445 # print "\t_$symbol\n";
1446 # print "\t$symbol = _$symbol\n";
1448 # elsif ($CCTYPE eq 'GCC') {
1449 # # Symbols have leading _ whole process is $%@"% slow
1450 # # so skip aliases for now
1451 # nprint "\t$symbol\n";
1454 # # for binary coexistence, export both the symbol and
1455 # # alias with leading underscore
1456 # print "\t$symbol\n";
1457 # print "\t_$symbol = $symbol\n";
1460 elsif ($PLATFORM eq 'os2') {
1461 printf qq( %-31s \@%s\n),
1462 qq("$symbol"), $ordinal{$symbol} || ++$sym_ord;
1463 printf qq( %-31s \@%s\n),
1464 qq("$exportperlmalloc{$symbol}" = "$symbol"),
1465 $ordinal{$exportperlmalloc{$symbol}} || ++$sym_ord
1466 if $exportperlmalloc and exists $exportperlmalloc{$symbol};
1468 elsif ($PLATFORM eq 'aix' || $PLATFORM eq 'MacOS') {
1471 elsif ($PLATFORM eq 'netware') {
1472 print "\t$symbol,\n";
1478 # extra globals not included above.
1489 # Oddities from PerlIO