This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Restructure the heredocs in perlmodlib.PL so the file as-is is valid Pod.
[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 */
eeb6b841 27#if defined(USE_ITHREADS)
115ff745 28PERLVAR(G, op_mutex, perl_mutex) /* Mutex for op refcounting */
eeb6b841 29#endif
115ff745 30PERLVAR(G, curinterp, PerlInterpreter *)
43165c05 31 /* currently running interpreter
ba869deb
GS
32 * (initial parent interpreter under
33 * useithreads) */
3db8f154 34#if defined(USE_ITHREADS)
115ff745 35PERLVAR(G, thr_key, perl_key) /* key to retrieve per-thread struct */
ba869deb 36#endif
a0ed51b3 37
43165c05 38/* XXX does anyone even use this? */
115ff745 39PERLVARI(G, do_undump, bool, FALSE) /* -u or dump seen? */
b363f7ed 40
eeb6b841 41#ifndef PERL_USE_SAFE_PUTENV
115ff745 42PERLVARI(G, use_safe_putenv, bool, TRUE)
b363f7ed 43#endif
534825c4 44
eeb6b841 45#if defined(FAKE_PERSISTENT_SIGNAL_HANDLERS)||defined(FAKE_DEFAULT_SIGNAL_HANDLERS)
115ff745 46PERLVARI(G, sig_handlers_initted, int, 0)
534825c4 47#endif
eeb6b841 48#ifdef FAKE_PERSISTENT_SIGNAL_HANDLERS
115ff745
NC
49PERLVARA(G, sig_ignoring, SIG_SIZE, int)
50 /* which signals we are ignoring */
eeb6b841
NC
51#endif
52#ifdef FAKE_DEFAULT_SIGNAL_HANDLERS
115ff745 53PERLVARA(G, sig_defaulting, SIG_SIZE, int)
d90a703e 54#endif
5c728af0 55
eeb6b841
NC
56/* XXX signals are process-wide anyway, so we
57 * ignore the implications of this for threading */
58#ifndef HAS_SIGACTION
115ff745 59PERLVARI(G, sig_trapped, int, 0)
428eed4a 60#endif
af419de7 61
2f42fcb0 62#ifndef PERL_MICRO
b35112e7
CS
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. */
115ff745
NC
65PERLVAR(G, sigfpe_saved, Sighandler_t)
66PERLVARI(G, csighandlerp, Sighandler_t, Perl_csighandler)
67 /* Pointer to C-level sighandler */
2f42fcb0 68#endif
5c1546dc 69
eeb6b841
NC
70/* This is constant on most architectures, a global on OS/2 */
71#ifdef OS2
115ff745 72PERLVARI(G, sh_path, char *, SH_PATH) /* full path of shell */
50acdf95 73#endif
27da23d5
JH
74
75#ifdef USE_PERLIO
eeb6b841
NC
76
77# if defined(USE_ITHREADS)
115ff745 78PERLVAR(G, perlio_mutex, perl_mutex) /* Mutex for perlio fd refcounts */
eeb6b841
NC
79# endif
80
115ff745
NC
81PERLVARI(G, perlio_fd_refcnt, int *, 0) /* Pointer to array of fd refcounts. */
82PERLVARI(G, perlio_fd_refcnt_size, int, 0) /* Size of the array */
83PERLVARI(G, perlio_debug_fd, int, 0) /* the fd to write perlio debug into, 0 means not set yet */
27da23d5
JH
84#endif
85
86#ifdef HAS_MMAP
115ff745 87PERLVARI(G, mmap_page_size, IV, 0)
27da23d5
JH
88#endif
89
eeb6b841 90#if defined(USE_ITHREADS)
115ff745 91PERLVAR(G, hints_mutex, perl_mutex) /* Mutex for refcounted he refcounting */
27da23d5
JH
92#endif
93
94#ifdef DEBUGGING
115ff745 95PERLVAR(G, watch_pvx, char *)
27da23d5
JH
96#endif
97
98#ifdef PERL_GLOBAL_STRUCT
115ff745
NC
99PERLVAR(G, ppaddr, Perl_ppaddr_t *) /* or opcode.h */
100PERLVAR(G, check, Perl_check_t *) /* or opcode.h */
101PERLVARA(G, fold_locale, 256, unsigned char) /* or perl.h */
27da23d5
JH
102#endif
103
104#ifdef PERL_NEED_APPCTX
115ff745 105PERLVAR(G, appctx, void*) /* the application context */
27da23d5
JH
106#endif
107
27da23d5 108#if defined(HAS_TIMES) && defined(PERL_NEED_TIMESBASE)
115ff745 109PERLVAR(G, timesbase, struct tms)
27da23d5
JH
110#endif
111
f16dd614 112/* allocate a unique index to every module that calls MY_CXT_INIT */
27da23d5 113
f16dd614 114#ifdef PERL_IMPLICIT_CONTEXT
97aff369 115# ifdef USE_ITHREADS
115ff745 116PERLVAR(G, my_ctx_mutex, perl_mutex)
97aff369 117# endif
115ff745 118PERLVARI(G, my_cxt_index, int, 0)
f16dd614 119#endif
71ad1b0c 120
c301d606
DM
121/* this is currently set without MUTEX protection, so keep it a type which
122 * can be set atomically (ie not a bit field) */
115ff745 123PERLVARI(G, veto_cleanup, int, FALSE) /* exit without cleanup */
c301d606 124
88e1f1a2
JV
125/*
126=for apidoc AmUx|Perl_keyword_plugin_t|PL_keyword_plugin
127
128Function pointer, pointing at a function used to handle extended keywords.
129The function should be declared as
130
131 int keyword_plugin_function(pTHX_
132 char *keyword_ptr, STRLEN keyword_len,
133 OP **op_ptr)
134
135The function is called from the tokeniser, whenever a possible keyword
136is seen. C<keyword_ptr> points at the word in the parser's input
137buffer, and C<keyword_len> gives its length; it is not null-terminated.
138The function is expected to examine the word, and possibly other state
139such as L<%^H|perlvar/%^H>, to decide whether it wants to handle it
140as an extended keyword. If it does not, the function should return
141C<KEYWORD_PLUGIN_DECLINE>, and the normal parser process will continue.
142
143If the function wants to handle the keyword, it first must
144parse anything following the keyword that is part of the syntax
f0e67a1d 145introduced by the keyword. See L</Lexer interface> for details.
88e1f1a2
JV
146
147When a keyword is being handled, the plugin function must build
148a tree of C<OP> structures, representing the code that was parsed.
149The root of the tree must be stored in C<*op_ptr>. The function then
364f83bf 150returns a constant indicating the syntactic role of the construct that
88e1f1a2
JV
151it has parsed: C<KEYWORD_PLUGIN_STMT> if it is a complete statement, or
152C<KEYWORD_PLUGIN_EXPR> if it is an expression. Note that a statement
153construct cannot be used inside an expression (except via C<do BLOCK>
154and similar), and an expression is not a complete statement (it requires
155at least a terminating semicolon).
156
157When a keyword is handled, the plugin function may also have
158(compile-time) side effects. It may modify C<%^H>, define functions, and
159so on. Typically, if side effects are the main purpose of a handler,
160it does not wish to generate any ops to be included in the normal
161compilation. In this case it is still required to supply an op tree,
162but it suffices to generate a single null op.
163
164That's how the C<*PL_keyword_plugin> function needs to behave overall.
165Conventionally, however, one does not completely replace the existing
166handler function. Instead, take a copy of C<PL_keyword_plugin> before
167assigning your own function pointer to it. Your handler function should
168look for keywords that it is interested in and handle those. Where it
169is not interested, it should call the saved plugin function, passing on
170the arguments it received. Thus C<PL_keyword_plugin> actually points
171at a chain of handler functions, all of which have an opportunity to
172handle keywords, and only the last function in the chain (built into
173the Perl core) will normally return C<KEYWORD_PLUGIN_DECLINE>.
174
175=cut
176*/
177
115ff745 178PERLVARI(G, keyword_plugin, Perl_keyword_plugin_t, Perl_keyword_plugin_standard)
eeb6b841 179
115ff745
NC
180PERLVAR(G, op_sequence, HV *) /* dump.c */
181PERLVARI(G, op_seq, UV, 0) /* dump.c */
eeb6b841
NC
182
183#ifdef USE_ITHREADS
115ff745 184PERLVAR(G, dollarzero_mutex, perl_mutex) /* Modifying $0 */
eeb6b841
NC
185#endif
186
187/* Restricted hashes placeholder value.
188 * The contents are never used, only the address. */
115ff745 189PERLVAR(G, sv_placeholder, SV)
eeb6b841
NC
190
191#if defined(MYMALLOC) && defined(USE_ITHREADS)
115ff745 192PERLVAR(G, malloc_mutex, perl_mutex) /* Mutex for malloc */
eeb6b841 193#endif