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