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