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