This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
PL_perlio_mutex is only needed with USE_UIHREADS && USE_PERLIO
[perl5.git] / perlvars.h
CommitLineData
eb1102fc
NIS
1/* perlvars.h
2 *
663f364b 3 * Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
54ca4ee7 4 * by Larry Wall and others
eb1102fc
NIS
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
88e1f1a2
JV
11/*
12=head1 Global Variables
13*/
49f531da 14
d7cb65f2 15/* Don't forget to re-run regen/embed.pl to propagate changes! */
cb68f92d
GS
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
22c35a8c 23 * generated in embed*.h. Such symbols are also used to generate
14dd3ad8 24 * the appropriate export list for win32. */
cb68f92d 25
49f531da 26/* global state */
cb68f92d 27PERLVAR(Gcurinterp, PerlInterpreter *)
43165c05 28 /* currently running interpreter
ba869deb
GS
29 * (initial parent interpreter under
30 * useithreads) */
3db8f154 31#if defined(USE_ITHREADS)
ba869deb
GS
32PERLVAR(Gthr_key, perl_key) /* key to retrieve per-thread struct */
33#endif
a0ed51b3 34
43165c05
GS
35/* XXX does anyone even use this? */
36PERLVARI(Gdo_undump, bool, FALSE) /* -u or dump seen? */
b363f7ed 37
3db8f154 38#if defined(MYMALLOC) && defined(USE_ITHREADS)
b363f7ed
GS
39PERLVAR(Gmalloc_mutex, perl_mutex) /* Mutex for malloc */
40#endif
534825c4
GS
41
42#if defined(USE_ITHREADS)
43PERLVAR(Gop_mutex, perl_mutex) /* Mutex for op refcounting */
44#endif
60e4ec2e 45
d90a703e
JH
46#ifdef USE_ITHREADS
47PERLVAR(Gdollarzero_mutex, perl_mutex) /* Modifying $0 */
48#endif
5c728af0 49
95ca8690 50
5c728af0 51/* This is constant on most architectures, a global on OS/2 */
428eed4a 52#ifdef OS2
0447859b 53PERLVARI(Gsh_path, char *, SH_PATH) /* full path of shell */
428eed4a 54#endif
af419de7 55
2f42fcb0 56#ifndef PERL_MICRO
b35112e7
CS
57/* If Perl has to ignore SIGPFE, this is its saved state.
58 * See perl.h macros PERL_FPU_INIT and PERL_FPU_{PRE,POST}_EXEC. */
59PERLVAR(Gsigfpe_saved, Sighandler_t)
2f42fcb0 60#endif
b35112e7 61
643157af
JH
62/* Restricted hashes placeholder value.
63 * The contents are never used, only the address. */
64PERLVAR(Gsv_placeholder, SV)
65
2f42fcb0 66#ifndef PERL_MICRO
1c127fab 67PERLVARI(Gcsighandlerp, Sighandler_t, Perl_csighandler) /* Pointer to C-level sighandler */
2f42fcb0 68#endif
5c1546dc 69
50acdf95 70#ifndef PERL_USE_SAFE_PUTENV
8bf20623 71PERLVARI(Guse_safe_putenv, bool, TRUE)
50acdf95 72#endif
27da23d5
JH
73
74#ifdef USE_PERLIO
22c96fc1
NC
75PERLVARI(Gperlio_fd_refcnt, int*, 0) /* Pointer to array of fd refcounts. */
76PERLVARI(Gperlio_fd_refcnt_size, int, 0) /* Size of the array */
27da23d5
JH
77PERLVARI(Gperlio_debug_fd, int, 0) /* the fd to write perlio debug into, 0 means not set yet */
78#endif
79
80#ifdef HAS_MMAP
81PERLVARI(Gmmap_page_size, IV, 0)
82#endif
83
84#if defined(FAKE_PERSISTENT_SIGNAL_HANDLERS)||defined(FAKE_DEFAULT_SIGNAL_HANDLERS)
85PERLVARI(Gsig_handlers_initted, int, 0)
86#endif
87#ifdef FAKE_PERSISTENT_SIGNAL_HANDLERS
88PERLVARA(Gsig_ignoring, SIG_SIZE, int) /* which signals we are ignoring */
89#endif
90#ifdef FAKE_DEFAULT_SIGNAL_HANDLERS
aadb217d 91PERLVARA(Gsig_defaulting, SIG_SIZE, int)
27da23d5
JH
92#endif
93
27da23d5
JH
94/* XXX signals are process-wide anyway, so we
95 * ignore the implications of this for threading */
96#ifndef HAS_SIGACTION
97PERLVARI(Gsig_trapped, int, 0)
98#endif
99
100#ifdef DEBUGGING
101PERLVAR(Gwatch_pvx, char*)
102#endif
103
104#ifdef PERL_GLOBAL_STRUCT
105PERLVAR(Gppaddr, Perl_ppaddr_t*) /* or opcode.h */
106PERLVAR(Gcheck, Perl_check_t *) /* or opcode.h */
107PERLVARA(Gfold_locale, 256, unsigned char) /* or perl.h */
108#endif
109
110#ifdef PERL_NEED_APPCTX
111PERLVAR(Gappctx, void*) /* the application context */
112#endif
113
114PERLVAR(Gop_sequence, HV*) /* dump.c */
115PERLVARI(Gop_seq, UV, 0) /* dump.c */
116
117#if defined(HAS_TIMES) && defined(PERL_NEED_TIMESBASE)
118PERLVAR(Gtimesbase, struct tms)
119#endif
120
f16dd614 121/* allocate a unique index to every module that calls MY_CXT_INIT */
27da23d5 122
f16dd614 123#ifdef PERL_IMPLICIT_CONTEXT
97aff369 124# ifdef USE_ITHREADS
f16dd614 125PERLVAR(Gmy_ctx_mutex, perl_mutex)
97aff369 126# endif
f16dd614
DM
127PERLVARI(Gmy_cxt_index, int, 0)
128#endif
71ad1b0c
NC
129
130#if defined(USE_ITHREADS)
131PERLVAR(Ghints_mutex, perl_mutex) /* Mutex for refcounted he refcounting */
132#endif
6cb8cb21 133
fdad75c9 134#if defined(USE_ITHREADS) && defined(USE_PERLIO)
6cb8cb21
RGS
135PERLVAR(Gperlio_mutex, perl_mutex) /* Mutex for perlio fd refcounts */
136#endif
c301d606
DM
137
138/* this is currently set without MUTEX protection, so keep it a type which
139 * can be set atomically (ie not a bit field) */
140PERLVARI(Gveto_cleanup, int, FALSE) /* exit without cleanup */
141
88e1f1a2
JV
142/*
143=for apidoc AmUx|Perl_keyword_plugin_t|PL_keyword_plugin
144
145Function pointer, pointing at a function used to handle extended keywords.
146The function should be declared as
147
148 int keyword_plugin_function(pTHX_
149 char *keyword_ptr, STRLEN keyword_len,
150 OP **op_ptr)
151
152The function is called from the tokeniser, whenever a possible keyword
153is seen. C<keyword_ptr> points at the word in the parser's input
154buffer, and C<keyword_len> gives its length; it is not null-terminated.
155The function is expected to examine the word, and possibly other state
156such as L<%^H|perlvar/%^H>, to decide whether it wants to handle it
157as an extended keyword. If it does not, the function should return
158C<KEYWORD_PLUGIN_DECLINE>, and the normal parser process will continue.
159
160If the function wants to handle the keyword, it first must
161parse anything following the keyword that is part of the syntax
f0e67a1d 162introduced by the keyword. See L</Lexer interface> for details.
88e1f1a2
JV
163
164When a keyword is being handled, the plugin function must build
165a tree of C<OP> structures, representing the code that was parsed.
166The root of the tree must be stored in C<*op_ptr>. The function then
364f83bf 167returns a constant indicating the syntactic role of the construct that
88e1f1a2
JV
168it has parsed: C<KEYWORD_PLUGIN_STMT> if it is a complete statement, or
169C<KEYWORD_PLUGIN_EXPR> if it is an expression. Note that a statement
170construct cannot be used inside an expression (except via C<do BLOCK>
171and similar), and an expression is not a complete statement (it requires
172at least a terminating semicolon).
173
174When a keyword is handled, the plugin function may also have
175(compile-time) side effects. It may modify C<%^H>, define functions, and
176so on. Typically, if side effects are the main purpose of a handler,
177it does not wish to generate any ops to be included in the normal
178compilation. In this case it is still required to supply an op tree,
179but it suffices to generate a single null op.
180
181That's how the C<*PL_keyword_plugin> function needs to behave overall.
182Conventionally, however, one does not completely replace the existing
183handler function. Instead, take a copy of C<PL_keyword_plugin> before
184assigning your own function pointer to it. Your handler function should
185look for keywords that it is interested in and handle those. Where it
186is not interested, it should call the saved plugin function, passing on
187the arguments it received. Thus C<PL_keyword_plugin> actually points
188at a chain of handler functions, all of which have an opportunity to
189handle keywords, and only the last function in the chain (built into
190the Perl core) will normally return C<KEYWORD_PLUGIN_DECLINE>.
191
192=cut
193*/
194
ef69c8fc 195PERLVARI(Gkeyword_plugin, Perl_keyword_plugin_t, Perl_keyword_plugin_standard)