summaryrefslogtreecommitdiff
path: root/gnu/usr.bin/perl/gv.h
diff options
context:
space:
mode:
authorTodd C. Miller <millert@cvs.openbsd.org>2008-09-29 17:36:25 +0000
committerTodd C. Miller <millert@cvs.openbsd.org>2008-09-29 17:36:25 +0000
commit00dd722c5378e478eed4daa17120ab518ad2f0b8 (patch)
treedaf0e090e9719c0407f3a6b208b46b6cc2645a55 /gnu/usr.bin/perl/gv.h
parentbfa863c83bfd01d72a748decaaf2676b800c60ff (diff)
fix conflicts and merge in local changes to perl 5.10.0
Diffstat (limited to 'gnu/usr.bin/perl/gv.h')
-rw-r--r--gnu/usr.bin/perl/gv.h111
1 files changed, 86 insertions, 25 deletions
diff --git a/gnu/usr.bin/perl/gv.h b/gnu/usr.bin/perl/gv.h
index 26da75818c9..fbd7e344f31 100644
--- a/gnu/usr.bin/perl/gv.h
+++ b/gnu/usr.bin/perl/gv.h
@@ -1,7 +1,7 @@
/* gv.h
*
* Copyright (C) 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
- * 2000, 2001, 2002, 2003, 2004, 2005, 2006, by Larry Wall and others
+ * 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, by Larry Wall and others
*
* You may distribute under the terms of either the GNU General Public
* License or the Artistic License, as specified in the README file.
@@ -10,26 +10,63 @@
struct gp {
SV * gp_sv; /* scalar value */
- U32 gp_refcnt; /* how many globs point to this? */
struct io * gp_io; /* filehandle value */
- CV * gp_form; /* format value */
- AV * gp_av; /* array value */
- HV * gp_hv; /* hash value */
- GV * gp_egv; /* effective gv, if *glob */
CV * gp_cv; /* subroutine value */
U32 gp_cvgen; /* generational validity of cached gv_cv */
- U32 gp_flags; /* XXX unused */
+ U32 gp_refcnt; /* how many globs point to this? */
+ HV * gp_hv; /* hash value */
+ AV * gp_av; /* array value */
+ CV * gp_form; /* format value */
+ GV * gp_egv; /* effective gv, if *glob */
line_t gp_line; /* line first declared at (for -w) */
- char * gp_file; /* file first declared in (for -w) */
+ HEK * gp_file_hek; /* file first declared in (for -w) */
};
#define GvXPVGV(gv) ((XPVGV*)SvANY(gv))
-#define GvGP(gv) (GvXPVGV(gv)->xgv_gp)
-#define GvNAME(gv) (GvXPVGV(gv)->xgv_name)
-#define GvNAMELEN(gv) (GvXPVGV(gv)->xgv_namelen)
-#define GvSTASH(gv) (GvXPVGV(gv)->xgv_stash)
-#define GvFLAGS(gv) (GvXPVGV(gv)->xgv_flags)
+
+#if defined (DEBUGGING) && defined(__GNUC__) && !defined(PERL_GCC_BRACE_GROUPS_FORBIDDEN) && !defined(__INTEL_COMPILER)
+# define GvGP(gv) \
+ (*({GV *const shplep = (GV *) (gv); \
+ assert(SvTYPE(shplep) == SVt_PVGV || SvTYPE(shplep) == SVt_PVLV); \
+ assert(isGV_with_GP(shplep)); \
+ &((shplep)->sv_u.svu_gp);}))
+# define GvFLAGS(gv) \
+ (*({GV *const yaah = (GV *) (gv); \
+ assert(SvTYPE(yaah) == SVt_PVGV || SvTYPE(yaah) == SVt_PVLV); \
+ assert(isGV_with_GP(yaah)); \
+ &(GvXPVGV(yaah)->xpv_cur);}))
+# define GvSTASH(gv) \
+ (*({ GV * const _gv = (GV *) (gv); \
+ assert(isGV_with_GP(_gv)); \
+ assert(SvTYPE(_gv) == SVt_PVGV || SvTYPE(_gv) >= SVt_PVLV); \
+ &(GvXPVGV(_gv)->xnv_u.xgv_stash); \
+ }))
+# define GvNAME_HEK(gv) \
+ (*({ GV * const zzzz = (GV *) (gv); \
+ assert(isGV_with_GP(zzzz)); \
+ assert(SvTYPE(zzzz) == SVt_PVGV || SvTYPE(zzzz) >= SVt_PVLV); \
+ assert(!SvVALID(zzzz)); \
+ &(GvXPVGV(zzzz)->xiv_u.xivu_namehek); \
+ }))
+# define GvNAME_get(gv) ({ assert(GvNAME_HEK(gv)); HEK_KEY(GvNAME_HEK(gv)); })
+# define GvNAMELEN_get(gv) ({ assert(GvNAME_HEK(gv)); HEK_LEN(GvNAME_HEK(gv)); })
+#else
+# define GvGP(gv) ((gv)->sv_u.svu_gp)
+# define GvFLAGS(gv) (GvXPVGV(gv)->xpv_cur)
+# define GvSTASH(gv) (GvXPVGV(gv)->xnv_u.xgv_stash)
+# define GvNAME_HEK(gv) (GvXPVGV(gv)->xiv_u.xivu_namehek)
+# define GvNAME_get(gv) HEK_KEY(GvNAME_HEK(gv))
+# define GvNAMELEN_get(gv) HEK_LEN(GvNAME_HEK(gv))
+#endif
+
+#define GvNAME(gv) GvNAME_get(gv)
+#define GvNAMELEN(gv) GvNAMELEN_get(gv)
+
+#define GvASSIGN_GENERATION(gv) (0 + ((XPV*) SvANY(gv))->xpv_len)
+#define GvASSIGN_GENERATION_set(gv,val) \
+ STMT_START { assert(SvTYPE(gv) == SVt_PVGV); \
+ (((XPV*) SvANY(gv))->xpv_len = (val)); } STMT_END
/*
=head1 GV Functions
@@ -51,7 +88,7 @@ Return the SV from the GV.
#endif
#define GvREFCNT(gv) (GvGP(gv)->gp_refcnt)
-#define GvIO(gv) ((gv) && SvTYPE((SV*)gv) == SVt_PVGV && GvGP(gv) ? GvIOp(gv) : 0)
+#define GvIO(gv) ((gv) && SvTYPE((SV*)gv) == SVt_PVGV && GvGP(gv) ? GvIOp(gv) : NULL)
#define GvIOp(gv) (GvGP(gv)->gp_io)
#define GvIOn(gv) (GvIO(gv) ? GvIOp(gv) : GvIOp(gv_IOadd(gv)))
@@ -72,12 +109,11 @@ Return the SV from the GV.
#define GvCV(gv) (GvGP(gv)->gp_cv)
#define GvCVGEN(gv) (GvGP(gv)->gp_cvgen)
-#define GvCVu(gv) (GvGP(gv)->gp_cvgen ? Nullcv : GvGP(gv)->gp_cv)
-
-#define GvGPFLAGS(gv) (GvGP(gv)->gp_flags)
+#define GvCVu(gv) (GvGP(gv)->gp_cvgen ? NULL : GvGP(gv)->gp_cv)
#define GvLINE(gv) (GvGP(gv)->gp_line)
-#define GvFILE(gv) (GvGP(gv)->gp_file)
+#define GvFILE_HEK(gv) (GvGP(gv)->gp_file_hek)
+#define GvFILE(gv) (GvFILE_HEK(gv) ? HEK_KEY(GvFILE_HEK(gv)) : NULL)
#define GvFILEGV(gv) (gv_fetchfile(GvFILE(gv)))
#define GvEGV(gv) (GvGP(gv)->gp_egv)
@@ -130,12 +166,9 @@ Return the SV from the GV.
#define GvIN_PAD_on(gv) (GvFLAGS(gv) |= GVf_IN_PAD)
#define GvIN_PAD_off(gv) (GvFLAGS(gv) &= ~GVf_IN_PAD)
-/* XXX: all GvFLAGS options are used, borrowing GvGPFLAGS for the moment */
-
-#define GVf_UNIQUE 0x0001
-#define GvUNIQUE(gv) (GvGP(gv) && (GvGPFLAGS(gv) & GVf_UNIQUE))
-#define GvUNIQUE_on(gv) (GvGPFLAGS(gv) |= GVf_UNIQUE)
-#define GvUNIQUE_off(gv) (GvGPFLAGS(gv) &= ~GVf_UNIQUE)
+#define GvUNIQUE(gv) 0
+#define GvUNIQUE_on(gv) NOOP
+#define GvUNIQUE_off(gv) NOOP
#ifdef USE_ITHREADS
#define GV_UNIQUE_CHECK
@@ -148,6 +181,7 @@ Return the SV from the GV.
#define DM_UID 0x003
#define DM_RUID 0x001
#define DM_EUID 0x002
+#define DM_ARRAY 0x004
#define DM_GID 0x030
#define DM_RGID 0x010
#define DM_EGID 0x020
@@ -156,11 +190,38 @@ Return the SV from the GV.
/*
* symbol creation flags, for use in gv_fetchpv() and get_*v()
*/
-#define GV_ADD 0x01 /* add, if symbol not already there */
+#define GV_ADD 0x01 /* add, if symbol not already there
+ For gv_name_set, adding a HEK for the first
+ time, so don't try to free what's there. */
#define GV_ADDMULTI 0x02 /* add, pretending it has been added already */
#define GV_ADDWARN 0x04 /* add, but warn if symbol wasn't already there */
#define GV_ADDINEVAL 0x08 /* add, as though we're doing so within an eval */
#define GV_NOINIT 0x10 /* add, but don't init symbol, if type != PVGV */
+/* This is used by toke.c to avoid turing placeholder constants in the symbol
+ table into full PVGVs with attached constant subroutines. */
+#define GV_NOADD_NOINIT 0x20 /* Don't add the symbol if it's not there.
+ Don't init it if it is there but ! PVGV */
+#define GV_NOEXPAND 0x40 /* Don't expand SvOK() entries to PVGV */
+#define GV_NOTQUAL 0x80 /* A plain symbol name, not qualified with a
+ package (so skip checks for :: and ') */
+
+/* SVf_UTF8 (more accurately the return value from SvUTF8) is also valid
+ as a flag to gv_fetch_pvn_flags, so ensure it lies outside this range.
+*/
+
+#define GV_NOADD_MASK (SVf_UTF8|GV_NOADD_NOINIT|GV_NOEXPAND|GV_NOTQUAL)
+/* The bit flags that don't cause gv_fetchpv() to add a symbol if not found */
#define gv_fullname3(sv,gv,prefix) gv_fullname4(sv,gv,prefix,TRUE)
#define gv_efullname3(sv,gv,prefix) gv_efullname4(sv,gv,prefix,TRUE)
+#define gv_fetchmethod(stash, name) gv_fetchmethod_autoload(stash, name, TRUE)
+
+/*
+ * Local variables:
+ * c-indentation-style: bsd
+ * c-basic-offset: 4
+ * indent-tabs-mode: t
+ * End:
+ *
+ * ex: set ts=8 sts=4 sw=4 noet:
+ */