Skip to content

Missing _BitScanReverse64 on x86 MSVC build #242

Description

@toptensoftware

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions