mailing list of musl libc
 help / color / mirror / code / Atom feed
* [musl] [PATCH] Fix RISC-V a_cas inline asm operand sign extension
@ 2020-01-15 13:24 Luís Marques
  2020-01-15 13:50 ` Florian Weimer
  2020-01-22 14:31 ` [musl] " Luís Marques
  0 siblings, 2 replies; 6+ messages in thread
From: Luís Marques @ 2020-01-15 13:24 UTC (permalink / raw)
  To: musl; +Cc: Luís Marques

This patch adds an explicit cast to the int arguments passed to the inline asm
used in the RISC-V's implementation of `a_cas`, to ensure that they are properly
sign extended to 64 bits. They aren't automatically sign extended by Clang, and
GCC technically also doesn't guarantee that they will be sign extended.

---
 arch/riscv64/atomic_arch.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/riscv64/atomic_arch.h b/arch/riscv64/atomic_arch.h
index 41ad4d04..0c382588 100644
--- a/arch/riscv64/atomic_arch.h
+++ b/arch/riscv64/atomic_arch.h
@@ -15,7 +15,7 @@ static inline int a_cas(volatile int *p, int t, int s)
 		"	bnez %1, 1b\n"
 		"1:"
 		: "=&r"(old), "=&r"(tmp)
-		: "r"(p), "r"(t), "r"(s)
+		: "r"(p), "r"((long)t), "r"((long)s)
 		: "memory");
 	return old;
 }
-- 
2.20.1


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2020-01-22 19:55 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-15 13:24 [musl] [PATCH] Fix RISC-V a_cas inline asm operand sign extension Luís Marques
2020-01-15 13:50 ` Florian Weimer
2020-01-15 14:18   ` Luís Marques
2020-01-22 14:31 ` [musl] " Luís Marques
2020-01-22 14:46   ` Rich Felker
2020-01-22 16:57     ` Luís Marques

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).