aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIngo Molnar <mingo@elte.hu>2009-04-07 05:30:17 -0400
committerIngo Molnar <mingo@elte.hu>2009-04-07 06:02:41 -0400
commit98c2aaf8be5baf7193be37fb28bce8e7327158bc (patch)
tree53309d2f2cd1b4464e1336f8041779d0637a9f9b
parent6278af660ff83fbafb18e53fc2747eb2ee6780fa (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.h24
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 */
300static inline void atomic64_set(atomic64_t *ptr, unsigned long long new_val) 302
303static inline unsigned long long
304atomic64_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 */
322static 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/**