This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
check ferror() only if read() returned 0
[perl5.git] / thrdvar.h
CommitLineData
cb68f92d
GS
1/***********************************************/
2/* Global only to current thread */
3/***********************************************/
4
8b3be1d1
JP
5/* Don't forget to re-run embed.pl to propagate changes! */
6
cb68f92d
GS
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 * Avoid build-specific #ifdefs here, like DEBUGGING. That way,
16 * we can keep binary compatibility of the curinterp structure */
8b3be1d1 17
49f531da 18/* Important ones in the first cache line (if alignment is done right) */
d4cce5f1 19
cb68f92d 20PERLVAR(Tstack_sp, SV **) /* top of the stack */
49f531da 21#ifdef OP_IN_REGISTER
cb68f92d 22PERLVAR(Topsave, OP *)
49f531da 23#else
cb68f92d 24PERLVAR(Top, OP *) /* currently executing op */
49f531da 25#endif
cb68f92d
GS
26PERLVAR(Tcurpad, SV **) /* active pad (lexicals+tmps) */
27
28PERLVAR(Tstack_base, SV **)
29PERLVAR(Tstack_max, SV **)
30
31PERLVAR(Tscopestack, I32 *) /* scopes we've ENTERed */
32PERLVAR(Tscopestack_ix, I32)
33PERLVAR(Tscopestack_max,I32)
49f531da 34
cb68f92d
GS
35PERLVAR(Tsavestack, ANY *) /* items that need to be restored
36 when LEAVEing scopes we've ENTERed */
37PERLVAR(Tsavestack_ix, I32)
38PERLVAR(Tsavestack_max, I32)
49f531da 39
cb68f92d
GS
40PERLVAR(Ttmps_stack, SV **) /* mortals we've made */
41PERLVARI(Ttmps_ix, I32, -1)
42PERLVARI(Ttmps_floor, I32, -1)
43PERLVAR(Ttmps_max, I32)
49f531da 44
cb68f92d
GS
45PERLVAR(Tmarkstack, I32 *) /* stack_sp locations we're remembering */
46PERLVAR(Tmarkstack_ptr, I32 *)
47PERLVAR(Tmarkstack_max, I32 *)
49f531da 48
cb68f92d
GS
49PERLVAR(Tretstack, OP **) /* OPs we have postponed executing */
50PERLVAR(Tretstack_ix, I32)
51PERLVAR(Tretstack_max, I32)
49f531da 52
cb68f92d
GS
53PERLVAR(TSv, SV *) /* used to hold temporary values */
54PERLVAR(TXpv, XPV *) /* used to hold temporary values */
49f531da 55
5c0ca799 56/* stat stuff */
cb68f92d 57PERLVAR(Tstatbuf, Stat_t)
5c0ca799
GS
58PERLVAR(Tstatcache, Stat_t) /* _ */
59PERLVAR(Tstatgv, GV *)
60PERLVARI(Tstatname, SV *, Nullsv)
61
49f531da 62#ifdef HAS_TIMES
cb68f92d 63PERLVAR(Ttimesbuf, struct tms)
49f531da 64#endif
49f531da
NIS
65
66/* Fields used by magic variables such as $@, $/ and so on */
d4cce5f1 67PERLVAR(Ttainted, bool) /* using variables controlled by $< */
cb68f92d
GS
68PERLVAR(Tcurpm, PMOP *) /* what to do \ interps in REs from */
69PERLVAR(Tnrs, SV *)
70PERLVAR(Trs, SV *) /* input record separator $/ */
71PERLVAR(Tlast_in_gv, GV *) /* GV used in last <FH> */
72PERLVAR(Tofs, char *) /* output field separator $, */
73PERLVAR(Tofslen, STRLEN)
74PERLVAR(Tdefoutgv, GV *) /* default FH for output */
d4cce5f1 75PERLVARI(Tchopset, char *, " \n-") /* $: */
cb68f92d
GS
76PERLVAR(Tformtarget, SV *)
77PERLVAR(Tbodytarget, SV *)
78PERLVAR(Ttoptarget, SV *)
49f531da 79
d4cce5f1
NIS
80/* Stashes */
81PERLVAR(Tdefstash, HV *) /* main symbol table */
82PERLVAR(Tcurstash, HV *) /* symbol table for current package */
49f531da 83
cb68f92d
GS
84PERLVAR(Trestartop, OP *) /* propagating an error from croak? */
85PERLVARI(Tcurcop, COP * VOL, &compiling)
d4cce5f1
NIS
86PERLVAR(Tin_eval, VOL int) /* trap "fatal" errors? */
87PERLVAR(Tdelaymagic, int) /* ($<,$>) = ... */
cb68f92d 88PERLVAR(Tdirty, bool) /* in the middle of tearing things down? */
61bb5906 89PERLVAR(Tlocalizing, int) /* are we processing a local() list? */
49f531da 90
cb68f92d
GS
91PERLVAR(Tcurstack, AV *) /* THE STACK */
92PERLVAR(Tcurstackinfo, PERL_SI *) /* current stack + context */
93PERLVAR(Tmainstack, AV *) /* the stack when nothing funny is happening */
94PERLVAR(Ttop_env, JMPENV *) /* ptr. to current sigjmp() environment */
95PERLVAR(Tstart_env, JMPENV) /* empty startup sigjmp() environment */
49f531da 96
4e4c362e 97/* statics "owned" by various functions */
cb68f92d
GS
98PERLVAR(Tav_fetch_sv, SV *) /* owned by av_fetch() */
99PERLVAR(Thv_fetch_sv, SV *) /* owned by hv_fetch() */
100PERLVAR(Thv_fetch_ent_mh, HE) /* owned by hv_fetch_ent() */
101
102PERLVAR(Tmodcount, I32) /* how much mod()ification in assignment? */
4e4c362e 103
5c0ca799
GS
104PERLVAR(Tlastgotoprobe, OP*) /* from pp_ctl.c */
105
106/* sort stuff */
107PERLVAR(Tsortcop, OP *) /* user defined sort routine */
108PERLVAR(Tsortstash, HV *) /* which is in some package or other */
109PERLVAR(Tfirstgv, GV *) /* $a */
110PERLVAR(Tsecondgv, GV *) /* $b */
111PERLVAR(Tsortcxix, I32) /* from pp_ctl.c */
112
113/* regex stuff */
114
115PERLVAR(Tscreamfirst, I32 *)
116PERLVAR(Tscreamnext, I32 *)
117PERLVARI(Tmaxscream, I32, -1)
118PERLVAR(Tlastscream, SV *)
119
120PERLVAR(Tregdummy, regnode) /* from regcomp.c */
121PERLVAR(Tregcomp_parse, char*) /* Input-scan pointer. */
122PERLVAR(Tregxend, char*) /* End of input for compile */
123PERLVAR(Tregcode, regnode*) /* Code-emit pointer; &regdummy = don't */
124PERLVAR(Tregnaughty, I32) /* How bad is this pattern? */
125PERLVAR(Tregsawback, I32) /* Did we see \1, ...? */
126PERLVAR(Tregprecomp, char *) /* uncompiled string. */
127PERLVAR(Tregnpar, I32) /* () count. */
128PERLVAR(Tregsize, I32) /* Code size. */
129PERLVAR(Tregflags, U16) /* are we folding, multilining? */
130PERLVAR(Tregseen, U32) /* from regcomp.c */
131PERLVAR(Tseen_zerolen, I32) /* from regcomp.c */
132PERLVAR(Tseen_evals, I32) /* from regcomp.c */
133PERLVAR(Tregcomp_rx, regexp *) /* from regcomp.c */
134PERLVAR(Textralen, I32) /* from regcomp.c */
135PERLVAR(Tcolorset, int) /* from regcomp.c */
136PERLVAR(Tcolors[4], char *) /* from regcomp.c */
137PERLVAR(Treginput, char *) /* String-input pointer. */
138PERLVAR(Tregbol, char *) /* Beginning of input, for ^ check. */
139PERLVAR(Tregeol, char *) /* End of input, for $ check. */
140PERLVAR(Tregstartp, char **) /* Pointer to startp array. */
141PERLVAR(Tregendp, char **) /* Ditto for endp. */
142PERLVAR(Treglastparen, U32 *) /* Similarly for lastparen. */
143PERLVAR(Tregtill, char *) /* How far we are required to go. */
144PERLVAR(Tregprev, char) /* char before regbol, \n if none */
145PERLVAR(Treg_start_tmp, char **) /* from regexec.c */
146PERLVAR(Treg_start_tmpl,U32) /* from regexec.c */
147PERLVAR(Tregdata, struct reg_data *)
148 /* from regexec.c renamed was data */
149PERLVAR(Tbostr, char *) /* from regexec.c */
150PERLVAR(Treg_flags, U32) /* from regexec.c */
151PERLVAR(Treg_eval_set, I32) /* from regexec.c */
152PERLVAR(Tregnarrate, I32) /* from regexec.c */
153PERLVAR(Tregprogram, regnode *) /* from regexec.c */
154PERLVARI(Tregindent, int, 0) /* from regexec.c */
155PERLVAR(Tregcc, CURCUR *) /* from regexec.c */
156
157PERLVARI(Tregcompp, regcomp_t, FUNC_NAME_TO_PTR(pregcomp))
158 /* Pointer to RE compiler */
159PERLVARI(Tregexecp, regexec_t, FUNC_NAME_TO_PTR(regexec_flags))
160 /* Pointer to RE executer */
161PERLVARI(Treginterp_cnt,int, 0) /* Whether `Regexp'
162 was interpolated. */
163
d4cce5f1 164
8b3be1d1 165/* Note that the variables below are all explicitly referenced in the code
cb68f92d 166 * as thr->whatever and therefore don't need the 'T' prefix. */
8b3be1d1 167
d4cce5f1 168#ifdef USE_THREADS
49f531da 169
cb68f92d
GS
170PERLVAR(oursv, SV *)
171PERLVAR(cvcache, HV *)
172PERLVAR(self, perl_os_thread) /* Underlying thread object */
173PERLVAR(flags, U32)
174PERLVAR(threadsv, AV *) /* Per-thread SVs ($_, $@ etc.) */
175PERLVAR(threadsvp, SV **) /* AvARRAY(threadsv) */
176PERLVAR(specific, AV *) /* Thread-specific user data */
177PERLVAR(errsv, SV *) /* Backing SV for $@ */
178PERLVAR(errhv, HV *) /* HV for what was %@ in pp_ctl.c */
179PERLVAR(mutex, perl_mutex) /* For the fields others can change */
180PERLVAR(tid, U32)
49f531da 181PERLVAR(prev, struct perl_thread *)
cb68f92d
GS
182PERLVAR(next, struct perl_thread *)
183 /* Circular linked list of threads */
49f531da
NIS
184
185#ifdef HAVE_THREAD_INTERN
cb68f92d
GS
186PERLVAR(i, struct thread_intern)
187 /* Platform-dependent internals */
49f531da
NIS
188#endif
189
cb68f92d 190PERLVAR(trailing_nul, char) /* For the sake of thrsv and oursv */
49f531da 191
d4cce5f1 192#endif /* USE_THREADS */