2 * PowerPC atomic operations
5 #ifndef _ASM_PPC_ATOMIC_H_
6 #define _ASM_PPC_ATOMIC_H_
8 #include <linux/config.h>
11 typedef struct { volatile int counter; } atomic_t;
13 typedef struct { int counter; } atomic_t;
16 #define ATOMIC_INIT(i) { (i) }
18 #define atomic_read(v) ((v)->counter)
19 #define atomic_set(v,i) (((v)->counter) = (i))
21 extern void atomic_clear_mask(unsigned long mask, unsigned long *addr);
22 extern void atomic_set_mask(unsigned long mask, unsigned long *addr);
24 extern __inline__ int atomic_add_return(int a, atomic_t *v)
28 __asm__ __volatile__("\n\
33 : "=&r" (t), "=m" (*v)
34 : "r" (a), "r" (v), "m" (*v)
40 extern __inline__ int atomic_sub_return(int a, atomic_t *v)
44 __asm__ __volatile__("\n\
49 : "=&r" (t), "=m" (*v)
50 : "r" (a), "r" (v), "m" (*v)
56 extern __inline__ int atomic_inc_return(atomic_t *v)
60 __asm__ __volatile__("\n\
65 : "=&r" (t), "=m" (*v)
72 extern __inline__ int atomic_dec_return(atomic_t *v)
76 __asm__ __volatile__("\n\
81 : "=&r" (t), "=m" (*v)
88 #define atomic_add(a, v) ((void) atomic_add_return((a), (v)))
89 #define atomic_sub(a, v) ((void) atomic_sub_return((a), (v)))
90 #define atomic_sub_and_test(a, v) (atomic_sub_return((a), (v)) == 0)
91 #define atomic_inc(v) ((void) atomic_inc_return((v)))
92 #define atomic_dec(v) ((void) atomic_dec_return((v)))
93 #define atomic_dec_and_test(v) (atomic_dec_return((v)) == 0)
95 #endif /* _ASM_PPC_ATOMIC_H_ */