diff options
author | Chris Robinson <[email protected]> | 2012-09-28 04:20:55 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2012-09-28 04:20:55 -0700 |
commit | 825c5b5282f9c06b90bb3e22c967270c25bb1796 (patch) | |
tree | 9280be474b4648b07f5a399228c1f840160938c6 | |
parent | 25ca1793892bc6ae2587339e0bd80aef1db8c11a (diff) |
Use lrintf to fast convert floats to ints when possible
-rw-r--r-- | CMakeLists.txt | 2 | ||||
-rw-r--r-- | OpenAL32/Include/alMain.h | 13 | ||||
-rw-r--r-- | config.h.in | 3 |
3 files changed, 9 insertions, 9 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index ce5e7a10..04d1e8fb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -258,7 +258,7 @@ ENDIF() CHECK_SYMBOL_EXISTS(aligned_alloc stdlib.h HAVE_ALIGNED_ALLOC) CHECK_SYMBOL_EXISTS(posix_memalign stdlib.h HAVE_POSIX_MEMALIGN) CHECK_SYMBOL_EXISTS(_aligned_malloc malloc.h HAVE__ALIGNED_MALLOC) -CHECK_SYMBOL_EXISTS(powf math.h HAVE_POWF) +CHECK_SYMBOL_EXISTS(lrintf math.h HAVE_LRINTF) CHECK_SYMBOL_EXISTS(powf math.h HAVE_POWF) CHECK_SYMBOL_EXISTS(sqrtf math.h HAVE_SQRTF) CHECK_SYMBOL_EXISTS(cosf math.h HAVE_COSF) diff --git a/OpenAL32/Include/alMain.h b/OpenAL32/Include/alMain.h index 24b24ca7..1449054f 100644 --- a/OpenAL32/Include/alMain.h +++ b/OpenAL32/Include/alMain.h @@ -5,6 +5,7 @@ #include <stdio.h> #include <stdarg.h> #include <assert.h> +#include <math.h> #ifdef HAVE_FENV_H #include <fenv.h> @@ -406,19 +407,15 @@ static __inline ALuint NextPowerOf2(ALuint value) * mode. */ static __inline ALint fastf2i(ALfloat f) { +#ifdef HAVE_LRINTF + return lrintf(f); +#elif defined(_MSC_VER) && defined(_M_IX86) ALint i; -#if defined(_MSC_VER) && defined(_M_IX86) __asm fld f __asm fistp i -#elif defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__)) - __asm__ __volatile__("flds %1\n\t" - "fistpl %0\n\t" - : "=m" (i) - : "m" (f)); #else - i = (ALint)f; + return (ALint)f; #endif - return i; } /* Fast float-to-uint conversion. Assumes the FPU is already in round-to-zero diff --git a/config.h.in b/config.h.in index 300373e5..750fcfab 100644 --- a/config.h.in +++ b/config.h.in @@ -67,6 +67,9 @@ /* Define if we have the stat function */ #cmakedefine HAVE_STAT +/* Define if we have the lrintf function */ +#cmakedefine HAVE_LRINTF + /* Define if we have the powf function */ #cmakedefine HAVE_POWF |