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