summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIvan Maidanski <ivmai@mail.ru>2021-01-12 09:18:13 +0300
committerIvan Maidanski <ivmai@mail.ru>2021-09-09 13:13:46 +0300
commit15461c97727b399fdce05f2d1552319ecf7d3bd8 (patch)
tree12dd4b66af42cc276fdc5bf1180482f3e9769517
parent22b5604f9af0f307fae797a0b8204314e26f88a1 (diff)
downloadlibatomic_ops-15461c97727b399fdce05f2d1552319ecf7d3bd8.tar.gz
Workaround assertion violation in AO_load/store on m68k
(a cherry-pick of commit c64527843 from 'release-7_4') Issue #48 (libatomic_ops). * src/atomic_ops/sysdeps/aligned_atomic_load_store.h (AO_load, AO_store): Do not assert alignment if __m68k__; add comment.
-rw-r--r--src/atomic_ops/sysdeps/aligned_atomic_load_store.h8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/atomic_ops/sysdeps/aligned_atomic_load_store.h b/src/atomic_ops/sysdeps/aligned_atomic_load_store.h
index d24fe1d..cb663eb 100644
--- a/src/atomic_ops/sysdeps/aligned_atomic_load_store.h
+++ b/src/atomic_ops/sysdeps/aligned_atomic_load_store.h
@@ -26,7 +26,13 @@
AO_INLINE AO_t
AO_load(const volatile AO_t *addr)
{
+#if defined(__m68k__)
+ /* Even though AO_t is redefined in m68k.h, some clients use AO */
+ /* pointer size primitives to access variables not declared as AO_t. */
+ /* Such variables may have 2-byte alignment, while their sizeof is 4. */
+#else
assert(((size_t)addr & (sizeof(AO_t) - 1)) == 0);
+#endif
/* Cast away the volatile for architectures where */
/* volatile adds barrier semantics. */
return *(AO_t *)addr;
@@ -36,7 +42,9 @@ AO_load(const volatile AO_t *addr)
AO_INLINE void
AO_store(volatile AO_t *addr, AO_t new_val)
{
+#if !defined(__m68k__)
assert(((size_t)addr & (sizeof(AO_t) - 1)) == 0);
+#endif
(*(AO_t *)addr) = new_val;
}
#define AO_HAVE_store