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 # perl.h logic duplication ends
138 if ($PLATFORM eq 'win32') {
139 warn join(' ',keys %define)."\n";
140 print "LIBRARY Perl57\n";
141 print "DESCRIPTION 'Perl interpreter'\n";
143 if ($define{PERL_IMPLICIT_SYS}) {
144 output_symbol("perl_get_host_info");
145 output_symbol("perl_alloc_override");
146 output_symbol("perl_clone_host");
149 elsif ($PLATFORM eq 'os2') {
150 if (open my $fh, '<', 'perl5.def') {
152 last if /^\s*EXPORTS\b/;
155 $ordinal{$1} = $2 if /^\s*"(\w+)"\s*\@(\d+)\s*$/;
156 # This allows skipping ordinals which were used in older versions
157 $sym_ord = $1 if /^\s*;\s*LAST_ORDINAL\s*=\s*(\d+)\s*$/;
159 $sym_ord < $_ and $sym_ord = $_ for values %ordinal; # Take the max
161 ($v = $]) =~ s/(\d\.\d\d\d)(\d\d)$/$1_$2/;
162 $v .= '-thread' if $ARCHNAME =~ /-thread/;
163 ($dll = $define{PERL_DLL}) =~ s/\.dll$//i;
164 $v .= "\@$PATCHLEVEL" if $PATCHLEVEL;
165 $d = "DESCRIPTION '\@#perl5-porters\@perl.org:$v#\@ Perl interpreter, configured as $CONFIG_ARGS'";
166 $d = substr($d, 0, 249) . "...'" if length $d > 253;
168 LIBRARY '$dll' INITINSTANCE TERMINSTANCE
172 DATA LOADONCALL NONSHARED MULTIPLE
176 elsif ($PLATFORM eq 'aix') {
181 if ($OSVER > 4 || ($OSVER == 4 && $OSREL >= 3)) {
187 elsif ($PLATFORM eq 'netware') {
188 if ($FILETYPE eq 'def') {
189 print "LIBRARY Perl57\n";
190 print "DESCRIPTION 'Perl interpreter for NetWare'\n";
193 if ($define{PERL_IMPLICIT_SYS}) {
194 output_symbol("perl_get_host_info");
195 output_symbol("perl_alloc_override");
196 output_symbol("perl_clone_host");
205 foreach my $symbol (@$list) {
212 foreach my $symbol (@$list) {
213 my $skipsym = $symbol;
215 if ($define{MULTIPLICITY}) {
216 $skipsym =~ s/^Perl_[GIT](\w+)_ptr$/PL_$1/;
218 emit_symbol($symbol) unless exists $skip{$skipsym};
222 if ($PLATFORM eq 'win32') {
247 Perl_init_thread_intern
273 elsif ($PLATFORM eq 'aix') {
292 Perl_sys_intern_clear
301 elsif ($PLATFORM eq 'os2') {
338 XS_Cwd_extLibpath_set
342 XS_Cwd_sys_is_absolute
343 XS_Cwd_sys_is_relative
345 XS_DynaLoader_mod2fname
346 XS_File__Copy_syscopy
350 Perl_Process_Messages
361 elsif ($PLATFORM eq 'MacOS') {
385 Perl_sys_intern_clear
389 elsif ($PLATFORM eq 'netware') {
414 Perl_init_thread_intern
440 unless ($define{'DEBUGGING'}) {
454 if ($define{'PERL_IMPLICIT_SYS'}) {
475 unless ($define{'PERL_FLEXIBLE_EXCEPTIONS'}) {
479 Perl_vdefault_protect
483 unless ($define{'USE_REENTRANT_API'}) {
489 if ($define{'MYMALLOC'}) {
496 if ($define{'USE_5005THREADS'} || $define{'USE_ITHREADS'}) {
516 unless ($define{'USE_5005THREADS'} || $define{'USE_ITHREADS'}) {
522 unless ($define{'USE_5005THREADS'}) {
541 Perl_new_struct_thread
542 Perl_per_thread_magicals
551 unless ($define{'USE_ITHREADS'}) {
558 PL_sharedsv_space_mutex
585 Perl_sharedsv_thrcnt_dec
586 Perl_sharedsv_thrcnt_inc
591 unless ($define{'PERL_IMPLICIT_CONTEXT'}) {
597 Perl_load_module_nocontext
600 Perl_warner_nocontext
601 Perl_newSVpvf_nocontext
602 Perl_sv_catpvf_nocontext
603 Perl_sv_setpvf_nocontext
604 Perl_sv_catpvf_mg_nocontext
605 Perl_sv_setpvf_mg_nocontext
609 unless ($define{'PERL_IMPLICIT_SYS'}) {
616 unless ($define{'FAKE_THREADS'}) {
617 skip_symbols [qw(PL_curthr)];
620 unless ($define{'PL_OP_SLAB_ALLOC'}) {
630 my $proc = shift || sub { "PL_$_[2]" };
631 open(VARS,$file) || die "Cannot open $file: $!\n";
634 # All symbols have a Perl_ prefix because that's what embed.h
635 # sticks in front of them.
636 push(@syms, &$proc($1,$2,$3)) if (/\bPERLVAR(A?I?C?)\(([IGT])(\w+)/);
642 if ($define{'USE_5005THREADS'}) {
643 my $thrd = readvar($thrdvar_h);
647 if ($define{'PERL_GLOBAL_STRUCT'}) {
648 my $global = readvar($perlvars_h);
649 skip_symbols $global;
650 emit_symbol('Perl_GetVars');
651 emit_symbols [qw(PL_Vars PL_VarsPtr)] unless $CCTYPE eq 'GCC';
654 # functions from *.sym files
656 my @syms = ($global_sym, $globvar_sym); # $pp_sym is not part of the API
667 PerlIOBase_setlinebuf
694 if ($define{'USE_PERLIO'}) {
695 push @syms, $perlio_sym;
696 if ($define{'USE_SFIO'}) {
697 skip_symbols \@layer_syms;
698 # SFIO defines most of the PerlIO routines as macros
744 # Skip the PerlIO New Generation symbols.
745 skip_symbols \@layer_syms;
748 for my $syms (@syms) {
749 open (GLOBAL, "<$syms") || die "failed to open $syms: $!\n";
751 next if (!/^[A-Za-z]/);
752 # Functions have a Perl_ prefix
753 # Variables have a PL_ prefix
755 my $symbol = ($syms =~ /var\.sym$/i ? "PL_" : "");
757 emit_symbol($symbol) unless exists $skip{$symbol};
764 if ($define{'MULTIPLICITY'}) {
765 for my $f ($perlvars_h, $intrpvar_h, $thrdvar_h) {
766 my $glob = readvar($f, sub { "Perl_" . $_[1] . $_[2] . "_ptr" });
769 # XXX AIX seems to want the perlvars.h symbols, for some reason
770 if ($PLATFORM eq 'aix') {
771 my $glob = readvar($perlvars_h);
776 unless ($define{'PERL_GLOBAL_STRUCT'}) {
777 my $glob = readvar($perlvars_h);
780 unless ($define{'MULTIPLICITY'}) {
781 my $glob = readvar($intrpvar_h);
784 unless ($define{'MULTIPLICITY'} || $define{'USE_5005THREADS'}) {
785 my $glob = readvar($thrdvar_h);
793 return if $symbol !~ /^[A-Za-z_]/;
794 return if $symbol =~ /^\#/;
797 return if exists $skip{$symbol};
798 emit_symbol($symbol);
805 if ($PLATFORM eq 'win32') {
806 foreach my $symbol (qw(
867 win32_getprotobynumber
968 elsif ($PLATFORM eq 'os2') {
969 open MAP, 'miniperl.map' or die 'Cannot read miniperl.map';
970 /^\s*[\da-f:]+\s+(\w+)/i and $mapped{$1}++ foreach <MAP>;
971 close MAP or die 'Cannot close miniperl.map';
973 @missing = grep { !exists $mapped{$_} and !exists $bincompat5005{$_} }
975 delete $export{$_} foreach @missing;
977 elsif ($PLATFORM eq 'MacOS') {
978 open MACSYMS, 'macperl.sym' or die 'Cannot read macperl.sym';
986 elsif ($PLATFORM eq 'netware') {
987 foreach my $symbol (qw(
1114 fnInsertHashListAddrs
1119 try_symbol($symbol);
1123 # Now all symbols should be defined because
1124 # next we are going to output them.
1126 foreach my $symbol (sort keys %export) {
1127 output_symbol($symbol);
1130 if ($PLATFORM eq 'netware') {
1131 # This may not be the right way to do. This is to make sure
1132 # that the last symbol will not contain a comma else
1133 # Watcom linker cribs
1135 } elsif ($PLATFORM eq 'os2') {
1136 print "; LAST_ORDINAL=$sym_ord\n";
1142 $export{$symbol} = 1;
1147 $symbol = $bincompat5005{$symbol}
1148 if $define{PERL_BINCOMPAT_5005} and $symbol =~ /^($bincompat5005)$/;
1149 if ($PLATFORM eq 'win32') {
1150 $symbol = "_$symbol" if $CCTYPE eq 'BORLAND';
1151 print "\t$symbol\n";
1152 # XXX: binary compatibility between compilers is an exercise
1153 # in frustration :-(
1154 # if ($CCTYPE eq "BORLAND") {
1155 # # workaround Borland quirk by exporting both the straight
1156 # # name and a name with leading underscore. Note the
1157 # # alias *must* come after the symbol itself, if both
1158 # # are to be exported. (Linker bug?)
1159 # print "\t_$symbol\n";
1160 # print "\t$symbol = _$symbol\n";
1162 # elsif ($CCTYPE eq 'GCC') {
1163 # # Symbols have leading _ whole process is $%@"% slow
1164 # # so skip aliases for now
1165 # nprint "\t$symbol\n";
1168 # # for binary coexistence, export both the symbol and
1169 # # alias with leading underscore
1170 # print "\t$symbol\n";
1171 # print "\t_$symbol = $symbol\n";
1174 elsif ($PLATFORM eq 'os2') {
1175 printf qq( %-31s \@%s\n),
1176 qq("$symbol"), $ordinal{$symbol} || ++$sym_ord;
1178 elsif ($PLATFORM eq 'aix' || $PLATFORM eq 'MacOS') {
1181 elsif ($PLATFORM eq 'netware') {
1182 print "\t$symbol,\n";
1188 # extra globals not included above.
1207 PerlIOBase_setlinebuf
1218 PerlIOBuf_set_ptrcnt