This commit is contained in:
_ClearEdge 2025-05-02 09:41:18 +00:00 committed by GitHub
commit 6a300fd462
WARNING! Although there is a key with this ID in the database it does not verify this commit! This commit is SUSPICIOUS.
GPG key ID: B5690EEEBB952194

View file

@ -236,8 +236,9 @@ static inline size_t mi_ctz(size_t x) {
#elif defined(_MSC_VER) && MI_ARCH_X64 && defined(__BMI1__)
return (x!=0 ? _tzcnt_u64(x) : MI_SIZE_BITS); // ensure it still works on non-BMI1 cpu's as well
#elif defined(_MSC_VER) && (MI_ARCH_X64 || MI_ARCH_X86 || MI_ARCH_ARM64 || MI_ARCH_ARM32)
unsigned long idx;
return (mi_msc_builtinz(_BitScanForward)(&idx, x) ? (size_t)idx : MI_SIZE_BITS);
unsigned long idx = MI_SIZE_BITS;
if (x != 0) { mi_msc_builtinz(_BitScanForward)(&idx, x); return (size_t)idx; }
return MI_SIZE_BITS;
#elif defined(__GNUC__) && MI_ARCH_X86
size_t r = MI_SIZE_BITS;
__asm ("bsf\t%1, %0" : "+r"(r) : "r"(x) : "cc");
@ -260,8 +261,9 @@ static inline size_t mi_clz(size_t x) {
#elif mi_has_builtinz(clz)
return (x!=0 ? (size_t)mi_builtinz(clz)(x) : MI_SIZE_BITS);
#elif defined(_MSC_VER) && (MI_ARCH_X64 || MI_ARCH_X86 || MI_ARCH_ARM64 || MI_ARCH_ARM32)
unsigned long idx;
return (mi_msc_builtinz(_BitScanReverse)(&idx, x) ? MI_SIZE_BITS - 1 - (size_t)idx : MI_SIZE_BITS);
unsigned long idx = MI_SIZE_BITS;
if (x != 0) { mi_msc_builtinz(_BitScanReverse)(&idx, x); return (size_t)(MI_SIZE_BITS - 1 - idx);}
return MI_SIZE_BITS;
#elif defined(__GNUC__) && (MI_ARCH_X64 || MI_ARCH_X86)
if (x==0) return MI_SIZE_BITS;
size_t r;
@ -363,4 +365,4 @@ static inline uint32_t mi_rotl32(uint32_t x, uint32_t r) {
}
#endif // MI_BITS_H
#endif // MI_BITS_H