Author: hbelusca
Date: Sat Oct 11 16:25:45 2014
New Revision: 64676
URL:
http://svn.reactos.org/svn/reactos?rev=64676&view=rev
Log:
[FAST486]: fixes for CountLeadingZeros64:
- remove extra ';'
- This is (x)>0xff.... not >=
- Use Timo inline function.
Modified:
trunk/reactos/lib/fast486/common.inl
Modified: trunk/reactos/lib/fast486/common.inl
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/fast486/common.inl?rev…
==============================================================================
--- trunk/reactos/lib/fast486/common.inl [iso-8859-1] (original)
+++ trunk/reactos/lib/fast486/common.inl [iso-8859-1] Sat Oct 11 16:25:45 2014
@@ -25,21 +25,26 @@
/* PUBLIC FUNCTIONS ***********************************************************/
#if defined (__GNUC__)
- #define CountLeadingZeros64(x) __builtin_clzll(x);
+ #define CountLeadingZeros64(x) __builtin_clzll(x)
#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)
+ #define CountLeadingZeros64(x) ((x) > 0xFFFFFFFFULL) ? __lzcnt((x) >> 32) \
+ : (__lzcnt(x) + 32)
#else
- static
- FORCEINLINE
+ static FORCEINLINE
ULONG CountLeadingZeros64(ULONGLONG Value)
{
- ULONG LeadingZeros = 0;
-
- while (!(Value & (1 << (63 - LeadingZeros)))) LeadingZeros++;
- return LeadingZeros;
+ ULONG Count = 0;
+ ULONGLONG Mask = 1ULL << 63;
+
+ while (!(Value & Mask))
+ {
+ Count++;
+ Mask >>= 1;
+ }
+
+ return Count;
}
#endif