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 *** To edit the content of this header, modify the corresponding 11 *** source file (e.g. under external/kernel-headers/original/) then 12 *** run bionic/libc/kernel/tools/update_all.py 13 *** 14 *** Any manual change here will be lost the next time this script will 15 *** be run. You've been warned! 16 *** 17 **************************************************************************** 18 ****************************************************************************/ 19 #ifndef _ASM_ATOMIC_H 20 #define _ASM_ATOMIC_H 21 #include <linux/irqflags.h> 22 #include <asm/barrier.h> 23 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 24 #include <asm/cpu-features.h> 25 #include <asm/war.h> 26 #include <asm/system.h> 27 typedef struct { volatile int counter; } atomic_t; 28 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 29 #define ATOMIC_INIT(i) { (i) } 30 #define atomic_read(v) ((v)->counter) 31 #define atomic_set(v, i) ((v)->counter = (i)) 32 #define atomic_cmpxchg(v, o, n) (cmpxchg(&((v)->counter), (o), (n))) 33 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 34 #define atomic_xchg(v, new) (xchg(&((v)->counter), (new))) 35 #define atomic_inc_not_zero(v) atomic_add_unless((v), 1, 0) 36 #define atomic_dec_return(v) atomic_sub_return(1, (v)) 37 #define atomic_inc_return(v) atomic_add_return(1, (v)) 38 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 39 #define atomic_sub_and_test(i, v) (atomic_sub_return((i), (v)) == 0) 40 #define atomic_inc_and_test(v) (atomic_inc_return(v) == 0) 41 #define atomic_dec_and_test(v) (atomic_sub_return(1, (v)) == 0) 42 #define atomic_dec_if_positive(v) atomic_sub_if_positive(1, v) 43 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 44 #define atomic_inc(v) atomic_add(1, (v)) 45 #define atomic_dec(v) atomic_sub(1, (v)) 46 #define atomic_add_negative(i, v) (atomic_add_return(i, (v)) < 0) 47 #define smp_mb__before_atomic_dec() smp_llsc_mb() 48 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 49 #define smp_mb__after_atomic_dec() smp_llsc_mb() 50 #define smp_mb__before_atomic_inc() smp_llsc_mb() 51 #define smp_mb__after_atomic_inc() smp_llsc_mb() 52 #include <asm-generic/atomic.h> 53 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 54 #endif 55