Heiko Carstens | 1275105 | 2009-09-11 10:28:34 +0200 | [diff] [blame] | 1 | /* |
Heiko Carstens | a53c8fa | 2012-07-20 11:15:04 +0200 | [diff] [blame] | 2 | * Copyright IBM Corp. 1999, 2009 |
Heiko Carstens | 1275105 | 2009-09-11 10:28:34 +0200 | [diff] [blame] | 3 | * Author(s): Martin Schwidefsky <schwidefsky@de.ibm.com>, |
| 4 | * Denis Joseph Barrow, |
| 5 | * Arnd Bergmann <arndb@de.ibm.com>, |
| 6 | * |
| 7 | * Atomic operations that C can't guarantee us. |
| 8 | * Useful for resource counting etc. |
Lucas De Marchi | 25985ed | 2011-03-30 22:57:33 -0300 | [diff] [blame] | 9 | * s390 uses 'Compare And Swap' for atomicity in SMP environment. |
Heiko Carstens | 1275105 | 2009-09-11 10:28:34 +0200 | [diff] [blame] | 10 | * |
| 11 | */ |
| 12 | |
Heiko Carstens | a53c8fa | 2012-07-20 11:15:04 +0200 | [diff] [blame] | 13 | #ifndef __ARCH_S390_ATOMIC__ |
| 14 | #define __ARCH_S390_ATOMIC__ |
| 15 | |
Dave Jones | 5bd1db6 | 2006-04-10 22:53:51 -0700 | [diff] [blame] | 16 | #include <linux/compiler.h> |
Matthew Wilcox | ea435467 | 2009-01-06 14:40:39 -0800 | [diff] [blame] | 17 | #include <linux/types.h> |
David Howells | a0616cd | 2012-03-28 18:30:02 +0100 | [diff] [blame] | 18 | #include <asm/cmpxchg.h> |
Dave Jones | 5bd1db6 | 2006-04-10 22:53:51 -0700 | [diff] [blame] | 19 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 20 | #define ATOMIC_INIT(i) { (i) } |
| 21 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 22 | #define __CS_LOOP(ptr, op_val, op_string) ({ \ |
Martin Schwidefsky | 3947517 | 2009-12-07 12:52:05 +0100 | [diff] [blame] | 23 | int old_val, new_val; \ |
Martin Schwidefsky | 94c12cc | 2006-09-28 16:56:43 +0200 | [diff] [blame] | 24 | asm volatile( \ |
| 25 | " l %0,%2\n" \ |
| 26 | "0: lr %1,%0\n" \ |
| 27 | op_string " %1,%3\n" \ |
| 28 | " cs %0,%1,%2\n" \ |
| 29 | " jl 0b" \ |
| 30 | : "=&d" (old_val), "=&d" (new_val), \ |
| 31 | "=Q" (((atomic_t *)(ptr))->counter) \ |
| 32 | : "d" (op_val), "Q" (((atomic_t *)(ptr))->counter) \ |
| 33 | : "cc", "memory"); \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 34 | new_val; \ |
| 35 | }) |
Martin Schwidefsky | 94c12cc | 2006-09-28 16:56:43 +0200 | [diff] [blame] | 36 | |
Heiko Carstens | c51b962 | 2007-08-22 13:51:45 +0200 | [diff] [blame] | 37 | static inline int atomic_read(const atomic_t *v) |
| 38 | { |
Heiko Carstens | 7657e41 | 2011-02-17 13:13:58 +0100 | [diff] [blame] | 39 | int c; |
| 40 | |
| 41 | asm volatile( |
| 42 | " l %0,%1\n" |
| 43 | : "=d" (c) : "Q" (v->counter)); |
| 44 | return c; |
Heiko Carstens | c51b962 | 2007-08-22 13:51:45 +0200 | [diff] [blame] | 45 | } |
| 46 | |
| 47 | static inline void atomic_set(atomic_t *v, int i) |
| 48 | { |
Heiko Carstens | 7657e41 | 2011-02-17 13:13:58 +0100 | [diff] [blame] | 49 | asm volatile( |
| 50 | " st %1,%0\n" |
| 51 | : "=Q" (v->counter) : "d" (i)); |
Heiko Carstens | c51b962 | 2007-08-22 13:51:45 +0200 | [diff] [blame] | 52 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 53 | |
Heiko Carstens | bfe3349b | 2009-09-11 10:28:35 +0200 | [diff] [blame] | 54 | static inline int atomic_add_return(int i, atomic_t *v) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 55 | { |
| 56 | return __CS_LOOP(v, i, "ar"); |
| 57 | } |
Martin Schwidefsky | 973bd99 | 2006-01-06 00:19:07 -0800 | [diff] [blame] | 58 | #define atomic_add(_i, _v) atomic_add_return(_i, _v) |
| 59 | #define atomic_add_negative(_i, _v) (atomic_add_return(_i, _v) < 0) |
| 60 | #define atomic_inc(_v) atomic_add_return(1, _v) |
| 61 | #define atomic_inc_return(_v) atomic_add_return(1, _v) |
| 62 | #define atomic_inc_and_test(_v) (atomic_add_return(1, _v) == 0) |
Heiko Carstens | 86d51bc | 2013-09-11 14:28:47 +0200 | [diff] [blame^] | 63 | #define atomic_sub_return(_i, _v) atomic_add_return(-(int)(_i), _v) |
Martin Schwidefsky | 973bd99 | 2006-01-06 00:19:07 -0800 | [diff] [blame] | 64 | #define atomic_sub(_i, _v) atomic_sub_return(_i, _v) |
| 65 | #define atomic_sub_and_test(_i, _v) (atomic_sub_return(_i, _v) == 0) |
| 66 | #define atomic_dec(_v) atomic_sub_return(1, _v) |
| 67 | #define atomic_dec_return(_v) atomic_sub_return(1, _v) |
| 68 | #define atomic_dec_and_test(_v) (atomic_sub_return(1, _v) == 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 69 | |
Heiko Carstens | bfe3349b | 2009-09-11 10:28:35 +0200 | [diff] [blame] | 70 | static inline void atomic_clear_mask(unsigned long mask, atomic_t *v) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 71 | { |
Heiko Carstens | bfe3349b | 2009-09-11 10:28:35 +0200 | [diff] [blame] | 72 | __CS_LOOP(v, ~mask, "nr"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 73 | } |
Martin Schwidefsky | 973bd99 | 2006-01-06 00:19:07 -0800 | [diff] [blame] | 74 | |
Heiko Carstens | bfe3349b | 2009-09-11 10:28:35 +0200 | [diff] [blame] | 75 | static inline void atomic_set_mask(unsigned long mask, atomic_t *v) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 76 | { |
Heiko Carstens | bfe3349b | 2009-09-11 10:28:35 +0200 | [diff] [blame] | 77 | __CS_LOOP(v, mask, "or"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 78 | } |
Martin Schwidefsky | 973bd99 | 2006-01-06 00:19:07 -0800 | [diff] [blame] | 79 | |
Ingo Molnar | ffbf670 | 2006-01-09 15:59:17 -0800 | [diff] [blame] | 80 | #define atomic_xchg(v, new) (xchg(&((v)->counter), new)) |
| 81 | |
Heiko Carstens | bfe3349b | 2009-09-11 10:28:35 +0200 | [diff] [blame] | 82 | static inline int atomic_cmpxchg(atomic_t *v, int old, int new) |
Martin Schwidefsky | 973bd99 | 2006-01-06 00:19:07 -0800 | [diff] [blame] | 83 | { |
Martin Schwidefsky | 94c12cc | 2006-09-28 16:56:43 +0200 | [diff] [blame] | 84 | asm volatile( |
| 85 | " cs %0,%2,%1" |
| 86 | : "+d" (old), "=Q" (v->counter) |
| 87 | : "d" (new), "Q" (v->counter) |
| 88 | : "cc", "memory"); |
Martin Schwidefsky | 973bd99 | 2006-01-06 00:19:07 -0800 | [diff] [blame] | 89 | return old; |
| 90 | } |
| 91 | |
Arun Sharma | f24219b | 2011-07-26 16:09:07 -0700 | [diff] [blame] | 92 | static inline int __atomic_add_unless(atomic_t *v, int a, int u) |
Martin Schwidefsky | 973bd99 | 2006-01-06 00:19:07 -0800 | [diff] [blame] | 93 | { |
| 94 | int c, old; |
Martin Schwidefsky | 973bd99 | 2006-01-06 00:19:07 -0800 | [diff] [blame] | 95 | c = atomic_read(v); |
Nick Piggin | 0b2fcfd | 2006-03-23 03:01:02 -0800 | [diff] [blame] | 96 | for (;;) { |
| 97 | if (unlikely(c == u)) |
| 98 | break; |
| 99 | old = atomic_cmpxchg(v, c, c + a); |
| 100 | if (likely(old == c)) |
| 101 | break; |
Martin Schwidefsky | 973bd99 | 2006-01-06 00:19:07 -0800 | [diff] [blame] | 102 | c = old; |
Nick Piggin | 0b2fcfd | 2006-03-23 03:01:02 -0800 | [diff] [blame] | 103 | } |
Arun Sharma | f24219b | 2011-07-26 16:09:07 -0700 | [diff] [blame] | 104 | return c; |
Martin Schwidefsky | 973bd99 | 2006-01-06 00:19:07 -0800 | [diff] [blame] | 105 | } |
| 106 | |
Martin Schwidefsky | 973bd99 | 2006-01-06 00:19:07 -0800 | [diff] [blame] | 107 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 108 | #undef __CS_LOOP |
| 109 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 110 | #define ATOMIC64_INIT(i) { (i) } |
| 111 | |
Heiko Carstens | 1275105 | 2009-09-11 10:28:34 +0200 | [diff] [blame] | 112 | #ifdef CONFIG_64BIT |
| 113 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 114 | #define __CSG_LOOP(ptr, op_val, op_string) ({ \ |
Martin Schwidefsky | 3947517 | 2009-12-07 12:52:05 +0100 | [diff] [blame] | 115 | long long old_val, new_val; \ |
Martin Schwidefsky | 94c12cc | 2006-09-28 16:56:43 +0200 | [diff] [blame] | 116 | asm volatile( \ |
| 117 | " lg %0,%2\n" \ |
| 118 | "0: lgr %1,%0\n" \ |
| 119 | op_string " %1,%3\n" \ |
| 120 | " csg %0,%1,%2\n" \ |
| 121 | " jl 0b" \ |
| 122 | : "=&d" (old_val), "=&d" (new_val), \ |
| 123 | "=Q" (((atomic_t *)(ptr))->counter) \ |
| 124 | : "d" (op_val), "Q" (((atomic_t *)(ptr))->counter) \ |
Heiko Carstens | bfe3349b | 2009-09-11 10:28:35 +0200 | [diff] [blame] | 125 | : "cc", "memory"); \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 126 | new_val; \ |
| 127 | }) |
Martin Schwidefsky | 94c12cc | 2006-09-28 16:56:43 +0200 | [diff] [blame] | 128 | |
Heiko Carstens | c51b962 | 2007-08-22 13:51:45 +0200 | [diff] [blame] | 129 | static inline long long atomic64_read(const atomic64_t *v) |
| 130 | { |
Heiko Carstens | 7657e41 | 2011-02-17 13:13:58 +0100 | [diff] [blame] | 131 | long long c; |
| 132 | |
| 133 | asm volatile( |
| 134 | " lg %0,%1\n" |
| 135 | : "=d" (c) : "Q" (v->counter)); |
| 136 | return c; |
Heiko Carstens | c51b962 | 2007-08-22 13:51:45 +0200 | [diff] [blame] | 137 | } |
| 138 | |
| 139 | static inline void atomic64_set(atomic64_t *v, long long i) |
| 140 | { |
Heiko Carstens | 7657e41 | 2011-02-17 13:13:58 +0100 | [diff] [blame] | 141 | asm volatile( |
| 142 | " stg %1,%0\n" |
| 143 | : "=Q" (v->counter) : "d" (i)); |
Heiko Carstens | c51b962 | 2007-08-22 13:51:45 +0200 | [diff] [blame] | 144 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 145 | |
Heiko Carstens | bfe3349b | 2009-09-11 10:28:35 +0200 | [diff] [blame] | 146 | static inline long long atomic64_add_return(long long i, atomic64_t *v) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 147 | { |
| 148 | return __CSG_LOOP(v, i, "agr"); |
| 149 | } |
Martin Schwidefsky | 973bd99 | 2006-01-06 00:19:07 -0800 | [diff] [blame] | 150 | |
Heiko Carstens | bfe3349b | 2009-09-11 10:28:35 +0200 | [diff] [blame] | 151 | static inline void atomic64_clear_mask(unsigned long mask, atomic64_t *v) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 152 | { |
Heiko Carstens | bfe3349b | 2009-09-11 10:28:35 +0200 | [diff] [blame] | 153 | __CSG_LOOP(v, ~mask, "ngr"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 154 | } |
Martin Schwidefsky | 973bd99 | 2006-01-06 00:19:07 -0800 | [diff] [blame] | 155 | |
Heiko Carstens | bfe3349b | 2009-09-11 10:28:35 +0200 | [diff] [blame] | 156 | static inline void atomic64_set_mask(unsigned long mask, atomic64_t *v) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 157 | { |
Heiko Carstens | bfe3349b | 2009-09-11 10:28:35 +0200 | [diff] [blame] | 158 | __CSG_LOOP(v, mask, "ogr"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 159 | } |
| 160 | |
Mathieu Desnoyers | 3a5f10e | 2007-02-21 10:55:59 +0100 | [diff] [blame] | 161 | #define atomic64_xchg(v, new) (xchg(&((v)->counter), new)) |
| 162 | |
Heiko Carstens | bfe3349b | 2009-09-11 10:28:35 +0200 | [diff] [blame] | 163 | static inline long long atomic64_cmpxchg(atomic64_t *v, |
Martin Schwidefsky | 973bd99 | 2006-01-06 00:19:07 -0800 | [diff] [blame] | 164 | long long old, long long new) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 165 | { |
Martin Schwidefsky | 94c12cc | 2006-09-28 16:56:43 +0200 | [diff] [blame] | 166 | asm volatile( |
| 167 | " csg %0,%2,%1" |
| 168 | : "+d" (old), "=Q" (v->counter) |
| 169 | : "d" (new), "Q" (v->counter) |
| 170 | : "cc", "memory"); |
Martin Schwidefsky | 973bd99 | 2006-01-06 00:19:07 -0800 | [diff] [blame] | 171 | return old; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 172 | } |
| 173 | |
Heiko Carstens | 1275105 | 2009-09-11 10:28:34 +0200 | [diff] [blame] | 174 | #undef __CSG_LOOP |
| 175 | |
| 176 | #else /* CONFIG_64BIT */ |
| 177 | |
| 178 | typedef struct { |
| 179 | long long counter; |
| 180 | } atomic64_t; |
| 181 | |
| 182 | static inline long long atomic64_read(const atomic64_t *v) |
| 183 | { |
| 184 | register_pair rp; |
| 185 | |
| 186 | asm volatile( |
Martin Schwidefsky | 987bcda | 2010-02-26 22:37:31 +0100 | [diff] [blame] | 187 | " lm %0,%N0,%1" |
| 188 | : "=&d" (rp) : "Q" (v->counter) ); |
Heiko Carstens | 1275105 | 2009-09-11 10:28:34 +0200 | [diff] [blame] | 189 | return rp.pair; |
| 190 | } |
| 191 | |
| 192 | static inline void atomic64_set(atomic64_t *v, long long i) |
| 193 | { |
| 194 | register_pair rp = {.pair = i}; |
| 195 | |
| 196 | asm volatile( |
Martin Schwidefsky | 987bcda | 2010-02-26 22:37:31 +0100 | [diff] [blame] | 197 | " stm %1,%N1,%0" |
| 198 | : "=Q" (v->counter) : "d" (rp) ); |
Heiko Carstens | 1275105 | 2009-09-11 10:28:34 +0200 | [diff] [blame] | 199 | } |
| 200 | |
| 201 | static inline long long atomic64_xchg(atomic64_t *v, long long new) |
| 202 | { |
| 203 | register_pair rp_new = {.pair = new}; |
| 204 | register_pair rp_old; |
| 205 | |
| 206 | asm volatile( |
Martin Schwidefsky | 987bcda | 2010-02-26 22:37:31 +0100 | [diff] [blame] | 207 | " lm %0,%N0,%1\n" |
| 208 | "0: cds %0,%2,%1\n" |
Heiko Carstens | 1275105 | 2009-09-11 10:28:34 +0200 | [diff] [blame] | 209 | " jl 0b\n" |
Martin Schwidefsky | 987bcda | 2010-02-26 22:37:31 +0100 | [diff] [blame] | 210 | : "=&d" (rp_old), "=Q" (v->counter) |
| 211 | : "d" (rp_new), "Q" (v->counter) |
Heiko Carstens | 1275105 | 2009-09-11 10:28:34 +0200 | [diff] [blame] | 212 | : "cc"); |
| 213 | return rp_old.pair; |
| 214 | } |
| 215 | |
| 216 | static inline long long atomic64_cmpxchg(atomic64_t *v, |
| 217 | long long old, long long new) |
| 218 | { |
| 219 | register_pair rp_old = {.pair = old}; |
| 220 | register_pair rp_new = {.pair = new}; |
| 221 | |
| 222 | asm volatile( |
Martin Schwidefsky | 987bcda | 2010-02-26 22:37:31 +0100 | [diff] [blame] | 223 | " cds %0,%2,%1" |
| 224 | : "+&d" (rp_old), "=Q" (v->counter) |
| 225 | : "d" (rp_new), "Q" (v->counter) |
Heiko Carstens | 1275105 | 2009-09-11 10:28:34 +0200 | [diff] [blame] | 226 | : "cc"); |
| 227 | return rp_old.pair; |
| 228 | } |
| 229 | |
| 230 | |
| 231 | static inline long long atomic64_add_return(long long i, atomic64_t *v) |
| 232 | { |
| 233 | long long old, new; |
| 234 | |
| 235 | do { |
| 236 | old = atomic64_read(v); |
| 237 | new = old + i; |
| 238 | } while (atomic64_cmpxchg(v, old, new) != old); |
| 239 | return new; |
| 240 | } |
| 241 | |
Heiko Carstens | 1275105 | 2009-09-11 10:28:34 +0200 | [diff] [blame] | 242 | static inline void atomic64_set_mask(unsigned long long mask, atomic64_t *v) |
| 243 | { |
| 244 | long long old, new; |
| 245 | |
| 246 | do { |
| 247 | old = atomic64_read(v); |
| 248 | new = old | mask; |
| 249 | } while (atomic64_cmpxchg(v, old, new) != old); |
| 250 | } |
| 251 | |
| 252 | static inline void atomic64_clear_mask(unsigned long long mask, atomic64_t *v) |
| 253 | { |
| 254 | long long old, new; |
| 255 | |
| 256 | do { |
| 257 | old = atomic64_read(v); |
| 258 | new = old & mask; |
| 259 | } while (atomic64_cmpxchg(v, old, new) != old); |
| 260 | } |
| 261 | |
| 262 | #endif /* CONFIG_64BIT */ |
| 263 | |
Heiko Carstens | bfe3349b | 2009-09-11 10:28:35 +0200 | [diff] [blame] | 264 | static inline int atomic64_add_unless(atomic64_t *v, long long a, long long u) |
Martin Schwidefsky | 973bd99 | 2006-01-06 00:19:07 -0800 | [diff] [blame] | 265 | { |
| 266 | long long c, old; |
Heiko Carstens | 2ddb3ec | 2010-05-26 23:26:18 +0200 | [diff] [blame] | 267 | |
Martin Schwidefsky | 973bd99 | 2006-01-06 00:19:07 -0800 | [diff] [blame] | 268 | c = atomic64_read(v); |
Nick Piggin | 0b2fcfd | 2006-03-23 03:01:02 -0800 | [diff] [blame] | 269 | for (;;) { |
| 270 | if (unlikely(c == u)) |
| 271 | break; |
| 272 | old = atomic64_cmpxchg(v, c, c + a); |
| 273 | if (likely(old == c)) |
| 274 | break; |
Martin Schwidefsky | 973bd99 | 2006-01-06 00:19:07 -0800 | [diff] [blame] | 275 | c = old; |
Nick Piggin | 0b2fcfd | 2006-03-23 03:01:02 -0800 | [diff] [blame] | 276 | } |
Martin Schwidefsky | 973bd99 | 2006-01-06 00:19:07 -0800 | [diff] [blame] | 277 | return c != u; |
| 278 | } |
| 279 | |
Heiko Carstens | 2ddb3ec | 2010-05-26 23:26:18 +0200 | [diff] [blame] | 280 | static inline long long atomic64_dec_if_positive(atomic64_t *v) |
| 281 | { |
| 282 | long long c, old, dec; |
| 283 | |
| 284 | c = atomic64_read(v); |
| 285 | for (;;) { |
| 286 | dec = c - 1; |
| 287 | if (unlikely(dec < 0)) |
| 288 | break; |
| 289 | old = atomic64_cmpxchg((v), c, dec); |
| 290 | if (likely(old == c)) |
| 291 | break; |
| 292 | c = old; |
| 293 | } |
| 294 | return dec; |
| 295 | } |
| 296 | |
Heiko Carstens | 1275105 | 2009-09-11 10:28:34 +0200 | [diff] [blame] | 297 | #define atomic64_add(_i, _v) atomic64_add_return(_i, _v) |
| 298 | #define atomic64_add_negative(_i, _v) (atomic64_add_return(_i, _v) < 0) |
| 299 | #define atomic64_inc(_v) atomic64_add_return(1, _v) |
| 300 | #define atomic64_inc_return(_v) atomic64_add_return(1, _v) |
| 301 | #define atomic64_inc_and_test(_v) (atomic64_add_return(1, _v) == 0) |
Heiko Carstens | 86d51bc | 2013-09-11 14:28:47 +0200 | [diff] [blame^] | 302 | #define atomic64_sub_return(_i, _v) atomic64_add_return(-(long long)(_i), _v) |
Heiko Carstens | 1275105 | 2009-09-11 10:28:34 +0200 | [diff] [blame] | 303 | #define atomic64_sub(_i, _v) atomic64_sub_return(_i, _v) |
| 304 | #define atomic64_sub_and_test(_i, _v) (atomic64_sub_return(_i, _v) == 0) |
| 305 | #define atomic64_dec(_v) atomic64_sub_return(1, _v) |
| 306 | #define atomic64_dec_return(_v) atomic64_sub_return(1, _v) |
| 307 | #define atomic64_dec_and_test(_v) (atomic64_sub_return(1, _v) == 0) |
| 308 | #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0) |
Nick Piggin | 8426e1f | 2005-11-13 16:07:25 -0800 | [diff] [blame] | 309 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 310 | #define smp_mb__before_atomic_dec() smp_mb() |
| 311 | #define smp_mb__after_atomic_dec() smp_mb() |
| 312 | #define smp_mb__before_atomic_inc() smp_mb() |
| 313 | #define smp_mb__after_atomic_inc() smp_mb() |
| 314 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 315 | #endif /* __ARCH_S390_ATOMIC__ */ |