diff options
author | Oliver Wolff <oliver.wolff@qt.io> | 2016-11-24 12:17:55 +0100 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@qt.io> | 2016-11-29 10:05:58 +0000 |
commit | a103992f49045323a3aaa4970eb1ee5f65a378dd (patch) | |
tree | a7d7f67ee51233406ed25604bad4a4838f3eb6b8 | |
parent | 7eb4be9db89d40ea2cc090e7a562bdd588708607 (diff) |
Fixed build using Visual Studio 2017
As _BitScanForward and friends are not marked constexpr in Visual Studio,
functions using these may not be marked either.
Task-number: QTBUG-57086
Change-Id: I29cfa4459580b5740f1011e7f39309844518ce03
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
-rw-r--r-- | src/corelib/tools/qalgorithms.h | 36 |
1 files changed, 21 insertions, 15 deletions
diff --git a/src/corelib/tools/qalgorithms.h b/src/corelib/tools/qalgorithms.h index 303374b06d..7e846956f5 100644 --- a/src/corelib/tools/qalgorithms.h +++ b/src/corelib/tools/qalgorithms.h @@ -589,15 +589,16 @@ Q_DECL_CONSTEXPR Q_ALWAYS_INLINE uint qt_builtin_popcountll(quint64 v) Q_DECL_NO return __builtin_popcountll(v); } #elif defined(Q_CC_MSVC) && !defined(Q_OS_WINCE) && !defined(Q_PROCESSOR_ARM) +#define QT_POPCOUNT_CONSTEXPR #define QT_HAS_BUILTIN_CTZ -Q_DECL_CONSTEXPR Q_ALWAYS_INLINE unsigned long qt_builtin_ctz(quint32 val) +Q_ALWAYS_INLINE unsigned long qt_builtin_ctz(quint32 val) { unsigned long result; _BitScanForward(&result, val); return result; } #define QT_HAS_BUILTIN_CLZ -Q_DECL_CONSTEXPR Q_ALWAYS_INLINE unsigned long qt_builtin_clz(quint32 val) +Q_ALWAYS_INLINE unsigned long qt_builtin_clz(quint32 val) { unsigned long result; _BitScanReverse(&result, val); @@ -610,7 +611,7 @@ Q_DECL_CONSTEXPR Q_ALWAYS_INLINE unsigned long qt_builtin_clz(quint32 val) #if Q_PROCESSOR_WORDSIZE == 8 // These are only defined for 64bit builds. #define QT_HAS_BUILTIN_CTZLL -Q_DECL_CONSTEXPR Q_ALWAYS_INLINE unsigned long qt_builtin_ctzll(quint64 val) +Q_ALWAYS_INLINE unsigned long qt_builtin_ctzll(quint64 val) { unsigned long result; _BitScanForward64(&result, val); @@ -618,7 +619,7 @@ Q_DECL_CONSTEXPR Q_ALWAYS_INLINE unsigned long qt_builtin_ctzll(quint64 val) } // MSVC calls it _BitScanReverse and returns the carry flag, which we don't need #define QT_HAS_BUILTIN_CLZLL -Q_DECL_CONSTEXPR Q_ALWAYS_INLINE unsigned long qt_builtin_clzll(quint64 val) +Q_ALWAYS_INLINE unsigned long qt_builtin_clzll(quint64 val) { unsigned long result; _BitScanReverse64(&result, val); @@ -628,31 +629,31 @@ Q_DECL_CONSTEXPR Q_ALWAYS_INLINE unsigned long qt_builtin_clzll(quint64 val) } #endif // MSVC 64bit # define QT_HAS_BUILTIN_CTZS -Q_DECL_CONSTEXPR Q_ALWAYS_INLINE uint qt_builtin_ctzs(quint16 v) Q_DECL_NOTHROW +Q_ALWAYS_INLINE uint qt_builtin_ctzs(quint16 v) Q_DECL_NOTHROW { return qt_builtin_ctz(v); } #define QT_HAS_BUILTIN_CLZS -Q_DECL_CONSTEXPR Q_ALWAYS_INLINE uint qt_builtin_clzs(quint16 v) Q_DECL_NOTHROW +Q_ALWAYS_INLINE uint qt_builtin_clzs(quint16 v) Q_DECL_NOTHROW { return qt_builtin_clz(v) - 16U; } #define QALGORITHMS_USE_BUILTIN_POPCOUNT -Q_DECL_CONSTEXPR Q_ALWAYS_INLINE uint qt_builtin_popcount(quint32 v) Q_DECL_NOTHROW +Q_ALWAYS_INLINE uint qt_builtin_popcount(quint32 v) Q_DECL_NOTHROW { return __popcnt(v); } -Q_DECL_CONSTEXPR Q_ALWAYS_INLINE uint qt_builtin_popcount(quint8 v) Q_DECL_NOTHROW +Q_ALWAYS_INLINE uint qt_builtin_popcount(quint8 v) Q_DECL_NOTHROW { return __popcnt16(v); } -Q_DECL_CONSTEXPR Q_ALWAYS_INLINE uint qt_builtin_popcount(quint16 v) Q_DECL_NOTHROW +Q_ALWAYS_INLINE uint qt_builtin_popcount(quint16 v) Q_DECL_NOTHROW { return __popcnt16(v); } #if Q_PROCESSOR_WORDSIZE == 8 #define QALGORITHMS_USE_BUILTIN_POPCOUNTLL -Q_DECL_CONSTEXPR Q_ALWAYS_INLINE uint qt_builtin_popcountll(quint64 v) Q_DECL_NOTHROW +Q_ALWAYS_INLINE uint qt_builtin_popcountll(quint64 v) Q_DECL_NOTHROW { return __popcnt64(v); } @@ -660,9 +661,13 @@ Q_DECL_CONSTEXPR Q_ALWAYS_INLINE uint qt_builtin_popcountll(quint64 v) Q_DECL_NO #endif // MSVC #endif // QT_HAS_CONSTEXPR_BUILTINS +#ifndef QT_POPCOUNT_CONSTEXPR +#define QT_POPCOUNT_CONSTEXPR Q_DECL_CONSTEXPR +#endif + } //namespace QAlgorithmsPrivate -Q_DECL_CONST_FUNCTION Q_DECL_CONSTEXPR inline uint qPopulationCount(quint32 v) Q_DECL_NOTHROW +Q_DECL_CONST_FUNCTION QT_POPCOUNT_CONSTEXPR inline uint qPopulationCount(quint32 v) Q_DECL_NOTHROW { #ifdef QALGORITHMS_USE_BUILTIN_POPCOUNT return QAlgorithmsPrivate::qt_builtin_popcount(v); @@ -675,7 +680,7 @@ Q_DECL_CONST_FUNCTION Q_DECL_CONSTEXPR inline uint qPopulationCount(quint32 v) Q #endif } -Q_DECL_CONST_FUNCTION Q_DECL_CONSTEXPR inline uint qPopulationCount(quint8 v) Q_DECL_NOTHROW +Q_DECL_CONST_FUNCTION QT_POPCOUNT_CONSTEXPR inline uint qPopulationCount(quint8 v) Q_DECL_NOTHROW { #ifdef QALGORITHMS_USE_BUILTIN_POPCOUNT return QAlgorithmsPrivate::qt_builtin_popcount(v); @@ -685,7 +690,7 @@ Q_DECL_CONST_FUNCTION Q_DECL_CONSTEXPR inline uint qPopulationCount(quint8 v) Q_ #endif } -Q_DECL_CONST_FUNCTION Q_DECL_CONSTEXPR inline uint qPopulationCount(quint16 v) Q_DECL_NOTHROW +Q_DECL_CONST_FUNCTION QT_POPCOUNT_CONSTEXPR inline uint qPopulationCount(quint16 v) Q_DECL_NOTHROW { #ifdef QALGORITHMS_USE_BUILTIN_POPCOUNT return QAlgorithmsPrivate::qt_builtin_popcount(v); @@ -696,7 +701,7 @@ Q_DECL_CONST_FUNCTION Q_DECL_CONSTEXPR inline uint qPopulationCount(quint16 v) Q #endif } -Q_DECL_CONST_FUNCTION Q_DECL_CONSTEXPR inline uint qPopulationCount(quint64 v) Q_DECL_NOTHROW +Q_DECL_CONST_FUNCTION QT_POPCOUNT_CONSTEXPR inline uint qPopulationCount(quint64 v) Q_DECL_NOTHROW { #ifdef QALGORITHMS_USE_BUILTIN_POPCOUNTLL return QAlgorithmsPrivate::qt_builtin_popcountll(v); @@ -711,7 +716,7 @@ Q_DECL_CONST_FUNCTION Q_DECL_CONSTEXPR inline uint qPopulationCount(quint64 v) Q #endif } -Q_DECL_CONST_FUNCTION Q_DECL_CONSTEXPR inline uint qPopulationCount(long unsigned int v) Q_DECL_NOTHROW +Q_DECL_CONST_FUNCTION QT_POPCOUNT_CONSTEXPR inline uint qPopulationCount(long unsigned int v) Q_DECL_NOTHROW { return qPopulationCount(static_cast<quint64>(v)); } @@ -719,6 +724,7 @@ Q_DECL_CONST_FUNCTION Q_DECL_CONSTEXPR inline uint qPopulationCount(long unsigne #if defined(Q_CC_GNU) && !defined(Q_CC_CLANG) #undef QALGORITHMS_USE_BUILTIN_POPCOUNT #endif +#undef QT_POPCOUNT_CONSTEXPR Q_DECL_RELAXED_CONSTEXPR inline uint qCountTrailingZeroBits(quint32 v) Q_DECL_NOTHROW { |