x86: atomic64: Inline atomic64_read() again
[deliverable/linux.git] / arch / x86 / include / asm / atomic_32.h
index d7c8849b8c67462ac046843dcce4c4d215308d59..dc5a667ff791388074804ee547b92370c07f59c6 100644 (file)
@@ -295,6 +295,28 @@ extern void atomic64_set(atomic64_t *ptr, u64 new_val);
  *
  * Atomically reads the value of @ptr and returns it.
  */
+static inline u64 atomic64_read(atomic64_t *ptr)
+{
+       u64 res;
+
+       /*
+        * Note, we inline this atomic64_t primitive because
+        * it only clobbers EAX/EDX and leaves the others
+        * untouched. We also (somewhat subtly) rely on the
+        * fact that cmpxchg8b returns the current 64-bit value
+        * of the memory location we are touching:
+        */
+       asm volatile(
+               "mov %%ebx, %%eax\n\t"
+               "mov %%ecx, %%edx\n\t"
+               LOCK_PREFIX "cmpxchg8b %1\n"
+                       : "=&A" (res)
+                       : "m" (*ptr)
+               );
+
+       return res;
+}
+
 extern u64 atomic64_read(atomic64_t *ptr);
 
 /**
This page took 0.02552 seconds and 5 git commands to generate.