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