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