Re: [ID 20010608.010] File::Find re-entrancy
[p5sagit/p5-mst-13.2.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 as well
10
11 my $PLATFORM;
12 my $CCTYPE;
13
14 my %bincompat5005 =
15       (
16        Perl_call_atexit         =>      "perl_atexit",
17        Perl_eval_sv             =>      "perl_eval_sv",
18        Perl_eval_pv             =>      "perl_eval_pv",
19        Perl_call_argv           =>      "perl_call_argv",
20        Perl_call_method         =>      "perl_call_method",
21        Perl_call_pv             =>      "perl_call_pv",
22        Perl_call_sv             =>      "perl_call_sv",
23        Perl_get_av              =>      "perl_get_av",
24        Perl_get_cv              =>      "perl_get_cv",
25        Perl_get_hv              =>      "perl_get_hv",
26        Perl_get_sv              =>      "perl_get_sv",
27        Perl_init_i18nl10n       =>      "perl_init_i18nl10n",
28        Perl_init_i18nl14n       =>      "perl_init_i18nl14n",
29        Perl_new_collate         =>      "perl_new_collate",
30        Perl_new_ctype           =>      "perl_new_ctype",
31        Perl_new_numeric         =>      "perl_new_numeric",
32        Perl_require_pv          =>      "perl_require_pv",
33        Perl_safesyscalloc       =>      "Perl_safecalloc",
34        Perl_safesysfree         =>      "Perl_safefree",
35        Perl_safesysmalloc       =>      "Perl_safemalloc",
36        Perl_safesysrealloc      =>      "Perl_saferealloc",
37        Perl_set_numeric_local   =>      "perl_set_numeric_local",
38        Perl_set_numeric_standard  =>    "perl_set_numeric_standard",
39        Perl_malloc              =>      "malloc",
40        Perl_mfree               =>      "free",
41        Perl_realloc             =>      "realloc",
42        Perl_calloc              =>      "calloc",
43       );
44
45 my $bincompat5005 = join("|", keys %bincompat5005);
46
47 while (@ARGV) {
48     my $flag = shift;
49     $define{$1} = 1 if ($flag =~ /^-D(\w+)$/);
50     $define{$1} = $2 if ($flag =~ /^-D(\w+)=(.+)$/);
51     $CCTYPE   = $1 if ($flag =~ /^CCTYPE=(\w+)$/);
52     $PLATFORM = $1 if ($flag =~ /^PLATFORM=(\w+)$/);
53 }
54
55 my @PLATFORM = qw(aix win32 os2 MacOS);
56 my %PLATFORM;
57 @PLATFORM{@PLATFORM} = ();
58
59 defined $PLATFORM || die "PLATFORM undefined, must be one of: @PLATFORM\n";
60 exists $PLATFORM{$PLATFORM} || die "PLATFORM must be one of: @PLATFORM\n";
61
62 my $config_sh   = "config.sh";
63 my $config_h    = "config.h";
64 my $thrdvar_h   = "thrdvar.h";
65 my $intrpvar_h  = "intrpvar.h";
66 my $perlvars_h  = "perlvars.h";
67 my $global_sym  = "global.sym";
68 my $pp_sym      = "pp.sym";
69 my $globvar_sym = "globvar.sym";
70 my $perlio_sym  = "perlio.sym";
71
72 if ($PLATFORM eq 'aix') {
73     # Nothing for now.
74 }
75 elsif ($PLATFORM eq 'win32') {
76     $CCTYPE = "MSVC" unless defined $CCTYPE;
77     foreach ($thrdvar_h, $intrpvar_h, $perlvars_h, $global_sym,
78                 $pp_sym, $globvar_sym, $perlio_sym) {
79         s!^!..\\!;
80     }
81 }
82 elsif ($PLATFORM eq 'MacOS') {
83     foreach ($thrdvar_h, $intrpvar_h, $perlvars_h, $global_sym,
84                 $pp_sym, $globvar_sym, $perlio_sym) {
85         s!^!::!;
86     }
87 }
88
89 unless ($PLATFORM eq 'win32' || $PLATFORM eq 'MacOS') {
90     open(CFG,$config_sh) || die "Cannot open $config_sh: $!\n";
91     while (<CFG>) {
92         if (/^(?:ccflags|optimize)='(.+)'$/) {
93             $_ = $1;
94             $define{$1} = 1 while /-D(\w+)/g;
95         }
96         if ($PLATFORM eq 'os2') {
97             $CONFIG_ARGS = $1 if /^(?:config_args)='(.+)'$/;
98             $ARCHNAME =    $1 if /^(?:archname)='(.+)'$/;
99         }
100     }
101     close(CFG);
102 }
103
104 open(CFG,$config_h) || die "Cannot open $config_h: $!\n";
105 while (<CFG>) {
106     $define{$1} = 1 if /^\s*#\s*define\s+(MYMALLOC)\b/;
107     $define{$1} = 1 if /^\s*#\s*define\s+(MULTIPLICITY)\b/;
108     $define{$1} = 1 if /^\s*#\s*define\s+(PERL_\w+)\b/;
109     $define{$1} = 1 if /^\s*#\s*define\s+(USE_\w+)\b/;
110 }
111 close(CFG);
112
113 # perl.h logic duplication begins
114
115 if ($define{USE_ITHREADS}) {
116     if (!$define{MULTIPLICITY} && !$define{PERL_OBJECT}) {
117         $define{MULTIPLICITY} = 1;
118     }
119 }
120
121 $define{PERL_IMPLICIT_CONTEXT} ||=
122     $define{USE_ITHREADS} ||
123     $define{USE_5005THREADS}  ||
124     $define{MULTIPLICITY} ;
125
126 if ($define{PERL_CAPI}) {
127     delete $define{PERL_OBJECT};
128     $define{MULTIPLICITY} = 1;
129     $define{PERL_IMPLICIT_CONTEXT} = 1;
130     $define{PERL_IMPLICIT_SYS}     = 1;
131 }
132
133 if ($define{PERL_OBJECT}) {
134     $define{PERL_IMPLICIT_CONTEXT} = 1;
135     $define{PERL_IMPLICIT_SYS}     = 1;
136 }
137
138 # perl.h logic duplication ends
139
140 if ($PLATFORM eq 'win32') {
141     warn join(' ',keys %define)."\n";
142     print "LIBRARY Perl57\n";
143     print "DESCRIPTION 'Perl interpreter'\n";
144     print "EXPORTS\n";
145     if ($define{PERL_IMPLICIT_SYS}) {
146         output_symbol("perl_get_host_info");
147         output_symbol("perl_alloc_override");
148     }
149 }
150 elsif ($PLATFORM eq 'os2') {
151     ($v = $]) =~ s/(\d\.\d\d\d)(\d\d)$/$1_$2/;
152     $v .= '-thread' if $ARCHNAME =~ /-thread/;
153     ($dll = $define{PERL_DLL}) =~ s/\.dll$//i;
154     $d = "DESCRIPTION '\@#perl5-porters\@perl.org:$v#\@ Perl interpreter, configured as $CONFIG_ARGS'";
155     $d = substr($d, 0, 249) . "...'" if length $d > 253;
156     print <<"---EOP---";
157 LIBRARY '$dll' INITINSTANCE TERMINSTANCE
158 $d
159 STACKSIZE 32768
160 CODE LOADONCALL
161 DATA LOADONCALL NONSHARED MULTIPLE
162 EXPORTS
163 ---EOP---
164 }
165 elsif ($PLATFORM eq 'aix') {
166     $OSVER = `uname -v`;
167     chop $OSVER;
168     $OSREL = `uname -r`;
169     chop $OSREL;
170     if ($OSVER > 4 || ($OSVER == 4 && $OSREL >= 3)) {
171         print "#! ..\n";
172     } else {
173         print "#!\n";
174     }
175 }
176
177 my %skip;
178 my %export;
179
180 sub skip_symbols {
181     my $list = shift;
182     foreach my $symbol (@$list) {
183         $skip{$symbol} = 1;
184     }
185 }
186
187 sub emit_symbols {
188     my $list = shift;
189     foreach my $symbol (@$list) {
190         my $skipsym = $symbol;
191         # XXX hack
192         if ($define{PERL_OBJECT} || $define{MULTIPLICITY}) {
193             $skipsym =~ s/^Perl_[GIT](\w+)_ptr$/PL_$1/;
194         }
195         emit_symbol($symbol) unless exists $skip{$skipsym};
196     }
197 }
198
199 if ($PLATFORM eq 'win32') {
200     skip_symbols [qw(
201                      PL_statusvalue_vms
202                      PL_archpat_auto
203                      PL_cryptseen
204                      PL_DBcv
205                      PL_generation
206                      PL_lastgotoprobe
207                      PL_linestart
208                      PL_modcount
209                      PL_pending_ident
210                      PL_sortcxix
211                      PL_sublex_info
212                      PL_timesbuf
213                      main
214                      Perl_ErrorNo
215                      Perl_GetVars
216                      Perl_do_exec3
217                      Perl_do_ipcctl
218                      Perl_do_ipcget
219                      Perl_do_msgrcv
220                      Perl_do_msgsnd
221                      Perl_do_semop
222                      Perl_do_shmio
223                      Perl_dump_fds
224                      Perl_init_thread_intern
225                      Perl_my_bzero
226                      Perl_my_bcopy
227                      Perl_my_htonl
228                      Perl_my_ntohl
229                      Perl_my_swap
230                      Perl_my_chsize
231                      Perl_same_dirent
232                      Perl_setenv_getix
233                      Perl_unlnk
234                      Perl_watch
235                      Perl_safexcalloc
236                      Perl_safexmalloc
237                      Perl_safexfree
238                      Perl_safexrealloc
239                      Perl_my_memcmp
240                      Perl_my_memset
241                      PL_cshlen
242                      PL_cshname
243                      PL_opsave
244                      Perl_do_exec
245                      Perl_getenv_len
246                      Perl_my_pclose
247                      Perl_my_popen
248                      )];
249 }
250 elsif ($PLATFORM eq 'aix') {
251     skip_symbols([qw(
252                      Perl_dump_fds
253                      Perl_ErrorNo
254                      Perl_GetVars
255                      Perl_my_bcopy
256                      Perl_my_bzero
257                      Perl_my_chsize
258                      Perl_my_htonl
259                      Perl_my_memcmp
260                      Perl_my_memset
261                      Perl_my_ntohl
262                      Perl_my_swap
263                      Perl_safexcalloc
264                      Perl_safexfree
265                      Perl_safexmalloc
266                      Perl_safexrealloc
267                      Perl_same_dirent
268                      Perl_unlnk
269                      Perl_sys_intern_clear
270                      Perl_sys_intern_dup
271                      Perl_sys_intern_init
272                      PL_cryptseen
273                      PL_opsave
274                      PL_statusvalue_vms
275                      PL_sys_intern
276                      )]);
277 }
278 elsif ($PLATFORM eq 'os2') {
279     emit_symbols([qw(
280                     ctermid
281                     get_sysinfo
282                     Perl_OS2_init
283                     OS2_Perl_data
284                     dlopen
285                     dlsym
286                     dlerror
287                     dlclose
288                     my_tmpfile
289                     my_tmpnam
290                     my_flock
291                     my_rmdir
292                     my_mkdir
293                     malloc_mutex
294                     threads_mutex
295                     nthreads
296                     nthreads_cond
297                     os2_cond_wait
298                     os2_stat
299                     pthread_join
300                     pthread_create
301                     pthread_detach
302                     XS_Cwd_change_drive
303                     XS_Cwd_current_drive
304                     XS_Cwd_extLibpath
305                     XS_Cwd_extLibpath_set
306                     XS_Cwd_sys_abspath
307                     XS_Cwd_sys_chdir
308                     XS_Cwd_sys_cwd
309                     XS_Cwd_sys_is_absolute
310                     XS_Cwd_sys_is_relative
311                     XS_Cwd_sys_is_rooted
312                     XS_DynaLoader_mod2fname
313                     XS_File__Copy_syscopy
314                     Perl_Register_MQ
315                     Perl_Deregister_MQ
316                     Perl_Serve_Messages
317                     Perl_Process_Messages
318                     init_PMWIN_entries
319                     PMWIN_entries
320                     Perl_hab_GET
321                     )]);
322 }
323 elsif ($PLATFORM eq 'MacOS') {
324     skip_symbols [qw(
325                     Perl_GetVars
326                     PL_cryptseen
327                     PL_cshlen
328                     PL_cshname
329                     PL_statusvalue_vms
330                     PL_sys_intern
331                     PL_opsave
332                     PL_timesbuf
333                     Perl_dump_fds
334                     Perl_my_bcopy
335                     Perl_my_bzero
336                     Perl_my_chsize
337                     Perl_my_htonl
338                     Perl_my_memcmp
339                     Perl_my_memset
340                     Perl_my_ntohl
341                     Perl_my_swap
342                     Perl_safexcalloc
343                     Perl_safexfree
344                     Perl_safexmalloc
345                     Perl_safexrealloc
346                     Perl_unlnk
347                     Perl_sys_intern_clear
348                     Perl_sys_intern_init
349                     )];
350 }
351
352
353 unless ($define{'DEBUGGING'}) {
354     skip_symbols [qw(
355                     Perl_deb_growlevel
356                     Perl_debop
357                     Perl_debprofdump
358                     Perl_debstack
359                     Perl_debstackptrs
360                     Perl_runops_debug
361                     Perl_sv_peek
362                     PL_block_type
363                     PL_watchaddr
364                     PL_watchok
365                     )];
366 }
367
368 if ($define{'PERL_IMPLICIT_SYS'}) {
369     skip_symbols [qw(
370                     Perl_getenv_len
371                     Perl_my_popen
372                     Perl_my_pclose
373                     )];
374 }
375 else {
376     skip_symbols [qw(
377                     PL_Mem
378                     PL_MemShared
379                     PL_MemParse
380                     PL_Env
381                     PL_StdIO
382                     PL_LIO
383                     PL_Dir
384                     PL_Sock
385                     PL_Proc
386                     )];
387 }
388
389 unless ($define{'PERL_FLEXIBLE_EXCEPTIONS'}) {
390     skip_symbols [qw(
391                     PL_protect
392                     Perl_default_protect
393                     Perl_vdefault_protect
394                     )];
395 }
396
397 if ($define{'MYMALLOC'}) {
398     emit_symbols [qw(
399                     Perl_dump_mstats
400                     Perl_get_mstats
401                     Perl_malloc
402                     Perl_mfree
403                     Perl_realloc
404                     Perl_calloc
405                     Perl_strdup
406                     Perl_putenv
407                     )];
408     if ($define{'USE_5005THREADS'} || $define{'USE_ITHREADS'}) {
409         emit_symbols [qw(
410                         PL_malloc_mutex
411                         )];
412     }
413     else {
414         skip_symbols [qw(
415                         PL_malloc_mutex
416                         )];
417     }
418 }
419 else {
420     skip_symbols [qw(
421                     PL_malloc_mutex
422                     Perl_dump_mstats
423                     Perl_get_mstats
424                     Perl_malloc
425                     Perl_mfree
426                     Perl_realloc
427                     Perl_calloc
428                     Perl_malloced_size
429                     )];
430 }
431
432 unless ($define{'USE_5005THREADS'} || $define{'USE_ITHREADS'}) {
433     skip_symbols [qw(
434                     PL_thr_key
435                     )];
436 }
437
438 unless ($define{'USE_5005THREADS'}) {
439     skip_symbols [qw(
440                     PL_sv_mutex
441                     PL_strtab_mutex
442                     PL_svref_mutex
443                     PL_cred_mutex
444                     PL_eval_mutex
445                     PL_fdpid_mutex
446                     PL_sv_lock_mutex
447                     PL_eval_cond
448                     PL_eval_owner
449                     PL_threads_mutex
450                     PL_nthreads
451                     PL_nthreads_cond
452                     PL_threadnum
453                     PL_threadsv_names
454                     PL_thrsv
455                     PL_vtbl_mutex
456                     Perl_condpair_magic
457                     Perl_new_struct_thread
458                     Perl_per_thread_magicals
459                     Perl_thread_create
460                     Perl_find_threadsv
461                     Perl_unlock_condpair
462                     Perl_magic_mutexfree
463                     Perl_sv_lock
464                     )];
465 }
466
467 unless ($define{'USE_ITHREADS'}) {
468     skip_symbols [qw(
469                     PL_ptr_table
470                     PL_op_mutex
471                     Perl_dirp_dup
472                     Perl_cx_dup
473                     Perl_si_dup
474                     Perl_any_dup
475                     Perl_ss_dup
476                     Perl_fp_dup
477                     Perl_gp_dup
478                     Perl_he_dup
479                     Perl_mg_dup
480                     Perl_re_dup
481                     Perl_sv_dup
482                     Perl_sys_intern_dup
483                     Perl_ptr_table_clear
484                     Perl_ptr_table_fetch
485                     Perl_ptr_table_free
486                     Perl_ptr_table_new
487                     Perl_ptr_table_clear
488                     Perl_ptr_table_free
489                     Perl_ptr_table_split
490                     Perl_ptr_table_store
491                     perl_clone
492                     perl_clone_using
493                     )];
494 }
495
496 unless ($define{'PERL_IMPLICIT_CONTEXT'}) {
497     skip_symbols [qw(
498                     Perl_croak_nocontext
499                     Perl_die_nocontext
500                     Perl_deb_nocontext
501                     Perl_form_nocontext
502                     Perl_load_module_nocontext
503                     Perl_mess_nocontext
504                     Perl_warn_nocontext
505                     Perl_warner_nocontext
506                     Perl_newSVpvf_nocontext
507                     Perl_sv_catpvf_nocontext
508                     Perl_sv_setpvf_nocontext
509                     Perl_sv_catpvf_mg_nocontext
510                     Perl_sv_setpvf_mg_nocontext
511                     )];
512 }
513
514 unless ($define{'PERL_IMPLICIT_SYS'}) {
515     skip_symbols [qw(
516                     perl_alloc_using
517                     perl_clone_using
518                     )];
519 }
520
521 unless ($define{'FAKE_THREADS'}) {
522     skip_symbols [qw(PL_curthr)];
523 }
524
525 sub readvar {
526     my $file = shift;
527     my $proc = shift || sub { "PL_$_[2]" };
528     open(VARS,$file) || die "Cannot open $file: $!\n";
529     my @syms;
530     while (<VARS>) {
531         # All symbols have a Perl_ prefix because that's what embed.h
532         # sticks in front of them.
533         push(@syms, &$proc($1,$2,$3)) if (/\bPERLVAR(A?I?C?)\(([IGT])(\w+)/);
534     }
535     close(VARS);
536     return \@syms;
537 }
538
539 if ($define{'USE_5005THREADS'}) {
540     my $thrd = readvar($thrdvar_h);
541     skip_symbols $thrd;
542 }
543
544 if ($define{'PERL_GLOBAL_STRUCT'}) {
545     my $global = readvar($perlvars_h);
546     skip_symbols $global;
547     emit_symbol('Perl_GetVars');
548     emit_symbols [qw(PL_Vars PL_VarsPtr)] unless $CCTYPE eq 'GCC';
549 }
550
551 # functions from *.sym files
552
553 my @syms = ($global_sym, $globvar_sym); # $pp_sym is not part of the API
554
555 my @layer_syms = qw(
556                          PerlIOBase_clearerr
557                          PerlIOBase_close
558                          PerlIOBase_eof
559                          PerlIOBase_error
560                          PerlIOBase_fileno
561                          PerlIOBase_setlinebuf
562                          PerlIOBase_pushed
563                          PerlIOBase_read
564                          PerlIOBase_unread
565                          PerlIOBuf_bufsiz
566                          PerlIOBuf_fill
567                          PerlIOBuf_flush
568                          PerlIOBuf_get_cnt
569                          PerlIOBuf_get_ptr
570                          PerlIOBuf_open
571                          PerlIOBuf_pushed
572                          PerlIOBuf_read
573                          PerlIOBuf_seek
574                          PerlIOBuf_set_ptrcnt
575                          PerlIOBuf_tell
576                          PerlIOBuf_unread
577                          PerlIOBuf_write
578                          PerlIO_define_layer
579                          PerlIO_arg_fetch
580                          PerlIO_pending
581                          PerlIO_allocate
582                          PerlIO_push
583                          PerlIO_unread
584 );
585
586 if ($define{'USE_PERLIO'}) {
587     push @syms, $perlio_sym;
588     if ($define{'USE_SFIO'}) {
589         skip_symbols \@layer_syms;
590         # SFIO defines most of the PerlIO routines as macros
591         skip_symbols [qw(
592                          PerlIO_canset_cnt
593                          PerlIO_clearerr
594                          PerlIO_close
595                          PerlIO_eof
596                          PerlIO_error
597                          PerlIO_exportFILE
598                          PerlIO_fast_gets
599                          PerlIO_fdopen
600                          PerlIO_fileno
601                          PerlIO_findFILE
602                          PerlIO_flush
603                          PerlIO_get_base
604                          PerlIO_get_bufsiz
605                          PerlIO_get_cnt
606                          PerlIO_get_ptr
607                          PerlIO_getc
608                          PerlIO_getname
609                          PerlIO_has_base
610                          PerlIO_has_cntptr
611                          PerlIO_importFILE
612                          PerlIO_open
613                          PerlIO_printf
614                          PerlIO_putc
615                          PerlIO_puts
616                          PerlIO_read
617                          PerlIO_releaseFILE
618                          PerlIO_reopen
619                          PerlIO_rewind
620                          PerlIO_seek
621                          PerlIO_set_cnt
622                          PerlIO_set_ptrcnt
623                          PerlIO_setlinebuf
624                          PerlIO_sprintf
625                          PerlIO_stderr
626                          PerlIO_stdin
627                          PerlIO_stdout
628                          PerlIO_stdoutf
629                          PerlIO_tell
630                          PerlIO_ungetc
631                          PerlIO_vprintf
632                          PerlIO_write
633                          )];
634     }
635 } else {
636         # Skip the PerlIO New Generation symbols.
637         skip_symbols \@layer_syms;
638 }
639
640 for my $syms (@syms) {
641     open (GLOBAL, "<$syms") || die "failed to open $syms: $!\n";
642     while (<GLOBAL>) {
643         next if (!/^[A-Za-z]/);
644         # Functions have a Perl_ prefix
645         # Variables have a PL_ prefix
646         chomp($_);
647         my $symbol = ($syms =~ /var\.sym$/i ? "PL_" : "");
648         $symbol .= $_;
649         emit_symbol($symbol) unless exists $skip{$symbol};
650     }
651     close(GLOBAL);
652 }
653
654 # variables
655
656 if ($define{'PERL_OBJECT'} || $define{'MULTIPLICITY'}) {
657     for my $f ($perlvars_h, $intrpvar_h, $thrdvar_h) {
658         my $glob = readvar($f, sub { "Perl_" . $_[1] . $_[2] . "_ptr" });
659         emit_symbols $glob;
660     }
661     # XXX AIX seems to want the perlvars.h symbols, for some reason
662     if ($PLATFORM eq 'aix') {
663         my $glob = readvar($perlvars_h);
664         emit_symbols $glob;
665     }
666 }
667 else {
668     unless ($define{'PERL_GLOBAL_STRUCT'}) {
669         my $glob = readvar($perlvars_h);
670         emit_symbols $glob;
671     }
672     unless ($define{'MULTIPLICITY'}) {
673         my $glob = readvar($intrpvar_h);
674         emit_symbols $glob;
675     }
676     unless ($define{'MULTIPLICITY'} || $define{'USE_5005THREADS'}) {
677         my $glob = readvar($thrdvar_h);
678         emit_symbols $glob;
679     }
680 }
681
682 sub try_symbol {
683     my $symbol = shift;
684
685     return if $symbol !~ /^[A-Za-z]/;
686     return if $symbol =~ /^\#/;
687     $symbol =~s/\r//g;
688     chomp($symbol);
689     return if exists $skip{$symbol};
690     emit_symbol($symbol);
691 }
692
693 while (<DATA>) {
694     try_symbol($_);
695 }
696
697 if ($PLATFORM eq 'win32') {
698     foreach my $symbol (qw(
699                             setuid
700                             setgid
701                             boot_DynaLoader
702                             Perl_init_os_extras
703                             Perl_thread_create
704                             Perl_win32_init
705                             RunPerl
706                             win32_errno
707                             win32_environ
708                             win32_abort
709                             win32_fstat
710                             win32_stat
711                             win32_pipe
712                             win32_popen
713                             win32_pclose
714                             win32_rename
715                             win32_setmode
716                             win32_lseek
717                             win32_tell
718                             win32_dup
719                             win32_dup2
720                             win32_open
721                             win32_close
722                             win32_eof
723                             win32_read
724                             win32_write
725                             win32_spawnvp
726                             win32_mkdir
727                             win32_rmdir
728                             win32_chdir
729                             win32_flock
730                             win32_execv
731                             win32_execvp
732                             win32_htons
733                             win32_ntohs
734                             win32_htonl
735                             win32_ntohl
736                             win32_inet_addr
737                             win32_inet_ntoa
738                             win32_socket
739                             win32_bind
740                             win32_listen
741                             win32_accept
742                             win32_connect
743                             win32_send
744                             win32_sendto
745                             win32_recv
746                             win32_recvfrom
747                             win32_shutdown
748                             win32_closesocket
749                             win32_ioctlsocket
750                             win32_setsockopt
751                             win32_getsockopt
752                             win32_getpeername
753                             win32_getsockname
754                             win32_gethostname
755                             win32_gethostbyname
756                             win32_gethostbyaddr
757                             win32_getprotobyname
758                             win32_getprotobynumber
759                             win32_getservbyname
760                             win32_getservbyport
761                             win32_select
762                             win32_endhostent
763                             win32_endnetent
764                             win32_endprotoent
765                             win32_endservent
766                             win32_getnetent
767                             win32_getnetbyname
768                             win32_getnetbyaddr
769                             win32_getprotoent
770                             win32_getservent
771                             win32_sethostent
772                             win32_setnetent
773                             win32_setprotoent
774                             win32_setservent
775                             win32_getenv
776                             win32_putenv
777                             win32_perror
778                             win32_malloc
779                             win32_calloc
780                             win32_realloc
781                             win32_free
782                             win32_sleep
783                             win32_times
784                             win32_access
785                             win32_alarm
786                             win32_chmod
787                             win32_open_osfhandle
788                             win32_get_osfhandle
789                             win32_ioctl
790                             win32_link
791                             win32_unlink
792                             win32_utime
793                             win32_uname
794                             win32_wait
795                             win32_waitpid
796                             win32_kill
797                             win32_str_os_error
798                             win32_opendir
799                             win32_readdir
800                             win32_telldir
801                             win32_seekdir
802                             win32_rewinddir
803                             win32_closedir
804                             win32_longpath
805                             win32_os_id
806                             win32_getpid
807                             win32_crypt
808                             win32_dynaload
809
810                             win32_stdin
811                             win32_stdout
812                             win32_stderr
813                             win32_ferror
814                             win32_feof
815                             win32_strerror
816                             win32_fprintf
817                             win32_printf
818                             win32_vfprintf
819                             win32_vprintf
820                             win32_fread
821                             win32_fwrite
822                             win32_fopen
823                             win32_fdopen
824                             win32_freopen
825                             win32_fclose
826                             win32_fputs
827                             win32_fputc
828                             win32_ungetc
829                             win32_getc
830                             win32_fileno
831                             win32_clearerr
832                             win32_fflush
833                             win32_ftell
834                             win32_fseek
835                             win32_fgetpos
836                             win32_fsetpos
837                             win32_rewind
838                             win32_tmpfile
839                             win32_setbuf
840                             win32_setvbuf
841                             win32_flushall
842                             win32_fcloseall
843                             win32_fgets
844                             win32_gets
845                             win32_fgetc
846                             win32_putc
847                             win32_puts
848                             win32_getchar
849                             win32_putchar
850                            ))
851     {
852         try_symbol($symbol);
853     }
854 }
855 elsif ($PLATFORM eq 'os2') {
856     open MAP, 'miniperl.map' or die 'Cannot read miniperl.map';
857     /^\s*[\da-f:]+\s+(\w+)/i and $mapped{$1}++ foreach <MAP>;
858     close MAP or die 'Cannot close miniperl.map';
859
860     @missing = grep { !exists $mapped{$_} and !exists $bincompat5005{$_} }
861                     keys %export;
862     delete $export{$_} foreach @missing;
863 }
864 elsif ($PLATFORM eq 'MacOS') {
865     open MACSYMS, 'macperl.sym' or die 'Cannot read macperl.sym';
866
867     while (<MACSYMS>) {
868         try_symbol($_);
869     }
870
871     close MACSYMS;
872 }
873
874 # Now all symbols should be defined because
875 # next we are going to output them.
876
877 foreach my $symbol (sort keys %export) {
878     output_symbol($symbol);
879 }
880
881 sub emit_symbol {
882     my $symbol = shift;
883     chomp($symbol);
884     $export{$symbol} = 1;
885 }
886
887 sub output_symbol {
888     my $symbol = shift;
889     $symbol = $bincompat5005{$symbol}
890         if $define{PERL_BINCOMPAT_5005} and $symbol =~ /^($bincompat5005)$/;
891     if ($PLATFORM eq 'win32') {
892         $symbol = "_$symbol" if $CCTYPE eq 'BORLAND';
893         print "\t$symbol\n";
894 # XXX: binary compatibility between compilers is an exercise
895 # in frustration :-(
896 #        if ($CCTYPE eq "BORLAND") {
897 #           # workaround Borland quirk by exporting both the straight
898 #           # name and a name with leading underscore.  Note the
899 #           # alias *must* come after the symbol itself, if both
900 #           # are to be exported. (Linker bug?)
901 #           print "\t_$symbol\n";
902 #           print "\t$symbol = _$symbol\n";
903 #       }
904 #       elsif ($CCTYPE eq 'GCC') {
905 #           # Symbols have leading _ whole process is $%@"% slow
906 #           # so skip aliases for now
907 #           nprint "\t$symbol\n";
908 #       }
909 #       else {
910 #           # for binary coexistence, export both the symbol and
911 #           # alias with leading underscore
912 #           print "\t$symbol\n";
913 #           print "\t_$symbol = $symbol\n";
914 #       }
915     }
916     elsif ($PLATFORM eq 'os2') {
917         print qq(    "$symbol"\n);
918     }
919     elsif ($PLATFORM eq 'aix' || $PLATFORM eq 'MacOS') {
920         print "$symbol\n";
921     }
922 }
923
924 1;
925 __DATA__
926 # extra globals not included above.
927 perl_alloc
928 perl_alloc_using
929 perl_clone
930 perl_clone_using
931 perl_construct
932 perl_destruct
933 perl_free
934 perl_parse
935 perl_run
936 PerlIO_define_layer
937 PerlIOBuf_set_ptrcnt
938 PerlIOBuf_get_cnt
939 PerlIOBuf_get_ptr
940 PerlIOBuf_bufsiz
941 PerlIOBase_clearerr
942 PerlIOBase_setlinebuf
943 PerlIOBase_pushed
944 PerlIOBase_read
945 PerlIOBase_unread
946 PerlIOBase_error
947 PerlIOBase_eof
948 PerlIOBuf_tell
949 PerlIOBuf_seek
950 PerlIOBuf_write
951 PerlIOBuf_unread
952 PerlIOBuf_read
953 PerlIOBuf_open
954 PerlIOBase_fileno
955 PerlIOBuf_pushed
956 PerlIOBuf_fill
957 PerlIOBuf_flush
958 PerlIOBase_close
959 PerlIO_define_layer
960 PerlIO_pending
961 PerlIO_unread
962 PerlIO_push
963 PerlIO_allocate
964 PerlIO_arg_fetch
965 PerlIO_apply_layers
966 perlsio_binmode
967 PerlIO_binmode
968 PerlIO_init
969 PerlIO_tmpfile
970 PerlIO_setpos
971 PerlIO_getpos
972 PerlIO_vsprintf
973 PerlIO_sprintf