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/arch/qatomic_unix.h | |
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/arch/qatomic_unix.h')
-rw-r--r-- | src/corelib/arch/qatomic_unix.h | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/src/corelib/arch/qatomic_unix.h b/src/corelib/arch/qatomic_unix.h index 02583297f9..017adabbe2 100644 --- a/src/corelib/arch/qatomic_unix.h +++ b/src/corelib/arch/qatomic_unix.h @@ -64,15 +64,25 @@ QT_END_NAMESPACE #define Q_ATOMIC_INT32_FETCH_AND_STORE_IS_NOT_NATIVE #define Q_ATOMIC_INT32_FETCH_AND_ADD_IS_NOT_NATIVE +#define Q_ATOMIC_INT64_IS_SUPPORTED +#define Q_ATOMIC_INT64_REFERENCE_COUNTING_IS_NOT_NATIVE +#define Q_ATOMIC_INT64_TEST_AND_SET_IS_NOT_NATIVE +#define Q_ATOMIC_INT64_FETCH_AND_STORE_IS_NOT_NATIVE +#define Q_ATOMIC_INT64_FETCH_AND_ADD_IS_NOT_NATIVE + #define Q_ATOMIC_POINTER_TEST_AND_SET_IS_NOT_NATIVE #define Q_ATOMIC_POINTER_FETCH_AND_STORE_IS_NOT_NATIVE #define Q_ATOMIC_POINTER_FETCH_AND_ADD_IS_NOT_NATIVE template<> struct QAtomicIntegerTraits<int> { enum { IsInteger = 1 }; }; +template<> struct QAtomicIntegerTraits<unsigned> { enum { IsInteger = 1 }; }; +template<> struct QAtomicIntegerTraits<long long> { enum { IsInteger = 1 }; }; +template<> struct QAtomicIntegerTraits<unsigned long long> { enum { IsInteger = 1 }; }; // No definition, needs specialization template <typename T> struct QAtomicOps; +// 32-bit version template <> struct QAtomicOps<int> : QGenericAtomicOps<QAtomicOps<int> > { @@ -83,6 +93,18 @@ struct QAtomicOps<int> : QGenericAtomicOps<QAtomicOps<int> > Q_CORE_EXPORT static bool testAndSetRelaxed(int &_q_value, int expectedValue, int newValue) Q_DECL_NOTHROW; }; +// 64-bit version +template <> +struct QAtomicOps<long long> : QGenericAtomicOps<QAtomicOps<long long> > +{ + typedef long long Type; + + 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(Type &_q_value, Type expectedValue, Type newValue) Q_DECL_NOTHROW; +}; + +// pointer version template <> struct QAtomicOps<void *> : QGenericAtomicOps<QAtomicOps<void *> > { @@ -113,5 +135,23 @@ struct QAtomicOps<T *> : QGenericAtomicOps<QAtomicOps<T *> > } }; +// 32- and 64-bit unsigned versions +template <> struct QAtomicOps<unsigned> : QAtomicOps<int> +{ + typedef unsigned Type; + Q_CORE_EXPORT static bool testAndSetRelaxed(Type &_q_value, Type expectedValue, Type newValue) Q_DECL_NOTHROW + { + return QAtomicOps<int>::testAndSetRelaxed(reinterpret_cast<int &>(_q_value), int(expectedValue), int(newValue)); + } +}; +template <> struct QAtomicOps<unsigned long long> : QAtomicOps<long long> +{ + typedef unsigned long longType; + Q_CORE_EXPORT static bool testAndSetRelaxed(Type &_q_value, Type expectedValue, Type newValue) Q_DECL_NOTHROW + { + return QAtomicOps<long long>::testAndSetRelaxed(reinterpret_cast<long long &>(_q_value), int(expectedValue), int(newValue)); + } +}; + QT_END_NAMESPACE #endif // QATOMIC_UNIX_H |