From 7833f4852ab4c44a1fae75cfb1221e19a7b3256c Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Wed, 8 Jul 2015 15:01:54 -0700 Subject: [PATCH] Fix alignment of 64-bit atomics on iOS The ldrexd and strexd instructions require 64-bit alignment, but Clang for iOS aligns those types on 32-bit boundaries inside structures. We can't use Q_ALIGNOF because it returns the alignment for the type inside a structure. Task-number: QTBUG-46949 Change-Id: Ib056b47dde3341ef9a52ffff13ef17bede0846f2 Reviewed-by: Olivier Goffart (Woboq GmbH) --- src/corelib/arch/qatomic_armv6.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/corelib/arch/qatomic_armv6.h b/src/corelib/arch/qatomic_armv6.h index b14ab3d636..b2ea85ada2 100644 --- a/src/corelib/arch/qatomic_armv6.h +++ b/src/corelib/arch/qatomic_armv6.h @@ -90,7 +90,10 @@ private: template struct QAtomicOps : QBasicAtomicOps { - typedef T Type; + // this is GCC or GCC-like, so we can use extensions: + // force the alignment to be the size of the type, as on some ABIs the alignment + // of 64-bit types is 32-bit. We need proper alignment for LDREX / STREX. + typedef __attribute__((__aligned__(sizeof(T)))) T Type; }; #ifndef Q_CC_RVCT