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