aboutsummaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2018-08-29 03:51:17 -0700
committerChris Robinson <[email protected]>2018-08-29 03:53:09 -0700
commit21dc2c761d87592feb8b42a4556e2786f2e4581f (patch)
treedd451ac272dd3d0b669092f270c6b86b3e89fc0b /common
parent529f387695d10368aca3460baa428ee90eea8332 (diff)
Check for and use copysignf
Diffstat (limited to 'common')
-rw-r--r--common/math_defs.h13
1 files changed, 13 insertions, 0 deletions
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))