]> err.no Git - linux-2.6/commitdiff
[POWERPC] Implement PowerPC futex_atomic_cmpxchg_inatomic().
authorDavid Woodhouse <dwmw2@infradead.org>
Tue, 5 Sep 2006 04:53:14 +0000 (21:53 -0700)
committerPaul Mackerras <paulus@samba.org>
Wed, 13 Sep 2006 08:28:41 +0000 (18:28 +1000)
The sys_[gs]et_robust_list() syscalls were wired up on PowerPC but
didn't work correctly because futex_atomic_cmpxchg_inatomic() wasn't
implemented.  Implement it, based on __cmpxchg_u32().

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
Signed-off-by: Paul Mackerras <paulus@samba.org>
include/asm-powerpc/futex.h

index f1b3c00bc1ce8d8ca0254f57cc76ac6d648820ae..936422e54891f0cab44229639f8321e9d47a270e 100644 (file)
@@ -84,7 +84,33 @@ static inline int futex_atomic_op_inuser (int encoded_op, int __user *uaddr)
 static inline int
 futex_atomic_cmpxchg_inatomic(int __user *uaddr, int oldval, int newval)
 {
-       return -ENOSYS;
+       int prev;
+
+       if (!access_ok(VERIFY_WRITE, uaddr, sizeof(int)))
+               return -EFAULT;
+
+        __asm__ __volatile__ (
+        LWSYNC_ON_SMP
+"1:     lwarx   %0,0,%2         # futex_atomic_cmpxchg_inatomic\n\
+        cmpw    0,%0,%3\n\
+        bne-    3f\n"
+        PPC405_ERR77(0,%2)
+"2:     stwcx.  %4,0,%2\n\
+        bne-    1b\n"
+        ISYNC_ON_SMP
+"3:    .section .fixup,\"ax\"\n\
+4:     li      %0,%5\n\
+       b       3b\n\
+       .previous\n\
+       .section __ex_table,\"a\"\n\
+       .align 3\n\
+       " PPC_LONG "1b,4b,2b,4b\n\
+       .previous" \
+        : "=&r" (prev), "+m" (*uaddr)
+        : "r" (uaddr), "r" (oldval), "r" (newval), "i" (-EFAULT)
+        : "cc", "memory");
+
+        return prev;
 }
 
 #endif /* __KERNEL__ */