=for apidoc Am|SV*|SvREFCNT_inc|SV* sv
Increments the reference count of the given SV.
+All of the following SvREFCNT_inc* macros are optimized versions of
+SvREFCNT_inc, and can be replaced with SvREFCNT_inc.
+
+=for apidoc Am|SV*|SvREFCNT_inc_NN|SV* sv
+Same as SvREFCNT_inc, but can only be used if you know I<sv>
+is not NULL. Since we don't have to check the NULLness, it's faster
+and smaller.
+
+=for apidoc Am|SV*|SvREFCNT_inc_void|SV* sv
+Same as SvREFCNT_inc, but can only be used if you don't need the
+return value. The macro doesn't need to return a meaningful value.
+
+=for apidoc Am|SV*|SvREFCNT_inc_void_NN|SV* sv
+Same as SvREFCNT_inc, but can only be used if you don't need the return
+value, and you know that I<sv> is not NULL. The macro doesn't need
+to return a meaningful value, or check for NULLness, so it's smaller
+and faster.
+
+=for apidoc Am|SV*|SvREFCNT_inc_simple|SV* sv
+Same as SvREFCNT_inc, but can only be used with simple variables, not
+expressions or pointer dereferences. Since we don't have to store a
+temporary value, it's faster.
+
+=for apidoc Am|SV*|SvREFCNT_inc_simple_NN|SV* sv
+Same as SvREFCNT_inc_simple, but can only be used if you know I<sv>
+is not NULL. Since we don't have to check the NULLness, it's faster
+and smaller.
+
+=for apidoc Am|SV*|SvREFCNT_inc_simple_void|SV* sv
+Same as SvREFCNT_inc_simple, but can only be used if you don't need the
+return value. The macro doesn't need to return a meaningful value.
+
+=for apidoc Am|SV*|SvREFCNT_inc|SV* sv
+Increments the reference count of the given SV.
+
=for apidoc Am|void|SvREFCNT_dec|SV* sv
Decrements the reference count of the given SV.
(SvREFCNT(_sv))++; \
_sv; \
})
+# define SvREFCNT_inc_simple(sv) \
+ ({ \
+ if (sv) \
+ (SvREFCNT(sv))++; \
+ (SV *)(sv); \
+ })
+# define SvREFCNT_inc_NN(sv) \
+ ({ \
+ SV * const _sv = (SV*)(sv); \
+ SvREFCNT(_sv)++; \
+ _sv; \
+ })
+# define SvREFCNT_inc_void(sv) \
+ ({ \
+ SV * const _sv = (SV*)(sv); \
+ if (_sv) \
+ (void)(SvREFCNT(_sv)++); \
+ })
#else
# define SvREFCNT_inc(sv) \
- ((PL_Sv=(SV*)(sv)) ? ((++(SvREFCNT(PL_Sv))),(PL_Sv)) : NULL)
+ ((PL_Sv=(SV*)(sv)) ? (++(SvREFCNT(PL_Sv)),PL_Sv) : NULL)
+# define SvREFCNT_inc_simple(sv) \
+ ((sv) ? (SvREFCNT(sv)++,(SV*)(sv)) : NULL)
+# define SvREFCNT_inc_NN(sv) \
+ (PL_Sv=(SV*)(sv),++(SvREFCNT(PL_Sv)),PL_Sv)
+# define SvREFCNT_inc_void(sv) \
+ (void)((PL_Sv=(SV*)(sv)) ? ++(SvREFCNT(PL_Sv)) : 0)
#endif
+/* These guys don't need the curly blocks */
+#define SvREFCNT_inc_simple_void(sv) if (sv) (SvREFCNT(sv)++);
+#define SvREFCNT_inc_simple_NN(sv) (++(SvREFCNT(sv)),(SV*)(sv))
+#define SvREFCNT_inc_void_NN(sv) (void)(++SvREFCNT((SV*)(sv)))
+#define SvREFCNT_inc_simple_void_NN(sv) (void)(++SvREFCNT((SV*)(sv)))
+
#if defined(__GNUC__) && !defined(__STRICT_ANSI__) && !defined(PERL_GCC_PEDANTIC)
# define SvREFCNT_dec(sv) \
({ \
struct xpv {
- NV xnv_nv; /* numeric value, if any */
+ union {
+ NV xnv_nv; /* numeric value, if any */
+ HV * xgv_stash;
+ } xnv_u;
STRLEN xpv_cur; /* length of svu_pv as a C string */
STRLEN xpv_len; /* allocated size */
};
#endif
struct xpviv {
- NV xnv_nv; /* numeric value, if any */
+ union {
+ NV xnv_nv; /* numeric value, if any */
+ HV * xgv_stash;
+ } xnv_u;
STRLEN xpv_cur; /* length of svu_pv as a C string */
STRLEN xpv_len; /* allocated size */
union {
UV xivu_uv;
void * xivu_p1;
I32 xivu_i32;
+ HEK * xivu_namehek;
} xiv_u;
};
UV xivu_uv;
void * xivu_p1;
I32 xivu_i32;
+ HEK * xivu_namehek;
} xiv_u;
} xpviv_allocated;
#endif
#define xiv_iv xiv_u.xivu_iv
struct xpvuv {
- NV xnv_nv; /* numeric value, if any */
+ union {
+ NV xnv_nv; /* numeric value, if any */
+ HV * xgv_stash;
+ } xnv_u;
STRLEN xpv_cur; /* length of svu_pv as a C string */
STRLEN xpv_len; /* allocated size */
union {
IV xuvu_iv;
UV xuvu_uv; /* unsigned value or pv offset */
void * xuvu_p1;
+ HEK * xivu_namehek;
} xuv_u;
};
#define xuv_uv xuv_u.xuvu_uv
struct xpvnv {
- NV xnv_nv; /* numeric value, if any */
+ union {
+ NV xnv_nv; /* numeric value, if any */
+ HV * xgv_stash;
+ } xnv_u;
STRLEN xpv_cur; /* length of svu_pv as a C string */
STRLEN xpv_len; /* allocated size */
union {
UV xivu_uv;
void * xivu_p1;
I32 xivu_i32;
+ HEK * xivu_namehek;
} xiv_u;
};
/* These structure must match the beginning of struct xpvhv in hv.h. */
struct xpvmg {
- NV xnv_nv; /* numeric value, if any */
+ union {
+ NV xnv_nv; /* numeric value, if any */
+ HV * xgv_stash;
+ } xnv_u;
STRLEN xpv_cur; /* length of svu_pv as a C string */
STRLEN xpv_len; /* allocated size */
union {
UV xivu_uv;
void * xivu_p1;
I32 xivu_i32;
+ HEK * xivu_namehek;
} xiv_u;
union {
MAGIC* xmg_magic; /* linked list of magicalness */
};
struct xpvlv {
- NV xnv_nv; /* numeric value, if any */
+ union {
+ NV xnv_nv; /* numeric value, if any */
+ HV * xgv_stash;
+ } xnv_u;
STRLEN xpv_cur; /* length of svu_pv as a C string */
STRLEN xpv_len; /* allocated size */
union {
UV xivu_uv;
void * xivu_p1;
I32 xivu_i32;
+ HEK * xivu_namehek; /* GvNAME */
} xiv_u;
union {
MAGIC* xmg_magic; /* linked list of magicalness */
} xmg_u;
HV* xmg_stash; /* class package */
- /* a full glob fits into this */
- char* xgv_name;
- STRLEN xgv_namelen;
- HV* xgv_stash;
- U8 xgv_flags;
-
STRLEN xlv_targoff;
STRLEN xlv_targlen;
SV* xlv_targ;
};
struct xpvgv {
- NV xnv_nv; /* numeric value, if any */
- 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 */
+ NV xnv_nv;
+ HV * xgv_stash; /* The stash of this GV */
+ } xnv_u;
+ STRLEN xpv_cur; /* xgv_flags */
+ STRLEN xpv_len; /* 0 */
+ union {
+ IV xivu_iv;
UV xivu_uv;
void * xivu_p1;
I32 xivu_i32;
+ HEK * xivu_namehek; /* GvNAME */
} xiv_u;
union {
MAGIC* xmg_magic; /* linked list of magicalness */
} xmg_u;
HV* xmg_stash; /* class package */
- char* xgv_name;
- STRLEN xgv_namelen;
- HV* xgv_stash;
- U8 xgv_flags;
};
struct xpvbm {
- NV xnv_nv; /* numeric value, if any */
+ union {
+ NV xnv_nv; /* numeric value, if any */
+ HV * xgv_stash;
+ } xnv_u;
STRLEN xpv_cur; /* length of svu_pv as a C string */
STRLEN xpv_len; /* allocated size */
union {
UV xivu_uv;
void * xivu_p1;
I32 xivu_i32;
+ HEK * xivu_namehek;
} xiv_u;
union {
MAGIC* xmg_magic; /* linked list of magicalness */
typedef U16 cv_flags_t;
struct xpvfm {
- NV xnv_nv; /* numeric value, if any */
+ union {
+ NV xnv_nv; /* numeric value, if any */
+ HV * xgv_stash;
+ } xnv_u;
STRLEN xpv_cur; /* length of svu_pv as a C string */
STRLEN xpv_len; /* allocated size */
union {
UV xivu_uv;
void * xivu_p1;
I32 xivu_i32;
+ HEK * xivu_namehek;
} xiv_u;
union {
MAGIC* xmg_magic; /* linked list of magicalness */
UV xivu_uv;
void * xivu_p1;
I32 xivu_i32;
+ HEK * xivu_namehek;
} xiv_u;
union {
MAGIC* xmg_magic; /* linked list of magicalness */
} xpvfm_allocated;
struct xpvio {
- NV xnv_nv; /* numeric value, if any */
+ union {
+ NV xnv_nv; /* numeric value, if any */
+ HV * xgv_stash;
+ } xnv_u;
STRLEN xpv_cur; /* length of svu_pv as a C string */
STRLEN xpv_len; /* allocated size */
union {
UV xivu_uv;
void * xivu_p1;
I32 xivu_i32;
+ HEK * xivu_namehek;
} xiv_u;
union {
MAGIC* xmg_magic; /* linked list of magicalness */
+0.0 + -0.0 => +0.0 but -0.0 + -0.0 => -0.0 */
# define SvIVX(sv) (0 + ((XPVIV*) SvANY(sv))->xiv_iv)
# define SvUVX(sv) (0 + ((XPVUV*) SvANY(sv))->xuv_uv)
-# define SvNVX(sv) (-0.0 + ((XPVNV*) SvANY(sv))->xnv_nv)
+# define SvNVX(sv) (-0.0 + ((XPVNV*) SvANY(sv))->xnv_u.xnv_nv)
/* Don't test the core XS code yet. */
# if defined (PERL_CORE) && PERL_DEBUG_COW > 1
# define SvPVX(sv) (0 + (assert(!SvREADONLY(sv)), (sv)->sv_u.svu_pv))
# define SvSTASH(sv) (0 + ((XPVMG*) SvANY(sv))->xmg_stash)
# endif
#else
-# 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)
assert(!isGV_with_GP(_svi)); \
&((_svi)->sv_u.svu_pv); \
}))
+# define SvCUR(sv) \
+ (*({ SV *const _svi = (SV *) sv; \
+ assert(SvTYPE(_svi) >= SVt_PV); \
+ assert(SvTYPE(_svi) != SVt_PVAV); \
+ assert(SvTYPE(_svi) != SVt_PVHV); \
+ assert(!isGV_with_GP(_svi)); \
+ &(((XPV*) SvANY(_svi))->xpv_cur); \
+ }))
# define SvIVX(sv) \
(*({ SV *const _svi = (SV *) sv; \
assert(SvTYPE(_svi) == SVt_IV || SvTYPE(_svi) >= SVt_PVIV); \
assert(SvTYPE(_svi) != SVt_PVHV); \
assert(SvTYPE(_svi) != SVt_PVFM); \
assert(!isGV_with_GP(_svi)); \
- &(((XPVNV*) SvANY(_svi))->xnv_nv); \
+ &(((XPVNV*) SvANY(_svi))->xnv_u.xnv_nv); \
}))
# define SvMAGIC(sv) \
(*({ SV *const _svi = (SV *) sv; \
&(((XPVMG*) SvANY(_svi))->xmg_stash); \
}))
# else
-# define SvPVX(sv) ((sv)->sv_u.svu_pv)
+# define SvPVX(sv) ((sv)->sv_u.svu_pv)
+# define SvCUR(sv) ((XPV*) SvANY(sv))->xpv_cur
# 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 SvNVX(sv) ((XPVNV*) SvANY(sv))->xnv_u.xnv_nv
# define SvMAGIC(sv) ((XPVMG*) SvANY(sv))->xmg_u.xmg_magic
# define SvSTASH(sv) ((XPVMG*) SvANY(sv))->xmg_stash
# endif
(void) SvIV(sv); } STMT_END
#define SvIV_set(sv, val) \
STMT_START { assert(SvTYPE(sv) == SVt_IV || SvTYPE(sv) >= SVt_PVIV); \
+ assert(!isGV_with_GP(sv)); \
(((XPVIV*) SvANY(sv))->xiv_iv = (val)); } STMT_END
#define SvNV_set(sv, val) \
STMT_START { assert(SvTYPE(sv) == SVt_NV || SvTYPE(sv) >= SVt_PVNV); \
assert(SvTYPE(sv) != SVt_PVAV); assert(SvTYPE(sv) != SVt_PVHV); \
- (((XPVNV*)SvANY(sv))->xnv_nv = (val)); } STMT_END
+ assert(!isGV_with_GP(sv)); \
+ (((XPVNV*)SvANY(sv))->xnv_u.xnv_nv = (val)); } STMT_END
#define SvPV_set(sv, val) \
STMT_START { assert(SvTYPE(sv) >= SVt_PV); \
+ assert(!isGV_with_GP(sv)); \
((sv)->sv_u.svu_pv = (val)); } STMT_END
#define SvUV_set(sv, val) \
STMT_START { assert(SvTYPE(sv) == SVt_IV || SvTYPE(sv) >= SVt_PVIV); \
+ assert(!isGV_with_GP(sv)); \
(((XPVUV*)SvANY(sv))->xuv_uv = (val)); } STMT_END
#define SvRV_set(sv, val) \
STMT_START { assert(SvTYPE(sv) >= SVt_RV); \
+ assert(!isGV_with_GP(sv)); \
((sv)->sv_u.svu_rv = (val)); } STMT_END
#define SvMAGIC_set(sv, val) \
STMT_START { assert(SvTYPE(sv) >= SVt_PVMG); \
(((XPVMG*) SvANY(sv))->xmg_stash = (val)); } STMT_END
#define SvCUR_set(sv, val) \
STMT_START { assert(SvTYPE(sv) >= SVt_PV); \
+ assert(!isGV_with_GP(sv)); \
(((XPV*) SvANY(sv))->xpv_cur = (val)); } STMT_END
#define SvLEN_set(sv, val) \
STMT_START { assert(SvTYPE(sv) >= SVt_PV); \