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 Perl_call_atexit => "perl_atexit",
17 Perl_eval_sv => "perl_eval_sv",
18 Perl_eval_pv => "perl_eval_pv",
19 Perl_call_argv => "perl_call_argv",
20 Perl_call_method => "perl_call_method",
21 Perl_call_pv => "perl_call_pv",
22 Perl_call_sv => "perl_call_sv",
23 Perl_get_av => "perl_get_av",
24 Perl_get_cv => "perl_get_cv",
25 Perl_get_hv => "perl_get_hv",
26 Perl_get_sv => "perl_get_sv",
27 Perl_init_i18nl10n => "perl_init_i18nl10n",
28 Perl_init_i18nl14n => "perl_init_i18nl14n",
29 Perl_new_collate => "perl_new_collate",
30 Perl_new_ctype => "perl_new_ctype",
31 Perl_new_numeric => "perl_new_numeric",
32 Perl_require_pv => "perl_require_pv",
33 Perl_safesyscalloc => "Perl_safecalloc",
34 Perl_safesysfree => "Perl_safefree",
35 Perl_safesysmalloc => "Perl_safemalloc",
36 Perl_safesysrealloc => "Perl_saferealloc",
37 Perl_set_numeric_local => "perl_set_numeric_local",
38 Perl_set_numeric_standard => "perl_set_numeric_standard",
39 Perl_malloc => "malloc",
41 Perl_realloc => "realloc",
42 Perl_calloc => "calloc",
45 my $bincompat5005 = join("|", keys %bincompat5005);
49 $define{$1} = 1 if ($flag =~ /^-D(\w+)$/);
50 $define{$1} = $2 if ($flag =~ /^-D(\w+)=(.+)$/);
51 $CCTYPE = $1 if ($flag =~ /^CCTYPE=(\w+)$/);
52 $PLATFORM = $1 if ($flag =~ /^PLATFORM=(\w+)$/);
53 if ($PLATFORM eq 'netware') {
54 $FILETYPE = $1 if ($flag =~ /^FILETYPE=(\w+)$/);
58 my @PLATFORM = qw(aix win32 os2 MacOS netware);
60 @PLATFORM{@PLATFORM} = ();
62 defined $PLATFORM || die "PLATFORM undefined, must be one of: @PLATFORM\n";
63 exists $PLATFORM{$PLATFORM} || die "PLATFORM must be one of: @PLATFORM\n";
65 my $config_sh = "config.sh";
66 my $config_h = "config.h";
67 my $thrdvar_h = "thrdvar.h";
68 my $intrpvar_h = "intrpvar.h";
69 my $perlvars_h = "perlvars.h";
70 my $global_sym = "global.sym";
71 my $pp_sym = "pp.sym";
72 my $globvar_sym = "globvar.sym";
73 my $perlio_sym = "perlio.sym";
75 if ($PLATFORM eq 'aix') {
78 elsif ($PLATFORM eq 'win32' || $PLATFORM eq 'netware') {
79 $CCTYPE = "MSVC" unless defined $CCTYPE;
80 foreach ($thrdvar_h, $intrpvar_h, $perlvars_h, $global_sym,
81 $pp_sym, $globvar_sym, $perlio_sym) {
85 elsif ($PLATFORM eq 'MacOS') {
86 foreach ($thrdvar_h, $intrpvar_h, $perlvars_h, $global_sym,
87 $pp_sym, $globvar_sym, $perlio_sym) {
92 unless ($PLATFORM eq 'win32' || $PLATFORM eq 'MacOS' || $PLATFORM eq 'netware') {
93 open(CFG,$config_sh) || die "Cannot open $config_sh: $!\n";
95 if (/^(?:ccflags|optimize)='(.+)'$/) {
97 $define{$1} = 1 while /-D(\w+)/g;
99 if ($PLATFORM eq 'os2') {
100 $CONFIG_ARGS = $1 if /^config_args='(.+)'$/;
101 $ARCHNAME = $1 if /^archname='(.+)'$/;
102 $PATCHLEVEL = $1 if /^perl_patchlevel='(.+)'$/;
108 open(CFG,$config_h) || die "Cannot open $config_h: $!\n";
110 $define{$1} = 1 if /^\s*#\s*define\s+(MYMALLOC)\b/;
111 $define{$1} = 1 if /^\s*#\s*define\s+(MULTIPLICITY)\b/;
112 $define{$1} = 1 if /^\s*#\s*define\s+(PERL_\w+)\b/;
113 $define{$1} = 1 if /^\s*#\s*define\s+(USE_\w+)\b/;
117 # perl.h logic duplication begins
119 if ($define{PERL_IMPLICIT_SYS}) {
120 $define{PL_OP_SLAB_ALLOC} = 1;
123 if ($define{USE_ITHREADS}) {
124 if (!$define{MULTIPLICITY}) {
125 $define{MULTIPLICITY} = 1;
129 $define{PERL_IMPLICIT_CONTEXT} ||=
130 $define{USE_ITHREADS} ||
131 $define{USE_5005THREADS} ||
132 $define{MULTIPLICITY} ;
134 if ($define{USE_ITHREADS} && $PLATFORM ne 'win32' && $^O ne 'darwin') {
135 $define{USE_REENTRANT_API} = 1;
138 # perl.h logic duplication ends
142 if ($PLATFORM eq 'win32') {
143 warn join(' ',keys %define)."\n";
144 print "LIBRARY perl58\n";
145 print "DESCRIPTION 'Perl interpreter'\n";
147 if ($define{PERL_IMPLICIT_SYS}) {
148 output_symbol("perl_get_host_info");
149 output_symbol("perl_alloc_override");
150 output_symbol("perl_clone_host");
153 elsif ($PLATFORM eq 'os2') {
154 if (open my $fh, '<', 'perl5.def') {
156 last if /^\s*EXPORTS\b/;
159 $ordinal{$1} = $2 if /^\s*"(\w+)"\s*\@(\d+)\s*$/;
160 # This allows skipping ordinals which were used in older versions
161 $sym_ord = $1 if /^\s*;\s*LAST_ORDINAL\s*=\s*(\d+)\s*$/;
163 $sym_ord < $_ and $sym_ord = $_ for values %ordinal; # Take the max
165 ($v = $]) =~ s/(\d\.\d\d\d)(\d\d)$/$1_$2/;
166 $v .= '-thread' if $ARCHNAME =~ /-thread/;
167 ($dll = $define{PERL_DLL}) =~ s/\.dll$//i;
168 $v .= "\@$PATCHLEVEL" if $PATCHLEVEL;
169 $d = "DESCRIPTION '\@#perl5-porters\@perl.org:$v#\@ Perl interpreter, configured as $CONFIG_ARGS'";
170 $d = substr($d, 0, 249) . "...'" if length $d > 253;
172 LIBRARY '$dll' INITINSTANCE TERMINSTANCE
176 DATA LOADONCALL NONSHARED MULTIPLE
180 elsif ($PLATFORM eq 'aix') {
185 if ($OSVER > 4 || ($OSVER == 4 && $OSREL >= 3)) {
191 elsif ($PLATFORM eq 'netware') {
192 if ($FILETYPE eq 'def') {
193 print "LIBRARY perl58\n";
194 print "DESCRIPTION 'Perl interpreter for NetWare'\n";
197 if ($define{PERL_IMPLICIT_SYS}) {
198 output_symbol("perl_get_host_info");
199 output_symbol("perl_alloc_override");
200 output_symbol("perl_clone_host");
209 foreach my $symbol (@$list) {
216 foreach my $symbol (@$list) {
217 my $skipsym = $symbol;
219 if ($define{MULTIPLICITY}) {
220 $skipsym =~ s/^Perl_[GIT](\w+)_ptr$/PL_$1/;
222 emit_symbol($symbol) unless exists $skip{$skipsym};
226 if ($PLATFORM eq 'win32') {
251 Perl_init_thread_intern
277 elsif ($PLATFORM eq 'aix') {
296 Perl_sys_intern_clear
305 elsif ($PLATFORM eq 'os2') {
342 XS_Cwd_extLibpath_set
346 XS_Cwd_sys_is_absolute
347 XS_Cwd_sys_is_relative
349 XS_DynaLoader_mod2fname
350 XS_File__Copy_syscopy
354 Perl_Process_Messages
365 elsif ($PLATFORM eq 'MacOS') {
389 Perl_sys_intern_clear
393 elsif ($PLATFORM eq 'netware') {
418 Perl_init_thread_intern
443 Perl_sys_intern_clear
451 Perl_PerlIO_setlinebuf
452 Perl_PerlIO_set_ptrcnt
458 Perl_PerlIO_get_bufsiz
471 unless ($define{'DEBUGGING'}) {
485 if ($define{'PERL_IMPLICIT_SYS'}) {
506 unless ($define{'PERL_FLEXIBLE_EXCEPTIONS'}) {
510 Perl_vdefault_protect
514 unless ($define{'USE_REENTRANT_API'}) {
520 if ($define{'MYMALLOC'}) {
527 if ($define{'USE_5005THREADS'} || $define{'USE_ITHREADS'}) {
547 unless ($define{'USE_5005THREADS'} || $define{'USE_ITHREADS'}) {
553 unless ($define{'USE_5005THREADS'}) {
572 Perl_new_struct_thread
573 Perl_per_thread_magicals
582 unless ($define{'USE_ITHREADS'}) {
589 PL_sharedsv_space_mutex
616 Perl_sharedsv_thrcnt_dec
617 Perl_sharedsv_thrcnt_inc
622 unless ($define{'PERL_IMPLICIT_CONTEXT'}) {
628 Perl_load_module_nocontext
631 Perl_warner_nocontext
632 Perl_newSVpvf_nocontext
633 Perl_sv_catpvf_nocontext
634 Perl_sv_setpvf_nocontext
635 Perl_sv_catpvf_mg_nocontext
636 Perl_sv_setpvf_mg_nocontext
640 unless ($define{'PERL_IMPLICIT_SYS'}) {
647 unless ($define{'FAKE_THREADS'}) {
648 skip_symbols [qw(PL_curthr)];
651 unless ($define{'PL_OP_SLAB_ALLOC'}) {
661 my $proc = shift || sub { "PL_$_[2]" };
662 open(VARS,$file) || die "Cannot open $file: $!\n";
665 # All symbols have a Perl_ prefix because that's what embed.h
666 # sticks in front of them.
667 push(@syms, &$proc($1,$2,$3)) if (/\bPERLVAR(A?I?C?)\(([IGT])(\w+)/);
673 if ($define{'USE_5005THREADS'}) {
674 my $thrd = readvar($thrdvar_h);
678 if ($define{'PERL_GLOBAL_STRUCT'}) {
679 my $global = readvar($perlvars_h);
680 skip_symbols $global;
681 emit_symbol('Perl_GetVars');
682 emit_symbols [qw(PL_Vars PL_VarsPtr)] unless $CCTYPE eq 'GCC';
685 # functions from *.sym files
687 my @syms = ($global_sym, $globvar_sym); # $pp_sym is not part of the API
698 PerlIOBase_setlinebuf
729 if ($define{'USE_PERLIO'}) {
730 push @syms, $perlio_sym;
731 if ($define{'USE_SFIO'}) {
732 skip_symbols \@layer_syms;
733 # SFIO defines most of the PerlIO routines as macros
785 Perl_PerlIO_get_bufsiz
791 Perl_PerlIO_set_ptrcnt
792 Perl_PerlIO_setlinebuf
802 # Skip the PerlIO New Generation symbols.
803 skip_symbols \@layer_syms;
806 for my $syms (@syms) {
807 open (GLOBAL, "<$syms") || die "failed to open $syms: $!\n";
809 next if (!/^[A-Za-z]/);
810 # Functions have a Perl_ prefix
811 # Variables have a PL_ prefix
813 my $symbol = ($syms =~ /var\.sym$/i ? "PL_" : "");
815 emit_symbol($symbol) unless exists $skip{$symbol};
822 if ($define{'MULTIPLICITY'}) {
823 for my $f ($perlvars_h, $intrpvar_h, $thrdvar_h) {
824 my $glob = readvar($f, sub { "Perl_" . $_[1] . $_[2] . "_ptr" });
827 # XXX AIX seems to want the perlvars.h symbols, for some reason
828 if ($PLATFORM eq 'aix') {
829 my $glob = readvar($perlvars_h);
834 unless ($define{'PERL_GLOBAL_STRUCT'}) {
835 my $glob = readvar($perlvars_h);
838 unless ($define{'MULTIPLICITY'}) {
839 my $glob = readvar($intrpvar_h);
842 unless ($define{'MULTIPLICITY'} || $define{'USE_5005THREADS'}) {
843 my $glob = readvar($thrdvar_h);
851 return if $symbol !~ /^[A-Za-z_]/;
852 return if $symbol =~ /^\#/;
855 return if exists $skip{$symbol};
856 emit_symbol($symbol);
863 if ($PLATFORM eq 'win32') {
864 foreach my $symbol (qw(
925 win32_getprotobynumber
1023 try_symbol($symbol);
1026 elsif ($PLATFORM eq 'os2') {
1027 open MAP, 'miniperl.map' or die 'Cannot read miniperl.map';
1028 /^\s*[\da-f:]+\s+(\w+)/i and $mapped{$1}++ foreach <MAP>;
1029 close MAP or die 'Cannot close miniperl.map';
1031 @missing = grep { !exists $mapped{$_} and !exists $bincompat5005{$_} }
1033 delete $export{$_} foreach @missing;
1035 elsif ($PLATFORM eq 'MacOS') {
1036 open MACSYMS, 'macperl.sym' or die 'Cannot read macperl.sym';
1044 elsif ($PLATFORM eq 'netware') {
1045 foreach my $symbol (qw(
1172 fnInsertHashListAddrs
1181 try_symbol($symbol);
1185 # Now all symbols should be defined because
1186 # next we are going to output them.
1188 foreach my $symbol (sort keys %export) {
1189 output_symbol($symbol);
1192 if ($PLATFORM eq 'os2') {
1193 print "; LAST_ORDINAL=$sym_ord\n";
1199 $export{$symbol} = 1;
1204 $symbol = $bincompat5005{$symbol}
1205 if $define{PERL_BINCOMPAT_5005} and $symbol =~ /^($bincompat5005)$/;
1206 if ($PLATFORM eq 'win32') {
1207 $symbol = "_$symbol" if $CCTYPE eq 'BORLAND';
1208 print "\t$symbol\n";
1209 # XXX: binary compatibility between compilers is an exercise
1210 # in frustration :-(
1211 # if ($CCTYPE eq "BORLAND") {
1212 # # workaround Borland quirk by exporting both the straight
1213 # # name and a name with leading underscore. Note the
1214 # # alias *must* come after the symbol itself, if both
1215 # # are to be exported. (Linker bug?)
1216 # print "\t_$symbol\n";
1217 # print "\t$symbol = _$symbol\n";
1219 # elsif ($CCTYPE eq 'GCC') {
1220 # # Symbols have leading _ whole process is $%@"% slow
1221 # # so skip aliases for now
1222 # nprint "\t$symbol\n";
1225 # # for binary coexistence, export both the symbol and
1226 # # alias with leading underscore
1227 # print "\t$symbol\n";
1228 # print "\t_$symbol = $symbol\n";
1231 elsif ($PLATFORM eq 'os2') {
1232 printf qq( %-31s \@%s\n),
1233 qq("$symbol"), $ordinal{$symbol} || ++$sym_ord;
1235 elsif ($PLATFORM eq 'aix' || $PLATFORM eq 'MacOS') {
1238 elsif ($PLATFORM eq 'netware') {
1239 print "\t$symbol,\n";
1245 # extra globals not included above.
1264 PerlIOBase_setlinebuf
1275 PerlIOBuf_set_ptrcnt