Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --- a\qtbase\src\corelib\tools\qalgorithms.h
- +++ b\qtbase\src\corelib\tools\qalgorithms.h
- @@ -587,19 +587,20 @@
- Q_DECL_CONSTEXPR Q_ALWAYS_INLINE uint qt_builtin_popcountll(quint64 v) Q_DECL_NOTHROW
- {
- 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);
- // Now Invert the result: clz will count *down* from the msb to the lsb, so the msb index is 31
- // and the lsb index is 0. The result for the index when counting up: msb index is 0 (because it
- @@ -608,63 +609,66 @@
- return result;
- }
- #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);
- return result;
- }
- // 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);
- // see qt_builtin_clz
- result ^= sizeof(quint64) * 8 - 1;
- return result;
- }
- #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);
- }
- #endif // MSVC 64bit
- #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);
- #else
- // See http://graphics.stanford.edu/~seander/bithacks.html#CountBitsSetParallel
- @@ -673,32 +677,32 @@
- (((v >> 12) & 0xfff) * Q_UINT64_C(0x1001001001001) & Q_UINT64_C(0x84210842108421)) % 0x1f +
- (((v >> 24) & 0xfff) * Q_UINT64_C(0x1001001001001) & Q_UINT64_C(0x84210842108421)) % 0x1f;
- #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);
- #else
- return
- (((v ) & 0xfff) * Q_UINT64_C(0x1001001001001) & Q_UINT64_C(0x84210842108421)) % 0x1f;
- #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);
- #else
- return
- (((v ) & 0xfff) * Q_UINT64_C(0x1001001001001) & Q_UINT64_C(0x84210842108421)) % 0x1f +
- (((v >> 12) & 0xfff) * Q_UINT64_C(0x1001001001001) & Q_UINT64_C(0x84210842108421)) % 0x1f;
- #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);
- #else
- return
- @@ -709,18 +713,19 @@
- (((v >> 48) & 0xfff) * Q_UINT64_C(0x1001001001001) & Q_UINT64_C(0x84210842108421)) % 0x1f +
- (((v >> 60) & 0xfff) * Q_UINT64_C(0x1001001001001) & Q_UINT64_C(0x84210842108421)) % 0x1f;
- #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));
- }
- #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
- {
- #if defined(QT_HAS_BUILTIN_CTZ)
- return v ? QAlgorithmsPrivate::qt_builtin_ctz(v) : 32U;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement