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)='(.+)'$/;
107 open(CFG,$config_h) || die "Cannot open $config_h: $!\n";
109 $define{$1} = 1 if /^\s*#\s*define\s+(MYMALLOC)\b/;
110 $define{$1} = 1 if /^\s*#\s*define\s+(MULTIPLICITY)\b/;
111 $define{$1} = 1 if /^\s*#\s*define\s+(PERL_\w+)\b/;
112 $define{$1} = 1 if /^\s*#\s*define\s+(USE_\w+)\b/;
116 # perl.h logic duplication begins
118 if ($define{USE_ITHREADS}) {
119 if (!$define{MULTIPLICITY} && !$define{PERL_OBJECT}) {
120 $define{MULTIPLICITY} = 1;
124 $define{PERL_IMPLICIT_CONTEXT} ||=
125 $define{USE_ITHREADS} ||
126 $define{USE_5005THREADS} ||
127 $define{MULTIPLICITY} ;
129 if ($define{PERL_CAPI}) {
130 delete $define{PERL_OBJECT};
131 $define{MULTIPLICITY} = 1;
132 $define{PERL_IMPLICIT_CONTEXT} = 1;
133 $define{PERL_IMPLICIT_SYS} = 1;
136 if ($define{PERL_OBJECT}) {
137 $define{PERL_IMPLICIT_CONTEXT} = 1;
138 $define{PERL_IMPLICIT_SYS} = 1;
141 # perl.h logic duplication ends
143 if ($PLATFORM eq 'win32') {
144 warn join(' ',keys %define)."\n";
145 print "LIBRARY Perl57\n";
146 print "DESCRIPTION 'Perl interpreter'\n";
148 if ($define{PERL_IMPLICIT_SYS}) {
149 output_symbol("perl_get_host_info");
150 output_symbol("perl_alloc_override");
151 output_symbol("perl_clone_host");
154 elsif ($PLATFORM eq 'os2') {
155 ($v = $]) =~ s/(\d\.\d\d\d)(\d\d)$/$1_$2/;
156 $v .= '-thread' if $ARCHNAME =~ /-thread/;
157 ($dll = $define{PERL_DLL}) =~ s/\.dll$//i;
158 $d = "DESCRIPTION '\@#perl5-porters\@perl.org:$v#\@ Perl interpreter, configured as $CONFIG_ARGS'";
159 $d = substr($d, 0, 249) . "...'" if length $d > 253;
161 LIBRARY '$dll' INITINSTANCE TERMINSTANCE
165 DATA LOADONCALL NONSHARED MULTIPLE
169 elsif ($PLATFORM eq 'aix') {
174 if ($OSVER > 4 || ($OSVER == 4 && $OSREL >= 3)) {
180 elsif ($PLATFORM eq 'netware') {
181 if ($FILETYPE eq 'def') {
182 print "LIBRARY Perl57\n";
183 print "DESCRIPTION 'Perl interpreter for NetWare'\n";
186 if ($define{PERL_IMPLICIT_SYS}) {
187 output_symbol("perl_get_host_info");
188 output_symbol("perl_alloc_override");
189 output_symbol("perl_clone_host");
198 foreach my $symbol (@$list) {
205 foreach my $symbol (@$list) {
206 my $skipsym = $symbol;
208 if ($define{PERL_OBJECT} || $define{MULTIPLICITY}) {
209 $skipsym =~ s/^Perl_[GIT](\w+)_ptr$/PL_$1/;
211 emit_symbol($symbol) unless exists $skip{$skipsym};
215 if ($PLATFORM eq 'win32') {
240 Perl_init_thread_intern
266 elsif ($PLATFORM eq 'aix') {
285 Perl_sys_intern_clear
294 elsif ($PLATFORM eq 'os2') {
329 XS_Cwd_extLibpath_set
333 XS_Cwd_sys_is_absolute
334 XS_Cwd_sys_is_relative
336 XS_DynaLoader_mod2fname
337 XS_File__Copy_syscopy
341 Perl_Process_Messages
349 elsif ($PLATFORM eq 'MacOS') {
373 Perl_sys_intern_clear
377 elsif ($PLATFORM eq 'netware') {
402 Perl_init_thread_intern
428 unless ($define{'DEBUGGING'}) {
443 if ($define{'PERL_IMPLICIT_SYS'}) {
464 unless ($define{'PERL_FLEXIBLE_EXCEPTIONS'}) {
468 Perl_vdefault_protect
472 if ($define{'MYMALLOC'}) {
479 if ($define{'USE_5005THREADS'} || $define{'USE_ITHREADS'}) {
499 unless ($define{'USE_5005THREADS'} || $define{'USE_ITHREADS'}) {
505 unless ($define{'USE_5005THREADS'}) {
524 Perl_new_struct_thread
525 Perl_per_thread_magicals
534 unless ($define{'USE_ITHREADS'}) {
563 unless ($define{'PERL_IMPLICIT_CONTEXT'}) {
569 Perl_load_module_nocontext
572 Perl_warner_nocontext
573 Perl_newSVpvf_nocontext
574 Perl_sv_catpvf_nocontext
575 Perl_sv_setpvf_nocontext
576 Perl_sv_catpvf_mg_nocontext
577 Perl_sv_setpvf_mg_nocontext
581 unless ($define{'PERL_IMPLICIT_SYS'}) {
588 unless ($define{'FAKE_THREADS'}) {
589 skip_symbols [qw(PL_curthr)];
594 my $proc = shift || sub { "PL_$_[2]" };
595 open(VARS,$file) || die "Cannot open $file: $!\n";
598 # All symbols have a Perl_ prefix because that's what embed.h
599 # sticks in front of them.
600 push(@syms, &$proc($1,$2,$3)) if (/\bPERLVAR(A?I?C?)\(([IGT])(\w+)/);
606 if ($define{'USE_5005THREADS'}) {
607 my $thrd = readvar($thrdvar_h);
611 if ($define{'PERL_GLOBAL_STRUCT'}) {
612 my $global = readvar($perlvars_h);
613 skip_symbols $global;
614 emit_symbol('Perl_GetVars');
615 emit_symbols [qw(PL_Vars PL_VarsPtr)] unless $CCTYPE eq 'GCC';
618 # functions from *.sym files
620 my @syms = ($global_sym, $globvar_sym); # $pp_sym is not part of the API
628 PerlIOBase_setlinebuf
653 if ($define{'USE_PERLIO'}) {
654 push @syms, $perlio_sym;
655 if ($define{'USE_SFIO'}) {
656 skip_symbols \@layer_syms;
657 # SFIO defines most of the PerlIO routines as macros
703 # Skip the PerlIO New Generation symbols.
704 skip_symbols \@layer_syms;
707 for my $syms (@syms) {
708 open (GLOBAL, "<$syms") || die "failed to open $syms: $!\n";
710 next if (!/^[A-Za-z]/);
711 # Functions have a Perl_ prefix
712 # Variables have a PL_ prefix
714 my $symbol = ($syms =~ /var\.sym$/i ? "PL_" : "");
716 emit_symbol($symbol) unless exists $skip{$symbol};
723 if ($define{'PERL_OBJECT'} || $define{'MULTIPLICITY'}) {
724 for my $f ($perlvars_h, $intrpvar_h, $thrdvar_h) {
725 my $glob = readvar($f, sub { "Perl_" . $_[1] . $_[2] . "_ptr" });
728 # XXX AIX seems to want the perlvars.h symbols, for some reason
729 if ($PLATFORM eq 'aix') {
730 my $glob = readvar($perlvars_h);
735 unless ($define{'PERL_GLOBAL_STRUCT'}) {
736 my $glob = readvar($perlvars_h);
739 unless ($define{'MULTIPLICITY'}) {
740 my $glob = readvar($intrpvar_h);
743 unless ($define{'MULTIPLICITY'} || $define{'USE_5005THREADS'}) {
744 my $glob = readvar($thrdvar_h);
752 return if $symbol !~ /^[A-Za-z]/;
753 return if $symbol =~ /^\#/;
756 return if exists $skip{$symbol};
757 emit_symbol($symbol);
764 if ($PLATFORM eq 'win32') {
765 foreach my $symbol (qw(
825 win32_getprotobynumber
922 elsif ($PLATFORM eq 'os2') {
923 open MAP, 'miniperl.map' or die 'Cannot read miniperl.map';
924 /^\s*[\da-f:]+\s+(\w+)/i and $mapped{$1}++ foreach <MAP>;
925 close MAP or die 'Cannot close miniperl.map';
927 @missing = grep { !exists $mapped{$_} and !exists $bincompat5005{$_} }
929 delete $export{$_} foreach @missing;
931 elsif ($PLATFORM eq 'MacOS') {
932 open MACSYMS, 'macperl.sym' or die 'Cannot read macperl.sym';
940 elsif ($PLATFORM eq 'netware') {
941 foreach my $symbol (qw(
1066 fnInsertHashListAddrs
1071 try_symbol($symbol);
1075 # Now all symbols should be defined because
1076 # next we are going to output them.
1078 foreach my $symbol (sort keys %export) {
1079 output_symbol($symbol);
1082 if ($PLATFORM eq 'netware') {
1083 # This may not be the right way to do. This is to make sure
1084 # that the last symbol will not contain a comma else
1085 # Watcom linker cribs
1092 $export{$symbol} = 1;
1099 $symbol = $bincompat5005{$symbol}
1100 if $define{PERL_BINCOMPAT_5005} and $symbol =~ /^($bincompat5005)$/;
1101 if ($PLATFORM eq 'win32') {
1102 $symbol = "_$symbol" if $CCTYPE eq 'BORLAND';
1103 print "\t$symbol\n";
1104 # XXX: binary compatibility between compilers is an exercise
1105 # in frustration :-(
1106 # if ($CCTYPE eq "BORLAND") {
1107 # # workaround Borland quirk by exporting both the straight
1108 # # name and a name with leading underscore. Note the
1109 # # alias *must* come after the symbol itself, if both
1110 # # are to be exported. (Linker bug?)
1111 # print "\t_$symbol\n";
1112 # print "\t$symbol = _$symbol\n";
1114 # elsif ($CCTYPE eq 'GCC') {
1115 # # Symbols have leading _ whole process is $%@"% slow
1116 # # so skip aliases for now
1117 # nprint "\t$symbol\n";
1120 # # for binary coexistence, export both the symbol and
1121 # # alias with leading underscore
1122 # print "\t$symbol\n";
1123 # print "\t_$symbol = $symbol\n";
1126 elsif ($PLATFORM eq 'os2') {
1127 printf qq( %-31s \@%s\n), qq("$symbol"), ++$sym_ord;
1129 elsif ($PLATFORM eq 'aix' || $PLATFORM eq 'MacOS') {
1132 elsif ($PLATFORM eq 'netware') {
1133 print "\t$symbol,\n";
1139 # extra globals not included above.
1150 PerlIOBuf_set_ptrcnt
1155 PerlIOBase_setlinebuf