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