ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/cvsroot/staticperl/perl/embed.pl
Revision: 1.1
Committed: Thu Jun 30 14:26:41 2005 UTC (21 years, 3 months ago) by root
Content type: text/plain
Branch: MAIN
CVS Tags: PERL-5-8-7, HEAD
Branch point for: PERL
Log Message:
*** empty log message ***

File Contents

# Content
1 #!/usr/bin/perl -w
2
3 require 5.003; # keep this compatible, an old perl is all we may have before
4 # we build the new one
5
6 BEGIN {
7 # Get function prototypes
8 require 'regen_lib.pl';
9 }
10
11 #
12 # See database of global and static function prototypes in embed.fnc
13 # This is used to generate prototype headers under various configurations,
14 # export symbols lists for different platforms, and macros to provide an
15 # implicit interpreter context argument.
16 #
17
18 sub do_not_edit ($)
19 {
20 my $file = shift;
21
22 my $years = '1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005';
23
24 $years =~ s/1999,/1999,\n / if length $years > 40;
25
26 my $warning = <<EOW;
27
28 $file
29
30 Copyright (C) $years, by Larry Wall and others
31
32 You may distribute under the terms of either the GNU General Public
33 License or the Artistic License, as specified in the README file.
34
35 !!!!!!! DO NOT EDIT THIS FILE !!!!!!!
36 This file is built by embed.pl from data in embed.fnc, embed.pl,
37 pp.sym, intrpvar.h, perlvars.h and thrdvar.h.
38 Any changes made here will be lost!
39
40 Edit those files and run 'make regen_headers' to effect changes.
41
42 EOW
43
44 $warning .= <<EOW if $file eq 'perlapi.c';
45
46 Up to the threshold of the door there mounted a flight of twenty-seven
47 broad stairs, hewn by some unknown art of the same black stone. This
48 was the only entrance to the tower.
49
50
51 EOW
52
53 if ($file =~ m:\.[ch]$:) {
54 $warning =~ s:^: * :gm;
55 $warning =~ s: +$::gm;
56 $warning =~ s: :/:;
57 $warning =~ s:$:/:;
58 }
59 else {
60 $warning =~ s:^:# :gm;
61 $warning =~ s: +$::gm;
62 }
63 $warning;
64 } # do_not_edit
65
66 open IN, "embed.fnc" or die $!;
67
68 # walk table providing an array of components in each line to
69 # subroutine, printing the result
70 sub walk_table (&@) {
71 my $function = shift;
72 my $filename = shift || '-';
73 my $leader = shift;
74 defined $leader or $leader = do_not_edit ($filename);
75 my $trailer = shift;
76 my $F;
77 local *F;
78 if (ref $filename) { # filehandle
79 $F = $filename;
80 }
81 else {
82 safer_unlink $filename;
83 open F, ">$filename" or die "Can't open $filename: $!";
84 binmode F;
85 $F = \*F;
86 }
87 print $F $leader if $leader;
88 seek IN, 0, 0; # so we may restart
89 while (<IN>) {
90 chomp;
91 next if /^:/;
92 while (s|\\$||) {
93 $_ .= <IN>;
94 chomp;
95 }
96 s/\s+$//;
97 my @args;
98 if (/^\s*(#|$)/) {
99 @args = $_;
100 }
101 else {
102 @args = split /\s*\|\s*/, $_;
103 }
104 my @outs = &{$function}(@args);
105 print $F @outs; # $function->(@args) is not 5.003
106 }
107 print $F $trailer if $trailer;
108 unless (ref $filename) {
109 close $F or die "Error closing $filename: $!";
110 }
111 }
112
113 sub munge_c_files () {
114 my $functions = {};
115 unless (@ARGV) {
116 warn "\@ARGV empty, nothing to do\n";
117 return;
118 }
119 walk_table {
120 if (@_ > 1) {
121 $functions->{$_[2]} = \@_ if $_[@_-1] =~ /\.\.\./;
122 }
123 } '/dev/null', '';
124 local $^I = '.bak';
125 while (<>) {
126 # if (/^#\s*include\s+"perl.h"/) {
127 # my $file = uc $ARGV;
128 # $file =~ s/\./_/g;
129 # print "#define PERL_IN_$file\n";
130 # }
131 # s{^(\w+)\s*\(}
132 # {
133 # my $f = $1;
134 # my $repl = "$f(";
135 # if (exists $functions->{$f}) {
136 # my $flags = $functions->{$f}[0];
137 # $repl = "Perl_$repl" if $flags =~ /p/;
138 # unless ($flags =~ /n/) {
139 # $repl .= "pTHX";
140 # $repl .= "_ " if @{$functions->{$f}} > 3;
141 # }
142 # warn("$ARGV:$.:$repl\n");
143 # }
144 # $repl;
145 # }e;
146 s{(\b(\w+)[ \t]*\([ \t]*(?!aTHX))}
147 {
148 my $repl = $1;
149 my $f = $2;
150 if (exists $functions->{$f}) {
151 $repl .= "aTHX_ ";
152 warn("$ARGV:$.:$`#$repl#$'");
153 }
154 $repl;
155 }eg;
156 print;
157 close ARGV if eof; # restart $.
158 }
159 exit;
160 }
161
162 #munge_c_files();
163
164 # generate proto.h
165 my $wrote_protected = 0;
166
167 sub write_protos {
168 my $ret = "";
169 if (@_ == 1) {
170 my $arg = shift;
171 $ret .= "$arg\n";
172 }
173 else {
174 my ($flags,$retval,$func,@args) = @_;
175 $ret .= '/* ' if $flags =~ /m/;
176 if ($flags =~ /s/) {
177 $retval = "STATIC $retval";
178 $func = "S_$func";
179 }
180 else {
181 $retval = "PERL_CALLCONV $retval";
182 if ($flags =~ /p/) {
183 $func = "Perl_$func";
184 }
185 }
186 $ret .= "$retval\t$func(";
187 unless ($flags =~ /n/) {
188 $ret .= "pTHX";
189 $ret .= "_ " if @args;
190 }
191 if (@args) {
192 $ret .= join ", ", @args;
193 }
194 else {
195 $ret .= "void" if $flags =~ /n/;
196 }
197 $ret .= ")";
198 $ret .= " __attribute__((noreturn))" if $flags =~ /r/;
199 if( $flags =~ /f/ ) {
200 my $prefix = $flags =~ /n/ ? '' : 'pTHX_';
201 my $args = scalar @args;
202 $ret .= sprintf "\n\t__attribute__format__(__printf__,%s%d,%s%d)",
203 $prefix, $args - 1, $prefix, $args;
204 }
205 $ret .= ";";
206 $ret .= ' */' if $flags =~ /m/;
207 $ret .= "\n";
208 }
209 $ret;
210 }
211
212 # generates global.sym (API export list), and populates %global with global symbols
213 sub write_global_sym {
214 my $ret = "";
215 if (@_ > 1) {
216 my ($flags,$retval,$func,@args) = @_;
217 if ($flags =~ /[AX]/ && $flags !~ /[xm]/
218 || $flags =~ /b/) { # public API, so export
219 $func = "Perl_$func" if $flags =~ /[pbX]/;
220 $ret = "$func\n";
221 }
222 }
223 $ret;
224 }
225
226 walk_table(\&write_protos, "proto.h", undef);
227 walk_table(\&write_global_sym, "global.sym", undef);
228
229 # XXX others that may need adding
230 # warnhook
231 # hints
232 # copline
233 my @extvars = qw(sv_undef sv_yes sv_no na dowarn
234 curcop compiling
235 tainting tainted stack_base stack_sp sv_arenaroot
236 no_modify
237 curstash DBsub DBsingle debstash
238 rsfp
239 stdingv
240 defgv
241 errgv
242 rsfp_filters
243 perldb
244 diehook
245 dirty
246 perl_destruct_level
247 ppaddr
248 );
249
250 sub readsyms (\%$) {
251 my ($syms, $file) = @_;
252 local (*FILE, $_);
253 open(FILE, "< $file")
254 or die "embed.pl: Can't open $file: $!\n";
255 while (<FILE>) {
256 s/[ \t]*#.*//; # Delete comments.
257 if (/^\s*(\S+)\s*$/) {
258 my $sym = $1;
259 warn "duplicate symbol $sym while processing $file\n"
260 if exists $$syms{$sym};
261 $$syms{$sym} = 1;
262 }
263 }
264 close(FILE);
265 }
266
267 # Perl_pp_* and Perl_ck_* are in pp.sym
268 readsyms my %ppsym, 'pp.sym';
269
270 sub readvars(\%$$@) {
271 my ($syms, $file,$pre,$keep_pre) = @_;
272 local (*FILE, $_);
273 open(FILE, "< $file")
274 or die "embed.pl: Can't open $file: $!\n";
275 while (<FILE>) {
276 s/[ \t]*#.*//; # Delete comments.
277 if (/PERLVARA?I?C?\($pre(\w+)/) {
278 my $sym = $1;
279 $sym = $pre . $sym if $keep_pre;
280 warn "duplicate symbol $sym while processing $file\n"
281 if exists $$syms{$sym};
282 $$syms{$sym} = $pre || 1;
283 }
284 }
285 close(FILE);
286 }
287
288 my %intrp;
289 my %thread;
290
291 readvars %intrp, 'intrpvar.h','I';
292 readvars %thread, 'thrdvar.h','T';
293 readvars %globvar, 'perlvars.h','G';
294
295 my $sym;
296 foreach $sym (sort keys %thread) {
297 warn "$sym in intrpvar.h as well as thrdvar.h\n" if exists $intrp{$sym};
298 }
299
300 sub undefine ($) {
301 my ($sym) = @_;
302 "#undef $sym\n";
303 }
304
305 sub hide ($$) {
306 my ($from, $to) = @_;
307 my $t = int(length($from) / 8);
308 "#define $from" . "\t" x ($t < 3 ? 3 - $t : 1) . "$to\n";
309 }
310
311 sub bincompat_var ($$) {
312 my ($pfx, $sym) = @_;
313 my $arg = ($pfx eq 'G' ? 'NULL' : 'aTHX');
314 undefine("PL_$sym") . hide("PL_$sym", "(*Perl_${pfx}${sym}_ptr($arg))");
315 }
316
317 sub multon ($$$) {
318 my ($sym,$pre,$ptr) = @_;
319 hide("PL_$sym", "($ptr$pre$sym)");
320 }
321
322 sub multoff ($$) {
323 my ($sym,$pre) = @_;
324 return hide("PL_$pre$sym", "PL_$sym");
325 }
326
327 safer_unlink 'embed.h';
328 open(EM, '> embed.h') or die "Can't create embed.h: $!\n";
329 binmode EM;
330
331 print EM do_not_edit ("embed.h"), <<'END';
332
333 /* (Doing namespace management portably in C is really gross.) */
334
335 /* By defining PERL_NO_SHORT_NAMES (not done by default) the short forms
336 * (like warn instead of Perl_warn) for the API are not defined.
337 * Not defining the short forms is a good thing for cleaner embedding. */
338
339 #ifndef PERL_NO_SHORT_NAMES
340
341 /* Hide global symbols */
342
343 #if !defined(PERL_IMPLICIT_CONTEXT)
344
345 END
346
347 # Try to elimiate lots of repeated
348 # #ifdef PERL_CORE
349 # foo
350 # #endif
351 # #ifdef PERL_CORE
352 # bar
353 # #endif
354 # by tracking state and merging foo and bar into one block.
355 my $ifdef_state = '';
356
357 walk_table {
358 my $ret = "";
359 my $new_ifdef_state = '';
360 if (@_ == 1) {
361 my $arg = shift;
362 $ret .= "$arg\n" if $arg =~ /^#\s*(if|ifn?def|else|endif)\b/;
363 }
364 else {
365 my ($flags,$retval,$func,@args) = @_;
366 unless ($flags =~ /[om]/) {
367 if ($flags =~ /s/) {
368 $ret .= hide($func,"S_$func");
369 }
370 elsif ($flags =~ /p/) {
371 $ret .= hide($func,"Perl_$func");
372 }
373 }
374 if ($ret ne '' && $flags !~ /A/) {
375 if ($flags =~ /E/) {
376 $new_ifdef_state
377 = "#if defined(PERL_CORE) || defined(PERL_EXT)\n";
378 }
379 else {
380 $new_ifdef_state = "#ifdef PERL_CORE\n";
381 }
382
383 if ($new_ifdef_state ne $ifdef_state) {
384 $ret = $new_ifdef_state . $ret;
385 }
386 }
387 }
388 if ($ifdef_state && $new_ifdef_state ne $ifdef_state) {
389 # Close the old one ahead of opening the new one.
390 $ret = "#endif\n$ret";
391 }
392 # Remember the new state.
393 $ifdef_state = $new_ifdef_state;
394 $ret;
395 } \*EM, "";
396
397 if ($ifdef_state) {
398 print EM "#endif\n";
399 }
400
401 for $sym (sort keys %ppsym) {
402 $sym =~ s/^Perl_//;
403 print EM hide($sym, "Perl_$sym");
404 }
405
406 print EM <<'END';
407
408 #else /* PERL_IMPLICIT_CONTEXT */
409
410 END
411
412 my @az = ('a'..'z');
413
414 $ifdef_state = '';
415 walk_table {
416 my $ret = "";
417 my $new_ifdef_state = '';
418 if (@_ == 1) {
419 my $arg = shift;
420 $ret .= "$arg\n" if $arg =~ /^#\s*(if|ifn?def|else|endif)\b/;
421 }
422 else {
423 my ($flags,$retval,$func,@args) = @_;
424 unless ($flags =~ /[om]/) {
425 my $args = scalar @args;
426 if ($args and $args[$args-1] =~ /\.\.\./) {
427 # we're out of luck for varargs functions under CPP
428 }
429 elsif ($flags =~ /n/) {
430 if ($flags =~ /s/) {
431 $ret .= hide($func,"S_$func");
432 }
433 elsif ($flags =~ /p/) {
434 $ret .= hide($func,"Perl_$func");
435 }
436 }
437 else {
438 my $alist = join(",", @az[0..$args-1]);
439 $ret = "#define $func($alist)";
440 my $t = int(length($ret) / 8);
441 $ret .= "\t" x ($t < 4 ? 4 - $t : 1);
442 if ($flags =~ /s/) {
443 $ret .= "S_$func(aTHX";
444 }
445 elsif ($flags =~ /p/) {
446 $ret .= "Perl_$func(aTHX";
447 }
448 $ret .= "_ " if $alist;
449 $ret .= $alist . ")\n";
450 }
451 }
452 unless ($flags =~ /A/) {
453 if ($flags =~ /E/) {
454 $new_ifdef_state
455 = "#if defined(PERL_CORE) || defined(PERL_EXT)\n";
456 }
457 else {
458 $new_ifdef_state = "#ifdef PERL_CORE\n";
459 }
460
461 if ($new_ifdef_state ne $ifdef_state) {
462 $ret = $new_ifdef_state . $ret;
463 }
464 }
465 }
466 if ($ifdef_state && $new_ifdef_state ne $ifdef_state) {
467 # Close the old one ahead of opening the new one.
468 $ret = "#endif\n$ret";
469 }
470 # Remember the new state.
471 $ifdef_state = $new_ifdef_state;
472 $ret;
473 } \*EM, "";
474
475 if ($ifdef_state) {
476 print EM "#endif\n";
477 }
478
479 for $sym (sort keys %ppsym) {
480 $sym =~ s/^Perl_//;
481 if ($sym =~ /^ck_/) {
482 print EM hide("$sym(a)", "Perl_$sym(aTHX_ a)");
483 }
484 elsif ($sym =~ /^pp_/) {
485 print EM hide("$sym()", "Perl_$sym(aTHX)");
486 }
487 else {
488 warn "Illegal symbol '$sym' in pp.sym";
489 }
490 }
491
492 print EM <<'END';
493
494 #endif /* PERL_IMPLICIT_CONTEXT */
495
496 #endif /* #ifndef PERL_NO_SHORT_NAMES */
497
498 END
499
500 print EM <<'END';
501
502 /* Compatibility stubs. Compile extensions with -DPERL_NOCOMPAT to
503 disable them.
504 */
505
506 #if !defined(PERL_CORE)
507 # define sv_setptrobj(rv,ptr,name) sv_setref_iv(rv,name,PTR2IV(ptr))
508 # define sv_setptrref(rv,ptr) sv_setref_iv(rv,Nullch,PTR2IV(ptr))
509 #endif
510
511 #if !defined(PERL_CORE) && !defined(PERL_NOCOMPAT)
512
513 /* Compatibility for various misnamed functions. All functions
514 in the API that begin with "perl_" (not "Perl_") take an explicit
515 interpreter context pointer.
516 The following are not like that, but since they had a "perl_"
517 prefix in previous versions, we provide compatibility macros.
518 */
519 # define perl_atexit(a,b) call_atexit(a,b)
520 # define perl_call_argv(a,b,c) call_argv(a,b,c)
521 # define perl_call_pv(a,b) call_pv(a,b)
522 # define perl_call_method(a,b) call_method(a,b)
523 # define perl_call_sv(a,b) call_sv(a,b)
524 # define perl_eval_sv(a,b) eval_sv(a,b)
525 # define perl_eval_pv(a,b) eval_pv(a,b)
526 # define perl_require_pv(a) require_pv(a)
527 # define perl_get_sv(a,b) get_sv(a,b)
528 # define perl_get_av(a,b) get_av(a,b)
529 # define perl_get_hv(a,b) get_hv(a,b)
530 # define perl_get_cv(a,b) get_cv(a,b)
531 # define perl_init_i18nl10n(a) init_i18nl10n(a)
532 # define perl_init_i18nl14n(a) init_i18nl14n(a)
533 # define perl_new_ctype(a) new_ctype(a)
534 # define perl_new_collate(a) new_collate(a)
535 # define perl_new_numeric(a) new_numeric(a)
536
537 /* varargs functions can't be handled with CPP macros. :-(
538 This provides a set of compatibility functions that don't take
539 an extra argument but grab the context pointer using the macro
540 dTHX.
541 */
542 #if defined(PERL_IMPLICIT_CONTEXT) && !defined(PERL_NO_SHORT_NAMES)
543 # define croak Perl_croak_nocontext
544 # define deb Perl_deb_nocontext
545 # define die Perl_die_nocontext
546 # define form Perl_form_nocontext
547 # define load_module Perl_load_module_nocontext
548 # define mess Perl_mess_nocontext
549 # define newSVpvf Perl_newSVpvf_nocontext
550 # define sv_catpvf Perl_sv_catpvf_nocontext
551 # define sv_setpvf Perl_sv_setpvf_nocontext
552 # define warn Perl_warn_nocontext
553 # define warner Perl_warner_nocontext
554 # define sv_catpvf_mg Perl_sv_catpvf_mg_nocontext
555 # define sv_setpvf_mg Perl_sv_setpvf_mg_nocontext
556 #endif
557
558 #endif /* !defined(PERL_CORE) && !defined(PERL_NOCOMPAT) */
559
560 #if !defined(PERL_IMPLICIT_CONTEXT)
561 /* undefined symbols, point them back at the usual ones */
562 # define Perl_croak_nocontext Perl_croak
563 # define Perl_die_nocontext Perl_die
564 # define Perl_deb_nocontext Perl_deb
565 # define Perl_form_nocontext Perl_form
566 # define Perl_load_module_nocontext Perl_load_module
567 # define Perl_mess_nocontext Perl_mess
568 # define Perl_newSVpvf_nocontext Perl_newSVpvf
569 # define Perl_sv_catpvf_nocontext Perl_sv_catpvf
570 # define Perl_sv_setpvf_nocontext Perl_sv_setpvf
571 # define Perl_warn_nocontext Perl_warn
572 # define Perl_warner_nocontext Perl_warner
573 # define Perl_sv_catpvf_mg_nocontext Perl_sv_catpvf_mg
574 # define Perl_sv_setpvf_mg_nocontext Perl_sv_setpvf_mg
575 #endif
576
577 END
578
579 close(EM) or die "Error closing EM: $!";
580
581 safer_unlink 'embedvar.h';
582 open(EM, '> embedvar.h')
583 or die "Can't create embedvar.h: $!\n";
584 binmode EM;
585
586 print EM do_not_edit ("embedvar.h"), <<'END';
587
588 /* (Doing namespace management portably in C is really gross.) */
589
590 /*
591 The following combinations of MULTIPLICITY, USE_5005THREADS
592 and PERL_IMPLICIT_CONTEXT are supported:
593 1) none
594 2) MULTIPLICITY # supported for compatibility
595 3) MULTIPLICITY && PERL_IMPLICIT_CONTEXT
596 4) USE_5005THREADS && PERL_IMPLICIT_CONTEXT
597 5) MULTIPLICITY && USE_5005THREADS && PERL_IMPLICIT_CONTEXT
598
599 All other combinations of these flags are errors.
600
601 #3, #4, #5, and #6 are supported directly, while #2 is a special
602 case of #3 (supported by redefining vTHX appropriately).
603 */
604
605 #if defined(MULTIPLICITY)
606 /* cases 2, 3 and 5 above */
607
608 # if defined(PERL_IMPLICIT_CONTEXT)
609 # define vTHX aTHX
610 # else
611 # define vTHX PERL_GET_INTERP
612 # endif
613
614 END
615
616 for $sym (sort keys %thread) {
617 print EM multon($sym,'T','vTHX->');
618 }
619
620 print EM <<'END';
621
622 # if defined(USE_5005THREADS)
623 /* case 5 above */
624
625 END
626
627 for $sym (sort keys %intrp) {
628 print EM multon($sym,'I','PERL_GET_INTERP->');
629 }
630
631 print EM <<'END';
632
633 # else /* !USE_5005THREADS */
634 /* cases 2 and 3 above */
635
636 END
637
638 for $sym (sort keys %intrp) {
639 print EM multon($sym,'I','vTHX->');
640 }
641
642 print EM <<'END';
643
644 # endif /* USE_5005THREADS */
645
646 #else /* !MULTIPLICITY */
647
648 /* cases 1 and 4 above */
649
650 END
651
652 for $sym (sort keys %intrp) {
653 print EM multoff($sym,'I');
654 }
655
656 print EM <<'END';
657
658 # if defined(USE_5005THREADS)
659 /* case 4 above */
660
661 END
662
663 for $sym (sort keys %thread) {
664 print EM multon($sym,'T','aTHX->');
665 }
666
667 print EM <<'END';
668
669 # else /* !USE_5005THREADS */
670 /* case 1 above */
671
672 END
673
674 for $sym (sort keys %thread) {
675 print EM multoff($sym,'T');
676 }
677
678 print EM <<'END';
679
680 # endif /* USE_5005THREADS */
681 #endif /* MULTIPLICITY */
682
683 #if defined(PERL_GLOBAL_STRUCT)
684
685 END
686
687 for $sym (sort keys %globvar) {
688 print EM multon($sym,'G','PL_Vars.');
689 }
690
691 print EM <<'END';
692
693 #else /* !PERL_GLOBAL_STRUCT */
694
695 END
696
697 for $sym (sort keys %globvar) {
698 print EM multoff($sym,'G');
699 }
700
701 print EM <<'END';
702
703 #endif /* PERL_GLOBAL_STRUCT */
704
705 #ifdef PERL_POLLUTE /* disabled by default in 5.6.0 */
706
707 END
708
709 for $sym (sort @extvars) {
710 print EM hide($sym,"PL_$sym");
711 }
712
713 print EM <<'END';
714
715 #endif /* PERL_POLLUTE */
716 END
717
718 close(EM) or die "Error closing EM: $!";
719
720 safer_unlink 'perlapi.h';
721 safer_unlink 'perlapi.c';
722 open(CAPI, '> perlapi.c') or die "Can't create perlapi.c: $!\n";
723 binmode CAPI;
724 open(CAPIH, '> perlapi.h') or die "Can't create perlapi.h: $!\n";
725 binmode CAPIH;
726
727 print CAPIH do_not_edit ("perlapi.h"), <<'EOT';
728
729 /* declare accessor functions for Perl variables */
730 #ifndef __perlapi_h__
731 #define __perlapi_h__
732
733 #if defined (MULTIPLICITY)
734
735 START_EXTERN_C
736
737 #undef PERLVAR
738 #undef PERLVARA
739 #undef PERLVARI
740 #undef PERLVARIC
741 #define PERLVAR(v,t) EXTERN_C t* Perl_##v##_ptr(pTHX);
742 #define PERLVARA(v,n,t) typedef t PL_##v##_t[n]; \
743 EXTERN_C PL_##v##_t* Perl_##v##_ptr(pTHX);
744 #define PERLVARI(v,t,i) PERLVAR(v,t)
745 #define PERLVARIC(v,t,i) PERLVAR(v, const t)
746
747 #include "thrdvar.h"
748 #include "intrpvar.h"
749 #include "perlvars.h"
750
751 #undef PERLVAR
752 #undef PERLVARA
753 #undef PERLVARI
754 #undef PERLVARIC
755
756 END_EXTERN_C
757
758 #if defined(PERL_CORE)
759
760 /* accessor functions for Perl variables (provide binary compatibility) */
761
762 /* these need to be mentioned here, or most linkers won't put them in
763 the perl executable */
764
765 #ifndef PERL_NO_FORCE_LINK
766
767 START_EXTERN_C
768
769 #ifndef DOINIT
770 EXT void *PL_force_link_funcs[];
771 #else
772 EXT void *PL_force_link_funcs[] = {
773 #undef PERLVAR
774 #undef PERLVARA
775 #undef PERLVARI
776 #undef PERLVARIC
777 #define PERLVAR(v,t) (void*)Perl_##v##_ptr,
778 #define PERLVARA(v,n,t) PERLVAR(v,t)
779 #define PERLVARI(v,t,i) PERLVAR(v,t)
780 #define PERLVARIC(v,t,i) PERLVAR(v,t)
781
782 #include "thrdvar.h"
783 #include "intrpvar.h"
784 #include "perlvars.h"
785
786 #undef PERLVAR
787 #undef PERLVARA
788 #undef PERLVARI
789 #undef PERLVARIC
790 };
791 #endif /* DOINIT */
792
793 END_EXTERN_C
794
795 #endif /* PERL_NO_FORCE_LINK */
796
797 #else /* !PERL_CORE */
798
799 EOT
800
801 foreach $sym (sort keys %intrp) {
802 print CAPIH bincompat_var('I',$sym);
803 }
804
805 foreach $sym (sort keys %thread) {
806 print CAPIH bincompat_var('T',$sym);
807 }
808
809 foreach $sym (sort keys %globvar) {
810 print CAPIH bincompat_var('G',$sym);
811 }
812
813 print CAPIH <<'EOT';
814
815 #endif /* !PERL_CORE */
816 #endif /* MULTIPLICITY */
817
818 #endif /* __perlapi_h__ */
819
820 EOT
821 close CAPIH or die "Error closing CAPIH: $!";
822
823 print CAPI do_not_edit ("perlapi.c"), <<'EOT';
824
825 #include "EXTERN.h"
826 #include "perl.h"
827 #include "perlapi.h"
828
829 #if defined (MULTIPLICITY)
830
831 /* accessor functions for Perl variables (provides binary compatibility) */
832 START_EXTERN_C
833
834 #undef PERLVAR
835 #undef PERLVARA
836 #undef PERLVARI
837 #undef PERLVARIC
838
839 #define PERLVAR(v,t) t* Perl_##v##_ptr(pTHX) \
840 { return &(aTHX->v); }
841 #define PERLVARA(v,n,t) PL_##v##_t* Perl_##v##_ptr(pTHX) \
842 { return &(aTHX->v); }
843
844 #define PERLVARI(v,t,i) PERLVAR(v,t)
845 #define PERLVARIC(v,t,i) PERLVAR(v, const t)
846
847 #include "thrdvar.h"
848 #include "intrpvar.h"
849
850 #undef PERLVAR
851 #undef PERLVARA
852 #define PERLVAR(v,t) t* Perl_##v##_ptr(pTHX) \
853 { return &(PL_##v); }
854 #define PERLVARA(v,n,t) PL_##v##_t* Perl_##v##_ptr(pTHX) \
855 { return &(PL_##v); }
856 #undef PERLVARIC
857 #define PERLVARIC(v,t,i) const t* Perl_##v##_ptr(pTHX) \
858 { return (const t *)&(PL_##v); }
859 #include "perlvars.h"
860
861 #undef PERLVAR
862 #undef PERLVARA
863 #undef PERLVARI
864 #undef PERLVARIC
865
866 END_EXTERN_C
867
868 #endif /* MULTIPLICITY */
869 EOT
870
871 close(CAPI) or die "Error closing CAPI: $!";
872
873 # functions that take va_list* for implementing vararg functions
874 # NOTE: makedef.pl must be updated if you add symbols to %vfuncs
875 # XXX %vfuncs currently unused
876 my %vfuncs = qw(
877 Perl_croak Perl_vcroak
878 Perl_warn Perl_vwarn
879 Perl_warner Perl_vwarner
880 Perl_die Perl_vdie
881 Perl_form Perl_vform
882 Perl_load_module Perl_vload_module
883 Perl_mess Perl_vmess
884 Perl_deb Perl_vdeb
885 Perl_newSVpvf Perl_vnewSVpvf
886 Perl_sv_setpvf Perl_sv_vsetpvf
887 Perl_sv_setpvf_mg Perl_sv_vsetpvf_mg
888 Perl_sv_catpvf Perl_sv_vcatpvf
889 Perl_sv_catpvf_mg Perl_sv_vcatpvf_mg
890 Perl_dump_indent Perl_dump_vindent
891 Perl_default_protect Perl_vdefault_protect
892 );