]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/commitdiff
x86, perfcounters: add atomic64_xchg()
authorIngo Molnar <mingo@elte.hu>
Tue, 7 Apr 2009 09:30:17 +0000 (11:30 +0200)
committerIngo Molnar <mingo@elte.hu>
Tue, 7 Apr 2009 10:02:41 +0000 (12:02 +0200)
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>
arch/x86/include/asm/atomic_32.h

index 977250ed8b898c17a869e759ec431b71b55177f8..aff9f1fcdcd7e2be9d86049fc7f9522bafd4b35d 100644 (file)
@@ -291,19 +291,37 @@ atomic64_cmpxchg(atomic64_t *ptr, unsigned long long old_val,
 }
 
 /**
- * atomic64_set - set atomic64 variable
+ * atomic64_xchg - xchg atomic64 variable
  * @ptr:      pointer to type atomic64_t
  * @new_val:  value to assign
+ * @old_val:  old value that was there
  *
- * Atomically sets the value of @ptr to @new_val.
+ * Atomically xchgs the value of @ptr to @new_val and returns
+ * the old value.
  */
-static inline void atomic64_set(atomic64_t *ptr, unsigned long long new_val)
+
+static inline unsigned long long
+atomic64_xchg(atomic64_t *ptr, unsigned long long new_val)
 {
        unsigned long long old_val;
 
        do {
                old_val = atomic_read(ptr);
        } while (atomic64_cmpxchg(ptr, old_val, new_val) != old_val);
+
+       return old_val;
+}
+
+/**
+ * atomic64_set - set atomic64 variable
+ * @ptr:      pointer to type atomic64_t
+ * @new_val:  value to assign
+ *
+ * Atomically sets the value of @ptr to @new_val.
+ */
+static inline void atomic64_set(atomic64_t *ptr, unsigned long long new_val)
+{
+       atomic64_xchg(ptr, new_val);
 }
 
 /**