diff options
author | Father Chrysostomos <sprout@cpan.org> | 2012-08-05 17:22:29 -0700 |
---|---|---|
committer | Father Chrysostomos <sprout@cpan.org> | 2012-08-05 22:27:04 -0700 |
commit | c77244152327e2223e55144a463094790d835933 (patch) | |
tree | 33363317bab89d55fe54551e0ed22090053cbd67 /sv.h | |
parent | b166eea9cd004d916f7322015c1c4337c549ac08 (diff) | |
download | perl-c77244152327e2223e55144a463094790d835933.tar.gz |
assert_(...)
This new macro expands to ‘assert(...),’ (with a trailing comma) under
debugging builds; the empty string otherwise.
It allows for the removal of some #ifdef DEBUGGINGs, which could not be
avoided otherwise.
Diffstat (limited to 'sv.h')
-rw-r--r-- | sv.h | 20 |
1 files changed, 5 insertions, 15 deletions
@@ -752,13 +752,8 @@ Set the actual length of the string which is in the SV. See C<SvIV_set>. #define SvNIOK_off(sv) (SvFLAGS(sv) &= ~(SVf_IOK|SVf_NOK| \ SVp_IOK|SVp_NOK|SVf_IVisUV)) -#if defined(__GNUC__) && !defined(PERL_GCC_BRACE_GROUPS_FORBIDDEN) -#define assert_not_ROK(sv) ({assert(!SvROK(sv) || !SvRV(sv));}), -#define assert_not_glob(sv) ({assert(!isGV_with_GP(sv));}), -#else -#define assert_not_ROK(sv) -#define assert_not_glob(sv) -#endif +#define assert_not_ROK(sv) assert_(!SvROK(sv) || !SvRV(sv)) +#define assert_not_glob(sv) assert_(!isGV_with_GP(sv)) #define SvOK(sv) ((SvTYPE(sv) == SVt_BIND) \ ? (SvFLAGS(SvRV(sv)) & SVf_OK) \ @@ -1139,7 +1134,7 @@ sv_force_normal does nothing. # define SvRV_const(sv) (0 + (sv)->sv_u.svu_rv) /* 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 SvPVX(sv) (0 + (assert_(!SvREADONLY(sv)) (sv)->sv_u.svu_pv)) # else # define SvPVX(sv) SvPVX_mutable(sv) # endif @@ -1147,13 +1142,8 @@ sv_force_normal does nothing. # define SvLEN(sv) (0 + ((XPV*) SvANY(sv))->xpv_len) # define SvEND(sv) ((sv)->sv_u.svu_pv + ((XPV*)SvANY(sv))->xpv_cur) -# ifdef DEBUGGING -# define SvMAGIC(sv) (0 + *(assert(SvTYPE(sv) >= SVt_PVMG), &((XPVMG*) SvANY(sv))->xmg_u.xmg_magic)) -# define SvSTASH(sv) (0 + *(assert(SvTYPE(sv) >= SVt_PVMG), &((XPVMG*) SvANY(sv))->xmg_stash)) -# else -# define SvMAGIC(sv) (0 + ((XPVMG*) SvANY(sv))->xmg_u.xmg_magic) -# define SvSTASH(sv) (0 + ((XPVMG*) SvANY(sv))->xmg_stash) -# endif +# define SvMAGIC(sv) (0 + *(assert_(SvTYPE(sv) >= SVt_PVMG) &((XPVMG*) SvANY(sv))->xmg_u.xmg_magic)) +# define SvSTASH(sv) (0 + *(assert_(SvTYPE(sv) >= SVt_PVMG) &((XPVMG*) SvANY(sv))->xmg_stash)) #else # define SvLEN(sv) ((XPV*) SvANY(sv))->xpv_len # define SvEND(sv) ((sv)->sv_u.svu_pv + ((XPV*)SvANY(sv))->xpv_cur) |