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");
35 my $bincompat5005 = join("|", keys %bincompat5005);
40 $define{$1} = 1 if ($flag =~ /^-D(\w+)$/);
41 $define{$1} = $2 if ($flag =~ /^-D(\w+)=(.+)$/);
42 $CCTYPE = $1 if ($flag =~ /^CCTYPE=(\w+)$/);
43 $PLATFORM = $1 if ($flag =~ /^PLATFORM=(\w+)$/);
46 my @PLATFORM = qw(aix win32 os2);
48 @PLATFORM{@PLATFORM} = ();
50 defined $PLATFORM || die "PLATFORM undefined, must be one of: @PLATFORM\n";
51 exists $PLATFORM{$PLATFORM} || die "PLATFORM must be one of: @PLATFORM\n";
53 my $config_sh = "config.sh";
54 my $config_h = "config.h";
55 my $thrdvar_h = "thrdvar.h";
56 my $intrpvar_h = "intrpvar.h";
57 my $perlvars_h = "perlvars.h";
58 my $global_sym = "global.sym";
59 my $pp_sym = "pp.sym";
60 my $globvar_sym = "globvar.sym";
61 my $perlio_sym = "perlio.sym";
63 if ($PLATFORM eq 'aix') {
65 } elsif ($PLATFORM eq 'win32') {
66 $CCTYPE = "MSVC" unless defined $CCTYPE;
67 foreach ($thrdvar_h, $intrpvar_h, $perlvars_h, $global_sym, $pp_sym, $globvar_sym) {
72 unless ($PLATFORM eq 'win32') {
73 open(CFG,$config_sh) || die "Cannot open $config_sh: $!\n";
76 if (/^(?:ccflags|optimize)='(.+)'$/) {
78 $define{$1} = 1 while /-D(\w+)/g;
80 if ($PLATFORM eq 'os2') {
81 $CONFIG_ARGS = $1 if /^(?:config_args)='(.+)'$/;
82 $ARCHNAME = $1 if /^(?:archname)='(.+)'$/;
88 open(CFG,$config_h) || die "Cannot open $config_h: $!\n";
91 $define{$1} = 1 if /^\s*#\s*define\s+(MYMALLOC)\b/;
92 $define{$1} = 1 if /^\s*#\s*define\s+(USE_THREADS)\b/;
93 $define{$1} = 1 if /^\s*#\s*define\s+(USE_PERLIO)\b/;
94 $define{$1} = 1 if /^\s*#\s*define\s+(MULTIPLICITY)\b/;
98 if ($PLATFORM eq 'win32') {
99 warn join(' ',keys %define)."\n";
100 if ($define{PERL_OBJECT}) {
101 print "LIBRARY Perl56\n";
102 print "DESCRIPTION 'Perl interpreter'\n";
104 # output_symbol("perl_alloc");
105 output_symbol("perl_get_host_info");
106 output_symbol("perl_alloc_using");
107 # output_symbol("perl_construct");
108 # output_symbol("perl_destruct");
109 # output_symbol("perl_free");
110 # output_symbol("perl_parse");
111 # output_symbol("perl_run");
112 # output_symbol("RunPerl");
116 if ($CCTYPE ne 'GCC') {
117 print "LIBRARY Perl\n";
118 print "DESCRIPTION 'Perl interpreter, export autogenerated'\n";
121 $define{'PERL_GLOBAL_STRUCT'} = 1;
122 $define{'MULTIPLICITY'} = 1;
126 } elsif ($PLATFORM eq 'os2') {
127 ($v = $]) =~ s/(\d\.\d\d\d)(\d\d)$/$1_$2/;
128 $v .= '-thread' if $ARCHNAME =~ /-thread/;
130 #for (split //, $v) {
131 # $sum = ($sum * 33) + ord;
136 #$sum = printf '%X', $sum;
137 ($dll = $define{PERL_DLL}) =~ s/\.dll$//i;
138 # print STDERR "'$dll' <= '$define{PERL_DLL}'\n";
140 LIBRARY '$dll' INITINSTANCE TERMINSTANCE
141 DESCRIPTION '\@#perl5-porters\@perl.org:$v#\@ Perl interpreter, configured as $CONFIG_ARGS'
144 DATA LOADONCALL NONSHARED MULTIPLE
147 } elsif ($PLATFORM eq 'aix') {
156 foreach my $symbol (@$list) {
163 foreach my $symbol (@$list) {
164 my $skipsym = $symbol;
166 if ($define{PERL_OBJECT}) {
167 $skipsym =~ s/^Perl_[GIT](\w+)_ptr$/PL_$1/;
169 emit_symbol($symbol) unless exists $skip{$skipsym};
173 if ($PLATFORM eq 'win32') {
198 Perl_init_thread_intern
218 } elsif ($PLATFORM eq 'aix') {
244 if ($PLATFORM eq 'os2') {
267 XS_Cwd_extLibpath_set
271 XS_Cwd_sys_is_absolute
272 XS_Cwd_sys_is_relative
274 XS_DynaLoader_mod2fname
275 XS_File__Copy_syscopy
279 Perl_Process_Messages
286 if ($define{'PERL_OBJECT'}) {
305 if ($define{'MYMALLOC'})
322 Perl_malloced_size)];
325 unless ($define{'USE_THREADS'})
347 Perl_new_struct_thread
348 Perl_per_thread_magicals
355 unless ($define{'USE_THREADS'} or $define{'PERL_IMPLICIT_CONTEXT'}
356 or $define{'PERL_OBJECT'})
364 Perl_warner_nocontext
365 Perl_newSVpvf_nocontext
366 Perl_sv_catpvf_nocontext
367 Perl_sv_setpvf_nocontext
368 Perl_sv_catpvf_mg_nocontext
369 Perl_sv_setpvf_mg_nocontext
373 unless ($define{'FAKE_THREADS'})
375 skip_symbols [qw(PL_curthr)];
381 my $proc = shift || sub { "PL_$_[2]" };
382 open(VARS,$file) || die "Cannot open $file: $!\n";
386 # All symbols have a Perl_ prefix because that's what embed.h
387 # sticks in front of them.
388 push(@syms, &$proc($1,$2,$3)) if (/\bPERLVAR(A?I?C?)\(([IGT])(\w+)/);
394 if ($define{'USE_THREADS'} || $define{'MULTIPLICITY'})
396 my $thrd = readvar($thrdvar_h);
400 if ($define{'MULTIPLICITY'})
402 my $interp = readvar($intrpvar_h);
403 skip_symbols $interp;
406 if ($define{'PERL_GLOBAL_STRUCT'})
408 my $global = readvar($perlvars_h);
409 skip_symbols $global;
410 emit_symbols [qw(Perl_GetVars)];
411 emit_symbols [qw(PL_Vars PL_VarsPtr)] unless $CCTYPE eq 'GCC';
414 unless ($define{'DEBUGGING'})
430 if ($PLATFORM eq 'win32' && $define{'HAVE_DES_FCRYPT'})
432 emit_symbols [qw(win32_crypt)];
435 # functions from *.sym files
437 my @syms = ($global_sym, $pp_sym, $globvar_sym);
439 if ($define{'USE_PERLIO'})
441 push @syms, $perlio_sym;
446 open (GLOBAL, "<$syms") || die "failed to open $syms: $!\n";
449 next if (!/^[A-Za-z]/);
450 # Functions have a Perl_ prefix
451 # Variables have a PL_ prefix
453 my $symbol = ($syms =~ /var\.sym$/i ? "PL_" : "");
455 emit_symbol($symbol) unless exists $skip{$symbol};
462 if ($define{'PERL_OBJECT'}) {
463 for my $f ($perlvars_h, $intrpvar_h, $thrdvar_h) {
464 my $glob = readvar($f, sub { "Perl_" . $_[1] . $_[2] . "_ptr" });
469 unless ($define{'PERL_GLOBAL_STRUCT'}) {
470 my $glob = readvar($perlvars_h);
473 unless ($define{'MULTIPLICITY'}) {
474 my $glob = readvar($intrpvar_h);
478 unless ($define{'MULTIPLICITY'} || $define{'USE_THREADS'}) {
479 my $glob = readvar($thrdvar_h);
487 return if $symbol !~ /^[A-Za-z]/;
488 return if $symbol =~ /^\#/;
491 return if exists $skip{$symbol};
492 emit_symbol($symbol);
499 if ($PLATFORM eq 'win32') {
500 foreach my $symbol (qw(
591 win32_getprotobynumber
650 elsif ($PLATFORM eq 'os2') {
651 open MAP, 'miniperl.map' or die 'Cannot read miniperl.map';
652 /^\s*[\da-f:]+\s+(\w+)/i and $mapped{$1}++ foreach <MAP>;
653 close MAP or die 'Cannot close miniperl.map';
655 @missing = grep { !exists $mapped{$_} } keys %export;
656 delete $export{$_} foreach @missing;
659 # Now all symbols should be defined because
660 # next we are going to output them.
662 foreach my $symbol (sort keys %export)
664 output_symbol($symbol);
670 $export{$symbol} = 1;
675 $symbol = $bincompat5005{$symbol} if $symbol =~ /^($bincompat5005)$/;
676 if ($PLATFORM eq 'win32') {
677 $symbol = "_$symbol" if $CCTYPE eq 'BORLAND';
679 # XXX: binary compatibility between compilers is an exercise
681 # if ($CCTYPE eq "BORLAND") {
682 # # workaround Borland quirk by exporting both the straight
683 # # name and a name with leading underscore. Note the
684 # # alias *must* come after the symbol itself, if both
685 # # are to be exported. (Linker bug?)
686 # print "\t_$symbol\n";
687 # print "\t$symbol = _$symbol\n";
689 # elsif ($CCTYPE eq 'GCC') {
690 # # Symbols have leading _ whole process is $%@"% slow
691 # # so skip aliases for now
692 # nprint "\t$symbol\n";
695 # # for binary coexistence, export both the symbol and
696 # # alias with leading underscore
697 # print "\t$symbol\n";
698 # print "\t_$symbol = $symbol\n";
700 } elsif ($PLATFORM eq 'os2') {
701 print qq( "$symbol"\n);
702 } elsif ($PLATFORM eq 'aix') {
709 # extra globals not included above.