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 | |
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.
-rw-r--r-- | cop.h | 6 | ||||
-rw-r--r-- | op.h | 6 | ||||
-rw-r--r-- | perl.h | 5 | ||||
-rw-r--r-- | sv.h | 20 |
4 files changed, 12 insertions, 25 deletions
@@ -420,12 +420,8 @@ struct cop { ? GvSV(gv_fetchfile(CopFILE(c))) : NULL) # define CopFILEAV(c) (CopFILE(c) \ ? GvAV(gv_fetchfile(CopFILE(c))) : NULL) -# ifdef DEBUGGING -# define CopFILEAVx(c) (assert(CopFILE(c)), \ +# define CopFILEAVx(c) (assert_(CopFILE(c)) \ GvAV(gv_fetchfile(CopFILE(c)))) -# else -# define CopFILEAVx(c) (GvAV(gv_fetchfile(CopFILE(c)))) -# endif # define CopSTASH(c) PL_stashpad[(c)->cop_stashoff] # define CopSTASH_set(c,hv) ((c)->cop_stashoff = (hv) \ @@ -748,12 +748,8 @@ struct opslab { # define OPSLOT_HEADER STRUCT_OFFSET(OPSLOT, opslot_op) # define OPSLOT_HEADER_P (OPSLOT_HEADER/sizeof(I32 *)) -# ifdef DEBUGGING -# define OpSLOT(o) (assert(o->op_slabbed), \ +# define OpSLOT(o) (assert_(o->op_slabbed) \ (OPSLOT *)(((char *)o)-OPSLOT_HEADER)) -# else -# define OpSLOT(o) ((OPSLOT *)(((char *)o)-OPSLOT_HEADER)) -# endif # define OpSLAB(o) OpSLOT(o)->opslot_slab # define OpslabREFCNT_dec(slab) \ (((slab)->opslab_refcnt == 1) \ @@ -3868,6 +3868,11 @@ Gid_t getegid (void); #ifndef assert # define assert(what) Perl_assert(what) #endif +#ifdef DEBUGGING +# define assert_(what) assert(what), +#else +# define assert_(what) +#endif struct ufuncs { I32 (*uf_val)(pTHX_ IV, SV*); @@ -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) |