Re: Cannot handle date (0, 0, 0, 2, 0, 1970)
[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         if ($PLATFORM eq 'netware') {
54                 $FILETYPE = $1 if ($flag =~ /^FILETYPE=(\w+)$/);
55         }
56 }
57
58 my @PLATFORM = qw(aix win32 os2 MacOS netware);
59 my %PLATFORM;
60 @PLATFORM{@PLATFORM} = ();
61
62 defined $PLATFORM || die "PLATFORM undefined, must be one of: @PLATFORM\n";
63 exists $PLATFORM{$PLATFORM} || die "PLATFORM must be one of: @PLATFORM\n";
64
65 my $config_sh   = "config.sh";
66 my $config_h    = "config.h";
67 my $thrdvar_h   = "thrdvar.h";
68 my $intrpvar_h  = "intrpvar.h";
69 my $perlvars_h  = "perlvars.h";
70 my $global_sym  = "global.sym";
71 my $pp_sym      = "pp.sym";
72 my $globvar_sym = "globvar.sym";
73 my $perlio_sym  = "perlio.sym";
74
75 if ($PLATFORM eq 'aix') {
76     # Nothing for now.
77 }
78 elsif ($PLATFORM eq 'win32' || $PLATFORM eq 'netware') {
79     $CCTYPE = "MSVC" unless defined $CCTYPE;
80     foreach ($thrdvar_h, $intrpvar_h, $perlvars_h, $global_sym,
81                 $pp_sym, $globvar_sym, $perlio_sym) {
82         s!^!..\\!;
83     }
84 }
85 elsif ($PLATFORM eq 'MacOS') {
86     foreach ($thrdvar_h, $intrpvar_h, $perlvars_h, $global_sym,
87                 $pp_sym, $globvar_sym, $perlio_sym) {
88         s!^!::!;
89     }
90 }
91
92 unless ($PLATFORM eq 'win32' || $PLATFORM eq 'MacOS' || $PLATFORM eq 'netware') {
93     open(CFG,$config_sh) || die "Cannot open $config_sh: $!\n";
94     while (<CFG>) {
95         if (/^(?:ccflags|optimize)='(.+)'$/) {
96             $_ = $1;
97             $define{$1} = 1 while /-D(\w+)/g;
98         }
99         if ($PLATFORM eq 'os2') {
100             $CONFIG_ARGS = $1 if /^(?:config_args)='(.+)'$/;
101             $ARCHNAME =    $1 if /^(?:archname)='(.+)'$/;
102         }
103     }
104     close(CFG);
105 }
106
107 open(CFG,$config_h) || die "Cannot open $config_h: $!\n";
108 while (<CFG>) {
109     $define{$1} = 1 if /^\s*#\s*define\s+(MYMALLOC)\b/;
110     $define{$1} = 1 if /^\s*#\s*define\s+(MULTIPLICITY)\b/;
111     $define{$1} = 1 if /^\s*#\s*define\s+(PERL_\w+)\b/;
112     $define{$1} = 1 if /^\s*#\s*define\s+(USE_\w+)\b/;
113 }
114 close(CFG);
115
116 # perl.h logic duplication begins
117
118 if ($define{USE_ITHREADS}) {
119     if (!$define{MULTIPLICITY}) {
120         $define{MULTIPLICITY} = 1;
121     }
122 }
123
124 $define{PERL_IMPLICIT_CONTEXT} ||=
125     $define{USE_ITHREADS} ||
126     $define{USE_5005THREADS}  ||
127     $define{MULTIPLICITY} ;
128
129 # perl.h logic duplication ends
130
131 if ($PLATFORM eq 'win32') {
132     warn join(' ',keys %define)."\n";
133     print "LIBRARY Perl57\n";
134     print "DESCRIPTION 'Perl interpreter'\n";
135     print "EXPORTS\n";
136     if ($define{PERL_IMPLICIT_SYS}) {
137         output_symbol("perl_get_host_info");
138         output_symbol("perl_alloc_override");
139     output_symbol("perl_clone_host");
140     }
141 }
142 elsif ($PLATFORM eq 'os2') {
143     ($v = $]) =~ s/(\d\.\d\d\d)(\d\d)$/$1_$2/;
144     $v .= '-thread' if $ARCHNAME =~ /-thread/;
145     ($dll = $define{PERL_DLL}) =~ s/\.dll$//i;
146     $d = "DESCRIPTION '\@#perl5-porters\@perl.org:$v#\@ Perl interpreter, configured as $CONFIG_ARGS'";
147     $d = substr($d, 0, 249) . "...'" if length $d > 253;
148     print <<"---EOP---";
149 LIBRARY '$dll' INITINSTANCE TERMINSTANCE
150 $d
151 STACKSIZE 32768
152 CODE LOADONCALL
153 DATA LOADONCALL NONSHARED MULTIPLE
154 EXPORTS
155 ---EOP---
156 }
157 elsif ($PLATFORM eq 'aix') {
158     $OSVER = `uname -v`;
159     chop $OSVER;
160     $OSREL = `uname -r`;
161     chop $OSREL;
162     if ($OSVER > 4 || ($OSVER == 4 && $OSREL >= 3)) {
163         print "#! ..\n";
164     } else {
165         print "#!\n";
166     }
167 }
168 elsif ($PLATFORM eq 'netware') {
169         if ($FILETYPE eq 'def') {
170         print "LIBRARY Perl57\n";
171         print "DESCRIPTION 'Perl interpreter for NetWare'\n";
172         print "EXPORTS\n";
173         }
174         if ($define{PERL_IMPLICIT_SYS}) {
175         output_symbol("perl_get_host_info");
176         output_symbol("perl_alloc_override");
177         output_symbol("perl_clone_host");
178         }
179 }
180
181 my %skip;
182 my %export;
183
184 sub skip_symbols {
185     my $list = shift;
186     foreach my $symbol (@$list) {
187         $skip{$symbol} = 1;
188     }
189 }
190
191 sub emit_symbols {
192     my $list = shift;
193     foreach my $symbol (@$list) {
194         my $skipsym = $symbol;
195         # XXX hack
196         if ($define{MULTIPLICITY}) {
197             $skipsym =~ s/^Perl_[GIT](\w+)_ptr$/PL_$1/;
198         }
199         emit_symbol($symbol) unless exists $skip{$skipsym};
200     }
201 }
202
203 if ($PLATFORM eq 'win32') {
204     skip_symbols [qw(
205                      PL_statusvalue_vms
206                      PL_archpat_auto
207                      PL_cryptseen
208                      PL_DBcv
209                      PL_generation
210                      PL_lastgotoprobe
211                      PL_linestart
212                      PL_modcount
213                      PL_pending_ident
214                      PL_sortcxix
215                      PL_sublex_info
216                      PL_timesbuf
217                      main
218                      Perl_ErrorNo
219                      Perl_GetVars
220                      Perl_do_exec3
221                      Perl_do_ipcctl
222                      Perl_do_ipcget
223                      Perl_do_msgrcv
224                      Perl_do_msgsnd
225                      Perl_do_semop
226                      Perl_do_shmio
227                      Perl_dump_fds
228                      Perl_init_thread_intern
229                      Perl_my_bzero
230                      Perl_my_bcopy
231                      Perl_my_htonl
232                      Perl_my_ntohl
233                      Perl_my_swap
234                      Perl_my_chsize
235                      Perl_same_dirent
236                      Perl_setenv_getix
237                      Perl_unlnk
238                      Perl_watch
239                      Perl_safexcalloc
240                      Perl_safexmalloc
241                      Perl_safexfree
242                      Perl_safexrealloc
243                      Perl_my_memcmp
244                      Perl_my_memset
245                      PL_cshlen
246                      PL_cshname
247                      PL_opsave
248                      Perl_do_exec
249                      Perl_getenv_len
250                      Perl_my_pclose
251                      Perl_my_popen
252                      )];
253 }
254 elsif ($PLATFORM eq 'aix') {
255     skip_symbols([qw(
256                      Perl_dump_fds
257                      Perl_ErrorNo
258                      Perl_GetVars
259                      Perl_my_bcopy
260                      Perl_my_bzero
261                      Perl_my_chsize
262                      Perl_my_htonl
263                      Perl_my_memcmp
264                      Perl_my_memset
265                      Perl_my_ntohl
266                      Perl_my_swap
267                      Perl_safexcalloc
268                      Perl_safexfree
269                      Perl_safexmalloc
270                      Perl_safexrealloc
271                      Perl_same_dirent
272                      Perl_unlnk
273                      Perl_sys_intern_clear
274                      Perl_sys_intern_dup
275                      Perl_sys_intern_init
276                      PL_cryptseen
277                      PL_opsave
278                      PL_statusvalue_vms
279                      PL_sys_intern
280                      )]);
281 }
282 elsif ($PLATFORM eq 'os2') {
283     emit_symbols([qw(
284                     ctermid
285                     get_sysinfo
286                     Perl_OS2_init
287                     Perl_OS2_init3
288                     Perl_OS2_term
289                     OS2_Perl_data
290                     dlopen
291                     dlsym
292                     dlerror
293                     dlclose
294                     my_tmpfile
295                     my_tmpnam
296                     my_flock
297                     my_rmdir
298                     my_mkdir
299                     my_getpwuid
300                     my_getpwnam
301                     my_getpwent
302                     my_setpwent
303                     my_endpwent
304                     setgrent
305                     endgrent
306                     getgrent
307                     malloc_mutex
308                     threads_mutex
309                     nthreads
310                     nthreads_cond
311                     os2_cond_wait
312                     os2_stat
313                     pthread_join
314                     pthread_create
315                     pthread_detach
316                     XS_Cwd_change_drive
317                     XS_Cwd_current_drive
318                     XS_Cwd_extLibpath
319                     XS_Cwd_extLibpath_set
320                     XS_Cwd_sys_abspath
321                     XS_Cwd_sys_chdir
322                     XS_Cwd_sys_cwd
323                     XS_Cwd_sys_is_absolute
324                     XS_Cwd_sys_is_relative
325                     XS_Cwd_sys_is_rooted
326                     XS_DynaLoader_mod2fname
327                     XS_File__Copy_syscopy
328                     Perl_Register_MQ
329                     Perl_Deregister_MQ
330                     Perl_Serve_Messages
331                     Perl_Process_Messages
332                     init_PMWIN_entries
333                     PMWIN_entries
334                     Perl_hab_GET
335                     loadByOrdinal
336                     pExtFCN
337                     os2error
338                     ResetWinError
339                     CroakWinError
340                     )]);
341 }
342 elsif ($PLATFORM eq 'MacOS') {
343     skip_symbols [qw(
344                     Perl_GetVars
345                     PL_cryptseen
346                     PL_cshlen
347                     PL_cshname
348                     PL_statusvalue_vms
349                     PL_sys_intern
350                     PL_opsave
351                     PL_timesbuf
352                     Perl_dump_fds
353                     Perl_my_bcopy
354                     Perl_my_bzero
355                     Perl_my_chsize
356                     Perl_my_htonl
357                     Perl_my_memcmp
358                     Perl_my_memset
359                     Perl_my_ntohl
360                     Perl_my_swap
361                     Perl_safexcalloc
362                     Perl_safexfree
363                     Perl_safexmalloc
364                     Perl_safexrealloc
365                     Perl_unlnk
366                     Perl_sys_intern_clear
367                     Perl_sys_intern_init
368                     )];
369 }
370 elsif ($PLATFORM eq 'netware') {
371         skip_symbols [qw(
372                         PL_statusvalue_vms
373                         PL_archpat_auto
374                         PL_cryptseen
375                         PL_DBcv
376                         PL_generation
377                         PL_lastgotoprobe
378                         PL_linestart
379                         PL_modcount
380                         PL_pending_ident
381                         PL_sortcxix
382                         PL_sublex_info
383                         PL_timesbuf
384                         main
385                         Perl_ErrorNo
386                         Perl_GetVars
387                         Perl_do_exec3
388                         Perl_do_ipcctl
389                         Perl_do_ipcget
390                         Perl_do_msgrcv
391                         Perl_do_msgsnd
392                         Perl_do_semop
393                         Perl_do_shmio
394                         Perl_dump_fds
395                         Perl_init_thread_intern
396                         Perl_my_bzero
397                         Perl_my_htonl
398                         Perl_my_ntohl
399                         Perl_my_swap
400                         Perl_my_chsize
401                         Perl_same_dirent
402                         Perl_setenv_getix
403                         Perl_unlnk
404                         Perl_watch
405                         Perl_safexcalloc
406                         Perl_safexmalloc
407                         Perl_safexfree
408                         Perl_safexrealloc
409                         Perl_my_memcmp
410                         Perl_my_memset
411                         PL_cshlen
412                         PL_cshname
413                         PL_opsave
414                         Perl_do_exec
415                         Perl_getenv_len
416                         Perl_my_pclose
417                         Perl_my_popen
418                         )];
419 }
420
421 unless ($define{'DEBUGGING'}) {
422     skip_symbols [qw(
423                     Perl_deb_growlevel
424                     Perl_debop
425                     Perl_debprofdump
426                     Perl_debstack
427                     Perl_debstackptrs
428                     Perl_sv_peek
429                     PL_block_type
430                     PL_watchaddr
431                     PL_watchok
432                     )];
433 }
434
435 if ($define{'PERL_IMPLICIT_SYS'}) {
436     skip_symbols [qw(
437                     Perl_getenv_len
438                     Perl_my_popen
439                     Perl_my_pclose
440                     )];
441 }
442 else {
443     skip_symbols [qw(
444                     PL_Mem
445                     PL_MemShared
446                     PL_MemParse
447                     PL_Env
448                     PL_StdIO
449                     PL_LIO
450                     PL_Dir
451                     PL_Sock
452                     PL_Proc
453                     )];
454 }
455
456 unless ($define{'PERL_FLEXIBLE_EXCEPTIONS'}) {
457     skip_symbols [qw(
458                     PL_protect
459                     Perl_default_protect
460                     Perl_vdefault_protect
461                     )];
462 }
463
464 unless ($define{'USE_REENTRANT_API'}) {
465     skip_symbols [qw(
466                     PL_reentrant_buffer
467                     )];
468 }
469
470 if ($define{'MYMALLOC'}) {
471     emit_symbols [qw(
472                     Perl_dump_mstats
473                     Perl_get_mstats
474                     Perl_strdup
475                     Perl_putenv
476                     )];
477     if ($define{'USE_5005THREADS'} || $define{'USE_ITHREADS'}) {
478         emit_symbols [qw(
479                         PL_malloc_mutex
480                         )];
481     }
482     else {
483         skip_symbols [qw(
484                         PL_malloc_mutex
485                         )];
486     }
487 }
488 else {
489     skip_symbols [qw(
490                     PL_malloc_mutex
491                     Perl_dump_mstats
492                     Perl_get_mstats
493                     Perl_malloced_size
494                     )];
495 }
496
497 unless ($define{'USE_5005THREADS'} || $define{'USE_ITHREADS'}) {
498     skip_symbols [qw(
499                     PL_thr_key
500                     )];
501 }
502
503 unless ($define{'USE_5005THREADS'}) {
504     skip_symbols [qw(
505                     PL_sv_mutex
506                     PL_strtab_mutex
507                     PL_svref_mutex
508                     PL_cred_mutex
509                     PL_eval_mutex
510                     PL_fdpid_mutex
511                     PL_sv_lock_mutex
512                     PL_eval_cond
513                     PL_eval_owner
514                     PL_threads_mutex
515                     PL_nthreads
516                     PL_nthreads_cond
517                     PL_threadnum
518                     PL_threadsv_names
519                     PL_thrsv
520                     PL_vtbl_mutex
521                     Perl_condpair_magic
522                     Perl_new_struct_thread
523                     Perl_per_thread_magicals
524                     Perl_thread_create
525                     Perl_find_threadsv
526                     Perl_unlock_condpair
527                     Perl_magic_mutexfree
528                     Perl_sv_lock
529                     )];
530 }
531
532 unless ($define{'USE_ITHREADS'}) {
533     skip_symbols [qw(
534                     PL_ptr_table
535                     PL_op_mutex
536                     PL_regex_pad
537                     PL_regex_padav
538                     PL_sharedsv_space
539                     PL_sharedsv_space_mutex
540                     Perl_dirp_dup
541                     Perl_cx_dup
542                     Perl_si_dup
543                     Perl_any_dup
544                     Perl_ss_dup
545                     Perl_fp_dup
546                     Perl_gp_dup
547                     Perl_he_dup
548                     Perl_mg_dup
549                     Perl_re_dup
550                     Perl_sv_dup
551                     Perl_sys_intern_dup
552                     Perl_ptr_table_clear
553                     Perl_ptr_table_fetch
554                     Perl_ptr_table_free
555                     Perl_ptr_table_new
556                     Perl_ptr_table_clear
557                     Perl_ptr_table_free
558                     Perl_ptr_table_split
559                     Perl_ptr_table_store
560                     perl_clone
561                     perl_clone_using
562                     Perl_sharedsv_find
563                     Perl_sharedsv_init
564                     Perl_sharedsv_lock
565                     Perl_sharedsv_new
566                     Perl_sharedsv_thrcnt_dec
567                     Perl_sharedsv_thrcnt_inc
568                     Perl_sharedsv_unlock
569                     )];
570 }
571
572 unless ($define{'PERL_IMPLICIT_CONTEXT'}) {
573     skip_symbols [qw(
574                     Perl_croak_nocontext
575                     Perl_die_nocontext
576                     Perl_deb_nocontext
577                     Perl_form_nocontext
578                     Perl_load_module_nocontext
579                     Perl_mess_nocontext
580                     Perl_warn_nocontext
581                     Perl_warner_nocontext
582                     Perl_newSVpvf_nocontext
583                     Perl_sv_catpvf_nocontext
584                     Perl_sv_setpvf_nocontext
585                     Perl_sv_catpvf_mg_nocontext
586                     Perl_sv_setpvf_mg_nocontext
587                     )];
588 }
589
590 unless ($define{'PERL_IMPLICIT_SYS'}) {
591     skip_symbols [qw(
592                     perl_alloc_using
593                     perl_clone_using
594                     )];
595 }
596
597 unless ($define{'FAKE_THREADS'}) {
598     skip_symbols [qw(PL_curthr)];
599 }
600
601 sub readvar {
602     my $file = shift;
603     my $proc = shift || sub { "PL_$_[2]" };
604     open(VARS,$file) || die "Cannot open $file: $!\n";
605     my @syms;
606     while (<VARS>) {
607         # All symbols have a Perl_ prefix because that's what embed.h
608         # sticks in front of them.
609         push(@syms, &$proc($1,$2,$3)) if (/\bPERLVAR(A?I?C?)\(([IGT])(\w+)/);
610     }
611     close(VARS);
612     return \@syms;
613 }
614
615 if ($define{'USE_5005THREADS'}) {
616     my $thrd = readvar($thrdvar_h);
617     skip_symbols $thrd;
618 }
619
620 if ($define{'PERL_GLOBAL_STRUCT'}) {
621     my $global = readvar($perlvars_h);
622     skip_symbols $global;
623     emit_symbol('Perl_GetVars');
624     emit_symbols [qw(PL_Vars PL_VarsPtr)] unless $CCTYPE eq 'GCC';
625 }
626
627 # functions from *.sym files
628
629 my @syms = ($global_sym, $globvar_sym); # $pp_sym is not part of the API
630
631 my @layer_syms = qw(
632                          PerlIOBase_clearerr
633                          PerlIOBase_close
634                          PerlIOBase_dup
635                          PerlIOBase_eof
636                          PerlIOBase_error
637                          PerlIOBase_fileno
638                          PerlIOBase_pushed
639                          PerlIOBase_read
640                          PerlIOBase_setlinebuf
641                          PerlIOBase_unread
642                          PerlIOBuf_bufsiz
643                          PerlIOBuf_fill
644                          PerlIOBuf_flush
645                          PerlIOBuf_get_cnt
646                          PerlIOBuf_get_ptr
647                          PerlIOBuf_open
648                          PerlIOBuf_pushed
649                          PerlIOBuf_read
650                          PerlIOBuf_seek
651                          PerlIOBuf_set_ptrcnt
652                          PerlIOBuf_tell
653                          PerlIOBuf_unread
654                          PerlIOBuf_write
655                          PerlIO_allocate
656                          PerlIO_arg_fetch
657                          PerlIO_define_layer
658                          PerlIO_modestr
659                          PerlIO_pending
660                          PerlIO_push
661                          PerlIO_sv_dup
662                          PL_def_layerlist
663                          PL_known_layers
664                          PL_perlio
665 );
666
667 if ($define{'USE_PERLIO'}) {
668     push @syms, $perlio_sym;
669     if ($define{'USE_SFIO'}) {
670         skip_symbols \@layer_syms;
671         # SFIO defines most of the PerlIO routines as macros
672         skip_symbols [qw(
673                          PerlIO_canset_cnt
674                          PerlIO_clearerr
675                          PerlIO_close
676                          PerlIO_eof
677                          PerlIO_error
678                          PerlIO_exportFILE
679                          PerlIO_fast_gets
680                          PerlIO_fdopen
681                          PerlIO_fileno
682                          PerlIO_findFILE
683                          PerlIO_flush
684                          PerlIO_get_base
685                          PerlIO_get_bufsiz
686                          PerlIO_get_cnt
687                          PerlIO_get_ptr
688                          PerlIO_getc
689                          PerlIO_getname
690                          PerlIO_has_base
691                          PerlIO_has_cntptr
692                          PerlIO_importFILE
693                          PerlIO_open
694                          PerlIO_printf
695                          PerlIO_putc
696                          PerlIO_puts
697                          PerlIO_read
698                          PerlIO_releaseFILE
699                          PerlIO_reopen
700                          PerlIO_rewind
701                          PerlIO_seek
702                          PerlIO_set_cnt
703                          PerlIO_set_ptrcnt
704                          PerlIO_setlinebuf
705                          PerlIO_sprintf
706                          PerlIO_stderr
707                          PerlIO_stdin
708                          PerlIO_stdout
709                          PerlIO_stdoutf
710                          PerlIO_tell
711                          PerlIO_ungetc
712                          PerlIO_vprintf
713                          PerlIO_write
714                          )];
715     }
716 } else {
717         # Skip the PerlIO New Generation symbols.
718         skip_symbols \@layer_syms;
719 }
720
721 for my $syms (@syms) {
722     open (GLOBAL, "<$syms") || die "failed to open $syms: $!\n";
723     while (<GLOBAL>) {
724         next if (!/^[A-Za-z]/);
725         # Functions have a Perl_ prefix
726         # Variables have a PL_ prefix
727         chomp($_);
728         my $symbol = ($syms =~ /var\.sym$/i ? "PL_" : "");
729         $symbol .= $_;
730         emit_symbol($symbol) unless exists $skip{$symbol};
731     }
732     close(GLOBAL);
733 }
734
735 # variables
736
737 if ($define{'MULTIPLICITY'}) {
738     for my $f ($perlvars_h, $intrpvar_h, $thrdvar_h) {
739         my $glob = readvar($f, sub { "Perl_" . $_[1] . $_[2] . "_ptr" });
740         emit_symbols $glob;
741     }
742     # XXX AIX seems to want the perlvars.h symbols, for some reason
743     if ($PLATFORM eq 'aix') {
744         my $glob = readvar($perlvars_h);
745         emit_symbols $glob;
746     }
747 }
748 else {
749     unless ($define{'PERL_GLOBAL_STRUCT'}) {
750         my $glob = readvar($perlvars_h);
751         emit_symbols $glob;
752     }
753     unless ($define{'MULTIPLICITY'}) {
754         my $glob = readvar($intrpvar_h);
755         emit_symbols $glob;
756     }
757     unless ($define{'MULTIPLICITY'} || $define{'USE_5005THREADS'}) {
758         my $glob = readvar($thrdvar_h);
759         emit_symbols $glob;
760     }
761 }
762
763 sub try_symbol {
764     my $symbol = shift;
765
766     return if $symbol !~ /^[A-Za-z_]/;
767     return if $symbol =~ /^\#/;
768     $symbol =~s/\r//g;
769     chomp($symbol);
770     return if exists $skip{$symbol};
771     emit_symbol($symbol);
772 }
773
774 while (<DATA>) {
775     try_symbol($_);
776 }
777
778 if ($PLATFORM eq 'win32') {
779     foreach my $symbol (qw(
780                             setuid
781                             setgid
782                             boot_DynaLoader
783                             Perl_init_os_extras
784                             Perl_thread_create
785                             Perl_win32_init
786                             RunPerl
787                             win32_async_check
788                             win32_errno
789                             win32_environ
790                             win32_abort
791                             win32_fstat
792                             win32_stat
793                             win32_pipe
794                             win32_popen
795                             win32_pclose
796                             win32_rename
797                             win32_setmode
798                             win32_lseek
799                             win32_tell
800                             win32_dup
801                             win32_dup2
802                             win32_open
803                             win32_close
804                             win32_eof
805                             win32_read
806                             win32_write
807                             win32_spawnvp
808                             win32_mkdir
809                             win32_rmdir
810                             win32_chdir
811                             win32_flock
812                             win32_execv
813                             win32_execvp
814                             win32_htons
815                             win32_ntohs
816                             win32_htonl
817                             win32_ntohl
818                             win32_inet_addr
819                             win32_inet_ntoa
820                             win32_socket
821                             win32_bind
822                             win32_listen
823                             win32_accept
824                             win32_connect
825                             win32_send
826                             win32_sendto
827                             win32_recv
828                             win32_recvfrom
829                             win32_shutdown
830                             win32_closesocket
831                             win32_ioctlsocket
832                             win32_setsockopt
833                             win32_getsockopt
834                             win32_getpeername
835                             win32_getsockname
836                             win32_gethostname
837                             win32_gethostbyname
838                             win32_gethostbyaddr
839                             win32_getprotobyname
840                             win32_getprotobynumber
841                             win32_getservbyname
842                             win32_getservbyport
843                             win32_select
844                             win32_endhostent
845                             win32_endnetent
846                             win32_endprotoent
847                             win32_endservent
848                             win32_getnetent
849                             win32_getnetbyname
850                             win32_getnetbyaddr
851                             win32_getprotoent
852                             win32_getservent
853                             win32_sethostent
854                             win32_setnetent
855                             win32_setprotoent
856                             win32_setservent
857                             win32_getenv
858                             win32_putenv
859                             win32_perror
860                             win32_malloc
861                             win32_calloc
862                             win32_realloc
863                             win32_free
864                             win32_sleep
865                             win32_times
866                             win32_access
867                             win32_alarm
868                             win32_chmod
869                             win32_open_osfhandle
870                             win32_get_osfhandle
871                             win32_ioctl
872                             win32_link
873                             win32_unlink
874                             win32_utime
875                             win32_uname
876                             win32_wait
877                             win32_waitpid
878                             win32_kill
879                             win32_str_os_error
880                             win32_opendir
881                             win32_readdir
882                             win32_telldir
883                             win32_seekdir
884                             win32_rewinddir
885                             win32_closedir
886                             win32_longpath
887                             win32_os_id
888                             win32_getpid
889                             win32_crypt
890                             win32_dynaload
891                             win32_get_childenv
892                             win32_free_childenv
893                             win32_clearenv
894                             win32_get_childdir
895                             win32_free_childdir
896                             win32_stdin
897                             win32_stdout
898                             win32_stderr
899                             win32_ferror
900                             win32_feof
901                             win32_strerror
902                             win32_fprintf
903                             win32_printf
904                             win32_vfprintf
905                             win32_vprintf
906                             win32_fread
907                             win32_fwrite
908                             win32_fopen
909                             win32_fdopen
910                             win32_freopen
911                             win32_fclose
912                             win32_fputs
913                             win32_fputc
914                             win32_ungetc
915                             win32_getc
916                             win32_fileno
917                             win32_clearerr
918                             win32_fflush
919                             win32_ftell
920                             win32_fseek
921                             win32_fgetpos
922                             win32_fsetpos
923                             win32_rewind
924                             win32_tmpfile
925                             win32_setbuf
926                             win32_setvbuf
927                             win32_flushall
928                             win32_fcloseall
929                             win32_fgets
930                             win32_gets
931                             win32_fgetc
932                             win32_putc
933                             win32_puts
934                             win32_getchar
935                             win32_putchar
936                            ))
937     {
938         try_symbol($symbol);
939     }
940 }
941 elsif ($PLATFORM eq 'os2') {
942     open MAP, 'miniperl.map' or die 'Cannot read miniperl.map';
943     /^\s*[\da-f:]+\s+(\w+)/i and $mapped{$1}++ foreach <MAP>;
944     close MAP or die 'Cannot close miniperl.map';
945
946     @missing = grep { !exists $mapped{$_} and !exists $bincompat5005{$_} }
947                     keys %export;
948     delete $export{$_} foreach @missing;
949 }
950 elsif ($PLATFORM eq 'MacOS') {
951     open MACSYMS, 'macperl.sym' or die 'Cannot read macperl.sym';
952
953     while (<MACSYMS>) {
954         try_symbol($_);
955     }
956
957     close MACSYMS;
958 }
959 elsif ($PLATFORM eq 'netware') {
960 foreach my $symbol (qw(
961                         boot_DynaLoader
962                         Perl_init_os_extras
963                         Perl_thread_create
964                         Perl_nw5_init
965                         RunPerl
966                         AllocStdPerl
967                         FreeStdPerl
968                         do_spawn2
969                         do_aspawn
970                         nw_uname
971                         nw_stdin
972                         nw_stdout
973                         nw_stderr
974                         nw_feof
975                         nw_ferror
976                         nw_fopen
977                         nw_fclose
978                         nw_clearerr
979                         nw_getc
980                         nw_fgets
981                         nw_fputc
982                         nw_fputs
983                         nw_fflush
984                         nw_ungetc
985                         nw_fileno
986                         nw_fdopen
987                         nw_freopen
988                         nw_fread
989                         nw_fwrite
990                         nw_setbuf
991                         nw_setvbuf
992                         nw_vfprintf
993                         nw_ftell
994                         nw_fseek
995                         nw_rewind
996                         nw_tmpfile
997                         nw_fgetpos
998                         nw_fsetpos
999                         nw_dup
1000                         nw_access
1001                         nw_chmod
1002                         nw_chsize
1003                         nw_close
1004                         nw_dup2
1005                         nw_flock
1006                         nw_isatty
1007                         nw_link
1008                         nw_lseek
1009                         nw_stat
1010                         nw_mktemp
1011                         nw_open
1012                         nw_read
1013                         nw_rename
1014                         nw_setmode
1015                         nw_unlink
1016                         nw_utime
1017                         nw_write
1018                         nw_chdir
1019                         nw_rmdir
1020                         nw_closedir
1021                         nw_opendir
1022                         nw_readdir
1023                         nw_rewinddir
1024                         nw_seekdir
1025                         nw_telldir
1026                         nw_htonl
1027                         nw_htons
1028                         nw_ntohl
1029                         nw_ntohs
1030                         nw_accept
1031                         nw_bind
1032                         nw_connect
1033                         nw_endhostent
1034                         nw_endnetent
1035                         nw_endprotoent
1036                         nw_endservent
1037                         nw_gethostbyaddr
1038                         nw_gethostbyname
1039                         nw_gethostent
1040                         nw_gethostname
1041                         nw_getnetbyaddr
1042                         nw_getnetbyname
1043                         nw_getnetent
1044                         nw_getpeername
1045                         nw_getprotobyname
1046                         nw_getprotobynumber
1047                         nw_getprotoent
1048                         nw_getservbyname
1049                         nw_getservbyport
1050                         nw_getservent
1051                         nw_getsockname
1052                         nw_getsockopt
1053                         nw_inet_addr
1054                         nw_listen
1055                         nw_socket
1056                         nw_recv
1057                         nw_recvfrom
1058                         nw_select
1059                         nw_send
1060                         nw_sendto
1061                         nw_sethostent
1062                         nw_setnetent
1063                         nw_setprotoent
1064                         nw_setservent
1065                         nw_setsockopt
1066                         nw_inet_ntoa
1067                         nw_shutdown
1068                         nw_crypt
1069                         nw_execvp
1070                         nw_kill
1071                         nw_Popen
1072                         nw_Pclose
1073                         nw_Pipe
1074                         nw_times
1075                         nw_waitpid
1076                         nw_getpid
1077                         nw_spawnvp
1078                         nw_os_id
1079                         nw_open_osfhandle
1080                         nw_get_osfhandle
1081                         nw_abort
1082                         nw_sleep
1083                         nw_wait
1084                         nw_dynaload
1085                         nw_strerror
1086                         fnFpSetMode
1087                         fnInsertHashListAddrs
1088                         fnGetHashListAddrs
1089                         Perl_deb
1090                            ))
1091     {
1092         try_symbol($symbol);
1093     }
1094 }
1095
1096 # Now all symbols should be defined because
1097 # next we are going to output them.
1098
1099 foreach my $symbol (sort keys %export) {
1100     output_symbol($symbol);
1101 }
1102
1103 if ($PLATFORM eq 'netware') {
1104         # This may not be the right way to do.  This is to make sure
1105         # that the last symbol will not contain a comma else
1106         # Watcom linker cribs
1107         print "\tdummy\n";
1108 }
1109
1110 sub emit_symbol {
1111     my $symbol = shift;
1112     chomp($symbol);
1113     $export{$symbol} = 1;
1114 }
1115
1116 my $sym_ord = 0;
1117
1118 sub output_symbol {
1119     my $symbol = shift;
1120     $symbol = $bincompat5005{$symbol}
1121         if $define{PERL_BINCOMPAT_5005} and $symbol =~ /^($bincompat5005)$/;
1122     if ($PLATFORM eq 'win32') {
1123         $symbol = "_$symbol" if $CCTYPE eq 'BORLAND';
1124         print "\t$symbol\n";
1125 # XXX: binary compatibility between compilers is an exercise
1126 # in frustration :-(
1127 #        if ($CCTYPE eq "BORLAND") {
1128 #           # workaround Borland quirk by exporting both the straight
1129 #           # name and a name with leading underscore.  Note the
1130 #           # alias *must* come after the symbol itself, if both
1131 #           # are to be exported. (Linker bug?)
1132 #           print "\t_$symbol\n";
1133 #           print "\t$symbol = _$symbol\n";
1134 #       }
1135 #       elsif ($CCTYPE eq 'GCC') {
1136 #           # Symbols have leading _ whole process is $%@"% slow
1137 #           # so skip aliases for now
1138 #           nprint "\t$symbol\n";
1139 #       }
1140 #       else {
1141 #           # for binary coexistence, export both the symbol and
1142 #           # alias with leading underscore
1143 #           print "\t$symbol\n";
1144 #           print "\t_$symbol = $symbol\n";
1145 #       }
1146     }
1147     elsif ($PLATFORM eq 'os2') {
1148         printf qq(    %-31s \@%s\n), qq("$symbol"), ++$sym_ord;
1149     }
1150     elsif ($PLATFORM eq 'aix' || $PLATFORM eq 'MacOS') {
1151         print "$symbol\n";
1152     }
1153         elsif ($PLATFORM eq 'netware') {
1154         print "\t$symbol,\n";
1155         }
1156 }
1157
1158 1;
1159 __DATA__
1160 # extra globals not included above.
1161 Perl_cxinc
1162 perl_alloc
1163 perl_alloc_using
1164 perl_clone
1165 perl_clone_using
1166 perl_construct
1167 perl_destruct
1168 perl_free
1169 perl_parse
1170 perl_run
1171 PerlIOBase_clearerr
1172 PerlIOBase_close
1173 PerlIOBase_dup
1174 PerlIOBase_eof
1175 PerlIOBase_error
1176 PerlIOBase_fileno
1177 PerlIOBase_pushed
1178 PerlIOBase_read
1179 PerlIOBase_setlinebuf
1180 PerlIOBase_unread
1181 PerlIOBuf_bufsiz
1182 PerlIOBuf_fill
1183 PerlIOBuf_flush
1184 PerlIOBuf_get_cnt
1185 PerlIOBuf_get_ptr
1186 PerlIOBuf_open
1187 PerlIOBuf_pushed
1188 PerlIOBuf_read
1189 PerlIOBuf_seek
1190 PerlIOBuf_set_ptrcnt
1191 PerlIOBuf_tell
1192 PerlIOBuf_unread
1193 PerlIOBuf_write
1194 PerlIO_allocate
1195 PerlIO_apply_layers
1196 PerlIO_arg_fetch
1197 PerlIO_binmode
1198 PerlIO_define_layer
1199 PerlIO_define_layer
1200 PerlIO_getpos
1201 PerlIO_init
1202 PerlIO_modestr
1203 PerlIO_pending
1204 PerlIO_perlio
1205 PerlIO_push
1206 PerlIO_setpos
1207 PerlIO_sprintf
1208 PerlIO_sv_dup
1209 PerlIO_tmpfile
1210 PerlIO_vsprintf
1211 perlsio_binmode