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, $pp_sym, $globvar_sym) {
81 unless ($PLATFORM eq 'win32') {
82 open(CFG,$config_sh) || die "Cannot open $config_sh: $!\n";
84 if (/^(?:ccflags|optimize)='(.+)'$/) {
86 $define{$1} = 1 while /-D(\w+)/g;
88 if ($PLATFORM eq 'os2') {
89 $CONFIG_ARGS = $1 if /^(?:config_args)='(.+)'$/;
90 $ARCHNAME = $1 if /^(?:archname)='(.+)'$/;
96 open(CFG,$config_h) || die "Cannot open $config_h: $!\n";
98 $define{$1} = 1 if /^\s*#\s*define\s+(MYMALLOC)\b/;
99 $define{$1} = 1 if /^\s*#\s*define\s+(USE_5005THREADS)\b/;
100 $define{$1} = 1 if /^\s*#\s*define\s+(USE_ITHREADS)\b/;
101 $define{$1} = 1 if /^\s*#\s*define\s+(USE_PERLIO)\b/;
102 $define{$1} = 1 if /^\s*#\s*define\s+(MULTIPLICITY)\b/;
103 $define{$1} = 1 if /^\s*#\s*define\s+(PERL_IMPLICIT_SYS)\b/;
104 $define{$1} = 1 if /^\s*#\s*define\s+(PERL_BINCOMPAT_5005)\b/;
108 # perl.h logic duplication begins
110 if ($define{USE_ITHREADS}) {
111 if (!$define{MULTIPLICITY} && !$define{PERL_OBJECT}) {
112 $define{MULTIPLICITY} = 1;
116 $define{PERL_IMPLICIT_CONTEXT} ||=
117 $define{USE_ITHREADS} ||
118 $define{USE_5005THREADS} ||
119 $define{MULTIPLICITY} ;
121 if ($define{PERL_CAPI}) {
122 delete $define{PERL_OBJECT};
123 $define{MULTIPLICITY} = 1;
124 $define{PERL_IMPLICIT_CONTEXT} = 1;
125 $define{PERL_IMPLICIT_SYS} = 1;
128 if ($define{PERL_OBJECT}) {
129 $define{PERL_IMPLICIT_CONTEXT} = 1;
130 $define{PERL_IMPLICIT_SYS} = 1;
133 # perl.h logic duplication ends
135 if ($PLATFORM eq 'win32') {
136 warn join(' ',keys %define)."\n";
137 print "LIBRARY Perl56\n";
138 print "DESCRIPTION 'Perl interpreter'\n";
140 if ($define{PERL_IMPLICIT_SYS}) {
141 output_symbol("perl_get_host_info");
142 output_symbol("perl_alloc_override");
145 elsif ($PLATFORM eq 'os2') {
146 ($v = $]) =~ s/(\d\.\d\d\d)(\d\d)$/$1_$2/;
147 $v .= '-thread' if $ARCHNAME =~ /-thread/;
149 #for (split //, $v) {
150 # $sum = ($sum * 33) + ord;
155 #$sum = printf '%X', $sum;
156 ($dll = $define{PERL_DLL}) =~ s/\.dll$//i;
157 # print STDERR "'$dll' <= '$define{PERL_DLL}'\n";
159 LIBRARY '$dll' INITINSTANCE TERMINSTANCE
160 DESCRIPTION '\@#perl5-porters\@perl.org:$v#\@ Perl interpreter, configured as $CONFIG_ARGS'
163 DATA LOADONCALL NONSHARED MULTIPLE
167 elsif ($PLATFORM eq 'aix') {
176 foreach my $symbol (@$list) {
183 foreach my $symbol (@$list) {
184 my $skipsym = $symbol;
186 if ($define{PERL_OBJECT} || $define{MULTIPLICITY}) {
187 $skipsym =~ s/^Perl_[GIT](\w+)_ptr$/PL_$1/;
189 emit_symbol($symbol) unless exists $skip{$skipsym};
193 if ($PLATFORM eq 'win32') {
218 Perl_init_thread_intern
243 elsif ($PLATFORM eq 'aix') {
270 elsif ($PLATFORM eq 'os2') {
295 XS_Cwd_extLibpath_set
299 XS_Cwd_sys_is_absolute
300 XS_Cwd_sys_is_relative
302 XS_DynaLoader_mod2fname
303 XS_File__Copy_syscopy
307 Perl_Process_Messages
314 unless ($define{'DEBUGGING'}) {
330 if ($define{'PERL_IMPLICIT_SYS'}) {
351 unless ($define{'PERL_FLEXIBLE_EXCEPTIONS'}) {
355 Perl_vdefault_protect
359 if ($define{'MYMALLOC'}) {
368 if ($define{'USE_5005THREADS'} || $define{'USE_ITHREADS'}) {
392 unless ($define{'USE_5005THREADS'} || $define{'USE_ITHREADS'}) {
398 unless ($define{'USE_5005THREADS'}) {
415 Perl_new_struct_thread
416 Perl_per_thread_magicals
424 unless ($define{'USE_ITHREADS'}) {
449 unless ($define{'PERL_IMPLICIT_CONTEXT'}) {
455 Perl_load_module_nocontext
458 Perl_warner_nocontext
459 Perl_newSVpvf_nocontext
460 Perl_sv_catpvf_nocontext
461 Perl_sv_setpvf_nocontext
462 Perl_sv_catpvf_mg_nocontext
463 Perl_sv_setpvf_mg_nocontext
467 unless ($define{'PERL_IMPLICIT_SYS'}) {
474 unless ($define{'FAKE_THREADS'}) {
475 skip_symbols [qw(PL_curthr)];
480 my $proc = shift || sub { "PL_$_[2]" };
481 open(VARS,$file) || die "Cannot open $file: $!\n";
484 # All symbols have a Perl_ prefix because that's what embed.h
485 # sticks in front of them.
486 push(@syms, &$proc($1,$2,$3)) if (/\bPERLVAR(A?I?C?)\(([IGT])(\w+)/);
492 if ($define{'USE_5005THREADS'}) {
493 my $thrd = readvar($thrdvar_h);
497 if ($define{'PERL_GLOBAL_STRUCT'}) {
498 my $global = readvar($perlvars_h);
499 skip_symbols $global;
500 emit_symbol('Perl_GetVars');
501 emit_symbols [qw(PL_Vars PL_VarsPtr)] unless $CCTYPE eq 'GCC';
504 # functions from *.sym files
506 my @syms = ($global_sym, $globvar_sym); # $pp_sym is not part of the API
508 if ($define{'USE_PERLIO'}) {
509 push @syms, $perlio_sym;
512 for my $syms (@syms) {
513 open (GLOBAL, "<$syms") || die "failed to open $syms: $!\n";
515 next if (!/^[A-Za-z]/);
516 # Functions have a Perl_ prefix
517 # Variables have a PL_ prefix
519 my $symbol = ($syms =~ /var\.sym$/i ? "PL_" : "");
521 emit_symbol($symbol) unless exists $skip{$symbol};
528 if ($define{'PERL_OBJECT'} || $define{'MULTIPLICITY'}) {
529 for my $f ($perlvars_h, $intrpvar_h, $thrdvar_h) {
530 my $glob = readvar($f, sub { "Perl_" . $_[1] . $_[2] . "_ptr" });
533 # XXX AIX seems to want the perlvars.h symbols, for some reason
534 if ($PLATFORM eq 'aix') {
535 my $glob = readvar($perlvars_h);
540 unless ($define{'PERL_GLOBAL_STRUCT'}) {
541 my $glob = readvar($perlvars_h);
544 unless ($define{'MULTIPLICITY'}) {
545 my $glob = readvar($intrpvar_h);
548 unless ($define{'MULTIPLICITY'} || $define{'USE_5005THREADS'}) {
549 my $glob = readvar($thrdvar_h);
557 return if $symbol !~ /^[A-Za-z]/;
558 return if $symbol =~ /^\#/;
561 return if exists $skip{$symbol};
562 emit_symbol($symbol);
569 if ($PLATFORM eq 'win32') {
570 foreach my $symbol (qw(
657 win32_getprotobynumber
724 elsif ($PLATFORM eq 'os2') {
725 open MAP, 'miniperl.map' or die 'Cannot read miniperl.map';
726 /^\s*[\da-f:]+\s+(\w+)/i and $mapped{$1}++ foreach <MAP>;
727 close MAP or die 'Cannot close miniperl.map';
729 @missing = grep { !exists $mapped{$_} and !exists $bincompat5005{$_} }
731 delete $export{$_} foreach @missing;
734 # Now all symbols should be defined because
735 # next we are going to output them.
737 foreach my $symbol (sort keys %export) {
738 output_symbol($symbol);
744 $export{$symbol} = 1;
749 $symbol = $bincompat5005{$symbol}
750 if $define{PERL_BINCOMPAT_5005} and $symbol =~ /^($bincompat5005)$/;
751 if ($PLATFORM eq 'win32') {
752 $symbol = "_$symbol" if $CCTYPE eq 'BORLAND';
754 # XXX: binary compatibility between compilers is an exercise
756 # if ($CCTYPE eq "BORLAND") {
757 # # workaround Borland quirk by exporting both the straight
758 # # name and a name with leading underscore. Note the
759 # # alias *must* come after the symbol itself, if both
760 # # are to be exported. (Linker bug?)
761 # print "\t_$symbol\n";
762 # print "\t$symbol = _$symbol\n";
764 # elsif ($CCTYPE eq 'GCC') {
765 # # Symbols have leading _ whole process is $%@"% slow
766 # # so skip aliases for now
767 # nprint "\t$symbol\n";
770 # # for binary coexistence, export both the symbol and
771 # # alias with leading underscore
772 # print "\t$symbol\n";
773 # print "\t_$symbol = $symbol\n";
776 elsif ($PLATFORM eq 'os2') {
777 print qq( "$symbol"\n);
779 elsif ($PLATFORM eq 'aix') {
786 # extra globals not included above.