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
15 Perl_call_atexit => "perl_atexit",
16 Perl_eval_sv => "perl_eval_sv",
17 Perl_eval_pv => "perl_eval_pv",
18 Perl_call_argv => "perl_call_argv",
19 Perl_call_method => "perl_call_method",
20 Perl_call_pv => "perl_call_pv",
21 Perl_call_sv => "perl_call_sv",
22 Perl_get_av => "perl_get_av",
23 Perl_get_cv => "perl_get_cv",
24 Perl_get_hv => "perl_get_hv",
25 Perl_get_sv => "perl_get_sv",
26 Perl_init_i18nl10n => "perl_init_i18nl10n",
27 Perl_init_i18nl14n => "perl_init_i18nl14n",
28 Perl_new_collate => "perl_new_collate",
29 Perl_new_ctype => "perl_new_ctype",
30 Perl_new_numeric => "perl_new_numeric",
31 Perl_require_pv => "perl_require_pv",
32 Perl_safesyscalloc => "Perl_safecalloc",
33 Perl_safesysfree => "Perl_safefree",
34 Perl_safesysmalloc => "Perl_safemalloc",
35 Perl_safesysrealloc => "Perl_saferealloc",
36 Perl_set_numeric_local => "perl_set_numeric_local",
37 Perl_set_numeric_standard => "perl_set_numeric_standard",
38 Perl_malloc => "malloc",
40 Perl_realloc => "realloc",
41 Perl_calloc => "calloc",
44 my $bincompat5005 = join("|", keys %bincompat5005);
48 $define{$1} = 1 if ($flag =~ /^-D(\w+)$/);
49 $define{$1} = $2 if ($flag =~ /^-D(\w+)=(.+)$/);
50 $CCTYPE = $1 if ($flag =~ /^CCTYPE=(\w+)$/);
51 $PLATFORM = $1 if ($flag =~ /^PLATFORM=(\w+)$/);
54 my @PLATFORM = qw(aix win32 os2 MacOS);
56 @PLATFORM{@PLATFORM} = ();
58 defined $PLATFORM || die "PLATFORM undefined, must be one of: @PLATFORM\n";
59 exists $PLATFORM{$PLATFORM} || die "PLATFORM must be one of: @PLATFORM\n";
61 my $config_sh = "config.sh";
62 my $config_h = "config.h";
63 my $thrdvar_h = "thrdvar.h";
64 my $intrpvar_h = "intrpvar.h";
65 my $perlvars_h = "perlvars.h";
66 my $global_sym = "global.sym";
67 my $pp_sym = "pp.sym";
68 my $globvar_sym = "globvar.sym";
69 my $perlio_sym = "perlio.sym";
71 if ($PLATFORM eq 'aix') {
74 elsif ($PLATFORM eq 'win32') {
75 $CCTYPE = "MSVC" unless defined $CCTYPE;
76 foreach ($thrdvar_h, $intrpvar_h, $perlvars_h, $global_sym,
77 $pp_sym, $globvar_sym, $perlio_sym) {
81 elsif ($PLATFORM eq 'MacOS') {
82 foreach ($thrdvar_h, $intrpvar_h, $perlvars_h, $global_sym,
83 $pp_sym, $globvar_sym, $perlio_sym) {
88 unless ($PLATFORM eq 'win32' || $PLATFORM eq 'MacOS') {
89 open(CFG,$config_sh) || die "Cannot open $config_sh: $!\n";
91 if (/^(?:ccflags|optimize)='(.+)'$/) {
93 $define{$1} = 1 while /-D(\w+)/g;
95 if ($PLATFORM eq 'os2') {
96 $CONFIG_ARGS = $1 if /^(?:config_args)='(.+)'$/;
97 $ARCHNAME = $1 if /^(?:archname)='(.+)'$/;
103 open(CFG,$config_h) || die "Cannot open $config_h: $!\n";
105 $define{$1} = 1 if /^\s*#\s*define\s+(MYMALLOC)\b/;
106 $define{$1} = 1 if /^\s*#\s*define\s+(MULTIPLICITY)\b/;
107 $define{$1} = 1 if /^\s*#\s*define\s+(PERL_\w+)\b/;
108 $define{$1} = 1 if /^\s*#\s*define\s+(USE_\w+)\b/;
112 # perl.h logic duplication begins
114 if ($define{USE_ITHREADS}) {
115 if (!$define{MULTIPLICITY} && !$define{PERL_OBJECT}) {
116 $define{MULTIPLICITY} = 1;
120 $define{PERL_IMPLICIT_CONTEXT} ||=
121 $define{USE_ITHREADS} ||
122 $define{USE_5005THREADS} ||
123 $define{MULTIPLICITY} ;
125 if ($define{PERL_CAPI}) {
126 delete $define{PERL_OBJECT};
127 $define{MULTIPLICITY} = 1;
128 $define{PERL_IMPLICIT_CONTEXT} = 1;
129 $define{PERL_IMPLICIT_SYS} = 1;
132 if ($define{PERL_OBJECT}) {
133 $define{PERL_IMPLICIT_CONTEXT} = 1;
134 $define{PERL_IMPLICIT_SYS} = 1;
137 # perl.h logic duplication ends
139 if ($PLATFORM eq 'win32') {
140 warn join(' ',keys %define)."\n";
141 print "LIBRARY Perl57\n";
142 print "DESCRIPTION 'Perl interpreter'\n";
144 if ($define{PERL_IMPLICIT_SYS}) {
145 output_symbol("perl_get_host_info");
146 output_symbol("perl_alloc_override");
149 elsif ($PLATFORM eq 'os2') {
150 ($v = $]) =~ s/(\d\.\d\d\d)(\d\d)$/$1_$2/;
151 $v .= '-thread' if $ARCHNAME =~ /-thread/;
152 ($dll = $define{PERL_DLL}) =~ s/\.dll$//i;
154 LIBRARY '$dll' INITINSTANCE TERMINSTANCE
155 DESCRIPTION '\@#perl5-porters\@perl.org:$v#\@ Perl interpreter'
158 DATA LOADONCALL NONSHARED MULTIPLE
162 elsif ($PLATFORM eq 'aix') {
171 foreach my $symbol (@$list) {
178 foreach my $symbol (@$list) {
179 my $skipsym = $symbol;
181 if ($define{PERL_OBJECT} || $define{MULTIPLICITY}) {
182 $skipsym =~ s/^Perl_[GIT](\w+)_ptr$/PL_$1/;
184 emit_symbol($symbol) unless exists $skip{$skipsym};
188 if ($PLATFORM eq 'win32') {
213 Perl_init_thread_intern
238 elsif ($PLATFORM eq 'aix') {
257 Perl_sys_intern_clear
266 elsif ($PLATFORM eq 'os2') {
291 XS_Cwd_extLibpath_set
295 XS_Cwd_sys_is_absolute
296 XS_Cwd_sys_is_relative
298 XS_DynaLoader_mod2fname
299 XS_File__Copy_syscopy
303 Perl_Process_Messages
309 elsif ($PLATFORM eq 'MacOS') {
333 Perl_sys_intern_clear
339 unless ($define{'DEBUGGING'}) {
354 if ($define{'PERL_IMPLICIT_SYS'}) {
375 unless ($define{'PERL_FLEXIBLE_EXCEPTIONS'}) {
379 Perl_vdefault_protect
383 if ($define{'MYMALLOC'}) {
392 if ($define{'USE_5005THREADS'} || $define{'USE_ITHREADS'}) {
416 unless ($define{'USE_5005THREADS'} || $define{'USE_ITHREADS'}) {
422 unless ($define{'USE_5005THREADS'}) {
441 Perl_new_struct_thread
442 Perl_per_thread_magicals
451 unless ($define{'USE_ITHREADS'}) {
478 unless ($define{'PERL_IMPLICIT_CONTEXT'}) {
484 Perl_load_module_nocontext
487 Perl_warner_nocontext
488 Perl_newSVpvf_nocontext
489 Perl_sv_catpvf_nocontext
490 Perl_sv_setpvf_nocontext
491 Perl_sv_catpvf_mg_nocontext
492 Perl_sv_setpvf_mg_nocontext
496 unless ($define{'PERL_IMPLICIT_SYS'}) {
503 unless ($define{'FAKE_THREADS'}) {
504 skip_symbols [qw(PL_curthr)];
509 my $proc = shift || sub { "PL_$_[2]" };
510 open(VARS,$file) || die "Cannot open $file: $!\n";
513 # All symbols have a Perl_ prefix because that's what embed.h
514 # sticks in front of them.
515 push(@syms, &$proc($1,$2,$3)) if (/\bPERLVAR(A?I?C?)\(([IGT])(\w+)/);
521 if ($define{'USE_5005THREADS'}) {
522 my $thrd = readvar($thrdvar_h);
526 if ($define{'PERL_GLOBAL_STRUCT'}) {
527 my $global = readvar($perlvars_h);
528 skip_symbols $global;
529 emit_symbol('Perl_GetVars');
530 emit_symbols [qw(PL_Vars PL_VarsPtr)] unless $CCTYPE eq 'GCC';
533 # functions from *.sym files
535 my @syms = ($global_sym, $globvar_sym); # $pp_sym is not part of the API
537 if ($define{'USE_PERLIO'}) {
538 push @syms, $perlio_sym;
539 if ($define{'USE_SFIO'}) {
540 # SFIO defines most of the PerlIO routines as macros
587 for my $syms (@syms) {
588 open (GLOBAL, "<$syms") || die "failed to open $syms: $!\n";
590 next if (!/^[A-Za-z]/);
591 # Functions have a Perl_ prefix
592 # Variables have a PL_ prefix
594 my $symbol = ($syms =~ /var\.sym$/i ? "PL_" : "");
596 emit_symbol($symbol) unless exists $skip{$symbol};
603 if ($define{'PERL_OBJECT'} || $define{'MULTIPLICITY'}) {
604 for my $f ($perlvars_h, $intrpvar_h, $thrdvar_h) {
605 my $glob = readvar($f, sub { "Perl_" . $_[1] . $_[2] . "_ptr" });
608 # XXX AIX seems to want the perlvars.h symbols, for some reason
609 if ($PLATFORM eq 'aix') {
610 my $glob = readvar($perlvars_h);
615 unless ($define{'PERL_GLOBAL_STRUCT'}) {
616 my $glob = readvar($perlvars_h);
619 unless ($define{'MULTIPLICITY'}) {
620 my $glob = readvar($intrpvar_h);
623 unless ($define{'MULTIPLICITY'} || $define{'USE_5005THREADS'}) {
624 my $glob = readvar($thrdvar_h);
632 return if $symbol !~ /^[A-Za-z]/;
633 return if $symbol =~ /^\#/;
636 return if exists $skip{$symbol};
637 emit_symbol($symbol);
644 if ($PLATFORM eq 'win32') {
645 foreach my $symbol (qw(
705 win32_getprotobynumber
802 elsif ($PLATFORM eq 'os2') {
803 open MAP, 'miniperl.map' or die 'Cannot read miniperl.map';
804 /^\s*[\da-f:]+\s+(\w+)/i and $mapped{$1}++ foreach <MAP>;
805 close MAP or die 'Cannot close miniperl.map';
807 @missing = grep { !exists $mapped{$_} and !exists $bincompat5005{$_} }
809 delete $export{$_} foreach @missing;
811 elsif ($PLATFORM eq 'MacOS') {
812 open MACSYMS, 'macperl.sym' or die 'Cannot read macperl.sym';
821 # Now all symbols should be defined because
822 # next we are going to output them.
824 foreach my $symbol (sort keys %export) {
825 output_symbol($symbol);
831 $export{$symbol} = 1;
836 $symbol = $bincompat5005{$symbol}
837 if $define{PERL_BINCOMPAT_5005} and $symbol =~ /^($bincompat5005)$/;
838 if ($PLATFORM eq 'win32') {
839 $symbol = "_$symbol" if $CCTYPE eq 'BORLAND';
841 # XXX: binary compatibility between compilers is an exercise
843 # if ($CCTYPE eq "BORLAND") {
844 # # workaround Borland quirk by exporting both the straight
845 # # name and a name with leading underscore. Note the
846 # # alias *must* come after the symbol itself, if both
847 # # are to be exported. (Linker bug?)
848 # print "\t_$symbol\n";
849 # print "\t$symbol = _$symbol\n";
851 # elsif ($CCTYPE eq 'GCC') {
852 # # Symbols have leading _ whole process is $%@"% slow
853 # # so skip aliases for now
854 # nprint "\t$symbol\n";
857 # # for binary coexistence, export both the symbol and
858 # # alias with leading underscore
859 # print "\t$symbol\n";
860 # print "\t_$symbol = $symbol\n";
863 elsif ($PLATFORM eq 'os2') {
864 print qq( "$symbol"\n);
866 elsif ($PLATFORM eq 'aix' || $PLATFORM eq 'MacOS') {
873 # extra globals not included above.