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