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