diff options
author | Ingo Molnar <mingo@elte.hu> | 2009-04-07 05:30:17 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2009-04-07 06:02:41 -0400 |
commit | 98c2aaf8be5baf7193be37fb28bce8e7327158bc (patch) | |
tree | 53309d2f2cd1b4464e1336f8041779d0637a9f9b | |
parent | 6278af660ff83fbafb18e53fc2747eb2ee6780fa (diff) |
x86, perfcounters: add atomic64_xchg()
Complete atomic64_t support on the 32-bit side by adding atomic64_xch().
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
LKML-Reference: <20090406094518.445450972@chello.nl>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
-rw-r--r-- | arch/x86/include/asm/atomic_32.h | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/arch/x86/include/asm/atomic_32.h b/arch/x86/include/asm/atomic_32.h index 977250ed8b89..aff9f1fcdcd7 100644 --- a/arch/x86/include/asm/atomic_32.h +++ b/arch/x86/include/asm/atomic_32.h | |||
@@ -291,19 +291,37 @@ atomic64_cmpxchg(atomic64_t *ptr, unsigned long long old_val, | |||
291 | } | 291 | } |
292 | 292 | ||
293 | /** | 293 | /** |
294 | * atomic64_set - set atomic64 variable | 294 | * atomic64_xchg - xchg atomic64 variable |
295 | * @ptr: pointer to type atomic64_t | 295 | * @ptr: pointer to type atomic64_t |
296 | * @new_val: value to assign | 296 | * @new_val: value to assign |
297 | * @old_val: old value that was there | ||
297 | * | 298 | * |
298 | * Atomically sets the value of @ptr to @new_val. | 299 | * Atomically xchgs the value of @ptr to @new_val and returns |
300 | * the old value. | ||
299 | */ | 301 | */ |
300 | static inline void atomic64_set(atomic64_t *ptr, unsigned long long new_val) | 302 | |
303 | static inline unsigned long long | ||
304 | atomic64_xchg(atomic64_t *ptr, unsigned long long new_val) | ||
301 | { | 305 | { |
302 | unsigned long long old_val; | 306 | unsigned long long old_val; |
303 | 307 | ||
304 | do { | 308 | do { |
305 | old_val = atomic_read(ptr); | 309 | old_val = atomic_read(ptr); |
306 | } while (atomic64_cmpxchg(ptr, old_val, new_val) != old_val); | 310 | } while (atomic64_cmpxchg(ptr, old_val, new_val) != old_val); |
311 | |||
312 | return old_val; | ||
313 | } | ||
314 | |||
315 | /** | ||
316 | * atomic64_set - set atomic64 variable | ||
317 | * @ptr: pointer to type atomic64_t | ||
318 | * @new_val: value to assign | ||
319 | * | ||
320 | * Atomically sets the value of @ptr to @new_val. | ||
321 | */ | ||
322 | static inline void atomic64_set(atomic64_t *ptr, unsigned long long new_val) | ||
323 | { | ||
324 | atomic64_xchg(ptr, new_val); | ||
307 | } | 325 | } |
308 | 326 | ||
309 | /** | 327 | /** |