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_SYS'}) {
597 unless ($define{'PERL_COPY_ON_WRITE'}) {
604 unless ($define{'USE_REENTRANT_API'}) {
610 if ($define{'MYMALLOC'}) {
619 if ($define{'USE_ITHREADS'}) {
641 unless ($define{'PERL_MALLOC_WRAP'}) {
647 unless ($define{'USE_ITHREADS'}) {
653 # USE_5005THREADS symbols. Kept as reference for easier removal
672 Perl_new_struct_thread
673 Perl_per_thread_magicals
681 unless ($define{'USE_ITHREADS'}) {
688 PL_sharedsv_space_mutex
717 Perl_sharedsv_thrcnt_dec
718 Perl_sharedsv_thrcnt_inc
723 unless ($define{'PERL_IMPLICIT_CONTEXT'}) {
729 Perl_load_module_nocontext
732 Perl_warner_nocontext
733 Perl_newSVpvf_nocontext
734 Perl_sv_catpvf_nocontext
735 Perl_sv_setpvf_nocontext
736 Perl_sv_catpvf_mg_nocontext
737 Perl_sv_setpvf_mg_nocontext
741 unless ($define{'PERL_IMPLICIT_SYS'}) {
748 unless ($define{'FAKE_THREADS'}) {
749 skip_symbols [qw(PL_curthr)];
752 unless ($define{'PL_OP_SLAB_ALLOC'}) {
762 unless ($define{'THREADS_HAVE_PIDS'}) {
763 skip_symbols [qw(PL_ppid)];
766 unless ($define{'PERL_NEED_APPCTX'}) {
772 unless ($define{'PERL_NEED_TIMESBASE'}) {
778 unless ($define{'d_mmap'}) {
784 if ($define{'d_sigaction'}) {
791 # VMS does its own thing for these symbols.
792 skip_symbols [qw(PL_sig_handlers_initted
799 my $proc = shift || sub { "PL_$_[2]" };
800 open(VARS,$file) || die "Cannot open $file: $!\n";
803 # All symbols have a Perl_ prefix because that's what embed.h
804 # sticks in front of them. The A?I?S?C? is strictly speaking
806 push(@syms, &$proc($1,$2,$3)) if (/\bPERLVAR(A?I?S?C?)\(([IGT])(\w+)/);
812 if ($define{'PERL_GLOBAL_STRUCT'}) {
813 my $global = readvar($perlvars_h);
814 skip_symbols $global;
815 emit_symbol('Perl_GetVars');
816 emit_symbols [qw(PL_Vars PL_VarsPtr)] unless $CCTYPE eq 'GCC';
818 skip_symbols [qw(Perl_init_global_struct Perl_free_global_struct)];
821 # functions from *.sym files
823 my @syms = ($global_sym, $globvar_sym); # $pp_sym is not part of the API
825 # Symbols that are the public face of the PerlIO layers implementation
826 # These are in _addition to_ the public face of the abstraction
827 # and need to be exported to allow XS modules to implement layers
841 PerlIOBase_setlinebuf
884 Perl_PerlIO_get_bufsiz
890 Perl_PerlIO_set_ptrcnt
891 Perl_PerlIO_setlinebuf
899 if ($PLATFORM eq 'netware') {
900 push(@layer_syms,'PL_def_layerlist','PL_known_layers','PL_perlio');
903 if ($define{'USE_PERLIO'}) {
904 # Export the symols that make up the PerlIO abstraction, regardless
905 # of its implementation - read from a file
906 push @syms, $perlio_sym;
908 # This part is then dependent on how the abstraction is implemented
909 if ($define{'USE_SFIO'}) {
910 # Old legacy non-stdio "PerlIO"
911 skip_symbols \@layer_syms;
912 # SFIO defines most of the PerlIO routines as macros
913 # So undo most of what $perlio_sym has just done - d'oh !
914 # Perhaps it would be better to list the ones which do exist
967 Perl_PerlIO_get_bufsiz
973 Perl_PerlIO_set_ptrcnt
974 Perl_PerlIO_setlinebuf
987 # PerlIO with layers - export implementation
988 emit_symbols \@layer_syms;
992 # Skip the PerlIO layer symbols - although
993 # nothing should have exported them anyway.
994 skip_symbols \@layer_syms;
995 skip_symbols [qw(PL_def_layerlist PL_known_layers PL_perlio)];
997 # Also do NOT add abstraction symbols from $perlio_sym
998 # abstraction is done as #define to stdio
999 # Remaining remnants that _may_ be functions
1000 # are handled in <DATA>
1003 for my $syms (@syms) {
1004 open (GLOBAL, "<$syms") || die "failed to open $syms: $!\n";
1006 next if (!/^[A-Za-z]/);
1007 # Functions have a Perl_ prefix
1008 # Variables have a PL_ prefix
1010 my $symbol = ($syms =~ /var\.sym$/i ? "PL_" : "");
1012 emit_symbol($symbol) unless exists $skip{$symbol};
1019 if ($define{'MULTIPLICITY'}) {
1020 for my $f ($perlvars_h, $intrpvar_h, $thrdvar_h) {
1021 my $glob = readvar($f, sub { "Perl_" . $_[1] . $_[2] . "_ptr" });
1024 # XXX AIX seems to want the perlvars.h symbols, for some reason
1025 if ($PLATFORM eq 'aix' or $PLATFORM eq 'os2') { # OS/2 needs PL_thr_key
1026 my $glob = readvar($perlvars_h);
1031 unless ($define{'PERL_GLOBAL_STRUCT'}) {
1032 my $glob = readvar($perlvars_h);
1035 unless ($define{'MULTIPLICITY'}) {
1036 my $glob = readvar($intrpvar_h);
1039 unless ($define{'MULTIPLICITY'}) {
1040 my $glob = readvar($thrdvar_h);
1048 return if $symbol !~ /^[A-Za-z_]/;
1049 return if $symbol =~ /^\#/;
1052 return if exists $skip{$symbol};
1053 emit_symbol($symbol);
1060 if ($PLATFORM =~ /^win(?:32|ce)$/) {
1061 foreach my $symbol (qw(
1123 win32_getprotobyname
1124 win32_getprotobynumber
1153 win32_open_osfhandle
1223 try_symbol($symbol);
1226 elsif ($PLATFORM eq 'os2') {
1227 open MAP, 'miniperl.map' or die 'Cannot read miniperl.map';
1228 /^\s*[\da-f:]+\s+(\w+)/i and $mapped{$1}++ foreach <MAP>;
1229 close MAP or die 'Cannot close miniperl.map';
1231 @missing = grep { !exists $mapped{$_} }
1233 @missing = grep { !exists $exportperlmalloc{$_} } @missing;
1234 delete $export{$_} foreach @missing;
1236 elsif ($PLATFORM eq 'MacOS') {
1237 open MACSYMS, 'macperl.sym' or die 'Cannot read macperl.sym';
1245 elsif ($PLATFORM eq 'netware') {
1246 foreach my $symbol (qw(
1373 fnInsertHashListAddrs
1384 try_symbol($symbol);
1388 # records of type boot_module for statically linked modules (except Dynaloader)
1389 $static_ext =~ s/\//__/g;
1390 $static_ext =~ s/\bDynaLoader\b//;
1391 my @stat_mods = map {"boot_$_"} grep {/\S/} split /\s+/, $static_ext;
1392 foreach my $symbol (@stat_mods)
1394 try_symbol($symbol);
1397 # Now all symbols should be defined because
1398 # next we are going to output them.
1400 foreach my $symbol (sort keys %export) {
1401 output_symbol($symbol);
1404 if ($PLATFORM eq 'os2') {
1409 Perl_OS2_handler_install
1411 ; LAST_ORDINAL=$sym_ord
1418 $export{$symbol} = 1;
1423 if ($PLATFORM =~ /^win(?:32|ce)$/) {
1424 $symbol = "_$symbol" if $CCTYPE eq 'BORLAND';
1425 print "\t$symbol\n";
1426 # XXX: binary compatibility between compilers is an exercise
1427 # in frustration :-(
1428 # if ($CCTYPE eq "BORLAND") {
1429 # # workaround Borland quirk by exporting both the straight
1430 # # name and a name with leading underscore. Note the
1431 # # alias *must* come after the symbol itself, if both
1432 # # are to be exported. (Linker bug?)
1433 # print "\t_$symbol\n";
1434 # print "\t$symbol = _$symbol\n";
1436 # elsif ($CCTYPE eq 'GCC') {
1437 # # Symbols have leading _ whole process is $%@"% slow
1438 # # so skip aliases for now
1439 # nprint "\t$symbol\n";
1442 # # for binary coexistence, export both the symbol and
1443 # # alias with leading underscore
1444 # print "\t$symbol\n";
1445 # print "\t_$symbol = $symbol\n";
1448 elsif ($PLATFORM eq 'os2') {
1449 printf qq( %-31s \@%s\n),
1450 qq("$symbol"), $ordinal{$symbol} || ++$sym_ord;
1451 printf qq( %-31s \@%s\n),
1452 qq("$exportperlmalloc{$symbol}" = "$symbol"),
1453 $ordinal{$exportperlmalloc{$symbol}} || ++$sym_ord
1454 if $exportperlmalloc and exists $exportperlmalloc{$symbol};
1456 elsif ($PLATFORM eq 'aix' || $PLATFORM eq 'MacOS') {
1459 elsif ($PLATFORM eq 'netware') {
1460 print "\t$symbol,\n";
1466 # extra globals not included above.
1477 # Oddities from PerlIO