about summary refs log tree commit diff
path: root/arch
diff options
context:
space:
mode:
authorRich Felker <dalias@aerifal.cx>2012-11-14 14:24:22 -0500
committerRich Felker <dalias@aerifal.cx>2012-11-14 14:24:22 -0500
commite7257d3e63b10d4725450c383e94cdbb997d9151 (patch)
tree34753864f964804b24bab36c94f4430d7bff9996 /arch
parent574d01a69617921b72d0171f9a0d6cd414619220 (diff)
downloadmusl-e7257d3e63b10d4725450c383e94cdbb997d9151.tar.gz
musl-e7257d3e63b10d4725450c383e94cdbb997d9151.tar.xz
musl-e7257d3e63b10d4725450c383e94cdbb997d9151.zip
fix powerpc atomic compare-and-swap function
previous version did not compare at all; it was just a fancy atomic
write. untested. further atomic fixes may be needed.
Diffstat (limited to 'arch')
-rw-r--r--arch/powerpc/atomic.h13
1 files changed, 7 insertions, 6 deletions
diff --git a/arch/powerpc/atomic.h b/arch/powerpc/atomic.h
index a83764d9..4a47064a 100644
--- a/arch/powerpc/atomic.h
+++ b/arch/powerpc/atomic.h
@@ -25,12 +25,13 @@ static inline int a_ctz_64(uint64_t x)
 
 static inline int a_cas(volatile int *p, int t, int s)
 {
-
-	__asm__( "1: lwarx 10, 0, %1\n"
-                 "   stwcx. %3, 0, %1\n"
-                 "   bne- 1b\n"
-                 "   mr %0, 10\n"
-		: "=r"(t) : "r"(p), "r"(t), "r"(s) : "memory" );
+	__asm__("1:	lwarx %0, 0, %1\n"
+		"	cmpw %0, %2\n"
+		"	bne 1f\n"
+		"	stwcx. %3, 0, %1\n"
+		"	bne- 1b\n"
+		"1:	\n"
+		: "=&r"(t) : "r"(p), "r"(t), "r"(s) : "cc", "memory" );
         return t;
 }