From: Nicholas Clark Date: Fri, 8 Apr 2005 10:39:15 +0000 (+0000) Subject: Add a macro PERL_DEBUG_COW, for aggressive compile time tests of X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=f599b64b5d5d221c90b5f40eb5ad167f16c1822c;p=p5sagit%2Fp5-mst-13.2.git Add a macro PERL_DEBUG_COW, for aggressive compile time tests of Copy-On-Write related source changes. Fix the problem this revealed. p4raw-id: //depot/perl@24201 --- diff --git a/sv.c b/sv.c index 452dd9c..102a000 100644 --- a/sv.c +++ b/sv.c @@ -7518,7 +7518,7 @@ Perl_sv_dec(pTHX_ register SV *sv) if (!(flags & SVp_POK)) { if ((flags & SVTYPEMASK) < SVt_PVNV) sv_upgrade(sv, SVt_NV); - SvNVX(sv) = -1.0; + SvNV_set(sv, 1.0); (void)SvNOK_only(sv); return; } diff --git a/sv.h b/sv.h index 09dae3f..5e0c45e 100644 --- a/sv.h +++ b/sv.h @@ -737,17 +737,22 @@ in gv.h: */ #define SvRVx(sv) SvRV(sv) #define SvIVX(sv) ((XPVIV*) SvANY(sv))->xiv_iv -#define SvIVXx(sv) SvIVX(sv) #define SvUVX(sv) ((XPVUV*) SvANY(sv))->xuv_uv -#define SvUVXx(sv) SvUVX(sv) +#ifdef PERL_DEBUG_COW +#define SvNVX(sv) (0.0 + ((XPVNV*)SvANY(sv))->xnv_nv) +#else #define SvNVX(sv) ((XPVNV*)SvANY(sv))->xnv_nv -#define SvNVXx(sv) SvNVX(sv) +#endif #define SvPVX(sv) ((XPV*) SvANY(sv))->xpv_pv -#define SvPVXx(sv) SvPVX(sv) #define SvCUR(sv) ((XPV*) SvANY(sv))->xpv_cur #define SvLEN(sv) ((XPV*) SvANY(sv))->xpv_len -#define SvLENx(sv) SvLEN(sv) #define SvEND(sv)(((XPV*) SvANY(sv))->xpv_pv + ((XPV*)SvANY(sv))->xpv_cur) + +#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)) #ifdef DEBUGGING @@ -769,7 +774,7 @@ in gv.h: */ (SvIVX(sv) = (val)); } STMT_END #define SvNV_set(sv, val) \ STMT_START { assert(SvTYPE(sv) == SVt_NV || SvTYPE(sv) >= SVt_PVNV); \ - (SvNVX(sv) = (val)); } STMT_END + (((XPVNV*)SvANY(sv))->xnv_nv = (val)); } STMT_END #define SvPV_set(sv, val) \ STMT_START { assert(SvTYPE(sv) >= SVt_PV); \ (SvPVX(sv) = (val)); } STMT_END