mailing list of musl libc
 help / color / mirror / code / Atom feed
* [PATCH] allow implementing a_cas_p with pointer-sized ll/sc
@ 2016-02-23  3:14 Bobby Bingham
  2016-02-23  3:35 ` Rich Felker
  0 siblings, 1 reply; 3+ messages in thread
From: Bobby Bingham @ 2016-02-23  3:14 UTC (permalink / raw)
  To: musl

No current ports do this, but it will be useful for porting to 64-bit ll/sc
architectures, such as mips64 and powerpc64.
---
 src/internal/atomic.h | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/src/internal/atomic.h b/src/internal/atomic.h
index 2097247..6f37d25 100644
--- a/src/internal/atomic.h
+++ b/src/internal/atomic.h
@@ -82,6 +82,23 @@ static inline int a_fetch_or(volatile int *p, int v)
 
 #endif
 
+#ifdef a_ll_p
+
+#ifndef a_cas_p
+#define a_cas_p a_cas_p
+static inline void *a_cas_p(volatile void *p, void *t, void *s)
+{
+	void *old;
+	a_pre_llsc();
+	do old = a_ll_p(p);
+	while (old==t && !a_sc_p(p, s));
+	a_post_llsc();
+	return old;
+}
+#endif
+
+#endif
+
 #ifndef a_cas
 #error missing definition of a_cas
 #endif
@@ -209,6 +226,7 @@ static inline void a_or_64(volatile uint64_t *p, uint64_t v)
 #endif
 
 #ifndef a_cas_p
+typedef char a_cas_p_undefined_but_pointer_not_32bit[-sizeof(char) == 0xffffffff ? 1 : -1];
 #define a_cas_p a_cas_p
 static inline void *a_cas_p(volatile void *p, void *t, void *s)
 {
-- 
2.7.1



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

* Re: [PATCH] allow implementing a_cas_p with pointer-sized ll/sc
  2016-02-23  3:14 [PATCH] allow implementing a_cas_p with pointer-sized ll/sc Bobby Bingham
@ 2016-02-23  3:35 ` Rich Felker
  2016-02-23 18:08   ` Rich Felker
  0 siblings, 1 reply; 3+ messages in thread
From: Rich Felker @ 2016-02-23  3:35 UTC (permalink / raw)
  To: musl

On Mon, Feb 22, 2016 at 09:14:23PM -0600, Bobby Bingham wrote:
> No current ports do this, but it will be useful for porting to 64-bit ll/sc
> architectures, such as mips64 and powerpc64.

Thanks!

Actually, aarch64 does, but it still needs a slightly modified version
of a_cas_p anyway. Can you check that this is compatible with what's
in the aarch64 file? I think we just need to add proper #define a_ll_p
a_ll_p and #define a_sc_p a_sc_p.

Rich


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

* Re: [PATCH] allow implementing a_cas_p with pointer-sized ll/sc
  2016-02-23  3:35 ` Rich Felker
@ 2016-02-23 18:08   ` Rich Felker
  0 siblings, 0 replies; 3+ messages in thread
From: Rich Felker @ 2016-02-23 18:08 UTC (permalink / raw)
  To: musl

On Mon, Feb 22, 2016 at 10:35:16PM -0500, Rich Felker wrote:
> On Mon, Feb 22, 2016 at 09:14:23PM -0600, Bobby Bingham wrote:
> > No current ports do this, but it will be useful for porting to 64-bit ll/sc
> > architectures, such as mips64 and powerpc64.
> 
> Thanks!
> 
> Actually, aarch64 does, but it still needs a slightly modified version
> of a_cas_p anyway. Can you check that this is compatible with what's
> in the aarch64 file? I think we just need to add proper #define a_ll_p
> a_ll_p and #define a_sc_p a_sc_p.

Never mind, nsz and I checked it out and I think your patch is fine.
I've committed a fix for the missing #defines on aarch64 too.

Rich


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

end of thread, other threads:[~2016-02-23 18:08 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-02-23  3:14 [PATCH] allow implementing a_cas_p with pointer-sized ll/sc Bobby Bingham
2016-02-23  3:35 ` Rich Felker
2016-02-23 18:08   ` 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).