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{MULTIPLICITY} ;
117 if ($define{USE_ITHREADS} && $PLATFORM ne 'win32' && $^O ne 'darwin') {
118 $define{USE_REENTRANT_API} = 1;
121 # perl.h logic duplication ends
125 if ($PLATFORM =~ /^win(?:32|ce)$/) {
126 warn join(' ',keys %define)."\n";
127 ($dll = ($define{PERL_DLL} || "perl59")) =~ s/\.dll$//i;
128 print "LIBRARY $dll\n";
129 print "DESCRIPTION 'Perl interpreter'\n";
131 if ($define{PERL_IMPLICIT_SYS}) {
132 output_symbol("perl_get_host_info");
133 output_symbol("perl_alloc_override");
135 if ($define{USE_ITHREADS} and $define{PERL_IMPLICIT_SYS}) {
136 output_symbol("perl_clone_host");
139 elsif ($PLATFORM eq 'os2') {
140 if (open my $fh, '<', 'perl5.def') {
142 last if /^\s*EXPORTS\b/;
145 $ordinal{$1} = $2 if /^\s*"(\w+)"\s*(?:=\s*"\w+"\s*)?\@(\d+)\s*$/;
146 # This allows skipping ordinals which were used in older versions
147 $sym_ord = $1 if /^\s*;\s*LAST_ORDINAL\s*=\s*(\d+)\s*$/;
149 $sym_ord < $_ and $sym_ord = $_ for values %ordinal; # Take the max
151 ($v = $]) =~ s/(\d\.\d\d\d)(\d\d)$/$1_$2/;
152 $v .= '-thread' if $ARCHNAME =~ /-thread/;
153 ($dll = $define{PERL_DLL}) =~ s/\.dll$//i;
154 $v .= "\@$PATCHLEVEL" if $PATCHLEVEL;
155 $d = "DESCRIPTION '\@#perl5-porters\@perl.org:$v#\@ Perl interpreter, configured as $CONFIG_ARGS'";
156 $d = substr($d, 0, 249) . "...'" if length $d > 253;
158 LIBRARY '$dll' INITINSTANCE TERMINSTANCE
162 DATA LOADONCALL NONSHARED MULTIPLE
166 elsif ($PLATFORM eq 'aix') {
171 if ($OSVER > 4 || ($OSVER == 4 && $OSREL >= 3)) {
177 elsif ($PLATFORM eq 'netware') {
178 if ($FILETYPE eq 'def') {
179 print "LIBRARY perl59\n";
180 print "DESCRIPTION 'Perl interpreter for NetWare'\n";
183 if ($define{PERL_IMPLICIT_SYS}) {
184 output_symbol("perl_get_host_info");
185 output_symbol("perl_alloc_override");
186 output_symbol("perl_clone_host");
195 foreach my $symbol (@$list) {
202 foreach my $symbol (@$list) {
203 my $skipsym = $symbol;
205 if ($define{MULTIPLICITY}) {
206 $skipsym =~ s/^Perl_[GIT](\w+)_ptr$/PL_$1/;
208 emit_symbol($symbol) unless exists $skip{$skipsym};
212 if ($PLATFORM eq 'win32') {
237 Perl_init_thread_intern
270 if ($PLATFORM eq 'wince') {
286 PL_collation_standard
314 Perl_init_thread_intern
340 elsif ($PLATFORM eq 'aix') {
359 Perl_sys_intern_clear
368 elsif ($PLATFORM eq 'os2') {
413 XS_Cwd_extLibpath_set
417 XS_Cwd_sys_is_absolute
418 XS_Cwd_sys_is_relative
420 XS_DynaLoader_mod2fname
421 XS_File__Copy_syscopy
425 Perl_Process_Messages
436 emit_symbols([qw(os2_cond_wait
441 if $define{'USE_5005THREADS'} or $define{'USE_ITHREADS'};
443 elsif ($PLATFORM eq 'MacOS') {
467 Perl_sys_intern_clear
471 elsif ($PLATFORM eq 'netware') {
496 Perl_init_thread_intern
521 Perl_sys_intern_clear
529 Perl_PerlIO_setlinebuf
530 Perl_PerlIO_set_ptrcnt
536 Perl_PerlIO_get_bufsiz
549 unless ($define{'DEBUGGING'}) {
563 if ($define{'PERL_IMPLICIT_SYS'}) {
584 unless ($define{'PERL_COPY_ON_WRITE'}) {
591 unless ($define{'PERL_FLEXIBLE_EXCEPTIONS'}) {
595 Perl_vdefault_protect
599 unless ($define{'USE_REENTRANT_API'}) {
605 if ($define{'MYMALLOC'}) {
614 if ($define{'USE_ITHREADS'}) {
636 unless ($define{'USE_ITHREADS'}) {
642 # USE_5005THREADS symbols. Kept as reference for easier removal
661 Perl_new_struct_thread
662 Perl_per_thread_magicals
670 unless ($define{'USE_ITHREADS'}) {
677 PL_sharedsv_space_mutex
705 Perl_sharedsv_thrcnt_dec
706 Perl_sharedsv_thrcnt_inc
711 unless ($define{'PERL_IMPLICIT_CONTEXT'}) {
717 Perl_load_module_nocontext
720 Perl_warner_nocontext
721 Perl_newSVpvf_nocontext
722 Perl_sv_catpvf_nocontext
723 Perl_sv_setpvf_nocontext
724 Perl_sv_catpvf_mg_nocontext
725 Perl_sv_setpvf_mg_nocontext
729 unless ($define{'PERL_IMPLICIT_SYS'}) {
736 unless ($define{'FAKE_THREADS'}) {
737 skip_symbols [qw(PL_curthr)];
740 unless ($define{'PL_OP_SLAB_ALLOC'}) {
750 unless ($define{'THREADS_HAVE_PIDS'}) {
751 skip_symbols [qw(PL_ppid)];
756 my $proc = shift || sub { "PL_$_[2]" };
757 open(VARS,$file) || die "Cannot open $file: $!\n";
760 # All symbols have a Perl_ prefix because that's what embed.h
761 # sticks in front of them.
762 push(@syms, &$proc($1,$2,$3)) if (/\bPERLVAR(A?I?C?)\(([IGT])(\w+)/);
768 if ($define{'PERL_GLOBAL_STRUCT'}) {
769 my $global = readvar($perlvars_h);
770 skip_symbols $global;
771 emit_symbol('Perl_GetVars');
772 emit_symbols [qw(PL_Vars PL_VarsPtr)] unless $CCTYPE eq 'GCC';
775 # functions from *.sym files
777 my @syms = ($global_sym, $globvar_sym); # $pp_sym is not part of the API
779 # Symbols that are the public face of the PerlIO layers implementation
780 # These are in _addition to_ the public face of the abstraction
781 # and need to be exported to allow XS modules to implement layers
795 PerlIOBase_setlinebuf
838 Perl_PerlIO_get_bufsiz
844 Perl_PerlIO_set_ptrcnt
845 Perl_PerlIO_setlinebuf
853 if ($PLATFORM eq 'netware') {
854 push(@layer_syms,'PL_def_layerlist','PL_known_layers','PL_perlio');
857 if ($define{'USE_PERLIO'}) {
858 # Export the symols that make up the PerlIO abstraction, regardless
859 # of its implementation - read from a file
860 push @syms, $perlio_sym;
862 # This part is then dependent on how the abstraction is implemented
863 if ($define{'USE_SFIO'}) {
864 # Old legacy non-stdio "PerlIO"
865 skip_symbols \@layer_syms;
866 # SFIO defines most of the PerlIO routines as macros
867 # So undo most of what $perlio_sym has just done - d'oh !
868 # Perhaps it would be better to list the ones which do exist
921 Perl_PerlIO_get_bufsiz
927 Perl_PerlIO_set_ptrcnt
928 Perl_PerlIO_setlinebuf
941 # PerlIO with layers - export implementation
942 emit_symbols \@layer_syms;
946 # Skip the PerlIO layer symbols - although
947 # nothing should have exported them any way
948 skip_symbols \@layer_syms;
949 skip_symbols [qw(PL_def_layerlist PL_known_layers PL_perlio)];
951 # Also do NOT add abstraction symbols from $perlio_sym
952 # abstraction is done as #define to stdio
953 # Remaining remnants that _may_ be functions
954 # are handled in <DATA>
957 for my $syms (@syms) {
958 open (GLOBAL, "<$syms") || die "failed to open $syms: $!\n";
960 next if (!/^[A-Za-z]/);
961 # Functions have a Perl_ prefix
962 # Variables have a PL_ prefix
964 my $symbol = ($syms =~ /var\.sym$/i ? "PL_" : "");
966 emit_symbol($symbol) unless exists $skip{$symbol};
973 if ($define{'MULTIPLICITY'}) {
974 for my $f ($perlvars_h, $intrpvar_h, $thrdvar_h) {
975 my $glob = readvar($f, sub { "Perl_" . $_[1] . $_[2] . "_ptr" });
978 # XXX AIX seems to want the perlvars.h symbols, for some reason
979 if ($PLATFORM eq 'aix' or $PLATFORM eq 'os2') { # OS/2 needs PL_thr_key
980 my $glob = readvar($perlvars_h);
985 unless ($define{'PERL_GLOBAL_STRUCT'}) {
986 my $glob = readvar($perlvars_h);
989 unless ($define{'MULTIPLICITY'}) {
990 my $glob = readvar($intrpvar_h);
993 unless ($define{'MULTIPLICITY'}) {
994 my $glob = readvar($thrdvar_h);
1002 return if $symbol !~ /^[A-Za-z_]/;
1003 return if $symbol =~ /^\#/;
1006 return if exists $skip{$symbol};
1007 emit_symbol($symbol);
1014 if ($PLATFORM =~ /^win(?:32|ce)$/) {
1015 foreach my $symbol (qw(
1076 win32_getprotobyname
1077 win32_getprotobynumber
1106 win32_open_osfhandle
1176 try_symbol($symbol);
1179 elsif ($PLATFORM eq 'os2') {
1180 open MAP, 'miniperl.map' or die 'Cannot read miniperl.map';
1181 /^\s*[\da-f:]+\s+(\w+)/i and $mapped{$1}++ foreach <MAP>;
1182 close MAP or die 'Cannot close miniperl.map';
1184 @missing = grep { !exists $mapped{$_} }
1186 @missing = grep { !exists $exportperlmalloc{$_} } @missing;
1187 delete $export{$_} foreach @missing;
1189 elsif ($PLATFORM eq 'MacOS') {
1190 open MACSYMS, 'macperl.sym' or die 'Cannot read macperl.sym';
1198 elsif ($PLATFORM eq 'netware') {
1199 foreach my $symbol (qw(
1326 fnInsertHashListAddrs
1337 try_symbol($symbol);
1341 # Now all symbols should be defined because
1342 # next we are going to output them.
1344 foreach my $symbol (sort keys %export) {
1345 output_symbol($symbol);
1348 if ($PLATFORM eq 'os2') {
1353 Perl_OS2_handler_install
1355 ; LAST_ORDINAL=$sym_ord
1362 $export{$symbol} = 1;
1367 if ($PLATFORM =~ /^win(?:32|ce)$/) {
1368 $symbol = "_$symbol" if $CCTYPE eq 'BORLAND';
1369 print "\t$symbol\n";
1370 # XXX: binary compatibility between compilers is an exercise
1371 # in frustration :-(
1372 # if ($CCTYPE eq "BORLAND") {
1373 # # workaround Borland quirk by exporting both the straight
1374 # # name and a name with leading underscore. Note the
1375 # # alias *must* come after the symbol itself, if both
1376 # # are to be exported. (Linker bug?)
1377 # print "\t_$symbol\n";
1378 # print "\t$symbol = _$symbol\n";
1380 # elsif ($CCTYPE eq 'GCC') {
1381 # # Symbols have leading _ whole process is $%@"% slow
1382 # # so skip aliases for now
1383 # nprint "\t$symbol\n";
1386 # # for binary coexistence, export both the symbol and
1387 # # alias with leading underscore
1388 # print "\t$symbol\n";
1389 # print "\t_$symbol = $symbol\n";
1392 elsif ($PLATFORM eq 'os2') {
1393 printf qq( %-31s \@%s\n),
1394 qq("$symbol"), $ordinal{$symbol} || ++$sym_ord;
1395 printf qq( %-31s \@%s\n),
1396 qq("$exportperlmalloc{$symbol}" = "$symbol"),
1397 $ordinal{$exportperlmalloc{$symbol}} || ++$sym_ord
1398 if $exportperlmalloc and exists $exportperlmalloc{$symbol};
1400 elsif ($PLATFORM eq 'aix' || $PLATFORM eq 'MacOS') {
1403 elsif ($PLATFORM eq 'netware') {
1404 print "\t$symbol,\n";
1410 # extra globals not included above.
1421 # Oddities from PerlIO