- 2.6.17 port work build breaks, but the patch set is relativly stable
[linux-flexiantxendom0-3.2.10.git] / include / asm-i386 / futex.h
index 24c9fd3..7b8ceef 100644 (file)
@@ -28,7 +28,7 @@
 "1:    movl    %2, %0\n\
        movl    %0, %3\n"                                       \
        insn "\n"                                               \
-"2:    " LOCK "cmpxchgl %3, %2\n\
+"2:    " LOCK_PREFIX "cmpxchgl %3, %2\n\
        jnz     1b\n\
 3:     .section .fixup,\"ax\"\n\
 4:     mov     %5, %1\n\
@@ -68,7 +68,7 @@ futex_atomic_op_inuser (int encoded_op, int __user *uaddr)
 #endif
                switch (op) {
                case FUTEX_OP_ADD:
-                       __futex_atomic_op1(LOCK "xaddl %0, %2", ret,
+                       __futex_atomic_op1(LOCK_PREFIX "xaddl %0, %2", ret,
                                           oldval, uaddr, oparg);
                        break;
                case FUTEX_OP_OR:
@@ -104,5 +104,32 @@ futex_atomic_op_inuser (int encoded_op, int __user *uaddr)
        return ret;
 }
 
+static inline int
+futex_atomic_cmpxchg_inatomic(int __user *uaddr, int oldval, int newval)
+{
+       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"
+               "       .long   1b,3b                           \n"
+               "       .previous                               \n"
+
+               : "=a" (oldval), "=m" (*uaddr)
+               : "i" (-EFAULT), "r" (newval), "0" (oldval)
+               : "memory"
+       );
+
+       return oldval;
+}
+
 #endif
 #endif