diff options
-rw-r--r-- | CMakeLists.txt | 7 | ||||
-rw-r--r-- | OpenAL32/Include/alMain.h | 16 | ||||
-rw-r--r-- | config.h.in | 3 |
3 files changed, 25 insertions, 1 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 8e3ee808..b5c65c55 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -494,6 +494,13 @@ IF(HAVE_INTRIN_H) _BitScanForward64(&idx, 1); return idx; }" HAVE_BITSCANFORWARD64_INTRINSIC) + CHECK_C_SOURCE_COMPILES("#include <intrin.h> + int main() + { + unsigned long idx = 0; + _BitScanForward(&idx, 1); + return idx; + }" HAVE_BITSCANFORWARD_INTRINSIC) ENDIF() CHECK_SYMBOL_EXISTS(sysconf unistd.h HAVE_SYSCONF) 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 diff --git a/config.h.in b/config.h.in index 99be6a0b..8ef9057a 100644 --- a/config.h.in +++ b/config.h.in @@ -182,6 +182,9 @@ /* Define if we have the _BitScanForward64() intrinsic */ #cmakedefine HAVE_BITSCANFORWARD64_INTRINSIC +/* Define if we have the _BitScanForward() intrinsic */ +#cmakedefine HAVE_BITSCANFORWARD_INTRINSIC + /* Define if we have _controlfp() */ #cmakedefine HAVE__CONTROLFP |