/* sv.h
*
* Copyright (C) 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
- * 2000, 2001, 2002, 2003, 2004, by Larry Wall and others
+ * 2000, 2001, 2002, 2003, 2004, 2005 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.
void* sv_any; /* pointer to something */
U32 sv_refcnt; /* how many references to us */
U32 sv_flags; /* what we are */
+#ifdef DEBUG_LEAKING_SCALARS
+ unsigned sv_debug_optype:9; /* the type of OP that allocated us */
+ unsigned sv_debug_inpad:1; /* was allocated in a pad for an OP */
+ unsigned sv_debug_cloned:1; /* was cloned for an ithread */
+ unsigned sv_debug_line:16; /* the line where we were allocated */
+ char * sv_debug_file; /* the file where we were allocated */
+#endif
};
struct gv {
#define SVp_SCREAM 0x08000000 /* has been studied? */
#define SVf_UTF8 0x20000000 /* SvPV is UTF-8 encoded */
+/* Ensure this value does not clash with the GV_ADD* flags in gv.h */
#define SVf_THINKFIRST (SVf_READONLY|SVf_ROK|SVf_FAKE)
=cut
*/
+/* Ensure the return value of this macro does not clash with the GV_ADD* flags
+in gv.h: */
#define SvUTF8(sv) (SvFLAGS(sv) & SVf_UTF8)
#define SvUTF8_on(sv) (SvFLAGS(sv) |= (SVf_UTF8))
#define SvUTF8_off(sv) (SvFLAGS(sv) &= ~(SVf_UTF8))
#define SvRV(sv) ((XRV*) SvANY(sv))->xrv_rv
#define SvRVx(sv) SvRV(sv)
+#ifdef PERL_DEBUG_COW
+#define SvIVX(sv) (0 + ((XPVIV*) SvANY(sv))->xiv_iv)
+#define SvUVX(sv) ((XPVUV*) SvANY(sv))->xuv_uv
+#define SvNVX(sv) (0.0 + ((XPVNV*)SvANY(sv))->xnv_nv)
+#else
#define SvIVX(sv) ((XPVIV*) SvANY(sv))->xiv_iv
-#define SvIVXx(sv) SvIVX(sv)
#define SvUVX(sv) ((XPVUV*) SvANY(sv))->xuv_uv
-#define SvUVXx(sv) SvUVX(sv)
-#define SvNVX(sv) ((XPVNV*)SvANY(sv))->xnv_nv
-#define SvNVXx(sv) SvNVX(sv)
+#define SvNVX(sv) ((XPVNV*)SvANY(sv))->xnv_nv
+#endif
#define SvPVX(sv) ((XPV*) SvANY(sv))->xpv_pv
-#define SvPVXx(sv) SvPVX(sv)
#define SvCUR(sv) ((XPV*) SvANY(sv))->xpv_cur
#define SvLEN(sv) ((XPV*) SvANY(sv))->xpv_len
-#define SvLENx(sv) SvLEN(sv)
#define SvEND(sv)(((XPV*) SvANY(sv))->xpv_pv + ((XPV*)SvANY(sv))->xpv_cur)
+
+#define SvIVXx(sv) SvIVX(sv)
+#define SvUVXx(sv) SvUVX(sv)
+#define SvNVXx(sv) SvNVX(sv)
+#define SvPVXx(sv) SvPVX(sv)
+#define SvLENx(sv) SvLEN(sv)
#define SvENDx(sv) ((PL_Sv = (sv)), SvEND(PL_Sv))
#ifdef DEBUGGING
(void) SvIV(sv); } STMT_END
#define SvIV_set(sv, val) \
STMT_START { assert(SvTYPE(sv) == SVt_IV || SvTYPE(sv) >= SVt_PVIV); \
- (SvIVX(sv) = (val)); } STMT_END
+ (((XPVIV*) SvANY(sv))->xiv_iv = (val)); } STMT_END
#define SvNV_set(sv, val) \
STMT_START { assert(SvTYPE(sv) == SVt_NV || SvTYPE(sv) >= SVt_PVNV); \
- (SvNVX(sv) = (val)); } STMT_END
+ (((XPVNV*)SvANY(sv))->xnv_nv = (val)); } STMT_END
#define SvPV_set(sv, val) \
STMT_START { assert(SvTYPE(sv) >= SVt_PV); \
(SvPVX(sv) = (val)); } STMT_END