1 From c5d7425f8ad391112758db161e3e08f18dc9d299 Mon Sep 17 00:00:00 2001
2 From: Marc Mutz <marc.mutz@kdab.com>
3 Date: Thu, 26 May 2016 08:30:26 +0200
4 Subject: [PATCH] QAtomic: pass explicit failure mode to
5 std::atomic::compare_exchange_strong
7 ... in an attempt to avoid GCC 4.8 errors such as
9 bits/atomic_base.h:577:70: error: failure memory model cannot be stronger than success memory model for '__atomic_compare_exchange'
10 return __atomic_compare_exchange_n(&_M_i, &__i1, __i2, 0, __m1, __m2);
15 Change-Id: If046e735888cf331d2d6506d8d5ca9aa7402f9ad
16 [Bug report: https://bugreports.qt.io/browse/QTBUG-59399
17 Patch sent upstream: https://codereview.qt-project.org/#/c/187980/]
18 Signed-off-by: Vicente Olivert Riera <Vincent.Riera@imgtec.org>
20 src/corelib/arch/qatomic_cxx11.h | 8 ++++----
21 1 file changed, 4 insertions(+), 4 deletions(-)
23 diff --git a/src/corelib/arch/qatomic_cxx11.h b/src/corelib/arch/qatomic_cxx11.h
24 index bb49aae..d6731ec 100644
25 --- a/src/corelib/arch/qatomic_cxx11.h
26 +++ b/src/corelib/arch/qatomic_cxx11.h
27 @@ -153,7 +153,7 @@ template <typename X> struct QAtomicOps
29 static bool testAndSetRelaxed(std::atomic<T> &_q_value, T expectedValue, T newValue, T *currentValue = Q_NULLPTR) Q_DECL_NOTHROW
31 - bool tmp = _q_value.compare_exchange_strong(expectedValue, newValue, std::memory_order_relaxed);
32 + bool tmp = _q_value.compare_exchange_strong(expectedValue, newValue, std::memory_order_relaxed, std::memory_order_relaxed);
34 *currentValue = expectedValue;
36 @@ -162,7 +162,7 @@ template <typename X> struct QAtomicOps
38 static bool testAndSetAcquire(std::atomic<T> &_q_value, T expectedValue, T newValue, T *currentValue = Q_NULLPTR) Q_DECL_NOTHROW
40 - bool tmp = _q_value.compare_exchange_strong(expectedValue, newValue, std::memory_order_acquire);
41 + bool tmp = _q_value.compare_exchange_strong(expectedValue, newValue, std::memory_order_acquire, std::memory_order_acquire);
43 *currentValue = expectedValue;
45 @@ -171,7 +171,7 @@ template <typename X> struct QAtomicOps
47 static bool testAndSetRelease(std::atomic<T> &_q_value, T expectedValue, T newValue, T *currentValue = Q_NULLPTR) Q_DECL_NOTHROW
49 - bool tmp = _q_value.compare_exchange_strong(expectedValue, newValue, std::memory_order_release);
50 + bool tmp = _q_value.compare_exchange_strong(expectedValue, newValue, std::memory_order_release, std::memory_order_relaxed);
52 *currentValue = expectedValue;
54 @@ -180,7 +180,7 @@ template <typename X> struct QAtomicOps
56 static bool testAndSetOrdered(std::atomic<T> &_q_value, T expectedValue, T newValue, T *currentValue = Q_NULLPTR) Q_DECL_NOTHROW
58 - bool tmp = _q_value.compare_exchange_strong(expectedValue, newValue, std::memory_order_acq_rel);
59 + bool tmp = _q_value.compare_exchange_strong(expectedValue, newValue, std::memory_order_acq_rel, std::memory_order_acquire);
61 *currentValue = expectedValue;