diff options
author | Nicholas Clark <nick@ccl4.org> | 2006-02-19 20:10:34 +0000 |
---|---|---|
committer | Nicholas Clark <nick@ccl4.org> | 2006-02-19 20:10:34 +0000 |
commit | 05ef5f8f807e05aa6ac8d4f78bb7f33dd4496cdb (patch) | |
tree | 6a1e027d0f5e470da8b162db9d97aa68ae2b3ede /sv.h | |
parent | 0aa395f8d7800f582dd6179dfa4fb15674fdc9d2 (diff) | |
download | perl-05ef5f8f807e05aa6ac8d4f78bb7f33dd4496cdb.tar.gz |
Under -DDEBUGGING, assert that SvIVX, SvUVX and SvNVX aren't being
used on scalars that don't have the memory allocated. Correct
SvSTASH and SvMAGIC to only evaluate the sv argument once.
p4raw-id: //depot/perl@27229
Diffstat (limited to 'sv.h')
-rw-r--r-- | sv.h | 36 |
1 files changed, 30 insertions, 6 deletions
@@ -897,18 +897,42 @@ in gv.h: */ # 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); \ + &(((XPVIV*) SvANY(_svi))->xiv_iv); \ + })) +# define SvUVX(sv) \ + (*({ SV *const _svi = (SV *) sv; \ + assert(SvTYPE(_svi) == SVt_IV || SvTYPE(_svi) >= SVt_PVIV); \ + &(((XPVUV*) SvANY(_svi))->xuv_uv); \ + })) +# define SvNVX(sv) \ + (*({ SV *const _svi = (SV *) sv; \ + assert(SvTYPE(_svi) == SVt_NV || SvTYPE(_svi) >= SVt_PVNV); \ + &(((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 |