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