diff options
author | Gurusamy Sarathy <gsar@cpan.org> | 1998-03-01 06:52:26 +0000 |
---|---|---|
committer | Gurusamy Sarathy <gsar@cpan.org> | 1998-03-01 06:52:26 +0000 |
commit | fbbbcc485c1d03c76a91f998e1e4492c8ad56b38 (patch) | |
tree | 3b1a893d2288b11451c4d4419edd75f4f85d2481 /sv.h | |
parent | c69f6586a27b86846a13e0177336730d72b33c95 (diff) | |
parent | 1c1c7f20b839aeb1c04942d0884c3efb087d3e4a (diff) | |
download | perl-fbbbcc485c1d03c76a91f998e1e4492c8ad56b38.tar.gz |
[asperl] integrate mainline changes
p4raw-id: //depot/asperl@607
Diffstat (limited to 'sv.h')
-rw-r--r-- | sv.h | 37 |
1 files changed, 35 insertions, 2 deletions
@@ -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 |