summaryrefslogtreecommitdiffstats
path: root/src/corelib/thread
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2013-12-02 19:39:36 -0800
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-01-30 18:06:23 +0100
commitfd0d576709fff48bc23444b3a30a86e92c625101 (patch)
treee3041b952aad7d02f5c23b1201cf8c1a5f767094 /src/corelib/thread
parent8d2a9bcf1d22c3e48ff9dc7d8aaac9d4fcac0c64 (diff)
Centralize support for QBasicAtomic for ints and longs
No need to redefine everywhere, since they're required to be supported. Change-Id: I2bdbbd0b0c44871e3bd0edcf0289fc58dd50ff31 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Diffstat (limited to 'src/corelib/thread')
-rw-r--r--src/corelib/thread/qatomic.cpp27
-rw-r--r--src/corelib/thread/qgenericatomic.h13
2 files changed, 39 insertions, 1 deletions
diff --git a/src/corelib/thread/qatomic.cpp b/src/corelib/thread/qatomic.cpp
index 36cdfdb369..bebdab3080 100644
--- a/src/corelib/thread/qatomic.cpp
+++ b/src/corelib/thread/qatomic.cpp
@@ -1221,9 +1221,34 @@
QT_BEGIN_NAMESPACE
-// The following three specializations must always be defined
+// The following specializations must always be defined
Q_STATIC_ASSERT(sizeof(QAtomicInteger<unsigned>));
+Q_STATIC_ASSERT(sizeof(QAtomicInteger<long>));
+Q_STATIC_ASSERT(sizeof(QAtomicInteger<unsigned long>));
Q_STATIC_ASSERT(sizeof(QAtomicInteger<quintptr>));
Q_STATIC_ASSERT(sizeof(QAtomicInteger<qptrdiff>));
+#ifdef Q_COMPILER_UNICODE_STRINGS
+Q_STATIC_ASSERT(sizeof(QAtomicInteger<char32_t>));
+#endif
+
+#ifdef Q_ATOMIC_INT16_IS_SUPPORTED
+Q_STATIC_ASSERT(sizeof(QAtomicInteger<short>));
+Q_STATIC_ASSERT(sizeof(QAtomicInteger<unsigned short>));
+# if WCHAR_MAX < 0x10000
+Q_STATIC_ASSERT(sizeof(QAtomicInteger<wchar_t>));
+# endif
+# ifdef Q_COMPILER_UNICODE_STRINGS
+Q_STATIC_ASSERT(sizeof(QAtomicInteger<char16_t>));
+# endif
+#endif
+
+#ifdef Q_ATOMIC_INT64_IS_SUPPORTED
+Q_STATIC_ASSERT(sizeof(QAtomicInteger<qint64>));
+Q_STATIC_ASSERT(sizeof(QAtomicInteger<quint64>));
+#endif
+
+#if WCHAR_MAX == INT_MAX
+Q_STATIC_ASSERT(sizeof(QAtomicInteger<wchar_t>));
+#endif
QT_END_NAMESPACE
diff --git a/src/corelib/thread/qgenericatomic.h b/src/corelib/thread/qgenericatomic.h
index 3a213f6a25..bbdc57ca50 100644
--- a/src/corelib/thread/qgenericatomic.h
+++ b/src/corelib/thread/qgenericatomic.h
@@ -62,6 +62,19 @@ QT_END_NAMESPACE
template<typename T> struct QAtomicIntegerTraits { enum { IsInteger = 0 }; };
+// these integers are always supported, on all platforms
+// - int, unsigned int and char32_t are 32-bit wide
+// - long and unsigned long might be 64-bit wide on 64-bit platforms,
+// but 64-bit integer support is required anyway
+template<> struct QAtomicIntegerTraits<int> { enum { IsInteger = 1 }; };
+template<> struct QAtomicIntegerTraits<unsigned int> { enum { IsInteger = 1 }; };
+template<> struct QAtomicIntegerTraits<long> { enum { IsInteger = 1 }; };
+template<> struct QAtomicIntegerTraits<unsigned long> { enum { IsInteger = 1 }; };
+#ifdef Q_COMPILER_UNICODE_STRINGS
+template<> struct QAtomicIntegerTraits<char32_t>
+{ enum { IsInteger = sizeof(char32_t) == sizeof(int) ? 1 : -1 }; };
+#endif
+
template <typename T> struct QAtomicAdditiveType
{
typedef T AdditiveT;