This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Fix assertion triggered by 13be902ce ([perl #77362] glob-to-lv assign)
[perl5.git] / perlvars.h
... / ...
CommitLineData
1/* perlvars.h
2 *
3 * Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
4 * by Larry Wall and others
5 *
6 * You may distribute under the terms of either the GNU General Public
7 * License or the Artistic License, as specified in the README file.
8 *
9 */
10
11/*
12=head1 Global Variables
13*/
14
15/* Don't forget to re-run embed.pl to propagate changes! */
16
17/* This file describes the "global" variables used by perl
18 * This used to be in perl.h directly but we want to abstract out into
19 * distinct files which are per-thread, per-interpreter or really global,
20 * and how they're initialized.
21 *
22 * The 'G' prefix is only needed for vars that need appropriate #defines
23 * generated in embed*.h. Such symbols are also used to generate
24 * the appropriate export list for win32. */
25
26/* global state */
27PERLVAR(Gcurinterp, PerlInterpreter *)
28 /* currently running interpreter
29 * (initial parent interpreter under
30 * useithreads) */
31#if defined(USE_ITHREADS)
32PERLVAR(Gthr_key, perl_key) /* key to retrieve per-thread struct */
33#endif
34
35/* constants (these are not literals to facilitate pointer comparisons)
36 * (PERLVARISC really does create variables, despite its looks) */
37PERLVARISC(GYes, "1")
38PERLVARISC(GNo, "")
39PERLVARISC(Ghexdigit, "0123456789abcdef0123456789ABCDEF")
40PERLVARISC(Gpatleave, "\\.^$@dDwWsSbB+*?|()-nrtfeaxc0123456789[{]}")
41
42/* XXX does anyone even use this? */
43PERLVARI(Gdo_undump, bool, FALSE) /* -u or dump seen? */
44
45#if defined(MYMALLOC) && defined(USE_ITHREADS)
46PERLVAR(Gmalloc_mutex, perl_mutex) /* Mutex for malloc */
47#endif
48
49#if defined(USE_ITHREADS)
50PERLVAR(Gop_mutex, perl_mutex) /* Mutex for op refcounting */
51#endif
52
53#ifdef USE_ITHREADS
54PERLVAR(Gdollarzero_mutex, perl_mutex) /* Modifying $0 */
55#endif
56
57
58/* This is constant on most architectures, a global on OS/2 */
59#ifdef OS2
60# define PERL___C
61#else
62# define PERL___C const
63#endif
64PERLVARI(Gsh_path, PERL___C char *, SH_PATH) /* full path of shell */
65#undef PERL___C
66
67#ifndef PERL_MICRO
68/* If Perl has to ignore SIGPFE, this is its saved state.
69 * See perl.h macros PERL_FPU_INIT and PERL_FPU_{PRE,POST}_EXEC. */
70PERLVAR(Gsigfpe_saved, Sighandler_t)
71#endif
72
73/* Restricted hashes placeholder value.
74 * The contents are never used, only the address. */
75PERLVAR(Gsv_placeholder, SV)
76
77#ifndef PERL_MICRO
78PERLVARI(Gcsighandlerp, Sighandler_t, Perl_csighandler) /* Pointer to C-level sighandler */
79#endif
80
81#ifndef PERL_USE_SAFE_PUTENV
82PERLVARI(Guse_safe_putenv, int, 1)
83#endif
84
85#ifdef USE_PERLIO
86PERLVARI(Gperlio_fd_refcnt, int*, 0) /* Pointer to array of fd refcounts. */
87PERLVARI(Gperlio_fd_refcnt_size, int, 0) /* Size of the array */
88PERLVARI(Gperlio_debug_fd, int, 0) /* the fd to write perlio debug into, 0 means not set yet */
89#endif
90
91#ifdef HAS_MMAP
92PERLVARI(Gmmap_page_size, IV, 0)
93#endif
94
95#if defined(FAKE_PERSISTENT_SIGNAL_HANDLERS)||defined(FAKE_DEFAULT_SIGNAL_HANDLERS)
96PERLVARI(Gsig_handlers_initted, int, 0)
97#endif
98#ifdef FAKE_PERSISTENT_SIGNAL_HANDLERS
99PERLVARA(Gsig_ignoring, SIG_SIZE, int) /* which signals we are ignoring */
100#endif
101#ifdef FAKE_DEFAULT_SIGNAL_HANDLERS
102PERLVARA(Gsig_defaulting, SIG_SIZE, int)
103#endif
104
105#ifndef PERL_IMPLICIT_CONTEXT
106PERLVAR(Gsig_sv, SV*)
107#endif
108
109/* XXX signals are process-wide anyway, so we
110 * ignore the implications of this for threading */
111#ifndef HAS_SIGACTION
112PERLVARI(Gsig_trapped, int, 0)
113#endif
114
115#ifdef DEBUGGING
116PERLVAR(Gwatch_pvx, char*)
117#endif
118
119#ifdef PERL_GLOBAL_STRUCT
120PERLVAR(Gppaddr, Perl_ppaddr_t*) /* or opcode.h */
121PERLVAR(Gcheck, Perl_check_t *) /* or opcode.h */
122PERLVARA(Gfold_locale, 256, unsigned char) /* or perl.h */
123PERLVARA(Gcharclass, 256, U32)
124#endif
125
126#ifdef PERL_NEED_APPCTX
127PERLVAR(Gappctx, void*) /* the application context */
128#endif
129
130PERLVAR(Gop_sequence, HV*) /* dump.c */
131PERLVARI(Gop_seq, UV, 0) /* dump.c */
132
133#if defined(HAS_TIMES) && defined(PERL_NEED_TIMESBASE)
134PERLVAR(Gtimesbase, struct tms)
135#endif
136
137/* allocate a unique index to every module that calls MY_CXT_INIT */
138
139#ifdef PERL_IMPLICIT_CONTEXT
140# ifdef USE_ITHREADS
141PERLVAR(Gmy_ctx_mutex, perl_mutex)
142# endif
143PERLVARI(Gmy_cxt_index, int, 0)
144#endif
145
146#if defined(USE_ITHREADS)
147PERLVAR(Ghints_mutex, perl_mutex) /* Mutex for refcounted he refcounting */
148#endif
149
150#if defined(USE_ITHREADS)
151PERLVAR(Gperlio_mutex, perl_mutex) /* Mutex for perlio fd refcounts */
152#endif
153
154/* this is currently set without MUTEX protection, so keep it a type which
155 * can be set atomically (ie not a bit field) */
156PERLVARI(Gveto_cleanup, int, FALSE) /* exit without cleanup */
157
158/* dummy variables that hold pointers to both runops functions, thus forcing
159 * them *both* to get linked in (useful for Peek.xs, debugging etc) */
160
161PERLVARI(Grunops_std, runops_proc_t, MEMBER_TO_FPTR(Perl_runops_standard))
162PERLVARI(Grunops_dbg, runops_proc_t, MEMBER_TO_FPTR(Perl_runops_debug))
163
164
165/* These are baked at compile time into any shared perl library.
166 In future 5.10.x releases this will allow us in main() to sanity test the
167 library we're linking against. */
168
169PERLVARI(Grevision, U8, PERL_REVISION)
170PERLVARI(Gversion, U8, PERL_VERSION)
171PERLVARI(Gsubversion, U8, PERL_SUBVERSION)
172
173#if defined(MULTIPLICITY)
174# define PERL_INTERPRETER_SIZE_UPTO_MEMBER(member) \
175 STRUCT_OFFSET(struct interpreter, member) + \
176 sizeof(((struct interpreter*)0)->member)
177
178/* These might be useful. */
179PERLVARI(Ginterp_size, U16, sizeof(struct interpreter))
180#if defined(PERL_GLOBAL_STRUCT)
181PERLVARI(Gglobal_struct_size, U16, sizeof(struct perl_vars))
182#endif
183
184/* This will be useful for subsequent releases, because this has to be the
185 same in your libperl as in main(), else you have a mismatch and must abort.
186*/
187PERLVARI(Ginterp_size_5_10_0, U16,
188 PERL_INTERPRETER_SIZE_UPTO_MEMBER(PERL_LAST_5_10_0_INTERP_MEMBER))
189#endif
190
191/*
192=for apidoc AmUx|Perl_keyword_plugin_t|PL_keyword_plugin
193
194Function pointer, pointing at a function used to handle extended keywords.
195The function should be declared as
196
197 int keyword_plugin_function(pTHX_
198 char *keyword_ptr, STRLEN keyword_len,
199 OP **op_ptr)
200
201The function is called from the tokeniser, whenever a possible keyword
202is seen. C<keyword_ptr> points at the word in the parser's input
203buffer, and C<keyword_len> gives its length; it is not null-terminated.
204The function is expected to examine the word, and possibly other state
205such as L<%^H|perlvar/%^H>, to decide whether it wants to handle it
206as an extended keyword. If it does not, the function should return
207C<KEYWORD_PLUGIN_DECLINE>, and the normal parser process will continue.
208
209If the function wants to handle the keyword, it first must
210parse anything following the keyword that is part of the syntax
211introduced by the keyword. See L</Lexer interface> for details.
212
213When a keyword is being handled, the plugin function must build
214a tree of C<OP> structures, representing the code that was parsed.
215The root of the tree must be stored in C<*op_ptr>. The function then
216returns a constant indicating the syntactic role of the construct that
217it has parsed: C<KEYWORD_PLUGIN_STMT> if it is a complete statement, or
218C<KEYWORD_PLUGIN_EXPR> if it is an expression. Note that a statement
219construct cannot be used inside an expression (except via C<do BLOCK>
220and similar), and an expression is not a complete statement (it requires
221at least a terminating semicolon).
222
223When a keyword is handled, the plugin function may also have
224(compile-time) side effects. It may modify C<%^H>, define functions, and
225so on. Typically, if side effects are the main purpose of a handler,
226it does not wish to generate any ops to be included in the normal
227compilation. In this case it is still required to supply an op tree,
228but it suffices to generate a single null op.
229
230That's how the C<*PL_keyword_plugin> function needs to behave overall.
231Conventionally, however, one does not completely replace the existing
232handler function. Instead, take a copy of C<PL_keyword_plugin> before
233assigning your own function pointer to it. Your handler function should
234look for keywords that it is interested in and handle those. Where it
235is not interested, it should call the saved plugin function, passing on
236the arguments it received. Thus C<PL_keyword_plugin> actually points
237at a chain of handler functions, all of which have an opportunity to
238handle keywords, and only the last function in the chain (built into
239the Perl core) will normally return C<KEYWORD_PLUGIN_DECLINE>.
240
241=cut
242*/
243
244PERLVARI(Gkeyword_plugin, Perl_keyword_plugin_t, MEMBER_TO_FPTR(Perl_keyword_plugin_standard))