diff options
author | Nicholas Clark <nick@ccl4.org> | 2002-08-15 01:10:35 +0100 |
---|---|---|
committer | hv <hv@crypt.org> | 2002-08-17 02:07:24 +0000 |
commit | 765f542df20317f47bb284c276cd0abfb50dcfd6 (patch) | |
tree | be92963942496ba900bdfb32c5b522ba355aafb0 /sv.h | |
parent | 6f12eb6d2a1dfaf441504d869b27d2e40ef4966a (diff) | |
download | perl-765f542df20317f47bb284c276cd0abfb50dcfd6.tar.gz |
Copy On Write
Message-id: <20020815001035.A69079@plum.flirble.org>
specify "-Accflags='-DPERL_COPY_ON_WRITE'" to use
p4raw-id: //depot/perl@17728
Diffstat (limited to 'sv.h')
-rw-r--r-- | sv.h | 30 |
1 files changed, 30 insertions, 0 deletions
@@ -556,15 +556,27 @@ Set the length of the string which is in the SV. See C<SvCUR>. #define SvOKp(sv) (SvFLAGS(sv) & (SVp_IOK|SVp_NOK|SVp_POK)) #define SvIOKp(sv) (SvFLAGS(sv) & SVp_IOK) +#ifdef PERL_COPY_ON_WRITE +#define SvRELEASE_IVX(sv) ((SvFLAGS(sv) & (SVf_OOK|SVf_READONLY|SVf_FAKE)) \ + && sv_release_IVX(sv)) +#define SvIOKp_on(sv) ((void)sv_release_IVX(sv), \ + SvFLAGS(sv) |= SVp_IOK) +#else #define SvIOKp_on(sv) ((void)SvOOK_off(sv), SvFLAGS(sv) |= SVp_IOK) +#endif #define SvNOKp(sv) (SvFLAGS(sv) & SVp_NOK) #define SvNOKp_on(sv) (SvFLAGS(sv) |= SVp_NOK) #define SvPOKp(sv) (SvFLAGS(sv) & SVp_POK) #define SvPOKp_on(sv) (SvFLAGS(sv) |= SVp_POK) #define SvIOK(sv) (SvFLAGS(sv) & SVf_IOK) +#ifdef PERL_COPY_ON_WRITE +#define SvIOK_on(sv) ((void)sv_release_IVX(sv), \ + SvFLAGS(sv) |= (SVf_IOK|SVp_IOK)) +#else #define SvIOK_on(sv) ((void)SvOOK_off(sv), \ SvFLAGS(sv) |= (SVf_IOK|SVp_IOK)) +#endif #define SvIOK_off(sv) (SvFLAGS(sv) &= ~(SVf_IOK|SVp_IOK|SVf_IVisUV)) #define SvIOK_only(sv) ((void)SvOK_off(sv), \ SvFLAGS(sv) |= (SVf_IOK|SVp_IOK)) @@ -1063,11 +1075,29 @@ otherwise. # endif /* USE_5005THREADS */ #endif /* __GNU__ */ +#define SvIsCOW(sv) ((SvFLAGS(sv) & (SVf_FAKE | SVf_READONLY)) == \ + (SVf_FAKE | SVf_READONLY)) /* flag values for sv_*_flags functions */ #define SV_IMMEDIATE_UNREF 1 #define SV_GMAGIC 2 +#ifdef PERL_COPY_ON_WRITE +#define SV_COW_DROP_PV 4 + +#define SvIsCOW_shared_hash(sv) (SvIsCOW(sv) && SvLEN(sv) == 0) +#define SvIsCOW_normal(sv) (SvIsCOW(sv) && SvLEN(sv)) + +#define SV_CHECK_THINKFIRST_COW_DROP(sv) if (SvTHINKFIRST(sv)) \ + sv_force_normal_flags(sv, SV_COW_DROP_PV) +#else +#define SV_CHECK_THINKFIRST_COW_DROP(sv) if (SvTHINKFIRST(sv)) \ + sv_force_normal_flags(sv, 0) +#endif /* PERL_COPY_ON_WRITE */ +#define SV_CHECK_THINKFIRST(sv) if (SvTHINKFIRST(sv)) \ + sv_force_normal_flags(sv, 0) + + /* all these 'functions' are now just macros */ #define sv_pv(sv) SvPV_nolen(sv) |