ryu icon indicating copy to clipboard operation
ryu copied to clipboard

Missing _BitScanReverse64 on x86 MSVC build

Open toptensoftware opened this issue 3 months ago • 0 comments

x86 MSVC doesn't support _BitScanReverse64, but adding something like this should fill in:

#ifndef _M_X64
static __inline unsigned char _BitScanReverse64(
    unsigned long *index,
    unsigned __int64 value)
{
    unsigned long hi, lo;

    hi = (unsigned long)(value >> 32);
    lo = (unsigned long)(value & 0xFFFFFFFFu);

    if (hi) {
        // If high part is nonzero, MSB is in the upper 32 bits
        _BitScanReverse(index, hi);
        *index += 32;
        return 1;
    } else if (lo) {
        _BitScanReverse(index, lo);
        return 1;
    } else {
        return 0; // value == 0
    }
}
#endif

toptensoftware avatar Oct 16 '25 04:10 toptensoftware