0003-QAtomic-pass-explicit-failure-mode-to-std-atomic-com.patch 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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
  6. ... in an attempt to avoid GCC 4.8 errors such as
  7. bits/atomic_base.h:577:70: error: failure memory model cannot be stronger than success memory model for '__atomic_compare_exchange'
  8. return __atomic_compare_exchange_n(&_M_i, &__i1, __i2, 0, __m1, __m2);
  9. ^
  10. as seen on Android.
  11. Change-Id: If046e735888cf331d2d6506d8d5ca9aa7402f9ad
  12. [Bug report: https://bugreports.qt.io/browse/QTBUG-59399
  13. Patch sent upstream: https://codereview.qt-project.org/#/c/187980/]
  14. Signed-off-by: Vicente Olivert Riera <Vincent.Riera@imgtec.org>
  15. ---
  16. src/corelib/arch/qatomic_cxx11.h | 8 ++++----
  17. 1 file changed, 4 insertions(+), 4 deletions(-)
  18. diff --git a/src/corelib/arch/qatomic_cxx11.h b/src/corelib/arch/qatomic_cxx11.h
  19. index bb49aae..d6731ec 100644
  20. --- a/src/corelib/arch/qatomic_cxx11.h
  21. +++ b/src/corelib/arch/qatomic_cxx11.h
  22. @@ -153,7 +153,7 @@ template <typename X> struct QAtomicOps
  23. template <typename T>
  24. static bool testAndSetRelaxed(std::atomic<T> &_q_value, T expectedValue, T newValue, T *currentValue = Q_NULLPTR) Q_DECL_NOTHROW
  25. {
  26. - bool tmp = _q_value.compare_exchange_strong(expectedValue, newValue, std::memory_order_relaxed);
  27. + bool tmp = _q_value.compare_exchange_strong(expectedValue, newValue, std::memory_order_relaxed, std::memory_order_relaxed);
  28. if (currentValue)
  29. *currentValue = expectedValue;
  30. return tmp;
  31. @@ -162,7 +162,7 @@ template <typename X> struct QAtomicOps
  32. template <typename T>
  33. static bool testAndSetAcquire(std::atomic<T> &_q_value, T expectedValue, T newValue, T *currentValue = Q_NULLPTR) Q_DECL_NOTHROW
  34. {
  35. - bool tmp = _q_value.compare_exchange_strong(expectedValue, newValue, std::memory_order_acquire);
  36. + bool tmp = _q_value.compare_exchange_strong(expectedValue, newValue, std::memory_order_acquire, std::memory_order_acquire);
  37. if (currentValue)
  38. *currentValue = expectedValue;
  39. return tmp;
  40. @@ -171,7 +171,7 @@ template <typename X> struct QAtomicOps
  41. template <typename T>
  42. static bool testAndSetRelease(std::atomic<T> &_q_value, T expectedValue, T newValue, T *currentValue = Q_NULLPTR) Q_DECL_NOTHROW
  43. {
  44. - bool tmp = _q_value.compare_exchange_strong(expectedValue, newValue, std::memory_order_release);
  45. + bool tmp = _q_value.compare_exchange_strong(expectedValue, newValue, std::memory_order_release, std::memory_order_relaxed);
  46. if (currentValue)
  47. *currentValue = expectedValue;
  48. return tmp;
  49. @@ -180,7 +180,7 @@ template <typename X> struct QAtomicOps
  50. template <typename T>
  51. static bool testAndSetOrdered(std::atomic<T> &_q_value, T expectedValue, T newValue, T *currentValue = Q_NULLPTR) Q_DECL_NOTHROW
  52. {
  53. - bool tmp = _q_value.compare_exchange_strong(expectedValue, newValue, std::memory_order_acq_rel);
  54. + bool tmp = _q_value.compare_exchange_strong(expectedValue, newValue, std::memory_order_acq_rel, std::memory_order_acquire);
  55. if (currentValue)
  56. *currentValue = expectedValue;
  57. return tmp;
  58. --
  59. 1.7.10.4