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);
44 $define{$1} = 1 if ($flag =~ /^-D(\w+)$/);
45 $define{$1} = $2 if ($flag =~ /^-D(\w+)=(.+)$/);
46 $CCTYPE = $1 if ($flag =~ /^CCTYPE=(\w+)$/);
47 $PLATFORM = $1 if ($flag =~ /^PLATFORM=(\w+)$/);
50 my @PLATFORM = qw(aix win32 os2);
52 @PLATFORM{@PLATFORM} = ();
54 defined $PLATFORM || die "PLATFORM undefined, must be one of: @PLATFORM\n";
55 exists $PLATFORM{$PLATFORM} || die "PLATFORM must be one of: @PLATFORM\n";
57 my $config_sh = "config.sh";
58 my $config_h = "config.h";
59 my $thrdvar_h = "thrdvar.h";
60 my $intrpvar_h = "intrpvar.h";
61 my $perlvars_h = "perlvars.h";
62 my $global_sym = "global.sym";
63 my $pp_sym = "pp.sym";
64 my $globvar_sym = "globvar.sym";
65 my $perlio_sym = "perlio.sym";
67 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";
80 if (/^(?:ccflags|optimize)='(.+)'$/) {
82 $define{$1} = 1 while /-D(\w+)/g;
84 if ($PLATFORM eq 'os2') {
85 $CONFIG_ARGS = $1 if /^(?:config_args)='(.+)'$/;
86 $ARCHNAME = $1 if /^(?:archname)='(.+)'$/;
92 open(CFG,$config_h) || die "Cannot open $config_h: $!\n";
95 $define{$1} = 1 if /^\s*#\s*define\s+(MYMALLOC)\b/;
96 $define{$1} = 1 if /^\s*#\s*define\s+(USE_THREADS)\b/;
97 $define{$1} = 1 if /^\s*#\s*define\s+(USE_PERLIO)\b/;
98 $define{$1} = 1 if /^\s*#\s*define\s+(MULTIPLICITY)\b/;
99 $define{$1} = 1 if /^\s*#\s*define\s+(PERL_BINCOMPAT_5005)\b/;
103 if ($PLATFORM eq 'win32') {
104 warn join(' ',keys %define)."\n";
105 if ($define{PERL_OBJECT}) {
106 print "LIBRARY Perl56\n";
107 print "DESCRIPTION 'Perl interpreter'\n";
109 # output_symbol("perl_alloc");
110 output_symbol("perl_get_host_info");
111 output_symbol("perl_alloc_using");
112 # output_symbol("perl_construct");
113 # output_symbol("perl_destruct");
114 # output_symbol("perl_free");
115 # output_symbol("perl_parse");
116 # output_symbol("perl_run");
117 # output_symbol("RunPerl");
121 if ($CCTYPE ne 'GCC') {
122 print "LIBRARY Perl\n";
123 print "DESCRIPTION 'Perl interpreter, export autogenerated'\n";
126 $define{'PERL_GLOBAL_STRUCT'} = 1;
127 $define{'MULTIPLICITY'} = 1;
131 } elsif ($PLATFORM eq 'os2') {
132 ($v = $]) =~ s/(\d\.\d\d\d)(\d\d)$/$1_$2/;
133 $v .= '-thread' if $ARCHNAME =~ /-thread/;
135 #for (split //, $v) {
136 # $sum = ($sum * 33) + ord;
141 #$sum = printf '%X', $sum;
142 ($dll = $define{PERL_DLL}) =~ s/\.dll$//i;
143 # print STDERR "'$dll' <= '$define{PERL_DLL}'\n";
145 LIBRARY '$dll' INITINSTANCE TERMINSTANCE
146 DESCRIPTION '\@#perl5-porters\@perl.org:$v#\@ Perl interpreter, configured as $CONFIG_ARGS'
149 DATA LOADONCALL NONSHARED MULTIPLE
152 } elsif ($PLATFORM eq 'aix') {
161 foreach my $symbol (@$list) {
168 foreach my $symbol (@$list) {
169 my $skipsym = $symbol;
171 if ($define{PERL_OBJECT}) {
172 $skipsym =~ s/^Perl_[GIT](\w+)_ptr$/PL_$1/;
174 emit_symbol($symbol) unless exists $skip{$skipsym};
178 if ($PLATFORM eq 'win32') {
203 Perl_init_thread_intern
228 } elsif ($PLATFORM eq 'aix') {
254 if ($PLATFORM eq 'os2') {
278 XS_Cwd_extLibpath_set
282 XS_Cwd_sys_is_absolute
283 XS_Cwd_sys_is_relative
285 XS_DynaLoader_mod2fname
286 XS_File__Copy_syscopy
290 Perl_Process_Messages
297 if ($define{'PERL_OBJECT'}) {
316 if ($define{'MYMALLOC'})
333 Perl_malloced_size)];
336 unless ($define{'USE_THREADS'})
358 Perl_new_struct_thread
359 Perl_per_thread_magicals
367 unless ($define{'USE_ITHREADS'})
388 unless ($define{'USE_THREADS'} or $define{'PERL_IMPLICIT_CONTEXT'}
389 or $define{'PERL_OBJECT'})
398 Perl_warner_nocontext
399 Perl_newSVpvf_nocontext
400 Perl_sv_catpvf_nocontext
401 Perl_sv_setpvf_nocontext
402 Perl_sv_catpvf_mg_nocontext
403 Perl_sv_setpvf_mg_nocontext
407 unless ($define{'FAKE_THREADS'})
409 skip_symbols [qw(PL_curthr)];
415 my $proc = shift || sub { "PL_$_[2]" };
416 open(VARS,$file) || die "Cannot open $file: $!\n";
420 # All symbols have a Perl_ prefix because that's what embed.h
421 # sticks in front of them.
422 push(@syms, &$proc($1,$2,$3)) if (/\bPERLVAR(A?I?C?)\(([IGT])(\w+)/);
428 if ($define{'USE_THREADS'} || $define{'MULTIPLICITY'})
430 my $thrd = readvar($thrdvar_h);
434 if ($define{'MULTIPLICITY'})
436 my $interp = readvar($intrpvar_h);
437 skip_symbols $interp;
440 if ($define{'PERL_GLOBAL_STRUCT'})
442 my $global = readvar($perlvars_h);
443 skip_symbols $global;
444 emit_symbol('Perl_GetVars');
445 emit_symbols [qw(PL_Vars PL_VarsPtr)] unless $CCTYPE eq 'GCC';
448 unless ($define{'DEBUGGING'})
464 # functions from *.sym files
466 my @syms = ($global_sym, $pp_sym, $globvar_sym);
468 if ($define{'USE_PERLIO'})
470 push @syms, $perlio_sym;
475 open (GLOBAL, "<$syms") || die "failed to open $syms: $!\n";
478 next if (!/^[A-Za-z]/);
479 # Functions have a Perl_ prefix
480 # Variables have a PL_ prefix
482 my $symbol = ($syms =~ /var\.sym$/i ? "PL_" : "");
484 emit_symbol($symbol) unless exists $skip{$symbol};
491 if ($define{'PERL_OBJECT'}) {
492 for my $f ($perlvars_h, $intrpvar_h, $thrdvar_h) {
493 my $glob = readvar($f, sub { "Perl_" . $_[1] . $_[2] . "_ptr" });
498 unless ($define{'PERL_GLOBAL_STRUCT'}) {
499 my $glob = readvar($perlvars_h);
502 unless ($define{'MULTIPLICITY'}) {
503 my $glob = readvar($intrpvar_h);
507 unless ($define{'MULTIPLICITY'} || $define{'USE_THREADS'}) {
508 my $glob = readvar($thrdvar_h);
516 return if $symbol !~ /^[A-Za-z]/;
517 return if $symbol =~ /^\#/;
520 return if exists $skip{$symbol};
521 emit_symbol($symbol);
528 if ($PLATFORM eq 'win32') {
529 foreach my $symbol (qw(
620 win32_getprotobynumber
680 elsif ($PLATFORM eq 'os2') {
681 open MAP, 'miniperl.map' or die 'Cannot read miniperl.map';
682 /^\s*[\da-f:]+\s+(\w+)/i and $mapped{$1}++ foreach <MAP>;
683 close MAP or die 'Cannot close miniperl.map';
685 @missing = grep { !exists $mapped{$_} and !exists $bincompat5005{$_} }
687 delete $export{$_} foreach @missing;
690 # Now all symbols should be defined because
691 # next we are going to output them.
693 foreach my $symbol (sort keys %export)
695 output_symbol($symbol);
701 $export{$symbol} = 1;
706 $symbol = $bincompat5005{$symbol}
707 if $define{PERL_BINCOMPAT_5005} and $symbol =~ /^($bincompat5005)$/;
708 if ($PLATFORM eq 'win32') {
709 $symbol = "_$symbol" if $CCTYPE eq 'BORLAND';
711 # XXX: binary compatibility between compilers is an exercise
713 # if ($CCTYPE eq "BORLAND") {
714 # # workaround Borland quirk by exporting both the straight
715 # # name and a name with leading underscore. Note the
716 # # alias *must* come after the symbol itself, if both
717 # # are to be exported. (Linker bug?)
718 # print "\t_$symbol\n";
719 # print "\t$symbol = _$symbol\n";
721 # elsif ($CCTYPE eq 'GCC') {
722 # # Symbols have leading _ whole process is $%@"% slow
723 # # so skip aliases for now
724 # nprint "\t$symbol\n";
727 # # for binary coexistence, export both the symbol and
728 # # alias with leading underscore
729 # print "\t$symbol\n";
730 # print "\t_$symbol = $symbol\n";
732 } elsif ($PLATFORM eq 'os2') {
733 print qq( "$symbol"\n);
734 } elsif ($PLATFORM eq 'aix') {
741 # extra globals not included above.