mirror of
https://github.com/JGRennison/OpenTTD-patches.git
synced 2024-11-04 06:00:15 +00:00
Add 64 bit FindFirstBit function
This commit is contained in:
parent
d0ee897135
commit
c8a37d8292
@ -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
|
||||
|
||||
/**
|
||||
|
@ -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 */
|
||||
|
Loading…
Reference in New Issue
Block a user