All of lore.kernel.org
 help / color / mirror / Atom feed
* [patch] s390: futex atomic operations part 2.
@ 2006-04-25 15:10 Martin Schwidefsky
  0 siblings, 0 replies; only message in thread
From: Martin Schwidefsky @ 2006-04-25 15:10 UTC (permalink / raw)
  To: linux-kernel, akpm

From: Martin Schwidefsky <schwidefsky@de.ibm.com>

[patch] s390: futex atomic operations part 2.

Add missing primitive futex_atomic_cmpxchg_inatomic. Remove incorrect
type cast of uaddr memory constraint from __futex_atomic_op.

Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
---
 include/asm-s390/futex.h |   31 +++++++++++++++++++++++++++++--
 1 files changed, 29 insertions(+), 2 deletions(-)

diff -urpN linux-2.6/include/asm-s390/futex.h linux-2.6-patched/include/asm-s390/futex.h
--- linux-2.6/include/asm-s390/futex.h	2006-04-25 13:41:36.000000000 +0200
+++ linux-2.6-patched/include/asm-s390/futex.h	2006-04-25 15:24:01.000000000 +0200
@@ -30,9 +30,9 @@
 		     "2:\n"						\
 		     __futex_atomic_fixup				\
 		     : "=d" (ret), "=&d" (oldval), "=&d" (newval),	\
-		       "=m" (*(unsigned long __user *) uaddr)		\
+		       "=m" (*uaddr)					\
 		     : "0" (-EFAULT), "d" (oparg), "a" (uaddr),		\
-		       "m" (*(unsigned long __user *) uaddr) : "cc" );
+		       "m" (*uaddr) : "cc" );
 
 static inline int futex_atomic_op_inuser (int encoded_op, int __user *uaddr)
 {
@@ -90,5 +90,32 @@ static inline int futex_atomic_op_inuser
 	return ret;
 }
 
+static inline int
+futex_atomic_cmpxchg_inatomic(int __user *uaddr, int oldval, int newval)
+{
+	int ret;
+
+	if (! access_ok (VERIFY_WRITE, uaddr, sizeof(int)))
+		return -EFAULT;
+	asm volatile("   cs   %1,%4,0(%5)\n"
+		     "0: lr   %0,%1\n"
+		     "1:\n"
+#ifndef __s390x__
+		     ".section __ex_table,\"a\"\n"
+		     "   .align 4\n"
+		     "   .long  0b,1b\n"
+		     ".previous"
+#else /* __s390x__ */
+		     ".section __ex_table,\"a\"\n"
+		     "   .align 8\n"
+		     "   .quad  0b,1b\n"
+		     ".previous"
+#endif /* __s390x__ */
+		     : "=d" (ret), "+d" (oldval), "=m" (*uaddr)
+		     : "0" (-EFAULT), "d" (newval), "a" (uaddr), "m" (*uaddr)
+		     : "cc", "memory" );
+	return oldval;
+}
+
 #endif /* __KERNEL__ */
 #endif /* _ASM_S390_FUTEX_H */

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2006-04-25 15:10 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-04-25 15:10 [patch] s390: futex atomic operations part 2 Martin Schwidefsky

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.