Make the Compressor struct opaque
[openal-soft.git] / common / math_defs.h
blobaa79b695689633aca8d825146ec9e8f27facc447
1 #ifndef AL_MATH_DEFS_H
2 #define AL_MATH_DEFS_H
4 #include <math.h>
5 #ifdef HAVE_FLOAT_H
6 #include <float.h>
7 #endif
9 #ifndef M_PI
10 #define M_PI (3.14159265358979323846)
11 #endif
13 #define F_PI (3.14159265358979323846f)
14 #define F_PI_2 (1.57079632679489661923f)
15 #define F_TAU (6.28318530717958647692f)
17 #ifndef FLT_EPSILON
18 #define FLT_EPSILON (1.19209290e-07f)
19 #endif
21 #define SQRT_2 1.41421356237309504880
22 #define SQRT_3 1.73205080756887719318
24 #define SQRTF_2 1.41421356237309504880f
25 #define SQRTF_3 1.73205080756887719318f
27 #ifndef HUGE_VALF
28 static const union msvc_inf_hack {
29 unsigned char b[4];
30 float f;
31 } msvc_inf_union = {{ 0x00, 0x00, 0x80, 0x7F }};
32 #define HUGE_VALF (msvc_inf_union.f)
33 #endif
35 #ifndef HAVE_LOG2F
36 static inline float log2f(float f)
38 return logf(f) / logf(2.0f);
40 #endif
42 #ifndef HAVE_CBRTF
43 static inline float cbrtf(float f)
45 return powf(f, 1.0f/3.0f);
47 #endif
49 #ifndef HAVE_COPYSIGNF
50 static inline float copysignf(float x, float y)
52 union {
53 float f;
54 unsigned int u;
55 } ux = { x }, uy = { y };
56 ux.u &= 0x7fffffffu;
57 ux.u |= (uy.u&0x80000000u);
58 return ux.f;
60 #endif
62 #define DEG2RAD(x) ((float)(x) * (float)(M_PI/180.0))
63 #define RAD2DEG(x) ((float)(x) * (float)(180.0/M_PI))
65 #endif /* AL_MATH_DEFS_H */