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