summaryrefslogtreecommitdiffstats
path: root/src/util/macros.h
diff options
context:
space:
mode:
authorJason Ekstrand <jason.ekstrand@intel.com>2015-01-28 10:38:01 -0800
committerJason Ekstrand <jason.ekstrand@intel.com>2015-01-28 11:47:56 -0800
commit58e8468d113c7d3d4a59ea4a8d70fd45b78e85e6 (patch)
treea54e97ed477f39e37df40741e54e60b85e1e2288 /src/util/macros.h
parent3b7747c022bae842b21c810ac72513844ff9fc26 (diff)
downloadexternal_mesa3d-58e8468d113c7d3d4a59ea4a8d70fd45b78e85e6.zip
external_mesa3d-58e8468d113c7d3d4a59ea4a8d70fd45b78e85e6.tar.gz
external_mesa3d-58e8468d113c7d3d4a59ea4a8d70fd45b78e85e6.tar.bz2
util: Predicate the fpclassify fallback on !defined(__cplusplus)
The problem is that the fallbacks we have at the moment don't work in C++. While we could theoretically fix the fallbacks it would also raise the issue of correctly detecting the fpclassify function. So, for now, we'll just disable it until we actually have a C++ user. Reported-by: Tom Stellard <thomas.stellard@amd.com> Tested-by: Tom Stellard <thomas.stellard@amd.com> Tested-by: EdB <edb+mesa@sigluy.net>
Diffstat (limited to 'src/util/macros.h')
-rw-r--r--src/util/macros.h14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/util/macros.h b/src/util/macros.h
index 180f2f6..74bd8bf 100644
--- a/src/util/macros.h
+++ b/src/util/macros.h
@@ -158,7 +158,15 @@ do { \
# endif
#endif
-#if defined(fpclassify)
+/* The fallbacks below don't work correctly in C++ and properly detecting
+ * FP_NORMAL in C++ is hard. Since we don't use fpclassify in any C++ code
+ * at the moment, we can just predicate this whole thing by not being in
+ * C++ and we shoudld be ok. If we ever want to use fpclassify in a C++
+ * file, we will have to revisit this.
+ */
+#ifndef __cplusplus
+
+#ifdef FP_NORMAL
/* ISO C99 says that fpclassify is a macro. Assume that any implementation
* of fpclassify, whether it's in a C99 compiler or not, will be a macro.
*/
@@ -199,7 +207,7 @@ fpclassify(double x)
#else
-enum {FP_NAN, FP_INFINITE, FP_ZERO, FP_SUBNORMAL, FP_NORMAL}
+static inline enum {FP_NAN, FP_INFINITE, FP_ZERO, FP_SUBNORMAL, FP_NORMAL}
fpclassify(double x)
{
/* XXX do something better someday */
@@ -208,4 +216,6 @@ fpclassify(double x)
#endif
+#endif /* __cplusplus */
+
#endif /* UTIL_MACROS_H */