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.
7 # reads global.sym, pp.sym, perlvars.h, intrpvar.h, thrdvar.h, config.h
8 # On OS/2 reads miniperl.map as well
15 Perl_call_atexit => "perl_atexit",
16 Perl_eval_sv => "perl_eval_sv",
17 Perl_eval_pv => "perl_eval_pv",
18 Perl_call_argv => "perl_call_argv",
19 Perl_call_method => "perl_call_method",
20 Perl_call_pv => "perl_call_pv",
21 Perl_call_sv => "perl_call_sv",
22 Perl_get_av => "perl_get_av",
23 Perl_get_cv => "perl_get_cv",
24 Perl_get_hv => "perl_get_hv",
25 Perl_get_sv => "perl_get_sv",
26 Perl_init_i18nl10n => "perl_init_i18nl10n",
27 Perl_init_i18nl14n => "perl_init_i18nl14n",
28 Perl_new_collate => "perl_new_collate",
29 Perl_new_ctype => "perl_new_ctype",
30 Perl_new_numeric => "perl_new_numeric",
31 Perl_require_pv => "perl_require_pv",
32 Perl_safesyscalloc => "Perl_safecalloc",
33 Perl_safesysfree => "Perl_safefree",
34 Perl_safesysmalloc => "Perl_safemalloc",
35 Perl_safesysrealloc => "Perl_saferealloc",
36 Perl_set_numeric_local => "perl_set_numeric_local",
37 Perl_set_numeric_standard => "perl_set_numeric_standard",
38 Perl_malloc => "malloc",
40 Perl_realloc => "realloc",
41 Perl_calloc => "calloc",
44 my $bincompat5005 = join("|", keys %bincompat5005);
48 $define{$1} = 1 if ($flag =~ /^-D(\w+)$/);
49 $define{$1} = $2 if ($flag =~ /^-D(\w+)=(.+)$/);
50 $CCTYPE = $1 if ($flag =~ /^CCTYPE=(\w+)$/);
51 $PLATFORM = $1 if ($flag =~ /^PLATFORM=(\w+)$/);
54 my @PLATFORM = qw(aix win32 os2 MacOS);
56 @PLATFORM{@PLATFORM} = ();
58 defined $PLATFORM || die "PLATFORM undefined, must be one of: @PLATFORM\n";
59 exists $PLATFORM{$PLATFORM} || die "PLATFORM must be one of: @PLATFORM\n";
61 my $config_sh = "config.sh";
62 my $config_h = "config.h";
63 my $thrdvar_h = "thrdvar.h";
64 my $intrpvar_h = "intrpvar.h";
65 my $perlvars_h = "perlvars.h";
66 my $global_sym = "global.sym";
67 my $pp_sym = "pp.sym";
68 my $globvar_sym = "globvar.sym";
69 my $perlio_sym = "perlio.sym";
71 if ($PLATFORM eq 'aix') {
74 elsif ($PLATFORM eq 'win32') {
75 $CCTYPE = "MSVC" unless defined $CCTYPE;
76 foreach ($thrdvar_h, $intrpvar_h, $perlvars_h, $global_sym, $pp_sym, $globvar_sym) {
80 elsif ($PLATFORM eq 'MacOS') {
81 foreach ($thrdvar_h, $intrpvar_h, $perlvars_h, $global_sym,
82 $pp_sym, $globvar_sym, $perlio_sym) {
87 unless ($PLATFORM eq 'win32' || $PLATFORM eq 'MacOS') {
88 open(CFG,$config_sh) || die "Cannot open $config_sh: $!\n";
90 if (/^(?:ccflags|optimize)='(.+)'$/) {
92 $define{$1} = 1 while /-D(\w+)/g;
94 if ($PLATFORM eq 'os2') {
95 $CONFIG_ARGS = $1 if /^(?:config_args)='(.+)'$/;
96 $ARCHNAME = $1 if /^(?:archname)='(.+)'$/;
102 open(CFG,$config_h) || die "Cannot open $config_h: $!\n";
104 $define{$1} = 1 if /^\s*#\s*define\s+(MYMALLOC)\b/;
105 $define{$1} = 1 if /^\s*#\s*define\s+(USE_5005THREADS)\b/;
106 $define{$1} = 1 if /^\s*#\s*define\s+(USE_ITHREADS)\b/;
107 $define{$1} = 1 if /^\s*#\s*define\s+(USE_PERLIO)\b/;
108 $define{$1} = 1 if /^\s*#\s*define\s+(USE_SFIO)\b/;
109 $define{$1} = 1 if /^\s*#\s*define\s+(MULTIPLICITY)\b/;
110 $define{$1} = 1 if /^\s*#\s*define\s+(PERL_IMPLICIT_SYS)\b/;
111 $define{$1} = 1 if /^\s*#\s*define\s+(PERL_BINCOMPAT_5005)\b/;
115 # perl.h logic duplication begins
117 if ($define{USE_ITHREADS}) {
118 if (!$define{MULTIPLICITY} && !$define{PERL_OBJECT}) {
119 $define{MULTIPLICITY} = 1;
123 $define{PERL_IMPLICIT_CONTEXT} ||=
124 $define{USE_ITHREADS} ||
125 $define{USE_5005THREADS} ||
126 $define{MULTIPLICITY} ;
128 if ($define{PERL_CAPI}) {
129 delete $define{PERL_OBJECT};
130 $define{MULTIPLICITY} = 1;
131 $define{PERL_IMPLICIT_CONTEXT} = 1;
132 $define{PERL_IMPLICIT_SYS} = 1;
135 if ($define{PERL_OBJECT}) {
136 $define{PERL_IMPLICIT_CONTEXT} = 1;
137 $define{PERL_IMPLICIT_SYS} = 1;
140 # perl.h logic duplication ends
142 if ($PLATFORM eq 'win32') {
143 warn join(' ',keys %define)."\n";
144 print "LIBRARY Perl56\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");
152 elsif ($PLATFORM eq 'os2') {
153 ($v = $]) =~ s/(\d\.\d\d\d)(\d\d)$/$1_$2/;
154 $v .= '-thread' if $ARCHNAME =~ /-thread/;
156 #for (split //, $v) {
157 # $sum = ($sum * 33) + ord;
162 #$sum = printf '%X', $sum;
163 ($dll = $define{PERL_DLL}) =~ s/\.dll$//i;
164 # print STDERR "'$dll' <= '$define{PERL_DLL}'\n";
166 LIBRARY '$dll' INITINSTANCE TERMINSTANCE
167 DESCRIPTION '\@#perl5-porters\@perl.org:$v#\@ Perl interpreter'
170 DATA LOADONCALL NONSHARED MULTIPLE
174 elsif ($PLATFORM eq 'aix') {
183 foreach my $symbol (@$list) {
190 foreach my $symbol (@$list) {
191 my $skipsym = $symbol;
193 if ($define{PERL_OBJECT} || $define{MULTIPLICITY}) {
194 $skipsym =~ s/^Perl_[GIT](\w+)_ptr$/PL_$1/;
196 emit_symbol($symbol) unless exists $skip{$skipsym};
200 if ($PLATFORM eq 'win32') {
225 Perl_init_thread_intern
250 elsif ($PLATFORM eq 'aix') {
269 Perl_sys_intern_clear
278 elsif ($PLATFORM eq 'os2') {
305 XS_Cwd_extLibpath_set
309 XS_Cwd_sys_is_absolute
310 XS_Cwd_sys_is_relative
312 XS_DynaLoader_mod2fname
313 XS_File__Copy_syscopy
317 Perl_Process_Messages
323 elsif ($PLATFORM eq 'MacOS') {
347 Perl_sys_intern_clear
353 unless ($define{'DEBUGGING'}) {
368 if ($define{'PERL_IMPLICIT_SYS'}) {
389 unless ($define{'PERL_FLEXIBLE_EXCEPTIONS'}) {
393 Perl_vdefault_protect
397 if ($define{'MYMALLOC'}) {
408 if ($define{'USE_5005THREADS'} || $define{'USE_ITHREADS'}) {
432 unless ($define{'USE_5005THREADS'} || $define{'USE_ITHREADS'}) {
438 unless ($define{'USE_5005THREADS'}) {
457 Perl_new_struct_thread
458 Perl_per_thread_magicals
467 unless ($define{'USE_ITHREADS'}) {
492 unless ($define{'PERL_IMPLICIT_CONTEXT'}) {
498 Perl_load_module_nocontext
501 Perl_warner_nocontext
502 Perl_newSVpvf_nocontext
503 Perl_sv_catpvf_nocontext
504 Perl_sv_setpvf_nocontext
505 Perl_sv_catpvf_mg_nocontext
506 Perl_sv_setpvf_mg_nocontext
510 unless ($define{'PERL_IMPLICIT_SYS'}) {
517 unless ($define{'FAKE_THREADS'}) {
518 skip_symbols [qw(PL_curthr)];
523 my $proc = shift || sub { "PL_$_[2]" };
524 open(VARS,$file) || die "Cannot open $file: $!\n";
527 # All symbols have a Perl_ prefix because that's what embed.h
528 # sticks in front of them.
529 push(@syms, &$proc($1,$2,$3)) if (/\bPERLVAR(A?I?C?)\(([IGT])(\w+)/);
535 if ($define{'USE_5005THREADS'}) {
536 my $thrd = readvar($thrdvar_h);
540 if ($define{'PERL_GLOBAL_STRUCT'}) {
541 my $global = readvar($perlvars_h);
542 skip_symbols $global;
543 emit_symbol('Perl_GetVars');
544 emit_symbols [qw(PL_Vars PL_VarsPtr)] unless $CCTYPE eq 'GCC';
547 # functions from *.sym files
549 my @syms = ($global_sym, $globvar_sym); # $pp_sym is not part of the API
551 if ($define{'USE_PERLIO'}) {
552 push @syms, $perlio_sym;
553 if ($define{'USE_SFIO'}) {
554 # SFIO defines most of the PerlIO routines as macros
601 for my $syms (@syms) {
602 open (GLOBAL, "<$syms") || die "failed to open $syms: $!\n";
604 next if (!/^[A-Za-z]/);
605 # Functions have a Perl_ prefix
606 # Variables have a PL_ prefix
608 my $symbol = ($syms =~ /var\.sym$/i ? "PL_" : "");
610 emit_symbol($symbol) unless exists $skip{$symbol};
617 if ($define{'PERL_OBJECT'} || $define{'MULTIPLICITY'}) {
618 for my $f ($perlvars_h, $intrpvar_h, $thrdvar_h) {
619 my $glob = readvar($f, sub { "Perl_" . $_[1] . $_[2] . "_ptr" });
622 # XXX AIX seems to want the perlvars.h symbols, for some reason
623 if ($PLATFORM eq 'aix') {
624 my $glob = readvar($perlvars_h);
629 unless ($define{'PERL_GLOBAL_STRUCT'}) {
630 my $glob = readvar($perlvars_h);
633 unless ($define{'MULTIPLICITY'}) {
634 my $glob = readvar($intrpvar_h);
637 unless ($define{'MULTIPLICITY'} || $define{'USE_5005THREADS'}) {
638 my $glob = readvar($thrdvar_h);
646 return if $symbol !~ /^[A-Za-z]/;
647 return if $symbol =~ /^\#/;
650 return if exists $skip{$symbol};
651 emit_symbol($symbol);
658 if ($PLATFORM eq 'win32') {
659 foreach my $symbol (qw(
746 win32_getprotobynumber
813 elsif ($PLATFORM eq 'os2') {
814 open MAP, 'miniperl.map' or die 'Cannot read miniperl.map';
815 /^\s*[\da-f:]+\s+(\w+)/i and $mapped{$1}++ foreach <MAP>;
816 close MAP or die 'Cannot close miniperl.map';
818 @missing = grep { !exists $mapped{$_} and !exists $bincompat5005{$_} }
820 delete $export{$_} foreach @missing;
822 elsif ($PLATFORM eq 'MacOS') {
823 open MACSYMS, 'macperl.sym' or die 'Cannot read macperl.sym';
832 # Now all symbols should be defined because
833 # next we are going to output them.
835 foreach my $symbol (sort keys %export) {
836 output_symbol($symbol);
842 $export{$symbol} = 1;
847 $symbol = $bincompat5005{$symbol}
848 if $define{PERL_BINCOMPAT_5005} and $symbol =~ /^($bincompat5005)$/;
849 if ($PLATFORM eq 'win32') {
850 $symbol = "_$symbol" if $CCTYPE eq 'BORLAND';
852 # XXX: binary compatibility between compilers is an exercise
854 # if ($CCTYPE eq "BORLAND") {
855 # # workaround Borland quirk by exporting both the straight
856 # # name and a name with leading underscore. Note the
857 # # alias *must* come after the symbol itself, if both
858 # # are to be exported. (Linker bug?)
859 # print "\t_$symbol\n";
860 # print "\t$symbol = _$symbol\n";
862 # elsif ($CCTYPE eq 'GCC') {
863 # # Symbols have leading _ whole process is $%@"% slow
864 # # so skip aliases for now
865 # nprint "\t$symbol\n";
868 # # for binary coexistence, export both the symbol and
869 # # alias with leading underscore
870 # print "\t$symbol\n";
871 # print "\t_$symbol = $symbol\n";
874 elsif ($PLATFORM eq 'os2') {
875 print qq( "$symbol"\n);
877 elsif ($PLATFORM eq 'aix' || $PLATFORM eq 'MacOS') {
884 # extra globals not included above.