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