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