nv50/ir: saturate depth writes
[mesa.git] / include / c99_math.h
index 5b01d53a83af269094b601d30a9155ffb27c432f..250e08d44cff9b0225704ac261da6d2c23bdef5c 100644 (file)
 #include "c99_compat.h"
 
 
-#if defined(_MSC_VER)
-
 /* This is to ensure that we get M_PI, etc. definitions */
-#if !defined(_USE_MATH_DEFINES)
+#if defined(_MSC_VER) && !defined(_USE_MATH_DEFINES)
 #error _USE_MATH_DEFINES define required when building with MSVC
 #endif 
 
-#if _MSC_VER < 1800
-#define isfinite(x) _finite((double)(x))
-#define isnan(x) _isnan((double)(x))
-#endif /* _MSC_VER < 1800 */
-
-#if _MSC_VER < 1800
-static inline double log2( double x )
-{
-   const double invln2 = 1.442695041;
-   return log( x ) * invln2;
-}
-
-static inline double
-round(double x)
-{
-   return x >= 0.0 ? floor(x + 0.5) : ceil(x - 0.5);
-}
-
-static inline float
-roundf(float x)
-{
-   return x >= 0.0f ? floorf(x + 0.5f) : ceilf(x - 0.5f);
-}
-#endif
 
-#ifndef INFINITY
-#include <float.h> // DBL_MAX
-#define INFINITY (DBL_MAX + DBL_MAX)
-#endif
+#if !defined(_MSC_VER) && \
+    __STDC_VERSION__ < 199901L && \
+    (!defined(_XOPEN_SOURCE) || _XOPEN_SOURCE < 600) && \
+    !defined(__cplusplus)
 
-#ifndef NAN
-#define NAN (INFINITY - INFINITY)
-#endif
-
-#endif /* _MSC_VER */
-
-
-#if __STDC_VERSION__ < 199901L && (!defined(__cplusplus) || defined(_MSC_VER))
 static inline long int
 lrint(double d)
 {
@@ -134,6 +100,19 @@ llrintf(float f)
 
    return rounded;
 }
+
+static inline float
+exp2f(float f)
+{
+   return powf(2.0f, f);
+}
+
+static inline double
+exp2(double d)
+{
+   return pow(2.0, d);
+}
+
 #endif /* C99 */