Make makedef.pl more robust
[p5sagit/p5-mst-13.2.git] / makedef.pl
1 #./perl -w
2 #
3 # Create the export list for perl.
4 #
5 # Needed by WIN32 and OS/2 for creating perl.dll,
6 # and by AIX for creating libperl.a when -Dusershrplib is in effect,
7 # and by MacOS Classic.
8 #
9 # Reads from information stored in
10 #
11 #    config.h
12 #    config.sh
13 #    global.sym
14 #    globvar.sym
15 #    intrpvar.h
16 #    macperl.sym  (on MacOS)
17 #    miniperl.map (on OS/2)
18 #    perl5.def    (on OS/2; this is the old version of the file being made)
19 #    perlio.sym
20 #    perlvars.h
21 #
22 # plus long lists of function names hard-coded directly in this script and
23 # in the DATA section.
24 #
25 # Writes the result to STDOUT.
26 #
27 # Normally this script is invoked from a makefile (e.g. win32/Makefile),
28 # which redirects STDOUT to a suitable file, such as:
29 #
30 #    perl5.def   OS/2
31 #    perldll.def Windows
32 #    perl.exp    AIX
33 #    perl.imp    NetWare
34
35
36 BEGIN { unshift @INC, "lib" }
37 use Config;
38 use strict;
39
40 use vars qw($PLATFORM $CCTYPE $FILETYPE $CONFIG_ARGS $ARCHNAME $PATCHLEVEL);
41
42 my (%define, %ordinal);
43
44 while (@ARGV) {
45     my $flag = shift;
46     if ($flag =~ s/^CC_FLAGS=/ /) {
47         for my $fflag ($flag =~ /(?:^|\s)-D(\S+)/g) {
48             $fflag     .= '=1' unless $fflag =~ /^(\w+)=/;
49             $define{$1} = $2   if $fflag =~ /^(\w+)=(.+)$/;
50         }
51         next;
52     }
53     $define{$1} = 1 if ($flag =~ /^-D(\w+)$/);
54     $define{$1} = $2 if ($flag =~ /^-D(\w+)=(.+)$/);
55     $CCTYPE   = $1 if ($flag =~ /^CCTYPE=(\w+)$/);
56     $PLATFORM = $1 if ($flag =~ /^PLATFORM=(\w+)$/);
57     if ($PLATFORM eq 'netware') {
58         $FILETYPE = $1 if ($flag =~ /^FILETYPE=(\w+)$/);
59     }
60 }
61
62 my @PLATFORM = qw(aix win32 wince os2 MacOS netware);
63 my %PLATFORM;
64 @PLATFORM{@PLATFORM} = ();
65
66 defined $PLATFORM || die "PLATFORM undefined, must be one of: @PLATFORM\n";
67 exists $PLATFORM{$PLATFORM} || die "PLATFORM must be one of: @PLATFORM\n";
68
69 if ($PLATFORM eq 'win32' or $PLATFORM eq 'wince' or $PLATFORM eq "aix") {
70         # Add the compile-time options that miniperl was built with to %define.
71         # On Win32 these are not the same options as perl itself will be built
72         # with since miniperl is built with a canned config (one of the win32/
73         # config_H.*) and none of the BUILDOPT's that are set in the makefiles,
74         # but they do include some #define's that are hard-coded in various
75         # source files and header files and don't include any BUILDOPT's that
76         # the user might have chosen to disable because the canned configs are
77         # minimal configs that don't include any of those options.
78         my $opts = ($PLATFORM eq 'wince' ? '-MCross' : ''); # for wince need Cross.pm to get Config.pm
79
80         $ENV{PERL5LIB} = join $Config{path_sep}, @INC;
81         my $cmd = "$^X $opts -V";
82         my $config = `$cmd`;
83         if (! $config) {
84             die "Couldn't run [$cmd]: $!";
85         };
86         my($options) = $config =~ /^  Compile-time options: (.*?)\n^  \S/ms;
87         $options =~ s/\s+/ /g;
88         print STDERR "Options: ($options)\n";
89         foreach (split /\s+/, $options) {
90                 $define{$_} = 1;
91         }
92 }
93
94 my %exportperlmalloc =
95     (
96        Perl_malloc              =>      "malloc",
97        Perl_mfree               =>      "free",
98        Perl_realloc             =>      "realloc",
99        Perl_calloc              =>      "calloc",
100     );
101
102 my $exportperlmalloc = $PLATFORM eq 'os2';
103
104 my $config_sh   = "config.sh";
105 my $config_h    = "config.h";
106 my $intrpvar_h  = "intrpvar.h";
107 my $perlvars_h  = "perlvars.h";
108 my $global_sym  = "global.sym";
109 my $pp_sym      = "pp.sym";
110 my $globvar_sym = "globvar.sym";
111 my $perlio_sym  = "perlio.sym";
112 my $static_ext = "";
113
114 if ($PLATFORM eq 'aix') {
115     # Nothing for now.
116 }
117 elsif ($PLATFORM =~ /^win(?:32|ce)$/ || $PLATFORM eq 'netware') {
118     $CCTYPE = "MSVC" unless defined $CCTYPE;
119     foreach ($intrpvar_h, $perlvars_h, $global_sym,
120              $pp_sym, $globvar_sym, $perlio_sym) {
121         s!^!..\\!;
122     }
123 }
124 elsif ($PLATFORM eq 'MacOS') {
125     foreach ($intrpvar_h, $perlvars_h, $global_sym,
126              $pp_sym, $globvar_sym, $perlio_sym) {
127         s!^!::!;
128     }
129 }
130
131 unless ($PLATFORM eq 'win32' || $PLATFORM eq 'wince' || $PLATFORM eq 'MacOS' || $PLATFORM eq 'netware') {
132     open(CFG,$config_sh) || die "Cannot open $config_sh: $!\n";
133     while (<CFG>) {
134         if (/^(?:ccflags|optimize)='(.+)'$/) {
135             $_ = $1;
136             $define{$1} = 1 while /-D(\w+)/g;
137         }
138         if (/^(d_(?:mmap|sigaction))='(.+)'$/) {
139             $define{$1} = $2;
140         }
141         if ($PLATFORM eq 'os2') {
142             $CONFIG_ARGS = $1 if /^config_args='(.+)'$/;
143             $ARCHNAME =    $1 if /^archname='(.+)'$/;
144             $PATCHLEVEL =  $1 if /^perl_patchlevel='(.+)'$/;
145         }
146     }
147     close(CFG);
148 }
149 if ($PLATFORM eq 'win32' || $PLATFORM eq 'wince') {
150     open(CFG,"<..\\$config_sh") || die "Cannot open ..\\$config_sh: $!\n";
151     if ((join '', <CFG>) =~ /^static_ext='(.*)'$/m) {
152         $static_ext = $1;
153     }
154     close(CFG);
155 }
156
157 open(CFG,$config_h) || die "Cannot open $config_h: $!\n";
158 while (<CFG>) {
159     $define{$1} = 1 if /^\s*#\s*define\s+(MYMALLOC)\b/;
160     $define{$1} = 1 if /^\s*#\s*define\s+(MULTIPLICITY)\b/;
161     $define{$1} = 1 if /^\s*#\s*define\s+(PERL_\w+)\b/;
162     $define{$1} = 1 if /^\s*#\s*define\s+(USE_\w+)\b/;
163     $define{$1} = 1 if /^\s*#\s*define\s+(HAS_\w+)\b/;
164 }
165 close(CFG);
166
167 # perl.h logic duplication begins
168
169 if ($define{PERL_IMPLICIT_SYS}) {
170     $define{PL_OP_SLAB_ALLOC} = 1;
171 }
172
173 if ($define{USE_ITHREADS}) {
174     if (!$define{MULTIPLICITY}) {
175         $define{MULTIPLICITY} = 1;
176     }
177 }
178
179 $define{PERL_IMPLICIT_CONTEXT} ||=
180     $define{USE_ITHREADS} ||
181     $define{MULTIPLICITY} ;
182
183 if ($define{USE_ITHREADS} && $PLATFORM ne 'win32' && $^O ne 'darwin') {
184     $define{USE_REENTRANT_API} = 1;
185 }
186
187 # perl.h logic duplication ends
188
189 my $sym_ord = 0;
190
191 print STDERR "Defines: (" . join(' ', sort keys %define) . ")\n";
192
193 if ($PLATFORM =~ /^win(?:32|ce)$/) {
194     (my $dll = ($define{PERL_DLL} || "perl511")) =~ s/\.dll$//i;
195     print "LIBRARY $dll\n";
196     # The DESCRIPTION module definition file statement is not supported
197     # by VC7 onwards.
198     if ($CCTYPE !~ /^MSVC7/ && $CCTYPE !~ /^MSVC8/ && $CCTYPE !~ /^MSVC9/) {
199         print "DESCRIPTION 'Perl interpreter'\n";
200     }
201     print "EXPORTS\n";
202     if ($define{PERL_IMPLICIT_SYS}) {
203         output_symbol("perl_get_host_info");
204         output_symbol("perl_alloc_override");
205     }
206     if ($define{USE_ITHREADS} and $define{PERL_IMPLICIT_SYS}) {
207         output_symbol("perl_clone_host");
208     }
209 }
210 elsif ($PLATFORM eq 'os2') {
211     if (open my $fh, '<', 'perl5.def') {
212       while (<$fh>) {
213         last if /^\s*EXPORTS\b/;
214       }
215       while (<$fh>) {
216         $ordinal{$1} = $2 if /^\s*"(\w+)"\s*(?:=\s*"\w+"\s*)?\@(\d+)\s*$/;
217         # This allows skipping ordinals which were used in older versions
218         $sym_ord = $1 if /^\s*;\s*LAST_ORDINAL\s*=\s*(\d+)\s*$/;
219       }
220       $sym_ord < $_ and $sym_ord = $_ for values %ordinal; # Take the max
221     }
222     (my $v = $]) =~ s/(\d\.\d\d\d)(\d\d)$/$1_$2/;
223     $v .= '-thread' if $ARCHNAME =~ /-thread/;
224     (my $dll = $define{PERL_DLL}) =~ s/\.dll$//i;
225     $v .= "\@$PATCHLEVEL" if $PATCHLEVEL;
226     my $d = "DESCRIPTION '\@#perl5-porters\@perl.org:$v#\@ Perl interpreter, configured as $CONFIG_ARGS'";
227     $d = substr($d, 0, 249) . "...'" if length $d > 253;
228     print <<"---EOP---";
229 LIBRARY '$dll' INITINSTANCE TERMINSTANCE
230 $d
231 STACKSIZE 32768
232 CODE LOADONCALL
233 DATA LOADONCALL NONSHARED MULTIPLE
234 EXPORTS
235 ---EOP---
236 }
237 elsif ($PLATFORM eq 'aix') {
238     my $OSVER = `uname -v`;
239     chop $OSVER;
240     my $OSREL = `uname -r`;
241     chop $OSREL;
242     if ($OSVER > 4 || ($OSVER == 4 && $OSREL >= 3)) {
243         print "#! ..\n";
244     } else {
245         print "#!\n";
246     }
247 }
248 elsif ($PLATFORM eq 'netware') {
249         if ($FILETYPE eq 'def') {
250         print "LIBRARY perl511\n";
251         print "DESCRIPTION 'Perl interpreter for NetWare'\n";
252         print "EXPORTS\n";
253         }
254         if ($define{PERL_IMPLICIT_SYS}) {
255             output_symbol("perl_get_host_info");
256             output_symbol("perl_alloc_override");
257             output_symbol("perl_clone_host");
258         }
259 }
260
261 my %skip;
262 my %export;
263
264 sub skip_symbols {
265     my $list = shift;
266     foreach my $symbol (@$list) {
267         $skip{$symbol} = 1;
268     }
269 }
270
271 sub emit_symbols {
272     my $list = shift;
273     foreach my $symbol (@$list) {
274         my $skipsym = $symbol;
275         # XXX hack
276         if ($define{MULTIPLICITY}) {
277             $skipsym =~ s/^Perl_[GIT](\w+)_ptr$/PL_$1/;
278         }
279         emit_symbol($symbol) unless exists $skip{$skipsym};
280     }
281 }
282
283 if ($PLATFORM eq 'win32') {
284     skip_symbols [qw(
285                      PL_statusvalue_vms
286                      PL_archpat_auto
287                      PL_cryptseen
288                      PL_DBcv
289                      PL_generation
290                      PL_lastgotoprobe
291                      PL_linestart
292                      PL_modcount
293                      PL_pending_ident
294                      PL_sublex_info
295                      PL_timesbuf
296                      main
297                      Perl_ErrorNo
298                      Perl_GetVars
299                      Perl_do_exec3
300                      Perl_do_ipcctl
301                      Perl_do_ipcget
302                      Perl_do_msgrcv
303                      Perl_do_msgsnd
304                      Perl_do_semop
305                      Perl_do_shmio
306                      Perl_dump_fds
307                      Perl_init_thread_intern
308                      Perl_my_bzero
309                      Perl_my_bcopy
310                      Perl_my_htonl
311                      Perl_my_ntohl
312                      Perl_my_swap
313                      Perl_my_chsize
314                      Perl_same_dirent
315                      Perl_setenv_getix
316                      Perl_unlnk
317                      Perl_watch
318                      Perl_safexcalloc
319                      Perl_safexmalloc
320                      Perl_safexfree
321                      Perl_safexrealloc
322                      Perl_my_memcmp
323                      Perl_my_memset
324                      PL_cshlen
325                      PL_cshname
326                      PL_opsave
327                      Perl_do_exec
328                      Perl_getenv_len
329                      Perl_my_pclose
330                      Perl_my_popen
331                      Perl_my_sprintf
332                      )];
333 }
334 else {
335     skip_symbols [qw(
336                      Perl_do_spawn
337                      Perl_do_spawn_nowait
338                      Perl_do_aspawn
339                      )];
340 }
341 if ($PLATFORM eq 'wince') {
342     skip_symbols [qw(
343                      PL_statusvalue_vms
344                      PL_archpat_auto
345                      PL_cryptseen
346                      PL_DBcv
347                      PL_generation
348                      PL_lastgotoprobe
349                      PL_linestart
350                      PL_modcount
351                      PL_pending_ident
352                      PL_sublex_info
353                      PL_timesbuf
354                      PL_collation_ix
355                      PL_collation_name
356                      PL_collation_standard
357                      PL_collxfrm_base
358                      PL_collxfrm_mult
359                      PL_numeric_compat1
360                      PL_numeric_local
361                      PL_numeric_name
362                      PL_numeric_radix_sv
363                      PL_numeric_standard
364                      PL_vtbl_collxfrm
365                      Perl_sv_collxfrm
366                      setgid
367                      setuid
368                      win32_free_childdir
369                      win32_free_childenv
370                      win32_get_childdir
371                      win32_get_childenv
372                      win32_spawnvp
373                      main
374                      Perl_ErrorNo
375                      Perl_GetVars
376                      Perl_do_exec3
377                      Perl_do_ipcctl
378                      Perl_do_ipcget
379                      Perl_do_msgrcv
380                      Perl_do_msgsnd
381                      Perl_do_semop
382                      Perl_do_shmio
383                      Perl_dump_fds
384                      Perl_init_thread_intern
385                      Perl_my_bzero
386                      Perl_my_bcopy
387                      Perl_my_htonl
388                      Perl_my_ntohl
389                      Perl_my_swap
390                      Perl_my_chsize
391                      Perl_same_dirent
392                      Perl_setenv_getix
393                      Perl_unlnk
394                      Perl_watch
395                      Perl_safexcalloc
396                      Perl_safexmalloc
397                      Perl_safexfree
398                      Perl_safexrealloc
399                      Perl_my_memcmp
400                      Perl_my_memset
401                      PL_cshlen
402                      PL_cshname
403                      PL_opsave
404                      Perl_do_exec
405                      Perl_getenv_len
406                      Perl_my_pclose
407                      Perl_my_popen
408                      Perl_my_sprintf
409                      )];
410 }
411 elsif ($PLATFORM eq 'aix') {
412     skip_symbols([qw(
413                      Perl_dump_fds
414                      Perl_ErrorNo
415                      Perl_GetVars
416                      Perl_my_bcopy
417                      Perl_my_bzero
418                      Perl_my_chsize
419                      Perl_my_htonl
420                      Perl_my_memcmp
421                      Perl_my_memset
422                      Perl_my_ntohl
423                      Perl_my_swap
424                      Perl_safexcalloc
425                      Perl_safexfree
426                      Perl_safexmalloc
427                      Perl_safexrealloc
428                      Perl_same_dirent
429                      Perl_unlnk
430                      Perl_sys_intern_clear
431                      Perl_sys_intern_dup
432                      Perl_sys_intern_init
433                      Perl_my_sprintf
434                      PL_cryptseen
435                      PL_opsave
436                      PL_statusvalue_vms
437                      PL_sys_intern
438                      )]);
439     skip_symbols([qw(
440                      Perl_signbit
441                      )])
442         if $define{'HAS_SIGNBIT'};
443     emit_symbols([qw(
444                      boot_DynaLoader
445                      )]);
446 }
447 elsif ($PLATFORM eq 'os2') {
448     emit_symbols([qw(
449                     ctermid
450                     get_sysinfo
451                     Perl_OS2_init
452                     Perl_OS2_init3
453                     Perl_OS2_term
454                     OS2_Perl_data
455                     dlopen
456                     dlsym
457                     dlerror
458                     dlclose
459                     dup2
460                     dup
461                     my_tmpfile
462                     my_tmpnam
463                     my_flock
464                     my_rmdir
465                     my_mkdir
466                     my_getpwuid
467                     my_getpwnam
468                     my_getpwent
469                     my_setpwent
470                     my_endpwent
471                     fork_with_resources
472                     croak_with_os2error
473                     setgrent
474                     endgrent
475                     getgrent
476                     malloc_mutex
477                     threads_mutex
478                     nthreads
479                     nthreads_cond
480                     os2_cond_wait
481                     os2_stat
482                     os2_execname
483                     async_mssleep
484                     msCounter
485                     InfoTable
486                     pthread_join
487                     pthread_create
488                     pthread_detach
489                     XS_Cwd_change_drive
490                     XS_Cwd_current_drive
491                     XS_Cwd_extLibpath
492                     XS_Cwd_extLibpath_set
493                     XS_Cwd_sys_abspath
494                     XS_Cwd_sys_chdir
495                     XS_Cwd_sys_cwd
496                     XS_Cwd_sys_is_absolute
497                     XS_Cwd_sys_is_relative
498                     XS_Cwd_sys_is_rooted
499                     XS_DynaLoader_mod2fname
500                     XS_File__Copy_syscopy
501                     Perl_Register_MQ
502                     Perl_Deregister_MQ
503                     Perl_Serve_Messages
504                     Perl_Process_Messages
505                     init_PMWIN_entries
506                     PMWIN_entries
507                     Perl_hab_GET
508                     loadByOrdinal
509                     pExtFCN
510                     os2error
511                     ResetWinError
512                     CroakWinError
513                     PL_do_undump
514                     )]);
515     emit_symbols([qw(os2_cond_wait
516                      pthread_join
517                      pthread_create
518                      pthread_detach
519                     )])
520       if $define{'USE_5005THREADS'} or $define{'USE_ITHREADS'};
521 }
522 elsif ($PLATFORM eq 'MacOS') {
523     skip_symbols [qw(
524                     Perl_GetVars
525                     PL_cryptseen
526                     PL_cshlen
527                     PL_cshname
528                     PL_statusvalue_vms
529                     PL_sys_intern
530                     PL_opsave
531                     PL_timesbuf
532                     Perl_dump_fds
533                     Perl_my_bcopy
534                     Perl_my_bzero
535                     Perl_my_chsize
536                     Perl_my_htonl
537                     Perl_my_memcmp
538                     Perl_my_memset
539                     Perl_my_ntohl
540                     Perl_my_swap
541                     Perl_safexcalloc
542                     Perl_safexfree
543                     Perl_safexmalloc
544                     Perl_safexrealloc
545                     Perl_unlnk
546                     Perl_sys_intern_clear
547                     Perl_sys_intern_init
548                     )];
549 }
550 elsif ($PLATFORM eq 'netware') {
551         skip_symbols [qw(
552                         PL_statusvalue_vms
553                         PL_archpat_auto
554                         PL_cryptseen
555                         PL_DBcv
556                         PL_generation
557                         PL_lastgotoprobe
558                         PL_linestart
559                         PL_modcount
560                         PL_pending_ident
561                         PL_sublex_info
562                         PL_timesbuf
563                         main
564                         Perl_ErrorNo
565                         Perl_GetVars
566                         Perl_do_exec3
567                         Perl_do_ipcctl
568                         Perl_do_ipcget
569                         Perl_do_msgrcv
570                         Perl_do_msgsnd
571                         Perl_do_semop
572                         Perl_do_shmio
573                         Perl_dump_fds
574                         Perl_init_thread_intern
575                         Perl_my_bzero
576                         Perl_my_htonl
577                         Perl_my_ntohl
578                         Perl_my_swap
579                         Perl_my_chsize
580                         Perl_same_dirent
581                         Perl_setenv_getix
582                         Perl_unlnk
583                         Perl_watch
584                         Perl_safexcalloc
585                         Perl_safexmalloc
586                         Perl_safexfree
587                         Perl_safexrealloc
588                         Perl_my_memcmp
589                         Perl_my_memset
590                         PL_cshlen
591                         PL_cshname
592                         PL_opsave
593                         Perl_do_exec
594                         Perl_getenv_len
595                         Perl_my_pclose
596                         Perl_my_popen
597                         Perl_sys_intern_init
598                         Perl_sys_intern_dup
599                         Perl_sys_intern_clear
600                         Perl_my_bcopy
601                         Perl_PerlIO_write
602                         Perl_PerlIO_unread
603                         Perl_PerlIO_tell
604                         Perl_PerlIO_stdout
605                         Perl_PerlIO_stdin
606                         Perl_PerlIO_stderr
607                         Perl_PerlIO_setlinebuf
608                         Perl_PerlIO_set_ptrcnt
609                         Perl_PerlIO_set_cnt
610                         Perl_PerlIO_seek
611                         Perl_PerlIO_read
612                         Perl_PerlIO_get_ptr
613                         Perl_PerlIO_get_cnt
614                         Perl_PerlIO_get_bufsiz
615                         Perl_PerlIO_get_base
616                         Perl_PerlIO_flush
617                         Perl_PerlIO_fill
618                         Perl_PerlIO_fileno
619                         Perl_PerlIO_error
620                         Perl_PerlIO_eof
621                         Perl_PerlIO_close
622                         Perl_PerlIO_clearerr
623                         PerlIO_perlio
624                         )];
625 }
626
627 unless ($define{'DEBUGGING'}) {
628     skip_symbols [qw(
629                     Perl_deb_growlevel
630                     Perl_debop
631                     Perl_debprofdump
632                     Perl_debstack
633                     Perl_debstackptrs
634                     Perl_pad_sv
635                     Perl_hv_assert
636                     PL_block_type
637                     PL_watchaddr
638                     PL_watchok
639                     PL_watch_pvx
640                     )];
641 }
642
643 if ($define{'PERL_IMPLICIT_CONTEXT'}) {
644     skip_symbols [qw(
645                     PL_sig_sv
646                     )];
647 }
648
649 if ($define{'PERL_IMPLICIT_SYS'}) {
650     skip_symbols [qw(
651                     Perl_getenv_len
652                     Perl_my_popen
653                     Perl_my_pclose
654                     )];
655 }
656 else {
657     skip_symbols [qw(
658                     PL_Mem
659                     PL_MemShared
660                     PL_MemParse
661                     PL_Env
662                     PL_StdIO
663                     PL_LIO
664                     PL_Dir
665                     PL_Sock
666                     PL_Proc
667                     )];
668 }
669
670 unless ($define{'PERL_OLD_COPY_ON_WRITE'}) {
671     skip_symbols [qw(
672                     Perl_sv_setsv_cow
673                   )];
674 }
675
676 unless ($define{'USE_REENTRANT_API'}) {
677     skip_symbols [qw(
678                     PL_reentrant_buffer
679                     )];
680 }
681
682 if ($define{'MYMALLOC'}) {
683     emit_symbols [qw(
684                     Perl_dump_mstats
685                     Perl_get_mstats
686                     Perl_strdup
687                     Perl_putenv
688                     MallocCfg_ptr
689                     MallocCfgP_ptr
690                     )];
691     if ($define{'USE_ITHREADS'}) {
692         emit_symbols [qw(
693                         PL_malloc_mutex
694                         )];
695     }
696     else {
697         skip_symbols [qw(
698                         PL_malloc_mutex
699                         )];
700     }
701 }
702 else {
703     skip_symbols [qw(
704                     PL_malloc_mutex
705                     Perl_dump_mstats
706                     Perl_get_mstats
707                     Perl_malloced_size
708                     Perl_malloc_good_size
709                     MallocCfg_ptr
710                     MallocCfgP_ptr
711                     )];
712 }
713
714 if ($define{'PERL_USE_SAFE_PUTENV'}) {
715     skip_symbols [qw(
716                    PL_use_safe_putenv
717                   )];
718 }
719
720 unless ($define{'USE_ITHREADS'}) {
721     skip_symbols [qw(
722                     PL_thr_key
723                     )];
724 }
725
726 # USE_5005THREADS symbols. Kept as reference for easier removal
727     skip_symbols [qw(
728                     PL_sv_mutex
729                     PL_strtab_mutex
730                     PL_svref_mutex
731                     PL_cred_mutex
732                     PL_eval_mutex
733                     PL_fdpid_mutex
734                     PL_sv_lock_mutex
735                     PL_eval_cond
736                     PL_eval_owner
737                     PL_threads_mutex
738                     PL_nthreads
739                     PL_nthreads_cond
740                     PL_threadnum
741                     PL_threadsv_names
742                     PL_thrsv
743                     PL_vtbl_mutex
744                     Perl_condpair_magic
745                     Perl_new_struct_thread
746                     Perl_per_thread_magicals
747                     Perl_thread_create
748                     Perl_find_threadsv
749                     Perl_unlock_condpair
750                     Perl_magic_mutexfree
751                     Perl_sv_lock
752                     )];
753
754 unless ($define{'USE_ITHREADS'}) {
755     skip_symbols [qw(
756                     PL_op_mutex
757                     PL_regex_pad
758                     PL_regex_padav
759                     PL_sharedsv_space
760                     PL_sharedsv_space_mutex
761                     PL_dollarzero_mutex
762                     PL_hints_mutex
763                     PL_perlio_mutex
764                     PL_regdupe
765                     Perl_parser_dup
766                     Perl_dirp_dup
767                     Perl_cx_dup
768                     Perl_si_dup
769                     Perl_any_dup
770                     Perl_ss_dup
771                     Perl_fp_dup
772                     Perl_gp_dup
773                     Perl_he_dup
774                     Perl_mg_dup
775                     Perl_mro_meta_dup
776                     Perl_re_dup_guts
777                     Perl_sv_dup
778                     Perl_rvpv_dup
779                     Perl_hek_dup
780                     Perl_sys_intern_dup
781                     perl_clone
782                     perl_clone_using
783                     Perl_sharedsv_find
784                     Perl_sharedsv_init
785                     Perl_sharedsv_lock
786                     Perl_sharedsv_new
787                     Perl_sharedsv_thrcnt_dec
788                     Perl_sharedsv_thrcnt_inc
789                     Perl_sharedsv_unlock
790                     Perl_stashpv_hvname_match
791                     Perl_regdupe_internal
792                     Perl_newPADOP
793                     )];
794 }
795
796 unless ($define{'PERL_IMPLICIT_CONTEXT'}) {
797     skip_symbols [qw(
798                     PL_my_ctx_mutex
799                     PL_my_cxt_index
800                     PL_my_cxt_list
801                     PL_my_cxt_size
802                     PL_my_cxt_keys
803                     Perl_croak_nocontext
804                     Perl_die_nocontext
805                     Perl_deb_nocontext
806                     Perl_form_nocontext
807                     Perl_load_module_nocontext
808                     Perl_mess_nocontext
809                     Perl_warn_nocontext
810                     Perl_warner_nocontext
811                     Perl_newSVpvf_nocontext
812                     Perl_sv_catpvf_nocontext
813                     Perl_sv_setpvf_nocontext
814                     Perl_sv_catpvf_mg_nocontext
815                     Perl_sv_setpvf_mg_nocontext
816                     Perl_my_cxt_init
817                     Perl_my_cxt_index
818                     )];
819 }
820
821 unless ($define{'PERL_IMPLICIT_SYS'}) {
822     skip_symbols [qw(
823                     perl_alloc_using
824                     perl_clone_using
825                     )];
826 }
827
828 unless ($define{'FAKE_THREADS'}) {
829     skip_symbols [qw(PL_curthr)];
830 }
831
832 unless ($define{'PL_OP_SLAB_ALLOC'}) {
833     skip_symbols [qw(
834                      PL_OpPtr
835                      PL_OpSlab
836                      PL_OpSpace
837                      Perl_Slab_Alloc
838                      Perl_Slab_Free
839                     )];
840 }
841
842 unless ($define{'PERL_DEBUG_READONLY_OPS'}) {
843     skip_symbols [qw(
844                     PL_slab_count
845                     PL_slabs
846                   )];
847 }
848
849 unless ($define{'THREADS_HAVE_PIDS'}) {
850     skip_symbols [qw(PL_ppid)];
851 }
852
853 unless ($define{'PERL_NEED_APPCTX'}) {
854     skip_symbols [qw(
855                     PL_appctx
856                     )];
857 }
858
859 unless ($define{'PERL_NEED_TIMESBASE'}) {
860     skip_symbols [qw(
861                     PL_timesbase
862                     )];
863 }
864
865 unless ($define{'DEBUG_LEAKING_SCALARS'}) {
866     skip_symbols [qw(
867                     PL_sv_serial
868                     )];
869 }
870
871 unless ($define{'DEBUG_LEAKING_SCALARS_FORK_DUMP'}) {
872     skip_symbols [qw(
873                     PL_dumper_fd
874                     )];
875 }
876 unless ($define{'PERL_DONT_CREATE_GVSV'}) {
877     skip_symbols [qw(
878                      Perl_gv_SVadd
879                     )];
880 }
881 if ($define{'SPRINTF_RETURNS_STRLEN'}) {
882     skip_symbols [qw(
883                      Perl_my_sprintf
884                     )];
885 }
886 unless ($define{'PERL_USES_PL_PIDSTATUS'}) {
887     skip_symbols [qw(
888                      Perl_pidgone
889                      PL_pidstatus
890                     )];
891 }
892
893 unless ($define{'PERL_TRACK_MEMPOOL'}) {
894     skip_symbols [qw(
895                      PL_memory_debug_header
896                     )];
897 }
898
899 if ($define{'PERL_MAD'}) {
900     skip_symbols [qw(
901                      PL_nextval
902                      PL_nexttype
903                      )];
904 } else {
905     skip_symbols [qw(
906                     PL_madskills
907                     PL_xmlfp
908                     PL_lasttoke
909                     PL_realtokenstart
910                     PL_faketokens
911                     PL_thismad
912                     PL_thistoken
913                     PL_thisopen
914                     PL_thisstuff
915                     PL_thisclose
916                     PL_thiswhite
917                     PL_nextwhite
918                     PL_skipwhite
919                     PL_endwhite
920                     PL_curforce
921                     Perl_pad_peg
922                     Perl_xmldump_indent
923                     Perl_xmldump_vindent
924                     Perl_xmldump_all
925                     Perl_xmldump_packsubs
926                     Perl_xmldump_sub
927                     Perl_xmldump_form
928                     Perl_xmldump_eval
929                     Perl_sv_catxmlsv
930                     Perl_sv_catxmlpvn
931                     Perl_sv_xmlpeek
932                     Perl_do_pmop_xmldump
933                     Perl_pmop_xmldump
934                     Perl_do_op_xmldump
935                     Perl_op_xmldump
936                     )];
937 }
938
939 unless ($define{'MULTIPLICITY'}) {
940     skip_symbols [qw(
941                     PL_interp_size
942                     PL_interp_size_5_10_0
943                     )];
944 }
945
946 unless ($define{'PERL_GLOBAL_STRUCT'}) {
947     skip_symbols [qw(
948                     PL_global_struct_size
949                     )];
950 }
951
952 unless ($define{'PERL_GLOBAL_STRUCT_PRIVATE'}) {
953     skip_symbols [qw(
954                     PL_my_cxt_keys
955                     Perl_my_cxt_index
956                     )];
957 }
958
959 unless ($define{'d_mmap'}) {
960     skip_symbols [qw(
961                     PL_mmap_page_size
962                     )];
963 }
964
965 if ($define{'d_sigaction'}) {
966     skip_symbols [qw(
967                     PL_sig_trapped
968                     )];
969 }
970
971 if ($^O ne 'vms') {
972     # VMS does its own thing for these symbols.
973     skip_symbols [qw(PL_sig_handlers_initted
974                      PL_sig_ignoring
975                      PL_sig_defaulting)];
976 }  
977
978 sub readvar {
979     my $file = shift;
980     my $proc = shift || sub { "PL_$_[2]" };
981     open(VARS,$file) || die "Cannot open $file: $!\n";
982     my @syms;
983     while (<VARS>) {
984         # All symbols have a Perl_ prefix because that's what embed.h
985         # sticks in front of them.  The A?I?S?C? is strictly speaking
986         # wrong.
987         push(@syms, &$proc($1,$2,$3)) if (/\bPERLVAR(A?I?S?C?)\(([IGT])(\w+)/);
988     }
989     close(VARS);
990     return \@syms;
991 }
992
993 if ($define{'PERL_GLOBAL_STRUCT'}) {
994     my $global = readvar($perlvars_h);
995     skip_symbols $global;
996     emit_symbol('Perl_GetVars');
997     emit_symbols [qw(PL_Vars PL_VarsPtr)] unless $CCTYPE eq 'GCC';
998 } else {
999     skip_symbols [qw(Perl_init_global_struct Perl_free_global_struct)];
1000 }
1001
1002 # functions from *.sym files
1003
1004 my @syms = ($global_sym, $globvar_sym); # $pp_sym is not part of the API
1005
1006 # Symbols that are the public face of the PerlIO layers implementation
1007 # These are in _addition to_ the public face of the abstraction
1008 # and need to be exported to allow XS modules to implement layers
1009 my @layer_syms = qw(
1010                     PerlIOBase_binmode
1011                     PerlIOBase_clearerr
1012                     PerlIOBase_close
1013                     PerlIOBase_dup
1014                     PerlIOBase_eof
1015                     PerlIOBase_error
1016                     PerlIOBase_fileno
1017                     PerlIOBase_noop_fail
1018                     PerlIOBase_noop_ok
1019                     PerlIOBase_popped
1020                     PerlIOBase_pushed
1021                     PerlIOBase_read
1022                     PerlIOBase_setlinebuf
1023                     PerlIOBase_unread
1024                     PerlIOBuf_bufsiz
1025                     PerlIOBuf_close
1026                     PerlIOBuf_dup
1027                     PerlIOBuf_fill
1028                     PerlIOBuf_flush
1029                     PerlIOBuf_get_base
1030                     PerlIOBuf_get_cnt
1031                     PerlIOBuf_get_ptr
1032                     PerlIOBuf_open
1033                     PerlIOBuf_popped
1034                     PerlIOBuf_pushed
1035                     PerlIOBuf_read
1036                     PerlIOBuf_seek
1037                     PerlIOBuf_set_ptrcnt
1038                     PerlIOBuf_tell
1039                     PerlIOBuf_unread
1040                     PerlIOBuf_write
1041                     PerlIO_allocate
1042                     PerlIO_apply_layera
1043                     PerlIO_apply_layers
1044                     PerlIO_arg_fetch
1045                     PerlIO_debug
1046                     PerlIO_define_layer
1047                     PerlIO_find_layer
1048                     PerlIO_isutf8
1049                     PerlIO_layer_fetch
1050                     PerlIO_list_alloc
1051                     PerlIO_list_free
1052                     PerlIO_modestr
1053                     PerlIO_parse_layers
1054                     PerlIO_pending
1055                     PerlIO_perlio
1056                     PerlIO_pop
1057                     PerlIO_push
1058                     PerlIO_sv_dup
1059                     Perl_PerlIO_clearerr
1060                     Perl_PerlIO_close
1061                     Perl_PerlIO_context_layers
1062                     Perl_PerlIO_eof
1063                     Perl_PerlIO_error
1064                     Perl_PerlIO_fileno
1065                     Perl_PerlIO_fill
1066                     Perl_PerlIO_flush
1067                     Perl_PerlIO_get_base
1068                     Perl_PerlIO_get_bufsiz
1069                     Perl_PerlIO_get_cnt
1070                     Perl_PerlIO_get_ptr
1071                     Perl_PerlIO_read
1072                     Perl_PerlIO_seek
1073                     Perl_PerlIO_set_cnt
1074                     Perl_PerlIO_set_ptrcnt
1075                     Perl_PerlIO_setlinebuf
1076                     Perl_PerlIO_stderr
1077                     Perl_PerlIO_stdin
1078                     Perl_PerlIO_stdout
1079                     Perl_PerlIO_tell
1080                     Perl_PerlIO_unread
1081                     Perl_PerlIO_write
1082 );
1083 if ($PLATFORM eq 'netware') {
1084     push(@layer_syms,'PL_def_layerlist','PL_known_layers','PL_perlio');
1085 }
1086
1087 if ($define{'USE_PERLIO'}) {
1088     # Export the symols that make up the PerlIO abstraction, regardless
1089     # of its implementation - read from a file
1090     push @syms, $perlio_sym;
1091
1092     # This part is then dependent on how the abstraction is implemented
1093     if ($define{'USE_SFIO'}) {
1094         # Old legacy non-stdio "PerlIO"
1095         skip_symbols \@layer_syms;
1096         skip_symbols [qw(perlsio_binmode)];
1097         # SFIO defines most of the PerlIO routines as macros
1098         # So undo most of what $perlio_sym has just done - d'oh !
1099         # Perhaps it would be better to list the ones which do exist
1100         # And emit them
1101         skip_symbols [qw(
1102                          PerlIO_canset_cnt
1103                          PerlIO_clearerr
1104                          PerlIO_close
1105                          PerlIO_eof
1106                          PerlIO_error
1107                          PerlIO_exportFILE
1108                          PerlIO_fast_gets
1109                          PerlIO_fdopen
1110                          PerlIO_fileno
1111                          PerlIO_findFILE
1112                          PerlIO_flush
1113                          PerlIO_get_base
1114                          PerlIO_get_bufsiz
1115                          PerlIO_get_cnt
1116                          PerlIO_get_ptr
1117                          PerlIO_getc
1118                          PerlIO_getname
1119                          PerlIO_has_base
1120                          PerlIO_has_cntptr
1121                          PerlIO_importFILE
1122                          PerlIO_open
1123                          PerlIO_printf
1124                          PerlIO_putc
1125                          PerlIO_puts
1126                          PerlIO_read
1127                          PerlIO_releaseFILE
1128                          PerlIO_reopen
1129                          PerlIO_rewind
1130                          PerlIO_seek
1131                          PerlIO_set_cnt
1132                          PerlIO_set_ptrcnt
1133                          PerlIO_setlinebuf
1134                          PerlIO_sprintf
1135                          PerlIO_stderr
1136                          PerlIO_stdin
1137                          PerlIO_stdout
1138                          PerlIO_stdoutf
1139                          PerlIO_tell
1140                          PerlIO_ungetc
1141                          PerlIO_vprintf
1142                          PerlIO_write
1143                          PerlIO_perlio
1144                          Perl_PerlIO_clearerr
1145                          Perl_PerlIO_close
1146                          Perl_PerlIO_eof
1147                          Perl_PerlIO_error
1148                          Perl_PerlIO_fileno
1149                          Perl_PerlIO_fill
1150                          Perl_PerlIO_flush
1151                          Perl_PerlIO_get_base
1152                          Perl_PerlIO_get_bufsiz
1153                          Perl_PerlIO_get_cnt
1154                          Perl_PerlIO_get_ptr
1155                          Perl_PerlIO_read
1156                          Perl_PerlIO_seek
1157                          Perl_PerlIO_set_cnt
1158                          Perl_PerlIO_set_ptrcnt
1159                          Perl_PerlIO_setlinebuf
1160                          Perl_PerlIO_stderr
1161                          Perl_PerlIO_stdin
1162                          Perl_PerlIO_stdout
1163                          Perl_PerlIO_tell
1164                          Perl_PerlIO_unread
1165                          Perl_PerlIO_write
1166                          PL_def_layerlist
1167                          PL_known_layers
1168                          PL_perlio
1169                          )];
1170     }
1171     else {
1172         # PerlIO with layers - export implementation
1173         emit_symbols \@layer_syms;
1174         emit_symbols [qw(perlsio_binmode)];
1175     }
1176     if ($define{'USE_ITHREADS'}) {
1177         emit_symbols [qw(
1178                         PL_perlio_mutex
1179                         )];
1180     }
1181     else {
1182         skip_symbols [qw(
1183                         PL_perlio_mutex
1184                         )];
1185     }
1186 } else {
1187         # -Uuseperlio
1188         # Skip the PerlIO layer symbols - although
1189         # nothing should have exported them anyway.
1190         skip_symbols \@layer_syms;
1191         skip_symbols [qw(
1192                         perlsio_binmode
1193                         PL_def_layerlist
1194                         PL_known_layers
1195                         PL_perlio
1196                         PL_perlio_debug_fd
1197                         PL_perlio_fd_refcnt
1198                         PL_perlio_fd_refcnt_size
1199                         )];
1200
1201         # Also do NOT add abstraction symbols from $perlio_sym
1202         # abstraction is done as #define to stdio
1203         # Remaining remnants that _may_ be functions
1204         # are handled in <DATA>
1205 }
1206
1207 for my $syms (@syms) {
1208     open (GLOBAL, "<$syms") || die "failed to open $syms: $!\n";
1209     while (<GLOBAL>) {
1210         next if (!/^[A-Za-z]/);
1211         # Functions have a Perl_ prefix
1212         # Variables have a PL_ prefix
1213         chomp($_);
1214         my $symbol = ($syms =~ /var\.sym$/i ? "PL_" : "");
1215         $symbol .= $_;
1216         emit_symbol($symbol) unless exists $skip{$symbol};
1217     }
1218     close(GLOBAL);
1219 }
1220
1221 # variables
1222
1223 if ($define{'MULTIPLICITY'}) {
1224     for my $f ($perlvars_h, $intrpvar_h) {
1225         my $glob = readvar($f, sub { "Perl_" . $_[1] . $_[2] . "_ptr" });
1226         emit_symbols $glob;
1227     }
1228     # XXX AIX seems to want the perlvars.h symbols, for some reason
1229     if ($PLATFORM eq 'aix' or $PLATFORM eq 'os2') {     # OS/2 needs PL_thr_key
1230         my $glob = readvar($perlvars_h);
1231         emit_symbols $glob;
1232     }
1233 }
1234 else {
1235     unless ($define{'PERL_GLOBAL_STRUCT'}) {
1236         my $glob = readvar($perlvars_h);
1237         emit_symbols $glob;
1238     }
1239     unless ($define{'MULTIPLICITY'}) {
1240         my $glob = readvar($intrpvar_h);
1241         emit_symbols $glob;
1242     }
1243 }
1244
1245 sub try_symbol {
1246     my $symbol = shift;
1247
1248     return if $symbol !~ /^[A-Za-z_]/;
1249     return if $symbol =~ /^\#/;
1250     $symbol =~s/\r//g;
1251     chomp($symbol);
1252     return if exists $skip{$symbol};
1253     emit_symbol($symbol);
1254 }
1255
1256 while (<DATA>) {
1257     try_symbol($_);
1258 }
1259
1260 if ($PLATFORM =~ /^win(?:32|ce)$/) {
1261     foreach my $symbol (qw(
1262                             setuid
1263                             setgid
1264                             boot_DynaLoader
1265                             Perl_init_os_extras
1266                             Perl_thread_create
1267                             Perl_win32_init
1268                             Perl_win32_term
1269                             RunPerl
1270                             win32_async_check
1271                             win32_errno
1272                             win32_environ
1273                             win32_abort
1274                             win32_fstat
1275                             win32_stat
1276                             win32_pipe
1277                             win32_popen
1278                             win32_pclose
1279                             win32_rename
1280                             win32_setmode
1281                             win32_chsize
1282                             win32_lseek
1283                             win32_tell
1284                             win32_dup
1285                             win32_dup2
1286                             win32_open
1287                             win32_close
1288                             win32_eof
1289                             win32_read
1290                             win32_write
1291                             win32_spawnvp
1292                             win32_mkdir
1293                             win32_rmdir
1294                             win32_chdir
1295                             win32_flock
1296                             win32_execv
1297                             win32_execvp
1298                             win32_htons
1299                             win32_ntohs
1300                             win32_htonl
1301                             win32_ntohl
1302                             win32_inet_addr
1303                             win32_inet_ntoa
1304                             win32_socket
1305                             win32_bind
1306                             win32_listen
1307                             win32_accept
1308                             win32_connect
1309                             win32_send
1310                             win32_sendto
1311                             win32_recv
1312                             win32_recvfrom
1313                             win32_shutdown
1314                             win32_closesocket
1315                             win32_ioctlsocket
1316                             win32_setsockopt
1317                             win32_getsockopt
1318                             win32_getpeername
1319                             win32_getsockname
1320                             win32_gethostname
1321                             win32_gethostbyname
1322                             win32_gethostbyaddr
1323                             win32_getprotobyname
1324                             win32_getprotobynumber
1325                             win32_getservbyname
1326                             win32_getservbyport
1327                             win32_select
1328                             win32_endhostent
1329                             win32_endnetent
1330                             win32_endprotoent
1331                             win32_endservent
1332                             win32_getnetent
1333                             win32_getnetbyname
1334                             win32_getnetbyaddr
1335                             win32_getprotoent
1336                             win32_getservent
1337                             win32_sethostent
1338                             win32_setnetent
1339                             win32_setprotoent
1340                             win32_setservent
1341                             win32_getenv
1342                             win32_putenv
1343                             win32_perror
1344                             win32_malloc
1345                             win32_calloc
1346                             win32_realloc
1347                             win32_free
1348                             win32_sleep
1349                             win32_times
1350                             win32_access
1351                             win32_alarm
1352                             win32_chmod
1353                             win32_open_osfhandle
1354                             win32_get_osfhandle
1355                             win32_ioctl
1356                             win32_link
1357                             win32_unlink
1358                             win32_utime
1359                             win32_gettimeofday
1360                             win32_uname
1361                             win32_wait
1362                             win32_waitpid
1363                             win32_kill
1364                             win32_str_os_error
1365                             win32_opendir
1366                             win32_readdir
1367                             win32_telldir
1368                             win32_seekdir
1369                             win32_rewinddir
1370                             win32_closedir
1371                             win32_longpath
1372                             win32_ansipath
1373                             win32_os_id
1374                             win32_getpid
1375                             win32_crypt
1376                             win32_dynaload
1377                             win32_get_childenv
1378                             win32_free_childenv
1379                             win32_clearenv
1380                             win32_get_childdir
1381                             win32_free_childdir
1382                             win32_stdin
1383                             win32_stdout
1384                             win32_stderr
1385                             win32_ferror
1386                             win32_feof
1387                             win32_strerror
1388                             win32_fprintf
1389                             win32_printf
1390                             win32_vfprintf
1391                             win32_vprintf
1392                             win32_fread
1393                             win32_fwrite
1394                             win32_fopen
1395                             win32_fdopen
1396                             win32_freopen
1397                             win32_fclose
1398                             win32_fputs
1399                             win32_fputc
1400                             win32_ungetc
1401                             win32_getc
1402                             win32_fileno
1403                             win32_clearerr
1404                             win32_fflush
1405                             win32_ftell
1406                             win32_fseek
1407                             win32_fgetpos
1408                             win32_fsetpos
1409                             win32_rewind
1410                             win32_tmpfile
1411                             win32_setbuf
1412                             win32_setvbuf
1413                             win32_flushall
1414                             win32_fcloseall
1415                             win32_fgets
1416                             win32_gets
1417                             win32_fgetc
1418                             win32_putc
1419                             win32_puts
1420                             win32_getchar
1421                             win32_putchar
1422                            ))
1423     {
1424         try_symbol($symbol);
1425     }
1426     if ($CCTYPE eq "BORLAND") {
1427         try_symbol('_matherr');
1428     }
1429 }
1430 elsif ($PLATFORM eq 'os2') {
1431     my (%mapped, @missing);
1432     open MAP, 'miniperl.map' or die 'Cannot read miniperl.map';
1433     /^\s*[\da-f:]+\s+(\w+)/i and $mapped{$1}++ foreach <MAP>;
1434     close MAP or die 'Cannot close miniperl.map';
1435
1436     @missing = grep { !exists $mapped{$_} }
1437                     keys %export;
1438     @missing = grep { !exists $exportperlmalloc{$_} } @missing;
1439     delete $export{$_} foreach @missing;
1440 }
1441 elsif ($PLATFORM eq 'MacOS') {
1442     open MACSYMS, 'macperl.sym' or die 'Cannot read macperl.sym';
1443
1444     while (<MACSYMS>) {
1445         try_symbol($_);
1446     }
1447
1448     close MACSYMS;
1449 }
1450 elsif ($PLATFORM eq 'netware') {
1451 foreach my $symbol (qw(
1452                         boot_DynaLoader
1453                         Perl_init_os_extras
1454                         Perl_thread_create
1455                         Perl_nw5_init
1456                         RunPerl
1457                         AllocStdPerl
1458                         FreeStdPerl
1459                         do_spawn2
1460                         do_aspawn
1461                         nw_uname
1462                         nw_stdin
1463                         nw_stdout
1464                         nw_stderr
1465                         nw_feof
1466                         nw_ferror
1467                         nw_fopen
1468                         nw_fclose
1469                         nw_clearerr
1470                         nw_getc
1471                         nw_fgets
1472                         nw_fputc
1473                         nw_fputs
1474                         nw_fflush
1475                         nw_ungetc
1476                         nw_fileno
1477                         nw_fdopen
1478                         nw_freopen
1479                         nw_fread
1480                         nw_fwrite
1481                         nw_setbuf
1482                         nw_setvbuf
1483                         nw_vfprintf
1484                         nw_ftell
1485                         nw_fseek
1486                         nw_rewind
1487                         nw_tmpfile
1488                         nw_fgetpos
1489                         nw_fsetpos
1490                         nw_dup
1491                         nw_access
1492                         nw_chmod
1493                         nw_chsize
1494                         nw_close
1495                         nw_dup2
1496                         nw_flock
1497                         nw_isatty
1498                         nw_link
1499                         nw_lseek
1500                         nw_stat
1501                         nw_mktemp
1502                         nw_open
1503                         nw_read
1504                         nw_rename
1505                         nw_setmode
1506                         nw_unlink
1507                         nw_utime
1508                         nw_write
1509                         nw_chdir
1510                         nw_rmdir
1511                         nw_closedir
1512                         nw_opendir
1513                         nw_readdir
1514                         nw_rewinddir
1515                         nw_seekdir
1516                         nw_telldir
1517                         nw_htonl
1518                         nw_htons
1519                         nw_ntohl
1520                         nw_ntohs
1521                         nw_accept
1522                         nw_bind
1523                         nw_connect
1524                         nw_endhostent
1525                         nw_endnetent
1526                         nw_endprotoent
1527                         nw_endservent
1528                         nw_gethostbyaddr
1529                         nw_gethostbyname
1530                         nw_gethostent
1531                         nw_gethostname
1532                         nw_getnetbyaddr
1533                         nw_getnetbyname
1534                         nw_getnetent
1535                         nw_getpeername
1536                         nw_getprotobyname
1537                         nw_getprotobynumber
1538                         nw_getprotoent
1539                         nw_getservbyname
1540                         nw_getservbyport
1541                         nw_getservent
1542                         nw_getsockname
1543                         nw_getsockopt
1544                         nw_inet_addr
1545                         nw_listen
1546                         nw_socket
1547                         nw_recv
1548                         nw_recvfrom
1549                         nw_select
1550                         nw_send
1551                         nw_sendto
1552                         nw_sethostent
1553                         nw_setnetent
1554                         nw_setprotoent
1555                         nw_setservent
1556                         nw_setsockopt
1557                         nw_inet_ntoa
1558                         nw_shutdown
1559                         nw_crypt
1560                         nw_execvp
1561                         nw_kill
1562                         nw_Popen
1563                         nw_Pclose
1564                         nw_Pipe
1565                         nw_times
1566                         nw_waitpid
1567                         nw_getpid
1568                         nw_spawnvp
1569                         nw_os_id
1570                         nw_open_osfhandle
1571                         nw_get_osfhandle
1572                         nw_abort
1573                         nw_sleep
1574                         nw_wait
1575                         nw_dynaload
1576                         nw_strerror
1577                         fnFpSetMode
1578                         fnInsertHashListAddrs
1579                         fnGetHashListAddrs
1580                         Perl_deb
1581                         Perl_sv_setsv
1582                         Perl_sv_catsv
1583                         Perl_sv_catpvn
1584                         Perl_sv_2pv
1585                         nw_freeenviron
1586                         Remove_Thread_Ctx
1587                            ))
1588     {
1589         try_symbol($symbol);
1590     }
1591 }
1592
1593 # records of type boot_module for statically linked modules (except Dynaloader)
1594 $static_ext =~ s/\//__/g;
1595 $static_ext =~ s/\bDynaLoader\b//;
1596 my @stat_mods = map {"boot_$_"} grep {/\S/} split /\s+/, $static_ext;
1597 foreach my $symbol (@stat_mods)
1598     {
1599         try_symbol($symbol);
1600     }
1601
1602 try_symbol("init_Win32CORE") if $static_ext =~ /\bWin32CORE\b/;
1603
1604 # Now all symbols should be defined because
1605 # next we are going to output them.
1606
1607 foreach my $symbol (sort keys %export) {
1608     output_symbol($symbol);
1609 }
1610
1611 if ($PLATFORM eq 'os2') {
1612         print <<EOP;
1613     dll_perlmain=main
1614     fill_extLibpath
1615     dir_subst
1616     Perl_OS2_handler_install
1617
1618 ; LAST_ORDINAL=$sym_ord
1619 EOP
1620 }
1621
1622 sub emit_symbol {
1623     my $symbol = shift;
1624     chomp($symbol);
1625     $export{$symbol} = 1;
1626 }
1627
1628 sub output_symbol {
1629     my $symbol = shift;
1630     if ($PLATFORM =~ /^win(?:32|ce)$/) {
1631         $symbol = "_$symbol" if $CCTYPE eq 'BORLAND';
1632         print "\t$symbol\n";
1633 # XXX: binary compatibility between compilers is an exercise
1634 # in frustration :-(
1635 #        if ($CCTYPE eq "BORLAND") {
1636 #           # workaround Borland quirk by exporting both the straight
1637 #           # name and a name with leading underscore.  Note the
1638 #           # alias *must* come after the symbol itself, if both
1639 #           # are to be exported. (Linker bug?)
1640 #           print "\t_$symbol\n";
1641 #           print "\t$symbol = _$symbol\n";
1642 #       }
1643 #       elsif ($CCTYPE eq 'GCC') {
1644 #           # Symbols have leading _ whole process is $%@"% slow
1645 #           # so skip aliases for now
1646 #           nprint "\t$symbol\n";
1647 #       }
1648 #       else {
1649 #           # for binary coexistence, export both the symbol and
1650 #           # alias with leading underscore
1651 #           print "\t$symbol\n";
1652 #           print "\t_$symbol = $symbol\n";
1653 #       }
1654     }
1655     elsif ($PLATFORM eq 'os2') {
1656         printf qq(    %-31s \@%s\n),
1657           qq("$symbol"), $ordinal{$symbol} || ++$sym_ord;
1658         printf qq(    %-31s \@%s\n),
1659           qq("$exportperlmalloc{$symbol}" = "$symbol"),
1660           $ordinal{$exportperlmalloc{$symbol}} || ++$sym_ord
1661           if $exportperlmalloc and exists $exportperlmalloc{$symbol};
1662     }
1663     elsif ($PLATFORM eq 'aix' || $PLATFORM eq 'MacOS') {
1664         print "$symbol\n";
1665     }
1666         elsif ($PLATFORM eq 'netware') {
1667         print "\t$symbol,\n";
1668         }
1669 }
1670
1671 1;
1672 __DATA__
1673 # Oddities from PerlIO
1674 PerlIO_binmode
1675 PerlIO_getpos
1676 PerlIO_init
1677 PerlIO_setpos
1678 PerlIO_sprintf
1679 PerlIO_sv_dup
1680 PerlIO_tmpfile
1681 PerlIO_vsprintf