summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/thread/qatomicinteger/tst_qatomicinteger.cpp
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2018-04-23 19:29:04 -0700
committerThiago Macieira <thiago.macieira@intel.com>2018-04-24 17:36:42 +0000
commit309dacedac6147e8c552b652e5fe2ffd02b6eac3 (patch)
tree2c61ff6100ef0034df5fa2cbea183064543eef3a /tests/auto/corelib/thread/qatomicinteger/tst_qatomicinteger.cpp
parent15ada2b91798638c90630c332e4a8caef7660638 (diff)
Atomics: remove requirement for alignment equality with plain types
This was originally added so that you could replace a T with QAtomicInteger<T> in the same class and still keep ABI. However, for legacy reasons, on 32-bit x86, types larger than 4 bytes keep an old 1990s alignment of only 4 bytes, but modern std::atomic<T> for those 8- byte types enforces an alignment of 8 bytes. Therefore, the requirement to keep alignment is not possible to guarantee. In other words: you may not replace T with QAtomicInteger<T> or std::atomic<T> and assume no ABI breakages in all platforms. This is a requirement to implement atomicity. An 8-byte type aligned to only a 4-byte boundary could cross a 16-byte boundary or, worse, cross a cacheline boundary. Crossing the 16-byte boundary could be bad on some processors, but crossing the cacheline boundary (addresses ending in 0x3C, 0x7C, 0xCC and 0xFC, or 4 out of 64 possible addresses or 6.25%) is always bad: the CPUs cannot guarantee an atomic load or store operation. See also <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71660>. Task-number: QTBUG-67858 Change-Id: If90a92b041d3442fa0a4fffd15283e4615474582 Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
Diffstat (limited to 'tests/auto/corelib/thread/qatomicinteger/tst_qatomicinteger.cpp')
-rw-r--r--tests/auto/corelib/thread/qatomicinteger/tst_qatomicinteger.cpp2
1 files changed, 0 insertions, 2 deletions
diff --git a/tests/auto/corelib/thread/qatomicinteger/tst_qatomicinteger.cpp b/tests/auto/corelib/thread/qatomicinteger/tst_qatomicinteger.cpp
index ca40927ef9..32e5b8ee56 100644
--- a/tests/auto/corelib/thread/qatomicinteger/tst_qatomicinteger.cpp
+++ b/tests/auto/corelib/thread/qatomicinteger/tst_qatomicinteger.cpp
@@ -185,12 +185,10 @@ private Q_SLOTS:
};
template <bool> inline void booleanHelper() { }
-struct TypeInStruct { TEST_TYPE type; };
void tst_QAtomicIntegerXX::static_checks()
{
Q_STATIC_ASSERT(sizeof(QAtomicInteger<T>) == sizeof(T));
- Q_STATIC_ASSERT(Q_ALIGNOF(QAtomicInteger<T>) == Q_ALIGNOF(TypeInStruct));
// statements with no effect
(void) QAtomicInteger<T>::isReferenceCountingNative();