mirror of
https://github.com/reactos/reactos.git
synced 2025-02-24 09:25:10 +00:00
[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:
parent
51ad4d4d0e
commit
2471c3b90f
1 changed files with 13 additions and 8 deletions
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in a new issue