aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt1
-rw-r--r--OpenAL32/Include/alu.h2
-rw-r--r--common/math_defs.h13
-rw-r--r--config.h.in3
4 files changed, 18 insertions, 1 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index a7d13777..16daa8d5 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -536,6 +536,7 @@ CHECK_SYMBOL_EXISTS(lrintf math.h HAVE_LRINTF)
CHECK_SYMBOL_EXISTS(modff math.h HAVE_MODFF)
CHECK_SYMBOL_EXISTS(log2f math.h HAVE_LOG2F)
CHECK_SYMBOL_EXISTS(cbrtf math.h HAVE_CBRTF)
+CHECK_SYMBOL_EXISTS(copysignf math.h HAVE_COPYSIGNF)
IF(HAVE_FLOAT_H)
CHECK_SYMBOL_EXISTS(_controlfp float.h HAVE__CONTROLFP)
diff --git a/OpenAL32/Include/alu.h b/OpenAL32/Include/alu.h
index ed318ada..c3e6ba12 100644
--- a/OpenAL32/Include/alu.h
+++ b/OpenAL32/Include/alu.h
@@ -484,7 +484,7 @@ inline void CalcAngleCoeffs(ALfloat azimuth, ALfloat elevation, ALfloat spread,
*/
inline float ScaleAzimuthFront(float azimuth, float scale)
{
- ALfloat sign = (azimuth < 0.0f) ? -1.0f : 1.0f;
+ ALfloat sign = copysignf(1.0f, azimuth);
if(!(fabsf(azimuth) > F_PI_2))
return minf(fabsf(azimuth) * scale, F_PI_2) * sign;
return azimuth;
diff --git a/common/math_defs.h b/common/math_defs.h
index 04d73f42..99cc62ec 100644
--- a/common/math_defs.h
+++ b/common/math_defs.h
@@ -40,6 +40,19 @@ static inline float cbrtf(float f)
}
#endif
+#ifndef HAVE_COPYSIGNF
+static inline float copysignf(float x, float y)
+{
+ union {
+ float f;
+ unsigned int u;
+ } ux = { x }, uy = { y };
+ ux.u &= 0x7fffffffu;
+ ux.u |= (uy.u&0x80000000u);
+ return ux.f;
+}
+#endif
+
#define DEG2RAD(x) ((float)(x) * (float)(M_PI/180.0))
#define RAD2DEG(x) ((float)(x) * (float)(180.0/M_PI))
diff --git a/config.h.in b/config.h.in
index 1ff64fe4..9cc6c16b 100644
--- a/config.h.in
+++ b/config.h.in
@@ -98,6 +98,9 @@
/* Define if we have the cbrtf function */
#cmakedefine HAVE_CBRTF
+/* Define if we have the copysignf function */
+#cmakedefine HAVE_COPYSIGNF
+
/* Define if we have the strtof function */
#cmakedefine HAVE_STRTOF