freedreno/registers: SC_WAIT_WC is not a6xx
[mesa.git] / include / c99_math.h
index bd35d1b32ed659098f9e333dca7324ddf13e58f6..e906c26aa543bc1adfd1bc341aba47886442466b 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
-#define INFINITY (DBL_MAX + DBL_MAX)
-#endif
 
-#ifndef NAN
-#define NAN (INFINITY - INFINITY)
-#endif
+#if !defined(_MSC_VER) && \
+    __STDC_VERSION__ < 199901L && \
+    (!defined(_XOPEN_SOURCE) || _XOPEN_SOURCE < 600) && \
+    !defined(__cplusplus)
 
-#endif /* _MSC_VER */
-
-
-#if __STDC_VERSION__ < 199901L && (!defined(__cplusplus) || defined(_MSC_VER))
 static inline long int
 lrint(double d)
 {
@@ -133,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 */
 
 
@@ -205,4 +185,27 @@ fpclassify(double x)
 #endif
 
 
+/* Since C++11, the following functions are part of the std namespace. Their C
+ * counteparts should still exist in the global namespace, however cmath
+ * undefines those functions, which in glibc 2.23, are defined as macros rather
+ * than functions as in glibc 2.22.
+ */
+#if __cplusplus >= 201103L && (__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 23))
+#include <cmath>
+
+using std::fpclassify;
+using std::isfinite;
+using std::isinf;
+using std::isnan;
+using std::isnormal;
+using std::signbit;
+using std::isgreater;
+using std::isgreaterequal;
+using std::isless;
+using std::islessequal;
+using std::islessgreater;
+using std::isunordered;
+#endif
+
+
 #endif /* #define _C99_MATH_H_ */