From 4dc38176131c430e0ae85314024d6ee37f1bb82f Mon Sep 17 00:00:00 2001 From: =?utf8?q?Herm=C3=A8s=20B=C3=A9lusca-Ma=C3=AFto?= Date: Sat, 11 Oct 2014 18:35:23 +0000 Subject: [PATCH] [FAST486] Use a more performant CountLeadingZeros64 version from Timo (tested by Thomas), and disable the MSVC-specific one until you find a version that works, and is supported for any CPU. svn path=/trunk/; revision=64680 --- reactos/lib/fast486/common.inl | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/reactos/lib/fast486/common.inl b/reactos/lib/fast486/common.inl index 1b33820dcf9..b94d8f0ce03 100644 --- a/reactos/lib/fast486/common.inl +++ b/reactos/lib/fast486/common.inl @@ -26,24 +26,27 @@ #if defined (__GNUC__) #define CountLeadingZeros64(x) __builtin_clzll(x) + +#if 0 #elif (_MSC_VER >= 1500) && defined(_WIN64) #define CountLeadingZeros64(x) __lzcnt64(x) #elif (_MSC_VER >= 1500) #define CountLeadingZeros64(x) ((x) > 0xFFFFFFFFULL) ? __lzcnt((x) >> 32) \ : (__lzcnt(x) + 32) +#endif + #else - static FORCEINLINE - ULONG CountLeadingZeros64(ULONGLONG Value) + FORCEINLINE + ULONG + CountLeadingZeros64(ULONGLONG Value) { ULONG Count = 0; - ULONGLONG Mask = 1ULL << 63; - - while (!(Value & Mask) && Mask) + Value = ~Value; + while ((LONGLONG)Value < 0) { Count++; - Mask >>= 1; + Value <<= 1; } - return Count; } #endif -- 2.17.1