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
14 (Perl_call_argv => "perl_call_argv",
15 Perl_call_method => "perl_call_method",
16 Perl_call_pv => "perl_call_pv",
17 Perl_call_sv => "perl_call_sv",
18 Perl_get_av => "perl_get_av",
19 Perl_get_cv => "perl_get_cv",
20 Perl_get_hv => "perl_get_hv",
21 Perl_get_sv => "perl_get_sv",
22 Perl_init_i18nl10n => "perl_init_i18nl10n",
23 Perl_init_i18nl14n => "perl_init_i18nl14n",
24 Perl_new_collate => "perl_new_collate",
25 Perl_new_ctype => "perl_new_ctype",
26 Perl_new_numeric => "perl_new_numeric",
27 Perl_require_pv => "perl_require_pv",
28 Perl_safesyscalloc => "Perl_safecalloc",
29 Perl_safesysfree => "Perl_safefree",
30 Perl_safesysmalloc => "Perl_safemalloc",
31 Perl_safesysrealloc => "Perl_saferealloc",
32 Perl_set_numeric_local => "perl_set_numeric_local",
33 Perl_set_numeric_standard => "perl_set_numeric_standard",
34 Perl_malloc => "malloc",
36 Perl_realloc => "realloc",
37 Perl_calloc => "calloc",);
39 my $bincompat5005 = join("|", keys %bincompat5005);
43 $define{$1} = 1 if ($flag =~ /^-D(\w+)$/);
44 $define{$1} = $2 if ($flag =~ /^-D(\w+)=(.+)$/);
45 $CCTYPE = $1 if ($flag =~ /^CCTYPE=(\w+)$/);
46 $PLATFORM = $1 if ($flag =~ /^PLATFORM=(\w+)$/);
49 my @PLATFORM = qw(aix win32 os2);
51 @PLATFORM{@PLATFORM} = ();
53 defined $PLATFORM || die "PLATFORM undefined, must be one of: @PLATFORM\n";
54 exists $PLATFORM{$PLATFORM} || die "PLATFORM must be one of: @PLATFORM\n";
56 my $config_sh = "config.sh";
57 my $config_h = "config.h";
58 my $thrdvar_h = "thrdvar.h";
59 my $intrpvar_h = "intrpvar.h";
60 my $perlvars_h = "perlvars.h";
61 my $global_sym = "global.sym";
62 my $pp_sym = "pp.sym";
63 my $globvar_sym = "globvar.sym";
64 my $perlio_sym = "perlio.sym";
66 if ($PLATFORM eq 'aix') {
69 elsif ($PLATFORM eq 'win32') {
70 $CCTYPE = "MSVC" unless defined $CCTYPE;
71 foreach ($thrdvar_h, $intrpvar_h, $perlvars_h, $global_sym, $pp_sym, $globvar_sym) {
76 unless ($PLATFORM eq 'win32') {
77 open(CFG,$config_sh) || die "Cannot open $config_sh: $!\n";
79 if (/^(?:ccflags|optimize)='(.+)'$/) {
81 $define{$1} = 1 while /-D(\w+)/g;
83 if ($PLATFORM eq 'os2') {
84 $CONFIG_ARGS = $1 if /^(?:config_args)='(.+)'$/;
85 $ARCHNAME = $1 if /^(?:archname)='(.+)'$/;
91 open(CFG,$config_h) || die "Cannot open $config_h: $!\n";
93 $define{$1} = 1 if /^\s*#\s*define\s+(MYMALLOC)\b/;
94 $define{$1} = 1 if /^\s*#\s*define\s+(USE_5005THREADS)\b/;
95 $define{$1} = 1 if /^\s*#\s*define\s+(USE_ITHREADS)\b/;
96 $define{$1} = 1 if /^\s*#\s*define\s+(USE_PERLIO)\b/;
97 $define{$1} = 1 if /^\s*#\s*define\s+(MULTIPLICITY)\b/;
98 $define{$1} = 1 if /^\s*#\s*define\s+(PERL_IMPLICIT_SYS)\b/;
99 $define{$1} = 1 if /^\s*#\s*define\s+(PERL_BINCOMPAT_5005)\b/;
103 # perl.h logic duplication begins
105 if ($define{USE_ITHREADS}) {
106 if (!$define{MULTIPLICITY} && !$define{PERL_OBJECT}) {
107 $define{MULTIPLICITY} = 1;
111 $define{PERL_IMPLICIT_CONTEXT} ||=
112 $define{USE_ITHREADS} ||
113 $define{USE_5005THREADS} ||
114 $define{MULTIPLICITY} ;
116 if ($define{PERL_CAPI}) {
117 delete $define{PERL_OBJECT};
118 $define{MULTIPLICITY} = 1;
119 $define{PERL_IMPLICIT_CONTEXT} = 1;
120 $define{PERL_IMPLICIT_SYS} = 1;
123 if ($define{PERL_OBJECT}) {
124 $define{PERL_IMPLICIT_CONTEXT} = 1;
125 $define{PERL_IMPLICIT_SYS} = 1;
128 # perl.h logic duplication ends
130 if ($PLATFORM eq 'win32') {
131 warn join(' ',keys %define)."\n";
132 print "LIBRARY Perl56\n";
133 print "DESCRIPTION 'Perl interpreter'\n";
135 if ($define{PERL_IMPLICIT_SYS}) {
136 output_symbol("perl_get_host_info");
137 output_symbol("perl_alloc_override");
140 elsif ($PLATFORM eq 'os2') {
141 ($v = $]) =~ s/(\d\.\d\d\d)(\d\d)$/$1_$2/;
142 $v .= '-thread' if $ARCHNAME =~ /-thread/;
144 #for (split //, $v) {
145 # $sum = ($sum * 33) + ord;
150 #$sum = printf '%X', $sum;
151 ($dll = $define{PERL_DLL}) =~ s/\.dll$//i;
152 # print STDERR "'$dll' <= '$define{PERL_DLL}'\n";
154 LIBRARY '$dll' INITINSTANCE TERMINSTANCE
155 DESCRIPTION '\@#perl5-porters\@perl.org:$v#\@ Perl interpreter, configured as $CONFIG_ARGS'
158 DATA LOADONCALL NONSHARED MULTIPLE
162 elsif ($PLATFORM eq 'aix') {
171 foreach my $symbol (@$list) {
178 foreach my $symbol (@$list) {
179 my $skipsym = $symbol;
181 if ($define{PERL_OBJECT} || $define{MULTIPLICITY}) {
182 $skipsym =~ s/^Perl_[GIT](\w+)_ptr$/PL_$1/;
184 emit_symbol($symbol) unless exists $skip{$skipsym};
188 if ($PLATFORM eq 'win32') {
213 Perl_init_thread_intern
238 elsif ($PLATFORM eq 'aix') {
264 elsif ($PLATFORM eq 'os2') {
289 XS_Cwd_extLibpath_set
293 XS_Cwd_sys_is_absolute
294 XS_Cwd_sys_is_relative
296 XS_DynaLoader_mod2fname
297 XS_File__Copy_syscopy
301 Perl_Process_Messages
308 unless ($define{'DEBUGGING'}) {
324 if ($define{'PERL_IMPLICIT_SYS'}) {
345 unless ($define{'PERL_FLEXIBLE_EXCEPTIONS'}) {
349 Perl_vdefault_protect
353 if ($define{'MYMALLOC'}) {
362 if ($define{'USE_5005THREADS'} || $define{'USE_ITHREADS'}) {
386 unless ($define{'USE_5005THREADS'} || $define{'USE_ITHREADS'}) {
392 unless ($define{'USE_5005THREADS'}) {
409 Perl_new_struct_thread
410 Perl_per_thread_magicals
418 unless ($define{'USE_ITHREADS'}) {
443 unless ($define{'PERL_IMPLICIT_CONTEXT'}) {
449 Perl_load_module_nocontext
452 Perl_warner_nocontext
453 Perl_newSVpvf_nocontext
454 Perl_sv_catpvf_nocontext
455 Perl_sv_setpvf_nocontext
456 Perl_sv_catpvf_mg_nocontext
457 Perl_sv_setpvf_mg_nocontext
461 unless ($define{'PERL_IMPLICIT_SYS'}) {
468 unless ($define{'FAKE_THREADS'}) {
469 skip_symbols [qw(PL_curthr)];
474 my $proc = shift || sub { "PL_$_[2]" };
475 open(VARS,$file) || die "Cannot open $file: $!\n";
478 # All symbols have a Perl_ prefix because that's what embed.h
479 # sticks in front of them.
480 push(@syms, &$proc($1,$2,$3)) if (/\bPERLVAR(A?I?C?)\(([IGT])(\w+)/);
486 if ($define{'USE_5005THREADS'}) {
487 my $thrd = readvar($thrdvar_h);
491 if ($define{'PERL_GLOBAL_STRUCT'}) {
492 my $global = readvar($perlvars_h);
493 skip_symbols $global;
494 emit_symbol('Perl_GetVars');
495 emit_symbols [qw(PL_Vars PL_VarsPtr)] unless $CCTYPE eq 'GCC';
498 # functions from *.sym files
500 my @syms = ($global_sym, $globvar_sym); # $pp_sym is not part of the API
502 if ($define{'USE_PERLIO'}) {
503 push @syms, $perlio_sym;
506 for my $syms (@syms) {
507 open (GLOBAL, "<$syms") || die "failed to open $syms: $!\n";
509 next if (!/^[A-Za-z]/);
510 # Functions have a Perl_ prefix
511 # Variables have a PL_ prefix
513 my $symbol = ($syms =~ /var\.sym$/i ? "PL_" : "");
515 emit_symbol($symbol) unless exists $skip{$symbol};
522 if ($define{'PERL_OBJECT'} || $define{'MULTIPLICITY'}) {
523 for my $f ($perlvars_h, $intrpvar_h, $thrdvar_h) {
524 my $glob = readvar($f, sub { "Perl_" . $_[1] . $_[2] . "_ptr" });
527 # XXX AIX seems to want the perlvars.h symbols, for some reason
528 if ($PLATFORM eq 'aix') {
529 my $glob = readvar($perlvars_h);
534 unless ($define{'PERL_GLOBAL_STRUCT'}) {
535 my $glob = readvar($perlvars_h);
538 unless ($define{'MULTIPLICITY'}) {
539 my $glob = readvar($intrpvar_h);
542 unless ($define{'MULTIPLICITY'} || $define{'USE_5005THREADS'}) {
543 my $glob = readvar($thrdvar_h);
551 return if $symbol !~ /^[A-Za-z]/;
552 return if $symbol =~ /^\#/;
555 return if exists $skip{$symbol};
556 emit_symbol($symbol);
563 if ($PLATFORM eq 'win32') {
564 foreach my $symbol (qw(
651 win32_getprotobynumber
718 elsif ($PLATFORM eq 'os2') {
719 open MAP, 'miniperl.map' or die 'Cannot read miniperl.map';
720 /^\s*[\da-f:]+\s+(\w+)/i and $mapped{$1}++ foreach <MAP>;
721 close MAP or die 'Cannot close miniperl.map';
723 @missing = grep { !exists $mapped{$_} and !exists $bincompat5005{$_} }
725 delete $export{$_} foreach @missing;
728 # Now all symbols should be defined because
729 # next we are going to output them.
731 foreach my $symbol (sort keys %export) {
732 output_symbol($symbol);
738 $export{$symbol} = 1;
743 $symbol = $bincompat5005{$symbol}
744 if $define{PERL_BINCOMPAT_5005} and $symbol =~ /^($bincompat5005)$/;
745 if ($PLATFORM eq 'win32') {
746 $symbol = "_$symbol" if $CCTYPE eq 'BORLAND';
748 # XXX: binary compatibility between compilers is an exercise
750 # if ($CCTYPE eq "BORLAND") {
751 # # workaround Borland quirk by exporting both the straight
752 # # name and a name with leading underscore. Note the
753 # # alias *must* come after the symbol itself, if both
754 # # are to be exported. (Linker bug?)
755 # print "\t_$symbol\n";
756 # print "\t$symbol = _$symbol\n";
758 # elsif ($CCTYPE eq 'GCC') {
759 # # Symbols have leading _ whole process is $%@"% slow
760 # # so skip aliases for now
761 # nprint "\t$symbol\n";
764 # # for binary coexistence, export both the symbol and
765 # # alias with leading underscore
766 # print "\t$symbol\n";
767 # print "\t_$symbol = $symbol\n";
770 elsif ($PLATFORM eq 'os2') {
771 print qq( "$symbol"\n);
773 elsif ($PLATFORM eq 'aix') {
780 # extra globals not included above.