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