Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 20 Jul 2005 10:49:26 -0400
From:      John Baldwin <jhb@FreeBSD.org>
To:        arm@FreeBSD.org
Cc:        cognet@FreeBSD.org
Subject:   [PATCH] - small cleanups to asm constraints
Message-ID:  <200507201049.27568.jhb@FreeBSD.org>

next in thread | raw e-mail | index | archive | help
Can you please test the patch below.  It makes use of the + modifier for a 
register variable in one place and fixes the asm constraints for _swp() to 
specify that _swp() modifies the memory being modified, not just the address 
of the memory (which isn't actually modified at that).  Note that this means 
that the generic "memory" clobber can probably be removed, but I haven't done 
that yet:

--- //depot/vendor/freebsd/src/sys/arm/include/atomic.h	2005/07/15 18:20:34
+++ //depot/projects/smpng/sys/arm/include/atomic.h	2005/07/18 17:20:49
@@ -77,8 +77,10 @@
 static __inline uint32_t
 __swp(uint32_t val, volatile uint32_t *ptr)
 {
-	__asm __volatile("swp	%0, %1, [%2]"
-	    : "=&r" (val) : "r" (val) , "r" (ptr) : "memory");
+	__asm __volatile("swp	%0, %2, [%3]"
+	    : "=&r" (val), "=m" (*ptr)
+	    : "r" (val) , "r" (ptr), "m" (*ptr)
+	    : "memory");
 	return (val);
 }
 
--- //depot/vendor/freebsd/src/sys/arm/include/endian.h	2005/05/24 21:45:17
+++ //depot/projects/smpng/sys/arm/include/endian.h	2005/07/18 17:20:49
@@ -100,11 +100,10 @@
 __bswap16_var(__uint16_t v)
 {
 	__asm __volatile(
-	    "mov    %0, %1, ror #8\n"
+	    "mov    %0, %0, ror #8\n"
 	    "orr    %0, %0, %0, lsr #16\n"
 	    "bic    %0, %0, %0, lsl #16"
-	    : "=r" (v)
-	    : "0" (v));
+	    : "+r" (v));
 	
 	return (v);
 }		

-- 
John Baldwin <jhb@FreeBSD.org>  <><  http://www.FreeBSD.org/~jhb/
"Power Users Use the Power to Serve"  =  http://www.FreeBSD.org



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200507201049.27568.jhb>