This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Resort MANIFEST.
[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+)$/);
53}
d55594ae 54
084592ab 55my @PLATFORM = qw(aix win32 os2 MacOS);
549a6b10
JH
56my %PLATFORM;
57@PLATFORM{@PLATFORM} = ();
58
59defined $PLATFORM || die "PLATFORM undefined, must be one of: @PLATFORM\n";
9df9a5cd 60exists $PLATFORM{$PLATFORM} || die "PLATFORM must be one of: @PLATFORM\n";
549a6b10
JH
61
62my $config_sh = "config.sh";
63my $config_h = "config.h";
64my $thrdvar_h = "thrdvar.h";
65my $intrpvar_h = "intrpvar.h";
66my $perlvars_h = "perlvars.h";
67my $global_sym = "global.sym";
68my $pp_sym = "pp.sym";
69my $globvar_sym = "globvar.sym";
70my $perlio_sym = "perlio.sym";
71
9df9a5cd 72if ($PLATFORM eq 'aix') {
549a6b10 73 # Nothing for now.
7766f137
GS
74}
75elsif ($PLATFORM eq 'win32') {
549a6b10 76 $CCTYPE = "MSVC" unless defined $CCTYPE;
00b02797
JH
77 foreach ($thrdvar_h, $intrpvar_h, $perlvars_h, $global_sym,
78 $pp_sym, $globvar_sym, $perlio_sym) {
549a6b10
JH
79 s!^!..\\!;
80 }
81}
084592ab
CN
82elsif ($PLATFORM eq 'MacOS') {
83 foreach ($thrdvar_h, $intrpvar_h, $perlvars_h, $global_sym,
84 $pp_sym, $globvar_sym, $perlio_sym) {
85 s!^!::!;
86 }
87}
549a6b10 88
084592ab 89unless ($PLATFORM eq 'win32' || $PLATFORM eq 'MacOS') {
549a6b10 90 open(CFG,$config_sh) || die "Cannot open $config_sh: $!\n";
7766f137 91 while (<CFG>) {
549a6b10
JH
92 if (/^(?:ccflags|optimize)='(.+)'$/) {
93 $_ = $1;
94 $define{$1} = 1 while /-D(\w+)/g;
95 }
3cfae81b
IZ
96 if ($PLATFORM eq 'os2') {
97 $CONFIG_ARGS = $1 if /^(?:config_args)='(.+)'$/;
0e32cd81 98 $ARCHNAME = $1 if /^(?:archname)='(.+)'$/;
3cfae81b 99 }
549a6b10
JH
100 }
101 close(CFG);
102}
103
104open(CFG,$config_h) || die "Cannot open $config_h: $!\n";
7766f137
GS
105while (<CFG>) {
106 $define{$1} = 1 if /^\s*#\s*define\s+(MYMALLOC)\b/;
7766f137 107 $define{$1} = 1 if /^\s*#\s*define\s+(MULTIPLICITY)\b/;
0e32cd81
JH
108 $define{$1} = 1 if /^\s*#\s*define\s+(PERL_\w+)\b/;
109 $define{$1} = 1 if /^\s*#\s*define\s+(USE_\w+)\b/;
7766f137 110}
bbc8f9de
NIS
111close(CFG);
112
18c4b137
JH
113# perl.h logic duplication begins
114
115if ($define{USE_ITHREADS}) {
341bd822 116 if (!$define{MULTIPLICITY} && !$define{PERL_OBJECT}) {
18c4b137
JH
117 $define{MULTIPLICITY} = 1;
118 }
119}
120
121$define{PERL_IMPLICIT_CONTEXT} ||=
122 $define{USE_ITHREADS} ||
66cf6f75 123 $define{USE_5005THREADS} ||
18c4b137
JH
124 $define{MULTIPLICITY} ;
125
126if ($define{PERL_CAPI}) {
127 delete $define{PERL_OBJECT};
9df9a5cd 128 $define{MULTIPLICITY} = 1;
18c4b137
JH
129 $define{PERL_IMPLICIT_CONTEXT} = 1;
130 $define{PERL_IMPLICIT_SYS} = 1;
131}
132
133if ($define{PERL_OBJECT}) {
134 $define{PERL_IMPLICIT_CONTEXT} = 1;
135 $define{PERL_IMPLICIT_SYS} = 1;
136}
137
138# perl.h logic duplication ends
139
549a6b10
JH
140if ($PLATFORM eq 'win32') {
141 warn join(' ',keys %define)."\n";
7d4dff66 142 print "LIBRARY Perl57\n";
dfdd1393
GS
143 print "DESCRIPTION 'Perl interpreter'\n";
144 print "EXPORTS\n";
145 if ($define{PERL_IMPLICIT_SYS}) {
549a6b10 146 output_symbol("perl_get_host_info");
7766f137 147 output_symbol("perl_alloc_override");
51371543 148 }
7766f137
GS
149}
150elsif ($PLATFORM eq 'os2') {
3cfae81b
IZ
151 ($v = $]) =~ s/(\d\.\d\d\d)(\d\d)$/$1_$2/;
152 $v .= '-thread' if $ARCHNAME =~ /-thread/;
3cfae81b 153 ($dll = $define{PERL_DLL}) =~ s/\.dll$//i;
1102eebe
IZ
154 $d = "DESCRIPTION '\@#perl5-porters\@perl.org:$v#\@ Perl interpreter, configured as $CONFIG_ARGS'";
155 $d = substr($d, 0, 249) . "...'" if length $d > 253;
3cfae81b
IZ
156 print <<"---EOP---";
157LIBRARY '$dll' INITINSTANCE TERMINSTANCE
1102eebe 158$d
3cfae81b
IZ
159STACKSIZE 32768
160CODE LOADONCALL
161DATA LOADONCALL NONSHARED MULTIPLE
162EXPORTS
163---EOP---
7766f137
GS
164}
165elsif ($PLATFORM eq 'aix') {
61d42ce4
JH
166 $OSVER = `uname -v`;
167 chop $OSVER;
168 $OSREL = `uname -r`;
169 chop $OSREL;
170 if ($OSVER > 4 || ($OSVER == 4 && $OSREL >= 3)) {
171 print "#! ..\n";
172 } else {
173 print "#!\n";
174 }
ac4c12e7 175}
bbc8f9de 176
22239a37
NIS
177my %skip;
178my %export;
179
51371543
GS
180sub skip_symbols {
181 my $list = shift;
182 foreach my $symbol (@$list) {
183 $skip{$symbol} = 1;
184 }
22239a37
NIS
185}
186
51371543
GS
187sub emit_symbols {
188 my $list = shift;
189 foreach my $symbol (@$list) {
190 my $skipsym = $symbol;
191 # XXX hack
6f4183fe 192 if ($define{PERL_OBJECT} || $define{MULTIPLICITY}) {
51371543
GS
193 $skipsym =~ s/^Perl_[GIT](\w+)_ptr$/PL_$1/;
194 }
195 emit_symbol($symbol) unless exists $skip{$skipsym};
196 }
22239a37
NIS
197}
198
549a6b10 199if ($PLATFORM eq 'win32') {
7766f137
GS
200 skip_symbols [qw(
201 PL_statusvalue_vms
202 PL_archpat_auto
203 PL_cryptseen
204 PL_DBcv
205 PL_generation
206 PL_lastgotoprobe
207 PL_linestart
208 PL_modcount
209 PL_pending_ident
210 PL_sortcxix
211 PL_sublex_info
212 PL_timesbuf
213 main
214 Perl_ErrorNo
215 Perl_GetVars
216 Perl_do_exec3
217 Perl_do_ipcctl
218 Perl_do_ipcget
219 Perl_do_msgrcv
220 Perl_do_msgsnd
221 Perl_do_semop
222 Perl_do_shmio
223 Perl_dump_fds
224 Perl_init_thread_intern
225 Perl_my_bzero
9d50d399 226 Perl_my_bcopy
7766f137
GS
227 Perl_my_htonl
228 Perl_my_ntohl
229 Perl_my_swap
230 Perl_my_chsize
231 Perl_same_dirent
232 Perl_setenv_getix
233 Perl_unlnk
234 Perl_watch
235 Perl_safexcalloc
236 Perl_safexmalloc
237 Perl_safexfree
238 Perl_safexrealloc
239 Perl_my_memcmp
240 Perl_my_memset
241 PL_cshlen
242 PL_cshname
243 PL_opsave
244 Perl_do_exec
245 Perl_getenv_len
246 Perl_my_pclose
247 Perl_my_popen
248 )];
249}
250elsif ($PLATFORM eq 'aix') {
549a6b10 251 skip_symbols([qw(
7766f137
GS
252 Perl_dump_fds
253 Perl_ErrorNo
254 Perl_GetVars
255 Perl_my_bcopy
256 Perl_my_bzero
257 Perl_my_chsize
258 Perl_my_htonl
259 Perl_my_memcmp
260 Perl_my_memset
261 Perl_my_ntohl
262 Perl_my_swap
263 Perl_safexcalloc
264 Perl_safexfree
265 Perl_safexmalloc
266 Perl_safexrealloc
267 Perl_same_dirent
268 Perl_unlnk
6c644e78 269 Perl_sys_intern_clear
95151ede 270 Perl_sys_intern_dup
52853b95 271 Perl_sys_intern_init
7766f137
GS
272 PL_cryptseen
273 PL_opsave
274 PL_statusvalue_vms
275 PL_sys_intern
276 )]);
277}
278elsif ($PLATFORM eq 'os2') {
3cfae81b 279 emit_symbols([qw(
7766f137
GS
280 ctermid
281 get_sysinfo
282 Perl_OS2_init
283 OS2_Perl_data
284 dlopen
285 dlsym
286 dlerror
403d6f8e 287 dlclose
7766f137
GS
288 my_tmpfile
289 my_tmpnam
290 my_flock
9c130f5b
NIS
291 my_rmdir
292 my_mkdir
7766f137
GS
293 malloc_mutex
294 threads_mutex
295 nthreads
296 nthreads_cond
297 os2_cond_wait
298 os2_stat
299 pthread_join
300 pthread_create
301 pthread_detach
302 XS_Cwd_change_drive
303 XS_Cwd_current_drive
304 XS_Cwd_extLibpath
305 XS_Cwd_extLibpath_set
306 XS_Cwd_sys_abspath
307 XS_Cwd_sys_chdir
308 XS_Cwd_sys_cwd
309 XS_Cwd_sys_is_absolute
310 XS_Cwd_sys_is_relative
311 XS_Cwd_sys_is_rooted
312 XS_DynaLoader_mod2fname
313 XS_File__Copy_syscopy
314 Perl_Register_MQ
315 Perl_Deregister_MQ
316 Perl_Serve_Messages
317 Perl_Process_Messages
318 init_PMWIN_entries
319 PMWIN_entries
320 Perl_hab_GET
321 )]);
3cfae81b 322}
084592ab
CN
323elsif ($PLATFORM eq 'MacOS') {
324 skip_symbols [qw(
325 Perl_GetVars
326 PL_cryptseen
327 PL_cshlen
328 PL_cshname
329 PL_statusvalue_vms
330 PL_sys_intern
331 PL_opsave
332 PL_timesbuf
333 Perl_dump_fds
334 Perl_my_bcopy
335 Perl_my_bzero
336 Perl_my_chsize
337 Perl_my_htonl
338 Perl_my_memcmp
339 Perl_my_memset
340 Perl_my_ntohl
341 Perl_my_swap
342 Perl_safexcalloc
343 Perl_safexfree
344 Perl_safexmalloc
345 Perl_safexrealloc
346 Perl_unlnk
fe05f414
JH
347 Perl_sys_intern_clear
348 Perl_sys_intern_init
084592ab
CN
349 )];
350}
351
3cfae81b 352
7766f137
GS
353unless ($define{'DEBUGGING'}) {
354 skip_symbols [qw(
7766f137
GS
355 Perl_deb_growlevel
356 Perl_debop
357 Perl_debprofdump
358 Perl_debstack
359 Perl_debstackptrs
360 Perl_runops_debug
361 Perl_sv_peek
362 PL_block_type
363 PL_watchaddr
364 PL_watchok
365 )];
366}
367
368if ($define{'PERL_IMPLICIT_SYS'}) {
369 skip_symbols [qw(
370 Perl_getenv_len
371 Perl_my_popen
372 Perl_my_pclose
373 )];
374}
375else {
376 skip_symbols [qw(
377 PL_Mem
378 PL_MemShared
379 PL_MemParse
380 PL_Env
381 PL_StdIO
382 PL_LIO
383 PL_Dir
384 PL_Sock
385 PL_Proc
386 )];
387}
388
7c128300
GS
389unless ($define{'PERL_FLEXIBLE_EXCEPTIONS'}) {
390 skip_symbols [qw(
391 PL_protect
392 Perl_default_protect
393 Perl_vdefault_protect
394 )];
395}
396
7766f137
GS
397if ($define{'MYMALLOC'}) {
398 emit_symbols [qw(
399 Perl_dump_mstats
827e134a 400 Perl_get_mstats
7766f137
GS
401 Perl_malloc
402 Perl_mfree
403 Perl_realloc
404 Perl_calloc
9c130f5b
NIS
405 Perl_strdup
406 Perl_putenv
7766f137 407 )];
bbda9c9d 408 if ($define{'USE_5005THREADS'} || $define{'USE_ITHREADS'}) {
1feb2720
GS
409 emit_symbols [qw(
410 PL_malloc_mutex
411 )];
412 }
80fc1a6e
GS
413 else {
414 skip_symbols [qw(
415 PL_malloc_mutex
416 )];
417 }
51371543
GS
418}
419else {
7766f137
GS
420 skip_symbols [qw(
421 PL_malloc_mutex
422 Perl_dump_mstats
6ecd3fcb 423 Perl_get_mstats
7766f137
GS
424 Perl_malloc
425 Perl_mfree
426 Perl_realloc
427 Perl_calloc
428 Perl_malloced_size
429 )];
430}
431
f433d095 432unless ($define{'USE_5005THREADS'} || $define{'USE_ITHREADS'}) {
7766f137
GS
433 skip_symbols [qw(
434 PL_thr_key
f433d095
GS
435 )];
436}
437
438unless ($define{'USE_5005THREADS'}) {
439 skip_symbols [qw(
7766f137
GS
440 PL_sv_mutex
441 PL_strtab_mutex
442 PL_svref_mutex
7766f137
GS
443 PL_cred_mutex
444 PL_eval_mutex
6940069f
GS
445 PL_fdpid_mutex
446 PL_sv_lock_mutex
7766f137
GS
447 PL_eval_cond
448 PL_eval_owner
449 PL_threads_mutex
450 PL_nthreads
451 PL_nthreads_cond
452 PL_threadnum
453 PL_threadsv_names
454 PL_thrsv
455 PL_vtbl_mutex
7766f137
GS
456 Perl_condpair_magic
457 Perl_new_struct_thread
458 Perl_per_thread_magicals
459 Perl_thread_create
460 Perl_find_threadsv
461 Perl_unlock_condpair
462 Perl_magic_mutexfree
4755096e 463 Perl_sv_lock
7766f137
GS
464 )];
465}
466
467unless ($define{'USE_ITHREADS'}) {
468 skip_symbols [qw(
469 PL_ptr_table
534825c4 470 PL_op_mutex
7766f137
GS
471 Perl_dirp_dup
472 Perl_cx_dup
473 Perl_si_dup
474 Perl_any_dup
475 Perl_ss_dup
476 Perl_fp_dup
477 Perl_gp_dup
478 Perl_he_dup
479 Perl_mg_dup
480 Perl_re_dup
481 Perl_sv_dup
482 Perl_sys_intern_dup
86593e8d 483 Perl_ptr_table_clear
7766f137 484 Perl_ptr_table_fetch
86593e8d 485 Perl_ptr_table_free
7766f137 486 Perl_ptr_table_new
4ac9195f
MS
487 Perl_ptr_table_clear
488 Perl_ptr_table_free
7766f137
GS
489 Perl_ptr_table_split
490 Perl_ptr_table_store
491 perl_clone
492 perl_clone_using
493 )];
494}
495
496unless ($define{'PERL_IMPLICIT_CONTEXT'}) {
497 skip_symbols [qw(
498 Perl_croak_nocontext
499 Perl_die_nocontext
500 Perl_deb_nocontext
501 Perl_form_nocontext
e0f4245d 502 Perl_load_module_nocontext
7766f137
GS
503 Perl_mess_nocontext
504 Perl_warn_nocontext
505 Perl_warner_nocontext
506 Perl_newSVpvf_nocontext
507 Perl_sv_catpvf_nocontext
508 Perl_sv_setpvf_nocontext
509 Perl_sv_catpvf_mg_nocontext
510 Perl_sv_setpvf_mg_nocontext
511 )];
512}
513
514unless ($define{'PERL_IMPLICIT_SYS'}) {
515 skip_symbols [qw(
516 perl_alloc_using
014822e4 517 perl_clone_using
7766f137
GS
518 )];
519}
520
521unless ($define{'FAKE_THREADS'}) {
522 skip_symbols [qw(PL_curthr)];
523}
524
525sub readvar {
526 my $file = shift;
527 my $proc = shift || sub { "PL_$_[2]" };
528 open(VARS,$file) || die "Cannot open $file: $!\n";
529 my @syms;
530 while (<VARS>) {
531 # All symbols have a Perl_ prefix because that's what embed.h
532 # sticks in front of them.
533 push(@syms, &$proc($1,$2,$3)) if (/\bPERLVAR(A?I?C?)\(([IGT])(\w+)/);
9df9a5cd
NIS
534 }
535 close(VARS);
7766f137
GS
536 return \@syms;
537}
538
6f4183fe 539if ($define{'USE_5005THREADS'}) {
7766f137
GS
540 my $thrd = readvar($thrdvar_h);
541 skip_symbols $thrd;
542}
543
7766f137
GS
544if ($define{'PERL_GLOBAL_STRUCT'}) {
545 my $global = readvar($perlvars_h);
546 skip_symbols $global;
547 emit_symbol('Perl_GetVars');
548 emit_symbols [qw(PL_Vars PL_VarsPtr)] unless $CCTYPE eq 'GCC';
549}
36c15d3f 550
22c35a8c
GS
551# functions from *.sym files
552
954c1994 553my @syms = ($global_sym, $globvar_sym); # $pp_sym is not part of the API
549a6b10 554
9df9a5cd
NIS
555my @layer_syms = qw(
556 PerlIOBase_clearerr
557 PerlIOBase_close
558 PerlIOBase_eof
559 PerlIOBase_error
560 PerlIOBase_fileno
8c0134a8
NIS
561 PerlIOBase_setlinebuf
562 PerlIOBase_pushed
563 PerlIOBase_read
a555790d 564 PerlIOBase_unread
9df9a5cd 565 PerlIOBuf_bufsiz
9df9a5cd
NIS
566 PerlIOBuf_fill
567 PerlIOBuf_flush
568 PerlIOBuf_get_cnt
569 PerlIOBuf_get_ptr
570 PerlIOBuf_open
571 PerlIOBuf_pushed
572 PerlIOBuf_read
9df9a5cd
NIS
573 PerlIOBuf_seek
574 PerlIOBuf_set_ptrcnt
9df9a5cd
NIS
575 PerlIOBuf_tell
576 PerlIOBuf_unread
577 PerlIOBuf_write
578 PerlIO_define_layer
8c0134a8 579 PerlIO_arg_fetch
9df9a5cd 580 PerlIO_pending
8c0134a8 581 PerlIO_allocate
9df9a5cd
NIS
582 PerlIO_push
583 PerlIO_unread
584);
585
7766f137 586if ($define{'USE_PERLIO'}) {
084592ab
CN
587 push @syms, $perlio_sym;
588 if ($define{'USE_SFIO'}) {
9df9a5cd 589 skip_symbols \@layer_syms;
084592ab
CN
590 # SFIO defines most of the PerlIO routines as macros
591 skip_symbols [qw(
592 PerlIO_canset_cnt
593 PerlIO_clearerr
594 PerlIO_close
595 PerlIO_eof
596 PerlIO_error
597 PerlIO_exportFILE
598 PerlIO_fast_gets
599 PerlIO_fdopen
600 PerlIO_fileno
601 PerlIO_findFILE
602 PerlIO_flush
603 PerlIO_get_base
604 PerlIO_get_bufsiz
605 PerlIO_get_cnt
606 PerlIO_get_ptr
607 PerlIO_getc
608 PerlIO_getname
609 PerlIO_has_base
610 PerlIO_has_cntptr
611 PerlIO_importFILE
612 PerlIO_open
613 PerlIO_printf
614 PerlIO_putc
615 PerlIO_puts
616 PerlIO_read
617 PerlIO_releaseFILE
618 PerlIO_reopen
619 PerlIO_rewind
620 PerlIO_seek
621 PerlIO_set_cnt
622 PerlIO_set_ptrcnt
623 PerlIO_setlinebuf
624 PerlIO_sprintf
625 PerlIO_stderr
626 PerlIO_stdin
627 PerlIO_stdout
628 PerlIO_stdoutf
629 PerlIO_tell
630 PerlIO_ungetc
631 PerlIO_vprintf
632 PerlIO_write
633 )];
634 }
5138f914 635} else {
86593e8d 636 # Skip the PerlIO New Generation symbols.
9df9a5cd
NIS
637 skip_symbols \@layer_syms;
638}
7766f137
GS
639
640for my $syms (@syms) {
641 open (GLOBAL, "<$syms") || die "failed to open $syms: $!\n";
642 while (<GLOBAL>) {
643 next if (!/^[A-Za-z]/);
644 # Functions have a Perl_ prefix
645 # Variables have a PL_ prefix
646 chomp($_);
647 my $symbol = ($syms =~ /var\.sym$/i ? "PL_" : "");
648 $symbol .= $_;
649 emit_symbol($symbol) unless exists $skip{$symbol};
650 }
651 close(GLOBAL);
652}
0a753a76 653
22c35a8c 654# variables
0a753a76 655
6f4183fe 656if ($define{'PERL_OBJECT'} || $define{'MULTIPLICITY'}) {
1acb48c9 657 for my $f ($perlvars_h, $intrpvar_h, $thrdvar_h) {
18c4b137
JH
658 my $glob = readvar($f, sub { "Perl_" . $_[1] . $_[2] . "_ptr" });
659 emit_symbols $glob;
18c4b137 660 }
1acb48c9
GS
661 # XXX AIX seems to want the perlvars.h symbols, for some reason
662 if ($PLATFORM eq 'aix') {
663 my $glob = readvar($perlvars_h);
51371543
GS
664 emit_symbols $glob;
665 }
666}
667else {
668 unless ($define{'PERL_GLOBAL_STRUCT'}) {
549a6b10 669 my $glob = readvar($perlvars_h);
51371543 670 emit_symbols $glob;
9df9a5cd 671 }
51371543 672 unless ($define{'MULTIPLICITY'}) {
549a6b10 673 my $glob = readvar($intrpvar_h);
51371543 674 emit_symbols $glob;
9df9a5cd 675 }
bbda9c9d 676 unless ($define{'MULTIPLICITY'} || $define{'USE_5005THREADS'}) {
549a6b10 677 my $glob = readvar($thrdvar_h);
51371543 678 emit_symbols $glob;
9df9a5cd 679 }
51371543 680}
0a753a76 681
549a6b10
JH
682sub try_symbol {
683 my $symbol = shift;
22239a37 684
549a6b10
JH
685 return if $symbol !~ /^[A-Za-z]/;
686 return if $symbol =~ /^\#/;
687 $symbol =~s/\r//g;
688 chomp($symbol);
43cd9f80 689 return if exists $skip{$symbol};
549a6b10 690 emit_symbol($symbol);
3e3baf6d 691}
0a753a76 692
549a6b10
JH
693while (<DATA>) {
694 try_symbol($_);
ac4c12e7
GS
695}
696
549a6b10
JH
697if ($PLATFORM eq 'win32') {
698 foreach my $symbol (qw(
00b02797
JH
699 setuid
700 setgid
7766f137 701 boot_DynaLoader
7766f137 702 Perl_init_os_extras
c44d3fdb 703 Perl_thread_create
7766f137
GS
704 Perl_win32_init
705 RunPerl
7766f137
GS
706 win32_errno
707 win32_environ
7766f137
GS
708 win32_abort
709 win32_fstat
710 win32_stat
711 win32_pipe
712 win32_popen
713 win32_pclose
714 win32_rename
715 win32_setmode
716 win32_lseek
717 win32_tell
718 win32_dup
719 win32_dup2
720 win32_open
721 win32_close
722 win32_eof
723 win32_read
724 win32_write
725 win32_spawnvp
726 win32_mkdir
727 win32_rmdir
728 win32_chdir
729 win32_flock
730 win32_execv
731 win32_execvp
732 win32_htons
733 win32_ntohs
734 win32_htonl
735 win32_ntohl
736 win32_inet_addr
737 win32_inet_ntoa
738 win32_socket
739 win32_bind
740 win32_listen
741 win32_accept
742 win32_connect
743 win32_send
744 win32_sendto
745 win32_recv
746 win32_recvfrom
747 win32_shutdown
748 win32_closesocket
749 win32_ioctlsocket
750 win32_setsockopt
751 win32_getsockopt
752 win32_getpeername
753 win32_getsockname
754 win32_gethostname
755 win32_gethostbyname
756 win32_gethostbyaddr
757 win32_getprotobyname
758 win32_getprotobynumber
759 win32_getservbyname
760 win32_getservbyport
761 win32_select
762 win32_endhostent
763 win32_endnetent
764 win32_endprotoent
765 win32_endservent
766 win32_getnetent
767 win32_getnetbyname
768 win32_getnetbyaddr
769 win32_getprotoent
770 win32_getservent
771 win32_sethostent
772 win32_setnetent
773 win32_setprotoent
774 win32_setservent
775 win32_getenv
776 win32_putenv
777 win32_perror
7766f137
GS
778 win32_malloc
779 win32_calloc
780 win32_realloc
781 win32_free
782 win32_sleep
783 win32_times
784 win32_access
785 win32_alarm
786 win32_chmod
787 win32_open_osfhandle
788 win32_get_osfhandle
789 win32_ioctl
790 win32_link
791 win32_unlink
792 win32_utime
793 win32_uname
794 win32_wait
795 win32_waitpid
796 win32_kill
797 win32_str_os_error
798 win32_opendir
799 win32_readdir
800 win32_telldir
801 win32_seekdir
802 win32_rewinddir
803 win32_closedir
804 win32_longpath
805 win32_os_id
806 win32_getpid
807 win32_crypt
808 win32_dynaload
00b02797
JH
809
810 win32_stdin
811 win32_stdout
812 win32_stderr
813 win32_ferror
814 win32_feof
815 win32_strerror
816 win32_fprintf
817 win32_printf
818 win32_vfprintf
819 win32_vprintf
820 win32_fread
821 win32_fwrite
822 win32_fopen
823 win32_fdopen
824 win32_freopen
825 win32_fclose
826 win32_fputs
827 win32_fputc
828 win32_ungetc
829 win32_getc
830 win32_fileno
831 win32_clearerr
832 win32_fflush
833 win32_ftell
834 win32_fseek
835 win32_fgetpos
836 win32_fsetpos
837 win32_rewind
838 win32_tmpfile
839 win32_setbuf
840 win32_setvbuf
841 win32_flushall
842 win32_fcloseall
843 win32_fgets
844 win32_gets
845 win32_fgetc
846 win32_putc
847 win32_puts
848 win32_getchar
849 win32_putchar
7766f137
GS
850 ))
851 {
549a6b10
JH
852 try_symbol($symbol);
853 }
854}
3cfae81b 855elsif ($PLATFORM eq 'os2') {
7766f137
GS
856 open MAP, 'miniperl.map' or die 'Cannot read miniperl.map';
857 /^\s*[\da-f:]+\s+(\w+)/i and $mapped{$1}++ foreach <MAP>;
858 close MAP or die 'Cannot close miniperl.map';
859
860 @missing = grep { !exists $mapped{$_} and !exists $bincompat5005{$_} }
861 keys %export;
862 delete $export{$_} foreach @missing;
3cfae81b 863}
084592ab
CN
864elsif ($PLATFORM eq 'MacOS') {
865 open MACSYMS, 'macperl.sym' or die 'Cannot read macperl.sym';
866
867 while (<MACSYMS>) {
868 try_symbol($_);
869 }
870
871 close MACSYMS;
872}
22239a37 873
549a6b10
JH
874# Now all symbols should be defined because
875# next we are going to output them.
876
7766f137
GS
877foreach my $symbol (sort keys %export) {
878 output_symbol($symbol);
879}
549a6b10
JH
880
881sub emit_symbol {
7766f137 882 my $symbol = shift;
9df9a5cd 883 chomp($symbol);
7766f137 884 $export{$symbol} = 1;
549a6b10
JH
885}
886
887sub output_symbol {
888 my $symbol = shift;
4cb71bb6
GS
889 $symbol = $bincompat5005{$symbol}
890 if $define{PERL_BINCOMPAT_5005} and $symbol =~ /^($bincompat5005)$/;
549a6b10 891 if ($PLATFORM eq 'win32') {
549a6b10 892 $symbol = "_$symbol" if $CCTYPE eq 'BORLAND';
520c758a 893 print "\t$symbol\n";
549a6b10
JH
894# XXX: binary compatibility between compilers is an exercise
895# in frustration :-(
896# if ($CCTYPE eq "BORLAND") {
897# # workaround Borland quirk by exporting both the straight
898# # name and a name with leading underscore. Note the
899# # alias *must* come after the symbol itself, if both
900# # are to be exported. (Linker bug?)
901# print "\t_$symbol\n";
902# print "\t$symbol = _$symbol\n";
903# }
904# elsif ($CCTYPE eq 'GCC') {
905# # Symbols have leading _ whole process is $%@"% slow
906# # so skip aliases for now
907# nprint "\t$symbol\n";
908# }
909# else {
910# # for binary coexistence, export both the symbol and
911# # alias with leading underscore
912# print "\t$symbol\n";
913# print "\t_$symbol = $symbol\n";
914# }
7766f137
GS
915 }
916 elsif ($PLATFORM eq 'os2') {
3cfae81b 917 print qq( "$symbol"\n);
7766f137 918 }
084592ab 919 elsif ($PLATFORM eq 'aix' || $PLATFORM eq 'MacOS') {
549a6b10
JH
920 print "$symbol\n";
921 }
922}
923
9241;
925__DATA__
926# extra globals not included above.
927perl_alloc
7766f137 928perl_alloc_using
014822e4
GS
929perl_clone
930perl_clone_using
549a6b10
JH
931perl_construct
932perl_destruct
933perl_free
934perl_parse
935perl_run
18b7339f
NIS
936PerlIO_define_layer
937PerlIOBuf_set_ptrcnt
938PerlIOBuf_get_cnt
939PerlIOBuf_get_ptr
940PerlIOBuf_bufsiz
18b7339f 941PerlIOBase_clearerr
8c0134a8
NIS
942PerlIOBase_setlinebuf
943PerlIOBase_pushed
944PerlIOBase_read
9156fa33 945PerlIOBase_unread
18b7339f
NIS
946PerlIOBase_error
947PerlIOBase_eof
948PerlIOBuf_tell
949PerlIOBuf_seek
950PerlIOBuf_write
951PerlIOBuf_unread
952PerlIOBuf_read
18b7339f 953PerlIOBuf_open
18b7339f
NIS
954PerlIOBase_fileno
955PerlIOBuf_pushed
956PerlIOBuf_fill
957PerlIOBuf_flush
958PerlIOBase_close
959PerlIO_define_layer
960PerlIO_pending
961PerlIO_unread
568ad336 962PerlIO_push
8c0134a8
NIS
963PerlIO_allocate
964PerlIO_arg_fetch
568ad336
NIS
965PerlIO_apply_layers
966perlsio_binmode
967PerlIO_binmode
968PerlIO_init
969PerlIO_tmpfile
970PerlIO_setpos
971PerlIO_getpos
972PerlIO_vsprintf
973PerlIO_sprintf