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
224 } elsif ($PLATFORM eq 'aix') {
250 if ($PLATFORM eq 'os2') {
274 XS_Cwd_extLibpath_set
278 XS_Cwd_sys_is_absolute
279 XS_Cwd_sys_is_relative
281 XS_DynaLoader_mod2fname
282 XS_File__Copy_syscopy
286 Perl_Process_Messages
293 if ($define{'PERL_OBJECT'}) {
312 if ($define{'MYMALLOC'})
329 Perl_malloced_size)];
332 unless ($define{'USE_THREADS'})
354 Perl_new_struct_thread
355 Perl_per_thread_magicals
363 unless ($define{'USE_ITHREADS'})
382 unless ($define{'USE_THREADS'} or $define{'PERL_IMPLICIT_CONTEXT'}
383 or $define{'PERL_OBJECT'})
392 Perl_warner_nocontext
393 Perl_newSVpvf_nocontext
394 Perl_sv_catpvf_nocontext
395 Perl_sv_setpvf_nocontext
396 Perl_sv_catpvf_mg_nocontext
397 Perl_sv_setpvf_mg_nocontext
401 unless ($define{'FAKE_THREADS'})
403 skip_symbols [qw(PL_curthr)];
409 my $proc = shift || sub { "PL_$_[2]" };
410 open(VARS,$file) || die "Cannot open $file: $!\n";
414 # All symbols have a Perl_ prefix because that's what embed.h
415 # sticks in front of them.
416 push(@syms, &$proc($1,$2,$3)) if (/\bPERLVAR(A?I?C?)\(([IGT])(\w+)/);
422 if ($define{'USE_THREADS'} || $define{'MULTIPLICITY'})
424 my $thrd = readvar($thrdvar_h);
428 if ($define{'MULTIPLICITY'})
430 my $interp = readvar($intrpvar_h);
431 skip_symbols $interp;
434 if ($define{'PERL_GLOBAL_STRUCT'})
436 my $global = readvar($perlvars_h);
437 skip_symbols $global;
438 emit_symbol('Perl_GetVars');
439 emit_symbols [qw(PL_Vars PL_VarsPtr)] unless $CCTYPE eq 'GCC';
442 unless ($define{'DEBUGGING'})
458 # functions from *.sym files
460 my @syms = ($global_sym, $pp_sym, $globvar_sym);
462 if ($define{'USE_PERLIO'})
464 push @syms, $perlio_sym;
469 open (GLOBAL, "<$syms") || die "failed to open $syms: $!\n";
472 next if (!/^[A-Za-z]/);
473 # Functions have a Perl_ prefix
474 # Variables have a PL_ prefix
476 my $symbol = ($syms =~ /var\.sym$/i ? "PL_" : "");
478 emit_symbol($symbol) unless exists $skip{$symbol};
485 if ($define{'PERL_OBJECT'}) {
486 for my $f ($perlvars_h, $intrpvar_h, $thrdvar_h) {
487 my $glob = readvar($f, sub { "Perl_" . $_[1] . $_[2] . "_ptr" });
492 unless ($define{'PERL_GLOBAL_STRUCT'}) {
493 my $glob = readvar($perlvars_h);
496 unless ($define{'MULTIPLICITY'}) {
497 my $glob = readvar($intrpvar_h);
501 unless ($define{'MULTIPLICITY'} || $define{'USE_THREADS'}) {
502 my $glob = readvar($thrdvar_h);
510 return if $symbol !~ /^[A-Za-z]/;
511 return if $symbol =~ /^\#/;
514 return if exists $skip{$symbol};
515 emit_symbol($symbol);
522 if ($PLATFORM eq 'win32') {
523 foreach my $symbol (qw(
614 win32_getprotobynumber
674 elsif ($PLATFORM eq 'os2') {
675 open MAP, 'miniperl.map' or die 'Cannot read miniperl.map';
676 /^\s*[\da-f:]+\s+(\w+)/i and $mapped{$1}++ foreach <MAP>;
677 close MAP or die 'Cannot close miniperl.map';
679 @missing = grep { !exists $mapped{$_} and !exists $bincompat5005{$_} }
681 delete $export{$_} foreach @missing;
684 # Now all symbols should be defined because
685 # next we are going to output them.
687 foreach my $symbol (sort keys %export)
689 output_symbol($symbol);
695 $export{$symbol} = 1;
700 $symbol = $bincompat5005{$symbol}
701 if $define{PERL_BINCOMPAT_5005} and $symbol =~ /^($bincompat5005)$/;
702 if ($PLATFORM eq 'win32') {
703 $symbol = "_$symbol" if $CCTYPE eq 'BORLAND';
705 # XXX: binary compatibility between compilers is an exercise
707 # if ($CCTYPE eq "BORLAND") {
708 # # workaround Borland quirk by exporting both the straight
709 # # name and a name with leading underscore. Note the
710 # # alias *must* come after the symbol itself, if both
711 # # are to be exported. (Linker bug?)
712 # print "\t_$symbol\n";
713 # print "\t$symbol = _$symbol\n";
715 # elsif ($CCTYPE eq 'GCC') {
716 # # Symbols have leading _ whole process is $%@"% slow
717 # # so skip aliases for now
718 # nprint "\t$symbol\n";
721 # # for binary coexistence, export both the symbol and
722 # # alias with leading underscore
723 # print "\t$symbol\n";
724 # print "\t_$symbol = $symbol\n";
726 } elsif ($PLATFORM eq 'os2') {
727 print qq( "$symbol"\n);
728 } elsif ($PLATFORM eq 'aix') {
735 # extra globals not included above.