[Mesa-dev] [PATCH] mesa: Portably detect the availability of fpclassify.
Jonas 'Sortie' Termansen
sortie at maxsi.org
Wed Nov 20 13:15:52 PST 2013
POSIX 2008 mandates fpclassify, FP_INFINITE, FP_NAN, FP_NORMAL, FP_SUBNORMAL,
and FP_ZERO are all macros and we can therefore detect them through simple
preprocessor conditionals on compliant platforms. This avoids further growth
of the current preprocessor list of platforms that has fpclassify. I retained
the current platform list as I could not confirm whether all the currently
supported platforms correctly declare all these as macros.
---
src/mesa/main/querymatrix.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/src/mesa/main/querymatrix.c b/src/mesa/main/querymatrix.c
index 19a8e92..4507343 100644
--- a/src/mesa/main/querymatrix.c
+++ b/src/mesa/main/querymatrix.c
@@ -37,7 +37,12 @@
#define INT_TO_FIXED(x) ((GLfixed) ((x) << 16))
#define FLOAT_TO_FIXED(x) ((GLfixed) ((x) * 65536.0))
-#if defined(_MSC_VER)
+#if defined(fpclassify) && defined(FP_INFINITE) && defined(FP_NAN) && \
+ defined(FP_NORMAL) && defined(FP_SUBNORMAL) && defined(FP_ZERO)
+
+/* fpclassify is available. */
+
+#elif defined(_MSC_VER)
#if _MSC_VER < 1800 /* Not required on VS2013 and above. */
/* Oddly, the fpclassify() function doesn't exist in such a form
* on MSVC. This is an implementation using slightly different
--
1.7.10.4
More information about the mesa-dev
mailing list