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