This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Throw a helpful warning when someone tries length(@array) or length(%hash)
[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 regen/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 */
27#if defined(USE_ITHREADS)
28PERLVAR(G, op_mutex, perl_mutex) /* Mutex for op refcounting */
29#endif
30PERLVAR(G, curinterp, PerlInterpreter *)
31 /* currently running interpreter
32 * (initial parent interpreter under
33 * useithreads) */
34#if defined(USE_ITHREADS)
35PERLVAR(G, thr_key, perl_key) /* key to retrieve per-thread struct */
36#endif
37
38/* XXX does anyone even use this? */
39PERLVARI(G, do_undump, bool, FALSE) /* -u or dump seen? */
40
41#ifndef PERL_USE_SAFE_PUTENV
42PERLVARI(G, use_safe_putenv, bool, TRUE)
43#endif
44
45#if defined(FAKE_PERSISTENT_SIGNAL_HANDLERS)||defined(FAKE_DEFAULT_SIGNAL_HANDLERS)
46PERLVARI(G, sig_handlers_initted, int, 0)
47#endif
48#ifdef FAKE_PERSISTENT_SIGNAL_HANDLERS
49PERLVARA(G, sig_ignoring, SIG_SIZE, int)
50 /* which signals we are ignoring */
51#endif
52#ifdef FAKE_DEFAULT_SIGNAL_HANDLERS
53PERLVARA(G, sig_defaulting, SIG_SIZE, int)
54#endif
55
56/* XXX signals are process-wide anyway, so we
57 * ignore the implications of this for threading */
58#ifndef HAS_SIGACTION
59PERLVARI(G, sig_trapped, int, 0)
60#endif
61
62#ifndef PERL_MICRO
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. */
65PERLVAR(G, sigfpe_saved, Sighandler_t)
66PERLVARI(G, csighandlerp, Sighandler_t, Perl_csighandler)
67 /* Pointer to C-level sighandler */
68#endif
69
70/* This is constant on most architectures, a global on OS/2 */
71#ifdef OS2
72PERLVARI(G, sh_path, char *, SH_PATH) /* full path of shell */
73#endif
74
75#ifdef USE_PERLIO
76
77# if defined(USE_ITHREADS)
78PERLVAR(G, perlio_mutex, perl_mutex) /* Mutex for perlio fd refcounts */
79# endif
80
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 */
84#endif
85
86#ifdef HAS_MMAP
87PERLVARI(G, mmap_page_size, IV, 0)
88#endif
89
90#if defined(USE_ITHREADS)
91PERLVAR(G, hints_mutex, perl_mutex) /* Mutex for refcounted he refcounting */
92#endif
93
94#ifdef DEBUGGING
95PERLVAR(G, watch_pvx, char *)
96#endif
97
98#ifdef PERL_GLOBAL_STRUCT
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 */
102#endif
103
104#ifdef PERL_NEED_APPCTX
105PERLVAR(G, appctx, void*) /* the application context */
106#endif
107
108#if defined(HAS_TIMES) && defined(PERL_NEED_TIMESBASE)
109PERLVAR(G, timesbase, struct tms)
110#endif
111
112/* allocate a unique index to every module that calls MY_CXT_INIT */
113
114#ifdef PERL_IMPLICIT_CONTEXT
115# ifdef USE_ITHREADS
116PERLVAR(G, my_ctx_mutex, perl_mutex)
117# endif
118PERLVARI(G, my_cxt_index, int, 0)
119#endif
120
121/* this is currently set without MUTEX protection, so keep it a type which
122 * can be set atomically (ie not a bit field) */
123PERLVARI(G, veto_cleanup, int, FALSE) /* exit without cleanup */
124
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
145introduced by the keyword. See L</Lexer interface> for details.
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
150returns a constant indicating the syntactic role of the construct that
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
178PERLVARI(G, keyword_plugin, Perl_keyword_plugin_t, Perl_keyword_plugin_standard)
179
180PERLVAR(G, op_sequence, HV *) /* dump.c */
181PERLVARI(G, op_seq, UV, 0) /* dump.c */
182
183#ifdef USE_ITHREADS
184PERLVAR(G, dollarzero_mutex, perl_mutex) /* Modifying $0 */
185#endif
186
187/* Restricted hashes placeholder value.
188 * The contents are never used, only the address. */
189PERLVAR(G, sv_placeholder, SV)
190
191#if defined(MYMALLOC) && defined(USE_ITHREADS)
192PERLVAR(G, malloc_mutex, perl_mutex) /* Mutex for malloc */
193#endif