uint32_t hi = (mask >> 32) & 0xFFFFFFFF;
uint32_t lo = mask & 0xFFFFFFFF;
uint32_t fakeBitIndex = 0;
- if (BitScanForward(&fakeBitIndex, hi))
+
+ uint8_t result = BitScanForward(bitIndex, lo);
+ if (result == 0)
{
- *bitIndex = fakeBitIndex + 32;
+ result = BitScanForward(&fakeBitIndex, hi);
+ if (result != 0)
+ {
+ *bitIndex = fakeBitIndex + 32;
+ }
}
- return BitScanForward(bitIndex, lo);
+ return result;
#else
return _BitScanForward64((unsigned long*)bitIndex, mask);
#endif // _WIN32