mailing list of musl libc
 help / color / mirror / code / Atom feed
* [PATCH] better a_sc inline asm constraint on aarch64 and arm
@ 2016-01-31 15:33 Szabolcs Nagy
  0 siblings, 0 replies; only message in thread
From: Szabolcs Nagy @ 2016-01-31 15:33 UTC (permalink / raw)
  To: musl

"Q" input constraint was used for the written object, instead of "=Q"
output constraint.  this should not cause problems because "memory"
is on the clobber list, but "=Q" better documents the intent and more
consistent with the actual asm code.

this changes the generated code, because different registers are used,
but other than the register names nothing should change.
---
 arch/aarch64/atomic_arch.h | 4 ++--
 arch/arm/atomic_arch.h     | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/arch/aarch64/atomic_arch.h b/arch/aarch64/atomic_arch.h
index 6b4f1a4..af93d87 100644
--- a/arch/aarch64/atomic_arch.h
+++ b/arch/aarch64/atomic_arch.h
@@ -10,7 +10,7 @@ static inline int a_ll(volatile int *p)
 static inline int a_sc(volatile int *p, int v)
 {
 	int r;
-	__asm__ __volatile__ ("stlxr %w0,%w1,%2" : "=&r"(r) : "r"(v), "Q"(*p) : "memory");
+	__asm__ __volatile__ ("stlxr %w0,%w2,%1" : "=&r"(r), "=Q"(*p) : "r"(v) : "memory");
 	return !r;
 }
 
@@ -44,7 +44,7 @@ static inline void *a_ll_p(volatile void *p)
 static inline int a_sc_p(volatile int *p, void *v)
 {
 	int r;
-	__asm__ __volatile__ ("stlxr %w0,%1,%2" : "=&r"(r) : "r"(v), "Q"(*(void *volatile *)p) : "memory");
+	__asm__ __volatile__ ("stlxr %w0,%2,%1" : "=&r"(r), "=Q"(*(void *volatile *)p) : "r"(v) : "memory");
 	return !r;
 }
 
diff --git a/arch/arm/atomic_arch.h b/arch/arm/atomic_arch.h
index 21db6b2..706fa1f 100644
--- a/arch/arm/atomic_arch.h
+++ b/arch/arm/atomic_arch.h
@@ -16,7 +16,7 @@ static inline int a_ll(volatile int *p)
 static inline int a_sc(volatile int *p, int v)
 {
 	int r;
-	__asm__ __volatile__ ("strex %0,%1,%2" : "=&r"(r) : "r"(v), "Q"(*p) : "memory");
+	__asm__ __volatile__ ("strex %0,%2,%1" : "=&r"(r), "=Q"(*p) : "r"(v) : "memory");
 	return !r;
 }
 
-- 
2.7.0



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

only message in thread, other threads:[~2016-01-31 15:33 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-01-31 15:33 [PATCH] better a_sc inline asm constraint on aarch64 and arm Szabolcs Nagy

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).