diff options
author | Thiago Macieira <thiago.macieira@intel.com> | 2012-08-06 18:03:49 +0200 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-08-18 18:35:36 +0200 |
commit | 2b00f97ab05f144293b26d1e0d8cf4c54d222f92 (patch) | |
tree | ef1ff7fa28fdb1449f5e91830adc26c36ef34c6c /tests/auto/corelib/thread/qatomicint/tst_qatomicint.cpp | |
parent | 624911e48174094c80df7e27b28cc2b2d46f4398 (diff) |
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>
Diffstat (limited to 'tests/auto/corelib/thread/qatomicint/tst_qatomicint.cpp')
-rw-r--r-- | tests/auto/corelib/thread/qatomicint/tst_qatomicint.cpp | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/auto/corelib/thread/qatomicint/tst_qatomicint.cpp b/tests/auto/corelib/thread/qatomicint/tst_qatomicint.cpp index c2dc8a4cc6..1283083f0e 100644 --- a/tests/auto/corelib/thread/qatomicint/tst_qatomicint.cpp +++ b/tests/auto/corelib/thread/qatomicint/tst_qatomicint.cpp @@ -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 } |