diff options
author | Thiago Macieira <thiago.macieira@intel.com> | 2013-12-02 19:22:57 -0800 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2014-01-30 18:06:17 +0100 |
commit | 8d2a9bcf1d22c3e48ff9dc7d8aaac9d4fcac0c64 (patch) | |
tree | 100a2f65d4fe3441be703e0fcfa38c34e21cdac4 /src/corelib/thread/qatomic.cpp | |
parent | e4533e3aebeb3aa47ecfdef39d0b5bbc1186ad39 (diff) |
Ensure that the pointer-sized QAtomicInteger specialization exists
This is already implemented in qatomic_x86.h, qatomic_ia64.h,
qatomic_mips.h, qatomic_armv6.h, and qatomic_cxx11.h. For
qatomic_msvc.h, we've just fixed it.
For qatomic_gcc.h, we know that the compiler supports it, so just add
it. According to the GCC manual, it might print a warning on some
platforms, so we only enable that on 64-bit builds.
For qatomic_unix.h, the support was missing (along with support for
unsigned 32-bit), so this commits adds it.
For qatomic_armv5.h, the platform does not always support 64-bit
atomics, but ARMv5 cannot compile in 64-bit mode anyway.
Change-Id: Ia8b3b5c641f11e5df05937fe7442be0a223174ef
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Diffstat (limited to 'src/corelib/thread/qatomic.cpp')
-rw-r--r-- | src/corelib/thread/qatomic.cpp | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/src/corelib/thread/qatomic.cpp b/src/corelib/thread/qatomic.cpp index f70b58d25b..36cdfdb369 100644 --- a/src/corelib/thread/qatomic.cpp +++ b/src/corelib/thread/qatomic.cpp @@ -72,9 +72,10 @@ \li 32-bit: int, unsigned int, qint32, quint32, char32_t (C++11) \li 64-bit: long long, unsigned long long, qint64, quint64 \li platform-specific size: long, unsigned long + \li pointer size: qintptr, quintptr, qptrdiff \endlist - Of the list above, only the 32-bit-sized instantiations are guaranteed to + Of the list above, only the 32-bit- and pointer-sized instantiations are guaranteed to work on all platforms. Support for other sizes depends on the compiler and processor architecture the code is being compiled for. To test whether the other types are supported, check the macro \c Q_ATOMIC_INT\e{nn}_IS_SUPPORTED, @@ -1213,3 +1214,16 @@ #ifndef Q_ATOMIC_INT32_IS_SUPPORTED # error "Q_ATOMIC_INT32_IS_SUPPORTED must be defined" #endif +#if !defined(Q_ATOMIC_INT64_IS_SUPPORTED) && QT_POINTER_SIZE == 8 +// 64-bit platform +# error "Q_ATOMIC_INT64_IS_SUPPORTED must be defined on a 64-bit platform" +#endif + +QT_BEGIN_NAMESPACE + +// The following three specializations must always be defined +Q_STATIC_ASSERT(sizeof(QAtomicInteger<unsigned>)); +Q_STATIC_ASSERT(sizeof(QAtomicInteger<quintptr>)); +Q_STATIC_ASSERT(sizeof(QAtomicInteger<qptrdiff>)); + +QT_END_NAMESPACE |