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