1 #ifndef _ASM_M32R_ATOMIC_H
2 #define _ASM_M32R_ATOMIC_H
12 #include <linux/types.h>
13 #include <asm/assembler.h>
14 #include <asm/cmpxchg.h>
22 #define ATOMIC_INIT(i) { (i) }
30 #define atomic_read(v) (*(volatile int *)&(v)->counter)
39 #define atomic_set(v,i) (((v)->counter) = (i))
55 "# atomic_add_return \n\t"
63 #ifdef CONFIG_CHIP_M32700_TS1
86 "# atomic_sub_return \n\t"
94 #ifdef CONFIG_CHIP_M32700_TS1
110 #define atomic_add(i,v) ((void) atomic_add_return((i), (v)))
119 #define atomic_sub(i,v) ((void) atomic_sub_return((i), (v)))
130 #define atomic_sub_and_test(i,v) (atomic_sub_return((i), (v)) == 0)
145 "# atomic_inc_return \n\t"
153 #ifdef CONFIG_CHIP_M32700_TS1
175 "# atomic_dec_return \n\t"
183 #ifdef CONFIG_CHIP_M32700_TS1
198 #define atomic_inc(v) ((void)atomic_inc_return(v))
206 #define atomic_dec(v) ((void)atomic_dec_return(v))
216 #define atomic_inc_and_test(v) (atomic_inc_return(v) == 0)
226 #define atomic_dec_and_test(v) (atomic_dec_return(v) == 0)
237 #define atomic_add_negative(i,v) (atomic_add_return((i), (v)) < 0)
239 #define atomic_cmpxchg(v, o, n) ((int)cmpxchg(&((v)->counter), (o), (n)))
240 #define atomic_xchg(v, new) (xchg(&((v)->counter), new))
274 "# atomic_clear_mask \n\t"
280 :
"r" (addr),
"r" (~mask)
282 #ifdef CONFIG_CHIP_M32700_TS1
296 "# atomic_set_mask \n\t"
302 :
"r" (addr),
"r" (mask)
304 #ifdef CONFIG_CHIP_M32700_TS1
312 #define smp_mb__before_atomic_dec() barrier()
313 #define smp_mb__after_atomic_dec() barrier()
314 #define smp_mb__before_atomic_inc() barrier()
315 #define smp_mb__after_atomic_inc() barrier()