X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=sv.h;h=f2bbe106e2c6b9cbce84d6d660e68ec53bc0daa8;hb=a6b599c70633c3b011aba1a198149d25707cbc98;hp=fc8729f634812db888dd9c6932f1ba217f58ba4d;hpb=b347df820803cfaa55e1ef645ee3797402b58e10;p=p5sagit%2Fp5-mst-13.2.git diff --git a/sv.h b/sv.h index fc8729f..f2bbe10 100644 --- a/sv.h +++ b/sv.h @@ -59,9 +59,16 @@ typedef enum { SVt_PVHV, /* 12 */ SVt_PVCV, /* 13 */ SVt_PVFM, /* 14 */ - SVt_PVIO /* 15 */ + SVt_PVIO, /* 15 */ + SVt_LAST /* keep last in enum. used to size arrays */ } svtype; +#ifdef PERL_IN_SV_C +#define PTE_SVSLOT SVt_RV +#endif +#if defined(PERL_IN_HV_C) || defined(PERL_IN_XS_APITEST) +#define HE_SVSLOT SVt_NULL +#endif /* typedefs to eliminate some typing */ typedef struct he HE; @@ -109,7 +116,7 @@ struct cv { }; struct av { - _SV_HEAD(XPVAV*); /* pointer to xpvcv body */ + _SV_HEAD(XPVAV*); /* pointer to xpvav body */ _SV_HEAD_UNION; }; @@ -124,7 +131,7 @@ struct io { }; #undef _SV_HEAD -#undef _SV_HEAD_UNION /* insure no pollution */ +#undef _SV_HEAD_UNION /* ensure no pollution */ /* =head1 SV Manipulation Functions @@ -162,7 +169,7 @@ perform the upgrade if necessary. See C. }) #else # define SvREFCNT_inc(sv) \ - ((PL_Sv=(SV*)(sv)), (PL_Sv && ++(SvREFCNT(PL_Sv))), (SV*)PL_Sv) + ((PL_Sv=(SV*)(sv)) ? ((++(SvREFCNT(PL_Sv))),(PL_Sv)) : NULL) #endif #if defined(__GNUC__) && !defined(__STRICT_ANSI__) && !defined(PERL_GCC_PEDANTIC) @@ -185,6 +192,11 @@ perform the upgrade if necessary. See C. #define SVTYPEMASK 0xff #define SvTYPE(sv) ((sv)->sv_flags & SVTYPEMASK) +/* Sadly there are some parts of the core that have pointers to already-freed + SV heads, and rely on being able to tell that they are now free. So mark + them all by using a consistent macro. */ +#define SvIS_FREED(sv) ((sv)->sv_flags == SVTYPEMASK) + #define SvUPGRADE(sv, mt) (SvTYPE(sv) >= (mt) || (sv_upgrade(sv, mt), 1)) #define SVs_PADSTALE 0x00000100 /* lexical has gone out of scope */ @@ -896,10 +908,17 @@ in gv.h: */ # endif #endif +#ifndef PERL_POISON /* Given that these two are new, there can't be any existing code using them * as LVALUEs */ -#define SvPVX_mutable(sv) (0 + (sv)->sv_u.svu_pv) -#define SvPVX_const(sv) ((const char*)(0 + (sv)->sv_u.svu_pv)) +# define SvPVX_mutable(sv) (0 + (sv)->sv_u.svu_pv) +# define SvPVX_const(sv) ((const char*)(0 + (sv)->sv_u.svu_pv)) +#else +/* Except for the poison code, which uses & to scribble over the pointer after + free() is called. */ +# define SvPVX_mutable(sv) ((sv)->sv_u.svu_pv) +# define SvPVX_const(sv) ((const char*)((sv)->sv_u.svu_pv)) +#endif #define SvIVXx(sv) SvIVX(sv) #define SvUVXx(sv) SvUVX(sv) @@ -1406,6 +1425,9 @@ Like C but doesn't process magic. #define sv_2iv(sv) sv_2iv_flags(sv, SV_GMAGIC) #define sv_2uv(sv) sv_2uv_flags(sv, SV_GMAGIC) +#define newSVpvs(str) newSVpvn(STR_WITH_LEN(str)) +#define sv_catpvs(sv, str) sv_catpvn_flags(sv, STR_WITH_LEN(str), SV_GMAGIC) + /* Should be named SvCatPVN_utf8_upgrade? */ #define sv_catpvn_utf8_upgrade(dsv, sstr, slen, nsv) \ STMT_START { \