Add Q_DECL_CONSTEXPR to the isXXX functions in the new atomics.

This allows one to write code that depends on these values at
compile-time.

Change-Id: I7d78524ed9c70d4141360496d1d764dcbfa92e62
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
Thiago Macieira 2012-08-06 18:03:49 +02:00 committed by Qt by Nokia
parent 624911e481
commit 2b00f97ab0
13 changed files with 124 additions and 96 deletions

View File

@ -101,8 +101,8 @@ template <int size> struct QBasicAtomicOps: QGenericAtomicOps<QBasicAtomicOps<si
template <typename T> static bool ref(T &_q_value) Q_DECL_NOTHROW;
template <typename T> static bool deref(T &_q_value) Q_DECL_NOTHROW;
static bool isTestAndSetNative() Q_DECL_NOTHROW { return false; }
static bool isTestAndSetWaitFree() Q_DECL_NOTHROW { return false; }
static Q_DECL_CONSTEXPR bool isTestAndSetNative() Q_DECL_NOTHROW { return false; }
static Q_DECL_CONSTEXPR bool isTestAndSetWaitFree() Q_DECL_NOTHROW { return false; }
template <typename T> static bool testAndSetRelaxed(T &_q_value, T expectedValue, T newValue) Q_DECL_NOTHROW;
template <typename T> static T fetchAndStoreRelaxed(T &_q_value, T newValue) Q_DECL_NOTHROW;
template <typename T> static

View File

@ -80,18 +80,18 @@ template <int size> struct QBasicAtomicOps: QGenericAtomicOps<QBasicAtomicOps<si
template <typename T>
static void orderedMemoryFence(const T &) Q_DECL_NOTHROW;
static inline bool isReferenceCountingNative() Q_DECL_NOTHROW { return true; }
static inline Q_DECL_CONSTEXPR bool isReferenceCountingNative() Q_DECL_NOTHROW { return true; }
template <typename T> static bool ref(T &_q_value) Q_DECL_NOTHROW;
template <typename T> static bool deref(T &_q_value) Q_DECL_NOTHROW;
static inline bool isTestAndSetNative() Q_DECL_NOTHROW { return true; }
static inline bool isTestAndSetWaitFree() Q_DECL_NOTHROW { return false; }
static inline Q_DECL_CONSTEXPR bool isTestAndSetNative() Q_DECL_NOTHROW { return true; }
static inline Q_DECL_CONSTEXPR bool isTestAndSetWaitFree() Q_DECL_NOTHROW { return false; }
template <typename T> static bool testAndSetRelaxed(T &_q_value, T expectedValue, T newValue) Q_DECL_NOTHROW;
static inline bool isFetchAndStoreNative() Q_DECL_NOTHROW { return true; }
static inline Q_DECL_CONSTEXPR bool isFetchAndStoreNative() Q_DECL_NOTHROW { return true; }
template <typename T> static T fetchAndStoreRelaxed(T &_q_value, T newValue) Q_DECL_NOTHROW;
static inline bool isFetchAndAddNative() Q_DECL_NOTHROW { return true; }
static inline Q_DECL_CONSTEXPR bool isFetchAndAddNative() Q_DECL_NOTHROW { return true; }
template <typename T> static
T fetchAndAddRelaxed(T &_q_value, typename QAtomicAdditiveType<T>::AdditiveT valueToAdd) Q_DECL_NOTHROW;
};

View File

@ -144,8 +144,8 @@ template <typename T> struct QAtomicOps
_q_value.store(newValue, std::memory_order_release);
}
static inline bool isReferenceCountingNative() Q_DECL_NOTHROW { return true; }
static inline bool isReferenceCountingWaitFree() Q_DECL_NOTHROW { return false; }
static inline Q_DECL_CONSTEXPR bool isReferenceCountingNative() Q_DECL_NOTHROW { return true; }
static inline Q_DECL_CONSTEXPR bool isReferenceCountingWaitFree() Q_DECL_NOTHROW { return false; }
static inline bool ref(Type &_q_value)
{
return ++_q_value != 0;
@ -156,8 +156,8 @@ template <typename T> struct QAtomicOps
return --_q_value != 0;
}
static inline bool isTestAndSetNative() Q_DECL_NOTHROW { return false; }
static inline bool isTestAndSetWaitFree() Q_DECL_NOTHROW { return false; }
static inline Q_DECL_CONSTEXPR bool isTestAndSetNative() Q_DECL_NOTHROW { return false; }
static inline Q_DECL_CONSTEXPR bool isTestAndSetWaitFree() Q_DECL_NOTHROW { return false; }
static
bool testAndSetRelaxed(Type &_q_value, T expectedValue, T newValue) Q_DECL_NOTHROW
@ -180,8 +180,8 @@ template <typename T> struct QAtomicOps
return _q_value.compare_exchange_strong(expectedValue, newValue, std::memory_order_acq_rel);
}
static inline bool isFetchAndStoreNative() Q_DECL_NOTHROW { return false; }
static inline bool isFetchAndStoreWaitFree() Q_DECL_NOTHROW { return false; }
static inline Q_DECL_CONSTEXPR bool isFetchAndStoreNative() Q_DECL_NOTHROW { return false; }
static inline Q_DECL_CONSTEXPR bool isFetchAndStoreWaitFree() Q_DECL_NOTHROW { return false; }
static T fetchAndStoreRelaxed(Type &_q_value, T newValue) Q_DECL_NOTHROW
{
@ -203,8 +203,8 @@ template <typename T> struct QAtomicOps
return _q_value.exchange(newValue, std::memory_order_acq_rel);
}
static inline bool isFetchAndAddNative() Q_DECL_NOTHROW { return false; }
static inline bool isFetchAndAddWaitFree() Q_DECL_NOTHROW { return false; }
static inline Q_DECL_CONSTEXPR bool isFetchAndAddNative() Q_DECL_NOTHROW { return false; }
static inline Q_DECL_CONSTEXPR bool isFetchAndAddWaitFree() Q_DECL_NOTHROW { return false; }
static
T fetchAndAddRelaxed(Type &_q_value, _AdditiveType valueToAdd) Q_DECL_NOTHROW

View File

@ -98,8 +98,8 @@ template <typename T> struct QAtomicOps: QGenericAtomicOps<QAtomicOps<T> >
}
#endif
static bool isTestAndSetNative() Q_DECL_NOTHROW { return false; }
static bool isTestAndSetWaitFree() Q_DECL_NOTHROW { return false; }
static Q_DECL_CONSTEXPR bool isTestAndSetNative() Q_DECL_NOTHROW { return false; }
static Q_DECL_CONSTEXPR bool isTestAndSetWaitFree() Q_DECL_NOTHROW { return false; }
static bool testAndSetRelaxed(T &_q_value, T expectedValue, T newValue) Q_DECL_NOTHROW
{
return __sync_bool_compare_and_swap(&_q_value, expectedValue, newValue);

View File

@ -154,27 +154,27 @@ template <int size> struct QBasicAtomicOps: QGenericAtomicOps<QBasicAtomicOps<si
{
*static_cast<volatile T *>(&_q_value) = newValue;
}
static inline bool isReferenceCountingNative() Q_DECL_NOTHROW { return true; }
static inline bool isReferenceCountingWaitFree() Q_DECL_NOTHROW { return size == 4 || size == 8; }
static inline Q_DECL_CONSTEXPR bool isReferenceCountingNative() Q_DECL_NOTHROW { return true; }
static inline Q_DECL_CONSTEXPR bool isReferenceCountingWaitFree() Q_DECL_NOTHROW { return size == 4 || size == 8; }
template <typename T> static bool ref(T &_q_value) Q_DECL_NOTHROW;
template <typename T> static bool deref(T &_q_value) Q_DECL_NOTHROW;
static inline bool isTestAndSetNative() Q_DECL_NOTHROW { return true; }
static inline bool isTestAndSetWaitFree() Q_DECL_NOTHROW { return true; }
static inline Q_DECL_CONSTEXPR bool isTestAndSetNative() Q_DECL_NOTHROW { return true; }
static inline Q_DECL_CONSTEXPR bool isTestAndSetWaitFree() Q_DECL_NOTHROW { return true; }
template <typename T> static bool testAndSetRelaxed(T &_q_value, T expectedValue, T newValue) Q_DECL_NOTHROW;
template <typename T> static bool testAndSetAcquire(T &_q_value, T expectedValue, T newValue) Q_DECL_NOTHROW;
template <typename T> static bool testAndSetRelease(T &_q_value, T expectedValue, T newValue) Q_DECL_NOTHROW;
template <typename T> static bool testAndSetOrdered(T &_q_value, T expectedValue, T newValue) Q_DECL_NOTHROW;
static inline bool isFetchAndStoreNative() Q_DECL_NOTHROW { return true; }
static inline bool isFetchAndStoreWaitFree() Q_DECL_NOTHROW { return true; }
static inline Q_DECL_CONSTEXPR bool isFetchAndStoreNative() Q_DECL_NOTHROW { return true; }
static inline Q_DECL_CONSTEXPR bool isFetchAndStoreWaitFree() Q_DECL_NOTHROW { return true; }
template <typename T> static T fetchAndStoreRelaxed(T &_q_value, T newValue) Q_DECL_NOTHROW;
template <typename T> static T fetchAndStoreAcquire(T &_q_value, T newValue) Q_DECL_NOTHROW;
template <typename T> static T fetchAndStoreRelease(T &_q_value, T newValue) Q_DECL_NOTHROW;
template <typename T> static T fetchAndStoreOrdered(T &_q_value, T newValue) Q_DECL_NOTHROW;
static inline bool isFetchAndAddNative() Q_DECL_NOTHROW { return true; }
static inline bool isFetchAndAddWaitFree() Q_DECL_NOTHROW { return false; }
static inline Q_DECL_CONSTEXPR bool isFetchAndAddNative() Q_DECL_NOTHROW { return true; }
static inline Q_DECL_CONSTEXPR bool isFetchAndAddWaitFree() Q_DECL_NOTHROW { return false; }
template <typename T> static
T fetchAndAddRelaxed(T &_q_value, typename QAtomicAdditiveType<T>::AdditiveT valueToAdd) Q_DECL_NOTHROW;
template <typename T> static

View File

@ -84,18 +84,18 @@ template <int size> struct QBasicAtomicOps: QGenericAtomicOps<QBasicAtomicOps<si
template <typename T>
static void orderedMemoryFence(const T &) Q_DECL_NOTHROW;
static inline bool isReferenceCountingNative() Q_DECL_NOTHROW { return true; }
static inline Q_DECL_CONSTEXPR bool isReferenceCountingNative() Q_DECL_NOTHROW { return true; }
template <typename T> static bool ref(T &_q_value) Q_DECL_NOTHROW;
template <typename T> static bool deref(T &_q_value) Q_DECL_NOTHROW;
static inline bool isTestAndSetNative() Q_DECL_NOTHROW { return true; }
static inline bool isTestAndSetWaitFree() Q_DECL_NOTHROW { return false; }
static inline Q_DECL_CONSTEXPR bool isTestAndSetNative() Q_DECL_NOTHROW { return true; }
static inline Q_DECL_CONSTEXPR bool isTestAndSetWaitFree() Q_DECL_NOTHROW { return false; }
template <typename T> static bool testAndSetRelaxed(T &_q_value, T expectedValue, T newValue) Q_DECL_NOTHROW;
static inline bool isFetchAndStoreNative() Q_DECL_NOTHROW { return true; }
static inline Q_DECL_CONSTEXPR bool isFetchAndStoreNative() Q_DECL_NOTHROW { return true; }
template <typename T> static T fetchAndStoreRelaxed(T &_q_value, T newValue) Q_DECL_NOTHROW;
static inline bool isFetchAndAddNative() Q_DECL_NOTHROW { return true; }
static inline Q_DECL_CONSTEXPR bool isFetchAndAddNative() Q_DECL_NOTHROW { return true; }
template <typename T> static
T fetchAndAddRelaxed(T &_q_value, typename QAtomicAdditiveType<T>::AdditiveT valueToAdd) Q_DECL_NOTHROW;
};

View File

@ -276,21 +276,21 @@ struct QAtomicOpsBySize<4> : QGenericAtomicOps<QAtomicOpsBySize<4> >
// The 32-bit Interlocked*() API takes parameters as longs.
typedef long Type;
static inline bool isReferenceCountingNative() Q_DECL_NOTHROW { return true; }
static inline bool isReferenceCountingWaitFree() Q_DECL_NOTHROW { return true; }
static inline Q_DECL_CONSTEXPR bool isReferenceCountingNative() Q_DECL_NOTHROW { return true; }
static inline Q_DECL_CONSTEXPR bool isReferenceCountingWaitFree() Q_DECL_NOTHROW { return true; }
static bool ref(long &_q_value) Q_DECL_NOTHROW;
static bool deref(long &_q_value) Q_DECL_NOTHROW;
static inline bool isTestAndSetNative() Q_DECL_NOTHROW { return true; }
static inline bool isTestAndSetWaitFree() Q_DECL_NOTHROW { return true; }
static inline Q_DECL_CONSTEXPR bool isTestAndSetNative() Q_DECL_NOTHROW { return true; }
static inline Q_DECL_CONSTEXPR bool isTestAndSetWaitFree() Q_DECL_NOTHROW { return true; }
static bool testAndSetRelaxed(long &_q_value, long expectedValue, long newValue) Q_DECL_NOTHROW;
static inline bool isFetchAndStoreNative() Q_DECL_NOTHROW { return true; }
static inline bool isFetchAndStoreWaitFree() Q_DECL_NOTHROW { return true; }
static inline Q_DECL_CONSTEXPR bool isFetchAndStoreNative() Q_DECL_NOTHROW { return true; }
static inline Q_DECL_CONSTEXPR bool isFetchAndStoreWaitFree() Q_DECL_NOTHROW { return true; }
static long fetchAndStoreRelaxed(long &_q_value, long newValue) Q_DECL_NOTHROW;
static inline bool isFetchAndAddNative() Q_DECL_NOTHROW { return true; }
static inline bool isFetchAndAddWaitFree() Q_DECL_NOTHROW { return true; }
static inline Q_DECL_CONSTEXPR bool isFetchAndAddNative() Q_DECL_NOTHROW { return true; }
static inline Q_DECL_CONSTEXPR bool isFetchAndAddWaitFree() Q_DECL_NOTHROW { return true; }
static long fetchAndAddRelaxed(long &_q_value, QAtomicAdditiveType<long>::AdditiveT valueToAdd) Q_DECL_NOTHROW;
};
@ -329,16 +329,16 @@ struct QAtomicOps<T *> : QGenericAtomicOps<QAtomicOps<T *> >
{
typedef T *Type;
static inline bool isTestAndSetNative() Q_DECL_NOTHROW { return true; }
static inline bool isTestAndSetWaitFree() Q_DECL_NOTHROW { return true; }
static inline Q_DECL_CONSTEXPR bool isTestAndSetNative() Q_DECL_NOTHROW { return true; }
static inline Q_DECL_CONSTEXPR bool isTestAndSetWaitFree() Q_DECL_NOTHROW { return true; }
static bool testAndSetRelaxed(T *&_q_value, T *expectedValue, T *newValue) Q_DECL_NOTHROW;
static inline bool isFetchAndStoreNative() Q_DECL_NOTHROW { return true; }
static inline bool isFetchAndStoreWaitFree() Q_DECL_NOTHROW { return true; }
static inline Q_DECL_CONSTEXPR bool isFetchAndStoreNative() Q_DECL_NOTHROW { return true; }
static inline Q_DECL_CONSTEXPR bool isFetchAndStoreWaitFree() Q_DECL_NOTHROW { return true; }
static T *fetchAndStoreRelaxed(T *&_q_value, T *newValue) Q_DECL_NOTHROW;
static inline bool isFetchAndAddNative() Q_DECL_NOTHROW { return true; }
static inline bool isFetchAndAddWaitFree() Q_DECL_NOTHROW { return true; }
static inline Q_DECL_CONSTEXPR bool isFetchAndAddNative() Q_DECL_NOTHROW { return true; }
static inline Q_DECL_CONSTEXPR bool isFetchAndAddWaitFree() Q_DECL_NOTHROW { return true; }
static T *fetchAndAddRelaxed(T *&_q_value, qptrdiff valueToAdd) Q_DECL_NOTHROW;
};

View File

@ -76,8 +76,8 @@ struct QAtomicOps<int> : QGenericAtomicOps<QAtomicOps<int> >
{
typedef int Type;
static inline bool isTestAndSetNative() Q_DECL_NOTHROW { return false; }
static inline bool isTestAndSetWaitFree() Q_DECL_NOTHROW { return false; }
static inline Q_DECL_CONSTEXPR bool isTestAndSetNative() Q_DECL_NOTHROW { return false; }
static inline Q_DECL_CONSTEXPR bool isTestAndSetWaitFree() Q_DECL_NOTHROW { return false; }
Q_CORE_EXPORT static bool testAndSetRelaxed(int &_q_value, int expectedValue, int newValue) Q_DECL_NOTHROW;
};
@ -86,8 +86,8 @@ struct QAtomicOps<void *> : QGenericAtomicOps<QAtomicOps<void *> >
{
typedef void *Type;
static inline bool isTestAndSetNative() Q_DECL_NOTHROW { return false; }
static inline bool isTestAndSetWaitFree() Q_DECL_NOTHROW { return false; }
static inline Q_DECL_CONSTEXPR bool isTestAndSetNative() Q_DECL_NOTHROW { return false; }
static inline Q_DECL_CONSTEXPR bool isTestAndSetWaitFree() Q_DECL_NOTHROW { return false; }
Q_CORE_EXPORT static bool testAndSetRelaxed(void *&_q_value, void *expectedValue, void *newValue) Q_DECL_NOTHROW;
};
@ -99,8 +99,8 @@ struct QAtomicOps<T *> : QGenericAtomicOps<QAtomicOps<T *> >
// helper to strip cv qualifiers
static inline void *nocv(const T *p) { return const_cast<void *>(static_cast<const volatile void *>(p)); }
static inline bool isTestAndSetNative() Q_DECL_NOTHROW { return false; }
static inline bool isTestAndSetWaitFree() Q_DECL_NOTHROW { return false; }
static inline Q_DECL_CONSTEXPR bool isTestAndSetNative() Q_DECL_NOTHROW { return false; }
static inline Q_DECL_CONSTEXPR bool isTestAndSetWaitFree() Q_DECL_NOTHROW { return false; }
static inline bool testAndSetRelaxed(T *&_q_value, T *expectedValue, T *newValue) Q_DECL_NOTHROW
{
// forward to the void* specialization

View File

@ -97,21 +97,21 @@ template<> struct QAtomicIntegerTraits<unsigned int> { enum { IsInteger = 1 }; }
template <int size> struct QBasicAtomicOps: QGenericAtomicOps<QBasicAtomicOps<size> >
{
static inline bool isReferenceCountingNative() Q_DECL_NOTHROW { return true; }
static inline bool isReferenceCountingWaitFree() Q_DECL_NOTHROW { return true; }
static inline Q_DECL_CONSTEXPR bool isReferenceCountingNative() Q_DECL_NOTHROW { return true; }
static inline Q_DECL_CONSTEXPR bool isReferenceCountingWaitFree() Q_DECL_NOTHROW { return true; }
template <typename T> static bool ref(T &_q_value) Q_DECL_NOTHROW;
template <typename T> static bool deref(T &_q_value) Q_DECL_NOTHROW;
static inline bool isTestAndSetNative() Q_DECL_NOTHROW { return true; }
static inline bool isTestAndSetWaitFree() Q_DECL_NOTHROW { return true; }
static inline Q_DECL_CONSTEXPR bool isTestAndSetNative() Q_DECL_NOTHROW { return true; }
static inline Q_DECL_CONSTEXPR bool isTestAndSetWaitFree() Q_DECL_NOTHROW { return true; }
template <typename T> static bool testAndSetRelaxed(T &_q_value, T expectedValue, T newValue) Q_DECL_NOTHROW;
static inline bool isFetchAndStoreNative() Q_DECL_NOTHROW { return true; }
static inline bool isFetchAndStoreWaitFree() Q_DECL_NOTHROW { return true; }
static inline Q_DECL_CONSTEXPR bool isFetchAndStoreNative() Q_DECL_NOTHROW { return true; }
static inline Q_DECL_CONSTEXPR bool isFetchAndStoreWaitFree() Q_DECL_NOTHROW { return true; }
template <typename T> static T fetchAndStoreRelaxed(T &_q_value, T newValue) Q_DECL_NOTHROW;
static inline bool isFetchAndAddNative() Q_DECL_NOTHROW { return true; }
static inline bool isFetchAndAddWaitFree() Q_DECL_NOTHROW { return true; }
static inline Q_DECL_CONSTEXPR bool isFetchAndAddNative() Q_DECL_NOTHROW { return true; }
static inline Q_DECL_CONSTEXPR bool isFetchAndAddWaitFree() Q_DECL_NOTHROW { return true; }
template <typename T> static
T fetchAndAddRelaxed(T &_q_value, typename QAtomicAdditiveType<T>::AdditiveT valueToAdd) Q_DECL_NOTHROW;
};
@ -381,8 +381,8 @@ bool QBasicAtomicOps<8>::deref(T &_q_value) Q_DECL_NOTHROW
// i386 architecture, emulate 64-bit support via cmpxchg8b
template <> struct QBasicAtomicOps<8>: QGenericAtomicOps<QBasicAtomicOps<8> >
{
static inline bool isTestAndSetNative() Q_DECL_NOTHROW { return true; }
static inline bool isTestAndSetWaitFree() Q_DECL_NOTHROW { return true; }
static inline Q_DECL_CONSTEXPR bool isTestAndSetNative() Q_DECL_NOTHROW { return true; }
static inline Q_DECL_CONSTEXPR bool isTestAndSetWaitFree() Q_DECL_NOTHROW { return true; }
template <typename T> static inline
bool testAndSetRelaxed(T &_q_value, T expectedValue, T newValue) Q_DECL_NOTHROW
{

View File

@ -78,30 +78,30 @@ public:
}
#ifdef qdoc
static bool isReferenceCountingNative();
static bool isReferenceCountingWaitFree();
static Q_DECL_CONSTEXPR bool isReferenceCountingNative();
static Q_DECL_CONSTEXPR bool isReferenceCountingWaitFree();
bool ref();
bool deref();
static bool isTestAndSetNative();
static bool isTestAndSetWaitFree();
static Q_DECL_CONSTEXPR bool isTestAndSetNative();
static Q_DECL_CONSTEXPR bool isTestAndSetWaitFree();
bool testAndSetRelaxed(int expectedValue, int newValue);
bool testAndSetAcquire(int expectedValue, int newValue);
bool testAndSetRelease(int expectedValue, int newValue);
bool testAndSetOrdered(int expectedValue, int newValue);
static bool isFetchAndStoreNative();
static bool isFetchAndStoreWaitFree();
static Q_DECL_CONSTEXPR bool isFetchAndStoreNative();
static Q_DECL_CONSTEXPR bool isFetchAndStoreWaitFree();
int fetchAndStoreRelaxed(int newValue);
int fetchAndStoreAcquire(int newValue);
int fetchAndStoreRelease(int newValue);
int fetchAndStoreOrdered(int newValue);
static bool isFetchAndAddNative();
static bool isFetchAndAddWaitFree();
static Q_DECL_CONSTEXPR bool isFetchAndAddNative();
static Q_DECL_CONSTEXPR bool isFetchAndAddWaitFree();
int fetchAndAddRelaxed(int valueToAdd);
int fetchAndAddAcquire(int valueToAdd);
@ -131,24 +131,24 @@ public:
}
#ifdef qdoc
static bool isTestAndSetNative();
static bool isTestAndSetWaitFree();
static Q_DECL_CONSTEXPR bool isTestAndSetNative();
static Q_DECL_CONSTEXPR bool isTestAndSetWaitFree();
bool testAndSetRelaxed(T *expectedValue, T *newValue);
bool testAndSetAcquire(T *expectedValue, T *newValue);
bool testAndSetRelease(T *expectedValue, T *newValue);
bool testAndSetOrdered(T *expectedValue, T *newValue);
static bool isFetchAndStoreNative();
static bool isFetchAndStoreWaitFree();
static Q_DECL_CONSTEXPR bool isFetchAndStoreNative();
static Q_DECL_CONSTEXPR bool isFetchAndStoreWaitFree();
T *fetchAndStoreRelaxed(T *newValue);
T *fetchAndStoreAcquire(T *newValue);
T *fetchAndStoreRelease(T *newValue);
T *fetchAndStoreOrdered(T *newValue);
static bool isFetchAndAddNative();
static bool isFetchAndAddWaitFree();
static Q_DECL_CONSTEXPR bool isFetchAndAddNative();
static Q_DECL_CONSTEXPR bool isFetchAndAddWaitFree();
T *fetchAndAddRelaxed(qptrdiff valueToAdd);
T *fetchAndAddAcquire(qptrdiff valueToAdd);

View File

@ -137,14 +137,14 @@ public:
T loadAcquire() const Q_DECL_NOTHROW { return Ops::loadAcquire(_q_value); }
void storeRelease(T newValue) Q_DECL_NOTHROW { Ops::storeRelease(_q_value, newValue); }
static bool isReferenceCountingNative() Q_DECL_NOTHROW { return Ops::isReferenceCountingNative(); }
static bool isReferenceCountingWaitFree() Q_DECL_NOTHROW { return Ops::isReferenceCountingWaitFree(); }
static Q_DECL_CONSTEXPR bool isReferenceCountingNative() Q_DECL_NOTHROW { return Ops::isReferenceCountingNative(); }
static Q_DECL_CONSTEXPR bool isReferenceCountingWaitFree() Q_DECL_NOTHROW { return Ops::isReferenceCountingWaitFree(); }
bool ref() Q_DECL_NOTHROW { return Ops::ref(_q_value); }
bool deref() Q_DECL_NOTHROW { return Ops::deref(_q_value); }
static bool isTestAndSetNative() Q_DECL_NOTHROW { return Ops::isTestAndSetNative(); }
static bool isTestAndSetWaitFree() Q_DECL_NOTHROW { return Ops::isTestAndSetWaitFree(); }
static Q_DECL_CONSTEXPR bool isTestAndSetNative() Q_DECL_NOTHROW { return Ops::isTestAndSetNative(); }
static Q_DECL_CONSTEXPR bool isTestAndSetWaitFree() Q_DECL_NOTHROW { return Ops::isTestAndSetWaitFree(); }
bool testAndSetRelaxed(T expectedValue, T newValue) Q_DECL_NOTHROW
{ return Ops::testAndSetRelaxed(_q_value, expectedValue, newValue); }
@ -155,8 +155,8 @@ public:
bool testAndSetOrdered(T expectedValue, T newValue) Q_DECL_NOTHROW
{ return Ops::testAndSetOrdered(_q_value, expectedValue, newValue); }
static bool isFetchAndStoreNative() Q_DECL_NOTHROW { return Ops::isFetchAndStoreNative(); }
static bool isFetchAndStoreWaitFree() Q_DECL_NOTHROW { return Ops::isFetchAndStoreWaitFree(); }
static Q_DECL_CONSTEXPR bool isFetchAndStoreNative() Q_DECL_NOTHROW { return Ops::isFetchAndStoreNative(); }
static Q_DECL_CONSTEXPR bool isFetchAndStoreWaitFree() Q_DECL_NOTHROW { return Ops::isFetchAndStoreWaitFree(); }
T fetchAndStoreRelaxed(T newValue) Q_DECL_NOTHROW
{ return Ops::fetchAndStoreRelaxed(_q_value, newValue); }
@ -167,8 +167,8 @@ public:
T fetchAndStoreOrdered(T newValue) Q_DECL_NOTHROW
{ return Ops::fetchAndStoreOrdered(_q_value, newValue); }
static bool isFetchAndAddNative() Q_DECL_NOTHROW { return Ops::isFetchAndAddNative(); }
static bool isFetchAndAddWaitFree() Q_DECL_NOTHROW { return Ops::isFetchAndAddWaitFree(); }
static Q_DECL_CONSTEXPR bool isFetchAndAddNative() Q_DECL_NOTHROW { return Ops::isFetchAndAddNative(); }
static Q_DECL_CONSTEXPR bool isFetchAndAddWaitFree() Q_DECL_NOTHROW { return Ops::isFetchAndAddWaitFree(); }
T fetchAndAddRelaxed(T valueToAdd) Q_DECL_NOTHROW
{ return Ops::fetchAndAddRelaxed(_q_value, valueToAdd); }
@ -207,8 +207,8 @@ public:
Type loadAcquire() const Q_DECL_NOTHROW { return Ops::loadAcquire(_q_value); }
void storeRelease(Type newValue) Q_DECL_NOTHROW { Ops::storeRelease(_q_value, newValue); }
static bool isTestAndSetNative() Q_DECL_NOTHROW { return Ops::isTestAndSetNative(); }
static bool isTestAndSetWaitFree() Q_DECL_NOTHROW { return Ops::isTestAndSetWaitFree(); }
static Q_DECL_CONSTEXPR bool isTestAndSetNative() Q_DECL_NOTHROW { return Ops::isTestAndSetNative(); }
static Q_DECL_CONSTEXPR bool isTestAndSetWaitFree() Q_DECL_NOTHROW { return Ops::isTestAndSetWaitFree(); }
bool testAndSetRelaxed(Type expectedValue, Type newValue) Q_DECL_NOTHROW
{ return Ops::testAndSetRelaxed(_q_value, expectedValue, newValue); }
@ -219,8 +219,8 @@ public:
bool testAndSetOrdered(Type expectedValue, Type newValue) Q_DECL_NOTHROW
{ return Ops::testAndSetOrdered(_q_value, expectedValue, newValue); }
static bool isFetchAndStoreNative() Q_DECL_NOTHROW { return Ops::isFetchAndStoreNative(); }
static bool isFetchAndStoreWaitFree() Q_DECL_NOTHROW { return Ops::isFetchAndStoreWaitFree(); }
static Q_DECL_CONSTEXPR bool isFetchAndStoreNative() Q_DECL_NOTHROW { return Ops::isFetchAndStoreNative(); }
static Q_DECL_CONSTEXPR bool isFetchAndStoreWaitFree() Q_DECL_NOTHROW { return Ops::isFetchAndStoreWaitFree(); }
Type fetchAndStoreRelaxed(Type newValue) Q_DECL_NOTHROW
{ return Ops::fetchAndStoreRelaxed(_q_value, newValue); }
@ -231,8 +231,8 @@ public:
Type fetchAndStoreOrdered(Type newValue) Q_DECL_NOTHROW
{ return Ops::fetchAndStoreOrdered(_q_value, newValue); }
static bool isFetchAndAddNative() Q_DECL_NOTHROW { return Ops::isFetchAndAddNative(); }
static bool isFetchAndAddWaitFree() Q_DECL_NOTHROW { return Ops::isFetchAndAddWaitFree(); }
static Q_DECL_CONSTEXPR bool isFetchAndAddNative() Q_DECL_NOTHROW { return Ops::isFetchAndAddNative(); }
static Q_DECL_CONSTEXPR bool isFetchAndAddWaitFree() Q_DECL_NOTHROW { return Ops::isFetchAndAddWaitFree(); }
Type fetchAndAddRelaxed(qptrdiff valueToAdd) Q_DECL_NOTHROW
{ return Ops::fetchAndAddRelaxed(_q_value, valueToAdd); }

View File

@ -119,9 +119,9 @@ template <typename BaseClass> struct QGenericAtomicOps
*static_cast<volatile T *>(&_q_value) = newValue;
}
static inline bool isReferenceCountingNative() Q_DECL_NOTHROW
static inline Q_DECL_CONSTEXPR bool isReferenceCountingNative() Q_DECL_NOTHROW
{ return BaseClass::isFetchAndAddNative(); }
static inline bool isReferenceCountingWaitFree() Q_DECL_NOTHROW
static inline Q_DECL_CONSTEXPR bool isReferenceCountingWaitFree() Q_DECL_NOTHROW
{ return BaseClass::isFetchAndAddWaitFree(); }
template <typename T> static inline always_inline
bool ref(T &_q_value) Q_DECL_NOTHROW
@ -138,8 +138,8 @@ template <typename BaseClass> struct QGenericAtomicOps
#if 0
// These functions have no default implementation
// Archictectures must implement them
static inline bool isTestAndSetNative() Q_DECL_NOTHROW;
static inline bool isTestAndSetWaitFree() Q_DECL_NOTHROW;
static inline Q_DECL_CONSTEXPR bool isTestAndSetNative() Q_DECL_NOTHROW;
static inline Q_DECL_CONSTEXPR bool isTestAndSetWaitFree() Q_DECL_NOTHROW;
template <typename T, typename X> static inline
bool testAndSetRelaxed(T &_q_value, X expectedValue, X newValue) Q_DECL_NOTHROW;
#endif
@ -166,8 +166,8 @@ template <typename BaseClass> struct QGenericAtomicOps
return BaseClass::testAndSetRelaxed(_q_value, expectedValue, newValue);
}
static inline bool isFetchAndStoreNative() Q_DECL_NOTHROW { return false; }
static inline bool isFetchAndStoreWaitFree() Q_DECL_NOTHROW { return false; }
static inline Q_DECL_CONSTEXPR bool isFetchAndStoreNative() Q_DECL_NOTHROW { return false; }
static inline Q_DECL_CONSTEXPR bool isFetchAndStoreWaitFree() Q_DECL_NOTHROW { return false; }
template <typename T, typename X> static inline always_inline
T fetchAndStoreRelaxed(T &_q_value, X newValue) Q_DECL_NOTHROW
@ -202,8 +202,8 @@ template <typename BaseClass> struct QGenericAtomicOps
return BaseClass::fetchAndStoreRelaxed(_q_value, newValue);
}
static inline bool isFetchAndAddNative() Q_DECL_NOTHROW { return false; }
static inline bool isFetchAndAddWaitFree() Q_DECL_NOTHROW { return false; }
static inline Q_DECL_CONSTEXPR bool isFetchAndAddNative() Q_DECL_NOTHROW { return false; }
static inline Q_DECL_CONSTEXPR bool isFetchAndAddWaitFree() Q_DECL_NOTHROW { return false; }
template <typename T> static inline always_inline
T fetchAndAddRelaxed(T &_q_value, typename QAtomicAdditiveType<T>::AdditiveT valueToAdd) Q_DECL_NOTHROW
{

View File

@ -161,6 +161,25 @@ static void warningFreeHelperTemplate()
assemblyMarker<64>(&i);
}
template <bool> inline void booleanHelper()
{ }
template <typename Atomic>
static void constexprFunctionsHelperTemplate()
{
#ifdef Q_COMPILER_CONSTEXPR
// this is a compile-time test only
booleanHelper<Atomic::isReferenceCountingNative()>();
booleanHelper<Atomic::isReferenceCountingWaitFree()>();
booleanHelper<Atomic::isTestAndSetNative()>();
booleanHelper<Atomic::isTestAndSetWaitFree()>();
booleanHelper<Atomic::isFetchAndStoreNative()>();
booleanHelper<Atomic::isFetchAndStoreWaitFree()>();
booleanHelper<Atomic::isFetchAndAddNative()>();
booleanHelper<Atomic::isFetchAndAddWaitFree()>();
#endif
}
void tst_QAtomicInt::warningFreeHelper()
{
qFatal("This code is bogus, and shouldn't be run. We're looking for compiler warnings only.");
@ -169,23 +188,32 @@ void tst_QAtomicInt::warningFreeHelper()
#ifdef Q_ATOMIC_INT32_IS_SUPPORTED
warningFreeHelperTemplate<int, QBasicAtomicInteger<int> >();
warningFreeHelperTemplate<unsigned int, QBasicAtomicInteger<unsigned int> >();
constexprFunctionsHelperTemplate<QBasicAtomicInteger<int> >();
constexprFunctionsHelperTemplate<QBasicAtomicInteger<unsigned int> >();
#endif
#ifdef Q_ATOMIC_INT16_IS_SUPPORTED
warningFreeHelperTemplate<qint16, QBasicAtomicInteger<qint16> >();
warningFreeHelperTemplate<quint16, QBasicAtomicInteger<quint16> >();
constexprFunctionsHelperTemplate<QBasicAtomicInteger<qint16> >();
constexprFunctionsHelperTemplate<QBasicAtomicInteger<quint16> >();
#endif
#ifdef Q_ATOMIC_INT8_IS_SUPPORTED
warningFreeHelperTemplate<char, QBasicAtomicInteger<char> >();
warningFreeHelperTemplate<signed char, QBasicAtomicInteger<signed char> >();
warningFreeHelperTemplate<unsigned char, QBasicAtomicInteger<unsigned char> >();
constexprFunctionsHelperTemplate<QBasicAtomicInteger<char> >();
constexprFunctionsHelperTemplate<QBasicAtomicInteger<signed char> >();
constexprFunctionsHelperTemplate<QBasicAtomicInteger<unsigned char> >();
#endif
#ifdef Q_ATOMIC_INT64_IS_SUPPORTED
#if !defined(__i386__) || (defined(Q_CC_GNU) && defined(__OPTIMIZE__))
warningFreeHelperTemplate<qlonglong, QBasicAtomicInteger<qlonglong> >();
warningFreeHelperTemplate<qulonglong, QBasicAtomicInteger<qulonglong> >();
constexprFunctionsHelperTemplate<QBasicAtomicInteger<qlonglong> >();
constexprFunctionsHelperTemplate<QBasicAtomicInteger<qulonglong> >();
#endif
#endif
}