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+(MULTIPLICITY)\b/;
101 $define{$1} = 1 if /^\s*#\s*define\s+(PERL_\w+)\b/;
102 $define{$1} = 1 if /^\s*#\s*define\s+(USE_\w+)\b/;
106 # perl.h logic duplication begins
108 if ($define{USE_ITHREADS}) {
109 if (!$define{MULTIPLICITY} && !$define{PERL_OBJECT}) {
110 $define{MULTIPLICITY} = 1;
114 $define{PERL_IMPLICIT_CONTEXT} ||=
115 $define{USE_ITHREADS} ||
116 $define{USE_5005THREADS} ||
117 $define{MULTIPLICITY} ;
119 if ($define{PERL_CAPI}) {
120 delete $define{PERL_OBJECT};
121 $define{MULTIPLICITY} = 1;
122 $define{PERL_IMPLICIT_CONTEXT} = 1;
123 $define{PERL_IMPLICIT_SYS} = 1;
126 if ($define{PERL_OBJECT}) {
127 $define{PERL_IMPLICIT_CONTEXT} = 1;
128 $define{PERL_IMPLICIT_SYS} = 1;
131 # perl.h logic duplication ends
133 if ($PLATFORM eq 'win32') {
134 warn join(' ',keys %define)."\n";
135 print "LIBRARY Perl57\n";
136 print "DESCRIPTION 'Perl interpreter'\n";
138 if ($define{PERL_IMPLICIT_SYS}) {
139 output_symbol("perl_get_host_info");
140 output_symbol("perl_alloc_override");
143 elsif ($PLATFORM eq 'os2') {
144 ($v = $]) =~ s/(\d\.\d\d\d)(\d\d)$/$1_$2/;
145 $v .= '-thread' if $ARCHNAME =~ /-thread/;
146 ($dll = $define{PERL_DLL}) =~ s/\.dll$//i;
148 LIBRARY '$dll' INITINSTANCE TERMINSTANCE
149 DESCRIPTION '\@#perl5-porters\@perl.org:$v#\@ Perl interpreter'
152 DATA LOADONCALL NONSHARED MULTIPLE
156 elsif ($PLATFORM eq 'aix') {
165 foreach my $symbol (@$list) {
172 foreach my $symbol (@$list) {
173 my $skipsym = $symbol;
175 if ($define{PERL_OBJECT} || $define{MULTIPLICITY}) {
176 $skipsym =~ s/^Perl_[GIT](\w+)_ptr$/PL_$1/;
178 emit_symbol($symbol) unless exists $skip{$skipsym};
182 if ($PLATFORM eq 'win32') {
207 Perl_init_thread_intern
232 elsif ($PLATFORM eq 'aix') {
251 Perl_sys_intern_clear
260 elsif ($PLATFORM eq 'os2') {
285 XS_Cwd_extLibpath_set
289 XS_Cwd_sys_is_absolute
290 XS_Cwd_sys_is_relative
292 XS_DynaLoader_mod2fname
293 XS_File__Copy_syscopy
297 Perl_Process_Messages
304 unless ($define{'DEBUGGING'}) {
319 if ($define{'PERL_IMPLICIT_SYS'}) {
340 unless ($define{'PERL_FLEXIBLE_EXCEPTIONS'}) {
344 Perl_vdefault_protect
348 if ($define{'MYMALLOC'}) {
357 if ($define{'USE_5005THREADS'} || $define{'USE_ITHREADS'}) {
381 unless ($define{'USE_5005THREADS'} || $define{'USE_ITHREADS'}) {
387 unless ($define{'USE_5005THREADS'}) {
406 Perl_new_struct_thread
407 Perl_per_thread_magicals
416 unless ($define{'USE_ITHREADS'}) {
441 unless ($define{'PERL_IMPLICIT_CONTEXT'}) {
447 Perl_load_module_nocontext
450 Perl_warner_nocontext
451 Perl_newSVpvf_nocontext
452 Perl_sv_catpvf_nocontext
453 Perl_sv_setpvf_nocontext
454 Perl_sv_catpvf_mg_nocontext
455 Perl_sv_setpvf_mg_nocontext
459 unless ($define{'PERL_IMPLICIT_SYS'}) {
466 unless ($define{'FAKE_THREADS'}) {
467 skip_symbols [qw(PL_curthr)];
472 my $proc = shift || sub { "PL_$_[2]" };
473 open(VARS,$file) || die "Cannot open $file: $!\n";
476 # All symbols have a Perl_ prefix because that's what embed.h
477 # sticks in front of them.
478 push(@syms, &$proc($1,$2,$3)) if (/\bPERLVAR(A?I?C?)\(([IGT])(\w+)/);
484 if ($define{'USE_5005THREADS'}) {
485 my $thrd = readvar($thrdvar_h);
489 if ($define{'PERL_GLOBAL_STRUCT'}) {
490 my $global = readvar($perlvars_h);
491 skip_symbols $global;
492 emit_symbol('Perl_GetVars');
493 emit_symbols [qw(PL_Vars PL_VarsPtr)] unless $CCTYPE eq 'GCC';
496 # functions from *.sym files
498 my @syms = ($global_sym, $globvar_sym); # $pp_sym is not part of the API
500 if ($define{'USE_PERLIO'}) {
501 push @syms, $perlio_sym;
504 for my $syms (@syms) {
505 open (GLOBAL, "<$syms") || die "failed to open $syms: $!\n";
507 next if (!/^[A-Za-z]/);
508 # Functions have a Perl_ prefix
509 # Variables have a PL_ prefix
511 my $symbol = ($syms =~ /var\.sym$/i ? "PL_" : "");
513 emit_symbol($symbol) unless exists $skip{$symbol};
520 if ($define{'PERL_OBJECT'} || $define{'MULTIPLICITY'}) {
521 for my $f ($perlvars_h, $intrpvar_h, $thrdvar_h) {
522 my $glob = readvar($f, sub { "Perl_" . $_[1] . $_[2] . "_ptr" });
525 # XXX AIX seems to want the perlvars.h symbols, for some reason
526 if ($PLATFORM eq 'aix') {
527 my $glob = readvar($perlvars_h);
532 unless ($define{'PERL_GLOBAL_STRUCT'}) {
533 my $glob = readvar($perlvars_h);
536 unless ($define{'MULTIPLICITY'}) {
537 my $glob = readvar($intrpvar_h);
540 unless ($define{'MULTIPLICITY'} || $define{'USE_5005THREADS'}) {
541 my $glob = readvar($thrdvar_h);
549 return if $symbol !~ /^[A-Za-z]/;
550 return if $symbol =~ /^\#/;
553 return if exists $skip{$symbol};
554 emit_symbol($symbol);
561 if ($PLATFORM eq 'win32') {
562 foreach my $symbol (qw(
622 win32_getprotobynumber
719 elsif ($PLATFORM eq 'os2') {
720 open MAP, 'miniperl.map' or die 'Cannot read miniperl.map';
721 /^\s*[\da-f:]+\s+(\w+)/i and $mapped{$1}++ foreach <MAP>;
722 close MAP or die 'Cannot close miniperl.map';
724 @missing = grep { !exists $mapped{$_} and !exists $bincompat5005{$_} }
726 delete $export{$_} foreach @missing;
729 # Now all symbols should be defined because
730 # next we are going to output them.
732 foreach my $symbol (sort keys %export) {
733 output_symbol($symbol);
739 $export{$symbol} = 1;
744 $symbol = $bincompat5005{$symbol}
745 if $define{PERL_BINCOMPAT_5005} and $symbol =~ /^($bincompat5005)$/;
746 if ($PLATFORM eq 'win32') {
747 $symbol = "_$symbol" if $CCTYPE eq 'BORLAND';
749 # XXX: binary compatibility between compilers is an exercise
751 # if ($CCTYPE eq "BORLAND") {
752 # # workaround Borland quirk by exporting both the straight
753 # # name and a name with leading underscore. Note the
754 # # alias *must* come after the symbol itself, if both
755 # # are to be exported. (Linker bug?)
756 # print "\t_$symbol\n";
757 # print "\t$symbol = _$symbol\n";
759 # elsif ($CCTYPE eq 'GCC') {
760 # # Symbols have leading _ whole process is $%@"% slow
761 # # so skip aliases for now
762 # nprint "\t$symbol\n";
765 # # for binary coexistence, export both the symbol and
766 # # alias with leading underscore
767 # print "\t$symbol\n";
768 # print "\t_$symbol = $symbol\n";
771 elsif ($PLATFORM eq 'os2') {
772 print qq( "$symbol"\n);
774 elsif ($PLATFORM eq 'aix') {
781 # extra globals not included above.