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