This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
unretract change#5871 (Dominic Dunlop reports machten is better
[perl5.git] / thrdvar.h
1 /***********************************************/
2 /* Global only to current thread               */
3 /***********************************************/
4
5 /* Don't forget to re-run embed.pl to propagate changes! */
6
7 /* The 'T' prefix is only needed for vars that need appropriate #defines
8  * generated when built with or without USE_THREADS.  It is also used
9  * to generate the appropriate export list for win32.
10  *
11  * When building without USE_THREADS, these variables will be truly global.
12  * When building without USE_THREADS but with MULTIPLICITY, these variables
13  * will be global per-interpreter. */
14
15 /* Important ones in the first cache line (if alignment is done right) */
16
17 #ifdef USE_THREADS
18 PERLVAR(interp,         PerlInterpreter*)       /* thread owner */
19 #endif
20
21 PERLVAR(Tstack_sp,      SV **)          /* top of the stack */
22 #ifdef OP_IN_REGISTER
23 PERLVAR(Topsave,        OP *)
24 #else
25 PERLVAR(Top,            OP *)           /* currently executing op */
26 #endif
27 PERLVAR(Tcurpad,        SV **)          /* active pad (lexicals+tmps) */
28
29 PERLVAR(Tstack_base,    SV **)
30 PERLVAR(Tstack_max,     SV **)
31
32 PERLVAR(Tscopestack,    I32 *)          /* scopes we've ENTERed */
33 PERLVAR(Tscopestack_ix, I32)
34 PERLVAR(Tscopestack_max,I32)
35
36 PERLVAR(Tsavestack,     ANY *)          /* items that need to be restored
37                                            when LEAVEing scopes we've ENTERed */
38 PERLVAR(Tsavestack_ix,  I32)
39 PERLVAR(Tsavestack_max, I32)
40
41 PERLVAR(Ttmps_stack,    SV **)          /* mortals we've made */
42 PERLVARI(Ttmps_ix,      I32,    -1)
43 PERLVARI(Ttmps_floor,   I32,    -1)
44 PERLVAR(Ttmps_max,      I32)
45
46 PERLVAR(Tmarkstack,     I32 *)          /* stack_sp locations we're remembering */
47 PERLVAR(Tmarkstack_ptr, I32 *)
48 PERLVAR(Tmarkstack_max, I32 *)
49
50 PERLVAR(Tretstack,      OP **)          /* OPs we have postponed executing */
51 PERLVAR(Tretstack_ix,   I32)
52 PERLVAR(Tretstack_max,  I32)
53
54 PERLVAR(TSv,            SV *)           /* used to hold temporary values */
55 PERLVAR(TXpv,           XPV *)          /* used to hold temporary values */
56
57 /*
58 =for apidoc Amn|STRLEN|PL_na
59
60 A convenience variable which is typically used with C<SvPV> when one
61 doesn't care about the length of the string.  It is usually more efficient
62 to either declare a local variable and use that instead or to use the
63 C<SvPV_nolen> macro.
64
65 =cut
66 */
67
68 PERLVAR(Tna,            STRLEN)         /* for use in SvPV when length is
69                                            Not Applicable */
70
71 /* stat stuff */
72 PERLVAR(Tstatbuf,       Stat_t)
73 PERLVAR(Tstatcache,     Stat_t)         /* _ */
74 PERLVAR(Tstatgv,        GV *)
75 PERLVARI(Tstatname,     SV *,   Nullsv)
76
77 #ifdef HAS_TIMES
78 PERLVAR(Ttimesbuf,      struct tms)
79 #endif
80
81 /* Fields used by magic variables such as $@, $/ and so on */
82 PERLVAR(Ttainted,       bool)           /* using variables controlled by $< */
83 PERLVAR(Tcurpm,         PMOP *)         /* what to do \ interps in REs from */
84 PERLVAR(Tnrs,           SV *)
85 PERLVAR(Trs,            SV *)           /* input record separator $/ */
86 PERLVAR(Tlast_in_gv,    GV *)           /* GV used in last <FH> */
87 PERLVAR(Tofs,           char *)         /* output field separator $, */
88 PERLVAR(Tofslen,        STRLEN)
89 PERLVAR(Tdefoutgv,      GV *)           /* default FH for output */
90 PERLVARI(Tchopset,      char *, " \n-") /* $: */
91 PERLVAR(Tformtarget,    SV *)
92 PERLVAR(Tbodytarget,    SV *)
93 PERLVAR(Ttoptarget,     SV *)
94
95 /* Stashes */
96 PERLVAR(Tdefstash,      HV *)           /* main symbol table */
97 PERLVAR(Tcurstash,      HV *)           /* symbol table for current package */
98
99 PERLVAR(Trestartop,     OP *)           /* propagating an error from croak? */
100 PERLVARI(Tcurcop,       COP * VOL,      &PL_compiling)
101 PERLVAR(Tin_eval,       VOL int)        /* trap "fatal" errors? */
102 PERLVAR(Tdelaymagic,    int)            /* ($<,$>) = ... */
103 PERLVARI(Tdirty,        bool, FALSE)    /* in the middle of tearing things down? */
104 PERLVAR(Tlocalizing,    int)            /* are we processing a local() list? */
105
106 PERLVAR(Tcurstack,      AV *)           /* THE STACK */
107 PERLVAR(Tcurstackinfo,  PERL_SI *)      /* current stack + context */
108 PERLVAR(Tmainstack,     AV *)           /* the stack when nothing funny is happening */
109
110 PERLVAR(Ttop_env,       JMPENV *)       /* ptr. to current sigjmp() environment */
111 PERLVAR(Tstart_env,     JMPENV)         /* empty startup sigjmp() environment */
112 #ifdef PERL_FLEXIBLE_EXCEPTIONS
113 PERLVARI(Tprotect,      protect_proc_t, MEMBER_TO_FPTR(Perl_default_protect))
114 #endif
115 PERLVARI(Terrors,       SV *, Nullsv)   /* outstanding queued errors */
116
117 /* statics "owned" by various functions */
118 PERLVAR(Tav_fetch_sv,   SV *)           /* owned by av_fetch() */
119 PERLVAR(Thv_fetch_sv,   SV *)           /* owned by hv_fetch() */
120 PERLVAR(Thv_fetch_ent_mh, HE)           /* owned by hv_fetch_ent() */
121
122 PERLVAR(Tmodcount,      I32)            /* how much mod()ification in assignment? */
123
124 PERLVAR(Tlastgotoprobe, OP*)            /* from pp_ctl.c */
125 PERLVARI(Tdumpindent,   I32, 4)         /* # of blanks per dump indentation level */
126
127 /* sort stuff */
128 PERLVAR(Tsortcop,       OP *)           /* user defined sort routine */
129 PERLVAR(Tsortstash,     HV *)           /* which is in some package or other */
130 PERLVAR(Tfirstgv,       GV *)           /* $a */
131 PERLVAR(Tsecondgv,      GV *)           /* $b */
132 PERLVAR(Tsortcxix,      I32)            /* from pp_ctl.c */
133
134 /* float buffer */
135 PERLVAR(Tefloatbuf,     char*)
136 PERLVAR(Tefloatsize,    STRLEN)
137
138 /* regex stuff */
139
140 PERLVAR(Tscreamfirst,   I32 *)
141 PERLVAR(Tscreamnext,    I32 *)
142 PERLVARI(Tmaxscream,    I32,    -1)
143 PERLVAR(Tlastscream,    SV *)
144
145 PERLVAR(Tregdummy,      regnode)        /* from regcomp.c */
146 PERLVAR(Tregcomp_parse, char*)          /* Input-scan pointer. */
147 PERLVAR(Tregxend,       char*)          /* End of input for compile */
148 PERLVAR(Tregcode,       regnode*)       /* Code-emit pointer; &regdummy = don't */
149 PERLVAR(Tregnaughty,    I32)            /* How bad is this pattern? */
150 PERLVAR(Tregsawback,    I32)            /* Did we see \1, ...? */
151 PERLVAR(Tregprecomp,    char *)         /* uncompiled string. */
152 PERLVAR(Tregnpar,       I32)            /* () count. */
153 PERLVAR(Tregsize,       I32)            /* Code size. */
154 PERLVAR(Tregflags,      U16)            /* are we folding, multilining? */
155 PERLVAR(Tregseen,       U32)            /* from regcomp.c */
156 PERLVAR(Tseen_zerolen,  I32)            /* from regcomp.c */
157 PERLVAR(Tseen_evals,    I32)            /* from regcomp.c */
158 PERLVAR(Tregcomp_rx,    regexp *)       /* from regcomp.c */
159 PERLVAR(Textralen,      I32)            /* from regcomp.c */
160 PERLVAR(Tcolorset,      int)            /* from regcomp.c */
161 PERLVARA(Tcolors,6,     char *)         /* from regcomp.c */
162 PERLVAR(Treg_whilem_seen, I32)          /* number of WHILEM in this expr */
163 PERLVAR(Treginput,      char *)         /* String-input pointer. */
164 PERLVAR(Tregbol,        char *)         /* Beginning of input, for ^ check. */
165 PERLVAR(Tregeol,        char *)         /* End of input, for $ check. */
166 PERLVAR(Tregstartp,     I32 *)          /* Pointer to startp array. */
167 PERLVAR(Tregendp,       I32 *)          /* Ditto for endp. */
168 PERLVAR(Treglastparen,  U32 *)          /* Similarly for lastparen. */
169 PERLVAR(Tregtill,       char *)         /* How far we are required to go. */
170 PERLVAR(Tregprev,       char)           /* char before regbol, \n if none */
171 PERLVAR(Treg_start_tmp, char **)        /* from regexec.c */
172 PERLVAR(Treg_start_tmpl,U32)            /* from regexec.c */
173 PERLVAR(Tregdata,       struct reg_data *)
174                                         /* from regexec.c renamed was data */
175 PERLVAR(Tbostr,         char *)         /* from regexec.c */
176 PERLVAR(Treg_flags,     U32)            /* from regexec.c */
177 PERLVAR(Treg_eval_set,  I32)            /* from regexec.c */
178 PERLVAR(Tregnarrate,    I32)            /* from regexec.c */
179 PERLVAR(Tregprogram,    regnode *)      /* from regexec.c */
180 PERLVARI(Tregindent,    int,        0)  /* from regexec.c */
181 PERLVAR(Tregcc,         CURCUR *)       /* from regexec.c */
182 PERLVAR(Treg_call_cc,   struct re_cc_state *)   /* from regexec.c */
183 PERLVAR(Treg_re,        regexp *)       /* from regexec.c */
184 PERLVAR(Treg_ganch,     char *)         /* position of \G */
185 PERLVAR(Treg_sv,        SV *)           /* what we match against */
186 PERLVAR(Treg_magic,     MAGIC *)        /* pos-magic of what we match */
187 PERLVAR(Treg_oldpos,    I32)            /* old pos of what we match */
188 PERLVARI(Treg_oldcurpm, PMOP*, NULL)    /* curpm before match */
189 PERLVARI(Treg_curpm,    PMOP*, NULL)    /* curpm during match */
190 PERLVAR(Treg_oldsaved,  char*)          /* old saved substr during match */
191 PERLVAR(Treg_oldsavedlen, STRLEN)       /* old length of saved substr during match */
192 PERLVAR(Treg_maxiter,   I32)            /* max wait until caching pos */
193 PERLVAR(Treg_leftiter,  I32)            /* wait until caching pos */
194 PERLVARI(Treg_poscache, char *, Nullch) /* cache of pos of WHILEM */
195 PERLVAR(Treg_poscache_size, STRLEN)     /* size of pos cache of WHILEM */
196
197 PERLVARI(Tregcompp,     regcomp_t, MEMBER_TO_FPTR(Perl_pregcomp))
198                                         /* Pointer to REx compiler */
199 PERLVARI(Tregexecp,     regexec_t, MEMBER_TO_FPTR(Perl_regexec_flags))
200                                         /* Pointer to REx executer */
201 PERLVARI(Tregint_start, re_intuit_start_t, MEMBER_TO_FPTR(Perl_re_intuit_start))
202                                         /* Pointer to optimized REx executer */
203 PERLVARI(Tregint_string,re_intuit_string_t, MEMBER_TO_FPTR(Perl_re_intuit_string))
204                                         /* Pointer to optimized REx string */
205 PERLVARI(Tregfree,      regfree_t, MEMBER_TO_FPTR(Perl_pregfree))
206                                         /* Pointer to REx free()er */
207
208 PERLVARI(Treginterp_cnt,int,        0)  /* Whether `Regexp'
209                                                    was interpolated. */
210 PERLVARI(Treg_starttry, char *,     0)  /* -Dr: where regtry was called. */
211 PERLVARI(Twatchaddr,    char **,    0)
212 PERLVAR(Twatchok,       char *)
213
214 /* Note that the variables below are all explicitly referenced in the code
215  * as thr->whatever and therefore don't need the 'T' prefix. */
216
217 #ifdef USE_THREADS
218
219 PERLVAR(oursv,          SV *)
220 PERLVAR(cvcache,        HV *)
221 PERLVAR(self,           perl_os_thread) /* Underlying thread object */
222 PERLVAR(flags,          U32)
223 PERLVAR(threadsv,       AV *)           /* Per-thread SVs ($_, $@ etc.) */
224 PERLVAR(threadsvp,      SV **)          /* AvARRAY(threadsv) */
225 PERLVAR(specific,       AV *)           /* Thread-specific user data */
226 PERLVAR(errsv,          SV *)           /* Backing SV for $@ */
227 PERLVAR(mutex,          perl_mutex)     /* For the fields others can change */
228 PERLVAR(tid,            U32)
229 PERLVAR(prev,           struct perl_thread *)
230 PERLVAR(next,           struct perl_thread *)
231                                         /* Circular linked list of threads */
232
233 #ifdef HAVE_THREAD_INTERN
234 PERLVAR(i,              struct thread_intern)
235                                         /* Platform-dependent internals */
236 #endif
237
238 PERLVAR(trailing_nul,   char)           /* For the sake of thrsv and oursv */
239
240 #endif /* USE_THREADS */