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);
43 $define{$1} = 1 if ($flag =~ /^-D(\w+)$/);
44 $define{$1} = $2 if ($flag =~ /^-D(\w+)=(.+)$/);
45 $CCTYPE = $1 if ($flag =~ /^CCTYPE=(\w+)$/);
46 $PLATFORM = $1 if ($flag =~ /^PLATFORM=(\w+)$/);
49 my @PLATFORM = qw(aix win32 os2);
51 @PLATFORM{@PLATFORM} = ();
53 defined $PLATFORM || die "PLATFORM undefined, must be one of: @PLATFORM\n";
54 exists $PLATFORM{$PLATFORM} || die "PLATFORM must be one of: @PLATFORM\n";
56 my $config_sh = "config.sh";
57 my $config_h = "config.h";
58 my $thrdvar_h = "thrdvar.h";
59 my $intrpvar_h = "intrpvar.h";
60 my $perlvars_h = "perlvars.h";
61 my $global_sym = "global.sym";
62 my $pp_sym = "pp.sym";
63 my $globvar_sym = "globvar.sym";
64 my $perlio_sym = "perlio.sym";
66 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";
79 if (/^(?:ccflags|optimize)='(.+)'$/) {
81 $define{$1} = 1 while /-D(\w+)/g;
83 if ($PLATFORM eq 'os2') {
84 $CONFIG_ARGS = $1 if /^(?:config_args)='(.+)'$/;
85 $ARCHNAME = $1 if /^(?:archname)='(.+)'$/;
91 open(CFG,$config_h) || die "Cannot open $config_h: $!\n";
93 $define{$1} = 1 if /^\s*#\s*define\s+(MYMALLOC)\b/;
94 $define{$1} = 1 if /^\s*#\s*define\s+(USE_5005THREADS)\b/;
95 $define{$1} = 1 if /^\s*#\s*define\s+(USE_ITHREADS)\b/;
96 $define{$1} = 1 if /^\s*#\s*define\s+(USE_PERLIO)\b/;
97 $define{$1} = 1 if /^\s*#\s*define\s+(MULTIPLICITY)\b/;
98 $define{$1} = 1 if /^\s*#\s*define\s+(PERL_BINCOMPAT_5005)\b/;
102 if ($PLATFORM eq 'win32') {
103 warn join(' ',keys %define)."\n";
104 if ($define{PERL_OBJECT} || $define{MULTIPLICITY}) {
105 print "LIBRARY Perl56\n";
106 print "DESCRIPTION 'Perl interpreter'\n";
108 output_symbol("perl_get_host_info");
109 output_symbol("perl_alloc_override");
112 print "LIBRARY Perl56\n";
113 print "DESCRIPTION 'Perl interpreter, export autogenerated'\n";
117 elsif ($PLATFORM eq 'os2') {
118 ($v = $]) =~ s/(\d\.\d\d\d)(\d\d)$/$1_$2/;
119 $v .= '-thread' if $ARCHNAME =~ /-thread/;
121 #for (split //, $v) {
122 # $sum = ($sum * 33) + ord;
127 #$sum = printf '%X', $sum;
128 ($dll = $define{PERL_DLL}) =~ s/\.dll$//i;
129 # print STDERR "'$dll' <= '$define{PERL_DLL}'\n";
131 LIBRARY '$dll' INITINSTANCE TERMINSTANCE
132 DESCRIPTION '\@#perl5-porters\@perl.org:$v#\@ Perl interpreter, configured as $CONFIG_ARGS'
135 DATA LOADONCALL NONSHARED MULTIPLE
139 elsif ($PLATFORM eq 'aix') {
148 foreach my $symbol (@$list) {
155 foreach my $symbol (@$list) {
156 my $skipsym = $symbol;
158 if ($define{PERL_OBJECT} || $define{MULTIPLICITY}) {
159 $skipsym =~ s/^Perl_[GIT](\w+)_ptr$/PL_$1/;
161 emit_symbol($symbol) unless exists $skip{$skipsym};
165 if ($PLATFORM eq 'win32') {
190 Perl_init_thread_intern
215 elsif ($PLATFORM eq 'aix') {
240 elsif ($PLATFORM eq 'os2') {
264 XS_Cwd_extLibpath_set
268 XS_Cwd_sys_is_absolute
269 XS_Cwd_sys_is_relative
271 XS_DynaLoader_mod2fname
272 XS_File__Copy_syscopy
276 Perl_Process_Messages
283 unless ($define{'DEBUGGING'}) {
299 if ($define{'PERL_IMPLICIT_SYS'}) {
320 if ($define{'MYMALLOC'}) {
328 if ($define{'USE_5005THREADS'} || $define{'USE_ITHREADS'}) {
346 unless ($define{'USE_5005THREADS'}) {
366 Perl_new_struct_thread
367 Perl_per_thread_magicals
375 unless ($define{'USE_ITHREADS'}) {
399 unless ($define{'PERL_IMPLICIT_CONTEXT'}) {
407 Perl_warner_nocontext
408 Perl_newSVpvf_nocontext
409 Perl_sv_catpvf_nocontext
410 Perl_sv_setpvf_nocontext
411 Perl_sv_catpvf_mg_nocontext
412 Perl_sv_setpvf_mg_nocontext
416 unless ($define{'PERL_IMPLICIT_SYS'}) {
423 unless ($define{'FAKE_THREADS'}) {
424 skip_symbols [qw(PL_curthr)];
429 my $proc = shift || sub { "PL_$_[2]" };
430 open(VARS,$file) || die "Cannot open $file: $!\n";
433 # All symbols have a Perl_ prefix because that's what embed.h
434 # sticks in front of them.
435 push(@syms, &$proc($1,$2,$3)) if (/\bPERLVAR(A?I?C?)\(([IGT])(\w+)/);
441 if ($define{'USE_5005THREADS'}) {
442 my $thrd = readvar($thrdvar_h);
446 if ($define{'PERL_GLOBAL_STRUCT'}) {
447 my $global = readvar($perlvars_h);
448 skip_symbols $global;
449 emit_symbol('Perl_GetVars');
450 emit_symbols [qw(PL_Vars PL_VarsPtr)] unless $CCTYPE eq 'GCC';
453 # functions from *.sym files
455 my @syms = ($global_sym, $pp_sym, $globvar_sym);
457 if ($define{'USE_PERLIO'}) {
458 push @syms, $perlio_sym;
461 for my $syms (@syms) {
462 open (GLOBAL, "<$syms") || die "failed to open $syms: $!\n";
464 next if (!/^[A-Za-z]/);
465 # Functions have a Perl_ prefix
466 # Variables have a PL_ prefix
468 my $symbol = ($syms =~ /var\.sym$/i ? "PL_" : "");
470 emit_symbol($symbol) unless exists $skip{$symbol};
477 if ($define{'PERL_OBJECT'} || $define{'MULTIPLICITY'}) {
478 for my $f ($perlvars_h, $intrpvar_h, $thrdvar_h) {
479 my $glob = readvar($f, sub { "Perl_" . $_[1] . $_[2] . "_ptr" });
484 unless ($define{'PERL_GLOBAL_STRUCT'}) {
485 my $glob = readvar($perlvars_h);
488 unless ($define{'MULTIPLICITY'}) {
489 my $glob = readvar($intrpvar_h);
492 unless ($define{'MULTIPLICITY'} || $define{'USE_5005THREADS'}) {
493 my $glob = readvar($thrdvar_h);
501 return if $symbol !~ /^[A-Za-z]/;
502 return if $symbol =~ /^\#/;
505 return if exists $skip{$symbol};
506 emit_symbol($symbol);
513 if ($PLATFORM eq 'win32') {
514 foreach my $symbol (qw(
605 win32_getprotobynumber
672 elsif ($PLATFORM eq 'os2') {
673 open MAP, 'miniperl.map' or die 'Cannot read miniperl.map';
674 /^\s*[\da-f:]+\s+(\w+)/i and $mapped{$1}++ foreach <MAP>;
675 close MAP or die 'Cannot close miniperl.map';
677 @missing = grep { !exists $mapped{$_} and !exists $bincompat5005{$_} }
679 delete $export{$_} foreach @missing;
682 # Now all symbols should be defined because
683 # next we are going to output them.
685 foreach my $symbol (sort keys %export) {
686 output_symbol($symbol);
692 $export{$symbol} = 1;
697 $symbol = $bincompat5005{$symbol}
698 if $define{PERL_BINCOMPAT_5005} and $symbol =~ /^($bincompat5005)$/;
699 if ($PLATFORM eq 'win32') {
700 $symbol = "_$symbol" if $CCTYPE eq 'BORLAND';
702 # XXX: binary compatibility between compilers is an exercise
704 # if ($CCTYPE eq "BORLAND") {
705 # # workaround Borland quirk by exporting both the straight
706 # # name and a name with leading underscore. Note the
707 # # alias *must* come after the symbol itself, if both
708 # # are to be exported. (Linker bug?)
709 # print "\t_$symbol\n";
710 # print "\t$symbol = _$symbol\n";
712 # elsif ($CCTYPE eq 'GCC') {
713 # # Symbols have leading _ whole process is $%@"% slow
714 # # so skip aliases for now
715 # nprint "\t$symbol\n";
718 # # for binary coexistence, export both the symbol and
719 # # alias with leading underscore
720 # print "\t$symbol\n";
721 # print "\t_$symbol = $symbol\n";
724 elsif ($PLATFORM eq 'os2') {
725 print qq( "$symbol"\n);
727 elsif ($PLATFORM eq 'aix') {
734 # extra globals not included above.