X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=include%2Fc99_math.h;h=e906c26aa543bc1adfd1bc341aba47886442466b;hb=afe8c8a2997950cd63076b7c9eba39e1858fee43;hp=8a67fb133d6e26013c0e5be8e5d84d33d0a5b5e9;hpb=6a7ca4ef2cd3f39d3b5e77051cb3f3175e9e60df;p=mesa.git diff --git a/include/c99_math.h b/include/c99_math.h index 8a67fb133d6..e906c26aa54 100644 --- a/include/c99_math.h +++ b/include/c99_math.h @@ -38,55 +38,16 @@ #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 // DBL_MAX -#define INFINITY (DBL_MAX + DBL_MAX) -#endif - -#ifndef NAN -#define NAN (INFINITY - INFINITY) -#endif - -#endif /* _MSC_VER */ - - -#if (defined(_MSC_VER) && _MSC_VER < 1800) || \ - (!defined(_MSC_VER) && \ - __STDC_VERSION__ < 199901L && \ - (!defined(_XOPEN_SOURCE) || _XOPEN_SOURCE < 600) && \ - !defined(__cplusplus)) +#if !defined(_MSC_VER) && \ + __STDC_VERSION__ < 199901L && \ + (!defined(_XOPEN_SOURCE) || _XOPEN_SOURCE < 600) && \ + !defined(__cplusplus) static inline long int lrint(double d) @@ -224,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 + +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_ */