From cbee6197d1fb31453ff51f9f1c705feed67c9c73 Mon Sep 17 00:00:00 2001 From: Mark Andrews Date: Wed, 14 Oct 2009 03:54:23 +0000 Subject: [PATCH] 2713. [bug] powerpc: atomic operations missing asm("ics") / __isync() calls. --- CHANGES | 3 +++ lib/isc/powerpc/include/isc/atomic.h | 37 +++++++++++++++++++++++++--- 2 files changed, 37 insertions(+), 3 deletions(-) diff --git a/CHANGES b/CHANGES index 6a79aa4735..612ac40df5 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,6 @@ +2713. [bug] powerpc: atomic operations missing asm("ics") / + __isync() calls. + --- 9.7.0b1 released --- 2712. [func] New 'auto-dnssec' zone option allows zone signing diff --git a/lib/isc/powerpc/include/isc/atomic.h b/lib/isc/powerpc/include/isc/atomic.h index 765cb6d72a..1e16a681b1 100644 --- a/lib/isc/powerpc/include/isc/atomic.h +++ b/lib/isc/powerpc/include/isc/atomic.h @@ -14,7 +14,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: atomic.h,v 1.6 2007/06/18 23:47:47 tbox Exp $ */ +/* $Id: atomic.h,v 1.7 2009/10/14 03:54:23 marka Exp $ */ #ifndef ISC_ATOMIC_H #define ISC_ATOMIC_H 1 @@ -46,9 +46,33 @@ #include -#define isc_atomic_xadd(p, v) fetch_and_add(p, v) #define isc_atomic_store(p, v) _clear_lock(p, v) +#ifdef __GNUC__ +static inline isc_int32_t +#else +static isc_int32_t +#endif +isc_atomic_xadd(isc_int32_t *p, isc_int32_t val) { + int ret; + +#ifdef __GNUC__ + asm("ics"); +#else + __isync(); +#endif + + ret = fetch_and_add((atomic_p)p, (int)val); + +#ifdef __GNUC__ + asm("ics"); +#else + __isync(); +#endif + + return (ret); +} + #ifdef __GNUC__ static inline int #else @@ -63,7 +87,14 @@ isc_atomic_cmpxchg(atomic_p p, int old, int new) { __isync(); #endif if (compare_and_swap(p, &orig, new)) - return (old); + orig = old; + +#ifdef __GNUC__ + asm("ics"); +#else + __isync(); +#endif + return (orig); }