If not building threaded, never mind the threaded prototypes.
[p5sagit/p5-mst-13.2.git] / gv.h
CommitLineData
a0d0e21e 1/* gv.h
79072805 2 *
be3c0a43 3 * Copyright (c) 1991-2002, Larry Wall
79072805 4 *
5 * You may distribute under the terms of either the GNU General Public
6 * License or the Artistic License, as specified in the README file.
7 *
79072805 8 */
9
10struct gp {
11 SV * gp_sv; /* scalar value */
12 U32 gp_refcnt; /* how many globs point to this? */
13 struct io * gp_io; /* filehandle value */
14 CV * gp_form; /* format value */
15 AV * gp_av; /* array value */
aa689395 16 HV * gp_hv; /* hash value */
79072805 17 GV * gp_egv; /* effective gv, if *glob */
18 CV * gp_cv; /* subroutine value */
463ee0b2 19 U32 gp_cvgen; /* generational validity of cached gv_cv */
f4c556ac 20 U32 gp_flags; /* XXX unused */
79072805 21 line_t gp_line; /* line first declared at (for -w) */
b195d487 22 char * gp_file; /* file first declared in (for -w) */
79072805 23};
24
25#if defined(CRIPPLED_CC) && (defined(iAPX286) || defined(M_I286) || defined(I80286))
26#define MICROPORT
27#endif
28
29#define GvXPVGV(gv) ((XPVGV*)SvANY(gv))
30
a5f75d66 31#define GvGP(gv) (GvXPVGV(gv)->xgv_gp)
32#define GvNAME(gv) (GvXPVGV(gv)->xgv_name)
33#define GvNAMELEN(gv) (GvXPVGV(gv)->xgv_namelen)
34#define GvSTASH(gv) (GvXPVGV(gv)->xgv_stash)
35#define GvFLAGS(gv) (GvXPVGV(gv)->xgv_flags)
36
954c1994 37/*
ccfc67b7 38=head1 GV Functions
39
954c1994 40=for apidoc Am|SV*|GvSV|GV* gv
41
42Return the SV from the GV.
43
44=cut
45*/
46
79072805 47#define GvSV(gv) (GvGP(gv)->gp_sv)
48#define GvREFCNT(gv) (GvGP(gv)->gp_refcnt)
a0d0e21e 49#define GvIO(gv) ((gv) && SvTYPE((SV*)gv) == SVt_PVGV ? GvIOp(gv) : 0)
50#define GvIOp(gv) (GvGP(gv)->gp_io)
51#define GvIOn(gv) (GvIO(gv) ? GvIOp(gv) : GvIOp(gv_IOadd(gv)))
79072805 52
53#define GvFORM(gv) (GvGP(gv)->gp_form)
54#define GvAV(gv) (GvGP(gv)->gp_av)
44a8e56a 55
56/* This macro is deprecated. Do not use! */
57#define GvREFCNT_inc(gv) ((GV*)SvREFCNT_inc(gv)) /* DO NOT USE */
79072805 58
59#ifdef MICROPORT /* Microport 2.4 hack */
60AV *GvAVn();
61#else
62#define GvAVn(gv) (GvGP(gv)->gp_av ? \
63 GvGP(gv)->gp_av : \
64 GvGP(gv_AVadd(gv))->gp_av)
65#endif
66#define GvHV(gv) ((GvGP(gv))->gp_hv)
67
68#ifdef MICROPORT /* Microport 2.4 hack */
69HV *GvHVn();
70#else
71#define GvHVn(gv) (GvGP(gv)->gp_hv ? \
72 GvGP(gv)->gp_hv : \
73 GvGP(gv_HVadd(gv))->gp_hv)
74#endif /* Microport 2.4 hack */
75
76#define GvCV(gv) (GvGP(gv)->gp_cv)
463ee0b2 77#define GvCVGEN(gv) (GvGP(gv)->gp_cvgen)
8ebc5c01 78#define GvCVu(gv) (GvGP(gv)->gp_cvgen ? Nullcv : GvGP(gv)->gp_cv)
79072805 79
f4c556ac 80#define GvGPFLAGS(gv) (GvGP(gv)->gp_flags)
79072805 81
82#define GvLINE(gv) (GvGP(gv)->gp_line)
b195d487 83#define GvFILE(gv) (GvGP(gv)->gp_file)
57843af0 84#define GvFILEGV(gv) (gv_fetchfile(GvFILE(gv)))
79072805 85
79072805 86#define GvEGV(gv) (GvGP(gv)->gp_egv)
748a9306 87#define GvENAME(gv) GvNAME(GvEGV(gv) ? GvEGV(gv) : gv)
748a9306 88#define GvESTASH(gv) GvSTASH(GvEGV(gv) ? GvEGV(gv) : gv)
79072805 89
a5f75d66 90#define GVf_INTRO 0x01
91#define GVf_MULTI 0x02
92#define GVf_ASSUMECV 0x04
743e66e6 93#define GVf_IN_PAD 0x08
a5f75d66 94#define GVf_IMPORTED 0xF0
95#define GVf_IMPORTED_SV 0x10
96#define GVf_IMPORTED_AV 0x20
97#define GVf_IMPORTED_HV 0x40
98#define GVf_IMPORTED_CV 0x80
99
100#define GvINTRO(gv) (GvFLAGS(gv) & GVf_INTRO)
101#define GvINTRO_on(gv) (GvFLAGS(gv) |= GVf_INTRO)
102#define GvINTRO_off(gv) (GvFLAGS(gv) &= ~GVf_INTRO)
103
104#define GvMULTI(gv) (GvFLAGS(gv) & GVf_MULTI)
105#define GvMULTI_on(gv) (GvFLAGS(gv) |= GVf_MULTI)
106#define GvMULTI_off(gv) (GvFLAGS(gv) &= ~GVf_MULTI)
107
108#define GvASSUMECV(gv) (GvFLAGS(gv) & GVf_ASSUMECV)
109#define GvASSUMECV_on(gv) (GvFLAGS(gv) |= GVf_ASSUMECV)
110#define GvASSUMECV_off(gv) (GvFLAGS(gv) &= ~GVf_ASSUMECV)
111
112#define GvIMPORTED(gv) (GvFLAGS(gv) & GVf_IMPORTED)
113#define GvIMPORTED_on(gv) (GvFLAGS(gv) |= GVf_IMPORTED)
114#define GvIMPORTED_off(gv) (GvFLAGS(gv) &= ~GVf_IMPORTED)
115
116#define GvIMPORTED_SV(gv) (GvFLAGS(gv) & GVf_IMPORTED_SV)
117#define GvIMPORTED_SV_on(gv) (GvFLAGS(gv) |= GVf_IMPORTED_SV)
118#define GvIMPORTED_SV_off(gv) (GvFLAGS(gv) &= ~GVf_IMPORTED_SV)
119
120#define GvIMPORTED_AV(gv) (GvFLAGS(gv) & GVf_IMPORTED_AV)
121#define GvIMPORTED_AV_on(gv) (GvFLAGS(gv) |= GVf_IMPORTED_AV)
122#define GvIMPORTED_AV_off(gv) (GvFLAGS(gv) &= ~GVf_IMPORTED_AV)
123
124#define GvIMPORTED_HV(gv) (GvFLAGS(gv) & GVf_IMPORTED_HV)
125#define GvIMPORTED_HV_on(gv) (GvFLAGS(gv) |= GVf_IMPORTED_HV)
126#define GvIMPORTED_HV_off(gv) (GvFLAGS(gv) &= ~GVf_IMPORTED_HV)
127
128#define GvIMPORTED_CV(gv) (GvFLAGS(gv) & GVf_IMPORTED_CV)
129#define GvIMPORTED_CV_on(gv) (GvFLAGS(gv) |= GVf_IMPORTED_CV)
130#define GvIMPORTED_CV_off(gv) (GvFLAGS(gv) &= ~GVf_IMPORTED_CV)
131
743e66e6 132#define GvIN_PAD(gv) (GvFLAGS(gv) & GVf_IN_PAD)
133#define GvIN_PAD_on(gv) (GvFLAGS(gv) |= GVf_IN_PAD)
134#define GvIN_PAD_off(gv) (GvFLAGS(gv) &= ~GVf_IN_PAD)
135
5bd07a3d 136/* XXX: all GvFLAGS options are used, borrowing GvGPFLAGS for the moment */
137
7fb37951 138#define GVf_UNIQUE 0x0001
139#define GvUNIQUE(gv) (GvGP(gv) && (GvGPFLAGS(gv) & GVf_UNIQUE))
140#define GvUNIQUE_on(gv) (GvGPFLAGS(gv) |= GVf_UNIQUE)
141#define GvUNIQUE_off(gv) (GvGPFLAGS(gv) &= ~GVf_UNIQUE)
5bd07a3d 142
143#ifdef USE_ITHREADS
7fb37951 144#define GV_UNIQUE_CHECK
5bd07a3d 145#else
7fb37951 146#undef GV_UNIQUE_CHECK
5bd07a3d 147#endif
148
79072805 149#define Nullgv Null(GV*)
150
151#define DM_UID 0x003
152#define DM_RUID 0x001
153#define DM_EUID 0x002
154#define DM_GID 0x030
155#define DM_RGID 0x010
156#define DM_EGID 0x020
157#define DM_DELAY 0x100
158
0f303493 159/*
864dbfa3 160 * symbol creation flags, for use in gv_fetchpv() and get_*v()
0f303493 161 */
162#define GV_ADD 0x01 /* add, if symbol not already there */
163#define GV_ADDMULTI 0x02 /* add, pretending it has been added already */
164#define GV_ADDWARN 0x04 /* add, but warn if symbol wasn't already there */
165#define GV_ADDINEVAL 0x08 /* add, as though we're doing so within an eval */
166#define GV_NOINIT 0x10 /* add, but don't init symbol, if type != PVGV */