Add 64 bit FindFirstBit function

This commit is contained in:
Jonathan G Rennison 2019-08-19 20:01:49 +01:00
parent d0ee897135
commit c8a37d8292
2 changed files with 14 additions and 0 deletions

View File

@ -55,6 +55,13 @@ uint8 FindFirstBit(uint32 x)
return pos;
}
uint8 FindFirstBit64(uint64 x)
{
if (x == 0) return 0;
if ((x & 0x00000000ffffffffULL) != 0) return FindFirstBit(x);
return FindFirstBit(x >> 32) + 32;
}
#endif
/**

View File

@ -198,6 +198,13 @@ inline uint8 FindFirstBit(uint32 x)
return __builtin_ctz(x);
}
inline uint8 FindFirstBit64(uint64 x)
{
if (x == 0) return 0;
return __builtin_ctzll(x);
}
#else
/** Lookup table to check which bit is set in a 6 bit variable */