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