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 and the previous version of perl5.def as well
16 if ($flag =~ s/^CC_FLAGS=/ /) {
17 for my $fflag ($flag =~ /(?:^|\s)-D(\S+)/g) {
18 $fflag .= '=1' unless $fflag =~ /^(\w+)=/;
19 $define{$1} = $2 if $fflag =~ /^(\w+)=(.+)$/;
23 $define{$1} = 1 if ($flag =~ /^-D(\w+)$/);
24 $define{$1} = $2 if ($flag =~ /^-D(\w+)=(.+)$/);
25 $CCTYPE = $1 if ($flag =~ /^CCTYPE=(\w+)$/);
26 $PLATFORM = $1 if ($flag =~ /^PLATFORM=(\w+)$/);
27 if ($PLATFORM eq 'netware') {
28 $FILETYPE = $1 if ($flag =~ /^FILETYPE=(\w+)$/);
32 my @PLATFORM = qw(aix win32 wince os2 MacOS netware);
34 @PLATFORM{@PLATFORM} = ();
36 defined $PLATFORM || die "PLATFORM undefined, must be one of: @PLATFORM\n";
37 exists $PLATFORM{$PLATFORM} || die "PLATFORM must be one of: @PLATFORM\n";
39 my %exportperlmalloc =
41 Perl_malloc => "malloc",
43 Perl_realloc => "realloc",
44 Perl_calloc => "calloc",
47 my $exportperlmalloc = $PLATFORM eq 'os2';
49 my $config_sh = "config.sh";
50 my $config_h = "config.h";
51 my $thrdvar_h = "thrdvar.h";
52 my $intrpvar_h = "intrpvar.h";
53 my $perlvars_h = "perlvars.h";
54 my $global_sym = "global.sym";
55 my $pp_sym = "pp.sym";
56 my $globvar_sym = "globvar.sym";
57 my $perlio_sym = "perlio.sym";
59 if ($PLATFORM eq 'aix') {
62 elsif ($PLATFORM =~ /^win(?:32|ce)$/ || $PLATFORM eq 'netware') {
63 $CCTYPE = "MSVC" unless defined $CCTYPE;
64 foreach ($thrdvar_h, $intrpvar_h, $perlvars_h, $global_sym,
65 $pp_sym, $globvar_sym, $perlio_sym) {
69 elsif ($PLATFORM eq 'MacOS') {
70 foreach ($thrdvar_h, $intrpvar_h, $perlvars_h, $global_sym,
71 $pp_sym, $globvar_sym, $perlio_sym) {
76 unless ($PLATFORM eq 'win32' || $PLATFORM eq 'wince' || $PLATFORM eq 'MacOS' || $PLATFORM eq 'netware') {
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='(.+)'$/;
86 $PATCHLEVEL = $1 if /^perl_patchlevel='(.+)'$/;
92 open(CFG,$config_h) || die "Cannot open $config_h: $!\n";
94 $define{$1} = 1 if /^\s*#\s*define\s+(MYMALLOC)\b/;
95 $define{$1} = 1 if /^\s*#\s*define\s+(MULTIPLICITY)\b/;
96 $define{$1} = 1 if /^\s*#\s*define\s+(PERL_\w+)\b/;
97 $define{$1} = 1 if /^\s*#\s*define\s+(USE_\w+)\b/;
101 # perl.h logic duplication begins
103 $define{PL_OP_SLAB_ALLOC} = 1;
105 if ($define{USE_ITHREADS}) {
106 if (!$define{MULTIPLICITY}) {
107 $define{MULTIPLICITY} = 1;
111 $define{PERL_IMPLICIT_CONTEXT} ||=
112 $define{USE_ITHREADS} ||
113 $define{MULTIPLICITY} ;
115 if ($define{USE_ITHREADS} && $PLATFORM ne 'win32' && $^O ne 'darwin') {
116 $define{USE_REENTRANT_API} = 1;
119 # perl.h logic duplication ends
123 if ($PLATFORM =~ /^win(?:32|ce)$/) {
124 warn join(' ',keys %define)."\n";
125 ($dll = ($define{PERL_DLL} || "perl59")) =~ s/\.dll$//i;
126 print "LIBRARY $dll\n";
127 print "DESCRIPTION 'Perl interpreter'\n";
129 if ($define{PERL_IMPLICIT_SYS}) {
130 output_symbol("perl_get_host_info");
131 output_symbol("perl_alloc_override");
133 if ($define{USE_ITHREADS} and $define{PERL_IMPLICIT_SYS}) {
134 output_symbol("perl_clone_host");
137 elsif ($PLATFORM eq 'os2') {
138 if (open my $fh, '<', 'perl5.def') {
140 last if /^\s*EXPORTS\b/;
143 $ordinal{$1} = $2 if /^\s*"(\w+)"\s*(?:=\s*"\w+"\s*)?\@(\d+)\s*$/;
144 # This allows skipping ordinals which were used in older versions
145 $sym_ord = $1 if /^\s*;\s*LAST_ORDINAL\s*=\s*(\d+)\s*$/;
147 $sym_ord < $_ and $sym_ord = $_ for values %ordinal; # Take the max
149 ($v = $]) =~ s/(\d\.\d\d\d)(\d\d)$/$1_$2/;
150 $v .= '-thread' if $ARCHNAME =~ /-thread/;
151 ($dll = $define{PERL_DLL}) =~ s/\.dll$//i;
152 $v .= "\@$PATCHLEVEL" if $PATCHLEVEL;
153 $d = "DESCRIPTION '\@#perl5-porters\@perl.org:$v#\@ Perl interpreter, configured as $CONFIG_ARGS'";
154 $d = substr($d, 0, 249) . "...'" if length $d > 253;
156 LIBRARY '$dll' INITINSTANCE TERMINSTANCE
160 DATA LOADONCALL NONSHARED MULTIPLE
164 elsif ($PLATFORM eq 'aix') {
169 if ($OSVER > 4 || ($OSVER == 4 && $OSREL >= 3)) {
175 elsif ($PLATFORM eq 'netware') {
176 if ($FILETYPE eq 'def') {
177 print "LIBRARY perl59\n";
178 print "DESCRIPTION 'Perl interpreter for NetWare'\n";
181 if ($define{PERL_IMPLICIT_SYS}) {
182 output_symbol("perl_get_host_info");
183 output_symbol("perl_alloc_override");
184 output_symbol("perl_clone_host");
193 foreach my $symbol (@$list) {
200 foreach my $symbol (@$list) {
201 my $skipsym = $symbol;
203 if ($define{MULTIPLICITY}) {
204 $skipsym =~ s/^Perl_[GIT](\w+)_ptr$/PL_$1/;
206 emit_symbol($symbol) unless exists $skip{$skipsym};
210 if ($PLATFORM eq 'win32') {
235 Perl_init_thread_intern
268 if ($PLATFORM eq 'wince') {
284 PL_collation_standard
312 Perl_init_thread_intern
338 elsif ($PLATFORM eq 'aix') {
357 Perl_sys_intern_clear
366 elsif ($PLATFORM eq 'os2') {
405 XS_Cwd_extLibpath_set
409 XS_Cwd_sys_is_absolute
410 XS_Cwd_sys_is_relative
412 XS_DynaLoader_mod2fname
413 XS_File__Copy_syscopy
417 Perl_Process_Messages
428 emit_symbols([qw(os2_cond_wait
433 if $define{'USE_5005THREADS'} or $define{'USE_ITHREADS'};
435 elsif ($PLATFORM eq 'MacOS') {
459 Perl_sys_intern_clear
463 elsif ($PLATFORM eq 'netware') {
488 Perl_init_thread_intern
513 Perl_sys_intern_clear
521 Perl_PerlIO_setlinebuf
522 Perl_PerlIO_set_ptrcnt
528 Perl_PerlIO_get_bufsiz
541 unless ($define{'DEBUGGING'}) {
555 if ($define{'PERL_IMPLICIT_SYS'}) {
576 unless ($define{'PERL_COPY_ON_WRITE'}) {
583 unless ($define{'PERL_FLEXIBLE_EXCEPTIONS'}) {
587 Perl_vdefault_protect
591 unless ($define{'USE_REENTRANT_API'}) {
597 if ($define{'MYMALLOC'}) {
606 if ($define{'USE_ITHREADS'}) {
628 unless ($define{'USE_ITHREADS'}) {
634 # USE_5005THREADS symbols. Kept as reference for easier removal
653 Perl_new_struct_thread
654 Perl_per_thread_magicals
662 unless ($define{'USE_ITHREADS'}) {
669 PL_sharedsv_space_mutex
697 Perl_sharedsv_thrcnt_dec
698 Perl_sharedsv_thrcnt_inc
703 unless ($define{'PERL_IMPLICIT_CONTEXT'}) {
709 Perl_load_module_nocontext
712 Perl_warner_nocontext
713 Perl_newSVpvf_nocontext
714 Perl_sv_catpvf_nocontext
715 Perl_sv_setpvf_nocontext
716 Perl_sv_catpvf_mg_nocontext
717 Perl_sv_setpvf_mg_nocontext
721 unless ($define{'PERL_IMPLICIT_SYS'}) {
728 unless ($define{'FAKE_THREADS'}) {
729 skip_symbols [qw(PL_curthr)];
732 unless ($define{'PL_OP_SLAB_ALLOC'}) {
740 unless ($define{'THREADS_HAVE_PIDS'}) {
741 skip_symbols [qw(PL_ppid)];
746 my $proc = shift || sub { "PL_$_[2]" };
747 open(VARS,$file) || die "Cannot open $file: $!\n";
750 # All symbols have a Perl_ prefix because that's what embed.h
751 # sticks in front of them.
752 push(@syms, &$proc($1,$2,$3)) if (/\bPERLVAR(A?I?C?)\(([IGT])(\w+)/);
758 if ($define{'PERL_GLOBAL_STRUCT'}) {
759 my $global = readvar($perlvars_h);
760 skip_symbols $global;
761 emit_symbol('Perl_GetVars');
762 emit_symbols [qw(PL_Vars PL_VarsPtr)] unless $CCTYPE eq 'GCC';
765 # functions from *.sym files
767 my @syms = ($global_sym, $globvar_sym); # $pp_sym is not part of the API
769 # Symbols that are the public face of the PerlIO layers implementation
770 # These are in _addition to_ the public face of the abstraction
771 # and need to be exported to allow XS modules to implement layers
785 PerlIOBase_setlinebuf
828 Perl_PerlIO_get_bufsiz
834 Perl_PerlIO_set_ptrcnt
835 Perl_PerlIO_setlinebuf
843 if ($PLATFORM eq 'netware') {
844 push(@layer_syms,'PL_def_layerlist','PL_known_layers','PL_perlio');
847 if ($define{'USE_PERLIO'}) {
848 # Export the symols that make up the PerlIO abstraction, regardless
849 # of its implementation - read from a file
850 push @syms, $perlio_sym;
852 # This part is then dependent on how the abstraction is implemented
853 if ($define{'USE_SFIO'}) {
854 # Old legacy non-stdio "PerlIO"
855 skip_symbols \@layer_syms;
856 # SFIO defines most of the PerlIO routines as macros
857 # So undo most of what $perlio_sym has just done - d'oh !
858 # Perhaps it would be better to list the ones which do exist
911 Perl_PerlIO_get_bufsiz
917 Perl_PerlIO_set_ptrcnt
918 Perl_PerlIO_setlinebuf
931 # PerlIO with layers - export implementation
932 emit_symbols \@layer_syms;
936 # Skip the PerlIO layer symbols - although
937 # nothing should have exported them any way
938 skip_symbols \@layer_syms;
939 skip_symbols [qw(PL_def_layerlist PL_known_layers PL_perlio)];
941 # Also do NOT add abstraction symbols from $perlio_sym
942 # abstraction is done as #define to stdio
943 # Remaining remnants that _may_ be functions
944 # are handled in <DATA>
947 for my $syms (@syms) {
948 open (GLOBAL, "<$syms") || die "failed to open $syms: $!\n";
950 next if (!/^[A-Za-z]/);
951 # Functions have a Perl_ prefix
952 # Variables have a PL_ prefix
954 my $symbol = ($syms =~ /var\.sym$/i ? "PL_" : "");
956 emit_symbol($symbol) unless exists $skip{$symbol};
963 if ($define{'MULTIPLICITY'}) {
964 for my $f ($perlvars_h, $intrpvar_h, $thrdvar_h) {
965 my $glob = readvar($f, sub { "Perl_" . $_[1] . $_[2] . "_ptr" });
968 # XXX AIX seems to want the perlvars.h symbols, for some reason
969 if ($PLATFORM eq 'aix' or $PLATFORM eq 'os2') { # OS/2 needs PL_thr_key
970 my $glob = readvar($perlvars_h);
975 unless ($define{'PERL_GLOBAL_STRUCT'}) {
976 my $glob = readvar($perlvars_h);
979 unless ($define{'MULTIPLICITY'}) {
980 my $glob = readvar($intrpvar_h);
983 unless ($define{'MULTIPLICITY'}) {
984 my $glob = readvar($thrdvar_h);
992 return if $symbol !~ /^[A-Za-z_]/;
993 return if $symbol =~ /^\#/;
996 return if exists $skip{$symbol};
997 emit_symbol($symbol);
1004 if ($PLATFORM =~ /^win(?:32|ce)$/) {
1005 foreach my $symbol (qw(
1066 win32_getprotobyname
1067 win32_getprotobynumber
1096 win32_open_osfhandle
1166 try_symbol($symbol);
1169 elsif ($PLATFORM eq 'os2') {
1170 open MAP, 'miniperl.map' or die 'Cannot read miniperl.map';
1171 /^\s*[\da-f:]+\s+(\w+)/i and $mapped{$1}++ foreach <MAP>;
1172 close MAP or die 'Cannot close miniperl.map';
1174 @missing = grep { !exists $mapped{$_} }
1176 @missing = grep { !exists $exportperlmalloc{$_} } @missing;
1177 delete $export{$_} foreach @missing;
1179 elsif ($PLATFORM eq 'MacOS') {
1180 open MACSYMS, 'macperl.sym' or die 'Cannot read macperl.sym';
1188 elsif ($PLATFORM eq 'netware') {
1189 foreach my $symbol (qw(
1316 fnInsertHashListAddrs
1327 try_symbol($symbol);
1331 # Now all symbols should be defined because
1332 # next we are going to output them.
1334 foreach my $symbol (sort keys %export) {
1335 output_symbol($symbol);
1338 if ($PLATFORM eq 'os2') {
1339 print "; LAST_ORDINAL=$sym_ord\n";
1345 $export{$symbol} = 1;
1350 if ($PLATFORM =~ /^win(?:32|ce)$/) {
1351 $symbol = "_$symbol" if $CCTYPE eq 'BORLAND';
1352 print "\t$symbol\n";
1353 # XXX: binary compatibility between compilers is an exercise
1354 # in frustration :-(
1355 # if ($CCTYPE eq "BORLAND") {
1356 # # workaround Borland quirk by exporting both the straight
1357 # # name and a name with leading underscore. Note the
1358 # # alias *must* come after the symbol itself, if both
1359 # # are to be exported. (Linker bug?)
1360 # print "\t_$symbol\n";
1361 # print "\t$symbol = _$symbol\n";
1363 # elsif ($CCTYPE eq 'GCC') {
1364 # # Symbols have leading _ whole process is $%@"% slow
1365 # # so skip aliases for now
1366 # nprint "\t$symbol\n";
1369 # # for binary coexistence, export both the symbol and
1370 # # alias with leading underscore
1371 # print "\t$symbol\n";
1372 # print "\t_$symbol = $symbol\n";
1375 elsif ($PLATFORM eq 'os2') {
1376 printf qq( %-31s \@%s\n),
1377 qq("$symbol"), $ordinal{$symbol} || ++$sym_ord;
1378 printf qq( %-31s \@%s\n),
1379 qq("$exportperlmalloc{$symbol}" = "$symbol"),
1380 $ordinal{$exportperlmalloc{$symbol}} || ++$sym_ord
1381 if $exportperlmalloc and exists $exportperlmalloc{$symbol};
1383 elsif ($PLATFORM eq 'aix' || $PLATFORM eq 'MacOS') {
1386 elsif ($PLATFORM eq 'netware') {
1387 print "\t$symbol,\n";
1393 # extra globals not included above.
1404 # Oddities from PerlIO