3 * Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
4 * by Larry Wall and others
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.
12 =head1 Global Variables
15 /* Don't forget to re-run regen/embed.pl to propagate changes! */
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.
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. */
27 #if defined(USE_ITHREADS)
28 PERLVAR(G, op_mutex, perl_mutex) /* Mutex for op refcounting */
30 PERLVAR(G, curinterp, PerlInterpreter *)
31 /* currently running interpreter
32 * (initial parent interpreter under
34 #if defined(USE_ITHREADS)
35 PERLVAR(G, thr_key, perl_key) /* key to retrieve per-thread struct */
38 /* XXX does anyone even use this? */
39 PERLVARI(G, do_undump, bool, FALSE) /* -u or dump seen? */
41 #ifndef PERL_USE_SAFE_PUTENV
42 PERLVARI(G, use_safe_putenv, bool, TRUE)
45 #if defined(FAKE_PERSISTENT_SIGNAL_HANDLERS)||defined(FAKE_DEFAULT_SIGNAL_HANDLERS)
46 PERLVARI(G, sig_handlers_initted, int, 0)
48 #ifdef FAKE_PERSISTENT_SIGNAL_HANDLERS
49 PERLVARA(G, sig_ignoring, SIG_SIZE, int)
50 /* which signals we are ignoring */
52 #ifdef FAKE_DEFAULT_SIGNAL_HANDLERS
53 PERLVARA(G, sig_defaulting, SIG_SIZE, int)
56 /* XXX signals are process-wide anyway, so we
57 * ignore the implications of this for threading */
59 PERLVARI(G, sig_trapped, int, 0)
63 /* If Perl has to ignore SIGPFE, this is its saved state.
64 * See perl.h macros PERL_FPU_INIT and PERL_FPU_{PRE,POST}_EXEC. */
65 PERLVAR(G, sigfpe_saved, Sighandler_t)
66 PERLVARI(G, csighandlerp, Sighandler_t, Perl_csighandler)
67 /* Pointer to C-level sighandler */
70 /* This is constant on most architectures, a global on OS/2 */
72 PERLVARI(G, sh_path, char *, SH_PATH) /* full path of shell */
77 # if defined(USE_ITHREADS)
78 PERLVAR(G, perlio_mutex, perl_mutex) /* Mutex for perlio fd refcounts */
81 PERLVARI(G, perlio_fd_refcnt, int *, 0) /* Pointer to array of fd refcounts. */
82 PERLVARI(G, perlio_fd_refcnt_size, int, 0) /* Size of the array */
83 PERLVARI(G, perlio_debug_fd, int, 0) /* the fd to write perlio debug into, 0 means not set yet */
87 PERLVARI(G, mmap_page_size, IV, 0)
90 #if defined(USE_ITHREADS)
91 PERLVAR(G, hints_mutex, perl_mutex) /* Mutex for refcounted he refcounting */
95 PERLVAR(G, watch_pvx, char *)
98 #ifdef PERL_GLOBAL_STRUCT
99 PERLVAR(G, ppaddr, Perl_ppaddr_t *) /* or opcode.h */
100 PERLVAR(G, check, Perl_check_t *) /* or opcode.h */
101 PERLVARA(G, fold_locale, 256, unsigned char) /* or perl.h */
104 #ifdef PERL_NEED_APPCTX
105 PERLVAR(G, appctx, void*) /* the application context */
108 #if defined(HAS_TIMES) && defined(PERL_NEED_TIMESBASE)
109 PERLVAR(G, timesbase, struct tms)
112 /* allocate a unique index to every module that calls MY_CXT_INIT */
114 #ifdef PERL_IMPLICIT_CONTEXT
116 PERLVAR(G, my_ctx_mutex, perl_mutex)
118 PERLVARI(G, my_cxt_index, int, 0)
121 /* this is currently set without MUTEX protection, so keep it a type which
122 * can be set atomically (ie not a bit field) */
123 PERLVARI(G, veto_cleanup, int, FALSE) /* exit without cleanup */
126 =for apidoc AmUx|Perl_keyword_plugin_t|PL_keyword_plugin
128 Function pointer, pointing at a function used to handle extended keywords.
129 The function should be declared as
131 int keyword_plugin_function(pTHX_
132 char *keyword_ptr, STRLEN keyword_len,
135 The function is called from the tokeniser, whenever a possible keyword
136 is seen. C<keyword_ptr> points at the word in the parser's input
137 buffer, and C<keyword_len> gives its length; it is not null-terminated.
138 The function is expected to examine the word, and possibly other state
139 such as L<%^H|perlvar/%^H>, to decide whether it wants to handle it
140 as an extended keyword. If it does not, the function should return
141 C<KEYWORD_PLUGIN_DECLINE>, and the normal parser process will continue.
143 If the function wants to handle the keyword, it first must
144 parse anything following the keyword that is part of the syntax
145 introduced by the keyword. See L</Lexer interface> for details.
147 When a keyword is being handled, the plugin function must build
148 a tree of C<OP> structures, representing the code that was parsed.
149 The root of the tree must be stored in C<*op_ptr>. The function then
150 returns a constant indicating the syntactic role of the construct that
151 it has parsed: C<KEYWORD_PLUGIN_STMT> if it is a complete statement, or
152 C<KEYWORD_PLUGIN_EXPR> if it is an expression. Note that a statement
153 construct cannot be used inside an expression (except via C<do BLOCK>
154 and similar), and an expression is not a complete statement (it requires
155 at least a terminating semicolon).
157 When a keyword is handled, the plugin function may also have
158 (compile-time) side effects. It may modify C<%^H>, define functions, and
159 so on. Typically, if side effects are the main purpose of a handler,
160 it does not wish to generate any ops to be included in the normal
161 compilation. In this case it is still required to supply an op tree,
162 but it suffices to generate a single null op.
164 That's how the C<*PL_keyword_plugin> function needs to behave overall.
165 Conventionally, however, one does not completely replace the existing
166 handler function. Instead, take a copy of C<PL_keyword_plugin> before
167 assigning your own function pointer to it. Your handler function should
168 look for keywords that it is interested in and handle those. Where it
169 is not interested, it should call the saved plugin function, passing on
170 the arguments it received. Thus C<PL_keyword_plugin> actually points
171 at a chain of handler functions, all of which have an opportunity to
172 handle keywords, and only the last function in the chain (built into
173 the Perl core) will normally return C<KEYWORD_PLUGIN_DECLINE>.
178 PERLVARI(G, keyword_plugin, Perl_keyword_plugin_t, Perl_keyword_plugin_standard)
180 PERLVAR(G, op_sequence, HV *) /* dump.c */
181 PERLVARI(G, op_seq, UV, 0) /* dump.c */
184 PERLVAR(G, dollarzero_mutex, perl_mutex) /* Modifying $0 */
187 /* Restricted hashes placeholder value.
188 * The contents are never used, only the address. */
189 PERLVAR(G, sv_placeholder, SV)
191 #if defined(MYMALLOC) && defined(USE_ITHREADS)
192 PERLVAR(G, malloc_mutex, perl_mutex) /* Mutex for malloc */