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{MULTIPLICITY} ;
110 if ($define{USE_ITHREADS} && $PLATFORM ne 'win32' && $^O ne 'darwin') {
111 $define{USE_REENTRANT_API} = 1;
114 # perl.h logic duplication ends
118 if ($PLATFORM =~ /^win(?:32|ce)$/) {
119 warn join(' ',keys %define)."\n";
120 ($dll = ($define{PERL_DLL} || "perl59")) =~ s/\.dll$//i;
121 print "LIBRARY $dll\n";
122 print "DESCRIPTION 'Perl interpreter'\n";
124 if ($define{PERL_IMPLICIT_SYS}) {
125 output_symbol("perl_get_host_info");
126 output_symbol("perl_alloc_override");
128 if ($define{USE_ITHREADS} and $define{PERL_IMPLICIT_SYS}) {
129 output_symbol("perl_clone_host");
132 elsif ($PLATFORM eq 'os2') {
133 if (open my $fh, '<', 'perl5.def') {
135 last if /^\s*EXPORTS\b/;
138 $ordinal{$1} = $2 if /^\s*"(\w+)"\s*(?:=\s*"\w+"\s*)?\@(\d+)\s*$/;
139 # This allows skipping ordinals which were used in older versions
140 $sym_ord = $1 if /^\s*;\s*LAST_ORDINAL\s*=\s*(\d+)\s*$/;
142 $sym_ord < $_ and $sym_ord = $_ for values %ordinal; # Take the max
144 ($v = $]) =~ s/(\d\.\d\d\d)(\d\d)$/$1_$2/;
145 $v .= '-thread' if $ARCHNAME =~ /-thread/;
146 ($dll = $define{PERL_DLL}) =~ s/\.dll$//i;
147 $v .= "\@$PATCHLEVEL" if $PATCHLEVEL;
148 $d = "DESCRIPTION '\@#perl5-porters\@perl.org:$v#\@ Perl interpreter, configured as $CONFIG_ARGS'";
149 $d = substr($d, 0, 249) . "...'" if length $d > 253;
151 LIBRARY '$dll' INITINSTANCE TERMINSTANCE
155 DATA LOADONCALL NONSHARED MULTIPLE
159 elsif ($PLATFORM eq 'aix') {
164 if ($OSVER > 4 || ($OSVER == 4 && $OSREL >= 3)) {
170 elsif ($PLATFORM eq 'netware') {
171 if ($FILETYPE eq 'def') {
172 print "LIBRARY perl59\n";
173 print "DESCRIPTION 'Perl interpreter for NetWare'\n";
176 if ($define{PERL_IMPLICIT_SYS}) {
177 output_symbol("perl_get_host_info");
178 output_symbol("perl_alloc_override");
179 output_symbol("perl_clone_host");
188 foreach my $symbol (@$list) {
195 foreach my $symbol (@$list) {
196 my $skipsym = $symbol;
198 if ($define{MULTIPLICITY}) {
199 $skipsym =~ s/^Perl_[GIT](\w+)_ptr$/PL_$1/;
201 emit_symbol($symbol) unless exists $skip{$skipsym};
205 if ($PLATFORM eq 'win32') {
230 Perl_init_thread_intern
263 if ($PLATFORM eq 'wince') {
279 PL_collation_standard
308 Perl_init_thread_intern
334 elsif ($PLATFORM eq 'aix') {
353 Perl_sys_intern_clear
362 elsif ($PLATFORM eq 'os2') {
399 XS_Cwd_extLibpath_set
403 XS_Cwd_sys_is_absolute
404 XS_Cwd_sys_is_relative
406 XS_DynaLoader_mod2fname
407 XS_File__Copy_syscopy
411 Perl_Process_Messages
422 elsif ($PLATFORM eq 'MacOS') {
446 Perl_sys_intern_clear
450 elsif ($PLATFORM eq 'netware') {
475 Perl_init_thread_intern
500 Perl_sys_intern_clear
508 Perl_PerlIO_setlinebuf
509 Perl_PerlIO_set_ptrcnt
515 Perl_PerlIO_get_bufsiz
528 unless ($define{'DEBUGGING'}) {
542 if ($define{'PERL_IMPLICIT_SYS'}) {
563 unless ($define{'PERL_FLEXIBLE_EXCEPTIONS'}) {
567 Perl_vdefault_protect
571 unless ($define{'USE_REENTRANT_API'}) {
577 if ($define{'MYMALLOC'}) {
584 if ($define{'USE_ITHREADS'}) {
604 unless ($define{'USE_ITHREADS'}) {
610 # USE_5005THREADS symbols. Kept as reference for easier removal
629 Perl_new_struct_thread
630 Perl_per_thread_magicals
638 unless ($define{'USE_ITHREADS'}) {
645 PL_sharedsv_space_mutex
673 Perl_sharedsv_thrcnt_dec
674 Perl_sharedsv_thrcnt_inc
679 unless ($define{'PERL_IMPLICIT_CONTEXT'}) {
685 Perl_load_module_nocontext
688 Perl_warner_nocontext
689 Perl_newSVpvf_nocontext
690 Perl_sv_catpvf_nocontext
691 Perl_sv_setpvf_nocontext
692 Perl_sv_catpvf_mg_nocontext
693 Perl_sv_setpvf_mg_nocontext
697 unless ($define{'PERL_IMPLICIT_SYS'}) {
704 unless ($define{'FAKE_THREADS'}) {
705 skip_symbols [qw(PL_curthr)];
708 unless ($define{'PL_OP_SLAB_ALLOC'}) {
716 unless ($define{'THREADS_HAVE_PIDS'}) {
717 skip_symbols [qw(PL_ppid)];
722 my $proc = shift || sub { "PL_$_[2]" };
723 open(VARS,$file) || die "Cannot open $file: $!\n";
726 # All symbols have a Perl_ prefix because that's what embed.h
727 # sticks in front of them.
728 push(@syms, &$proc($1,$2,$3)) if (/\bPERLVAR(A?I?C?)\(([IGT])(\w+)/);
734 if ($define{'PERL_GLOBAL_STRUCT'}) {
735 my $global = readvar($perlvars_h);
736 skip_symbols $global;
737 emit_symbol('Perl_GetVars');
738 emit_symbols [qw(PL_Vars PL_VarsPtr)] unless $CCTYPE eq 'GCC';
741 # functions from *.sym files
743 my @syms = ($global_sym, $globvar_sym); # $pp_sym is not part of the API
745 # Symbols that are the public face of the PerlIO layers implementation
746 # These are in _addition to_ the public face of the abstraction
747 # and need to be exported to allow XS modules to implement layers
759 PerlIOBase_setlinebuf
801 Perl_PerlIO_get_bufsiz
807 Perl_PerlIO_set_ptrcnt
808 Perl_PerlIO_setlinebuf
817 if ($PLATFORM eq 'netware') {
818 push(@layer_syms,'PL_def_layerlist','PL_known_layers','PL_perlio');
821 if ($define{'USE_PERLIO'}) {
822 # Export the symols that make up the PerlIO abstraction, regardless
823 # of its implementation - read from a file
824 push @syms, $perlio_sym;
826 # This part is then dependent on how the abstraction is implemented
827 if ($define{'USE_SFIO'}) {
828 # Old legacy non-stdio "PerlIO"
829 skip_symbols \@layer_syms;
830 # SFIO defines most of the PerlIO routines as macros
831 # So undo most of what $perlio_sym has just done - d'oh !
832 # Perhaps it would be better to list the ones which do exist
885 Perl_PerlIO_get_bufsiz
891 Perl_PerlIO_set_ptrcnt
892 Perl_PerlIO_setlinebuf
905 # PerlIO with layers - export implementation
906 emit_symbols \@layer_syms;
910 # Skip the PerlIO layer symbols - although
911 # nothing should have exported them any way
912 skip_symbols \@layer_syms;
913 skip_symbols [qw(PL_def_layerlist PL_known_layers PL_perlio)];
915 # Also do NOT add abstraction symbols from $perlio_sym
916 # abstraction is done as #define to stdio
917 # Remaining remnants that _may_ be functions
918 # are handled in <DATA>
921 for my $syms (@syms) {
922 open (GLOBAL, "<$syms") || die "failed to open $syms: $!\n";
924 next if (!/^[A-Za-z]/);
925 # Functions have a Perl_ prefix
926 # Variables have a PL_ prefix
928 my $symbol = ($syms =~ /var\.sym$/i ? "PL_" : "");
930 emit_symbol($symbol) unless exists $skip{$symbol};
937 if ($define{'MULTIPLICITY'}) {
938 for my $f ($perlvars_h, $intrpvar_h, $thrdvar_h) {
939 my $glob = readvar($f, sub { "Perl_" . $_[1] . $_[2] . "_ptr" });
942 # XXX AIX seems to want the perlvars.h symbols, for some reason
943 if ($PLATFORM eq 'aix') {
944 my $glob = readvar($perlvars_h);
949 unless ($define{'PERL_GLOBAL_STRUCT'}) {
950 my $glob = readvar($perlvars_h);
953 unless ($define{'MULTIPLICITY'}) {
954 my $glob = readvar($intrpvar_h);
957 unless ($define{'MULTIPLICITY'}) {
958 my $glob = readvar($thrdvar_h);
966 return if $symbol !~ /^[A-Za-z_]/;
967 return if $symbol =~ /^\#/;
970 return if exists $skip{$symbol};
971 emit_symbol($symbol);
978 if ($PLATFORM =~ /^win(?:32|ce)$/) {
979 foreach my $symbol (qw(
1039 win32_getprotobyname
1040 win32_getprotobynumber
1069 win32_open_osfhandle
1139 try_symbol($symbol);
1142 elsif ($PLATFORM eq 'os2') {
1143 open MAP, 'miniperl.map' or die 'Cannot read miniperl.map';
1144 /^\s*[\da-f:]+\s+(\w+)/i and $mapped{$1}++ foreach <MAP>;
1145 close MAP or die 'Cannot close miniperl.map';
1147 @missing = grep { !exists $mapped{$_} }
1149 @missing = grep { !exists $exportperlmalloc{$_} } @missing;
1150 delete $export{$_} foreach @missing;
1152 elsif ($PLATFORM eq 'MacOS') {
1153 open MACSYMS, 'macperl.sym' or die 'Cannot read macperl.sym';
1161 elsif ($PLATFORM eq 'netware') {
1162 foreach my $symbol (qw(
1289 fnInsertHashListAddrs
1300 try_symbol($symbol);
1304 # Now all symbols should be defined because
1305 # next we are going to output them.
1307 foreach my $symbol (sort keys %export) {
1308 output_symbol($symbol);
1311 if ($PLATFORM eq 'os2') {
1312 print "; LAST_ORDINAL=$sym_ord\n";
1318 $export{$symbol} = 1;
1323 if ($PLATFORM =~ /^win(?:32|ce)$/) {
1324 $symbol = "_$symbol" if $CCTYPE eq 'BORLAND';
1325 print "\t$symbol\n";
1326 # XXX: binary compatibility between compilers is an exercise
1327 # in frustration :-(
1328 # if ($CCTYPE eq "BORLAND") {
1329 # # workaround Borland quirk by exporting both the straight
1330 # # name and a name with leading underscore. Note the
1331 # # alias *must* come after the symbol itself, if both
1332 # # are to be exported. (Linker bug?)
1333 # print "\t_$symbol\n";
1334 # print "\t$symbol = _$symbol\n";
1336 # elsif ($CCTYPE eq 'GCC') {
1337 # # Symbols have leading _ whole process is $%@"% slow
1338 # # so skip aliases for now
1339 # nprint "\t$symbol\n";
1342 # # for binary coexistence, export both the symbol and
1343 # # alias with leading underscore
1344 # print "\t$symbol\n";
1345 # print "\t_$symbol = $symbol\n";
1348 elsif ($PLATFORM eq 'os2') {
1349 printf qq( %-31s \@%s\n),
1350 qq("$symbol"), $ordinal{$symbol} || ++$sym_ord;
1351 printf qq( %-31s \@%s\n),
1352 qq("$exportperlmalloc{$symbol}" = "$symbol"),
1353 $ordinal{$exportperlmalloc{$symbol}} || ++$sym_ord
1354 if $exportperlmalloc and exists $exportperlmalloc{$symbol};
1356 elsif ($PLATFORM eq 'aix' || $PLATFORM eq 'MacOS') {
1359 elsif ($PLATFORM eq 'netware') {
1360 print "\t$symbol,\n";
1366 # extra globals not included above.
1377 # Oddities from PerlIO