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/;
95 $define{$1} = 1 if /^\s*#\s*define\s+(PERL_BINCOMPAT_5005)\b/;
99 if ($PLATFORM eq 'win32') {
100 warn join(' ',keys %define)."\n";
101 if ($define{PERL_OBJECT}) {
102 print "LIBRARY Perl56\n";
103 print "DESCRIPTION 'Perl interpreter'\n";
105 # output_symbol("perl_alloc");
106 output_symbol("perl_get_host_info");
107 output_symbol("perl_alloc_using");
108 # output_symbol("perl_construct");
109 # output_symbol("perl_destruct");
110 # output_symbol("perl_free");
111 # output_symbol("perl_parse");
112 # output_symbol("perl_run");
113 # output_symbol("RunPerl");
117 if ($CCTYPE ne 'GCC') {
118 print "LIBRARY Perl\n";
119 print "DESCRIPTION 'Perl interpreter, export autogenerated'\n";
122 $define{'PERL_GLOBAL_STRUCT'} = 1;
123 $define{'MULTIPLICITY'} = 1;
127 } elsif ($PLATFORM eq 'os2') {
128 ($v = $]) =~ s/(\d\.\d\d\d)(\d\d)$/$1_$2/;
129 $v .= '-thread' if $ARCHNAME =~ /-thread/;
131 #for (split //, $v) {
132 # $sum = ($sum * 33) + ord;
137 #$sum = printf '%X', $sum;
138 ($dll = $define{PERL_DLL}) =~ s/\.dll$//i;
139 # print STDERR "'$dll' <= '$define{PERL_DLL}'\n";
141 LIBRARY '$dll' INITINSTANCE TERMINSTANCE
142 DESCRIPTION '\@#perl5-porters\@perl.org:$v#\@ Perl interpreter, configured as $CONFIG_ARGS'
145 DATA LOADONCALL NONSHARED MULTIPLE
148 } elsif ($PLATFORM eq 'aix') {
157 foreach my $symbol (@$list) {
164 foreach my $symbol (@$list) {
165 my $skipsym = $symbol;
167 if ($define{PERL_OBJECT}) {
168 $skipsym =~ s/^Perl_[GIT](\w+)_ptr$/PL_$1/;
170 emit_symbol($symbol) unless exists $skip{$skipsym};
174 if ($PLATFORM eq 'win32') {
199 Perl_init_thread_intern
219 } elsif ($PLATFORM eq 'aix') {
245 if ($PLATFORM eq 'os2') {
268 XS_Cwd_extLibpath_set
272 XS_Cwd_sys_is_absolute
273 XS_Cwd_sys_is_relative
275 XS_DynaLoader_mod2fname
276 XS_File__Copy_syscopy
280 Perl_Process_Messages
287 if ($define{'PERL_OBJECT'}) {
306 if ($define{'MYMALLOC'})
323 Perl_malloced_size)];
326 unless ($define{'USE_THREADS'})
348 Perl_new_struct_thread
349 Perl_per_thread_magicals
356 unless ($define{'USE_THREADS'} or $define{'PERL_IMPLICIT_CONTEXT'}
357 or $define{'PERL_OBJECT'})
366 Perl_warner_nocontext
367 Perl_newSVpvf_nocontext
368 Perl_sv_catpvf_nocontext
369 Perl_sv_setpvf_nocontext
370 Perl_sv_catpvf_mg_nocontext
371 Perl_sv_setpvf_mg_nocontext
375 unless ($define{'FAKE_THREADS'})
377 skip_symbols [qw(PL_curthr)];
383 my $proc = shift || sub { "PL_$_[2]" };
384 open(VARS,$file) || die "Cannot open $file: $!\n";
388 # All symbols have a Perl_ prefix because that's what embed.h
389 # sticks in front of them.
390 push(@syms, &$proc($1,$2,$3)) if (/\bPERLVAR(A?I?C?)\(([IGT])(\w+)/);
396 if ($define{'USE_THREADS'} || $define{'MULTIPLICITY'})
398 my $thrd = readvar($thrdvar_h);
402 if ($define{'MULTIPLICITY'})
404 my $interp = readvar($intrpvar_h);
405 skip_symbols $interp;
408 if ($define{'PERL_GLOBAL_STRUCT'})
410 my $global = readvar($perlvars_h);
411 skip_symbols $global;
412 emit_symbols [qw(Perl_GetVars)];
413 emit_symbols [qw(PL_Vars PL_VarsPtr)] unless $CCTYPE eq 'GCC';
416 unless ($define{'DEBUGGING'})
432 if ($PLATFORM eq 'win32' && $define{'HAVE_DES_FCRYPT'})
434 emit_symbols [qw(win32_crypt)];
437 # functions from *.sym files
439 my @syms = ($global_sym, $pp_sym, $globvar_sym);
441 if ($define{'USE_PERLIO'})
443 push @syms, $perlio_sym;
448 open (GLOBAL, "<$syms") || die "failed to open $syms: $!\n";
451 next if (!/^[A-Za-z]/);
452 # Functions have a Perl_ prefix
453 # Variables have a PL_ prefix
455 my $symbol = ($syms =~ /var\.sym$/i ? "PL_" : "");
457 emit_symbol($symbol) unless exists $skip{$symbol};
464 if ($define{'PERL_OBJECT'}) {
465 for my $f ($perlvars_h, $intrpvar_h, $thrdvar_h) {
466 my $glob = readvar($f, sub { "Perl_" . $_[1] . $_[2] . "_ptr" });
471 unless ($define{'PERL_GLOBAL_STRUCT'}) {
472 my $glob = readvar($perlvars_h);
475 unless ($define{'MULTIPLICITY'}) {
476 my $glob = readvar($intrpvar_h);
480 unless ($define{'MULTIPLICITY'} || $define{'USE_THREADS'}) {
481 my $glob = readvar($thrdvar_h);
489 return if $symbol !~ /^[A-Za-z]/;
490 return if $symbol =~ /^\#/;
493 return if exists $skip{$symbol};
494 emit_symbol($symbol);
501 if ($PLATFORM eq 'win32') {
502 foreach my $symbol (qw(
593 win32_getprotobynumber
652 elsif ($PLATFORM eq 'os2') {
653 open MAP, 'miniperl.map' or die 'Cannot read miniperl.map';
654 /^\s*[\da-f:]+\s+(\w+)/i and $mapped{$1}++ foreach <MAP>;
655 close MAP or die 'Cannot close miniperl.map';
657 @missing = grep { !exists $mapped{$_} } keys %export;
658 delete $export{$_} foreach @missing;
661 # Now all symbols should be defined because
662 # next we are going to output them.
664 foreach my $symbol (sort keys %export)
666 output_symbol($symbol);
672 $export{$symbol} = 1;
677 $symbol = $bincompat5005{$symbol}
678 if $define{PERL_BINCOMPAT_5005} and $symbol =~ /^($bincompat5005)$/;
679 if ($PLATFORM eq 'win32') {
680 $symbol = "_$symbol" if $CCTYPE eq 'BORLAND';
682 # XXX: binary compatibility between compilers is an exercise
684 # if ($CCTYPE eq "BORLAND") {
685 # # workaround Borland quirk by exporting both the straight
686 # # name and a name with leading underscore. Note the
687 # # alias *must* come after the symbol itself, if both
688 # # are to be exported. (Linker bug?)
689 # print "\t_$symbol\n";
690 # print "\t$symbol = _$symbol\n";
692 # elsif ($CCTYPE eq 'GCC') {
693 # # Symbols have leading _ whole process is $%@"% slow
694 # # so skip aliases for now
695 # nprint "\t$symbol\n";
698 # # for binary coexistence, export both the symbol and
699 # # alias with leading underscore
700 # print "\t$symbol\n";
701 # print "\t_$symbol = $symbol\n";
703 } elsif ($PLATFORM eq 'os2') {
704 print qq( "$symbol"\n);
705 } elsif ($PLATFORM eq 'aix') {
712 # extra globals not included above.