/* sv.h
*
* Copyright (C) 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
- * 2000, 2001, 2002, 2003, 2004, 2005 by Larry Wall and others
+ * 2000, 2001, 2002, 2003, 2004, 2005, 2006, 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.
SVt_LAST /* keep last in enum. used to size arrays */
} svtype;
+/* There is collusion here with sv_clear - sv_clear exits early for SVt_NULL
+ and SVt_IV, so never reaches the clause at the end that uses
+ sv_type_details->body_size to determine whether to call safefree(). Hence
+ body_size can be set no-zero to record the size of PTEs and HEs, without
+ fear of bogus frees. */
#ifdef PERL_IN_SV_C
-#define PTE_SVSLOT SVt_RV
+#define PTE_SVSLOT SVt_IV
+#endif
+#if defined(PERL_IN_HV_C) || defined(PERL_IN_XS_APITEST)
+#define HE_SVSLOT SVt_NULL
#endif
/* typedefs to eliminate some typing */
};
struct av {
- _SV_HEAD(XPVAV*); /* pointer to xpvcv body */
+ _SV_HEAD(XPVAV*); /* pointer to xpvav body */
_SV_HEAD_UNION;
};
};
#undef _SV_HEAD
-#undef _SV_HEAD_UNION /* insure no pollution */
+#undef _SV_HEAD_UNION /* ensure no pollution */
/*
=head1 SV Manipulation Functions
})
#else
# define SvREFCNT_inc(sv) \
- ((PL_Sv=(SV*)(sv)), (PL_Sv && ++(SvREFCNT(PL_Sv))), (SV*)PL_Sv)
+ ((PL_Sv=(SV*)(sv)) ? ((++(SvREFCNT(PL_Sv))),(PL_Sv)) : NULL)
#endif
#if defined(__GNUC__) && !defined(__STRICT_ANSI__) && !defined(PERL_GCC_PEDANTIC)
IV xivu_iv; /* integer value or pv offset */
UV xivu_uv;
void * xivu_p1;
+ I32 xivu_i32;
} xiv_u;
};
IV xivu_iv; /* integer value or pv offset */
UV xivu_uv;
void * xivu_p1;
+ I32 xivu_i32;
} xiv_u;
} xpviv_allocated;
#endif
IV xivu_iv; /* integer value or pv offset */
UV xivu_uv;
void * xivu_p1;
+ I32 xivu_i32;
} xiv_u;
};
IV xivu_iv; /* integer value or pv offset */
UV xivu_uv;
void * xivu_p1;
+ I32 xivu_i32;
} xiv_u;
MAGIC* xmg_magic; /* linked list of magicalness */
HV* xmg_stash; /* class package */
IV xivu_iv; /* integer value or pv offset */
UV xivu_uv;
void * xivu_p1;
+ I32 xivu_i32;
} xiv_u;
MAGIC* xmg_magic; /* linked list of magicalness */
HV* xmg_stash; /* class package */
IV xivu_iv; /* integer value or pv offset */
UV xivu_uv;
void * xivu_p1;
+ I32 xivu_i32;
} xiv_u;
MAGIC* xmg_magic; /* linked list of magicalness */
HV* xmg_stash; /* class package */
IV xivu_iv; /* integer value or pv offset */
UV xivu_uv;
void * xivu_p1;
+ I32 xivu_i32;
} xiv_u;
MAGIC* xmg_magic; /* linked list of magicalness */
HV* xmg_stash; /* class package */
STRLEN xpv_cur; /* length of svu_pv as a C string */
STRLEN xpv_len; /* allocated size */
union {
- IV xivu_iv; /* integer value or pv offset */
+ IV xivu_iv; /* PVFMs use the pv offset */
UV xivu_uv;
void * xivu_p1;
+ I32 xivu_i32;
} xiv_u;
MAGIC* xmg_magic; /* linked list of magicalness */
HV* xmg_stash; /* class package */
HV * xcv_stash;
- OP * xcv_start;
- OP * xcv_root;
- void (*xcv_xsub)(pTHX_ CV*);
- ANY xcv_xsubany;
+ union {
+ OP * xcv_start;
+ ANY xcv_xsubany;
+ } xcv_start_u;
+ union {
+ OP * xcv_root;
+ void (*xcv_xsub) (pTHX_ CV*);
+ } xcv_root_u;
GV * xcv_gv;
char * xcv_file;
- long xcv_depth; /* >= 2 indicates recursive call */
AV * xcv_padlist;
CV * xcv_outside;
- cv_flags_t xcv_flags;
U32 xcv_outside_seq; /* the COP sequence (at the point of our
* compilation) in the lexically enclosing
* sub */
+ cv_flags_t xcv_flags;
IV xfm_lines;
};
+typedef struct {
+ STRLEN xpv_cur; /* length of svu_pv as a C string */
+ STRLEN xpv_len; /* allocated size */
+ union {
+ IV xivu_iv; /* PVFMs use the pv offset */
+ UV xivu_uv;
+ void * xivu_p1;
+ I32 xivu_i32;
+ } xiv_u;
+ MAGIC* xmg_magic; /* linked list of magicalness */
+ HV* xmg_stash; /* class package */
+
+ HV * xcv_stash;
+ union {
+ OP * xcv_start;
+ ANY xcv_xsubany;
+ } xcv_start_u;
+ union {
+ OP * xcv_root;
+ void (*xcv_xsub) (pTHX_ CV*);
+ } xcv_root_u;
+ GV * xcv_gv;
+ char * xcv_file;
+ AV * xcv_padlist;
+ CV * xcv_outside;
+ U32 xcv_outside_seq; /* the COP sequence (at the point of our
+ * compilation) in the lexically enclosing
+ * sub */
+ cv_flags_t xcv_flags;
+ IV xfm_lines;
+} xpvfm_allocated;
+
struct xpvio {
NV xnv_nv; /* numeric value, if any */
STRLEN xpv_cur; /* length of svu_pv as a C string */
IV xivu_iv; /* integer value or pv offset */
UV xivu_uv;
void * xivu_p1;
+ I32 xivu_i32;
} xiv_u;
MAGIC* xmg_magic; /* linked list of magicalness */
HV* xmg_stash; /* class package */
SVf_IVisUV), \
SvFLAGS(sv) |= (SVf_POK|SVp_POK))
-#define SvVOK(sv) (SvMAGICAL(sv) && mg_find(sv,'V'))
+#define SvVOK(sv) (SvMAGICAL(sv) \
+ ? mg_find(sv,PERL_MAGIC_vstring) : NULL)
#define SvOOK(sv) (SvFLAGS(sv) & SVf_OOK)
#define SvOOK_on(sv) ((void)SvIOK_off(sv), SvFLAGS(sv) |= SVf_OOK)
#define SvOOK_off(sv) ((void)(SvOOK(sv) && sv_backoff(sv)))
# define SvSTASH(sv) (0 + ((XPVMG*) SvANY(sv))->xmg_stash)
# endif
#else
-# define SvIVX(sv) ((XPVIV*) SvANY(sv))->xiv_iv
-# define SvUVX(sv) ((XPVUV*) SvANY(sv))->xuv_uv
-# define SvNVX(sv) ((XPVNV*) SvANY(sv))->xnv_nv
# define SvPVX(sv) ((sv)->sv_u.svu_pv)
# define SvCUR(sv) ((XPV*) SvANY(sv))->xpv_cur
# define SvLEN(sv) ((XPV*) SvANY(sv))->xpv_len
# define SvEND(sv) ((sv)->sv_u.svu_pv + ((XPV*)SvANY(sv))->xpv_cur)
-# ifdef DEBUGGING
-# define SvMAGIC(sv) (*(assert(SvTYPE(sv) >= SVt_PVMG), &((XPVMG*) SvANY(sv))->xmg_magic))
-# define SvSTASH(sv) (*(assert(SvTYPE(sv) >= SVt_PVMG), &((XPVMG*) SvANY(sv))->xmg_stash))
+# if defined (DEBUGGING) && defined(__GNUC__) && !defined(PERL_GCC_BRACE_GROUPS_FORBIDDEN)
+/* These get expanded inside other macros that already use a variable _sv */
+# define SvIVX(sv) \
+ (*({ SV *const _svi = (SV *) sv; \
+ assert(SvTYPE(_svi) == SVt_IV || SvTYPE(_svi) >= SVt_PVIV); \
+ assert(SvTYPE(_svi) != SVt_PVAV); \
+ assert(SvTYPE(_svi) != SVt_PVHV); \
+ assert(SvTYPE(_svi) != SVt_PVCV); \
+ &(((XPVIV*) SvANY(_svi))->xiv_iv); \
+ }))
+# define SvUVX(sv) \
+ (*({ SV *const _svi = (SV *) sv; \
+ assert(SvTYPE(_svi) == SVt_IV || SvTYPE(_svi) >= SVt_PVIV); \
+ assert(SvTYPE(_svi) != SVt_PVAV); \
+ assert(SvTYPE(_svi) != SVt_PVHV); \
+ assert(SvTYPE(_svi) != SVt_PVCV); \
+ &(((XPVUV*) SvANY(_svi))->xuv_uv); \
+ }))
+# define SvNVX(sv) \
+ (*({ SV *const _svi = (SV *) sv; \
+ assert(SvTYPE(_svi) == SVt_NV || SvTYPE(_svi) >= SVt_PVNV); \
+ assert(SvTYPE(_svi) != SVt_PVAV); \
+ assert(SvTYPE(_svi) != SVt_PVHV); \
+ assert(SvTYPE(_svi) != SVt_PVFM); \
+ &(((XPVNV*) SvANY(_svi))->xnv_nv); \
+ }))
+# define SvMAGIC(sv) \
+ (*({ SV *const _svi = (SV *) sv; \
+ assert(SvTYPE(_svi) >= SVt_PVMG); \
+ &(((XPVMG*) SvANY(_svi))->xmg_magic); \
+ }))
+# define SvSTASH(sv) \
+ (*({ SV *const _svi = (SV *) sv; \
+ assert(SvTYPE(_svi) >= SVt_PVMG); \
+ &(((XPVMG*) SvANY(_svi))->xmg_stash); \
+ }))
# else
+# define SvIVX(sv) ((XPVIV*) SvANY(sv))->xiv_iv
+# define SvUVX(sv) ((XPVUV*) SvANY(sv))->xuv_uv
+# define SvNVX(sv) ((XPVNV*) SvANY(sv))->xnv_nv
# define SvMAGIC(sv) ((XPVMG*) SvANY(sv))->xmg_magic
# define SvSTASH(sv) ((XPVMG*) SvANY(sv))->xmg_stash
# endif
=cut
*/
-#define sv_taint(sv) sv_magic((sv), Nullsv, PERL_MAGIC_taint, Nullch, 0)
+#define sv_taint(sv) sv_magic((sv), NULL, PERL_MAGIC_taint, NULL, 0)
#define SvTAINTED(sv) (SvMAGICAL(sv) && sv_tainted(sv))
#define SvTAINTED_on(sv) STMT_START{ if(PL_tainting){sv_taint(sv);} }STMT_END