summaryrefslogtreecommitdiff
path: root/include/asm-x86_64/futex.h
diff options
context:
space:
mode:
authorIngo Molnar <mingo@elte.hu>2006-03-27 01:16:26 -0800
committerLinus Torvalds <torvalds@g5.osdl.org>2006-03-27 08:44:49 -0800
commit8fdd6c6df7889dc89df3d9fe0f5bbe6733e39f48 (patch)
treee037a0eb7214818ad4ef177c618ef1e302c2aed9 /include/asm-x86_64/futex.h
parentdfd4e3ec246355274c9cf62c6b04a1ee6fa3caba (diff)
[PATCH] lightweight robust futexes: x86_64
x86_64: add the futex_atomic_cmpxchg_inuser() assembly implementation, and wire up the new syscalls. Signed-off-by: Ingo Molnar <mingo@elte.hu> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Signed-off-by: Arjan van de Ven <arjan@infradead.org> Acked-by: Ulrich Drepper <drepper@redhat.com> Cc: Andi Kleen <ak@muc.de> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'include/asm-x86_64/futex.h')
-rw-r--r--include/asm-x86_64/futex.h23
1 files changed, 22 insertions, 1 deletions
diff --git a/include/asm-x86_64/futex.h b/include/asm-x86_64/futex.h
index 4f4cb3410d06..7d9eb1a84546 100644
--- a/include/asm-x86_64/futex.h
+++ b/include/asm-x86_64/futex.h
@@ -97,7 +97,28 @@ futex_atomic_op_inuser (int encoded_op, int __user *uaddr)
static inline int
futex_atomic_cmpxchg_inuser(int __user *uaddr, int oldval, int newval)
{
- return -ENOSYS;
+ if (!access_ok(VERIFY_WRITE, uaddr, sizeof(int)))
+ return -EFAULT;
+
+ __asm__ __volatile__(
+ "1: " LOCK_PREFIX "cmpxchgl %3, %1 \n"
+
+ "2: .section .fixup, \"ax\" \n"
+ "3: mov %2, %0 \n"
+ " jmp 2b \n"
+ " .previous \n"
+
+ " .section __ex_table, \"a\" \n"
+ " .align 8 \n"
+ " .quad 1b,3b \n"
+ " .previous \n"
+
+ : "=a" (oldval), "=m" (*uaddr)
+ : "i" (-EFAULT), "r" (newval), "0" (oldval)
+ : "memory"
+ );
+
+ return oldval;
}
#endif