From 9718502e5db46952693d550c54ec35b0a44128d3 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Sat, 27 Jan 2018 11:11:39 -0800 Subject: Check for _BitScanForward64 before using it --- OpenAL32/Include/alMain.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'OpenAL32/Include') diff --git a/OpenAL32/Include/alMain.h b/OpenAL32/Include/alMain.h index f3ffac29..afa3eee3 100644 --- a/OpenAL32/Include/alMain.h +++ b/OpenAL32/Include/alMain.h @@ -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) -- cgit v1.2.3