X-Git-Url: http://git.liburcu.org/?p=urcu.git;a=blobdiff_plain;f=arch_atomic_ppc.h;h=54c5f5caae0fa05a074a4ad6c33f172bd6eb027b;hp=d696e26d1eb508ebc4c01d539975775903c3de4c;hb=ba59a0c7b244a0939a2298fc76a9002436ef9674;hpb=5eb3201d7a7dc40f01269eefa23a681473579ebc diff --git a/arch_atomic_ppc.h b/arch_atomic_ppc.h index d696e26..54c5f5c 100644 --- a/arch_atomic_ppc.h +++ b/arch_atomic_ppc.h @@ -20,6 +20,8 @@ * Boehm-Demers-Weiser conservative garbage collector. */ +#include + #ifndef __SIZEOF_LONG__ #ifdef __powerpc64__ #define __SIZEOF_LONG__ 8 @@ -52,7 +54,7 @@ do { \ /* xchg */ -static __attribute__((always_inline)) +static inline __attribute__((always_inline)) unsigned long _atomic_exchange(void *addr, unsigned long val, int len) { switch (len) { @@ -97,12 +99,12 @@ unsigned long _atomic_exchange(void *addr, unsigned long val, int len) return 0; } -#define xchg(addr, v) (__typeof__(*(addr))) _atomic_exchange((addr), (v), \ - sizeof(*(addr))) - +#define xchg(addr, v) \ + ((__typeof__(*(addr))) _atomic_exchange((addr), (unsigned long)(v), \ + sizeof(*(addr)))) /* cmpxchg */ -static __attribute__((always_inline)) +static inline __attribute__((always_inline)) unsigned long _atomic_cmpxchg(void *addr, unsigned long old, unsigned long _new, int len) { @@ -120,7 +122,7 @@ unsigned long _atomic_cmpxchg(void *addr, unsigned long old, "bne- 1b\n" /* retry if lost reservation */ "isync\n" "2:\n" - : "=&r"(old_val), + : "=&r"(old_val) : "r"(addr), "r"((unsigned int)_new), "r"((unsigned int)old) : "memory", "cc"); @@ -156,13 +158,15 @@ unsigned long _atomic_cmpxchg(void *addr, unsigned long old, return 0; } -#define cmpxchg(addr, old, _new) \ - (__typeof__(*(addr))) _atomic_cmpxchg((addr), (old), (_new), \ - sizeof(*(addr))) + +#define cmpxchg(addr, old, _new) \ + ((__typeof__(*(addr))) _atomic_cmpxchg((addr), (unsigned long)(old),\ + (unsigned long)(_new), \ + sizeof(*(addr)))) /* atomic_add_return */ -static __attribute__((always_inline)) +static inline __attribute__((always_inline)) unsigned long _atomic_add_return(void *addr, unsigned long val, int len) { @@ -210,8 +214,11 @@ unsigned long _atomic_add_return(void *addr, unsigned long val, return 0; } -#define atomic_add_return(addr, v) \ - (__typeof__(*(addr))) _atomic_add((addr), (v), sizeof(*(addr))) + +#define atomic_add_return(addr, v) \ + ((__typeof__(*(addr))) _atomic_add_return((addr), \ + (unsigned long)(v), \ + sizeof(*(addr)))) /* atomic_sub_return, atomic_add, atomic_sub, atomic_inc, atomic_dec */ @@ -220,8 +227,8 @@ unsigned long _atomic_add_return(void *addr, unsigned long val, #define atomic_add(addr, v) (void)atomic_add_return((addr), (v)) #define atomic_sub(addr, v) (void)atomic_sub_return((addr), (v)) -#define atomic_inc(addr, v) atomic_add((addr), 1) -#define atomic_dec(addr, v) atomic_add((addr), -1) +#define atomic_inc(addr) atomic_add((addr), 1) +#define atomic_dec(addr) atomic_add((addr), -1) #endif /* #ifndef _INCLUDE_API_H */