[FAST486]
authorHermès Bélusca-Maïto <hermes.belusca-maito@reactos.org>
Sat, 11 Oct 2014 18:35:23 +0000 (18:35 +0000)
committerHermès Bélusca-Maïto <hermes.belusca-maito@reactos.org>
Sat, 11 Oct 2014 18:35:23 +0000 (18:35 +0000)
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

index 1b33820..b94d8f0 100644 (file)
 
 #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