X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=sv.h;h=ca3a2dfa659a3bc9450cf96d891cf40b49d84266;hb=5a0924038aa1098308ad491a6148bc59d3045ce6;hp=4dfa2c2559dd430af74905e9e7590d7c64b6e51d;hpb=837485b6cd4b757519a4ac6f03f3857c2fcf4844;p=p5sagit%2Fp5-mst-13.2.git diff --git a/sv.h b/sv.h index 4dfa2c2..ca3a2df 100644 --- a/sv.h +++ b/sv.h @@ -72,13 +72,46 @@ struct io { #define SvFLAGS(sv) (sv)->sv_flags #define SvREFCNT(sv) (sv)->sv_refcnt +#ifdef USE_THREADS + +# ifndef EMULATE_ATOMIC_REFCOUNTS +# include "atomic.h" +# endif + +# ifdef EMULATE_ATOMIC_REFCOUNTS +# define ATOMIC_INC(count) STMT_START { \ + MUTEX_LOCK(&svref_mutex); \ + ++count; \ + MUTEX_UNLOCK(&svref_mutex); \ + } STMT_END +# define ATOMIC_DEC_AND_TEST(res,count) STMT_START { \ + MUTEX_LOCK(&svref_mutex); \ + res = (--count == 0); \ + MUTEX_UNLOCK(&svref_mutex); \ + } STMT_END +# else +# define ATOMIC_INC(count) atomic_inc(&count) +# define ATOMIC_DEC_AND_TEST(res,count) (res = atomic_dec_and_test(&count)) +# endif /* EMULATE_ATOMIC_REFCOUNTS */ +#else +# define ATOMIC_INC(count) (++count) +# define ATOMIC_DEC_AND_TEST(res, count) (res = (--count == 0)) +#endif /* USE_THREADS */ + #ifdef __GNUC__ -# define SvREFCNT_inc(sv) ({SV* nsv=(SV*)(sv); if(nsv) ++SvREFCNT(nsv); nsv;}) +# define SvREFCNT_inc(sv) \ + ({ \ + SV *nsv = (SV*)(sv); \ + if (nsv) \ + ATOMIC_INC(SvREFCNT(nsv)); \ + nsv; \ + }) #else # if defined(CRIPPLED_CC) || defined(USE_THREADS) # define SvREFCNT_inc(sv) sv_newref((SV*)sv) # else -# define SvREFCNT_inc(sv) ((Sv=(SV*)(sv)), (Sv && ++SvREFCNT(Sv)), (SV*)Sv) +# define SvREFCNT_inc(sv) \ + ((Sv=(SV*)(sv)), (Sv && ATOMIC_INC(SvREFCNT(Sv))), (SV*)Sv) # endif #endif @@ -166,6 +199,7 @@ struct xpvnv { double xnv_nv; /* numeric value, if any */ }; +/* These structure must match the beginning of struct xpvhv in hv.h. */ struct xpvmg { char * xpv_pv; /* pointer to malloced string */ STRLEN xpv_cur; /* length of xpv_pv as a C string */ @@ -237,7 +271,7 @@ struct xpvfm { HV * xcv_stash; OP * xcv_start; OP * xcv_root; - void (*xcv_xsub)_((CV*)); + void (*xcv_xsub)_((CV* _CPERLproto)); ANY xcv_xsubany; GV * xcv_gv; GV * xcv_filegv;