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