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