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 wince 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 =~ /^win(?:32|ce)$/ || $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 'wince' || $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 =~ /^win(?:32|ce)$/) {
110 warn join(' ',keys %define)."\n";
111 ($dll = ($define{PERL_DLL} || "perl58")) =~ s/\.dll$//i;
112 print "LIBRARY $dll\n";
113 print "DESCRIPTION 'Perl interpreter'\n";
115 if ($define{PERL_IMPLICIT_SYS}) {
116 output_symbol("perl_get_host_info");
117 output_symbol("perl_alloc_override");
119 if ($define{USE_ITHREADS} and $define{PERL_IMPLICIT_SYS}) {
120 output_symbol("perl_clone_host");
123 elsif ($PLATFORM eq 'os2') {
124 if (open my $fh, '<', 'perl5.def') {
126 last if /^\s*EXPORTS\b/;
129 $ordinal{$1} = $2 if /^\s*"(\w+)"\s*\@(\d+)\s*$/;
130 # This allows skipping ordinals which were used in older versions
131 $sym_ord = $1 if /^\s*;\s*LAST_ORDINAL\s*=\s*(\d+)\s*$/;
133 $sym_ord < $_ and $sym_ord = $_ for values %ordinal; # Take the max
135 ($v = $]) =~ s/(\d\.\d\d\d)(\d\d)$/$1_$2/;
136 $v .= '-thread' if $ARCHNAME =~ /-thread/;
137 ($dll = $define{PERL_DLL}) =~ s/\.dll$//i;
138 $v .= "\@$PATCHLEVEL" if $PATCHLEVEL;
139 $d = "DESCRIPTION '\@#perl5-porters\@perl.org:$v#\@ Perl interpreter, configured as $CONFIG_ARGS'";
140 $d = substr($d, 0, 249) . "...'" if length $d > 253;
142 LIBRARY '$dll' INITINSTANCE TERMINSTANCE
146 DATA LOADONCALL NONSHARED MULTIPLE
150 elsif ($PLATFORM eq 'aix') {
155 if ($OSVER > 4 || ($OSVER == 4 && $OSREL >= 3)) {
161 elsif ($PLATFORM eq 'netware') {
162 if ($FILETYPE eq 'def') {
163 print "LIBRARY perl58\n";
164 print "DESCRIPTION 'Perl interpreter for NetWare'\n";
167 if ($define{PERL_IMPLICIT_SYS}) {
168 output_symbol("perl_get_host_info");
169 output_symbol("perl_alloc_override");
170 output_symbol("perl_clone_host");
179 foreach my $symbol (@$list) {
186 foreach my $symbol (@$list) {
187 my $skipsym = $symbol;
189 if ($define{MULTIPLICITY}) {
190 $skipsym =~ s/^Perl_[GIT](\w+)_ptr$/PL_$1/;
192 emit_symbol($symbol) unless exists $skip{$skipsym};
196 if ($PLATFORM eq 'win32') {
221 Perl_init_thread_intern
247 elsif ($PLATFORM eq 'wince') {
263 PL_collation_standard
292 Perl_init_thread_intern
318 elsif ($PLATFORM eq 'aix') {
337 Perl_sys_intern_clear
346 elsif ($PLATFORM eq 'os2') {
383 XS_Cwd_extLibpath_set
387 XS_Cwd_sys_is_absolute
388 XS_Cwd_sys_is_relative
390 XS_DynaLoader_mod2fname
391 XS_File__Copy_syscopy
395 Perl_Process_Messages
406 elsif ($PLATFORM eq 'MacOS') {
430 Perl_sys_intern_clear
434 elsif ($PLATFORM eq 'netware') {
459 Perl_init_thread_intern
484 Perl_sys_intern_clear
492 Perl_PerlIO_setlinebuf
493 Perl_PerlIO_set_ptrcnt
499 Perl_PerlIO_get_bufsiz
512 unless ($define{'DEBUGGING'}) {
526 if ($define{'PERL_IMPLICIT_SYS'}) {
547 unless ($define{'PERL_FLEXIBLE_EXCEPTIONS'}) {
551 Perl_vdefault_protect
555 unless ($define{'USE_REENTRANT_API'}) {
561 if ($define{'MYMALLOC'}) {
568 if ($define{'USE_5005THREADS'} || $define{'USE_ITHREADS'}) {
588 unless ($define{'USE_5005THREADS'} || $define{'USE_ITHREADS'}) {
594 unless ($define{'USE_5005THREADS'}) {
613 Perl_new_struct_thread
614 Perl_per_thread_magicals
623 unless ($define{'USE_ITHREADS'}) {
630 PL_sharedsv_space_mutex
657 Perl_sharedsv_thrcnt_dec
658 Perl_sharedsv_thrcnt_inc
663 unless ($define{'PERL_IMPLICIT_CONTEXT'}) {
669 Perl_load_module_nocontext
672 Perl_warner_nocontext
673 Perl_newSVpvf_nocontext
674 Perl_sv_catpvf_nocontext
675 Perl_sv_setpvf_nocontext
676 Perl_sv_catpvf_mg_nocontext
677 Perl_sv_setpvf_mg_nocontext
681 unless ($define{'PERL_IMPLICIT_SYS'}) {
688 unless ($define{'FAKE_THREADS'}) {
689 skip_symbols [qw(PL_curthr)];
692 unless ($define{'PL_OP_SLAB_ALLOC'}) {
702 my $proc = shift || sub { "PL_$_[2]" };
703 open(VARS,$file) || die "Cannot open $file: $!\n";
706 # All symbols have a Perl_ prefix because that's what embed.h
707 # sticks in front of them.
708 push(@syms, &$proc($1,$2,$3)) if (/\bPERLVAR(A?I?C?)\(([IGT])(\w+)/);
714 if ($define{'USE_5005THREADS'}) {
715 my $thrd = readvar($thrdvar_h);
719 if ($define{'PERL_GLOBAL_STRUCT'}) {
720 my $global = readvar($perlvars_h);
721 skip_symbols $global;
722 emit_symbol('Perl_GetVars');
723 emit_symbols [qw(PL_Vars PL_VarsPtr)] unless $CCTYPE eq 'GCC';
726 # functions from *.sym files
728 my @syms = ($global_sym, $globvar_sym); # $pp_sym is not part of the API
730 # Symbols that are the public face of the PerlIO layers implementation
731 # These are in _addition to_ the public face of the abstraction
732 # and need to be exported to allow XS modules to implement layers
744 PerlIOBase_setlinebuf
786 Perl_PerlIO_get_bufsiz
792 Perl_PerlIO_set_ptrcnt
793 Perl_PerlIO_setlinebuf
802 if ($PLATFORM eq 'netware') {
803 push(@layer_syms,'PL_def_layerlist','PL_known_layers','PL_perlio');
806 if ($define{'USE_PERLIO'}) {
807 # Export the symols that make up the PerlIO abstraction, regardless
808 # of its implementation - read from a file
809 push @syms, $perlio_sym;
811 # This part is then dependent on how the abstraction is implemented
812 if ($define{'USE_SFIO'}) {
813 # Old legacy non-stdio "PerlIO"
814 skip_symbols \@layer_syms;
815 # SFIO defines most of the PerlIO routines as macros
816 # So undo most of what $perlio_sym has just done - d'oh !
817 # Perhaps it would be better to list the ones which do exist
870 Perl_PerlIO_get_bufsiz
876 Perl_PerlIO_set_ptrcnt
877 Perl_PerlIO_setlinebuf
890 # PerlIO with layers - export implementation
891 emit_symbols \@layer_syms;
895 # Skip the PerlIO layer symbols - although
896 # nothing should have exported them any way
897 skip_symbols \@layer_syms;
898 skip_symbols [qw(PL_def_layerlist PL_known_layers PL_perlio)];
900 # Also do NOT add abstraction symbols from $perlio_sym
901 # abstraction is done as #define to stdio
902 # Remaining remnants that _may_ be functions
903 # are handled in <DATA>
906 for my $syms (@syms) {
907 open (GLOBAL, "<$syms") || die "failed to open $syms: $!\n";
909 next if (!/^[A-Za-z]/);
910 # Functions have a Perl_ prefix
911 # Variables have a PL_ prefix
913 my $symbol = ($syms =~ /var\.sym$/i ? "PL_" : "");
915 emit_symbol($symbol) unless exists $skip{$symbol};
922 if ($define{'MULTIPLICITY'}) {
923 for my $f ($perlvars_h, $intrpvar_h, $thrdvar_h) {
924 my $glob = readvar($f, sub { "Perl_" . $_[1] . $_[2] . "_ptr" });
927 # XXX AIX seems to want the perlvars.h symbols, for some reason
928 if ($PLATFORM eq 'aix') {
929 my $glob = readvar($perlvars_h);
934 unless ($define{'PERL_GLOBAL_STRUCT'}) {
935 my $glob = readvar($perlvars_h);
938 unless ($define{'MULTIPLICITY'}) {
939 my $glob = readvar($intrpvar_h);
942 unless ($define{'MULTIPLICITY'} || $define{'USE_5005THREADS'}) {
943 my $glob = readvar($thrdvar_h);
951 return if $symbol !~ /^[A-Za-z_]/;
952 return if $symbol =~ /^\#/;
955 return if exists $skip{$symbol};
956 emit_symbol($symbol);
963 if ($PLATFORM =~ /^win(?:32|ce)$/) {
964 foreach my $symbol (qw(
1024 win32_getprotobyname
1025 win32_getprotobynumber
1054 win32_open_osfhandle
1124 try_symbol($symbol);
1127 elsif ($PLATFORM eq 'os2') {
1128 open MAP, 'miniperl.map' or die 'Cannot read miniperl.map';
1129 /^\s*[\da-f:]+\s+(\w+)/i and $mapped{$1}++ foreach <MAP>;
1130 close MAP or die 'Cannot close miniperl.map';
1132 @missing = grep { !exists $mapped{$_} }
1134 delete $export{$_} foreach @missing;
1136 elsif ($PLATFORM eq 'MacOS') {
1137 open MACSYMS, 'macperl.sym' or die 'Cannot read macperl.sym';
1145 elsif ($PLATFORM eq 'netware') {
1146 foreach my $symbol (qw(
1273 fnInsertHashListAddrs
1284 try_symbol($symbol);
1288 # Now all symbols should be defined because
1289 # next we are going to output them.
1291 foreach my $symbol (sort keys %export) {
1292 output_symbol($symbol);
1295 if ($PLATFORM eq 'os2') {
1296 print "; LAST_ORDINAL=$sym_ord\n";
1302 $export{$symbol} = 1;
1307 if ($PLATFORM =~ /^win(?:32|ce)$/) {
1308 $symbol = "_$symbol" if $CCTYPE eq 'BORLAND';
1309 print "\t$symbol\n";
1310 # XXX: binary compatibility between compilers is an exercise
1311 # in frustration :-(
1312 # if ($CCTYPE eq "BORLAND") {
1313 # # workaround Borland quirk by exporting both the straight
1314 # # name and a name with leading underscore. Note the
1315 # # alias *must* come after the symbol itself, if both
1316 # # are to be exported. (Linker bug?)
1317 # print "\t_$symbol\n";
1318 # print "\t$symbol = _$symbol\n";
1320 # elsif ($CCTYPE eq 'GCC') {
1321 # # Symbols have leading _ whole process is $%@"% slow
1322 # # so skip aliases for now
1323 # nprint "\t$symbol\n";
1326 # # for binary coexistence, export both the symbol and
1327 # # alias with leading underscore
1328 # print "\t$symbol\n";
1329 # print "\t_$symbol = $symbol\n";
1332 elsif ($PLATFORM eq 'os2') {
1333 printf qq( %-31s \@%s\n),
1334 qq("$symbol"), $ordinal{$symbol} || ++$sym_ord;
1336 elsif ($PLATFORM eq 'aix' || $PLATFORM eq 'MacOS') {
1339 elsif ($PLATFORM eq 'netware') {
1340 print "\t$symbol,\n";
1346 # extra globals not included above.
1357 # Oddities from PerlIO