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;
155 LIBRARY '$dll' INITINSTANCE TERMINSTANCE
156 DESCRIPTION '\@#perl5-porters\@perl.org:$v#\@ Perl interpreter'
159 DATA LOADONCALL NONSHARED MULTIPLE
163 elsif ($PLATFORM eq 'aix') {
172 foreach my $symbol (@$list) {
179 foreach my $symbol (@$list) {
180 my $skipsym = $symbol;
182 if ($define{PERL_OBJECT} || $define{MULTIPLICITY}) {
183 $skipsym =~ s/^Perl_[GIT](\w+)_ptr$/PL_$1/;
185 emit_symbol($symbol) unless exists $skip{$skipsym};
189 if ($PLATFORM eq 'win32') {
214 Perl_init_thread_intern
239 elsif ($PLATFORM eq 'aix') {
258 Perl_sys_intern_clear
267 elsif ($PLATFORM eq 'os2') {
294 XS_Cwd_extLibpath_set
298 XS_Cwd_sys_is_absolute
299 XS_Cwd_sys_is_relative
301 XS_DynaLoader_mod2fname
302 XS_File__Copy_syscopy
306 Perl_Process_Messages
312 elsif ($PLATFORM eq 'MacOS') {
336 Perl_sys_intern_clear
342 unless ($define{'DEBUGGING'}) {
357 if ($define{'PERL_IMPLICIT_SYS'}) {
378 unless ($define{'PERL_FLEXIBLE_EXCEPTIONS'}) {
382 Perl_vdefault_protect
386 if ($define{'MYMALLOC'}) {
397 if ($define{'USE_5005THREADS'} || $define{'USE_ITHREADS'}) {
421 unless ($define{'USE_5005THREADS'} || $define{'USE_ITHREADS'}) {
427 unless ($define{'USE_5005THREADS'}) {
446 Perl_new_struct_thread
447 Perl_per_thread_magicals
456 unless ($define{'USE_ITHREADS'}) {
485 unless ($define{'PERL_IMPLICIT_CONTEXT'}) {
491 Perl_load_module_nocontext
494 Perl_warner_nocontext
495 Perl_newSVpvf_nocontext
496 Perl_sv_catpvf_nocontext
497 Perl_sv_setpvf_nocontext
498 Perl_sv_catpvf_mg_nocontext
499 Perl_sv_setpvf_mg_nocontext
503 unless ($define{'PERL_IMPLICIT_SYS'}) {
510 unless ($define{'FAKE_THREADS'}) {
511 skip_symbols [qw(PL_curthr)];
516 my $proc = shift || sub { "PL_$_[2]" };
517 open(VARS,$file) || die "Cannot open $file: $!\n";
520 # All symbols have a Perl_ prefix because that's what embed.h
521 # sticks in front of them.
522 push(@syms, &$proc($1,$2,$3)) if (/\bPERLVAR(A?I?C?)\(([IGT])(\w+)/);
528 if ($define{'USE_5005THREADS'}) {
529 my $thrd = readvar($thrdvar_h);
533 if ($define{'PERL_GLOBAL_STRUCT'}) {
534 my $global = readvar($perlvars_h);
535 skip_symbols $global;
536 emit_symbol('Perl_GetVars');
537 emit_symbols [qw(PL_Vars PL_VarsPtr)] unless $CCTYPE eq 'GCC';
540 # functions from *.sym files
542 my @syms = ($global_sym, $globvar_sym); # $pp_sym is not part of the API
572 if ($define{'USE_PERLIO'}) {
573 push @syms, $perlio_sym;
574 if ($define{'USE_SFIO'}) {
575 skip_symbols \@layer_syms;
576 # SFIO defines most of the PerlIO routines as macros
622 # Skip the PerlIO New Generation symbols.
623 skip_symbols \@layer_syms;
626 for my $syms (@syms) {
627 open (GLOBAL, "<$syms") || die "failed to open $syms: $!\n";
629 next if (!/^[A-Za-z]/);
630 # Functions have a Perl_ prefix
631 # Variables have a PL_ prefix
633 my $symbol = ($syms =~ /var\.sym$/i ? "PL_" : "");
635 emit_symbol($symbol) unless exists $skip{$symbol};
642 if ($define{'PERL_OBJECT'} || $define{'MULTIPLICITY'}) {
643 for my $f ($perlvars_h, $intrpvar_h, $thrdvar_h) {
644 my $glob = readvar($f, sub { "Perl_" . $_[1] . $_[2] . "_ptr" });
647 # XXX AIX seems to want the perlvars.h symbols, for some reason
648 if ($PLATFORM eq 'aix') {
649 my $glob = readvar($perlvars_h);
654 unless ($define{'PERL_GLOBAL_STRUCT'}) {
655 my $glob = readvar($perlvars_h);
658 unless ($define{'MULTIPLICITY'}) {
659 my $glob = readvar($intrpvar_h);
662 unless ($define{'MULTIPLICITY'} || $define{'USE_5005THREADS'}) {
663 my $glob = readvar($thrdvar_h);
671 return if $symbol !~ /^[A-Za-z]/;
672 return if $symbol =~ /^\#/;
675 return if exists $skip{$symbol};
676 emit_symbol($symbol);
683 if ($PLATFORM eq 'win32') {
684 foreach my $symbol (qw(
744 win32_getprotobynumber
841 elsif ($PLATFORM eq 'os2') {
842 open MAP, 'miniperl.map' or die 'Cannot read miniperl.map';
843 /^\s*[\da-f:]+\s+(\w+)/i and $mapped{$1}++ foreach <MAP>;
844 close MAP or die 'Cannot close miniperl.map';
846 @missing = grep { !exists $mapped{$_} and !exists $bincompat5005{$_} }
848 delete $export{$_} foreach @missing;
850 elsif ($PLATFORM eq 'MacOS') {
851 open MACSYMS, 'macperl.sym' or die 'Cannot read macperl.sym';
860 # Now all symbols should be defined because
861 # next we are going to output them.
863 foreach my $symbol (sort keys %export) {
864 output_symbol($symbol);
870 $export{$symbol} = 1;
875 $symbol = $bincompat5005{$symbol}
876 if $define{PERL_BINCOMPAT_5005} and $symbol =~ /^($bincompat5005)$/;
877 if ($PLATFORM eq 'win32') {
878 $symbol = "_$symbol" if $CCTYPE eq 'BORLAND';
880 # XXX: binary compatibility between compilers is an exercise
882 # if ($CCTYPE eq "BORLAND") {
883 # # workaround Borland quirk by exporting both the straight
884 # # name and a name with leading underscore. Note the
885 # # alias *must* come after the symbol itself, if both
886 # # are to be exported. (Linker bug?)
887 # print "\t_$symbol\n";
888 # print "\t$symbol = _$symbol\n";
890 # elsif ($CCTYPE eq 'GCC') {
891 # # Symbols have leading _ whole process is $%@"% slow
892 # # so skip aliases for now
893 # nprint "\t$symbol\n";
896 # # for binary coexistence, export both the symbol and
897 # # alias with leading underscore
898 # print "\t$symbol\n";
899 # print "\t_$symbol = $symbol\n";
902 elsif ($PLATFORM eq 'os2') {
903 print qq( "$symbol"\n);
905 elsif ($PLATFORM eq 'aix' || $PLATFORM eq 'MacOS') {
912 # extra globals not included above.