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