diff options
author | Thiago Macieira <thiago.macieira@intel.com> | 2015-01-15 15:16:53 -0800 |
---|---|---|
committer | Thiago Macieira <thiago.macieira@intel.com> | 2015-03-05 00:05:00 +0000 |
commit | 212285639d748c7def8648f89b8c1c21c5f481e6 (patch) | |
tree | e283c0e0e99fb5aee81a2364f4ed00478bc26b36 /tests/auto/corelib/thread/qatomicinteger/tst_qatomicinteger.cpp | |
parent | 126d489f7f561bc3967ee2a36624c3b1fa26f974 (diff) |
Add missing fetchAndXxx methods to atomic classes based on std::atomic
And add tests for the GCC intrinsics and for std::atomic.
Task-number: QTBUG-43794
Change-Id: Ic5d393bfd36e48a193fcffff13b9b2dbaee80469
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
Diffstat (limited to 'tests/auto/corelib/thread/qatomicinteger/tst_qatomicinteger.cpp')
-rw-r--r-- | tests/auto/corelib/thread/qatomicinteger/tst_qatomicinteger.cpp | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/auto/corelib/thread/qatomicinteger/tst_qatomicinteger.cpp b/tests/auto/corelib/thread/qatomicinteger/tst_qatomicinteger.cpp index cb01237b85..d3c85c54a7 100644 --- a/tests/auto/corelib/thread/qatomicinteger/tst_qatomicinteger.cpp +++ b/tests/auto/corelib/thread/qatomicinteger/tst_qatomicinteger.cpp @@ -31,6 +31,30 @@ ** ****************************************************************************/ +#ifdef QT_ATOMIC_FORCE_CXX11 +// We need to check if this compiler has C++11 atomics and constexpr support. +// We can't rely on qcompilerdetection.h because it forces all of qglobal.h to +// be included, which causes qbasicatomic.h to be included too. +// Incomplete, but ok +# if defined(__INTEL_COMPILER) && __INTEL_COMPILER >= 1500 && (__cplusplus >= 201103L || defined(__INTEL_CXX11_MODE__)) +# elif defined(__clang__) && (__cplusplus >= 201103L || defined(__GXX_EXPERIMENTAL_CXX0X__)) +# if !__has_feature(cxx_constexpr) || !__has_feature(cxx_atomic) || !__has_include(<atomic>) +# undef QT_ATOMIC_FORCE_CXX11 +# endif +# elif defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__) >= 407 && (__cplusplus >= 201103L || defined(__GXX_EXPERIMENTAL_CXX0X__)) +# elif defined(_MSC_VER) && _MSC_VER >= 1900 + // We need MSVC 2015 because of: atomics (2012), constexpr (2015), and unrestricted unions (2015). + // Support for constexpr is not working completely on MSVC 2015 but it's enough for the test. +# else +# undef QT_ATOMIC_FORCE_CXX11 +# endif + +# ifndef QT_ATOMIC_FORCE_CXX11 +# undef QATOMIC_TEST_TYPE +# define QATOMIC_TEST_TYPE unsupported +# endif +#endif + #include <QtTest> #include <QAtomicInt> |