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