mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Jesse Taube <mr.bossman075@gmail.com>
To: musl@lists.openwall.com
Cc: dalias@libc.org, Jesse Taube <Mr.Bossman075@gmail.com>
Subject: [musl] [PATCH] arch/riscv*/atomic_arch.h: Check if atomic is supported
Date: Mon,  2 Sep 2024 15:56:14 -0400	[thread overview]
Message-ID: <20240902195614.3169239-1-Mr.Bossman075@gmail.com> (raw)

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


             reply	other threads:[~2024-09-02 19:56 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-02 19:56 Jesse Taube [this message]
2024-09-02 21:02 ` Rich Felker

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240902195614.3169239-1-Mr.Bossman075@gmail.com \
    --to=mr.bossman075@gmail.com \
    --cc=dalias@libc.org \
    --cc=musl@lists.openwall.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).