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