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,
6 # and by MacOS Classic.
8 # reads global.sym, pp.sym, perlvars.h, intrpvar.h, thrdvar.h, config.h
9 # On OS/2 reads miniperl.map as well
16 $define{$1} = 1 if ($flag =~ /^-D(\w+)$/);
17 $define{$1} = $2 if ($flag =~ /^-D(\w+)=(.+)$/);
18 $CCTYPE = $1 if ($flag =~ /^CCTYPE=(\w+)$/);
19 $PLATFORM = $1 if ($flag =~ /^PLATFORM=(\w+)$/);
20 if ($PLATFORM eq 'netware') {
21 $FILETYPE = $1 if ($flag =~ /^FILETYPE=(\w+)$/);
25 my @PLATFORM = qw(aix win32 os2 MacOS netware);
27 @PLATFORM{@PLATFORM} = ();
29 defined $PLATFORM || die "PLATFORM undefined, must be one of: @PLATFORM\n";
30 exists $PLATFORM{$PLATFORM} || die "PLATFORM must be one of: @PLATFORM\n";
32 my $config_sh = "config.sh";
33 my $config_h = "config.h";
34 my $thrdvar_h = "thrdvar.h";
35 my $intrpvar_h = "intrpvar.h";
36 my $perlvars_h = "perlvars.h";
37 my $global_sym = "global.sym";
38 my $pp_sym = "pp.sym";
39 my $globvar_sym = "globvar.sym";
40 my $perlio_sym = "perlio.sym";
42 if ($PLATFORM eq 'aix') {
45 elsif ($PLATFORM eq 'win32' || $PLATFORM eq 'netware') {
46 $CCTYPE = "MSVC" unless defined $CCTYPE;
47 foreach ($thrdvar_h, $intrpvar_h, $perlvars_h, $global_sym,
48 $pp_sym, $globvar_sym, $perlio_sym) {
52 elsif ($PLATFORM eq 'MacOS') {
53 foreach ($thrdvar_h, $intrpvar_h, $perlvars_h, $global_sym,
54 $pp_sym, $globvar_sym, $perlio_sym) {
59 unless ($PLATFORM eq 'win32' || $PLATFORM eq 'MacOS' || $PLATFORM eq 'netware') {
60 open(CFG,$config_sh) || die "Cannot open $config_sh: $!\n";
62 if (/^(?:ccflags|optimize)='(.+)'$/) {
64 $define{$1} = 1 while /-D(\w+)/g;
66 if ($PLATFORM eq 'os2') {
67 $CONFIG_ARGS = $1 if /^config_args='(.+)'$/;
68 $ARCHNAME = $1 if /^archname='(.+)'$/;
69 $PATCHLEVEL = $1 if /^perl_patchlevel='(.+)'$/;
75 open(CFG,$config_h) || die "Cannot open $config_h: $!\n";
77 $define{$1} = 1 if /^\s*#\s*define\s+(MYMALLOC)\b/;
78 $define{$1} = 1 if /^\s*#\s*define\s+(MULTIPLICITY)\b/;
79 $define{$1} = 1 if /^\s*#\s*define\s+(PERL_\w+)\b/;
80 $define{$1} = 1 if /^\s*#\s*define\s+(USE_\w+)\b/;
84 # perl.h logic duplication begins
86 if ($define{PERL_IMPLICIT_SYS}) {
87 $define{PL_OP_SLAB_ALLOC} = 1;
90 if ($define{USE_ITHREADS}) {
91 if (!$define{MULTIPLICITY}) {
92 $define{MULTIPLICITY} = 1;
96 $define{PERL_IMPLICIT_CONTEXT} ||=
97 $define{USE_ITHREADS} ||
98 $define{USE_5005THREADS} ||
99 $define{MULTIPLICITY} ;
101 if ($define{USE_ITHREADS} && $PLATFORM ne 'win32' && $^O ne 'darwin') {
102 $define{USE_REENTRANT_API} = 1;
105 # perl.h logic duplication ends
109 if ($PLATFORM eq 'win32') {
110 warn join(' ',keys %define)."\n";
111 print "LIBRARY perl58\n";
112 print "DESCRIPTION 'Perl interpreter'\n";
114 if ($define{PERL_IMPLICIT_SYS}) {
115 output_symbol("perl_get_host_info");
116 output_symbol("perl_alloc_override");
118 if ($define{USE_ITHREADS}) {
119 output_symbol("perl_clone_host");
122 elsif ($PLATFORM eq 'os2') {
123 if (open my $fh, '<', 'perl5.def') {
125 last if /^\s*EXPORTS\b/;
128 $ordinal{$1} = $2 if /^\s*"(\w+)"\s*\@(\d+)\s*$/;
129 # This allows skipping ordinals which were used in older versions
130 $sym_ord = $1 if /^\s*;\s*LAST_ORDINAL\s*=\s*(\d+)\s*$/;
132 $sym_ord < $_ and $sym_ord = $_ for values %ordinal; # Take the max
134 ($v = $]) =~ s/(\d\.\d\d\d)(\d\d)$/$1_$2/;
135 $v .= '-thread' if $ARCHNAME =~ /-thread/;
136 ($dll = $define{PERL_DLL}) =~ s/\.dll$//i;
137 $v .= "\@$PATCHLEVEL" if $PATCHLEVEL;
138 $d = "DESCRIPTION '\@#perl5-porters\@perl.org:$v#\@ Perl interpreter, configured as $CONFIG_ARGS'";
139 $d = substr($d, 0, 249) . "...'" if length $d > 253;
141 LIBRARY '$dll' INITINSTANCE TERMINSTANCE
145 DATA LOADONCALL NONSHARED MULTIPLE
149 elsif ($PLATFORM eq 'aix') {
154 if ($OSVER > 4 || ($OSVER == 4 && $OSREL >= 3)) {
160 elsif ($PLATFORM eq 'netware') {
161 if ($FILETYPE eq 'def') {
162 print "LIBRARY perl58\n";
163 print "DESCRIPTION 'Perl interpreter for NetWare'\n";
166 if ($define{PERL_IMPLICIT_SYS}) {
167 output_symbol("perl_get_host_info");
168 output_symbol("perl_alloc_override");
169 output_symbol("perl_clone_host");
178 foreach my $symbol (@$list) {
185 foreach my $symbol (@$list) {
186 my $skipsym = $symbol;
188 if ($define{MULTIPLICITY}) {
189 $skipsym =~ s/^Perl_[GIT](\w+)_ptr$/PL_$1/;
191 emit_symbol($symbol) unless exists $skip{$skipsym};
195 if ($PLATFORM eq 'win32') {
220 Perl_init_thread_intern
246 elsif ($PLATFORM eq 'aix') {
265 Perl_sys_intern_clear
274 elsif ($PLATFORM eq 'os2') {
311 XS_Cwd_extLibpath_set
315 XS_Cwd_sys_is_absolute
316 XS_Cwd_sys_is_relative
318 XS_DynaLoader_mod2fname
319 XS_File__Copy_syscopy
323 Perl_Process_Messages
334 elsif ($PLATFORM eq 'MacOS') {
358 Perl_sys_intern_clear
362 elsif ($PLATFORM eq 'netware') {
387 Perl_init_thread_intern
412 Perl_sys_intern_clear
420 Perl_PerlIO_setlinebuf
421 Perl_PerlIO_set_ptrcnt
427 Perl_PerlIO_get_bufsiz
440 unless ($define{'DEBUGGING'}) {
454 if ($define{'PERL_IMPLICIT_SYS'}) {
475 unless ($define{'PERL_FLEXIBLE_EXCEPTIONS'}) {
479 Perl_vdefault_protect
483 unless ($define{'USE_REENTRANT_API'}) {
489 if ($define{'MYMALLOC'}) {
496 if ($define{'USE_5005THREADS'} || $define{'USE_ITHREADS'}) {
516 unless ($define{'USE_5005THREADS'} || $define{'USE_ITHREADS'}) {
522 unless ($define{'USE_5005THREADS'}) {
541 Perl_new_struct_thread
542 Perl_per_thread_magicals
551 unless ($define{'USE_ITHREADS'}) {
558 PL_sharedsv_space_mutex
585 Perl_sharedsv_thrcnt_dec
586 Perl_sharedsv_thrcnt_inc
591 unless ($define{'PERL_IMPLICIT_CONTEXT'}) {
597 Perl_load_module_nocontext
600 Perl_warner_nocontext
601 Perl_newSVpvf_nocontext
602 Perl_sv_catpvf_nocontext
603 Perl_sv_setpvf_nocontext
604 Perl_sv_catpvf_mg_nocontext
605 Perl_sv_setpvf_mg_nocontext
609 unless ($define{'PERL_IMPLICIT_SYS'}) {
616 unless ($define{'FAKE_THREADS'}) {
617 skip_symbols [qw(PL_curthr)];
620 unless ($define{'PL_OP_SLAB_ALLOC'}) {
630 my $proc = shift || sub { "PL_$_[2]" };
631 open(VARS,$file) || die "Cannot open $file: $!\n";
634 # All symbols have a Perl_ prefix because that's what embed.h
635 # sticks in front of them.
636 push(@syms, &$proc($1,$2,$3)) if (/\bPERLVAR(A?I?C?)\(([IGT])(\w+)/);
642 if ($define{'USE_5005THREADS'}) {
643 my $thrd = readvar($thrdvar_h);
647 if ($define{'PERL_GLOBAL_STRUCT'}) {
648 my $global = readvar($perlvars_h);
649 skip_symbols $global;
650 emit_symbol('Perl_GetVars');
651 emit_symbols [qw(PL_Vars PL_VarsPtr)] unless $CCTYPE eq 'GCC';
654 # functions from *.sym files
656 my @syms = ($global_sym, $globvar_sym); # $pp_sym is not part of the API
658 # Symbols that are the public face of the PerlIO layers implementation
659 # These are in _addition to_ the public face of the abstraction
660 # and need to be exported to allow XS modules to implement layers
670 PerlIOBase_setlinebuf
709 Perl_PerlIO_get_bufsiz
715 Perl_PerlIO_set_ptrcnt
716 Perl_PerlIO_setlinebuf
725 if ($PLATFORM eq 'netware') {
726 push(@layer_syms,'PL_def_layerlist','PL_known_layers','PL_perlio');
729 if ($define{'USE_PERLIO'}) {
730 # Export the symols that make up the PerlIO abstraction, regardless
731 # of its implementation - read from a file
732 push @syms, $perlio_sym;
734 # This part is then dependent on how the abstraction is implemented
735 if ($define{'USE_SFIO'}) {
736 # Old legacy non-stdio "PerlIO"
737 skip_symbols \@layer_syms;
738 # SFIO defines most of the PerlIO routines as macros
739 # So undo most of what $perlio_sym has just done - d'oh !
740 # Perhaps it would be better to list the ones which do exist
793 Perl_PerlIO_get_bufsiz
799 Perl_PerlIO_set_ptrcnt
800 Perl_PerlIO_setlinebuf
810 # PerlIO with layers - export implementation
811 emit_symbols \@layer_syms;
815 # Skip the PerlIO layer symbols - although
816 # nothing should have exported them any way
817 skip_symbols \@layer_syms;
818 skip_symbols [qw(PL_def_layerlist PL_known_layers PL_perlio)];
820 # Also do NOT add abstraction symbols from $perlio_sym
821 # abstraction is done as #define to stdio
822 # Remaining remnants that _may_ be functions
823 # are handled in <DATA>
826 for my $syms (@syms) {
827 open (GLOBAL, "<$syms") || die "failed to open $syms: $!\n";
829 next if (!/^[A-Za-z]/);
830 # Functions have a Perl_ prefix
831 # Variables have a PL_ prefix
833 my $symbol = ($syms =~ /var\.sym$/i ? "PL_" : "");
835 emit_symbol($symbol) unless exists $skip{$symbol};
842 if ($define{'MULTIPLICITY'}) {
843 for my $f ($perlvars_h, $intrpvar_h, $thrdvar_h) {
844 my $glob = readvar($f, sub { "Perl_" . $_[1] . $_[2] . "_ptr" });
847 # XXX AIX seems to want the perlvars.h symbols, for some reason
848 if ($PLATFORM eq 'aix') {
849 my $glob = readvar($perlvars_h);
854 unless ($define{'PERL_GLOBAL_STRUCT'}) {
855 my $glob = readvar($perlvars_h);
858 unless ($define{'MULTIPLICITY'}) {
859 my $glob = readvar($intrpvar_h);
862 unless ($define{'MULTIPLICITY'} || $define{'USE_5005THREADS'}) {
863 my $glob = readvar($thrdvar_h);
871 return if $symbol !~ /^[A-Za-z_]/;
872 return if $symbol =~ /^\#/;
875 return if exists $skip{$symbol};
876 emit_symbol($symbol);
883 if ($PLATFORM eq 'win32') {
884 foreach my $symbol (qw(
945 win32_getprotobynumber
1043 try_symbol($symbol);
1046 elsif ($PLATFORM eq 'os2') {
1047 open MAP, 'miniperl.map' or die 'Cannot read miniperl.map';
1048 /^\s*[\da-f:]+\s+(\w+)/i and $mapped{$1}++ foreach <MAP>;
1049 close MAP or die 'Cannot close miniperl.map';
1051 @missing = grep { !exists $mapped{$_} }
1053 delete $export{$_} foreach @missing;
1055 elsif ($PLATFORM eq 'MacOS') {
1056 open MACSYMS, 'macperl.sym' or die 'Cannot read macperl.sym';
1064 elsif ($PLATFORM eq 'netware') {
1065 foreach my $symbol (qw(
1192 fnInsertHashListAddrs
1201 try_symbol($symbol);
1205 # Now all symbols should be defined because
1206 # next we are going to output them.
1208 foreach my $symbol (sort keys %export) {
1209 output_symbol($symbol);
1212 if ($PLATFORM eq 'os2') {
1213 print "; LAST_ORDINAL=$sym_ord\n";
1219 $export{$symbol} = 1;
1224 if ($PLATFORM eq 'win32') {
1225 $symbol = "_$symbol" if $CCTYPE eq 'BORLAND';
1226 print "\t$symbol\n";
1227 # XXX: binary compatibility between compilers is an exercise
1228 # in frustration :-(
1229 # if ($CCTYPE eq "BORLAND") {
1230 # # workaround Borland quirk by exporting both the straight
1231 # # name and a name with leading underscore. Note the
1232 # # alias *must* come after the symbol itself, if both
1233 # # are to be exported. (Linker bug?)
1234 # print "\t_$symbol\n";
1235 # print "\t$symbol = _$symbol\n";
1237 # elsif ($CCTYPE eq 'GCC') {
1238 # # Symbols have leading _ whole process is $%@"% slow
1239 # # so skip aliases for now
1240 # nprint "\t$symbol\n";
1243 # # for binary coexistence, export both the symbol and
1244 # # alias with leading underscore
1245 # print "\t$symbol\n";
1246 # print "\t_$symbol = $symbol\n";
1249 elsif ($PLATFORM eq 'os2') {
1250 printf qq( %-31s \@%s\n),
1251 qq("$symbol"), $ordinal{$symbol} || ++$sym_ord;
1253 elsif ($PLATFORM eq 'aix' || $PLATFORM eq 'MacOS') {
1256 elsif ($PLATFORM eq 'netware') {
1257 print "\t$symbol,\n";
1263 # extra globals not included above.
1274 # Oddities from PerlIO