[FAST486]: fixes for CountLeadingZeros64:

- remove extra ';'
- This is (x)>0xff.... not >=
- Use Timo inline function.

svn path=/trunk/; revision=64676
This commit is contained in:
Hermès Bélusca-Maïto 2014-10-11 16:25:45 +00:00
parent 51ad4d4d0e
commit 2471c3b90f

View file

@ -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;
ULONG Count = 0;
ULONGLONG Mask = 1ULL << 63;
while (!(Value & (1 << (63 - LeadingZeros)))) LeadingZeros++;
return LeadingZeros;
while (!(Value & Mask))
{
Count++;
Mask >>= 1;
}
return Count;
}
#endif