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);
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,
77 $pp_sym, $globvar_sym, $perlio_sym) {
82 unless ($PLATFORM eq 'win32') {
83 open(CFG,$config_sh) || die "Cannot open $config_sh: $!\n";
85 if (/^(?:ccflags|optimize)='(.+)'$/) {
87 $define{$1} = 1 while /-D(\w+)/g;
89 if ($PLATFORM eq 'os2') {
90 $CONFIG_ARGS = $1 if /^(?:config_args)='(.+)'$/;
91 $ARCHNAME = $1 if /^(?:archname)='(.+)'$/;
97 open(CFG,$config_h) || die "Cannot open $config_h: $!\n";
99 $define{$1} = 1 if /^\s*#\s*define\s+(MYMALLOC)\b/;
100 $define{$1} = 1 if /^\s*#\s*define\s+(USE_5005THREADS)\b/;
101 $define{$1} = 1 if /^\s*#\s*define\s+(USE_ITHREADS)\b/;
102 $define{$1} = 1 if /^\s*#\s*define\s+(USE_PERLIO)\b/;
103 $define{$1} = 1 if /^\s*#\s*define\s+(MULTIPLICITY)\b/;
104 $define{$1} = 1 if /^\s*#\s*define\s+(PERL_IMPLICIT_SYS)\b/;
105 $define{$1} = 1 if /^\s*#\s*define\s+(PERL_BINCOMPAT_5005)\b/;
109 # perl.h logic duplication begins
111 if ($define{USE_ITHREADS}) {
112 if (!$define{MULTIPLICITY} && !$define{PERL_OBJECT}) {
113 $define{MULTIPLICITY} = 1;
117 $define{PERL_IMPLICIT_CONTEXT} ||=
118 $define{USE_ITHREADS} ||
119 $define{USE_5005THREADS} ||
120 $define{MULTIPLICITY} ;
122 if ($define{PERL_CAPI}) {
123 delete $define{PERL_OBJECT};
124 $define{MULTIPLICITY} = 1;
125 $define{PERL_IMPLICIT_CONTEXT} = 1;
126 $define{PERL_IMPLICIT_SYS} = 1;
129 if ($define{PERL_OBJECT}) {
130 $define{PERL_IMPLICIT_CONTEXT} = 1;
131 $define{PERL_IMPLICIT_SYS} = 1;
134 # perl.h logic duplication ends
136 if ($PLATFORM eq 'win32') {
137 warn join(' ',keys %define)."\n";
138 print "LIBRARY Perl56\n";
139 print "DESCRIPTION 'Perl interpreter'\n";
141 if ($define{PERL_IMPLICIT_SYS}) {
142 output_symbol("perl_get_host_info");
143 output_symbol("perl_alloc_override");
146 elsif ($PLATFORM eq 'os2') {
147 ($v = $]) =~ s/(\d\.\d\d\d)(\d\d)$/$1_$2/;
148 $v .= '-thread' if $ARCHNAME =~ /-thread/;
150 #for (split //, $v) {
151 # $sum = ($sum * 33) + ord;
156 #$sum = printf '%X', $sum;
157 ($dll = $define{PERL_DLL}) =~ s/\.dll$//i;
158 # print STDERR "'$dll' <= '$define{PERL_DLL}'\n";
160 LIBRARY '$dll' INITINSTANCE TERMINSTANCE
161 DESCRIPTION '\@#perl5-porters\@perl.org:$v#\@ Perl interpreter'
164 DATA LOADONCALL NONSHARED MULTIPLE
168 elsif ($PLATFORM eq 'aix') {
177 foreach my $symbol (@$list) {
184 foreach my $symbol (@$list) {
185 my $skipsym = $symbol;
187 if ($define{PERL_OBJECT} || $define{MULTIPLICITY}) {
188 $skipsym =~ s/^Perl_[GIT](\w+)_ptr$/PL_$1/;
190 emit_symbol($symbol) unless exists $skip{$skipsym};
194 if ($PLATFORM eq 'win32') {
219 Perl_init_thread_intern
244 elsif ($PLATFORM eq 'aix') {
263 Perl_sys_intern_clear
272 elsif ($PLATFORM eq 'os2') {
297 XS_Cwd_extLibpath_set
301 XS_Cwd_sys_is_absolute
302 XS_Cwd_sys_is_relative
304 XS_DynaLoader_mod2fname
305 XS_File__Copy_syscopy
309 Perl_Process_Messages
316 unless ($define{'DEBUGGING'}) {
332 if ($define{'PERL_IMPLICIT_SYS'}) {
353 unless ($define{'PERL_FLEXIBLE_EXCEPTIONS'}) {
357 Perl_vdefault_protect
361 if ($define{'MYMALLOC'}) {
370 if ($define{'USE_5005THREADS'} || $define{'USE_ITHREADS'}) {
394 unless ($define{'USE_5005THREADS'} || $define{'USE_ITHREADS'}) {
400 unless ($define{'USE_5005THREADS'}) {
419 Perl_new_struct_thread
420 Perl_per_thread_magicals
429 unless ($define{'USE_ITHREADS'}) {
454 unless ($define{'PERL_IMPLICIT_CONTEXT'}) {
460 Perl_load_module_nocontext
463 Perl_warner_nocontext
464 Perl_newSVpvf_nocontext
465 Perl_sv_catpvf_nocontext
466 Perl_sv_setpvf_nocontext
467 Perl_sv_catpvf_mg_nocontext
468 Perl_sv_setpvf_mg_nocontext
472 unless ($define{'PERL_IMPLICIT_SYS'}) {
479 unless ($define{'FAKE_THREADS'}) {
480 skip_symbols [qw(PL_curthr)];
485 my $proc = shift || sub { "PL_$_[2]" };
486 open(VARS,$file) || die "Cannot open $file: $!\n";
489 # All symbols have a Perl_ prefix because that's what embed.h
490 # sticks in front of them.
491 push(@syms, &$proc($1,$2,$3)) if (/\bPERLVAR(A?I?C?)\(([IGT])(\w+)/);
497 if ($define{'USE_5005THREADS'}) {
498 my $thrd = readvar($thrdvar_h);
502 if ($define{'PERL_GLOBAL_STRUCT'}) {
503 my $global = readvar($perlvars_h);
504 skip_symbols $global;
505 emit_symbol('Perl_GetVars');
506 emit_symbols [qw(PL_Vars PL_VarsPtr)] unless $CCTYPE eq 'GCC';
509 # functions from *.sym files
511 my @syms = ($global_sym, $globvar_sym); # $pp_sym is not part of the API
513 if ($define{'USE_PERLIO'}) {
514 push @syms, $perlio_sym;
517 for my $syms (@syms) {
518 open (GLOBAL, "<$syms") || die "failed to open $syms: $!\n";
520 next if (!/^[A-Za-z]/);
521 # Functions have a Perl_ prefix
522 # Variables have a PL_ prefix
524 my $symbol = ($syms =~ /var\.sym$/i ? "PL_" : "");
526 emit_symbol($symbol) unless exists $skip{$symbol};
533 if ($define{'PERL_OBJECT'} || $define{'MULTIPLICITY'}) {
534 for my $f ($perlvars_h, $intrpvar_h, $thrdvar_h) {
535 my $glob = readvar($f, sub { "Perl_" . $_[1] . $_[2] . "_ptr" });
538 # XXX AIX seems to want the perlvars.h symbols, for some reason
539 if ($PLATFORM eq 'aix') {
540 my $glob = readvar($perlvars_h);
545 unless ($define{'PERL_GLOBAL_STRUCT'}) {
546 my $glob = readvar($perlvars_h);
549 unless ($define{'MULTIPLICITY'}) {
550 my $glob = readvar($intrpvar_h);
553 unless ($define{'MULTIPLICITY'} || $define{'USE_5005THREADS'}) {
554 my $glob = readvar($thrdvar_h);
562 return if $symbol !~ /^[A-Za-z]/;
563 return if $symbol =~ /^\#/;
566 return if exists $skip{$symbol};
567 emit_symbol($symbol);
574 if ($PLATFORM eq 'win32') {
575 foreach my $symbol (qw(
635 win32_getprotobynumber
732 elsif ($PLATFORM eq 'os2') {
733 open MAP, 'miniperl.map' or die 'Cannot read miniperl.map';
734 /^\s*[\da-f:]+\s+(\w+)/i and $mapped{$1}++ foreach <MAP>;
735 close MAP or die 'Cannot close miniperl.map';
737 @missing = grep { !exists $mapped{$_} and !exists $bincompat5005{$_} }
739 delete $export{$_} foreach @missing;
742 # Now all symbols should be defined because
743 # next we are going to output them.
745 foreach my $symbol (sort keys %export) {
746 output_symbol($symbol);
752 $export{$symbol} = 1;
757 $symbol = $bincompat5005{$symbol}
758 if $define{PERL_BINCOMPAT_5005} and $symbol =~ /^($bincompat5005)$/;
759 if ($PLATFORM eq 'win32') {
760 $symbol = "_$symbol" if $CCTYPE eq 'BORLAND';
762 # XXX: binary compatibility between compilers is an exercise
764 # if ($CCTYPE eq "BORLAND") {
765 # # workaround Borland quirk by exporting both the straight
766 # # name and a name with leading underscore. Note the
767 # # alias *must* come after the symbol itself, if both
768 # # are to be exported. (Linker bug?)
769 # print "\t_$symbol\n";
770 # print "\t$symbol = _$symbol\n";
772 # elsif ($CCTYPE eq 'GCC') {
773 # # Symbols have leading _ whole process is $%@"% slow
774 # # so skip aliases for now
775 # nprint "\t$symbol\n";
778 # # for binary coexistence, export both the symbol and
779 # # alias with leading underscore
780 # print "\t$symbol\n";
781 # print "\t_$symbol = $symbol\n";
784 elsif ($PLATFORM eq 'os2') {
785 print qq( "$symbol"\n);
787 elsif ($PLATFORM eq 'aix') {
794 # extra globals not included above.