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