This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
MULTICALL *shouldn't* clear savestack
[perl5.git] / regen / embed.pl
CommitLineData
5f05dabc 1#!/usr/bin/perl -w
6294c161
DM
2#
3# Regenerate (overwriting only if changed):
4#
5# embed.h
6# embedvar.h
6294c161
DM
7# perlapi.c
8# perlapi.h
9# proto.h
10#
11# from information stored in
12#
13# embed.fnc
14# intrpvar.h
15# perlvars.h
897d3989 16# regen/opcodes
6294c161 17#
6294c161
DM
18# Accepts the standard regen_lib -q and -v args.
19#
20# This script is normally invoked from regen.pl.
e50aee73 21
916e4025 22require 5.004; # keep this compatible, an old perl is all we may have before
954c1994 23 # we build the new one
5f05dabc 24
88e01c9d
AL
25use strict;
26
36bb303b
NC
27BEGIN {
28 # Get function prototypes
af001346 29 require 'regen/regen_lib.pl';
cdde42af 30 require 'regen/embed_lib.pl';
36bb303b
NC
31}
32
88e01c9d 33my $SPLINT = 0; # Turn true for experimental splint support http://www.splint.org
916e4025 34my $unflagged_pointers;
88e01c9d 35
cea2e8a9 36#
346f75ff 37# See database of global and static function prototypes in embed.fnc
cea2e8a9
GS
38# This is used to generate prototype headers under various configurations,
39# export symbols lists for different platforms, and macros to provide an
40# implicit interpreter context argument.
41#
42
03b6588a
KW
43sub full_name ($$) { # Returns the function name with potentially the
44 # prefixes 'S_' or 'Perl_'
45 my ($func, $flags) = @_;
46
47 return "S_$func" if $flags =~ /[si]/;
48 return "Perl_$func" if $flags =~ /[bp]/;
49 return $func;
50}
51
5f8dc073 52sub open_print_header {
56fd1190 53 my ($file, $quote) = @_;
4373e329 54
5f8dc073
NC
55 return open_new($file, '>',
56 { file => $file, style => '*', by => 'regen/embed.pl',
57 from => ['data in embed.fnc', 'regen/embed.pl',
58 'regen/opcodes', 'intrpvar.h', 'perlvars.h'],
59 final => "\nEdit those files and run 'make regen_headers' to effect changes.\n",
60 copyright => [1993 .. 2009], quote => $quote });
61}
7f1be197 62
5ccbf88e
NC
63my ($embed, $core, $ext, $api) = setup_embed();
64
cea2e8a9 65# generate proto.h
9516dc40 66{
5f8dc073
NC
67 my $pr = open_print_header("proto.h");
68 print $pr "START_EXTERN_C\n";
f8394530 69 my $ret;
9516dc40 70
5ccbf88e 71 foreach (@$embed) {
9516dc40
NC
72 if (@$_ == 1) {
73 print $pr "$_->[0]\n";
74 next;
75 }
76
77 my ($flags,$retval,$plain_func,@args) = @$_;
4373e329
AL
78 my @nonnull;
79 my $has_context = ( $flags !~ /n/ );
88e01c9d
AL
80 my $never_returns = ( $flags =~ /r/ );
81 my $commented_out = ( $flags =~ /m/ );
aa4ca557 82 my $binarycompat = ( $flags =~ /b/ );
88e01c9d
AL
83 my $is_malloc = ( $flags =~ /a/ );
84 my $can_ignore = ( $flags !~ /R/ ) && !$is_malloc;
7918f24d
NC
85 my @names_of_nn;
86 my $func;
88e01c9d 87
9f68b0f7
KW
88 if (! $can_ignore && $retval eq 'void') {
89 warn "It is nonsensical to require the return value of a void function ($plain_func) to be checked";
90 }
82728c33
KW
91
92 my $scope_type_flag_count = 0;
93 $scope_type_flag_count++ if $flags =~ /s/;
94 $scope_type_flag_count++ if $flags =~ /i/;
95 $scope_type_flag_count++ if $flags =~ /p/;
96 warn "$plain_func: i, p, and s flags are all mutually exclusive"
97 if $scope_type_flag_count > 1;
88e01c9d
AL
98 my $splint_flags = "";
99 if ( $SPLINT && !$commented_out ) {
100 $splint_flags .= '/*@noreturn@*/ ' if $never_returns;
101 if ($can_ignore && ($retval ne 'void') && ($retval !~ /\*/)) {
102 $retval .= " /*\@alt void\@*/";
103 }
104 }
105
71556506 106 if ($flags =~ /([si])/) {
98c015b7
DD
107 my $type;
108 if ($never_returns) {
109 $type = $1 eq 's' ? "PERL_STATIC_NO_RET" : "PERL_STATIC_INLINE_NO_RET";
110 }
111 else {
112 $type = $1 eq 's' ? "STATIC" : "PERL_STATIC_INLINE";
113 }
71556506 114 $retval = "$type $splint_flags$retval";
cea2e8a9 115 }
0cb96387 116 else {
718fae11
JD
117 if ($never_returns) {
118 $retval = "PERL_CALLCONV_NO_RET $splint_flags$retval";
119 }
120 else {
121 $retval = "PERL_CALLCONV $splint_flags$retval";
122 }
cea2e8a9 123 }
03b6588a 124 $func = full_name($plain_func, $flags);
f8394530 125 $ret = "$retval\t$func(";
4373e329
AL
126 if ( $has_context ) {
127 $ret .= @args ? "pTHX_ " : "pTHX";
cea2e8a9
GS
128 }
129 if (@args) {
4373e329
AL
130 my $n;
131 for my $arg ( @args ) {
132 ++$n;
7827dc65
AL
133 if ( $arg =~ /\*/ && $arg !~ /\b(NN|NULLOK)\b/ ) {
134 warn "$func: $arg needs NN or NULLOK\n";
7827dc65
AL
135 ++$unflagged_pointers;
136 }
88e01c9d
AL
137 my $nn = ( $arg =~ s/\s*\bNN\b\s+// );
138 push( @nonnull, $n ) if $nn;
139
140 my $nullok = ( $arg =~ s/\s*\bNULLOK\b\s+// ); # strip NULLOK with no effect
c48640ec
AL
141
142 # Make sure each arg has at least a type and a var name.
143 # An arg of "int" is valid C, but want it to be "int foo".
144 my $temp_arg = $arg;
145 $temp_arg =~ s/\*//g;
146 $temp_arg =~ s/\s*\bstruct\b\s*/ /g;
7918f24d
NC
147 if ( ($temp_arg ne "...")
148 && ($temp_arg !~ /\w+\s+(\w+)(?:\[\d+\])?\s*$/) ) {
149 warn "$func: $arg ($n) doesn't have a name\n";
c48640ec 150 }
88e01c9d
AL
151 if ( $SPLINT && $nullok && !$commented_out ) {
152 $arg = '/*@null@*/ ' . $arg;
153 }
aa4ca557 154 if (defined $1 && $nn && !($commented_out && !$binarycompat)) {
7918f24d
NC
155 push @names_of_nn, $1;
156 }
4373e329 157 }
cea2e8a9
GS
158 $ret .= join ", ", @args;
159 }
160 else {
4373e329 161 $ret .= "void" if !$has_context;
cea2e8a9
GS
162 }
163 $ret .= ")";
f54cb97a
AL
164 my @attrs;
165 if ( $flags =~ /r/ ) {
abb2c242 166 push @attrs, "__attribute__noreturn__";
f54cb97a 167 }
a5c26493
RGS
168 if ( $flags =~ /D/ ) {
169 push @attrs, "__attribute__deprecated__";
170 }
88e01c9d 171 if ( $is_malloc ) {
abb2c242 172 push @attrs, "__attribute__malloc__";
f54cb97a 173 }
88e01c9d 174 if ( !$can_ignore ) {
abb2c242 175 push @attrs, "__attribute__warn_unused_result__";
f54cb97a
AL
176 }
177 if ( $flags =~ /P/ ) {
abb2c242 178 push @attrs, "__attribute__pure__";
f54cb97a 179 }
1c846c1f 180 if( $flags =~ /f/ ) {
cdfeb707 181 my $prefix = $has_context ? 'pTHX_' : '';
5d37acd6
DM
182 my ($args, $pat);
183 if ($args[-1] eq '...') {
184 $args = scalar @args;
185 $pat = $args - 1;
186 $args = $prefix . $args;
187 }
188 else {
189 # don't check args, and guess which arg is the pattern
190 # (one of 'fmt', 'pat', 'f'),
191 $args = 0;
192 my @fmts = grep $args[$_] =~ /\b(f|pat|fmt)$/, 0..$#args;
193 if (@fmts != 1) {
194 die "embed.pl: '$plain_func': can't determine pattern arg\n";
195 }
196 $pat = $fmts[0] + 1;
197 }
198 my $macro = grep($_ == $pat, @nonnull)
cdfeb707
RB
199 ? '__attribute__format__'
200 : '__attribute__format__null_ok__';
531b2663
DM
201 if ($plain_func =~ /strftime/) {
202 push @attrs, sprintf "%s(__strftime__,%s1,0)", $macro, $prefix;
203 }
204 else {
5d37acd6
DM
205 push @attrs, sprintf "%s(__printf__,%s%d,%s)", $macro,
206 $prefix, $pat, $args;
531b2663 207 }
894356b3 208 }
f54cb97a
AL
209 if ( @attrs ) {
210 $ret .= "\n";
211 $ret .= join( "\n", map { "\t\t\t$_" } @attrs );
4373e329 212 }
af3c7592 213 $ret .= ";";
88e01c9d 214 $ret = "/* $ret */" if $commented_out;
7918f24d
NC
215 if (@names_of_nn) {
216 $ret .= "\n#define PERL_ARGS_ASSERT_\U$plain_func\E\t\\\n\t"
217 . join '; ', map "assert($_)", @names_of_nn;
218 }
f54cb97a 219 $ret .= @attrs ? "\n\n" : "\n";
9516dc40
NC
220
221 print $pr $ret;
cea2e8a9 222 }
9516dc40 223
897d3989
NC
224 print $pr <<'EOF';
225#ifdef PERL_CORE
226# include "pp_proto.h"
227#endif
228END_EXTERN_C
897d3989 229EOF
9516dc40 230
ce716c52 231 read_only_bottom_close_and_rename($pr);
cea2e8a9
GS
232}
233
7827dc65 234warn "$unflagged_pointers pointer arguments to clean up\n" if $unflagged_pointers;
cea2e8a9 235
adf34b4b
NC
236sub readvars {
237 my ($file, $pre) = @_;
d4cce5f1 238 local (*FILE, $_);
adf34b4b 239 my %seen;
d4cce5f1
NIS
240 open(FILE, "< $file")
241 or die "embed.pl: Can't open $file: $!\n";
242 while (<FILE>) {
243 s/[ \t]*#.*//; # Delete comments.
115ff745 244 if (/PERLVARA?I?C?\($pre,\s*(\w+)/) {
adf34b4b
NC
245 warn "duplicate symbol $1 while processing $file line $.\n"
246 if $seen{$1}++;
d4cce5f1
NIS
247 }
248 }
249 close(FILE);
adf34b4b 250 return sort keys %seen;
d4cce5f1
NIS
251}
252
adf34b4b
NC
253my @intrp = readvars 'intrpvar.h','I';
254my @globvar = readvars 'perlvars.h','G';
d4cce5f1 255
125218eb
NC
256sub hide {
257 my ($from, $to, $indent) = @_;
258 $indent = '' unless defined $indent;
259 my $t = int(length("$indent$from") / 8);
260 "#${indent}define $from" . "\t" x ($t < 3 ? 3 - $t : 1) . "$to\n";
5f05dabc 261}
c6af7a1a 262
d4cce5f1
NIS
263sub multon ($$$) {
264 my ($sym,$pre,$ptr) = @_;
3280af22 265 hide("PL_$sym", "($ptr$pre$sym)");
5f05dabc 266}
54aff467 267
5f8dc073 268my $em = open_print_header('embed.h');
e50aee73 269
5f8dc073 270print $em <<'END';
e50aee73
AD
271/* (Doing namespace management portably in C is really gross.) */
272
d51482e4
JH
273/* By defining PERL_NO_SHORT_NAMES (not done by default) the short forms
274 * (like warn instead of Perl_warn) for the API are not defined.
275 * Not defining the short forms is a good thing for cleaner embedding. */
276
277#ifndef PERL_NO_SHORT_NAMES
820c3be9 278
22c35a8c 279/* Hide global symbols */
5f05dabc 280
e50aee73
AD
281END
282
cea2e8a9
GS
283my @az = ('a'..'z');
284
e8a67806
NC
285sub embed_h {
286 my ($guard, $funcs) = @_;
287 print $em "$guard\n" if $guard;
288
2a4d8072 289 my $lines;
e8a67806
NC
290 foreach (@$funcs) {
291 if (@$_ == 1) {
292 my $cond = $_->[0];
293 # Indent the conditionals if we are wrapped in an #if/#endif pair.
294 $cond =~ s/#(.*)/# $1/ if $guard;
2a4d8072 295 $lines .= "$cond\n";
e8a67806
NC
296 next;
297 }
298 my $ret = "";
299 my ($flags,$retval,$func,@args) = @$_;
af3c7592 300 unless ($flags =~ /[om]/) {
cea2e8a9 301 my $args = scalar @args;
7a5a24f7 302 if ($flags =~ /n/) {
03b6588a 303 $ret = hide($func, full_name($func, $flags));
cea2e8a9 304 }
7a5a24f7 305 elsif ($args and $args[$args-1] =~ /\.\.\./) {
e64ca59f
NC
306 if ($flags =~ /p/) {
307 # we're out of luck for varargs functions under CPP
308 # So we can only do these macros for no implicit context:
309 $ret = "#ifndef PERL_IMPLICIT_CONTEXT\n"
03b6588a 310 . hide($func, full_name($func, $flags)) . "#endif\n";
e64ca59f 311 }
7a5a24f7 312 }
cea2e8a9
GS
313 else {
314 my $alist = join(",", @az[0..$args-1]);
315 $ret = "#define $func($alist)";
316 my $t = int(length($ret) / 8);
317 $ret .= "\t" x ($t < 4 ? 4 - $t : 1);
03b6588a 318 $ret .= full_name($func, $flags) . "(aTHX";
cea2e8a9
GS
319 $ret .= "_ " if $alist;
320 $ret .= $alist . ")\n";
321 }
322 }
2a4d8072 323 $lines .= $ret;
cea2e8a9 324 }
2a4d8072
NC
325 # Prune empty #if/#endif pairs.
326 while ($lines =~ s/#\s*if[^\n]+\n#\s*endif\n//) {
327 }
b2e549c0
NC
328 # Merge adjacent blocks.
329 while ($lines =~ s/(#ifndef PERL_IMPLICIT_CONTEXT
330[^\n]+
331)#endif
332#ifndef PERL_IMPLICIT_CONTEXT
333/$1/) {
334 }
335
2a4d8072 336 print $em $lines;
e8a67806 337 print $em "#endif\n" if $guard;
da4ddda1
NC
338}
339
5ccbf88e
NC
340embed_h('', $api);
341embed_h('#if defined(PERL_CORE) || defined(PERL_EXT)', $ext);
342embed_h('#ifdef PERL_CORE', $core);
e8a67806 343
424a4936 344print $em <<'END';
e50aee73 345
d51482e4 346#endif /* #ifndef PERL_NO_SHORT_NAMES */
35209cc8 347
cea2e8a9
GS
348/* Compatibility stubs. Compile extensions with -DPERL_NOCOMPAT to
349 disable them.
350 */
351
538feb02 352#if !defined(PERL_CORE)
5bc28da9 353# define sv_setptrobj(rv,ptr,name) sv_setref_iv(rv,name,PTR2IV(ptr))
a0714e2c 354# define sv_setptrref(rv,ptr) sv_setref_iv(rv,NULL,PTR2IV(ptr))
538feb02 355#endif
cea2e8a9 356
08e5223a 357#if !defined(PERL_CORE) && !defined(PERL_NOCOMPAT)
cea2e8a9
GS
358
359/* Compatibility for various misnamed functions. All functions
360 in the API that begin with "perl_" (not "Perl_") take an explicit
361 interpreter context pointer.
362 The following are not like that, but since they had a "perl_"
363 prefix in previous versions, we provide compatibility macros.
364 */
65cec589 365# define perl_atexit(a,b) call_atexit(a,b)
7b53c8ee
NC
366END
367
3a54c8e7
NC
368foreach (@$embed) {
369 my ($flags, $retval, $func, @args) = @$_;
370 next unless $func;
371 next unless $flags =~ /O/;
7b53c8ee
NC
372
373 my $alist = join ",", @az[0..$#args];
374 my $ret = "# define perl_$func($alist)";
375 my $t = (length $ret) >> 3;
376 $ret .= "\t" x ($t < 5 ? 5 - $t : 1);
3a54c8e7
NC
377 print $em "$ret$func($alist)\n";
378}
7b53c8ee 379
eacd26c2
NC
380my @nocontext;
381{
382 my (%has_va, %has_nocontext);
5ccbf88e 383 foreach (@$embed) {
eacd26c2
NC
384 next unless @$_ > 1;
385 ++$has_va{$_->[2]} if $_->[-1] =~ /\.\.\./;
386 ++$has_nocontext{$1} if $_->[2] =~ /(.*)_nocontext/;
387 }
388
389 @nocontext = sort grep {
390 $has_nocontext{$_}
391 && !/printf/ # Not clear to me why these are skipped but they are.
392 } keys %has_va;
393}
394
7b53c8ee 395print $em <<'END';
cea2e8a9
GS
396
397/* varargs functions can't be handled with CPP macros. :-(
398 This provides a set of compatibility functions that don't take
399 an extra argument but grab the context pointer using the macro
400 dTHX.
401 */
d51482e4 402#if defined(PERL_IMPLICIT_CONTEXT) && !defined(PERL_NO_SHORT_NAMES)
125218eb
NC
403END
404
eacd26c2 405foreach (@nocontext) {
125218eb
NC
406 print $em hide($_, "Perl_${_}_nocontext", " ");
407}
408
409print $em <<'END';
cea2e8a9
GS
410#endif
411
412#endif /* !defined(PERL_CORE) && !defined(PERL_NOCOMPAT) */
413
414#if !defined(PERL_IMPLICIT_CONTEXT)
415/* undefined symbols, point them back at the usual ones */
125218eb
NC
416END
417
eacd26c2 418foreach (@nocontext) {
125218eb
NC
419 print $em hide("Perl_${_}_nocontext", "Perl_$_", " ");
420}
421
422print $em <<'END';
cea2e8a9 423#endif
d4cce5f1
NIS
424END
425
ce716c52 426read_only_bottom_close_and_rename($em);
d4cce5f1 427
5f8dc073 428$em = open_print_header('embedvar.h');
d4cce5f1 429
5f8dc073 430print $em <<'END';
d4cce5f1
NIS
431/* (Doing namespace management portably in C is really gross.) */
432
54aff467 433/*
3db8f154
MB
434 The following combinations of MULTIPLICITY and PERL_IMPLICIT_CONTEXT
435 are supported:
54aff467
GS
436 1) none
437 2) MULTIPLICITY # supported for compatibility
438 3) MULTIPLICITY && PERL_IMPLICIT_CONTEXT
54aff467
GS
439
440 All other combinations of these flags are errors.
441
3db8f154 442 only #3 is supported directly, while #2 is a special
54aff467
GS
443 case of #3 (supported by redefining vTHX appropriately).
444*/
cea2e8a9 445
54aff467 446#if defined(MULTIPLICITY)
3db8f154 447/* cases 2 and 3 above */
cea2e8a9 448
54aff467
GS
449# if defined(PERL_IMPLICIT_CONTEXT)
450# define vTHX aTHX
451# else
452# define vTHX PERL_GET_INTERP
453# endif
cea2e8a9 454
e50aee73
AD
455END
456
adf34b4b
NC
457my $sym;
458
459for $sym (@intrp) {
1a904fc8
FC
460 if ($sym eq 'sawampersand') {
461 print $em "#ifndef PL_sawampersand\n";
462 }
424a4936 463 print $em multon($sym,'I','vTHX->');
1a904fc8
FC
464 if ($sym eq 'sawampersand') {
465 print $em "#endif\n";
466 }
d4cce5f1
NIS
467}
468
424a4936 469print $em <<'END';
d4cce5f1 470
54aff467 471#endif /* MULTIPLICITY */
d4cce5f1 472
54aff467 473#if defined(PERL_GLOBAL_STRUCT)
22239a37
NIS
474
475END
476
adf34b4b 477for $sym (@globvar) {
0447859b 478 print $em "#ifdef OS2\n" if $sym eq 'sh_path';
424a4936
NC
479 print $em multon($sym, 'G','my_vars->');
480 print $em multon("G$sym",'', 'my_vars->');
0447859b 481 print $em "#endif\n" if $sym eq 'sh_path';
22239a37
NIS
482}
483
424a4936 484print $em <<'END';
22239a37 485
22239a37 486#endif /* PERL_GLOBAL_STRUCT */
84fee439
NIS
487END
488
ce716c52 489read_only_bottom_close_and_rename($em);
c6af7a1a 490
5f8dc073 491my $capih = open_print_header('perlapi.h');
51371543 492
5f8dc073 493print $capih <<'EOT';
51371543 494/* declare accessor functions for Perl variables */
6f4183fe
GS
495#ifndef __perlapi_h__
496#define __perlapi_h__
51371543 497
87b9e160 498#if defined (MULTIPLICITY) && defined (PERL_GLOBAL_STRUCT)
c5be433b 499
51371543
GS
500START_EXTERN_C
501
502#undef PERLVAR
503#undef PERLVARA
504#undef PERLVARI
505#undef PERLVARIC
115ff745
NC
506#define PERLVAR(p,v,t) EXTERN_C t* Perl_##p##v##_ptr(pTHX);
507#define PERLVARA(p,v,n,t) typedef t PL_##v##_t[n]; \
508 EXTERN_C PL_##v##_t* Perl_##p##v##_ptr(pTHX);
509#define PERLVARI(p,v,t,i) PERLVAR(p,v,t)
510#define PERLVARIC(p,v,t,i) PERLVAR(p,v, const t)
51371543 511
51371543
GS
512#include "perlvars.h"
513
514#undef PERLVAR
515#undef PERLVARA
516#undef PERLVARI
517#undef PERLVARIC
27da23d5 518
51371543
GS
519END_EXTERN_C
520
682fc664 521#if defined(PERL_CORE)
6f4183fe 522
87b9e160 523/* accessor functions for Perl "global" variables */
682fc664
GS
524
525/* these need to be mentioned here, or most linkers won't put them in
526 the perl executable */
527
528#ifndef PERL_NO_FORCE_LINK
529
530START_EXTERN_C
531
532#ifndef DOINIT
27da23d5 533EXTCONST void * const PL_force_link_funcs[];
682fc664 534#else
27da23d5 535EXTCONST void * const PL_force_link_funcs[] = {
682fc664
GS
536#undef PERLVAR
537#undef PERLVARA
538#undef PERLVARI
539#undef PERLVARIC
115ff745
NC
540#define PERLVAR(p,v,t) (void*)Perl_##p##v##_ptr,
541#define PERLVARA(p,v,n,t) PERLVAR(p,v,t)
542#define PERLVARI(p,v,t,i) PERLVAR(p,v,t)
543#define PERLVARIC(p,v,t,i) PERLVAR(p,v,t)
682fc664 544
3c0f78ca
JH
545/* In Tru64 (__DEC && __osf__) the cc option -std1 causes that one
546 * cannot cast between void pointers and function pointers without
547 * info level warnings. The PL_force_link_funcs[] would cause a few
548 * hundred of those warnings. In code one can circumnavigate this by using
549 * unions that overlay the different pointers, but in declarations one
550 * cannot use this trick. Therefore we just disable the warning here
551 * for the duration of the PL_force_link_funcs[] declaration. */
552
553#if defined(__DECC) && defined(__osf__)
554#pragma message save
555#pragma message disable (nonstandcast)
556#endif
557
682fc664
GS
558#include "perlvars.h"
559
3c0f78ca
JH
560#if defined(__DECC) && defined(__osf__)
561#pragma message restore
562#endif
563
682fc664
GS
564#undef PERLVAR
565#undef PERLVARA
566#undef PERLVARI
567#undef PERLVARIC
568};
569#endif /* DOINIT */
570
acfe0abc 571END_EXTERN_C
682fc664
GS
572
573#endif /* PERL_NO_FORCE_LINK */
574
575#else /* !PERL_CORE */
51371543
GS
576
577EOT
578
adf34b4b 579foreach $sym (@globvar) {
5f9c6535
NC
580 print $capih
581 "#undef PL_$sym\n" . hide("PL_$sym", "(*Perl_G${sym}_ptr(NULL))");
6f4183fe
GS
582}
583
424a4936 584print $capih <<'EOT';
6f4183fe
GS
585
586#endif /* !PERL_CORE */
87b9e160 587#endif /* MULTIPLICITY && PERL_GLOBAL_STRUCT */
6f4183fe
GS
588
589#endif /* __perlapi_h__ */
6f4183fe 590EOT
ce716c52
NC
591
592read_only_bottom_close_and_rename($capih);
51371543 593
5f8dc073 594my $capi = open_print_header('perlapi.c', <<'EOQ');
56fd1190 595 *
892eaa71
NC
596 *
597 * Up to the threshold of the door there mounted a flight of twenty-seven
598 * broad stairs, hewn by some unknown art of the same black stone. This
599 * was the only entrance to the tower; ...
600 *
601 * [p.577 of _The Lord of the Rings_, III/x: "The Voice of Saruman"]
602 *
603 */
56fd1190 604EOQ
892eaa71 605
5f8dc073 606print $capi <<'EOT';
51371543
GS
607#include "EXTERN.h"
608#include "perl.h"
609#include "perlapi.h"
610
87b9e160 611#if defined (MULTIPLICITY) && defined (PERL_GLOBAL_STRUCT)
51371543 612
87b9e160 613/* accessor functions for Perl "global" variables */
51371543
GS
614START_EXTERN_C
615
51371543 616#undef PERLVARI
115ff745 617#define PERLVARI(p,v,t,i) PERLVAR(p,v,t)
c5be433b
GS
618
619#undef PERLVAR
620#undef PERLVARA
115ff745 621#define PERLVAR(p,v,t) t* Perl_##p##v##_ptr(pTHX) \
96a5add6 622 { dVAR; PERL_UNUSED_CONTEXT; return &(PL_##v); }
115ff745 623#define PERLVARA(p,v,n,t) PL_##v##_t* Perl_##p##v##_ptr(pTHX) \
96a5add6 624 { dVAR; PERL_UNUSED_CONTEXT; return &(PL_##v); }
34f7a5fe 625#undef PERLVARIC
115ff745
NC
626#define PERLVARIC(p,v,t,i) \
627 const t* Perl_##p##v##_ptr(pTHX) \
96a5add6 628 { PERL_UNUSED_CONTEXT; return (const t *)&(PL_##v); }
51371543
GS
629#include "perlvars.h"
630
631#undef PERLVAR
632#undef PERLVARA
633#undef PERLVARI
634#undef PERLVARIC
27da23d5 635
acfe0abc 636END_EXTERN_C
6f4183fe 637
87b9e160 638#endif /* MULTIPLICITY && PERL_GLOBAL_STRUCT */
51371543
GS
639EOT
640
ce716c52 641read_only_bottom_close_and_rename($capi);
acfe0abc 642
1b6737cc 643# ex: set ts=8 sts=4 sw=4 noet: