X-Git-Url: https://git.liburcu.org/?a=blobdiff_plain;f=urcu%2Fuatomic_arch_sparc64.h;h=81f95cbe91ac641aacdce2e5e2f450a9cf1ec41f;hb=f152776dbd7d8cf072160d4d0229e1c3e4ea6f1c;hp=87deacd1a064366bceb799cf8620485c06ba6206;hpb=58de5a4bc81e0b64f4fbd46973b5c8b0cd06cda6;p=urcu.git diff --git a/urcu/uatomic_arch_sparc64.h b/urcu/uatomic_arch_sparc64.h index 87deacd..81f95cb 100644 --- a/urcu/uatomic_arch_sparc64.h +++ b/urcu/uatomic_arch_sparc64.h @@ -23,8 +23,12 @@ #include #include +#ifdef __cplusplus +extern "C" { +#endif + #ifndef __SIZEOF_LONG__ -#if (defined(__sparc_v8__) || defined(__sparc_v9__)) +#ifdef __LP64__ #define __SIZEOF_LONG__ 8 #else #define __SIZEOF_LONG__ 4 @@ -35,9 +39,6 @@ #define BITS_PER_LONG (__SIZEOF_LONG__ * 8) #endif -#define uatomic_set(addr, v) STORE_SHARED(*(addr), (v)) -#define uatomic_read(addr) LOAD_SHARED(*(addr)) - /* cmpxchg */ static inline __attribute__((always_inline)) @@ -82,101 +83,10 @@ unsigned long _uatomic_cmpxchg(void *addr, unsigned long old, (unsigned long)(_new), \ sizeof(*(addr)))) -/* xchg */ - -static inline __attribute__((always_inline)) -unsigned long _uatomic_exchange(void *addr, unsigned long val, int len) -{ - switch (len) { - case 4: - { - unsigned int old; - - oldt = uatomic_read(addr); - do { - old = oldt; - oldt = _uatomic_cmpxchg(addr, old, val, 4); - } while (oldt != old); - - return old; - } -#if (BITS_PER_LONG == 64) - case 8: - { - unsigned long old; - - oldt = uatomic_read(addr); - do { - old = oldt; - oldt = _uatomic_cmpxchg(addr, old, val, 8); - } while (oldt != old); - - return old; - } -#endif - } - __builtin_trap(); - return 0; +#ifdef __cplusplus } - -#define uatomic_xchg(addr, v) \ - ((__typeof__(*(addr))) _uatomic_exchange((addr), (unsigned long)(v), \ - sizeof(*(addr)))) - -/* uatomic_add_return */ - -static inline __attribute__((always_inline)) -unsigned long _uatomic_add_return(void *addr, unsigned long val, - int len) -{ - switch (len) { - case 4: - { - unsigned int old; - - oldt = uatomic_read(addr); - do { - old = oldt; - oldt = _uatomic_cmpxchg(addr, old, old + val, 4); - } while (oldt != old); - - return old + val; - } -#if (BITS_PER_LONG == 64) - case 8: - { - unsigned long old; - - oldt = uatomic_read(addr); - do { - old = oldt; - oldt = _uatomic_cmpxchg(addr, old, old + val, 8); - } while (oldt != old); - - return old + val; - } #endif - } - __builtin_trap(); - return 0; -} - -#define uatomic_add_return(addr, v) \ - ((__typeof__(*(addr))) _uatomic_add_return((addr), \ - (unsigned long)(v), \ - sizeof(*(addr)))) - -/* uatomic_sub_return, uatomic_add, uatomic_sub, uatomic_inc, uatomic_dec */ - -#define uatomic_sub_return(addr, v) uatomic_add_return((addr), -(v)) - -#define uatomic_add(addr, v) (void)uatomic_add_return((addr), (v)) -#define uatomic_sub(addr, v) (void)uatomic_sub_return((addr), (v)) - -#define uatomic_inc(addr) uatomic_add((addr), 1) -#define uatomic_dec(addr) uatomic_add((addr), -1) -#define URCU_CAS_AVAIL() 1 -#define compat_uatomic_cmpxchg(ptr, old, _new) uatomic_cmpxchg(ptr, old, _new) +#include #endif /* _URCU_ARCH_UATOMIC_PPC_H */