Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Commit fa15aac

Browse files
authored
[local gc] Fix for BitScanForward64, it was ignoring the high byte check (#17142)
1 parent 091462c commit fa15aac

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/gc/env/gcenv.base.h

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -253,12 +253,18 @@ inline uint8_t BitScanForward64(uint32_t *bitIndex, uint64_t mask)
253253
uint32_t hi = (mask >> 32) & 0xFFFFFFFF;
254254
uint32_t lo = mask & 0xFFFFFFFF;
255255
uint32_t fakeBitIndex = 0;
256-
if (BitScanForward(&fakeBitIndex, hi))
256+
257+
uint8_t result = BitScanForward(bitIndex, lo);
258+
if (result == 0)
257259
{
258-
*bitIndex = fakeBitIndex + 32;
260+
result = BitScanForward(&fakeBitIndex, hi);
261+
if (result != 0)
262+
{
263+
*bitIndex = fakeBitIndex + 32;
264+
}
259265
}
260266

261-
return BitScanForward(bitIndex, lo);
267+
return result;
262268
#else
263269
return _BitScanForward64((unsigned long*)bitIndex, mask);
264270
#endif // _WIN32

0 commit comments

Comments
 (0)