Check for _BitScanForward64 before using it
This commit is contained in:
parent
9613b4bfe2
commit
9718502e5d
@ -487,6 +487,13 @@ IF(HAVE_INTRIN_H)
|
||||
__cpuid(regs, 0);
|
||||
return regs[0];
|
||||
}" HAVE_CPUID_INTRINSIC)
|
||||
CHECK_C_SOURCE_COMPILES("#include <intrin.h>
|
||||
int main()
|
||||
{
|
||||
unsigned long idx = 0;
|
||||
_BitScanForward64(&idx, 1);
|
||||
return idx;
|
||||
}" HAVE_BITSCANFORWARD64_INTRINSIC)
|
||||
ENDIF()
|
||||
|
||||
CHECK_SYMBOL_EXISTS(sysconf unistd.h HAVE_SYSCONF)
|
||||
|
@ -97,13 +97,13 @@ typedef ALuint64SOFT ALuint64;
|
||||
#define CTZ64(x) __builtin_ctzll(x)
|
||||
#endif
|
||||
|
||||
#elif defined(_MSC_VER)
|
||||
#elif defined(HAVE_BITSCANFORWARD64_INTRINSIC)
|
||||
|
||||
static inline int msvc_ctz64(ALuint64 v)
|
||||
{
|
||||
unsigned long idx = 0;
|
||||
unsigned long idx = 64;
|
||||
_BitScanForward64(&idx, v);
|
||||
return idx;
|
||||
return (int)idx;
|
||||
}
|
||||
#define CTZ64(x) msvc_ctz64(x)
|
||||
|
||||
@ -121,7 +121,7 @@ static inline int fallback_popcnt64(ALuint64 v)
|
||||
v = v - ((v >> 1) & U64(0x5555555555555555));
|
||||
v = (v & U64(0x3333333333333333)) + ((v >> 2) & U64(0x3333333333333333));
|
||||
v = (v + (v >> 4)) & U64(0x0f0f0f0f0f0f0f0f);
|
||||
return (v * U64(0x0101010101010101)) >> 56;
|
||||
return (int)((v * U64(0x0101010101010101)) >> 56);
|
||||
}
|
||||
|
||||
static inline int fallback_ctz64(ALuint64 value)
|
||||
|
@ -179,6 +179,9 @@
|
||||
/* Define if we have the __cpuid() intrinsic */
|
||||
#cmakedefine HAVE_CPUID_INTRINSIC
|
||||
|
||||
/* Define if we have the _BitScanForward64() intrinsic */
|
||||
#cmakedefine HAVE_BITSCANFORWARD64_INTRINSIC
|
||||
|
||||
/* Define if we have _controlfp() */
|
||||
#cmakedefine HAVE__CONTROLFP
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user