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+)$/);
55 my @PLATFORM = qw(aix win32 os2 MacOS);
57 @PLATFORM{@PLATFORM} = ();
59 defined $PLATFORM || die "PLATFORM undefined, must be one of: @PLATFORM\n";
60 exists $PLATFORM{$PLATFORM} || die "PLATFORM must be one of: @PLATFORM\n";
62 my $config_sh = "config.sh";
63 my $config_h = "config.h";
64 my $thrdvar_h = "thrdvar.h";
65 my $intrpvar_h = "intrpvar.h";
66 my $perlvars_h = "perlvars.h";
67 my $global_sym = "global.sym";
68 my $pp_sym = "pp.sym";
69 my $globvar_sym = "globvar.sym";
70 my $perlio_sym = "perlio.sym";
72 if ($PLATFORM eq 'aix') {
75 elsif ($PLATFORM eq 'win32') {
76 $CCTYPE = "MSVC" unless defined $CCTYPE;
77 foreach ($thrdvar_h, $intrpvar_h, $perlvars_h, $global_sym,
78 $pp_sym, $globvar_sym, $perlio_sym) {
82 elsif ($PLATFORM eq 'MacOS') {
83 foreach ($thrdvar_h, $intrpvar_h, $perlvars_h, $global_sym,
84 $pp_sym, $globvar_sym, $perlio_sym) {
89 unless ($PLATFORM eq 'win32' || $PLATFORM eq 'MacOS') {
90 open(CFG,$config_sh) || die "Cannot open $config_sh: $!\n";
92 if (/^(?:ccflags|optimize)='(.+)'$/) {
94 $define{$1} = 1 while /-D(\w+)/g;
96 if ($PLATFORM eq 'os2') {
97 $CONFIG_ARGS = $1 if /^(?:config_args)='(.+)'$/;
98 $ARCHNAME = $1 if /^(?:archname)='(.+)'$/;
104 open(CFG,$config_h) || die "Cannot open $config_h: $!\n";
106 $define{$1} = 1 if /^\s*#\s*define\s+(MYMALLOC)\b/;
107 $define{$1} = 1 if /^\s*#\s*define\s+(MULTIPLICITY)\b/;
108 $define{$1} = 1 if /^\s*#\s*define\s+(PERL_\w+)\b/;
109 $define{$1} = 1 if /^\s*#\s*define\s+(USE_\w+)\b/;
113 # perl.h logic duplication begins
115 if ($define{USE_ITHREADS}) {
116 if (!$define{MULTIPLICITY} && !$define{PERL_OBJECT}) {
117 $define{MULTIPLICITY} = 1;
121 $define{PERL_IMPLICIT_CONTEXT} ||=
122 $define{USE_ITHREADS} ||
123 $define{USE_5005THREADS} ||
124 $define{MULTIPLICITY} ;
126 if ($define{PERL_CAPI}) {
127 delete $define{PERL_OBJECT};
128 $define{MULTIPLICITY} = 1;
129 $define{PERL_IMPLICIT_CONTEXT} = 1;
130 $define{PERL_IMPLICIT_SYS} = 1;
133 if ($define{PERL_OBJECT}) {
134 $define{PERL_IMPLICIT_CONTEXT} = 1;
135 $define{PERL_IMPLICIT_SYS} = 1;
138 # perl.h logic duplication ends
140 if ($PLATFORM eq 'win32') {
141 warn join(' ',keys %define)."\n";
142 print "LIBRARY Perl57\n";
143 print "DESCRIPTION 'Perl interpreter'\n";
145 if ($define{PERL_IMPLICIT_SYS}) {
146 output_symbol("perl_get_host_info");
147 output_symbol("perl_alloc_override");
150 elsif ($PLATFORM eq 'os2') {
151 ($v = $]) =~ s/(\d\.\d\d\d)(\d\d)$/$1_$2/;
152 $v .= '-thread' if $ARCHNAME =~ /-thread/;
153 ($dll = $define{PERL_DLL}) =~ s/\.dll$//i;
154 $d = "DESCRIPTION '\@#perl5-porters\@perl.org:$v#\@ Perl interpreter, configured as $CONFIG_ARGS'";
155 $d = substr($d, 0, 249) . "...'" if length $d > 253;
157 LIBRARY '$dll' INITINSTANCE TERMINSTANCE
161 DATA LOADONCALL NONSHARED MULTIPLE
165 elsif ($PLATFORM eq 'aix') {
174 foreach my $symbol (@$list) {
181 foreach my $symbol (@$list) {
182 my $skipsym = $symbol;
184 if ($define{PERL_OBJECT} || $define{MULTIPLICITY}) {
185 $skipsym =~ s/^Perl_[GIT](\w+)_ptr$/PL_$1/;
187 emit_symbol($symbol) unless exists $skip{$skipsym};
191 if ($PLATFORM eq 'win32') {
216 Perl_init_thread_intern
241 elsif ($PLATFORM eq 'aix') {
260 Perl_sys_intern_clear
269 elsif ($PLATFORM eq 'os2') {
296 XS_Cwd_extLibpath_set
300 XS_Cwd_sys_is_absolute
301 XS_Cwd_sys_is_relative
303 XS_DynaLoader_mod2fname
304 XS_File__Copy_syscopy
308 Perl_Process_Messages
314 elsif ($PLATFORM eq 'MacOS') {
338 Perl_sys_intern_clear
344 unless ($define{'DEBUGGING'}) {
359 if ($define{'PERL_IMPLICIT_SYS'}) {
380 unless ($define{'PERL_FLEXIBLE_EXCEPTIONS'}) {
384 Perl_vdefault_protect
388 if ($define{'MYMALLOC'}) {
399 if ($define{'USE_5005THREADS'} || $define{'USE_ITHREADS'}) {
423 unless ($define{'USE_5005THREADS'} || $define{'USE_ITHREADS'}) {
429 unless ($define{'USE_5005THREADS'}) {
448 Perl_new_struct_thread
449 Perl_per_thread_magicals
458 unless ($define{'USE_ITHREADS'}) {
487 unless ($define{'PERL_IMPLICIT_CONTEXT'}) {
493 Perl_load_module_nocontext
496 Perl_warner_nocontext
497 Perl_newSVpvf_nocontext
498 Perl_sv_catpvf_nocontext
499 Perl_sv_setpvf_nocontext
500 Perl_sv_catpvf_mg_nocontext
501 Perl_sv_setpvf_mg_nocontext
505 unless ($define{'PERL_IMPLICIT_SYS'}) {
512 unless ($define{'FAKE_THREADS'}) {
513 skip_symbols [qw(PL_curthr)];
518 my $proc = shift || sub { "PL_$_[2]" };
519 open(VARS,$file) || die "Cannot open $file: $!\n";
522 # All symbols have a Perl_ prefix because that's what embed.h
523 # sticks in front of them.
524 push(@syms, &$proc($1,$2,$3)) if (/\bPERLVAR(A?I?C?)\(([IGT])(\w+)/);
530 if ($define{'USE_5005THREADS'}) {
531 my $thrd = readvar($thrdvar_h);
535 if ($define{'PERL_GLOBAL_STRUCT'}) {
536 my $global = readvar($perlvars_h);
537 skip_symbols $global;
538 emit_symbol('Perl_GetVars');
539 emit_symbols [qw(PL_Vars PL_VarsPtr)] unless $CCTYPE eq 'GCC';
542 # functions from *.sym files
544 my @syms = ($global_sym, $globvar_sym); # $pp_sym is not part of the API
552 PerlIOBase_setlinebuf
577 if ($define{'USE_PERLIO'}) {
578 push @syms, $perlio_sym;
579 if ($define{'USE_SFIO'}) {
580 skip_symbols \@layer_syms;
581 # SFIO defines most of the PerlIO routines as macros
627 # Skip the PerlIO New Generation symbols.
628 skip_symbols \@layer_syms;
631 for my $syms (@syms) {
632 open (GLOBAL, "<$syms") || die "failed to open $syms: $!\n";
634 next if (!/^[A-Za-z]/);
635 # Functions have a Perl_ prefix
636 # Variables have a PL_ prefix
638 my $symbol = ($syms =~ /var\.sym$/i ? "PL_" : "");
640 emit_symbol($symbol) unless exists $skip{$symbol};
647 if ($define{'PERL_OBJECT'} || $define{'MULTIPLICITY'}) {
648 for my $f ($perlvars_h, $intrpvar_h, $thrdvar_h) {
649 my $glob = readvar($f, sub { "Perl_" . $_[1] . $_[2] . "_ptr" });
652 # XXX AIX seems to want the perlvars.h symbols, for some reason
653 if ($PLATFORM eq 'aix') {
654 my $glob = readvar($perlvars_h);
659 unless ($define{'PERL_GLOBAL_STRUCT'}) {
660 my $glob = readvar($perlvars_h);
663 unless ($define{'MULTIPLICITY'}) {
664 my $glob = readvar($intrpvar_h);
667 unless ($define{'MULTIPLICITY'} || $define{'USE_5005THREADS'}) {
668 my $glob = readvar($thrdvar_h);
676 return if $symbol !~ /^[A-Za-z]/;
677 return if $symbol =~ /^\#/;
680 return if exists $skip{$symbol};
681 emit_symbol($symbol);
688 if ($PLATFORM eq 'win32') {
689 foreach my $symbol (qw(
749 win32_getprotobynumber
846 elsif ($PLATFORM eq 'os2') {
847 open MAP, 'miniperl.map' or die 'Cannot read miniperl.map';
848 /^\s*[\da-f:]+\s+(\w+)/i and $mapped{$1}++ foreach <MAP>;
849 close MAP or die 'Cannot close miniperl.map';
851 @missing = grep { !exists $mapped{$_} and !exists $bincompat5005{$_} }
853 delete $export{$_} foreach @missing;
855 elsif ($PLATFORM eq 'MacOS') {
856 open MACSYMS, 'macperl.sym' or die 'Cannot read macperl.sym';
865 # Now all symbols should be defined because
866 # next we are going to output them.
868 foreach my $symbol (sort keys %export) {
869 output_symbol($symbol);
875 $export{$symbol} = 1;
880 $symbol = $bincompat5005{$symbol}
881 if $define{PERL_BINCOMPAT_5005} and $symbol =~ /^($bincompat5005)$/;
882 if ($PLATFORM eq 'win32') {
883 $symbol = "_$symbol" if $CCTYPE eq 'BORLAND';
885 # XXX: binary compatibility between compilers is an exercise
887 # if ($CCTYPE eq "BORLAND") {
888 # # workaround Borland quirk by exporting both the straight
889 # # name and a name with leading underscore. Note the
890 # # alias *must* come after the symbol itself, if both
891 # # are to be exported. (Linker bug?)
892 # print "\t_$symbol\n";
893 # print "\t$symbol = _$symbol\n";
895 # elsif ($CCTYPE eq 'GCC') {
896 # # Symbols have leading _ whole process is $%@"% slow
897 # # so skip aliases for now
898 # nprint "\t$symbol\n";
901 # # for binary coexistence, export both the symbol and
902 # # alias with leading underscore
903 # print "\t$symbol\n";
904 # print "\t_$symbol = $symbol\n";
907 elsif ($PLATFORM eq 'os2') {
908 print qq( "$symbol"\n);
910 elsif ($PLATFORM eq 'aix' || $PLATFORM eq 'MacOS') {
917 # extra globals not included above.
933 PerlIOBase_setlinebuf