1 /**************************************************************************** 2 **************************************************************************** 3 *** 4 *** This header was automatically generated from a Linux kernel header 5 *** of the same name, to make information necessary for userspace to 6 *** call into the kernel available to libc. It contains only constants, 7 *** structures, and macros generated from the original header, and thus, 8 *** contains no copyrightable information. 9 *** 10 **************************************************************************** 11 ****************************************************************************/ 12 #ifndef __ASM_SH_ATOMIC_H 13 #define __ASM_SH_ATOMIC_H 14 15 typedef struct { volatile int counter; } atomic_t; 16 17 #define ATOMIC_INIT(i) ( (atomic_t) { (i) } ) 18 19 #define atomic_read(v) ((v)->counter) 20 #define atomic_set(v,i) ((v)->counter = (i)) 21 22 #include <linux/compiler.h> 23 #include <asm/system.h> 24 25 #include <asm/atomic-llsc.h> 26 27 #define atomic_add_negative(a, v) (atomic_add_return((a), (v)) < 0) 28 29 #define atomic_dec_return(v) atomic_sub_return(1,(v)) 30 #define atomic_inc_return(v) atomic_add_return(1,(v)) 31 32 #define atomic_inc_and_test(v) (atomic_inc_return(v) == 0) 33 34 #define atomic_sub_and_test(i,v) (atomic_sub_return((i), (v)) == 0) 35 #define atomic_dec_and_test(v) (atomic_sub_return(1, (v)) == 0) 36 37 #define atomic_inc(v) atomic_add(1,(v)) 38 #define atomic_dec(v) atomic_sub(1,(v)) 39 40 #define atomic_xchg(v, new) (xchg(&((v)->counter), new)) 41 #define atomic_inc_not_zero(v) atomic_add_unless((v), 1, 0) 42 #define smp_mb__before_atomic_dec() barrier() 43 #define smp_mb__after_atomic_dec() barrier() 44 #define smp_mb__before_atomic_inc() barrier() 45 #define smp_mb__after_atomic_inc() barrier() 46 #include <asm-generic/atomic.h> 47 #endif 48