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