From: Nicholas Clark Date: Tue, 19 Apr 2005 20:07:49 +0000 (+0000) Subject: Force RVALUE macros when in PERL_DEBUG_COW X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=62703e7218aceb3f5d30f70a2307dd02e5eb8c63;p=p5sagit%2Fp5-mst-13.2.git Force RVALUE macros when in PERL_DEBUG_COW p4raw-id: //depot/perl@24252 --- diff --git a/ext/ByteLoader/byterun.c b/ext/ByteLoader/byterun.c index fd506b1..0eaca45 100644 --- a/ext/ByteLoader/byterun.c +++ b/ext/ByteLoader/byterun.c @@ -592,7 +592,7 @@ byterun(pTHX_ register struct byteloader_state *bstate) { svindex arg; BGET_svindex(arg); - *(SV**)&SvSTASH(bstate->bs_sv) = arg; + SvSTASH_set(bstate->bs_sv, arg); break; } case INSN_GV_FETCHPV: /* 77 */ diff --git a/sv.h b/sv.h index 352e270..d1cb725 100644 --- a/sv.h +++ b/sv.h @@ -742,29 +742,30 @@ in gv.h: */ #define SvRVx(sv) SvRV(sv) #ifdef PERL_DEBUG_COW -#define SvIVX(sv) (0 + ((XPVIV*) SvANY(sv))->xiv_iv) -#define SvUVX(sv) (0 + ((XPVUV*) SvANY(sv))->xuv_uv) -#define SvNVX(sv) (0 + ((XPVNV*)SvANY(sv))->xnv_nv) -#define SvPVX(sv) (0 + ((XPV*) SvANY(sv))->xpv_pv) -#define SvCUR(sv) (0 + ((XPV*) SvANY(sv))->xpv_cur) -#define SvLEN(sv) (0 + ((XPV*) SvANY(sv))->xpv_len) -#define SvEND(sv) (0 + (((XPV*) SvANY(sv))->xpv_pv + ((XPV*)SvANY(sv))->xpv_cur)) +#define SvIVX(sv) (0 + ((XPVIV*) SvANY(sv))->xiv_iv) +#define SvUVX(sv) (0 + ((XPVUV*) SvANY(sv))->xuv_uv) +#define SvNVX(sv) (0 + ((XPVNV*) SvANY(sv))->xnv_nv) +#define SvPVX(sv) (0 + ((XPV*) SvANY(sv))->xpv_pv) +#define SvCUR(sv) (0 + ((XPV*) SvANY(sv))->xpv_cur) +#define SvLEN(sv) (0 + ((XPV*) SvANY(sv))->xpv_len) +#define SvEND(sv) (((XPV*) SvANY(sv))->xpv_pv + ((XPV*)SvANY(sv))->xpv_cur) + +#ifdef PERL_IN_SV_C +/* Can't make this RVALUE because of Perl_sv_unmagic. */ +#define SvMAGIC(sv) (*(assert(SvTYPE(sv) >= SVt_PVMG), &((XPVMG*) SvANY(sv))->xmg_magic)) #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) ((XPV*) SvANY(sv))->xpv_pv -#define SvCUR(sv) ((XPV*) SvANY(sv))->xpv_cur -#define SvLEN(sv) ((XPV*) SvANY(sv))->xpv_len -#define SvEND(sv)(((XPV*) SvANY(sv))->xpv_pv + ((XPV*)SvANY(sv))->xpv_cur) +#define SvMAGIC(sv) (0 + *(assert(SvTYPE(sv) >= SVt_PVMG), &((XPVMG*) SvANY(sv))->xmg_magic)) #endif +#define SvSTASH(sv) (0 + *(assert(SvTYPE(sv) >= SVt_PVMG), &((XPVMG*) SvANY(sv))->xmg_stash)) -#define SvIVXx(sv) SvIVX(sv) -#define SvUVXx(sv) SvUVX(sv) -#define SvNVXx(sv) SvNVX(sv) -#define SvPVXx(sv) SvPVX(sv) -#define SvLENx(sv) SvLEN(sv) -#define SvENDx(sv) ((PL_Sv = (sv)), SvEND(PL_Sv)) +#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) ((XPV*) SvANY(sv))->xpv_pv +#define SvCUR(sv) ((XPV*) SvANY(sv))->xpv_cur +#define SvLEN(sv) ((XPV*) SvANY(sv))->xpv_len +#define SvEND(sv) (((XPV*) SvANY(sv))->xpv_pv + ((XPV*)SvANY(sv))->xpv_cur) #ifdef DEBUGGING #define SvMAGIC(sv) (*(assert(SvTYPE(sv) >= SVt_PVMG), &((XPVMG*) SvANY(sv))->xmg_magic)) @@ -774,6 +775,16 @@ in gv.h: */ #define SvSTASH(sv) ((XPVMG*) SvANY(sv))->xmg_stash #endif +#endif + +#define SvIVXx(sv) SvIVX(sv) +#define SvUVXx(sv) SvUVX(sv) +#define SvNVXx(sv) SvNVX(sv) +#define SvPVXx(sv) SvPVX(sv) +#define SvLENx(sv) SvLEN(sv) +#define SvENDx(sv) ((PL_Sv = (sv)), SvEND(PL_Sv)) + + /* Ask a scalar nicely to try to become an IV, if possible. Not guaranteed to stay returning void */ /* Macro won't actually call sv_2iv if already IOK */