mailing list of musl libc
 help / color / mirror / code / Atom feed
* [musl] [PATCH] arch/riscv*/atomic_arch.h: Check if atomic is supported
@ 2024-09-02 19:56 Jesse Taube
  2024-09-02 21:02 ` Rich Felker
  0 siblings, 1 reply; 2+ messages in thread
From: Jesse Taube @ 2024-09-02 19:56 UTC (permalink / raw)
  To: musl; +Cc: dalias, Jesse Taube

Define a_cas and a_cas_p only if atomic instructions are supported.

Signed-off-by: Jesse Taube <Mr.Bossman075@gmail.com>
---
 arch/riscv32/atomic_arch.h | 4 ++++
 arch/riscv64/atomic_arch.h | 4 ++++
 2 files changed, 8 insertions(+)

diff --git a/arch/riscv32/atomic_arch.h b/arch/riscv32/atomic_arch.h
index 4d418f63..331ce46e 100644
--- a/arch/riscv32/atomic_arch.h
+++ b/arch/riscv32/atomic_arch.h
@@ -4,6 +4,8 @@ static inline void a_barrier()
 	__asm__ __volatile__ ("fence rw,rw" : : : "memory");
 }
 
+#if defined(__riscv_a) || defined(__riscv_atomic)
+
 #define a_cas a_cas
 static inline int a_cas(volatile int *p, int t, int s)
 {
@@ -19,3 +21,5 @@ static inline int a_cas(volatile int *p, int t, int s)
 		: "memory");
 	return old;
 }
+
+#endif
diff --git a/arch/riscv64/atomic_arch.h b/arch/riscv64/atomic_arch.h
index 0c382588..dac972d2 100644
--- a/arch/riscv64/atomic_arch.h
+++ b/arch/riscv64/atomic_arch.h
@@ -4,6 +4,8 @@ static inline void a_barrier()
 	__asm__ __volatile__ ("fence rw,rw" : : : "memory");
 }
 
+#if defined(__riscv_a) || defined(__riscv_atomic)
+
 #define a_cas a_cas
 static inline int a_cas(volatile int *p, int t, int s)
 {
@@ -36,3 +38,5 @@ static inline void *a_cas_p(volatile void *p, void *t, void *s)
 		: "memory");
 	return old;
 }
+
+#endif
-- 
2.45.2


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

end of thread, other threads:[~2024-09-02 21:02 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-09-02 19:56 [musl] [PATCH] arch/riscv*/atomic_arch.h: Check if atomic is supported Jesse Taube
2024-09-02 21:02 ` Rich Felker

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