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 if ($define{PERL_IMPLICIT_SYS}) {
104 $define{PL_OP_SLAB_ALLOC} = 1;
107 if ($define{USE_ITHREADS}) {
108 if (!$define{MULTIPLICITY}) {
109 $define{MULTIPLICITY} = 1;
113 $define{PERL_IMPLICIT_CONTEXT} ||=
114 $define{USE_ITHREADS} ||
115 $define{USE_5005THREADS} ||
116 $define{MULTIPLICITY} ;
118 if ($define{USE_ITHREADS} && $PLATFORM ne 'win32' && $^O ne 'darwin') {
119 $define{USE_REENTRANT_API} = 1;
122 # perl.h logic duplication ends
126 if ($PLATFORM =~ /^win(?:32|ce)$/) {
127 warn join(' ',keys %define)."\n";
128 ($dll = ($define{PERL_DLL} || "perl58")) =~ s/\.dll$//i;
129 print "LIBRARY $dll\n";
130 print "DESCRIPTION 'Perl interpreter'\n";
132 if ($define{PERL_IMPLICIT_SYS}) {
133 output_symbol("perl_get_host_info");
134 output_symbol("perl_alloc_override");
136 if ($define{USE_ITHREADS} and $define{PERL_IMPLICIT_SYS}) {
137 output_symbol("perl_clone_host");
140 elsif ($PLATFORM eq 'os2') {
141 if (open my $fh, '<', 'perl5.def') {
143 last if /^\s*EXPORTS\b/;
146 $ordinal{$1} = $2 if /^\s*"(\w+)"\s*(?:=\s*"\w+"\s*)?\@(\d+)\s*$/;
147 # This allows skipping ordinals which were used in older versions
148 $sym_ord = $1 if /^\s*;\s*LAST_ORDINAL\s*=\s*(\d+)\s*$/;
150 $sym_ord < $_ and $sym_ord = $_ for values %ordinal; # Take the max
152 ($v = $]) =~ s/(\d\.\d\d\d)(\d\d)$/$1_$2/;
153 $v .= '-thread' if $ARCHNAME =~ /-thread/;
154 ($dll = $define{PERL_DLL}) =~ s/\.dll$//i;
155 $v .= "\@$PATCHLEVEL" if $PATCHLEVEL;
156 $d = "DESCRIPTION '\@#perl5-porters\@perl.org:$v#\@ Perl interpreter, configured as $CONFIG_ARGS'";
157 $d = substr($d, 0, 249) . "...'" if length $d > 253;
159 LIBRARY '$dll' INITINSTANCE TERMINSTANCE
163 DATA LOADONCALL NONSHARED MULTIPLE
167 elsif ($PLATFORM eq 'aix') {
172 if ($OSVER > 4 || ($OSVER == 4 && $OSREL >= 3)) {
178 elsif ($PLATFORM eq 'netware') {
179 if ($FILETYPE eq 'def') {
180 print "LIBRARY perl58\n";
181 print "DESCRIPTION 'Perl interpreter for NetWare'\n";
184 if ($define{PERL_IMPLICIT_SYS}) {
185 output_symbol("perl_get_host_info");
186 output_symbol("perl_alloc_override");
187 output_symbol("perl_clone_host");
196 foreach my $symbol (@$list) {
203 foreach my $symbol (@$list) {
204 my $skipsym = $symbol;
206 if ($define{MULTIPLICITY}) {
207 $skipsym =~ s/^Perl_[GIT](\w+)_ptr$/PL_$1/;
209 emit_symbol($symbol) unless exists $skip{$skipsym};
213 if ($PLATFORM eq 'win32') {
238 Perl_init_thread_intern
271 if ($PLATFORM eq 'wince') {
287 PL_collation_standard
316 Perl_init_thread_intern
342 elsif ($PLATFORM eq 'aix') {
361 Perl_sys_intern_clear
370 elsif ($PLATFORM eq 'os2') {
409 XS_Cwd_extLibpath_set
413 XS_Cwd_sys_is_absolute
414 XS_Cwd_sys_is_relative
416 XS_DynaLoader_mod2fname
417 XS_File__Copy_syscopy
421 Perl_Process_Messages
432 emit_symbols([qw(os2_cond_wait
437 if $define{'USE_5005THREADS'} or $define{'USE_ITHREADS'};
439 elsif ($PLATFORM eq 'MacOS') {
463 Perl_sys_intern_clear
467 elsif ($PLATFORM eq 'netware') {
492 Perl_init_thread_intern
517 Perl_sys_intern_clear
525 Perl_PerlIO_setlinebuf
526 Perl_PerlIO_set_ptrcnt
532 Perl_PerlIO_get_bufsiz
545 unless ($define{'DEBUGGING'}) {
559 if ($define{'PERL_IMPLICIT_SYS'}) {
580 unless ($define{'PERL_FLEXIBLE_EXCEPTIONS'}) {
584 Perl_vdefault_protect
588 unless ($define{'USE_REENTRANT_API'}) {
594 if ($define{'MYMALLOC'}) {
601 if ($define{'USE_5005THREADS'} || $define{'USE_ITHREADS'}) {
621 unless ($define{'USE_5005THREADS'} || $define{'USE_ITHREADS'}) {
627 unless ($define{'USE_5005THREADS'}) {
646 Perl_new_struct_thread
647 Perl_per_thread_magicals
656 unless ($define{'USE_ITHREADS'}) {
663 PL_sharedsv_space_mutex
691 Perl_sharedsv_thrcnt_dec
692 Perl_sharedsv_thrcnt_inc
697 unless ($define{'PERL_IMPLICIT_CONTEXT'}) {
703 Perl_load_module_nocontext
706 Perl_warner_nocontext
707 Perl_newSVpvf_nocontext
708 Perl_sv_catpvf_nocontext
709 Perl_sv_setpvf_nocontext
710 Perl_sv_catpvf_mg_nocontext
711 Perl_sv_setpvf_mg_nocontext
715 unless ($define{'PERL_IMPLICIT_SYS'}) {
722 unless ($define{'FAKE_THREADS'}) {
723 skip_symbols [qw(PL_curthr)];
726 unless ($define{'PL_OP_SLAB_ALLOC'}) {
734 unless ($define{'THREADS_HAVE_PIDS'}) {
735 skip_symbols [qw(PL_ppid)];
740 my $proc = shift || sub { "PL_$_[2]" };
741 open(VARS,$file) || die "Cannot open $file: $!\n";
744 # All symbols have a Perl_ prefix because that's what embed.h
745 # sticks in front of them.
746 push(@syms, &$proc($1,$2,$3)) if (/\bPERLVAR(A?I?C?)\(([IGT])(\w+)/);
752 if ($define{'USE_5005THREADS'}) {
753 my $thrd = readvar($thrdvar_h);
757 if ($define{'PERL_GLOBAL_STRUCT'}) {
758 my $global = readvar($perlvars_h);
759 skip_symbols $global;
760 emit_symbol('Perl_GetVars');
761 emit_symbols [qw(PL_Vars PL_VarsPtr)] unless $CCTYPE eq 'GCC';
764 # functions from *.sym files
766 my @syms = ($global_sym, $globvar_sym); # $pp_sym is not part of the API
768 # Symbols that are the public face of the PerlIO layers implementation
769 # These are in _addition to_ the public face of the abstraction
770 # and need to be exported to allow XS modules to implement layers
782 PerlIOBase_setlinebuf
826 Perl_PerlIO_get_bufsiz
832 Perl_PerlIO_set_ptrcnt
833 Perl_PerlIO_setlinebuf
842 if ($PLATFORM eq 'netware') {
843 push(@layer_syms,'PL_def_layerlist','PL_known_layers','PL_perlio');
846 if ($define{'USE_PERLIO'}) {
847 # Export the symols that make up the PerlIO abstraction, regardless
848 # of its implementation - read from a file
849 push @syms, $perlio_sym;
851 # This part is then dependent on how the abstraction is implemented
852 if ($define{'USE_SFIO'}) {
853 # Old legacy non-stdio "PerlIO"
854 skip_symbols \@layer_syms;
855 # SFIO defines most of the PerlIO routines as macros
856 # So undo most of what $perlio_sym has just done - d'oh !
857 # Perhaps it would be better to list the ones which do exist
910 Perl_PerlIO_get_bufsiz
916 Perl_PerlIO_set_ptrcnt
917 Perl_PerlIO_setlinebuf
930 # PerlIO with layers - export implementation
931 emit_symbols \@layer_syms;
935 # Skip the PerlIO layer symbols - although
936 # nothing should have exported them any way
937 skip_symbols \@layer_syms;
938 skip_symbols [qw(PL_def_layerlist PL_known_layers PL_perlio)];
940 # Also do NOT add abstraction symbols from $perlio_sym
941 # abstraction is done as #define to stdio
942 # Remaining remnants that _may_ be functions
943 # are handled in <DATA>
946 for my $syms (@syms) {
947 open (GLOBAL, "<$syms") || die "failed to open $syms: $!\n";
949 next if (!/^[A-Za-z]/);
950 # Functions have a Perl_ prefix
951 # Variables have a PL_ prefix
953 my $symbol = ($syms =~ /var\.sym$/i ? "PL_" : "");
955 emit_symbol($symbol) unless exists $skip{$symbol};
962 if ($define{'MULTIPLICITY'}) {
963 for my $f ($perlvars_h, $intrpvar_h, $thrdvar_h) {
964 my $glob = readvar($f, sub { "Perl_" . $_[1] . $_[2] . "_ptr" });
967 # XXX AIX seems to want the perlvars.h symbols, for some reason
968 if ($PLATFORM eq 'aix' or $PLATFORM eq 'os2') { # OS/2 needs PL_thr_key
969 my $glob = readvar($perlvars_h);
974 unless ($define{'PERL_GLOBAL_STRUCT'}) {
975 my $glob = readvar($perlvars_h);
978 unless ($define{'MULTIPLICITY'}) {
979 my $glob = readvar($intrpvar_h);
982 unless ($define{'MULTIPLICITY'} || $define{'USE_5005THREADS'}) {
983 my $glob = readvar($thrdvar_h);
991 return if $symbol !~ /^[A-Za-z_]/;
992 return if $symbol =~ /^\#/;
995 return if exists $skip{$symbol};
996 emit_symbol($symbol);
1003 if ($PLATFORM =~ /^win(?:32|ce)$/) {
1004 foreach my $symbol (qw(
1065 win32_getprotobyname
1066 win32_getprotobynumber
1095 win32_open_osfhandle
1165 try_symbol($symbol);
1168 elsif ($PLATFORM eq 'os2') {
1169 open MAP, 'miniperl.map' or die 'Cannot read miniperl.map';
1170 /^\s*[\da-f:]+\s+(\w+)/i and $mapped{$1}++ foreach <MAP>;
1171 close MAP or die 'Cannot close miniperl.map';
1173 @missing = grep { !exists $mapped{$_} }
1175 @missing = grep { !exists $exportperlmalloc{$_} } @missing;
1176 delete $export{$_} foreach @missing;
1178 elsif ($PLATFORM eq 'MacOS') {
1179 open MACSYMS, 'macperl.sym' or die 'Cannot read macperl.sym';
1187 elsif ($PLATFORM eq 'netware') {
1188 foreach my $symbol (qw(
1315 fnInsertHashListAddrs
1326 try_symbol($symbol);
1330 # Now all symbols should be defined because
1331 # next we are going to output them.
1333 foreach my $symbol (sort keys %export) {
1334 output_symbol($symbol);
1337 if ($PLATFORM eq 'os2') {
1338 print "; LAST_ORDINAL=$sym_ord\n";
1344 $export{$symbol} = 1;
1349 if ($PLATFORM =~ /^win(?:32|ce)$/) {
1350 $symbol = "_$symbol" if $CCTYPE eq 'BORLAND';
1351 print "\t$symbol\n";
1352 # XXX: binary compatibility between compilers is an exercise
1353 # in frustration :-(
1354 # if ($CCTYPE eq "BORLAND") {
1355 # # workaround Borland quirk by exporting both the straight
1356 # # name and a name with leading underscore. Note the
1357 # # alias *must* come after the symbol itself, if both
1358 # # are to be exported. (Linker bug?)
1359 # print "\t_$symbol\n";
1360 # print "\t$symbol = _$symbol\n";
1362 # elsif ($CCTYPE eq 'GCC') {
1363 # # Symbols have leading _ whole process is $%@"% slow
1364 # # so skip aliases for now
1365 # nprint "\t$symbol\n";
1368 # # for binary coexistence, export both the symbol and
1369 # # alias with leading underscore
1370 # print "\t$symbol\n";
1371 # print "\t_$symbol = $symbol\n";
1374 elsif ($PLATFORM eq 'os2') {
1375 printf qq( %-31s \@%s\n),
1376 qq("$symbol"), $ordinal{$symbol} || ++$sym_ord;
1377 printf qq( %-31s \@%s\n),
1378 qq("$exportperlmalloc{$symbol}" = "$symbol"),
1379 $ordinal{$exportperlmalloc{$symbol}} || ++$sym_ord
1380 if $exportperlmalloc and exists $exportperlmalloc{$symbol};
1382 elsif ($PLATFORM eq 'aix' || $PLATFORM eq 'MacOS') {
1385 elsif ($PLATFORM eq 'netware') {
1386 print "\t$symbol,\n";
1392 # extra globals not included above.
1403 # Oddities from PerlIO