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