diff options
author | Paul "LeoNerd" Evans <leonerd@leonerd.org.uk> | 2021-08-07 14:46:48 +0100 |
---|---|---|
committer | Paul Evans <leonerd@leonerd.org.uk> | 2021-09-10 20:08:40 +0100 |
commit | 914bb57489325d34ddbb7c0557c53df7baa84d86 (patch) | |
tree | 71f2abe766af31e734c2f6e22b82df71bdcf4f12 /sv.h | |
parent | 170944218d18492ce2141ac45166c62ec99ba1a7 (diff) | |
download | perl-914bb57489325d34ddbb7c0557c53df7baa84d86.tar.gz |
Define a third kind of COW state; STATIC
Previously, when IsCOW flag was set there were two cases:
SvLEN()==0:
PV is really a shared HEK
SvLEN()!=0:
PV is a COW structure with 1..256 refcount stored in its extra final byte
This change adds a third state:
SvLEN()==0 && SvFLAGS() & SVppv_STATIC:
PV is a shared static const pointer and must not be modified
sv_setsv_flags() and sv_setsv_cow() will preserve this state
sv_uncow() will copy it out to a regular string buffer
sv_dup() will preserve the static pointer into cloned threads
Diffstat (limited to 'sv.h')
-rw-r--r-- | sv.h | 11 |
1 files changed, 7 insertions, 4 deletions
@@ -462,6 +462,8 @@ perform the upgrade if necessary. See C<L</svtype>>. /* Some private flags. */ +/* scalar SVs with SVp_POK */ +#define SVppv_STATIC 0x40000000 /* PV is pointer to static const; must be set with SVf_IsCOW */ /* PVAV */ #define SVpav_REAL 0x40000000 /* free old entries */ /* PVHV */ @@ -2008,10 +2010,11 @@ scalar. ) \ ) -#define SvIsCOW(sv) (SvFLAGS(sv) & SVf_IsCOW) -#define SvIsCOW_on(sv) (SvFLAGS(sv) |= SVf_IsCOW) -#define SvIsCOW_off(sv) (SvFLAGS(sv) &= ~SVf_IsCOW) -#define SvIsCOW_shared_hash(sv) (SvIsCOW(sv) && SvLEN(sv) == 0) +#define SvIsCOW(sv) (SvFLAGS(sv) & SVf_IsCOW) +#define SvIsCOW_on(sv) (SvFLAGS(sv) |= SVf_IsCOW) +#define SvIsCOW_off(sv) (SvFLAGS(sv) &= ~(SVf_IsCOW|SVppv_STATIC)) +#define SvIsCOW_shared_hash(sv) ((SvFLAGS(sv) & (SVf_IsCOW|SVppv_STATIC)) == (SVf_IsCOW) && SvLEN(sv) == 0) +#define SvIsCOW_static(sv) ((SvFLAGS(sv) & (SVf_IsCOW|SVppv_STATIC)) == (SVf_IsCOW|SVppv_STATIC)) #define SvSHARED_HEK_FROM_PV(pvx) \ ((struct hek*)(pvx - STRUCT_OFFSET(struct hek, hek_key))) |