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