Go to the documentation of this file.
25 #include <linux/types.h>
26 #include <asm/cmpxchg.h>
28 #define ATOMIC_INIT(i) { (i) }
29 #define atomic_set(v, i) ((v)->counter = (i))
37 #define atomic_read(v) ((v)->counter)
44 #define atomic_xchg(v, new) (xchg(&((v)->counter), (new)))
69 "1: %0 = memw_locked(%1);\n"
70 " { P0 = cmp.eq(%0,%2);\n"
71 " if (!P0.new) jump:nt 2f; }\n"
72 " memw_locked(%1,P0) = %3;\n"
73 " if (!P0) jump 1b;\n"
76 :
"r" (&v->
counter),
"r" (old),
"r" (
new)
88 "1: %0 = memw_locked(%1);\n"
90 " memw_locked(%1,P3)=%0;\n"
100 #define atomic_add(i, v) atomic_add_return(i, (v))
106 "1: %0 = memw_locked(%1);\n"
107 " %0 = sub(%0,%2);\n"
108 " memw_locked(%1,P3)=%0\n"
117 #define atomic_sub(i, v) atomic_sub_return(i, (v))
127 static inline int __atomic_add_unless(
atomic_t *v,
int a,
int u)
129 int output, __oldval;
131 "1: %0 = memw_locked(%2);"
133 " p3 = cmp.eq(%0, %4);"
134 " if (p3.new) jump:nt 2f;"
138 " memw_locked(%2, p3) = %0;"
144 :
"=&r" (__oldval),
"=&r" (output)
145 :
"r" (
v),
"r" (a),
"r" (
u)
151 #define atomic_inc_not_zero(v) atomic_add_unless((v), 1, 0)
153 #define atomic_inc(v) atomic_add(1, (v))
154 #define atomic_dec(v) atomic_sub(1, (v))
156 #define atomic_inc_and_test(v) (atomic_add_return(1, (v)) == 0)
157 #define atomic_dec_and_test(v) (atomic_sub_return(1, (v)) == 0)
158 #define atomic_sub_and_test(i, v) (atomic_sub_return(i, (v)) == 0)
159 #define atomic_add_negative(i, v) (atomic_add_return(i, (v)) < 0)
162 #define atomic_inc_return(v) (atomic_add_return(1, v))
163 #define atomic_dec_return(v) (atomic_sub_return(1, v))