diff options
author | Thiago Macieira <thiago.macieira@intel.com> | 2018-04-23 19:29:04 -0700 |
---|---|---|
committer | Thiago Macieira <thiago.macieira@intel.com> | 2018-04-24 17:36:42 +0000 |
commit | 309dacedac6147e8c552b652e5fe2ffd02b6eac3 (patch) | |
tree | 2c61ff6100ef0034df5fa2cbea183064543eef3a /src/plugins | |
parent | 15ada2b91798638c90630c332e4a8caef7660638 (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 'src/plugins')
0 files changed, 0 insertions, 0 deletions