Use PerlSIO_fdupopen() if not using PerlIO
[p5sagit/p5-mst-13.2.git] / makedef.pl
CommitLineData
549a6b10 1#
2# Create the export list for perl.
3#
86593e8d 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.
549a6b10 7#
22c35a8c 8# reads global.sym, pp.sym, perlvars.h, intrpvar.h, thrdvar.h, config.h
3cfae81b 9# On OS/2 reads miniperl.map as well
0a753a76 10
549a6b10 11my $PLATFORM;
12my $CCTYPE;
910dfcc8 13
7766f137 14while (@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+)$/);
2986a63f 20 if ($PLATFORM eq 'netware') {
21 $FILETYPE = $1 if ($flag =~ /^FILETYPE=(\w+)$/);
22 }
7766f137 23}
d55594ae 24
2986a63f 25my @PLATFORM = qw(aix win32 os2 MacOS netware);
549a6b10 26my %PLATFORM;
27@PLATFORM{@PLATFORM} = ();
28
29defined $PLATFORM || die "PLATFORM undefined, must be one of: @PLATFORM\n";
9df9a5cd 30exists $PLATFORM{$PLATFORM} || die "PLATFORM must be one of: @PLATFORM\n";
549a6b10 31
32my $config_sh = "config.sh";
33my $config_h = "config.h";
34my $thrdvar_h = "thrdvar.h";
35my $intrpvar_h = "intrpvar.h";
36my $perlvars_h = "perlvars.h";
37my $global_sym = "global.sym";
38my $pp_sym = "pp.sym";
39my $globvar_sym = "globvar.sym";
40my $perlio_sym = "perlio.sym";
41
9df9a5cd 42if ($PLATFORM eq 'aix') {
549a6b10 43 # Nothing for now.
7766f137 44}
2986a63f 45elsif ($PLATFORM eq 'win32' || $PLATFORM eq 'netware') {
549a6b10 46 $CCTYPE = "MSVC" unless defined $CCTYPE;
00b02797 47 foreach ($thrdvar_h, $intrpvar_h, $perlvars_h, $global_sym,
48 $pp_sym, $globvar_sym, $perlio_sym) {
549a6b10 49 s!^!..\\!;
50 }
51}
084592ab 52elsif ($PLATFORM eq 'MacOS') {
53 foreach ($thrdvar_h, $intrpvar_h, $perlvars_h, $global_sym,
54 $pp_sym, $globvar_sym, $perlio_sym) {
55 s!^!::!;
56 }
57}
549a6b10 58
2986a63f 59unless ($PLATFORM eq 'win32' || $PLATFORM eq 'MacOS' || $PLATFORM eq 'netware') {
549a6b10 60 open(CFG,$config_sh) || die "Cannot open $config_sh: $!\n";
7766f137 61 while (<CFG>) {
549a6b10 62 if (/^(?:ccflags|optimize)='(.+)'$/) {
63 $_ = $1;
64 $define{$1} = 1 while /-D(\w+)/g;
65 }
3cfae81b 66 if ($PLATFORM eq 'os2') {
52e4c282 67 $CONFIG_ARGS = $1 if /^config_args='(.+)'$/;
68 $ARCHNAME = $1 if /^archname='(.+)'$/;
69 $PATCHLEVEL = $1 if /^perl_patchlevel='(.+)'$/;
3cfae81b 70 }
549a6b10 71 }
72 close(CFG);
73}
74
75open(CFG,$config_h) || die "Cannot open $config_h: $!\n";
7766f137 76while (<CFG>) {
77 $define{$1} = 1 if /^\s*#\s*define\s+(MYMALLOC)\b/;
7766f137 78 $define{$1} = 1 if /^\s*#\s*define\s+(MULTIPLICITY)\b/;
0e32cd81 79 $define{$1} = 1 if /^\s*#\s*define\s+(PERL_\w+)\b/;
80 $define{$1} = 1 if /^\s*#\s*define\s+(USE_\w+)\b/;
7766f137 81}
bbc8f9de 82close(CFG);
83
18c4b137 84# perl.h logic duplication begins
85
ac6bedea 86if ($define{PERL_IMPLICIT_SYS}) {
87 $define{PL_OP_SLAB_ALLOC} = 1;
88}
89
18c4b137 90if ($define{USE_ITHREADS}) {
acfe0abc 91 if (!$define{MULTIPLICITY}) {
18c4b137 92 $define{MULTIPLICITY} = 1;
93 }
94}
95
96$define{PERL_IMPLICIT_CONTEXT} ||=
97 $define{USE_ITHREADS} ||
66cf6f75 98 $define{USE_5005THREADS} ||
18c4b137 99 $define{MULTIPLICITY} ;
100
10bc17b6 101if ($define{USE_ITHREADS} && $PLATFORM ne 'win32' && $^O ne 'darwin') {
102 $define{USE_REENTRANT_API} = 1;
103}
104
18c4b137 105# perl.h logic duplication ends
106
ac6bedea 107my $sym_ord = 0;
108
549a6b10 109if ($PLATFORM eq 'win32') {
110 warn join(' ',keys %define)."\n";
9c25e1f8 111 print "LIBRARY perl58\n";
dfdd1393 112 print "DESCRIPTION 'Perl interpreter'\n";
113 print "EXPORTS\n";
114 if ($define{PERL_IMPLICIT_SYS}) {
549a6b10 115 output_symbol("perl_get_host_info");
7766f137 116 output_symbol("perl_alloc_override");
ac6bedea 117 output_symbol("perl_clone_host");
51371543 118 }
7766f137 119}
120elsif ($PLATFORM eq 'os2') {
52e4c282 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 }
3cfae81b 132 ($v = $]) =~ s/(\d\.\d\d\d)(\d\d)$/$1_$2/;
133 $v .= '-thread' if $ARCHNAME =~ /-thread/;
3cfae81b 134 ($dll = $define{PERL_DLL}) =~ s/\.dll$//i;
52e4c282 135 $v .= "\@$PATCHLEVEL" if $PATCHLEVEL;
1102eebe 136 $d = "DESCRIPTION '\@#perl5-porters\@perl.org:$v#\@ Perl interpreter, configured as $CONFIG_ARGS'";
137 $d = substr($d, 0, 249) . "...'" if length $d > 253;
3cfae81b 138 print <<"---EOP---";
139LIBRARY '$dll' INITINSTANCE TERMINSTANCE
1102eebe 140$d
3cfae81b 141STACKSIZE 32768
142CODE LOADONCALL
143DATA LOADONCALL NONSHARED MULTIPLE
144EXPORTS
145---EOP---
7766f137 146}
147elsif ($PLATFORM eq 'aix') {
61d42ce4 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 }
ac4c12e7 157}
2986a63f 158elsif ($PLATFORM eq 'netware') {
159 if ($FILETYPE eq 'def') {
9c25e1f8 160 print "LIBRARY perl58\n";
2986a63f 161 print "DESCRIPTION 'Perl interpreter for NetWare'\n";
162 print "EXPORTS\n";
163 }
164 if ($define{PERL_IMPLICIT_SYS}) {
ac6bedea 165 output_symbol("perl_get_host_info");
166 output_symbol("perl_alloc_override");
167 output_symbol("perl_clone_host");
2986a63f 168 }
169}
bbc8f9de 170
22239a37 171my %skip;
172my %export;
173
51371543 174sub skip_symbols {
175 my $list = shift;
176 foreach my $symbol (@$list) {
177 $skip{$symbol} = 1;
178 }
22239a37 179}
180
51371543 181sub emit_symbols {
182 my $list = shift;
183 foreach my $symbol (@$list) {
184 my $skipsym = $symbol;
185 # XXX hack
acfe0abc 186 if ($define{MULTIPLICITY}) {
51371543 187 $skipsym =~ s/^Perl_[GIT](\w+)_ptr$/PL_$1/;
188 }
189 emit_symbol($symbol) unless exists $skip{$skipsym};
190 }
22239a37 191}
192
549a6b10 193if ($PLATFORM eq 'win32') {
7766f137 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
9d50d399 220 Perl_my_bcopy
7766f137 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}
244elsif ($PLATFORM eq 'aix') {
549a6b10 245 skip_symbols([qw(
7766f137 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
6c644e78 263 Perl_sys_intern_clear
95151ede 264 Perl_sys_intern_dup
52853b95 265 Perl_sys_intern_init
7766f137 266 PL_cryptseen
267 PL_opsave
268 PL_statusvalue_vms
269 PL_sys_intern
270 )]);
271}
272elsif ($PLATFORM eq 'os2') {
3cfae81b 273 emit_symbols([qw(
7766f137 274 ctermid
275 get_sysinfo
276 Perl_OS2_init
764df951 277 Perl_OS2_init3
278 Perl_OS2_term
7766f137 279 OS2_Perl_data
280 dlopen
281 dlsym
282 dlerror
403d6f8e 283 dlclose
7766f137 284 my_tmpfile
285 my_tmpnam
286 my_flock
9c130f5b 287 my_rmdir
288 my_mkdir
f72c975a 289 my_getpwuid
290 my_getpwnam
291 my_getpwent
292 my_setpwent
293 my_endpwent
294 setgrent
295 endgrent
296 getgrent
7766f137 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
35bc1fdc 325 loadByOrdinal
326 pExtFCN
30500b05 327 os2error
328 ResetWinError
329 CroakWinError
7766f137 330 )]);
3cfae81b 331}
084592ab 332elsif ($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
fe05f414 356 Perl_sys_intern_clear
357 Perl_sys_intern_init
084592ab 358 )];
359}
2986a63f 360elsif ($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
011f1a1a 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
2986a63f 435 )];
436}
3cfae81b 437
7766f137 438unless ($define{'DEBUGGING'}) {
439 skip_symbols [qw(
7766f137 440 Perl_deb_growlevel
441 Perl_debop
442 Perl_debprofdump
443 Perl_debstack
444 Perl_debstackptrs
7766f137 445 Perl_sv_peek
446 PL_block_type
447 PL_watchaddr
448 PL_watchok
449 )];
450}
451
452if ($define{'PERL_IMPLICIT_SYS'}) {
453 skip_symbols [qw(
454 Perl_getenv_len
455 Perl_my_popen
456 Perl_my_pclose
457 )];
458}
459else {
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
7c128300 473unless ($define{'PERL_FLEXIBLE_EXCEPTIONS'}) {
474 skip_symbols [qw(
475 PL_protect
476 Perl_default_protect
477 Perl_vdefault_protect
478 )];
479}
480
5bcb3f6c 481unless ($define{'USE_REENTRANT_API'}) {
482 skip_symbols [qw(
483 PL_reentrant_buffer
484 )];
485}
486
7766f137 487if ($define{'MYMALLOC'}) {
488 emit_symbols [qw(
489 Perl_dump_mstats
827e134a 490 Perl_get_mstats
9c130f5b 491 Perl_strdup
492 Perl_putenv
7766f137 493 )];
bbda9c9d 494 if ($define{'USE_5005THREADS'} || $define{'USE_ITHREADS'}) {
1feb2720 495 emit_symbols [qw(
496 PL_malloc_mutex
497 )];
498 }
80fc1a6e 499 else {
500 skip_symbols [qw(
501 PL_malloc_mutex
502 )];
503 }
51371543 504}
505else {
7766f137 506 skip_symbols [qw(
507 PL_malloc_mutex
508 Perl_dump_mstats
6ecd3fcb 509 Perl_get_mstats
7766f137 510 Perl_malloced_size
511 )];
512}
513
f433d095 514unless ($define{'USE_5005THREADS'} || $define{'USE_ITHREADS'}) {
7766f137 515 skip_symbols [qw(
516 PL_thr_key
f433d095 517 )];
518}
519
520unless ($define{'USE_5005THREADS'}) {
521 skip_symbols [qw(
7766f137 522 PL_sv_mutex
523 PL_strtab_mutex
524 PL_svref_mutex
7766f137 525 PL_cred_mutex
526 PL_eval_mutex
6940069f 527 PL_fdpid_mutex
528 PL_sv_lock_mutex
7766f137 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
7766f137 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
4755096e 545 Perl_sv_lock
7766f137 546 )];
547}
548
549unless ($define{'USE_ITHREADS'}) {
550 skip_symbols [qw(
551 PL_ptr_table
534825c4 552 PL_op_mutex
7e95b20d 553 PL_regex_pad
554 PL_regex_padav
f2f7cecd 555 PL_sharedsv_space
556 PL_sharedsv_space_mutex
7766f137 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
86593e8d 569 Perl_ptr_table_clear
7766f137 570 Perl_ptr_table_fetch
86593e8d 571 Perl_ptr_table_free
7766f137 572 Perl_ptr_table_new
4ac9195f 573 Perl_ptr_table_clear
574 Perl_ptr_table_free
7766f137 575 Perl_ptr_table_split
576 Perl_ptr_table_store
577 perl_clone
578 perl_clone_using
038f0558 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
7766f137 586 )];
587}
588
589unless ($define{'PERL_IMPLICIT_CONTEXT'}) {
590 skip_symbols [qw(
591 Perl_croak_nocontext
592 Perl_die_nocontext
593 Perl_deb_nocontext
594 Perl_form_nocontext
e0f4245d 595 Perl_load_module_nocontext
7766f137 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
607unless ($define{'PERL_IMPLICIT_SYS'}) {
608 skip_symbols [qw(
609 perl_alloc_using
014822e4 610 perl_clone_using
7766f137 611 )];
612}
613
614unless ($define{'FAKE_THREADS'}) {
615 skip_symbols [qw(PL_curthr)];
616}
617
ac6bedea 618unless ($define{'PL_OP_SLAB_ALLOC'}) {
619 skip_symbols [qw(
620 PL_OpPtr
621 PL_OpSlab
622 PL_OpSpace
623 )];
624}
625
7766f137 626sub 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+)/);
9df9a5cd 635 }
636 close(VARS);
7766f137 637 return \@syms;
638}
639
6f4183fe 640if ($define{'USE_5005THREADS'}) {
7766f137 641 my $thrd = readvar($thrdvar_h);
642 skip_symbols $thrd;
643}
644
7766f137 645if ($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}
36c15d3f 651
22c35a8c 652# functions from *.sym files
653
954c1994 654my @syms = ($global_sym, $globvar_sym); # $pp_sym is not part of the API
549a6b10 655
d892637e 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
9df9a5cd 659my @layer_syms = qw(
660 PerlIOBase_clearerr
661 PerlIOBase_close
8437356b 662 PerlIOBase_dup
9df9a5cd 663 PerlIOBase_eof
664 PerlIOBase_error
665 PerlIOBase_fileno
8c0134a8 666 PerlIOBase_pushed
667 PerlIOBase_read
55ac2d47 668 PerlIOBase_setlinebuf
d892637e 669 PerlIOBase_unread
9df9a5cd 670 PerlIOBuf_bufsiz
9df9a5cd 671 PerlIOBuf_fill
672 PerlIOBuf_flush
673 PerlIOBuf_get_cnt
674 PerlIOBuf_get_ptr
675 PerlIOBuf_open
676 PerlIOBuf_pushed
677 PerlIOBuf_read
9df9a5cd 678 PerlIOBuf_seek
679 PerlIOBuf_set_ptrcnt
9df9a5cd 680 PerlIOBuf_tell
681 PerlIOBuf_unread
682 PerlIOBuf_write
d892637e 683 PerlIO_debug
55ac2d47 684 PerlIO_allocate
d892637e 685 PerlIO_apply_layera
686 PerlIO_apply_layers
8c0134a8 687 PerlIO_arg_fetch
55ac2d47 688 PerlIO_define_layer
d9dac8cd 689 PerlIO_modestr
690 PerlIO_parse_layers
691 PerlIO_layer_fetch
692 PerlIO_list_free
693 PerlIO_apply_layera
9df9a5cd 694 PerlIO_pending
695 PerlIO_push
8437356b 696 PerlIO_sv_dup
ad6971c8 697 PerlIO_perlio
9df9a5cd 698);
699
d892637e 700
7766f137 701if ($define{'USE_PERLIO'}) {
d892637e 702 # Export the symols that make up the PerlIO abstraction, regardless
703 # of its implementation - read from a file
084592ab 704 push @syms, $perlio_sym;
d892637e 705
706 # This part is then dependent on how the abstraction is implemented
084592ab 707 if ($define{'USE_SFIO'}) {
d892637e 708 # Old legacy non-stdio "PerlIO"
9df9a5cd 709 skip_symbols \@layer_syms;
084592ab 710 # SFIO defines most of the PerlIO routines as macros
d892637e 711 # So undo most of what $perlio_sym has just done - d'oh !
712 # Perhaps it would be better to list the ones which do exist
713 # And emit them
084592ab 714 skip_symbols [qw(
715 PerlIO_canset_cnt
716 PerlIO_clearerr
717 PerlIO_close
718 PerlIO_eof
719 PerlIO_error
720 PerlIO_exportFILE
721 PerlIO_fast_gets
722 PerlIO_fdopen
723 PerlIO_fileno
724 PerlIO_findFILE
725 PerlIO_flush
726 PerlIO_get_base
727 PerlIO_get_bufsiz
728 PerlIO_get_cnt
729 PerlIO_get_ptr
730 PerlIO_getc
731 PerlIO_getname
732 PerlIO_has_base
733 PerlIO_has_cntptr
734 PerlIO_importFILE
735 PerlIO_open
736 PerlIO_printf
737 PerlIO_putc
738 PerlIO_puts
739 PerlIO_read
740 PerlIO_releaseFILE
741 PerlIO_reopen
742 PerlIO_rewind
743 PerlIO_seek
744 PerlIO_set_cnt
745 PerlIO_set_ptrcnt
746 PerlIO_setlinebuf
747 PerlIO_sprintf
748 PerlIO_stderr
749 PerlIO_stdin
750 PerlIO_stdout
751 PerlIO_stdoutf
752 PerlIO_tell
753 PerlIO_ungetc
754 PerlIO_vprintf
755 PerlIO_write
bcdb689b 756 PerlIO_perlio
757 Perl_PerlIO_clearerr
758 Perl_PerlIO_close
759 Perl_PerlIO_eof
760 Perl_PerlIO_error
761 Perl_PerlIO_fileno
762 Perl_PerlIO_fill
763 Perl_PerlIO_flush
764 Perl_PerlIO_get_base
765 Perl_PerlIO_get_bufsiz
766 Perl_PerlIO_get_cnt
767 Perl_PerlIO_get_ptr
768 Perl_PerlIO_read
769 Perl_PerlIO_seek
770 Perl_PerlIO_set_cnt
771 Perl_PerlIO_set_ptrcnt
772 Perl_PerlIO_setlinebuf
773 Perl_PerlIO_stderr
774 Perl_PerlIO_stdin
775 Perl_PerlIO_stdout
776 Perl_PerlIO_tell
777 Perl_PerlIO_unread
778 Perl_PerlIO_write
084592ab 779 )];
780 }
d892637e 781 else {
782 # PerlIO with layers - export implementation
783 emit_symbols \@layer_syms;
784 }
5138f914 785} else {
d892637e 786 # -Uuseperlio
787 # Skip the PerlIO layer symbols - although
788 # nothing should have exported them any way
9df9a5cd 789 skip_symbols \@layer_syms;
d892637e 790 # Also do NOT add abstraction symbols from $perlio_sym
791 # abstraction is done as #define to stdio
792 # Remaining remnants that _may_ be functions
793 # are handled in <DATA>
9df9a5cd 794}
7766f137 795
796for my $syms (@syms) {
797 open (GLOBAL, "<$syms") || die "failed to open $syms: $!\n";
798 while (<GLOBAL>) {
799 next if (!/^[A-Za-z]/);
800 # Functions have a Perl_ prefix
801 # Variables have a PL_ prefix
802 chomp($_);
803 my $symbol = ($syms =~ /var\.sym$/i ? "PL_" : "");
804 $symbol .= $_;
805 emit_symbol($symbol) unless exists $skip{$symbol};
806 }
807 close(GLOBAL);
808}
0a753a76 809
22c35a8c 810# variables
0a753a76 811
acfe0abc 812if ($define{'MULTIPLICITY'}) {
1acb48c9 813 for my $f ($perlvars_h, $intrpvar_h, $thrdvar_h) {
18c4b137 814 my $glob = readvar($f, sub { "Perl_" . $_[1] . $_[2] . "_ptr" });
815 emit_symbols $glob;
18c4b137 816 }
1acb48c9 817 # XXX AIX seems to want the perlvars.h symbols, for some reason
818 if ($PLATFORM eq 'aix') {
819 my $glob = readvar($perlvars_h);
51371543 820 emit_symbols $glob;
821 }
822}
823else {
824 unless ($define{'PERL_GLOBAL_STRUCT'}) {
549a6b10 825 my $glob = readvar($perlvars_h);
51371543 826 emit_symbols $glob;
9df9a5cd 827 }
51371543 828 unless ($define{'MULTIPLICITY'}) {
549a6b10 829 my $glob = readvar($intrpvar_h);
51371543 830 emit_symbols $glob;
9df9a5cd 831 }
bbda9c9d 832 unless ($define{'MULTIPLICITY'} || $define{'USE_5005THREADS'}) {
549a6b10 833 my $glob = readvar($thrdvar_h);
51371543 834 emit_symbols $glob;
9df9a5cd 835 }
51371543 836}
0a753a76 837
549a6b10 838sub try_symbol {
839 my $symbol = shift;
22239a37 840
4d6b4052 841 return if $symbol !~ /^[A-Za-z_]/;
549a6b10 842 return if $symbol =~ /^\#/;
843 $symbol =~s/\r//g;
844 chomp($symbol);
43cd9f80 845 return if exists $skip{$symbol};
549a6b10 846 emit_symbol($symbol);
3e3baf6d 847}
0a753a76 848
549a6b10 849while (<DATA>) {
850 try_symbol($_);
ac4c12e7 851}
852
549a6b10 853if ($PLATFORM eq 'win32') {
854 foreach my $symbol (qw(
00b02797 855 setuid
856 setgid
7766f137 857 boot_DynaLoader
7766f137 858 Perl_init_os_extras
c44d3fdb 859 Perl_thread_create
7766f137 860 Perl_win32_init
861 RunPerl
5290524f 862 win32_async_check
7766f137 863 win32_errno
864 win32_environ
7766f137 865 win32_abort
866 win32_fstat
867 win32_stat
868 win32_pipe
869 win32_popen
870 win32_pclose
871 win32_rename
872 win32_setmode
873 win32_lseek
874 win32_tell
875 win32_dup
876 win32_dup2
877 win32_open
878 win32_close
879 win32_eof
880 win32_read
881 win32_write
882 win32_spawnvp
883 win32_mkdir
884 win32_rmdir
885 win32_chdir
886 win32_flock
887 win32_execv
888 win32_execvp
889 win32_htons
890 win32_ntohs
891 win32_htonl
892 win32_ntohl
893 win32_inet_addr
894 win32_inet_ntoa
895 win32_socket
896 win32_bind
897 win32_listen
898 win32_accept
899 win32_connect
900 win32_send
901 win32_sendto
902 win32_recv
903 win32_recvfrom
904 win32_shutdown
905 win32_closesocket
906 win32_ioctlsocket
907 win32_setsockopt
908 win32_getsockopt
909 win32_getpeername
910 win32_getsockname
911 win32_gethostname
912 win32_gethostbyname
913 win32_gethostbyaddr
914 win32_getprotobyname
915 win32_getprotobynumber
916 win32_getservbyname
917 win32_getservbyport
918 win32_select
919 win32_endhostent
920 win32_endnetent
921 win32_endprotoent
922 win32_endservent
923 win32_getnetent
924 win32_getnetbyname
925 win32_getnetbyaddr
926 win32_getprotoent
927 win32_getservent
928 win32_sethostent
929 win32_setnetent
930 win32_setprotoent
931 win32_setservent
932 win32_getenv
933 win32_putenv
934 win32_perror
7766f137 935 win32_malloc
936 win32_calloc
937 win32_realloc
938 win32_free
939 win32_sleep
940 win32_times
941 win32_access
942 win32_alarm
943 win32_chmod
944 win32_open_osfhandle
945 win32_get_osfhandle
946 win32_ioctl
947 win32_link
948 win32_unlink
949 win32_utime
950 win32_uname
951 win32_wait
952 win32_waitpid
953 win32_kill
954 win32_str_os_error
955 win32_opendir
956 win32_readdir
957 win32_telldir
958 win32_seekdir
959 win32_rewinddir
960 win32_closedir
961 win32_longpath
962 win32_os_id
963 win32_getpid
964 win32_crypt
965 win32_dynaload
df3728a2 966 win32_get_childenv
967 win32_free_childenv
968 win32_clearenv
969 win32_get_childdir
970 win32_free_childdir
00b02797 971 win32_stdin
972 win32_stdout
973 win32_stderr
974 win32_ferror
975 win32_feof
976 win32_strerror
977 win32_fprintf
978 win32_printf
979 win32_vfprintf
980 win32_vprintf
981 win32_fread
982 win32_fwrite
983 win32_fopen
984 win32_fdopen
985 win32_freopen
986 win32_fclose
987 win32_fputs
988 win32_fputc
989 win32_ungetc
990 win32_getc
991 win32_fileno
992 win32_clearerr
993 win32_fflush
994 win32_ftell
995 win32_fseek
996 win32_fgetpos
997 win32_fsetpos
998 win32_rewind
999 win32_tmpfile
1000 win32_setbuf
1001 win32_setvbuf
1002 win32_flushall
1003 win32_fcloseall
1004 win32_fgets
1005 win32_gets
1006 win32_fgetc
1007 win32_putc
1008 win32_puts
1009 win32_getchar
1010 win32_putchar
7766f137 1011 ))
1012 {
549a6b10 1013 try_symbol($symbol);
1014 }
1015}
3cfae81b 1016elsif ($PLATFORM eq 'os2') {
7766f137 1017 open MAP, 'miniperl.map' or die 'Cannot read miniperl.map';
1018 /^\s*[\da-f:]+\s+(\w+)/i and $mapped{$1}++ foreach <MAP>;
1019 close MAP or die 'Cannot close miniperl.map';
1020
ad6971c8 1021 @missing = grep { !exists $mapped{$_} }
7766f137 1022 keys %export;
1023 delete $export{$_} foreach @missing;
3cfae81b 1024}
084592ab 1025elsif ($PLATFORM eq 'MacOS') {
1026 open MACSYMS, 'macperl.sym' or die 'Cannot read macperl.sym';
1027
1028 while (<MACSYMS>) {
1029 try_symbol($_);
1030 }
1031
1032 close MACSYMS;
1033}
2986a63f 1034elsif ($PLATFORM eq 'netware') {
1035foreach my $symbol (qw(
1036 boot_DynaLoader
1037 Perl_init_os_extras
1038 Perl_thread_create
1039 Perl_nw5_init
1040 RunPerl
1041 AllocStdPerl
1042 FreeStdPerl
1043 do_spawn2
1044 do_aspawn
1045 nw_uname
1046 nw_stdin
1047 nw_stdout
1048 nw_stderr
1049 nw_feof
1050 nw_ferror
1051 nw_fopen
1052 nw_fclose
1053 nw_clearerr
1054 nw_getc
1055 nw_fgets
1056 nw_fputc
1057 nw_fputs
1058 nw_fflush
1059 nw_ungetc
1060 nw_fileno
1061 nw_fdopen
1062 nw_freopen
1063 nw_fread
1064 nw_fwrite
1065 nw_setbuf
1066 nw_setvbuf
1067 nw_vfprintf
1068 nw_ftell
1069 nw_fseek
1070 nw_rewind
1071 nw_tmpfile
1072 nw_fgetpos
1073 nw_fsetpos
1074 nw_dup
1075 nw_access
1076 nw_chmod
1077 nw_chsize
1078 nw_close
1079 nw_dup2
1080 nw_flock
1081 nw_isatty
1082 nw_link
1083 nw_lseek
1084 nw_stat
1085 nw_mktemp
1086 nw_open
1087 nw_read
1088 nw_rename
1089 nw_setmode
1090 nw_unlink
1091 nw_utime
1092 nw_write
1093 nw_chdir
1094 nw_rmdir
1095 nw_closedir
1096 nw_opendir
1097 nw_readdir
1098 nw_rewinddir
1099 nw_seekdir
1100 nw_telldir
1101 nw_htonl
1102 nw_htons
1103 nw_ntohl
1104 nw_ntohs
1105 nw_accept
1106 nw_bind
1107 nw_connect
1108 nw_endhostent
1109 nw_endnetent
1110 nw_endprotoent
1111 nw_endservent
1112 nw_gethostbyaddr
1113 nw_gethostbyname
1114 nw_gethostent
1115 nw_gethostname
1116 nw_getnetbyaddr
1117 nw_getnetbyname
1118 nw_getnetent
1119 nw_getpeername
1120 nw_getprotobyname
1121 nw_getprotobynumber
1122 nw_getprotoent
1123 nw_getservbyname
1124 nw_getservbyport
1125 nw_getservent
1126 nw_getsockname
1127 nw_getsockopt
1128 nw_inet_addr
1129 nw_listen
1130 nw_socket
1131 nw_recv
1132 nw_recvfrom
1133 nw_select
1134 nw_send
1135 nw_sendto
1136 nw_sethostent
1137 nw_setnetent
1138 nw_setprotoent
1139 nw_setservent
3a0827a6 1140 nw_setsockopt
4d76e4b4 1141 nw_inet_ntoa
2986a63f 1142 nw_shutdown
1143 nw_crypt
1144 nw_execvp
1145 nw_kill
1146 nw_Popen
1147 nw_Pclose
1148 nw_Pipe
1149 nw_times
1150 nw_waitpid
1151 nw_getpid
1152 nw_spawnvp
1153 nw_os_id
1154 nw_open_osfhandle
1155 nw_get_osfhandle
1156 nw_abort
1157 nw_sleep
1158 nw_wait
1159 nw_dynaload
1160 nw_strerror
1161 fnFpSetMode
1162 fnInsertHashListAddrs
1163 fnGetHashListAddrs
1164 Perl_deb
011f1a1a 1165 Perl_sv_setsv
1166 Perl_sv_catsv
1167 Perl_sv_catpvn
1168 Perl_sv_2pv
2986a63f 1169 ))
1170 {
1171 try_symbol($symbol);
1172 }
1173}
22239a37 1174
549a6b10 1175# Now all symbols should be defined because
1176# next we are going to output them.
1177
7766f137 1178foreach my $symbol (sort keys %export) {
1179 output_symbol($symbol);
1180}
549a6b10 1181
011f1a1a 1182if ($PLATFORM eq 'os2') {
52e4c282 1183 print "; LAST_ORDINAL=$sym_ord\n";
2986a63f 1184}
1185
549a6b10 1186sub emit_symbol {
7766f137 1187 my $symbol = shift;
9df9a5cd 1188 chomp($symbol);
7766f137 1189 $export{$symbol} = 1;
549a6b10 1190}
1191
1192sub output_symbol {
1193 my $symbol = shift;
1194 if ($PLATFORM eq 'win32') {
549a6b10 1195 $symbol = "_$symbol" if $CCTYPE eq 'BORLAND';
520c758a 1196 print "\t$symbol\n";
549a6b10 1197# XXX: binary compatibility between compilers is an exercise
1198# in frustration :-(
1199# if ($CCTYPE eq "BORLAND") {
1200# # workaround Borland quirk by exporting both the straight
1201# # name and a name with leading underscore. Note the
1202# # alias *must* come after the symbol itself, if both
1203# # are to be exported. (Linker bug?)
1204# print "\t_$symbol\n";
1205# print "\t$symbol = _$symbol\n";
1206# }
1207# elsif ($CCTYPE eq 'GCC') {
1208# # Symbols have leading _ whole process is $%@"% slow
1209# # so skip aliases for now
1210# nprint "\t$symbol\n";
1211# }
1212# else {
1213# # for binary coexistence, export both the symbol and
1214# # alias with leading underscore
1215# print "\t$symbol\n";
1216# print "\t_$symbol = $symbol\n";
1217# }
7766f137 1218 }
1219 elsif ($PLATFORM eq 'os2') {
52e4c282 1220 printf qq( %-31s \@%s\n),
1221 qq("$symbol"), $ordinal{$symbol} || ++$sym_ord;
7766f137 1222 }
084592ab 1223 elsif ($PLATFORM eq 'aix' || $PLATFORM eq 'MacOS') {
549a6b10 1224 print "$symbol\n";
1225 }
2986a63f 1226 elsif ($PLATFORM eq 'netware') {
1227 print "\t$symbol,\n";
1228 }
549a6b10 1229}
1230
12311;
1232__DATA__
1233# extra globals not included above.
8437356b 1234Perl_cxinc
549a6b10 1235perl_alloc
7766f137 1236perl_alloc_using
014822e4 1237perl_clone
1238perl_clone_using
549a6b10 1239perl_construct
1240perl_destruct
1241perl_free
1242perl_parse
1243perl_run
b6d604f4 1244# Oddities from PerlIO
1245PerlIO_open
568ad336 1246PerlIO_binmode
8437356b 1247PerlIO_getpos
568ad336 1248PerlIO_init
a8b77c32 1249PerlIO_perlio
568ad336 1250PerlIO_setpos
568ad336 1251PerlIO_sprintf
b6d604f4 1252PerlIO_printf
8437356b 1253PerlIO_sv_dup
1254PerlIO_tmpfile
8437356b 1255PerlIO_vsprintf
1256perlsio_binmode