This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Correct code-like snippet in documentation
[perl5.git] / makedef.pl
CommitLineData
3df97b6d 1#./perl -w
549a6b10
JH
2#
3# Create the export list for perl.
4#
86593e8d 5# Needed by WIN32 and OS/2 for creating perl.dll,
60fae896 6# and by AIX for creating libperl.a when -Duseshrplib is in effect,
93ea32b8 7# and by VMS for creating perlshr.exe.
549a6b10 8#
3523994b
DM
9# Reads from information stored in
10#
208d7614 11# %Config::Config (ie config.sh)
3523994b 12# config.h
d500e60d 13# embed.fnc
3523994b
DM
14# globvar.sym
15# intrpvar.h
3523994b
DM
16# miniperl.map (on OS/2)
17# perl5.def (on OS/2; this is the old version of the file being made)
18# perlio.sym
19# perlvars.h
d500e60d 20# regen/opcodes
3523994b 21#
bf09e1bd 22# plus long lists of function names hard-coded directly in this script.
3523994b
DM
23#
24# Writes the result to STDOUT.
25#
26# Normally this script is invoked from a makefile (e.g. win32/Makefile),
27# which redirects STDOUT to a suitable file, such as:
28#
29# perl5.def OS/2
30# perldll.def Windows
31# perl.exp AIX
93ea32b8 32# makedef.lis VMS
c560d966 33
681a22f4
NC
34use strict;
35use Config;
c5ceea5a 36use warnings;
681a22f4 37
196f7c46
DD
38my $fold;
39my %ARGS;
d6035849 40my %define;
910dfcc8 41
196f7c46 42BEGIN {
196f7c46 43 %ARGS = (CCTYPE => 'MSVC', TARG_DIR => '');
c1b34f5f 44
196f7c46
DD
45 sub process_cc_flags {
46 foreach (map {split /\s+/, $_} @_) {
47 $define{$1} = $2 // 1 if /^-D(\w+)(?:=(.+))?/;
48 }
5c728af0 49 }
d55594ae 50
196f7c46
DD
51 while (@ARGV) {
52 my $flag = shift;
53 if ($flag =~ /^(?:CC_FLAGS=)?(-D\w.*)/) {
54 process_cc_flags($1);
55 } elsif ($flag =~ /^(CCTYPE|FILETYPE|PLATFORM|TARG_DIR)=(.+)$/) {
56 $ARGS{$1} = $2;
57 } elsif ($flag eq '--sort-fold') {
58 ++$fold;
59 }
60 }
2eb109a4 61 my @PLATFORM = qw(aix win32 os2 vms test);
29200a82
NC
62 my %PLATFORM;
63 @PLATFORM{@PLATFORM} = ();
549a6b10 64
29200a82
NC
65 die "PLATFORM undefined, must be one of: @PLATFORM\n"
66 unless defined $ARGS{PLATFORM};
67 die "PLATFORM must be one of: @PLATFORM\n"
68 unless exists $PLATFORM{$ARGS{PLATFORM}};
69}
7431637b 70
196f7c46
DD
71use constant PLATFORM => $ARGS{PLATFORM};
72
7431637b
KW
73# This makes us able to use, e.g., $define{WIN32}, so you don't have to
74# remember what things came from %ARGS.
75$define{uc $ARGS{'PLATFORM'}} = 1;
76
3d7c117d 77require "./$ARGS{TARG_DIR}regen/embed_lib.pl";
549a6b10 78
208d7614
NC
79# Is the following guard strictly necessary? Added during refactoring
80# to keep the same behaviour when merging other code into here.
c1b34f5f 81process_cc_flags(@Config{qw(ccflags optimize)})
89201293 82 if PLATFORM ne 'win32';
208d7614 83
c960bcfd
NC
84# Add the compile-time options that miniperl was built with to %define.
85# On Win32 these are not the same options as perl itself will be built
86# with since miniperl is built with a canned config (one of the win32/
87# config_H.*) and none of the BUILDOPT's that are set in the makefiles,
88# but they do include some #define's that are hard-coded in various
89# source files and header files and don't include any BUILDOPT's that
90# the user might have chosen to disable because the canned configs are
91# minimal configs that don't include any of those options.
92
79c32fc2 93my @options = sort(Config::bincompat_options(), Config::non_bincompat_options());
89201293 94print STDERR "Options: (@options)\n" unless PLATFORM eq 'test';
79c32fc2 95$define{$_} = 1 foreach @options;
17bdc114 96
c6261f3b
JH
97my %exportperlmalloc =
98 (
99 Perl_malloc => "malloc",
100 Perl_mfree => "free",
101 Perl_realloc => "realloc",
102 Perl_calloc => "calloc",
103 );
104
89201293 105my $exportperlmalloc = PLATFORM eq 'os2';
c6261f3b 106
9f88ff7a 107my $config_h = 'config.h';
61b311ca 108open(CFG, '<', $config_h) || die "Cannot open $config_h: $!\n";
7766f137 109while (<CFG>) {
1f0041ed 110 $define{$1} = 1 if /^\s*\#\s*define\s+(MYMALLOC|MULTIPLICITY
dc2a396b 111 |KILL_BY_SIGPRC
1f0041ed 112 |(?:PERL|USE|HAS)_\w+)\b/x;
7766f137 113}
bbc8f9de
NIS
114close(CFG);
115
7de8159a 116#==========================================================================
18c4b137
JH
117# perl.h logic duplication begins
118
7431637b 119
18c4b137 120if ($define{USE_ITHREADS}) {
acfe0abc 121 if (!$define{MULTIPLICITY}) {
18c4b137
JH
122 $define{MULTIPLICITY} = 1;
123 }
124}
125
6e512bc2 126$define{MULTIPLICITY} ||=
18c4b137 127 $define{USE_ITHREADS} ||
6e512bc2 128 $define{PERL_IMPLICIT_CONTEXT} ;
18c4b137 129
7431637b 130if ($define{USE_ITHREADS} && ! $define{WIN32}) {
10bc17b6
JH
131 $define{USE_REENTRANT_API} = 1;
132}
133
aa8a2baa
KW
134if (! $define{NO_LOCALE}) {
135 if ( ! $define{NO_POSIX_2008_LOCALE}
136 && $define{HAS_NEWLOCALE}
137 && $define{HAS_USELOCALE}
138 && $define{HAS_DUPLOCALE}
139 && $define{HAS_FREELOCALE})
5a53bf38 140 {
aa8a2baa
KW
141 $define{HAS_POSIX_2008_LOCALE} = 1;
142 $define{USE_LOCALE} = 1;
5a53bf38 143 }
aa8a2baa
KW
144 elsif ($define{HAS_SETLOCALE}) {
145 $define{USE_LOCALE} = 1;
5a53bf38
KW
146 }
147}
148
522d5f90 149# https://en.wikipedia.org/wiki/Microsoft_Visual_C%2B%2B#Internal_version_numbering
aa8a2baa 150my $cctype = $ARGS{CCTYPE} =~ s/MSVC//r;
8751a11f
KW
151if ($define{USE_ITHREADS} && ! $define{NO_LOCALE_THREADS}) {
152 $define{USE_LOCALE_THREADS} = 1;
153}
7de8159a
KW
154
155if ( $define{HAS_POSIX_2008_LOCALE}
156 && ( ! $define{HAS_SETLOCALE} || ( $define{USE_LOCALE_THREADS}
157 && ! $define{NO_POSIX_2008_LOCALE})))
158{
aa8a2baa 159 $define{USE_POSIX_2008_LOCALE} = 1;
aa8a2baa 160}
7de8159a
KW
161
162if ($define{USE_LOCALE_THREADS} && ! $define{NO_THREAD_SAFE_LOCALE})
163{
164 if ( $define{USE_POSIX_2008_LOCALE}
7431637b
KW
165 || ($define{WIN32} && ( $cctype !~ /\D/
166 && $cctype >= 80)))
7de8159a
KW
167 {
168 $define{USE_THREAD_SAFE_LOCALE} = 1;
169 }
170}
171
172if ($define{USE_POSIX_2008_LOCALE} && $define{HAS_QUERYLOCALE})
aa8a2baa 173{
7de8159a
KW
174 $define{USE_QUERYLOCALE} = 1;
175
176 # Don't need glibc only code from perl.h
aa8a2baa
KW
177}
178
7de8159a 179if ($define{USE_POSIX_2008_LOCALE} && ! $define{USE_QUERYLOCALE})
5e395a7a
KW
180{
181 $define{USE_PL_CURLOCALES} = 1;
6a4065f2 182 $define{USE_PL_CUR_LC_ALL} = 1;
5e395a7a
KW
183}
184
7431637b 185if ($define{WIN32} && $define{USE_THREAD_SAFE_LOCALE})
aa8a2baa 186{
644641ff
KW
187 $define{USE_PL_CUR_LC_ALL} = 1;
188
7de8159a
KW
189 if ($cctype < 140) {
190 $define{TS_W32_BROKEN_LOCALECONV} = 1;
191 }
aa8a2baa
KW
192}
193
644641ff 194if ($define{MULTIPLICITY} && ( $define{USE_POSIX_2008_LOCALE}
7431637b 195 || ( $define{WIN32}
89201293 196 && $define{USE_THREAD_SAFE_LOCALE})))
644641ff 197{
84fa78b4 198 $define{USE_PERL_SWITCH_LOCALE_CONTEXT} = 1;
644641ff
KW
199}
200
18c4b137 201# perl.h logic duplication ends
7de8159a 202#==========================================================================
18c4b137 203
1f7ae1be 204print STDERR "Defines: (" . join(' ', sort keys %define) . ")\n"
89201293 205 unless PLATFORM eq 'test';
dcddf0a3 206
d6035849
NC
207my $sym_ord = 0;
208my %ordinal;
209
89201293 210if (PLATFORM eq 'os2') {
52e4c282
IZ
211 if (open my $fh, '<', 'perl5.def') {
212 while (<$fh>) {
213 last if /^\s*EXPORTS\b/;
214 }
215 while (<$fh>) {
78232bc0 216 $ordinal{$1} = $2 if /^\s*"(\w+)"\s*(?:=\s*"\w+"\s*)?\@(\d+)\s*$/;
52e4c282
IZ
217 # This allows skipping ordinals which were used in older versions
218 $sym_ord = $1 if /^\s*;\s*LAST_ORDINAL\s*=\s*(\d+)\s*$/;
219 }
220 $sym_ord < $_ and $sym_ord = $_ for values %ordinal; # Take the max
221 }
2986a63f 222}
bbc8f9de 223
44c17813
NC
224my %skip;
225# All platforms export boot_DynaLoader unconditionally.
226my %export = ( boot_DynaLoader => 1 );
227
b1015292 228# d_thread_local not perl_thread_local - see hints/darwin.sh
3683a9ee 229++$export{PL_current_context}
b1015292 230 if defined $Config{d_thread_local} && $define{USE_ITHREADS};
3683a9ee 231
430d15ed
NC
232sub try_symbols {
233 foreach my $symbol (@_) {
44c17813
NC
234 ++$export{$symbol} unless exists $skip{$symbol};
235 }
236}
237
238sub readvar {
239 # $hash is the hash that we're adding to. For one of our callers, it will
240 # actually be the skip hash but that doesn't affect the intent of what
241 # we're doing, as in that case we skip adding something to the skip hash
242 # for the second time.
243
321600e1
NC
244 my $file = $ARGS{TARG_DIR} . shift;
245 my $hash = shift;
246 my $proc = shift;
a3815e44 247 open my $vars, '<', $file or die "Cannot open $file: $!\n";
44c17813
NC
248
249 while (<$vars>) {
250 # All symbols have a Perl_ prefix because that's what embed.h sticks
251 # in front of them. The A?I?S?C? is strictly speaking wrong.
115ff745 252 next unless /\bPERLVAR(A?I?S?C?)\(([IGT]),\s*(\w+)/;
44c17813
NC
253
254 my $var = "PL_$3";
255 my $symbol = $proc ? &$proc($1,$2,$3) : $var;
256 ++$hash->{$symbol} unless exists $skip{$var};
51371543 257 }
22239a37
NIS
258}
259
89201293 260if (PLATFORM ne 'os2') {
e7c4906b 261 ++$skip{$_} foreach qw(
f2921293 262 PL_opsave
f2921293
NC
263 Perl_dump_fds
264 Perl_my_bcopy
265 Perl_my_bzero
266 Perl_my_chsize
267 Perl_my_htonl
268 Perl_my_memcmp
269 Perl_my_memset
270 Perl_my_ntohl
271 Perl_my_swap
e7c4906b 272 );
89201293 273 if (PLATFORM eq 'vms') {
e7c4906b 274 ++$skip{PL_statusvalue_posix};
4b476daa
CB
275 # This is a wrapper if we have symlink, not a replacement
276 # if we don't.
277 ++$skip{Perl_my_symlink} unless $Config{d_symlink};
c36317f0 278 } else {
e7c4906b 279 ++$skip{PL_statusvalue_vms};
483efd0a 280 ++$skip{PL_perllib_sep};
89201293 281 if (PLATFORM ne 'aix') {
e7c4906b 282 ++$skip{$_} foreach qw(
c36317f0
NC
283 PL_DBcv
284 PL_generation
285 PL_lastgotoprobe
286 PL_modcount
c36317f0 287 main
e7c4906b 288 );
c36317f0
NC
289 }
290 }
f2921293
NC
291}
292
89201293 293if (PLATFORM ne 'vms') {
c36317f0 294 # VMS does its own thing for these symbols.
e7c4906b 295 ++$skip{$_} foreach qw(
c36317f0
NC
296 PL_sig_handlers_initted
297 PL_sig_ignoring
298 PL_sig_defaulting
e7c4906b 299 );
89201293 300 if (PLATFORM ne 'win32') {
e7c4906b 301 ++$skip{$_} foreach qw(
c36317f0
NC
302 Perl_do_spawn
303 Perl_do_spawn_nowait
304 Perl_do_aspawn
e7c4906b 305 );
c36317f0 306 }
7766f137 307}
c36317f0 308
89201293 309if (PLATFORM ne 'win32') {
bfb2a8f9 310 ++$skip{$_} foreach qw(
c728a1a6 311 Perl_get_win32_message_utf8ness
881a2f91
CB
312 Perl_Win_utf8_string_to_wstring
313 Perl_Win_wstring_to_utf8_string
bfb2a8f9
CB
314 );
315}
316
df39eaa8 317unless ($define{UNLINK_ALL_VERSIONS}) {
e7c4906b 318 ++$skip{Perl_unlnk};
93ea32b8 319}
3cfae81b 320
7766f137 321unless ($define{'DEBUGGING'}) {
e7c4906b 322 ++$skip{$_} foreach qw(
7766f137
GS
323 Perl_debop
324 Perl_debprofdump
325 Perl_debstack
326 Perl_debstackptrs
5cbf7fcf 327 Perl_pad_sv
b65222da 328 Perl_pad_setsv
eacbb379 329 Perl_set_padlist
943795c2 330 Perl_hv_assert
7766f137
GS
331 PL_watchaddr
332 PL_watchok
e7c4906b 333 );
7766f137
GS
334}
335
336if ($define{'PERL_IMPLICIT_SYS'}) {
e7c4906b 337 ++$skip{$_} foreach qw(
7766f137
GS
338 Perl_my_popen
339 Perl_my_pclose
e7c4906b 340 );
2c84c919
NC
341 ++$export{$_} foreach qw(perl_get_host_info perl_alloc_override);
342 ++$export{perl_clone_host} if $define{USE_ITHREADS};
7766f137
GS
343}
344else {
e7c4906b 345 ++$skip{$_} foreach qw(
7766f137
GS
346 PL_Mem
347 PL_MemShared
348 PL_MemParse
349 PL_Env
350 PL_StdIO
351 PL_LIO
352 PL_Dir
353 PL_Sock
354 PL_Proc
2c84c919
NC
355 perl_alloc_using
356 perl_clone_using
e7c4906b 357 );
7766f137
GS
358}
359
00d484c1 360if (!$define{'PERL_COPY_ON_WRITE'} || $define{'PERL_NO_COW'}) {
e7c4906b 361 ++$skip{Perl_sv_setsv_cow};
0190f6ec
AT
362}
363
6b898924 364unless ($define{PERL_SAWAMPERSAND}) {
1a904fc8
FC
365 ++$skip{PL_sawampersand};
366}
367
5bcb3f6c 368unless ($define{'USE_REENTRANT_API'}) {
e7c4906b 369 ++$skip{PL_reentrant_buffer};
5bcb3f6c
NIS
370}
371
7766f137 372if ($define{'MYMALLOC'}) {
430d15ed 373 try_symbols(qw(
7766f137 374 Perl_dump_mstats
827e134a 375 Perl_get_mstats
9c130f5b
NIS
376 Perl_strdup
377 Perl_putenv
6af660ee
IZ
378 MallocCfg_ptr
379 MallocCfgP_ptr
430d15ed 380 ));
3cf3941e
NC
381 unless ($define{USE_ITHREADS}) {
382 ++$skip{PL_malloc_mutex}
80fc1a6e 383 }
51371543
GS
384}
385else {
e7c4906b 386 ++$skip{$_} foreach qw(
7766f137
GS
387 PL_malloc_mutex
388 Perl_dump_mstats
6ecd3fcb 389 Perl_get_mstats
6af660ee
IZ
390 MallocCfg_ptr
391 MallocCfgP_ptr
e7c4906b 392 );
7766f137
GS
393}
394
3db8f154 395unless ($define{'USE_ITHREADS'}) {
e7c4906b 396 ++$skip{PL_thr_key};
8310e7fa 397 ++$skip{PL_user_prop_mutex};
dd52e3cc 398 ++$skip{PL_user_def_props_aTHX};
f433d095
GS
399}
400
7766f137 401unless ($define{'USE_ITHREADS'}) {
e7c4906b 402 ++$skip{$_} foreach qw(
2b503742 403 PL_keyword_plugin_mutex
bb0d02ab 404 PL_check_mutex
1094750e 405 PL_cur_locale_obj
534825c4 406 PL_op_mutex
7e95b20d
JH
407 PL_regex_pad
408 PL_regex_padav
e2975953 409 PL_dollarzero_mutex
2bc5f86a 410 PL_env_mutex
b60bf3b9 411 PL_hints_mutex
929e1213 412 PL_locale_mutex
da1b79a9 413 PL_locale_mutex_depth
8703a9a4 414 PL_my_ctx_mutex
f1791e53 415 PL_perlio_mutex
d4d03940
FC
416 PL_stashpad
417 PL_stashpadix
418 PL_stashpadmax
644641ff 419 PL_veto_switch_non_tTHX_context
61a25672 420 Perl_alloccopstash
9eb247a1 421 Perl_allocfilegv
7c425e3c
NC
422 Perl_clone_params_del
423 Perl_clone_params_new
b0bb49b6 424 Perl_parser_dup
7766f137
GS
425 Perl_dirp_dup
426 Perl_cx_dup
427 Perl_si_dup
428 Perl_any_dup
429 Perl_ss_dup
430 Perl_fp_dup
431 Perl_gp_dup
432 Perl_he_dup
433 Perl_mg_dup
7f605079 434 Perl_re_dup_guts
7766f137 435 Perl_sv_dup
7c425e3c 436 Perl_sv_dup_inc
aeef2723 437 Perl_rvpv_dup
88daff13 438 Perl_hek_dup
7766f137 439 Perl_sys_intern_dup
7766f137
GS
440 perl_clone
441 perl_clone_using
dc1061dc 442 Perl_stashpv_hvname_match
1fa600a7 443 Perl_regdupe_internal
392d04bb 444 Perl_newPADOP
e7c4906b 445 );
7766f137
GS
446}
447
8751a11f 448unless ($define{USE_POSIX_2008_LOCALE})
e1895adc
KW
449{
450 ++$skip{$_} foreach qw(
451 PL_C_locale_obj
827a4a05 452 PL_scratch_locale_obj
5b95d1b1 453 PL_underlying_numeric_obj
6ebbc862
KW
454 );
455}
5e395a7a 456unless ($define{USE_PL_CURLOCALES})
827a4a05
KW
457{
458 ++$skip{$_} foreach qw(
459 PL_curlocales
460 );
461}
6ebbc862 462
6a4065f2
KW
463unless ($define{USE_PL_CUR_LC_ALL})
464{
465 ++$skip{$_} foreach qw(
466 PL_cur_LC_ALL
467 );
468}
469
644641ff
KW
470unless ($define{USE_PERL_SWITCH_LOCALE_CONTEXT})
471{
472 ++$skip{$_} foreach qw(
473 Perl_switch_locale_context
474 );
475}
476
6e512bc2 477unless ($define{'MULTIPLICITY'}) {
e7c4906b 478 ++$skip{$_} foreach qw(
1f9ecdc6
SH
479 PL_my_cxt_index
480 PL_my_cxt_list
481 PL_my_cxt_size
ecb9cc66 482 PL_my_cxt_keys
04912be7 483 PL_my_cxt_keys_size
7766f137
GS
484 Perl_croak_nocontext
485 Perl_die_nocontext
486 Perl_deb_nocontext
487 Perl_form_nocontext
e0f4245d 488 Perl_load_module_nocontext
7766f137
GS
489 Perl_mess_nocontext
490 Perl_warn_nocontext
491 Perl_warner_nocontext
492 Perl_newSVpvf_nocontext
493 Perl_sv_catpvf_nocontext
494 Perl_sv_setpvf_nocontext
495 Perl_sv_catpvf_mg_nocontext
496 Perl_sv_setpvf_mg_nocontext
484eff17 497 Perl_my_cxt_init
ecb9cc66 498 Perl_my_cxt_index
e7c4906b 499 );
7766f137 500}
1fafe688 501
3f6bd23a
DM
502unless ($define{'USE_DTRACE'}) {
503 ++$skip{$_} foreach qw(
504 Perl_dtrace_probe_call
505 Perl_dtrace_probe_load
506 Perl_dtrace_probe_op
507 Perl_dtrace_probe_phase
508 );
509}
510
dfc72f41 511unless ($define{'DEBUG_LEAKING_SCALARS'}) {
e7c4906b 512 ++$skip{PL_sv_serial};
dfc72f41
NC
513}
514
808e2276 515unless ($define{'DEBUG_LEAKING_SCALARS_FORK_DUMP'}) {
e7c4906b 516 ++$skip{PL_dumper_fd};
808e2276 517}
e7c4906b 518
c69033f2 519unless ($define{'PERL_DONT_CREATE_GVSV'}) {
e7c4906b 520 ++$skip{Perl_gv_SVadd};
c69033f2 521}
e7c4906b 522
ca0c25f6 523unless ($define{'PERL_USES_PL_PIDSTATUS'}) {
e7c4906b 524 ++$skip{PL_pidstatus};
ca0c25f6 525}
808e2276 526
02ca4724 527unless ($define{'PERL_TRACK_MEMPOOL'}) {
e7c4906b 528 ++$skip{PL_memory_debug_header};
02ca4724
SP
529}
530
03694582 531unless ($define{'PERL_MEM_LOG'}) {
bc726283
TC
532 ++$skip{$_} foreach qw(
533 PL_mem_log
534 Perl_mem_log_alloc
535 Perl_mem_log_realloc
536 Perl_mem_log_free
537 Perl_mem_log_new_sv
538 Perl_mem_log_del_sv
539 );
03694582
KW
540}
541
2a5adacc 542unless ($define{'MULTIPLICITY'}) {
e7c4906b 543 ++$skip{$_} foreach qw(
01523419 544 PL_interp_size
d399cf59 545 PL_interp_size_5_18_0
7c123f9d
DM
546 PL_sv_yes
547 PL_sv_undef
548 PL_sv_no
549 PL_sv_zero
e7c4906b 550 );
2a5adacc
JD
551}
552
bd1ae5d2 553unless ($define{HAS_MMAP}) {
e7c4906b 554 ++$skip{PL_mmap_page_size};
ac6bedea
JH
555}
556
bd1ae5d2 557if ($define{HAS_SIGACTION}) {
e7c4906b 558 ++$skip{PL_sig_trapped};
662667f1 559
89201293 560 if (PLATFORM eq 'vms') {
662667f1
CB
561 # FAKE_PERSISTENT_SIGNAL_HANDLERS defined as !defined(HAS_SIGACTION)
562 ++$skip{PL_sig_ignoring};
dc2a396b 563 ++$skip{PL_sig_handlers_initted} unless $define{KILL_BY_SIGPRC};
662667f1 564 }
d97afc04
AT
565}
566
89201293 567if (PLATFORM eq 'vms' && !$define{KILL_BY_SIGPRC}) {
dc2a396b
CB
568 # FAKE_DEFAULT_SIGNAL_HANDLERS defined as KILL_BY_SIGPRC
569 ++$skip{Perl_csighandler_init};
570 ++$skip{Perl_my_kill};
571 ++$skip{Perl_sig_to_vmscondition};
572 ++$skip{PL_sig_defaulting};
573 ++$skip{PL_sig_handlers_initted} unless !$define{HAS_SIGACTION};
574}
575
ffaed893
CB
576if ($define{'HAS_STRNLEN'})
577{
578 ++$skip{Perl_my_strnlen};
579}
580
bdcba273 581unless ($define{USE_LOCALE_COLLATE}) {
e7c4906b 582 ++$skip{$_} foreach qw(
bdcba273
NC
583 PL_collation_ix
584 PL_collation_name
585 PL_collation_standard
586 PL_collxfrm_base
587 PL_collxfrm_mult
588 Perl_sv_collxfrm
589 Perl_sv_collxfrm_flags
d36adde0
KW
590 PL_strxfrm_NUL_replacement
591 PL_strxfrm_is_behaved
592 PL_strxfrm_max_cp
7a615b71 593 PL_in_utf8_COLLATE_locale
e7c4906b 594 );
bdcba273
NC
595}
596
1f1ade4f 597unless ($define{USE_LOCALE_NUMERIC}) {
e7c4906b 598 ++$skip{$_} foreach qw(
d36adde0 599 PL_underlying_numeric_obj
e7c4906b 600 );
1f1ade4f
NC
601}
602
b269edc8
KW
603unless ($define{USE_LOCALE_CTYPE}) {
604 ++$skip{$_} foreach qw(
605 PL_ctype_name
f41910bf
KW
606 PL_in_utf8_CTYPE_locale
607 PL_in_utf8_turkic_locale
b269edc8
KW
608 );
609}
610
470dd224
JH
611unless ($define{'USE_C_BACKTRACE'}) {
612 ++$skip{Perl_get_c_backtrace_dump};
613 ++$skip{Perl_dump_c_backtrace};
614}
615
1ab20eaa 616unless ($define{HAVE_INTERP_INTERN}) {
e7c4906b 617 ++$skip{$_} foreach qw(
1ab20eaa
NC
618 Perl_sys_intern_clear
619 Perl_sys_intern_dup
620 Perl_sys_intern_init
621 PL_sys_intern
e7c4906b 622 );
1ab20eaa
NC
623}
624
47e4ddfc 625if ($define{HAS_SIGNBIT}) {
e7c4906b 626 ++$skip{Perl_signbit};
47e4ddfc
NC
627}
628
04525552
NC
629++$skip{PL_op_exec_cnt}
630 unless $define{PERL_TRACE_OPS};
631
11c9859f
SH
632++$skip{PL_hash_chars}
633 unless $define{PERL_USE_SINGLE_CHAR_HASH_CACHE};
634
22c35a8c
GS
635# functions from *.sym files
636
d500e60d 637my @syms = qw(globvar.sym);
549a6b10 638
d892637e
NIS
639# Symbols that are the public face of the PerlIO layers implementation
640# These are in _addition to_ the public face of the abstraction
641# and need to be exported to allow XS modules to implement layers
9df9a5cd 642my @layer_syms = qw(
db76e01e
JH
643 PerlIOBase_binmode
644 PerlIOBase_clearerr
645 PerlIOBase_close
646 PerlIOBase_dup
647 PerlIOBase_eof
648 PerlIOBase_error
649 PerlIOBase_fileno
3dfd1b5c 650 PerlIOBase_open
db76e01e
JH
651 PerlIOBase_noop_fail
652 PerlIOBase_noop_ok
653 PerlIOBase_popped
7e700b9a 654 PerlIOBase_pushed
db76e01e
JH
655 PerlIOBase_read
656 PerlIOBase_setlinebuf
657 PerlIOBase_unread
658 PerlIOBuf_bufsiz
659 PerlIOBuf_close
660 PerlIOBuf_dup
661 PerlIOBuf_fill
662 PerlIOBuf_flush
663 PerlIOBuf_get_base
664 PerlIOBuf_get_cnt
665 PerlIOBuf_get_ptr
666 PerlIOBuf_open
667 PerlIOBuf_popped
668 PerlIOBuf_pushed
669 PerlIOBuf_read
670 PerlIOBuf_seek
671 PerlIOBuf_set_ptrcnt
672 PerlIOBuf_tell
673 PerlIOBuf_unread
674 PerlIOBuf_write
675 PerlIO_allocate
8ffeedc3 676 PerlIO_apply_layera
db76e01e
JH
677 PerlIO_apply_layers
678 PerlIO_arg_fetch
679 PerlIO_debug
680 PerlIO_define_layer
4dcdb34a 681 PerlIO_find_layer
51d05609 682 PerlIO_isutf8
db76e01e 683 PerlIO_layer_fetch
4dcdb34a 684 PerlIO_list_alloc
db76e01e
JH
685 PerlIO_list_free
686 PerlIO_modestr
687 PerlIO_parse_layers
688 PerlIO_pending
689 PerlIO_perlio
690 PerlIO_pop
691 PerlIO_push
692 PerlIO_sv_dup
693 Perl_PerlIO_clearerr
694 Perl_PerlIO_close
188f0c84 695 Perl_PerlIO_context_layers
db76e01e
JH
696 Perl_PerlIO_eof
697 Perl_PerlIO_error
698 Perl_PerlIO_fileno
699 Perl_PerlIO_fill
700 Perl_PerlIO_flush
701 Perl_PerlIO_get_base
702 Perl_PerlIO_get_bufsiz
703 Perl_PerlIO_get_cnt
704 Perl_PerlIO_get_ptr
705 Perl_PerlIO_read
0ea86a10
FC
706 Perl_PerlIO_restore_errno
707 Perl_PerlIO_save_errno
db76e01e
JH
708 Perl_PerlIO_seek
709 Perl_PerlIO_set_cnt
710 Perl_PerlIO_set_ptrcnt
711 Perl_PerlIO_setlinebuf
712 Perl_PerlIO_stderr
713 Perl_PerlIO_stdin
714 Perl_PerlIO_stdout
715 Perl_PerlIO_tell
716 Perl_PerlIO_unread
717 Perl_PerlIO_write
9df9a5cd 718);
d892637e 719
56022c66
CB
720# Export the symbols that make up the PerlIO abstraction, regardless
721# of its implementation - read from a file
722push @syms, 'perlio.sym';
d892637e 723
56022c66
CB
724# PerlIO with layers - export implementation
725try_symbols(@layer_syms, 'perlsio_binmode');
1e8a8f59 726
7766f137 727
068eadbd
JH
728unless ($define{'USE_QUADMATH'}) {
729 ++$skip{Perl_quadmath_format_needed};
730 ++$skip{Perl_quadmath_format_single};
731}
732
c83b64ee
TC
733unless ($Config{d_mbrlen}) {
734 ++$skip{PL_mbrlen_ps};
735}
736
737unless ($Config{d_mbrtowc}) {
738 ++$skip{PL_mbrtowc_ps};
739}
740
741unless ($Config{d_wcrtomb}) {
742 ++$skip{PL_wcrtomb_ps};
743}
744
71afeaec
NC
745###############################################################################
746
747# At this point all skip lists should be completed, as we are about to test
748# many symbols against them.
749
d500e60d
NC
750{
751 my %seen;
69e2d40a 752 my ($embed_array) = setup_embed($ARGS{TARG_DIR});
c43e2db5 753 my $excludedre = $define{'NO_MATHOMS'} ? qr/[emiIsb]/ : qr/[emiIs]/;
d500e60d 754
69e2d40a
YO
755 foreach (@$embed_array) {
756 my $embed= $_->{embed}
757 or next;
758 my ($flags, $retval, $func, $args) = @{$embed}{qw(flags return_type name args)};
d500e60d 759 next unless $func;
e52e9867 760 if (($flags =~ /[AXC]/ && $flags !~ $excludedre)
c41ed026 761 || (!$define{'NO_MATHOMS'} && $flags =~ /b/))
3f1866a8 762 {
d500e60d
NC
763 # public API, so export
764
765 # If a function is defined twice, for example before and after
766 # an #else, only export its name once. Important to do this test
767 # within the block, as the *first* definition may have flags which
768 # mean "don't export"
769 next if $seen{$func}++;
cbe4d57f 770 # Should we also skip adding the Perl_ prefix if $flags =~ /o/ ?
c43e2db5 771 $func = "Perl_$func" if ($flags =~ /[psX]/ && $func !~ /^Perl_/);
d500e60d
NC
772 ++$export{$func} unless exists $skip{$func};
773 }
774 }
775}
776
321600e1
NC
777foreach (@syms) {
778 my $syms = $ARGS{TARG_DIR} . $_;
a6587d2d 779 open my $global, '<', $syms or die "failed to open $syms: $!\n";
a6587d2d
NC
780 while (<$global>) {
781 next unless /^([A-Za-z].*)/;
c774046b 782 my $symbol = "$1";
944921d3 783 ++$export{$symbol} unless exists $skip{$symbol};
7766f137 784 }
7766f137 785}
0a753a76 786
22c35a8c 787# variables
0a753a76 788
8c3a0f6c
DIM
789readvar('perlvars.h', \%export);
790unless ($define{MULTIPLICITY}) {
791 readvar('intrpvar.h', \%export);
51371543 792}
0a753a76 793
bf09e1bd 794# Oddities from PerlIO
01cace46
NC
795# All have alternate implementations in perlio.c, so always exist.
796# Should they be considered to be part of the API?
430d15ed 797try_symbols(qw(
bf09e1bd
NC
798 PerlIO_binmode
799 PerlIO_getpos
800 PerlIO_init
801 PerlIO_setpos
bf09e1bd 802 PerlIO_tmpfile
430d15ed 803 ));
ac4c12e7 804
89201293 805if (PLATFORM eq 'win32') {
7a95c549 806 try_symbols(qw(
79c32fc2
SH
807 win32_free_childdir
808 win32_free_childenv
809 win32_get_childdir
810 win32_get_childenv
811 win32_spawnvp
812 Perl_init_os_extras
79c32fc2
SH
813 Perl_win32_init
814 Perl_win32_term
815 RunPerl
816 win32_async_check
817 win32_errno
818 win32_environ
819 win32_abort
820 win32_fstat
821 win32_stat
822 win32_pipe
823 win32_popen
824 win32_pclose
825 win32_rename
826 win32_setmode
827 win32_chsize
828 win32_lseek
829 win32_tell
830 win32_dup
831 win32_dup2
832 win32_open
833 win32_close
834 win32_eof
835 win32_isatty
836 win32_read
837 win32_write
838 win32_mkdir
839 win32_rmdir
840 win32_chdir
841 win32_flock
842 win32_execv
843 win32_execvp
844 win32_htons
845 win32_ntohs
846 win32_htonl
847 win32_ntohl
848 win32_inet_addr
849 win32_inet_ntoa
850 win32_socket
851 win32_bind
852 win32_listen
853 win32_accept
854 win32_connect
855 win32_send
856 win32_sendto
857 win32_recv
858 win32_recvfrom
859 win32_shutdown
860 win32_closesocket
861 win32_ioctlsocket
862 win32_setsockopt
863 win32_getsockopt
864 win32_getpeername
865 win32_getsockname
866 win32_gethostname
867 win32_gethostbyname
868 win32_gethostbyaddr
869 win32_getprotobyname
870 win32_getprotobynumber
871 win32_getservbyname
872 win32_getservbyport
873 win32_select
874 win32_endhostent
875 win32_endnetent
876 win32_endprotoent
877 win32_endservent
878 win32_getnetent
879 win32_getnetbyname
880 win32_getnetbyaddr
881 win32_getprotoent
882 win32_getservent
883 win32_sethostent
884 win32_setnetent
885 win32_setprotoent
886 win32_setservent
887 win32_getenv
888 win32_putenv
889 win32_perror
890 win32_malloc
891 win32_calloc
892 win32_realloc
893 win32_free
894 win32_sleep
895 win32_pause
896 win32_times
897 win32_access
898 win32_alarm
899 win32_chmod
900 win32_open_osfhandle
901 win32_get_osfhandle
902 win32_ioctl
903 win32_link
904 win32_unlink
905 win32_utime
906 win32_gettimeofday
907 win32_uname
908 win32_wait
909 win32_waitpid
910 win32_kill
911 win32_str_os_error
912 win32_opendir
913 win32_readdir
914 win32_telldir
915 win32_seekdir
916 win32_rewinddir
917 win32_closedir
918 win32_longpath
919 win32_ansipath
920 win32_os_id
921 win32_getpid
922 win32_crypt
923 win32_dynaload
924 win32_clearenv
925 win32_stdin
926 win32_stdout
927 win32_stderr
928 win32_ferror
929 win32_feof
930 win32_strerror
931 win32_fprintf
932 win32_printf
933 win32_vfprintf
934 win32_vprintf
935 win32_fread
936 win32_fwrite
937 win32_fopen
938 win32_fdopen
939 win32_freopen
940 win32_fclose
941 win32_fputs
942 win32_fputc
943 win32_ungetc
944 win32_getc
945 win32_fileno
946 win32_clearerr
947 win32_fflush
948 win32_ftell
949 win32_fseek
950 win32_fgetpos
951 win32_fsetpos
952 win32_rewind
953 win32_tmpfile
954 win32_setbuf
955 win32_setvbuf
956 win32_flushall
957 win32_fcloseall
958 win32_fgets
959 win32_gets
960 win32_fgetc
961 win32_putc
962 win32_puts
963 win32_getchar
964 win32_putchar
e5388933
TC
965 win32_symlink
966 win32_lstat
967 win32_readlink
7a95c549 968 ));
549a6b10 969}
89201293 970elsif (PLATFORM eq 'vms') {
71afeaec
NC
971 try_symbols(qw(
972 Perl_cando
973 Perl_cando_by_name
974 Perl_closedir
975 Perl_csighandler_init
976 Perl_do_rmdir
977 Perl_fileify_dirspec
978 Perl_fileify_dirspec_ts
979 Perl_fileify_dirspec_utf8
980 Perl_fileify_dirspec_utf8_ts
981 Perl_flex_fstat
982 Perl_flex_lstat
983 Perl_flex_stat
984 Perl_kill_file
985 Perl_my_chdir
986 Perl_my_chmod
987 Perl_my_crypt
988 Perl_my_endpwent
989 Perl_my_fclose
990 Perl_my_fdopen
991 Perl_my_fgetname
992 Perl_my_flush
993 Perl_my_fwrite
994 Perl_my_gconvert
995 Perl_my_getenv
996 Perl_my_getenv_len
71afeaec
NC
997 Perl_my_getpwnam
998 Perl_my_getpwuid
999 Perl_my_gmtime
1000 Perl_my_kill
96f902ff 1001 Perl_my_killpg
71afeaec
NC
1002 Perl_my_localtime
1003 Perl_my_mkdir
1004 Perl_my_sigaction
1005 Perl_my_symlink
1006 Perl_my_time
1007 Perl_my_tmpfile
1008 Perl_my_trnlnm
1009 Perl_my_utime
1010 Perl_my_waitpid
1011 Perl_opendir
1012 Perl_pathify_dirspec
1013 Perl_pathify_dirspec_ts
1014 Perl_pathify_dirspec_utf8
1015 Perl_pathify_dirspec_utf8_ts
1016 Perl_readdir
1017 Perl_readdir_r
1018 Perl_rename
1019 Perl_rmscopy
1020 Perl_rmsexpand
1021 Perl_rmsexpand_ts
1022 Perl_rmsexpand_utf8
1023 Perl_rmsexpand_utf8_ts
1024 Perl_seekdir
1025 Perl_sig_to_vmscondition
1026 Perl_telldir
1027 Perl_tounixpath
1028 Perl_tounixpath_ts
1029 Perl_tounixpath_utf8
1030 Perl_tounixpath_utf8_ts
1031 Perl_tounixspec
1032 Perl_tounixspec_ts
1033 Perl_tounixspec_utf8
1034 Perl_tounixspec_utf8_ts
1035 Perl_tovmspath
1036 Perl_tovmspath_ts
1037 Perl_tovmspath_utf8
1038 Perl_tovmspath_utf8_ts
1039 Perl_tovmsspec
1040 Perl_tovmsspec_ts
1041 Perl_tovmsspec_utf8
1042 Perl_tovmsspec_utf8_ts
1043 Perl_trim_unixpath
1044 Perl_vms_case_tolerant
1045 Perl_vms_do_aexec
1046 Perl_vms_do_exec
1047 Perl_vms_image_init
1048 Perl_vms_realpath
1049 Perl_vmssetenv
1050 Perl_vmssetuserlnm
1051 Perl_vmstrnenv
1052 PerlIO_openn
1053 ));
1054}
89201293 1055elsif (PLATFORM eq 'os2') {
71afeaec
NC
1056 try_symbols(qw(
1057 ctermid
1058 get_sysinfo
1059 Perl_OS2_init
1060 Perl_OS2_init3
1061 Perl_OS2_term
1062 OS2_Perl_data
1063 dlopen
1064 dlsym
1065 dlerror
1066 dlclose
1067 dup2
1068 dup
1069 my_tmpfile
1070 my_tmpnam
1071 my_flock
1072 my_rmdir
1073 my_mkdir
1074 my_getpwuid
1075 my_getpwnam
1076 my_getpwent
1077 my_setpwent
1078 my_endpwent
1079 fork_with_resources
1080 croak_with_os2error
1081 setgrent
1082 endgrent
1083 getgrent
1084 malloc_mutex
1085 threads_mutex
1086 nthreads
1087 nthreads_cond
1088 os2_cond_wait
1089 os2_stat
1090 os2_execname
1091 async_mssleep
1092 msCounter
1093 InfoTable
1094 pthread_join
1095 pthread_create
1096 pthread_detach
1097 XS_Cwd_change_drive
1098 XS_Cwd_current_drive
1099 XS_Cwd_extLibpath
1100 XS_Cwd_extLibpath_set
1101 XS_Cwd_sys_abspath
1102 XS_Cwd_sys_chdir
1103 XS_Cwd_sys_cwd
1104 XS_Cwd_sys_is_absolute
1105 XS_Cwd_sys_is_relative
1106 XS_Cwd_sys_is_rooted
1107 XS_DynaLoader_mod2fname
1108 XS_File__Copy_syscopy
1109 Perl_Register_MQ
1110 Perl_Deregister_MQ
1111 Perl_Serve_Messages
1112 Perl_Process_Messages
1113 init_PMWIN_entries
1114 PMWIN_entries
1115 Perl_hab_GET
1116 loadByOrdinal
1117 pExtFCN
1118 os2error
1119 ResetWinError
1120 CroakWinError
1121 PL_do_undump
1122 ));
3cfae81b 1123}
22239a37 1124
79c32fc2 1125# When added this code was only run for Win32 (and WinCE at the time)
9661ac31 1126# Currently only Win32 links static extensions into the shared library.
9661ac31
NC
1127# For *nix (and presumably OS/2) with a shared libperl, Makefile.SH compiles
1128# static extensions with -fPIC, but links them to perl, not libperl.so
1129# The VMS build scripts don't yet implement static extensions at all.
1130
89201293 1131if (PLATFORM eq 'win32') {
9661ac31 1132 # records of type boot_module for statically linked modules (except Dynaloader)
c051ff4c 1133 my $static_ext = $Config{static_ext} // "";
9661ac31
NC
1134 $static_ext =~ s/\//__/g;
1135 $static_ext =~ s/\bDynaLoader\b//;
1136 try_symbols(map {"boot_$_"} grep {/\S/} split /\s+/, $static_ext);
1137 try_symbols("init_Win32CORE") if $static_ext =~ /\bWin32CORE\b/;
1138}
9fb265f7 1139
89201293 1140if (PLATFORM eq 'os2') {
71afeaec 1141 my (%mapped, @missing);
1ae6ead9 1142 open MAP, '<', 'miniperl.map' or die 'Cannot read miniperl.map';
71afeaec
NC
1143 /^\s*[\da-f:]+\s+(\w+)/i and $mapped{$1}++ foreach <MAP>;
1144 close MAP or die 'Cannot close miniperl.map';
1145
1146 @missing = grep { !exists $mapped{$_} }
1147 keys %export;
1148 @missing = grep { !exists $exportperlmalloc{$_} } @missing;
1149 delete $export{$_} foreach @missing;
1150}
1151
d6035849
NC
1152###############################################################################
1153
1154# Now all symbols should be defined because next we are going to output them.
1155
1156# Start with platform specific headers:
1157
89201293 1158if (PLATFORM eq 'win32') {
d9f179d8
NC
1159 my $dll = $define{PERL_DLL} ? $define{PERL_DLL} =~ s/\.dll$//ir
1160 : "perl$Config{api_revision}$Config{api_version}";
d6035849
NC
1161 print "LIBRARY $dll\n";
1162 # The DESCRIPTION module definition file statement is not supported
1163 # by VC7 onwards.
7adf2470 1164 if ($ARGS{CCTYPE} eq 'GCC') {
d6035849
NC
1165 print "DESCRIPTION 'Perl interpreter'\n";
1166 }
1167 print "EXPORTS\n";
1168}
89201293 1169elsif (PLATFORM eq 'os2') {
d6035849 1170 (my $v = $]) =~ s/(\d\.\d\d\d)(\d\d)$/$1_$2/;
c051ff4c 1171 $v .= '-thread' if $Config{archname} =~ /-thread/;
d6035849 1172 (my $dll = $define{PERL_DLL}) =~ s/\.dll$//i;
c051ff4c
NC
1173 $v .= "\@$Config{perl_patchlevel}" if $Config{perl_patchlevel};
1174 my $d = "DESCRIPTION '\@#perl5-porters\@perl.org:$v#\@ Perl interpreter, configured as $Config{config_args}'";
d6035849
NC
1175 $d = substr($d, 0, 249) . "...'" if length $d > 253;
1176 print <<"---EOP---";
1177LIBRARY '$dll' INITINSTANCE TERMINSTANCE
1178$d
1179STACKSIZE 32768
1180CODE LOADONCALL
1181DATA LOADONCALL NONSHARED MULTIPLE
1182EXPORTS
1183---EOP---
1184}
89201293 1185elsif (PLATFORM eq 'aix') {
d6035849
NC
1186 my $OSVER = `uname -v`;
1187 chop $OSVER;
1188 my $OSREL = `uname -r`;
1189 chop $OSREL;
1190 if ($OSVER > 4 || ($OSVER == 4 && $OSREL >= 3)) {
1191 print "#! ..\n";
1192 } else {
1193 print "#!\n";
1194 }
1195}
d6035849
NC
1196
1197# Then the symbols
549a6b10 1198
5d4e58dc
NC
1199my @symbols = $fold ? sort {lc $a cmp lc $b} keys %export : sort keys %export;
1200foreach my $symbol (@symbols) {
79c32fc2 1201 if (PLATFORM eq 'win32') {
75debb79
SH
1202 # Remembering the origin file of each symbol is an alternative to PL_ matching
1203 if (substr($symbol, 0, 3) eq 'PL_') {
1204 print "\t$symbol DATA\n";
196f7c46
DD
1205 }
1206 else {
1207 print "\t$symbol\n";
1208 }
7766f137 1209 }
196f7c46 1210 elsif (PLATFORM eq 'os2') {
52e4c282
IZ
1211 printf qq( %-31s \@%s\n),
1212 qq("$symbol"), $ordinal{$symbol} || ++$sym_ord;
78232bc0
JH
1213 printf qq( %-31s \@%s\n),
1214 qq("$exportperlmalloc{$symbol}" = "$symbol"),
1215 $ordinal{$exportperlmalloc{$symbol}} || ++$sym_ord
1216 if $exportperlmalloc and exists $exportperlmalloc{$symbol};
ed463ba8 1217 } else {
549a6b10
JH
1218 print "$symbol\n";
1219 }
ed463ba8
NC
1220}
1221
1222# Then platform specific footers.
1223
89201293 1224if (PLATFORM eq 'os2') {
ed463ba8
NC
1225 print <<EOP;
1226 dll_perlmain=main
1227 fill_extLibpath
1228 dir_subst
1229 Perl_OS2_handler_install
1230
1231; LAST_ORDINAL=$sym_ord
1232EOP
549a6b10
JH
1233}
1234
12351;