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");
117 output_symbol("perl_clone_host");
120 elsif ($PLATFORM eq 'os2') {
121 if (open my $fh, '<', 'perl5.def') {
123 last if /^\s*EXPORTS\b/;
126 $ordinal{$1} = $2 if /^\s*"(\w+)"\s*\@(\d+)\s*$/;
127 # This allows skipping ordinals which were used in older versions
128 $sym_ord = $1 if /^\s*;\s*LAST_ORDINAL\s*=\s*(\d+)\s*$/;
130 $sym_ord < $_ and $sym_ord = $_ for values %ordinal; # Take the max
132 ($v = $]) =~ s/(\d\.\d\d\d)(\d\d)$/$1_$2/;
133 $v .= '-thread' if $ARCHNAME =~ /-thread/;
134 ($dll = $define{PERL_DLL}) =~ s/\.dll$//i;
135 $v .= "\@$PATCHLEVEL" if $PATCHLEVEL;
136 $d = "DESCRIPTION '\@#perl5-porters\@perl.org:$v#\@ Perl interpreter, configured as $CONFIG_ARGS'";
137 $d = substr($d, 0, 249) . "...'" if length $d > 253;
139 LIBRARY '$dll' INITINSTANCE TERMINSTANCE
143 DATA LOADONCALL NONSHARED MULTIPLE
147 elsif ($PLATFORM eq 'aix') {
152 if ($OSVER > 4 || ($OSVER == 4 && $OSREL >= 3)) {
158 elsif ($PLATFORM eq 'netware') {
159 if ($FILETYPE eq 'def') {
160 print "LIBRARY perl58\n";
161 print "DESCRIPTION 'Perl interpreter for NetWare'\n";
164 if ($define{PERL_IMPLICIT_SYS}) {
165 output_symbol("perl_get_host_info");
166 output_symbol("perl_alloc_override");
167 output_symbol("perl_clone_host");
176 foreach my $symbol (@$list) {
183 foreach my $symbol (@$list) {
184 my $skipsym = $symbol;
186 if ($define{MULTIPLICITY}) {
187 $skipsym =~ s/^Perl_[GIT](\w+)_ptr$/PL_$1/;
189 emit_symbol($symbol) unless exists $skip{$skipsym};
193 if ($PLATFORM eq 'win32') {
218 Perl_init_thread_intern
244 elsif ($PLATFORM eq 'aix') {
263 Perl_sys_intern_clear
272 elsif ($PLATFORM eq 'os2') {
309 XS_Cwd_extLibpath_set
313 XS_Cwd_sys_is_absolute
314 XS_Cwd_sys_is_relative
316 XS_DynaLoader_mod2fname
317 XS_File__Copy_syscopy
321 Perl_Process_Messages
332 elsif ($PLATFORM eq 'MacOS') {
356 Perl_sys_intern_clear
360 elsif ($PLATFORM eq 'netware') {
385 Perl_init_thread_intern
410 Perl_sys_intern_clear
418 Perl_PerlIO_setlinebuf
419 Perl_PerlIO_set_ptrcnt
425 Perl_PerlIO_get_bufsiz
438 unless ($define{'DEBUGGING'}) {
452 if ($define{'PERL_IMPLICIT_SYS'}) {
473 unless ($define{'PERL_FLEXIBLE_EXCEPTIONS'}) {
477 Perl_vdefault_protect
481 unless ($define{'USE_REENTRANT_API'}) {
487 if ($define{'MYMALLOC'}) {
494 if ($define{'USE_5005THREADS'} || $define{'USE_ITHREADS'}) {
514 unless ($define{'USE_5005THREADS'} || $define{'USE_ITHREADS'}) {
520 unless ($define{'USE_5005THREADS'}) {
539 Perl_new_struct_thread
540 Perl_per_thread_magicals
549 unless ($define{'USE_ITHREADS'}) {
556 PL_sharedsv_space_mutex
583 Perl_sharedsv_thrcnt_dec
584 Perl_sharedsv_thrcnt_inc
589 unless ($define{'PERL_IMPLICIT_CONTEXT'}) {
595 Perl_load_module_nocontext
598 Perl_warner_nocontext
599 Perl_newSVpvf_nocontext
600 Perl_sv_catpvf_nocontext
601 Perl_sv_setpvf_nocontext
602 Perl_sv_catpvf_mg_nocontext
603 Perl_sv_setpvf_mg_nocontext
607 unless ($define{'PERL_IMPLICIT_SYS'}) {
614 unless ($define{'FAKE_THREADS'}) {
615 skip_symbols [qw(PL_curthr)];
618 unless ($define{'PL_OP_SLAB_ALLOC'}) {
628 my $proc = shift || sub { "PL_$_[2]" };
629 open(VARS,$file) || die "Cannot open $file: $!\n";
632 # All symbols have a Perl_ prefix because that's what embed.h
633 # sticks in front of them.
634 push(@syms, &$proc($1,$2,$3)) if (/\bPERLVAR(A?I?C?)\(([IGT])(\w+)/);
640 if ($define{'USE_5005THREADS'}) {
641 my $thrd = readvar($thrdvar_h);
645 if ($define{'PERL_GLOBAL_STRUCT'}) {
646 my $global = readvar($perlvars_h);
647 skip_symbols $global;
648 emit_symbol('Perl_GetVars');
649 emit_symbols [qw(PL_Vars PL_VarsPtr)] unless $CCTYPE eq 'GCC';
652 # functions from *.sym files
654 my @syms = ($global_sym, $globvar_sym); # $pp_sym is not part of the API
656 # Symbols that are the public face of the PerlIO layers implementation
657 # These are in _addition to_ the public face of the abstraction
658 # and need to be exported to allow XS modules to implement layers
668 PerlIOBase_setlinebuf
707 Perl_PerlIO_get_bufsiz
713 Perl_PerlIO_set_ptrcnt
714 Perl_PerlIO_setlinebuf
725 if ($define{'USE_PERLIO'}) {
726 # Export the symols that make up the PerlIO abstraction, regardless
727 # of its implementation - read from a file
728 push @syms, $perlio_sym;
730 # This part is then dependent on how the abstraction is implemented
731 if ($define{'USE_SFIO'}) {
732 # Old legacy non-stdio "PerlIO"
733 skip_symbols \@layer_syms;
734 # SFIO defines most of the PerlIO routines as macros
735 # So undo most of what $perlio_sym has just done - d'oh !
736 # Perhaps it would be better to list the ones which do exist
789 Perl_PerlIO_get_bufsiz
795 Perl_PerlIO_set_ptrcnt
796 Perl_PerlIO_setlinebuf
806 # PerlIO with layers - export implementation
807 emit_symbols \@layer_syms;
811 # Skip the PerlIO layer symbols - although
812 # nothing should have exported them any way
813 skip_symbols \@layer_syms;
814 skip_symbols [qw(PL_def_layerlist PL_known_layers PL_perlio)];
816 # Also do NOT add abstraction symbols from $perlio_sym
817 # abstraction is done as #define to stdio
818 # Remaining remnants that _may_ be functions
819 # are handled in <DATA>
822 for my $syms (@syms) {
823 open (GLOBAL, "<$syms") || die "failed to open $syms: $!\n";
825 next if (!/^[A-Za-z]/);
826 # Functions have a Perl_ prefix
827 # Variables have a PL_ prefix
829 my $symbol = ($syms =~ /var\.sym$/i ? "PL_" : "");
831 emit_symbol($symbol) unless exists $skip{$symbol};
838 if ($define{'MULTIPLICITY'}) {
839 for my $f ($perlvars_h, $intrpvar_h, $thrdvar_h) {
840 my $glob = readvar($f, sub { "Perl_" . $_[1] . $_[2] . "_ptr" });
843 # XXX AIX seems to want the perlvars.h symbols, for some reason
844 if ($PLATFORM eq 'aix') {
845 my $glob = readvar($perlvars_h);
850 unless ($define{'PERL_GLOBAL_STRUCT'}) {
851 my $glob = readvar($perlvars_h);
854 unless ($define{'MULTIPLICITY'}) {
855 my $glob = readvar($intrpvar_h);
858 unless ($define{'MULTIPLICITY'} || $define{'USE_5005THREADS'}) {
859 my $glob = readvar($thrdvar_h);
867 return if $symbol !~ /^[A-Za-z_]/;
868 return if $symbol =~ /^\#/;
871 return if exists $skip{$symbol};
872 emit_symbol($symbol);
879 if ($PLATFORM eq 'win32') {
880 foreach my $symbol (qw(
941 win32_getprotobynumber
1039 try_symbol($symbol);
1042 elsif ($PLATFORM eq 'os2') {
1043 open MAP, 'miniperl.map' or die 'Cannot read miniperl.map';
1044 /^\s*[\da-f:]+\s+(\w+)/i and $mapped{$1}++ foreach <MAP>;
1045 close MAP or die 'Cannot close miniperl.map';
1047 @missing = grep { !exists $mapped{$_} }
1049 delete $export{$_} foreach @missing;
1051 elsif ($PLATFORM eq 'MacOS') {
1052 open MACSYMS, 'macperl.sym' or die 'Cannot read macperl.sym';
1060 elsif ($PLATFORM eq 'netware') {
1061 foreach my $symbol (qw(
1188 fnInsertHashListAddrs
1197 try_symbol($symbol);
1201 # Now all symbols should be defined because
1202 # next we are going to output them.
1204 foreach my $symbol (sort keys %export) {
1205 output_symbol($symbol);
1208 if ($PLATFORM eq 'os2') {
1209 print "; LAST_ORDINAL=$sym_ord\n";
1215 $export{$symbol} = 1;
1220 if ($PLATFORM eq 'win32') {
1221 $symbol = "_$symbol" if $CCTYPE eq 'BORLAND';
1222 print "\t$symbol\n";
1223 # XXX: binary compatibility between compilers is an exercise
1224 # in frustration :-(
1225 # if ($CCTYPE eq "BORLAND") {
1226 # # workaround Borland quirk by exporting both the straight
1227 # # name and a name with leading underscore. Note the
1228 # # alias *must* come after the symbol itself, if both
1229 # # are to be exported. (Linker bug?)
1230 # print "\t_$symbol\n";
1231 # print "\t$symbol = _$symbol\n";
1233 # elsif ($CCTYPE eq 'GCC') {
1234 # # Symbols have leading _ whole process is $%@"% slow
1235 # # so skip aliases for now
1236 # nprint "\t$symbol\n";
1239 # # for binary coexistence, export both the symbol and
1240 # # alias with leading underscore
1241 # print "\t$symbol\n";
1242 # print "\t_$symbol = $symbol\n";
1245 elsif ($PLATFORM eq 'os2') {
1246 printf qq( %-31s \@%s\n),
1247 qq("$symbol"), $ordinal{$symbol} || ++$sym_ord;
1249 elsif ($PLATFORM eq 'aix' || $PLATFORM eq 'MacOS') {
1252 elsif ($PLATFORM eq 'netware') {
1253 print "\t$symbol,\n";
1259 # extra globals not included above.
1270 # Oddities from PerlIO