Go to the documentation of this file. 1 #ifndef _ASM_POWERPC_ATOMIC_H_
2 #define _ASM_POWERPC_ATOMIC_H_
9 #include <linux/types.h>
10 #include <asm/cmpxchg.h>
12 #define ATOMIC_INIT(i) { (i) }
18 __asm__ __volatile__(
"lwz%U1%X1 %0,%1" :
"=r"(t) :
"m"(v->
counter));
25 __asm__ __volatile__(
"stw%U0%X0 %1,%0" :
"=m"(v->
counter) :
"r"(i));
33 "1: lwarx %0,0,%3 # atomic_add\n\
48 PPC_ATOMIC_ENTRY_BARRIER
49 "1: lwarx %0,0,%2 # atomic_add_return\n\
54 PPC_ATOMIC_EXIT_BARRIER
62 #define atomic_add_negative(a, v) (atomic_add_return((a), (v)) < 0)
69 "1: lwarx %0,0,%3 # atomic_sub\n\
84 PPC_ATOMIC_ENTRY_BARRIER
85 "1: lwarx %0,0,%2 # atomic_sub_return\n\
90 PPC_ATOMIC_EXIT_BARRIER
103 "1: lwarx %0,0,%2 # atomic_inc\n\
118 PPC_ATOMIC_ENTRY_BARRIER
119 "1: lwarx %0,0,%1 # atomic_inc_return\n\
124 PPC_ATOMIC_EXIT_BARRIER
127 :
"cc",
"xer",
"memory");
140 #define atomic_inc_and_test(v) (atomic_inc_return(v) == 0)
147 "1: lwarx %0,0,%2 # atomic_dec\n\
162 PPC_ATOMIC_ENTRY_BARRIER
163 "1: lwarx %0,0,%1 # atomic_dec_return\n\
168 PPC_ATOMIC_EXIT_BARRIER
171 :
"cc",
"xer",
"memory");
176 #define atomic_cmpxchg(v, o, n) (cmpxchg(&((v)->counter), (o), (n)))
177 #define atomic_xchg(v, new) (xchg(&((v)->counter), new))
193 PPC_ATOMIC_ENTRY_BARRIER
194 "1: lwarx %0,0,%1 # __atomic_add_unless\n\
201 PPC_ATOMIC_EXIT_BARRIER
205 :
"r" (&v->
counter),
"r" (a),
"r" (u)
223 PPC_ATOMIC_ENTRY_BARRIER
224 "1: lwarx %0,0,%2 # atomic_inc_not_zero\n\
231 PPC_ATOMIC_EXIT_BARRIER
234 :
"=&r" (t1),
"=&r" (t2)
236 :
"cc",
"xer",
"memory");
240 #define atomic_inc_not_zero(v) atomic_inc_not_zero((v))
242 #define atomic_sub_and_test(a, v) (atomic_sub_return((a), (v)) == 0)
243 #define atomic_dec_and_test(v) (atomic_dec_return((v)) == 0)
255 PPC_ATOMIC_ENTRY_BARRIER
256 "1: lwarx %0,0,%1 # atomic_dec_if_positive\n\
263 PPC_ATOMIC_EXIT_BARRIER
271 #define atomic_dec_if_positive atomic_dec_if_positive
273 #define smp_mb__before_atomic_dec() smp_mb()
274 #define smp_mb__after_atomic_dec() smp_mb()
275 #define smp_mb__before_atomic_inc() smp_mb()
276 #define smp_mb__after_atomic_inc() smp_mb()
280 #define ATOMIC64_INIT(i) { (i) }
286 __asm__ __volatile__(
"ld%U1%X1 %0,%1" :
"=r"(t) :
"m"(v->
counter));
293 __asm__ __volatile__(
"std%U0%X0 %1,%0" :
"=m"(v->
counter) :
"r"(i));
301 "1: ldarx %0,0,%3 # atomic64_add\n\
315 PPC_ATOMIC_ENTRY_BARRIER
316 "1: ldarx %0,0,%2 # atomic64_add_return\n\
320 PPC_ATOMIC_EXIT_BARRIER
328 #define atomic64_add_negative(a, v) (atomic64_add_return((a), (v)) < 0)
335 "1: ldarx %0,0,%3 # atomic64_sub\n\
349 PPC_ATOMIC_ENTRY_BARRIER
350 "1: ldarx %0,0,%2 # atomic64_sub_return\n\
354 PPC_ATOMIC_EXIT_BARRIER
367 "1: ldarx %0,0,%2 # atomic64_inc\n\
381 PPC_ATOMIC_ENTRY_BARRIER
382 "1: ldarx %0,0,%1 # atomic64_inc_return\n\
386 PPC_ATOMIC_EXIT_BARRIER
389 :
"cc",
"xer",
"memory");
402 #define atomic64_inc_and_test(v) (atomic64_inc_return(v) == 0)
409 "1: ldarx %0,0,%2 # atomic64_dec\n\
423 PPC_ATOMIC_ENTRY_BARRIER
424 "1: ldarx %0,0,%1 # atomic64_dec_return\n\
428 PPC_ATOMIC_EXIT_BARRIER
431 :
"cc",
"xer",
"memory");
436 #define atomic64_sub_and_test(a, v) (atomic64_sub_return((a), (v)) == 0)
437 #define atomic64_dec_and_test(v) (atomic64_dec_return((v)) == 0)
448 PPC_ATOMIC_ENTRY_BARRIER
449 "1: ldarx %0,0,%1 # atomic64_dec_if_positive\n\
454 PPC_ATOMIC_EXIT_BARRIER
458 :
"cc",
"xer",
"memory");
463 #define atomic64_cmpxchg(v, o, n) (cmpxchg(&((v)->counter), (o), (n)))
464 #define atomic64_xchg(v, new) (xchg(&((v)->counter), new))
480 PPC_ATOMIC_ENTRY_BARRIER
481 "1: ldarx %0,0,%1 # __atomic_add_unless\n\
487 PPC_ATOMIC_EXIT_BARRIER
491 :
"r" (&v->
counter),
"r" (a),
"r" (u)
509 PPC_ATOMIC_ENTRY_BARRIER
510 "1: ldarx %0,0,%2 # atomic64_inc_not_zero\n\
516 PPC_ATOMIC_EXIT_BARRIER
519 :
"=&r" (t1),
"=&r" (t2)
521 :
"cc",
"xer",
"memory");