aboutsummaryrefslogtreecommitdiffstats
path: root/OpenAL32/Include/alMain.h
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2012-09-28 04:20:55 -0700
committerChris Robinson <[email protected]>2012-09-28 04:20:55 -0700
commit825c5b5282f9c06b90bb3e22c967270c25bb1796 (patch)
tree9280be474b4648b07f5a399228c1f840160938c6 /OpenAL32/Include/alMain.h
parent25ca1793892bc6ae2587339e0bd80aef1db8c11a (diff)
Use lrintf to fast convert floats to ints when possible
Diffstat (limited to 'OpenAL32/Include/alMain.h')
-rw-r--r--OpenAL32/Include/alMain.h13
1 files changed, 5 insertions, 8 deletions
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