summaryrefslogtreecommitdiffstats
path: root/src/corelib
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@kdab.com>2013-09-18 16:21:35 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-09-21 01:25:19 +0200
commit129a8ce3898091c7a6a84b9b0b68fa32b7ce61bd (patch)
tree896335d7f01d8f054c0c85c6685034a50b4a41cf /src/corelib
parent9efa71ac0a0e9c5f3d52b0205eee2c015f96443f (diff)
qatomic_cxx11: fix fetchAndAdd*()
In qatomic_cxx11, the 'Type' is std::atomic<T>, whose fetch_add method, used in fetchAndAdd*(), already does the right thing for T* with sizeof(T) > 1. The code, however, applied 'AddScale' to the 'valueToAdd', thus becoming incompatible with normal pointer arithmetics. This is very apparent when one goes to the length of actually testing qatomic_cxx11 with tst_QAtomicPointer (which is non-trivial, since the -c++11 configure option currently doesn't have an effect on tests/auto). To fix, remove the AddScale factor. Change-Id: I7507203af3b7df31d8322b31a6a1a33ca847d224 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib')
-rw-r--r--src/corelib/arch/qatomic_cxx11.h12
1 files changed, 4 insertions, 8 deletions
diff --git a/src/corelib/arch/qatomic_cxx11.h b/src/corelib/arch/qatomic_cxx11.h
index ed19064724..55e71e1e88 100644
--- a/src/corelib/arch/qatomic_cxx11.h
+++ b/src/corelib/arch/qatomic_cxx11.h
@@ -219,29 +219,25 @@ template <typename X> struct QAtomicOps
template <typename T> static inline
T fetchAndAddRelaxed(std::atomic<T> &_q_value, typename QAtomicAdditiveType<T>::AdditiveT valueToAdd) Q_DECL_NOTHROW
{
- return _q_value.fetch_add(valueToAdd * QAtomicAdditiveType<T>::AddScale,
- std::memory_order_relaxed);
+ return _q_value.fetch_add(valueToAdd, std::memory_order_relaxed);
}
template <typename T> static inline
T fetchAndAddAcquire(std::atomic<T> &_q_value, typename QAtomicAdditiveType<T>::AdditiveT valueToAdd) Q_DECL_NOTHROW
{
- return _q_value.fetch_add(valueToAdd * QAtomicAdditiveType<T>::AddScale,
- std::memory_order_acquire);
+ return _q_value.fetch_add(valueToAdd, std::memory_order_acquire);
}
template <typename T> static inline
T fetchAndAddRelease(std::atomic<T> &_q_value, typename QAtomicAdditiveType<T>::AdditiveT valueToAdd) Q_DECL_NOTHROW
{
- return _q_value.fetch_add(valueToAdd * QAtomicAdditiveType<T>::AddScale,
- std::memory_order_release);
+ return _q_value.fetch_add(valueToAdd, std::memory_order_release);
}
template <typename T> static inline
T fetchAndAddOrdered(std::atomic<T> &_q_value, typename QAtomicAdditiveType<T>::AdditiveT valueToAdd) Q_DECL_NOTHROW
{
- return _q_value.fetch_add(valueToAdd * QAtomicAdditiveType<T>::AddScale,
- std::memory_order_acq_rel);
+ return _q_value.fetch_add(valueToAdd, std::memory_order_acq_rel);
}
};