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