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