Update to 12.2

This commit is contained in:
dP
2022-04-02 15:34:00 +03:00
parent 76f735ed58
commit 269352680c
87 changed files with 1685 additions and 549 deletions

View File

@@ -24,7 +24,7 @@ const uint8 _ffb_64[64] = {
};
/**
* Search the first set bit in a 32 bit variable.
* Search the first set bit in a 64 bit variable.
*
* This algorithm is a static implementation of a log
* congruence search algorithm. It checks the first half
@@ -34,7 +34,7 @@ const uint8 _ffb_64[64] = {
* @param x The value to search
* @return The position of the first bit set
*/
uint8 FindFirstBit(uint32 x)
uint8 FindFirstBit(uint64 x)
{
if (x == 0) return 0;
/* The macro FIND_FIRST_BIT is better to use when your x is
@@ -42,11 +42,12 @@ uint8 FindFirstBit(uint32 x)
uint8 pos = 0;
if ((x & 0x0000ffff) == 0) { x >>= 16; pos += 16; }
if ((x & 0x000000ff) == 0) { x >>= 8; pos += 8; }
if ((x & 0x0000000f) == 0) { x >>= 4; pos += 4; }
if ((x & 0x00000003) == 0) { x >>= 2; pos += 2; }
if ((x & 0x00000001) == 0) { pos += 1; }
if ((x & 0xffffffffULL) == 0) { x >>= 32; pos += 32; }
if ((x & 0x0000ffffULL) == 0) { x >>= 16; pos += 16; }
if ((x & 0x000000ffULL) == 0) { x >>= 8; pos += 8; }
if ((x & 0x0000000fULL) == 0) { x >>= 4; pos += 4; }
if ((x & 0x00000003ULL) == 0) { x >>= 2; pos += 2; }
if ((x & 0x00000001ULL) == 0) { pos += 1; }
return pos;
}