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