diff options
author | Chris Robinson <[email protected]> | 2018-01-27 11:19:59 -0800 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2018-01-27 14:34:05 -0800 |
commit | f76ab02bd4fc13d6648d839374da966ef12201fd (patch) | |
tree | b049aca85a332f798806443b635438ff8b9febf3 /OpenAL32/Include/alMain.h | |
parent | 4d392a8b870818662572ff2784e8ebab07714218 (diff) |
Add a ctz64 fallback using _BitScanForward when available
Diffstat (limited to 'OpenAL32/Include/alMain.h')
-rw-r--r-- | OpenAL32/Include/alMain.h | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/OpenAL32/Include/alMain.h b/OpenAL32/Include/alMain.h index afa3eee3..c4223ac9 100644 --- a/OpenAL32/Include/alMain.h +++ b/OpenAL32/Include/alMain.h @@ -99,12 +99,26 @@ typedef ALuint64SOFT ALuint64; #elif defined(HAVE_BITSCANFORWARD64_INTRINSIC) -static inline int msvc_ctz64(ALuint64 v) +static inline int msvc64_ctz64(ALuint64 v) { unsigned long idx = 64; _BitScanForward64(&idx, v); return (int)idx; } +#define CTZ64(x) msvc64_ctz64(x) + +#elif defined(HAVE_BITSCANFORWARD_INTRINSIC) + +static inline int msvc_ctz64(ALuint64 v) +{ + unsigned long idx = 64; + if(!_BitScanForward(&idx, v&0xffffffff)) + { + if(_BitScanForward(&idx, v>>32)) + idx += 32; + } + return (int)idx; +} #define CTZ64(x) msvc_ctz64(x) #else |