This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
[RFC] [PATCH] powerpc: Fix missing barriers in atomic_exchange_and_add_{acq,rel}
- From: Torvald Riegel <triegel at redhat dot com>
- To: libc-alpha at sourceware dot org
- Date: Tue, 21 Oct 2014 21:54:34 +0200
- Subject: [RFC] [PATCH] powerpc: Fix missing barriers in atomic_exchange_and_add_{acq,rel}
- Authentication-results: sourceware.org; auth=none
On powerpc, atomic_exchange_and_add is implemented without any barriers.
However, atomic_exchange_and_add_acq and atomic_exchange_and_add_rel
(which supposedly should have acquire / release barrier semantics) both
fall back to atomic_exchange_and_add if they are not defined (see
include/atomic.h). I have not reviewed existing code to see whether
this would indeed cause a bug, but this lack of barriers likely is a
(future) fault, and prevents any use of
atomic_exchange_and_add_{acq,rel} that actually rely on the barrier
semantics. Therefore, this patch defines
atomic_exchange_and_add_{acq,rel} using atomic_read_barrier /
atomic_write_barrier.
I have NOT tested this. Can somebody who cares about powerpc please
have a look and test this? Thanks!
commit 67da4e31ce865d57bb798d6247d893941f2148f3
Author: Torvald Riegel <triegel@redhat.com>
Date: Tue Oct 21 21:21:57 2014 +0200
powerpc: Fix missing barriers in atomic_exchange_and_add_{acq,rel}
diff --git a/sysdeps/powerpc/bits/atomic.h b/sysdeps/powerpc/bits/atomic.h
index 2ffba48..b838631 100644
--- a/sysdeps/powerpc/bits/atomic.h
+++ b/sysdeps/powerpc/bits/atomic.h
@@ -253,6 +253,18 @@ typedef uintmax_t uatomic_max_t;
abort (); \
__result; \
})
+#define atomic_exchange_and_add_acq(mem, value) \
+ ({ \
+ __typeof (*(mem)) __result2; \
+ __result2 = atomic_exchange_and_add (mem, value); \
+ atomic_read_barrier (); \
+ __result2; \
+ })
+#define atomic_exchange_and_add_rel(mem, value) \
+ ({ \
+ atomic_write_barrier (); \
+ atomic_exchange_and_add (mem, value); \
+ })
#define atomic_increment_val(mem) \
({ \