diff options
Diffstat (limited to 'sys/powerpc/include/atomic.h')
-rw-r--r-- | sys/powerpc/include/atomic.h | 52 |
1 files changed, 27 insertions, 25 deletions
diff --git a/sys/powerpc/include/atomic.h b/sys/powerpc/include/atomic.h index ebd45ba..619ca7e 100644 --- a/sys/powerpc/include/atomic.h +++ b/sys/powerpc/include/atomic.h @@ -38,15 +38,15 @@ * of interrupts and SMP safe. */ -void atomic_set_8(volatile u_int8_t *, u_int8_t); -void atomic_clear_8(volatile u_int8_t *, u_int8_t); -void atomic_add_8(volatile u_int8_t *, u_int8_t); -void atomic_subtract_8(volatile u_int8_t *, u_int8_t); +void atomic_set_8(volatile u_int8_t *, u_int8_t); +void atomic_clear_8(volatile u_int8_t *, u_int8_t); +void atomic_add_8(volatile u_int8_t *, u_int8_t); +void atomic_subtract_8(volatile u_int8_t *, u_int8_t); -void atomic_set_16(volatile u_int16_t *, u_int16_t); -void atomic_clear_16(volatile u_int16_t *, u_int16_t); -void atomic_add_16(volatile u_int16_t *, u_int16_t); -void atomic_subtract_16(volatile u_int16_t *, u_int16_t); +void atomic_set_16(volatile u_int16_t *, u_int16_t); +void atomic_clear_16(volatile u_int16_t *, u_int16_t); +void atomic_add_16(volatile u_int16_t *, u_int16_t); +void atomic_subtract_16(volatile u_int16_t *, u_int16_t); static __inline void atomic_set_32(volatile u_int32_t *p, u_int32_t v) @@ -217,7 +217,7 @@ atomic_readandclear_64(volatile u_int64_t *addr) #define atomic_set_long atomic_set_32 #define atomic_clear_long atomic_clear_32 -#define atomic_add_long atomic_add_32 +#define atomic_add_long(p, v) atomic_add_32((u_int32_t *)p, (u_int32_t)v) #define atomic_subtract_long atomic_subtract_32 #define atomic_readandclear_long atomic_readandclear_32 @@ -334,19 +334,21 @@ ATOMIC_STORE_LOAD(int, 32) static __inline u_int32_t atomic_cmpset_32(volatile u_int32_t* p, u_int32_t cmpval, u_int32_t newval) { - u_int32_t ret; + u_int32_t ret; + + ret = 0; __asm __volatile ( - "1:\tlwarx %0, 0, %4\n\t" /* load old value */ - "cmplw 0, %2, %0\n\t" /* compare */ - "bne 2\n\t" /* exit if not equal */ - "mr %0, %3\n\t" /* value to store */ - "stwcx. %0, 0, %1\n\t" /* attempt to store */ - "bne- 1\n\t" /* spin if failed */ + "1:\tlwarx %0, 0, %3\n\t" /* load old value */ + "cmplw 0, %1, %0\n\t" /* compare */ + "bne 2f\n\t" /* exit if not equal */ + "mr %0, %2\n\t" /* value to store */ + "stwcx. %0, 0, %3\n\t" /* attempt to store */ + "bne- 1b\n\t" /* spin if failed */ "eieio\n" /* memory barrier */ "2:\t\n" - : "=&r" (ret), "=r" (*p) - : "r" (cmpval), "r" (newval), "r" (*p) + : "=r" (ret) + : "r" (cmpval), "r" (newval), "r" (p) : "memory"); return ret; @@ -416,7 +418,7 @@ static __inline int atomic_cmpset_acq_ptr(volatile void *dst, void *exp, void *src) { - return (atomic_cmpset_acq_long((volatile u_int32_t *)dst, + return (atomic_cmpset_acq_32((volatile u_int32_t *)dst, (u_int32_t)exp, (u_int32_t)src)); } @@ -424,7 +426,7 @@ static __inline int atomic_cmpset_rel_ptr(volatile void *dst, void *exp, void *src) { - return (atomic_cmpset_rel_long((volatile u_int32_t *)dst, + return (atomic_cmpset_rel_32((volatile u_int32_t *)dst, (u_int32_t)exp, (u_int32_t)src)); } @@ -432,33 +434,33 @@ static __inline void * atomic_load_acq_ptr(volatile void *p) { - return (void *)atomic_load_acq_long((volatile u_int32_t *)p); + return (void *)atomic_load_acq_32((volatile u_int32_t *)p); } static __inline void atomic_store_rel_ptr(volatile void *p, void *v) { - atomic_store_rel_long((volatile u_int32_t *)p, (u_int32_t)v); + atomic_store_rel_32((volatile u_int32_t *)p, (u_int32_t)v); } #define ATOMIC_PTR(NAME) \ static __inline void \ atomic_##NAME##_ptr(volatile void *p, uintptr_t v) \ { \ - atomic_##NAME##_long((volatile u_int32_t *)p, v); \ + atomic_##NAME##_32((volatile u_int32_t *)p, v); \ } \ \ static __inline void \ atomic_##NAME##_acq_ptr(volatile void *p, uintptr_t v) \ { \ - atomic_##NAME##_acq_long((volatile u_int32_t *)p, v); \ + atomic_##NAME##_acq_32((volatile u_int32_t *)p, v); \ } \ \ static __inline void \ atomic_##NAME##_rel_ptr(volatile void *p, uintptr_t v) \ { \ - atomic_##NAME##_rel_long((volatile u_int32_t *)p, v); \ + atomic_##NAME##_rel_32((volatile u_int32_t *)p, v); \ } ATOMIC_PTR(set) |