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