This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Update File-Temp to CPAN version 0.2302
[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
RB
181 my $prefix = $has_context ? 'pTHX_' : '';
182 my $args = scalar @args;
183 my $pat = $args - 1;
184 my $macro = @nonnull && $nonnull[-1] == $pat
185 ? '__attribute__format__'
186 : '__attribute__format__null_ok__';
187 push @attrs, sprintf "%s(__printf__,%s%d,%s%d)", $macro,
188 $prefix, $pat, $prefix, $args;
894356b3 189 }
4373e329 190 if ( @nonnull ) {
3d42dc86 191 my @pos = map { $has_context ? "pTHX_$_" : $_ } @nonnull;
abb2c242 192 push @attrs, map { sprintf( "__attribute__nonnull__(%s)", $_ ) } @pos;
f54cb97a
AL
193 }
194 if ( @attrs ) {
195 $ret .= "\n";
196 $ret .= join( "\n", map { "\t\t\t$_" } @attrs );
4373e329 197 }
af3c7592 198 $ret .= ";";
88e01c9d 199 $ret = "/* $ret */" if $commented_out;
7918f24d
NC
200 if (@names_of_nn) {
201 $ret .= "\n#define PERL_ARGS_ASSERT_\U$plain_func\E\t\\\n\t"
202 . join '; ', map "assert($_)", @names_of_nn;
203 }
f54cb97a 204 $ret .= @attrs ? "\n\n" : "\n";
9516dc40
NC
205
206 print $pr $ret;
cea2e8a9 207 }
9516dc40 208
897d3989
NC
209 print $pr <<'EOF';
210#ifdef PERL_CORE
211# include "pp_proto.h"
212#endif
213END_EXTERN_C
897d3989 214EOF
9516dc40 215
ce716c52 216 read_only_bottom_close_and_rename($pr);
cea2e8a9
GS
217}
218
7827dc65 219warn "$unflagged_pointers pointer arguments to clean up\n" if $unflagged_pointers;
cea2e8a9 220
adf34b4b
NC
221sub readvars {
222 my ($file, $pre) = @_;
d4cce5f1 223 local (*FILE, $_);
adf34b4b 224 my %seen;
d4cce5f1
NIS
225 open(FILE, "< $file")
226 or die "embed.pl: Can't open $file: $!\n";
227 while (<FILE>) {
228 s/[ \t]*#.*//; # Delete comments.
115ff745 229 if (/PERLVARA?I?C?\($pre,\s*(\w+)/) {
adf34b4b
NC
230 warn "duplicate symbol $1 while processing $file line $.\n"
231 if $seen{$1}++;
d4cce5f1
NIS
232 }
233 }
234 close(FILE);
adf34b4b 235 return sort keys %seen;
d4cce5f1
NIS
236}
237
adf34b4b
NC
238my @intrp = readvars 'intrpvar.h','I';
239my @globvar = readvars 'perlvars.h','G';
d4cce5f1 240
125218eb
NC
241sub hide {
242 my ($from, $to, $indent) = @_;
243 $indent = '' unless defined $indent;
244 my $t = int(length("$indent$from") / 8);
245 "#${indent}define $from" . "\t" x ($t < 3 ? 3 - $t : 1) . "$to\n";
5f05dabc 246}
c6af7a1a 247
d4cce5f1
NIS
248sub multon ($$$) {
249 my ($sym,$pre,$ptr) = @_;
3280af22 250 hide("PL_$sym", "($ptr$pre$sym)");
5f05dabc 251}
54aff467 252
5f8dc073 253my $em = open_print_header('embed.h');
e50aee73 254
5f8dc073 255print $em <<'END';
e50aee73
AD
256/* (Doing namespace management portably in C is really gross.) */
257
d51482e4
JH
258/* By defining PERL_NO_SHORT_NAMES (not done by default) the short forms
259 * (like warn instead of Perl_warn) for the API are not defined.
260 * Not defining the short forms is a good thing for cleaner embedding. */
261
262#ifndef PERL_NO_SHORT_NAMES
820c3be9 263
22c35a8c 264/* Hide global symbols */
5f05dabc 265
e50aee73
AD
266END
267
cea2e8a9
GS
268my @az = ('a'..'z');
269
e8a67806
NC
270sub embed_h {
271 my ($guard, $funcs) = @_;
272 print $em "$guard\n" if $guard;
273
2a4d8072 274 my $lines;
e8a67806
NC
275 foreach (@$funcs) {
276 if (@$_ == 1) {
277 my $cond = $_->[0];
278 # Indent the conditionals if we are wrapped in an #if/#endif pair.
279 $cond =~ s/#(.*)/# $1/ if $guard;
2a4d8072 280 $lines .= "$cond\n";
e8a67806
NC
281 next;
282 }
283 my $ret = "";
284 my ($flags,$retval,$func,@args) = @$_;
af3c7592 285 unless ($flags =~ /[om]/) {
cea2e8a9 286 my $args = scalar @args;
7a5a24f7 287 if ($flags =~ /n/) {
03b6588a 288 $ret = hide($func, full_name($func, $flags));
cea2e8a9 289 }
7a5a24f7 290 elsif ($args and $args[$args-1] =~ /\.\.\./) {
e64ca59f
NC
291 if ($flags =~ /p/) {
292 # we're out of luck for varargs functions under CPP
293 # So we can only do these macros for no implicit context:
294 $ret = "#ifndef PERL_IMPLICIT_CONTEXT\n"
03b6588a 295 . hide($func, full_name($func, $flags)) . "#endif\n";
e64ca59f 296 }
7a5a24f7 297 }
cea2e8a9
GS
298 else {
299 my $alist = join(",", @az[0..$args-1]);
300 $ret = "#define $func($alist)";
301 my $t = int(length($ret) / 8);
302 $ret .= "\t" x ($t < 4 ? 4 - $t : 1);
03b6588a 303 $ret .= full_name($func, $flags) . "(aTHX";
cea2e8a9
GS
304 $ret .= "_ " if $alist;
305 $ret .= $alist . ")\n";
306 }
307 }
2a4d8072 308 $lines .= $ret;
cea2e8a9 309 }
2a4d8072
NC
310 # Prune empty #if/#endif pairs.
311 while ($lines =~ s/#\s*if[^\n]+\n#\s*endif\n//) {
312 }
b2e549c0
NC
313 # Merge adjacent blocks.
314 while ($lines =~ s/(#ifndef PERL_IMPLICIT_CONTEXT
315[^\n]+
316)#endif
317#ifndef PERL_IMPLICIT_CONTEXT
318/$1/) {
319 }
320
2a4d8072 321 print $em $lines;
e8a67806 322 print $em "#endif\n" if $guard;
da4ddda1
NC
323}
324
5ccbf88e
NC
325embed_h('', $api);
326embed_h('#if defined(PERL_CORE) || defined(PERL_EXT)', $ext);
327embed_h('#ifdef PERL_CORE', $core);
e8a67806 328
424a4936 329print $em <<'END';
e50aee73 330
d51482e4 331#endif /* #ifndef PERL_NO_SHORT_NAMES */
35209cc8 332
cea2e8a9
GS
333/* Compatibility stubs. Compile extensions with -DPERL_NOCOMPAT to
334 disable them.
335 */
336
538feb02 337#if !defined(PERL_CORE)
5bc28da9 338# define sv_setptrobj(rv,ptr,name) sv_setref_iv(rv,name,PTR2IV(ptr))
a0714e2c 339# define sv_setptrref(rv,ptr) sv_setref_iv(rv,NULL,PTR2IV(ptr))
538feb02 340#endif
cea2e8a9 341
08e5223a 342#if !defined(PERL_CORE) && !defined(PERL_NOCOMPAT)
cea2e8a9
GS
343
344/* Compatibility for various misnamed functions. All functions
345 in the API that begin with "perl_" (not "Perl_") take an explicit
346 interpreter context pointer.
347 The following are not like that, but since they had a "perl_"
348 prefix in previous versions, we provide compatibility macros.
349 */
65cec589 350# define perl_atexit(a,b) call_atexit(a,b)
7b53c8ee
NC
351END
352
3a54c8e7
NC
353foreach (@$embed) {
354 my ($flags, $retval, $func, @args) = @$_;
355 next unless $func;
356 next unless $flags =~ /O/;
7b53c8ee
NC
357
358 my $alist = join ",", @az[0..$#args];
359 my $ret = "# define perl_$func($alist)";
360 my $t = (length $ret) >> 3;
361 $ret .= "\t" x ($t < 5 ? 5 - $t : 1);
3a54c8e7
NC
362 print $em "$ret$func($alist)\n";
363}
7b53c8ee 364
eacd26c2
NC
365my @nocontext;
366{
367 my (%has_va, %has_nocontext);
5ccbf88e 368 foreach (@$embed) {
eacd26c2
NC
369 next unless @$_ > 1;
370 ++$has_va{$_->[2]} if $_->[-1] =~ /\.\.\./;
371 ++$has_nocontext{$1} if $_->[2] =~ /(.*)_nocontext/;
372 }
373
374 @nocontext = sort grep {
375 $has_nocontext{$_}
376 && !/printf/ # Not clear to me why these are skipped but they are.
377 } keys %has_va;
378}
379
7b53c8ee 380print $em <<'END';
cea2e8a9
GS
381
382/* varargs functions can't be handled with CPP macros. :-(
383 This provides a set of compatibility functions that don't take
384 an extra argument but grab the context pointer using the macro
385 dTHX.
386 */
d51482e4 387#if defined(PERL_IMPLICIT_CONTEXT) && !defined(PERL_NO_SHORT_NAMES)
125218eb
NC
388END
389
eacd26c2 390foreach (@nocontext) {
125218eb
NC
391 print $em hide($_, "Perl_${_}_nocontext", " ");
392}
393
394print $em <<'END';
cea2e8a9
GS
395#endif
396
397#endif /* !defined(PERL_CORE) && !defined(PERL_NOCOMPAT) */
398
399#if !defined(PERL_IMPLICIT_CONTEXT)
400/* undefined symbols, point them back at the usual ones */
125218eb
NC
401END
402
eacd26c2 403foreach (@nocontext) {
125218eb
NC
404 print $em hide("Perl_${_}_nocontext", "Perl_$_", " ");
405}
406
407print $em <<'END';
cea2e8a9 408#endif
d4cce5f1
NIS
409END
410
ce716c52 411read_only_bottom_close_and_rename($em);
d4cce5f1 412
5f8dc073 413$em = open_print_header('embedvar.h');
d4cce5f1 414
5f8dc073 415print $em <<'END';
d4cce5f1
NIS
416/* (Doing namespace management portably in C is really gross.) */
417
54aff467 418/*
3db8f154
MB
419 The following combinations of MULTIPLICITY and PERL_IMPLICIT_CONTEXT
420 are supported:
54aff467
GS
421 1) none
422 2) MULTIPLICITY # supported for compatibility
423 3) MULTIPLICITY && PERL_IMPLICIT_CONTEXT
54aff467
GS
424
425 All other combinations of these flags are errors.
426
3db8f154 427 only #3 is supported directly, while #2 is a special
54aff467
GS
428 case of #3 (supported by redefining vTHX appropriately).
429*/
cea2e8a9 430
54aff467 431#if defined(MULTIPLICITY)
3db8f154 432/* cases 2 and 3 above */
cea2e8a9 433
54aff467
GS
434# if defined(PERL_IMPLICIT_CONTEXT)
435# define vTHX aTHX
436# else
437# define vTHX PERL_GET_INTERP
438# endif
cea2e8a9 439
e50aee73
AD
440END
441
adf34b4b
NC
442my $sym;
443
444for $sym (@intrp) {
1a904fc8
FC
445 if ($sym eq 'sawampersand') {
446 print $em "#ifndef PL_sawampersand\n";
447 }
424a4936 448 print $em multon($sym,'I','vTHX->');
1a904fc8
FC
449 if ($sym eq 'sawampersand') {
450 print $em "#endif\n";
451 }
d4cce5f1
NIS
452}
453
424a4936 454print $em <<'END';
d4cce5f1 455
54aff467 456#endif /* MULTIPLICITY */
d4cce5f1 457
54aff467 458#if defined(PERL_GLOBAL_STRUCT)
22239a37
NIS
459
460END
461
adf34b4b 462for $sym (@globvar) {
0447859b 463 print $em "#ifdef OS2\n" if $sym eq 'sh_path';
424a4936
NC
464 print $em multon($sym, 'G','my_vars->');
465 print $em multon("G$sym",'', 'my_vars->');
0447859b 466 print $em "#endif\n" if $sym eq 'sh_path';
22239a37
NIS
467}
468
424a4936 469print $em <<'END';
22239a37 470
22239a37 471#endif /* PERL_GLOBAL_STRUCT */
84fee439
NIS
472END
473
ce716c52 474read_only_bottom_close_and_rename($em);
c6af7a1a 475
5f8dc073 476my $capih = open_print_header('perlapi.h');
51371543 477
5f8dc073 478print $capih <<'EOT';
51371543 479/* declare accessor functions for Perl variables */
6f4183fe
GS
480#ifndef __perlapi_h__
481#define __perlapi_h__
51371543 482
87b9e160 483#if defined (MULTIPLICITY) && defined (PERL_GLOBAL_STRUCT)
c5be433b 484
51371543
GS
485START_EXTERN_C
486
487#undef PERLVAR
488#undef PERLVARA
489#undef PERLVARI
490#undef PERLVARIC
115ff745
NC
491#define PERLVAR(p,v,t) EXTERN_C t* Perl_##p##v##_ptr(pTHX);
492#define PERLVARA(p,v,n,t) typedef t PL_##v##_t[n]; \
493 EXTERN_C PL_##v##_t* Perl_##p##v##_ptr(pTHX);
494#define PERLVARI(p,v,t,i) PERLVAR(p,v,t)
495#define PERLVARIC(p,v,t,i) PERLVAR(p,v, const t)
51371543 496
51371543
GS
497#include "perlvars.h"
498
499#undef PERLVAR
500#undef PERLVARA
501#undef PERLVARI
502#undef PERLVARIC
27da23d5 503
51371543
GS
504END_EXTERN_C
505
682fc664 506#if defined(PERL_CORE)
6f4183fe 507
87b9e160 508/* accessor functions for Perl "global" variables */
682fc664
GS
509
510/* these need to be mentioned here, or most linkers won't put them in
511 the perl executable */
512
513#ifndef PERL_NO_FORCE_LINK
514
515START_EXTERN_C
516
517#ifndef DOINIT
27da23d5 518EXTCONST void * const PL_force_link_funcs[];
682fc664 519#else
27da23d5 520EXTCONST void * const PL_force_link_funcs[] = {
682fc664
GS
521#undef PERLVAR
522#undef PERLVARA
523#undef PERLVARI
524#undef PERLVARIC
115ff745
NC
525#define PERLVAR(p,v,t) (void*)Perl_##p##v##_ptr,
526#define PERLVARA(p,v,n,t) PERLVAR(p,v,t)
527#define PERLVARI(p,v,t,i) PERLVAR(p,v,t)
528#define PERLVARIC(p,v,t,i) PERLVAR(p,v,t)
682fc664 529
3c0f78ca
JH
530/* In Tru64 (__DEC && __osf__) the cc option -std1 causes that one
531 * cannot cast between void pointers and function pointers without
532 * info level warnings. The PL_force_link_funcs[] would cause a few
533 * hundred of those warnings. In code one can circumnavigate this by using
534 * unions that overlay the different pointers, but in declarations one
535 * cannot use this trick. Therefore we just disable the warning here
536 * for the duration of the PL_force_link_funcs[] declaration. */
537
538#if defined(__DECC) && defined(__osf__)
539#pragma message save
540#pragma message disable (nonstandcast)
541#endif
542
682fc664
GS
543#include "perlvars.h"
544
3c0f78ca
JH
545#if defined(__DECC) && defined(__osf__)
546#pragma message restore
547#endif
548
682fc664
GS
549#undef PERLVAR
550#undef PERLVARA
551#undef PERLVARI
552#undef PERLVARIC
553};
554#endif /* DOINIT */
555
acfe0abc 556END_EXTERN_C
682fc664
GS
557
558#endif /* PERL_NO_FORCE_LINK */
559
560#else /* !PERL_CORE */
51371543
GS
561
562EOT
563
adf34b4b 564foreach $sym (@globvar) {
5f9c6535
NC
565 print $capih
566 "#undef PL_$sym\n" . hide("PL_$sym", "(*Perl_G${sym}_ptr(NULL))");
6f4183fe
GS
567}
568
424a4936 569print $capih <<'EOT';
6f4183fe
GS
570
571#endif /* !PERL_CORE */
87b9e160 572#endif /* MULTIPLICITY && PERL_GLOBAL_STRUCT */
6f4183fe
GS
573
574#endif /* __perlapi_h__ */
6f4183fe 575EOT
ce716c52
NC
576
577read_only_bottom_close_and_rename($capih);
51371543 578
5f8dc073 579my $capi = open_print_header('perlapi.c', <<'EOQ');
56fd1190 580 *
892eaa71
NC
581 *
582 * Up to the threshold of the door there mounted a flight of twenty-seven
583 * broad stairs, hewn by some unknown art of the same black stone. This
584 * was the only entrance to the tower; ...
585 *
586 * [p.577 of _The Lord of the Rings_, III/x: "The Voice of Saruman"]
587 *
588 */
56fd1190 589EOQ
892eaa71 590
5f8dc073 591print $capi <<'EOT';
51371543
GS
592#include "EXTERN.h"
593#include "perl.h"
594#include "perlapi.h"
595
87b9e160 596#if defined (MULTIPLICITY) && defined (PERL_GLOBAL_STRUCT)
51371543 597
87b9e160 598/* accessor functions for Perl "global" variables */
51371543
GS
599START_EXTERN_C
600
51371543 601#undef PERLVARI
115ff745 602#define PERLVARI(p,v,t,i) PERLVAR(p,v,t)
c5be433b
GS
603
604#undef PERLVAR
605#undef PERLVARA
115ff745 606#define PERLVAR(p,v,t) t* Perl_##p##v##_ptr(pTHX) \
96a5add6 607 { dVAR; PERL_UNUSED_CONTEXT; return &(PL_##v); }
115ff745 608#define PERLVARA(p,v,n,t) PL_##v##_t* Perl_##p##v##_ptr(pTHX) \
96a5add6 609 { dVAR; PERL_UNUSED_CONTEXT; return &(PL_##v); }
34f7a5fe 610#undef PERLVARIC
115ff745
NC
611#define PERLVARIC(p,v,t,i) \
612 const t* Perl_##p##v##_ptr(pTHX) \
96a5add6 613 { PERL_UNUSED_CONTEXT; return (const t *)&(PL_##v); }
51371543
GS
614#include "perlvars.h"
615
616#undef PERLVAR
617#undef PERLVARA
618#undef PERLVARI
619#undef PERLVARIC
27da23d5 620
acfe0abc 621END_EXTERN_C
6f4183fe 622
87b9e160 623#endif /* MULTIPLICITY && PERL_GLOBAL_STRUCT */
51371543
GS
624EOT
625
ce716c52 626read_only_bottom_close_and_rename($capi);
acfe0abc 627
1b6737cc 628# ex: set ts=8 sts=4 sw=4 noet: