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 %exportperlmalloc =
34 Perl_malloc => "malloc",
36 Perl_realloc => "realloc",
37 Perl_calloc => "calloc",
40 my $exportperlmalloc = $PLATFORM eq 'os2';
42 my $config_sh = "config.sh";
43 my $config_h = "config.h";
44 my $thrdvar_h = "thrdvar.h";
45 my $intrpvar_h = "intrpvar.h";
46 my $perlvars_h = "perlvars.h";
47 my $global_sym = "global.sym";
48 my $pp_sym = "pp.sym";
49 my $globvar_sym = "globvar.sym";
50 my $perlio_sym = "perlio.sym";
52 if ($PLATFORM eq 'aix') {
55 elsif ($PLATFORM =~ /^win(?:32|ce)$/ || $PLATFORM eq 'netware') {
56 $CCTYPE = "MSVC" unless defined $CCTYPE;
57 foreach ($thrdvar_h, $intrpvar_h, $perlvars_h, $global_sym,
58 $pp_sym, $globvar_sym, $perlio_sym) {
62 elsif ($PLATFORM eq 'MacOS') {
63 foreach ($thrdvar_h, $intrpvar_h, $perlvars_h, $global_sym,
64 $pp_sym, $globvar_sym, $perlio_sym) {
69 unless ($PLATFORM eq 'win32' || $PLATFORM eq 'wince' || $PLATFORM eq 'MacOS' || $PLATFORM eq 'netware') {
70 open(CFG,$config_sh) || die "Cannot open $config_sh: $!\n";
72 if (/^(?:ccflags|optimize)='(.+)'$/) {
74 $define{$1} = 1 while /-D(\w+)/g;
76 if ($PLATFORM eq 'os2') {
77 $CONFIG_ARGS = $1 if /^config_args='(.+)'$/;
78 $ARCHNAME = $1 if /^archname='(.+)'$/;
79 $PATCHLEVEL = $1 if /^perl_patchlevel='(.+)'$/;
85 open(CFG,$config_h) || die "Cannot open $config_h: $!\n";
87 $define{$1} = 1 if /^\s*#\s*define\s+(MYMALLOC)\b/;
88 $define{$1} = 1 if /^\s*#\s*define\s+(MULTIPLICITY)\b/;
89 $define{$1} = 1 if /^\s*#\s*define\s+(PERL_\w+)\b/;
90 $define{$1} = 1 if /^\s*#\s*define\s+(USE_\w+)\b/;
94 # perl.h logic duplication begins
96 if ($define{PERL_IMPLICIT_SYS}) {
97 $define{PL_OP_SLAB_ALLOC} = 1;
100 if ($define{USE_ITHREADS}) {
101 if (!$define{MULTIPLICITY}) {
102 $define{MULTIPLICITY} = 1;
106 $define{PERL_IMPLICIT_CONTEXT} ||=
107 $define{USE_ITHREADS} ||
108 $define{MULTIPLICITY} ;
110 if ($define{USE_ITHREADS} && $PLATFORM ne 'win32' && $^O ne 'darwin') {
111 $define{USE_REENTRANT_API} = 1;
114 # perl.h logic duplication ends
118 if ($PLATFORM =~ /^win(?:32|ce)$/) {
119 warn join(' ',keys %define)."\n";
120 ($dll = ($define{PERL_DLL} || "perl59")) =~ s/\.dll$//i;
121 print "LIBRARY $dll\n";
122 print "DESCRIPTION 'Perl interpreter'\n";
124 if ($define{PERL_IMPLICIT_SYS}) {
125 output_symbol("perl_get_host_info");
126 output_symbol("perl_alloc_override");
128 if ($define{USE_ITHREADS} and $define{PERL_IMPLICIT_SYS}) {
129 output_symbol("perl_clone_host");
132 elsif ($PLATFORM eq 'os2') {
133 if (open my $fh, '<', 'perl5.def') {
135 last if /^\s*EXPORTS\b/;
138 $ordinal{$1} = $2 if /^\s*"(\w+)"\s*(?:=\s*"\w+"\s*)?\@(\d+)\s*$/;
139 # This allows skipping ordinals which were used in older versions
140 $sym_ord = $1 if /^\s*;\s*LAST_ORDINAL\s*=\s*(\d+)\s*$/;
142 $sym_ord < $_ and $sym_ord = $_ for values %ordinal; # Take the max
144 ($v = $]) =~ s/(\d\.\d\d\d)(\d\d)$/$1_$2/;
145 $v .= '-thread' if $ARCHNAME =~ /-thread/;
146 ($dll = $define{PERL_DLL}) =~ s/\.dll$//i;
147 $v .= "\@$PATCHLEVEL" if $PATCHLEVEL;
148 $d = "DESCRIPTION '\@#perl5-porters\@perl.org:$v#\@ Perl interpreter, configured as $CONFIG_ARGS'";
149 $d = substr($d, 0, 249) . "...'" if length $d > 253;
151 LIBRARY '$dll' INITINSTANCE TERMINSTANCE
155 DATA LOADONCALL NONSHARED MULTIPLE
159 elsif ($PLATFORM eq 'aix') {
164 if ($OSVER > 4 || ($OSVER == 4 && $OSREL >= 3)) {
170 elsif ($PLATFORM eq 'netware') {
171 if ($FILETYPE eq 'def') {
172 print "LIBRARY perl59\n";
173 print "DESCRIPTION 'Perl interpreter for NetWare'\n";
176 if ($define{PERL_IMPLICIT_SYS}) {
177 output_symbol("perl_get_host_info");
178 output_symbol("perl_alloc_override");
179 output_symbol("perl_clone_host");
188 foreach my $symbol (@$list) {
195 foreach my $symbol (@$list) {
196 my $skipsym = $symbol;
198 if ($define{MULTIPLICITY}) {
199 $skipsym =~ s/^Perl_[GIT](\w+)_ptr$/PL_$1/;
201 emit_symbol($symbol) unless exists $skip{$skipsym};
205 if ($PLATFORM eq 'win32') {
230 Perl_init_thread_intern
263 if ($PLATFORM eq 'wince') {
279 PL_collation_standard
308 Perl_init_thread_intern
334 elsif ($PLATFORM eq 'aix') {
353 Perl_sys_intern_clear
362 elsif ($PLATFORM eq 'os2') {
399 XS_Cwd_extLibpath_set
403 XS_Cwd_sys_is_absolute
404 XS_Cwd_sys_is_relative
406 XS_DynaLoader_mod2fname
407 XS_File__Copy_syscopy
411 Perl_Process_Messages
422 elsif ($PLATFORM eq 'MacOS') {
446 Perl_sys_intern_clear
450 elsif ($PLATFORM eq 'netware') {
475 Perl_init_thread_intern
500 Perl_sys_intern_clear
508 Perl_PerlIO_setlinebuf
509 Perl_PerlIO_set_ptrcnt
515 Perl_PerlIO_get_bufsiz
528 unless ($define{'DEBUGGING'}) {
542 if ($define{'PERL_IMPLICIT_SYS'}) {
563 unless ($define{'PERL_COPY_ON_WRITE'}) {
570 unless ($define{'PERL_FLEXIBLE_EXCEPTIONS'}) {
574 Perl_vdefault_protect
578 unless ($define{'USE_REENTRANT_API'}) {
584 if ($define{'MYMALLOC'}) {
591 if ($define{'USE_ITHREADS'}) {
611 unless ($define{'USE_ITHREADS'}) {
617 # USE_5005THREADS symbols. Kept as reference for easier removal
636 Perl_new_struct_thread
637 Perl_per_thread_magicals
645 unless ($define{'USE_ITHREADS'}) {
652 PL_sharedsv_space_mutex
680 Perl_sharedsv_thrcnt_dec
681 Perl_sharedsv_thrcnt_inc
686 unless ($define{'PERL_IMPLICIT_CONTEXT'}) {
692 Perl_load_module_nocontext
695 Perl_warner_nocontext
696 Perl_newSVpvf_nocontext
697 Perl_sv_catpvf_nocontext
698 Perl_sv_setpvf_nocontext
699 Perl_sv_catpvf_mg_nocontext
700 Perl_sv_setpvf_mg_nocontext
704 unless ($define{'PERL_IMPLICIT_SYS'}) {
711 unless ($define{'FAKE_THREADS'}) {
712 skip_symbols [qw(PL_curthr)];
715 unless ($define{'PL_OP_SLAB_ALLOC'}) {
723 unless ($define{'THREADS_HAVE_PIDS'}) {
724 skip_symbols [qw(PL_ppid)];
729 my $proc = shift || sub { "PL_$_[2]" };
730 open(VARS,$file) || die "Cannot open $file: $!\n";
733 # All symbols have a Perl_ prefix because that's what embed.h
734 # sticks in front of them.
735 push(@syms, &$proc($1,$2,$3)) if (/\bPERLVAR(A?I?C?)\(([IGT])(\w+)/);
741 if ($define{'PERL_GLOBAL_STRUCT'}) {
742 my $global = readvar($perlvars_h);
743 skip_symbols $global;
744 emit_symbol('Perl_GetVars');
745 emit_symbols [qw(PL_Vars PL_VarsPtr)] unless $CCTYPE eq 'GCC';
748 # functions from *.sym files
750 my @syms = ($global_sym, $globvar_sym); # $pp_sym is not part of the API
752 # Symbols that are the public face of the PerlIO layers implementation
753 # These are in _addition to_ the public face of the abstraction
754 # and need to be exported to allow XS modules to implement layers
766 PerlIOBase_setlinebuf
808 Perl_PerlIO_get_bufsiz
814 Perl_PerlIO_set_ptrcnt
815 Perl_PerlIO_setlinebuf
824 if ($PLATFORM eq 'netware') {
825 push(@layer_syms,'PL_def_layerlist','PL_known_layers','PL_perlio');
828 if ($define{'USE_PERLIO'}) {
829 # Export the symols that make up the PerlIO abstraction, regardless
830 # of its implementation - read from a file
831 push @syms, $perlio_sym;
833 # This part is then dependent on how the abstraction is implemented
834 if ($define{'USE_SFIO'}) {
835 # Old legacy non-stdio "PerlIO"
836 skip_symbols \@layer_syms;
837 # SFIO defines most of the PerlIO routines as macros
838 # So undo most of what $perlio_sym has just done - d'oh !
839 # Perhaps it would be better to list the ones which do exist
892 Perl_PerlIO_get_bufsiz
898 Perl_PerlIO_set_ptrcnt
899 Perl_PerlIO_setlinebuf
912 # PerlIO with layers - export implementation
913 emit_symbols \@layer_syms;
917 # Skip the PerlIO layer symbols - although
918 # nothing should have exported them any way
919 skip_symbols \@layer_syms;
920 skip_symbols [qw(PL_def_layerlist PL_known_layers PL_perlio)];
922 # Also do NOT add abstraction symbols from $perlio_sym
923 # abstraction is done as #define to stdio
924 # Remaining remnants that _may_ be functions
925 # are handled in <DATA>
928 for my $syms (@syms) {
929 open (GLOBAL, "<$syms") || die "failed to open $syms: $!\n";
931 next if (!/^[A-Za-z]/);
932 # Functions have a Perl_ prefix
933 # Variables have a PL_ prefix
935 my $symbol = ($syms =~ /var\.sym$/i ? "PL_" : "");
937 emit_symbol($symbol) unless exists $skip{$symbol};
944 if ($define{'MULTIPLICITY'}) {
945 for my $f ($perlvars_h, $intrpvar_h, $thrdvar_h) {
946 my $glob = readvar($f, sub { "Perl_" . $_[1] . $_[2] . "_ptr" });
949 # XXX AIX seems to want the perlvars.h symbols, for some reason
950 if ($PLATFORM eq 'aix') {
951 my $glob = readvar($perlvars_h);
956 unless ($define{'PERL_GLOBAL_STRUCT'}) {
957 my $glob = readvar($perlvars_h);
960 unless ($define{'MULTIPLICITY'}) {
961 my $glob = readvar($intrpvar_h);
964 unless ($define{'MULTIPLICITY'}) {
965 my $glob = readvar($thrdvar_h);
973 return if $symbol !~ /^[A-Za-z_]/;
974 return if $symbol =~ /^\#/;
977 return if exists $skip{$symbol};
978 emit_symbol($symbol);
985 if ($PLATFORM =~ /^win(?:32|ce)$/) {
986 foreach my $symbol (qw(
1046 win32_getprotobyname
1047 win32_getprotobynumber
1076 win32_open_osfhandle
1146 try_symbol($symbol);
1149 elsif ($PLATFORM eq 'os2') {
1150 open MAP, 'miniperl.map' or die 'Cannot read miniperl.map';
1151 /^\s*[\da-f:]+\s+(\w+)/i and $mapped{$1}++ foreach <MAP>;
1152 close MAP or die 'Cannot close miniperl.map';
1154 @missing = grep { !exists $mapped{$_} }
1156 @missing = grep { !exists $exportperlmalloc{$_} } @missing;
1157 delete $export{$_} foreach @missing;
1159 elsif ($PLATFORM eq 'MacOS') {
1160 open MACSYMS, 'macperl.sym' or die 'Cannot read macperl.sym';
1168 elsif ($PLATFORM eq 'netware') {
1169 foreach my $symbol (qw(
1296 fnInsertHashListAddrs
1307 try_symbol($symbol);
1311 # Now all symbols should be defined because
1312 # next we are going to output them.
1314 foreach my $symbol (sort keys %export) {
1315 output_symbol($symbol);
1318 if ($PLATFORM eq 'os2') {
1319 print "; LAST_ORDINAL=$sym_ord\n";
1325 $export{$symbol} = 1;
1330 if ($PLATFORM =~ /^win(?:32|ce)$/) {
1331 $symbol = "_$symbol" if $CCTYPE eq 'BORLAND';
1332 print "\t$symbol\n";
1333 # XXX: binary compatibility between compilers is an exercise
1334 # in frustration :-(
1335 # if ($CCTYPE eq "BORLAND") {
1336 # # workaround Borland quirk by exporting both the straight
1337 # # name and a name with leading underscore. Note the
1338 # # alias *must* come after the symbol itself, if both
1339 # # are to be exported. (Linker bug?)
1340 # print "\t_$symbol\n";
1341 # print "\t$symbol = _$symbol\n";
1343 # elsif ($CCTYPE eq 'GCC') {
1344 # # Symbols have leading _ whole process is $%@"% slow
1345 # # so skip aliases for now
1346 # nprint "\t$symbol\n";
1349 # # for binary coexistence, export both the symbol and
1350 # # alias with leading underscore
1351 # print "\t$symbol\n";
1352 # print "\t_$symbol = $symbol\n";
1355 elsif ($PLATFORM eq 'os2') {
1356 printf qq( %-31s \@%s\n),
1357 qq("$symbol"), $ordinal{$symbol} || ++$sym_ord;
1358 printf qq( %-31s \@%s\n),
1359 qq("$exportperlmalloc{$symbol}" = "$symbol"),
1360 $ordinal{$exportperlmalloc{$symbol}} || ++$sym_ord
1361 if $exportperlmalloc and exists $exportperlmalloc{$symbol};
1363 elsif ($PLATFORM eq 'aix' || $PLATFORM eq 'MacOS') {
1366 elsif ($PLATFORM eq 'netware') {
1367 print "\t$symbol,\n";
1373 # extra globals not included above.
1384 # Oddities from PerlIO