On 03/11/2015 01:23 AM, Jose Fonseca wrote:
On 11/03/15 01:41, Brian Paul wrote:
---
  include/c99_math.h          | 52
+++++++++++++++++++++++++++++++++++++++++++++
  src/mesa/main/querymatrix.c | 51
+-------------------------------------------
  2 files changed, 53 insertions(+), 50 deletions(-)

diff --git a/include/c99_math.h b/include/c99_math.h
index 0a49950..f1a6685 100644
--- a/include/c99_math.h
+++ b/include/c99_math.h
@@ -161,4 +161,56 @@ llrintf(float f)
  #endif


+#if defined(fpclassify)
+/* 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.
+ */
+#elif defined(__cplusplus)
+/* For C++, fpclassify() should be defined in <cmath> */

Does MSVC's cmath implement fpclassify?  If not this #elif clause should
be moved after MSC_VER clause.

Looks like the answer is "no". I'll move it. Though things built fine on MSVC probably because we don't use fpclassify in any C++ files.



+#elif defined(_MSC_VER)
+/* 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 lower-level Windows functions.
+ */
+#include <float.h>
+
+static inline enum {FP_NAN, FP_INFINITE, FP_ZERO, FP_SUBNORMAL,
FP_NORMAL}
+fpclassify(double x)
+{
+   switch(_fpclass(x)) {
+   case _FPCLASS_SNAN: /* signaling NaN */
+   case _FPCLASS_QNAN: /* quiet NaN */
+      return FP_NAN;
+   case _FPCLASS_NINF: /* negative infinity */
+   case _FPCLASS_PINF: /* positive infinity */
+      return FP_INFINITE;
+   case _FPCLASS_NN:   /* negative normal */
+   case _FPCLASS_PN:   /* positive normal */
+      return FP_NORMAL;
+   case _FPCLASS_ND:   /* negative denormalized */
+   case _FPCLASS_PD:   /* positive denormalized */
+      return FP_SUBNORMAL;
+   case _FPCLASS_NZ:   /* negative zero */
+   case _FPCLASS_PZ:   /* positive zero */
+      return FP_ZERO;
+   default:
+      /* Should never get here; but if we do, this will guarantee
+       * that the pattern is not treated like a number.
+       */
+      return FP_NAN;
+   }
+}
+
+#else

If might be better to simply #error here.  Or leave the code but put a
#warning.

I'll do the #error. That seems to be the pattern we're using in the wrapper headers.

-Brian




Jose

+static inline enum {FP_NAN, FP_INFINITE, FP_ZERO, FP_SUBNORMAL,
FP_NORMAL}
+fpclassify(double x)
+{
+   /* XXX do something better someday */
+   return FP_NORMAL;
+}
+
+#endif
+
+
  #endif /* #define _C99_MATH_H_ */
diff --git a/src/mesa/main/querymatrix.c b/src/mesa/main/querymatrix.c
index ef85175..095817c 100644
--- a/src/mesa/main/querymatrix.c
+++ b/src/mesa/main/querymatrix.c
@@ -13,7 +13,7 @@


  #include <stdlib.h>
-#include <math.h>
+#include "c99_math.h"
  #include "glheader.h"
  #include "querymatrix.h"
  #include "main/get.h"
@@ -37,55 +37,6 @@
  #define INT_TO_FIXED(x) ((GLfixed) ((x) << 16))
  #define FLOAT_TO_FIXED(x) ((GLfixed) ((x) * 65536.0))

-#if defined(fpclassify)
-/* 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.
- */
-#elif defined(_MSC_VER)
-/* 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
- * lower-level Windows functions.
- */
-#include <float.h>
-
-enum {FP_NAN, FP_INFINITE, FP_ZERO, FP_SUBNORMAL, FP_NORMAL}
-fpclassify(double x)
-{
-    switch(_fpclass(x)) {
-        case _FPCLASS_SNAN: /* signaling NaN */
-        case _FPCLASS_QNAN: /* quiet NaN */
-            return FP_NAN;
-        case _FPCLASS_NINF: /* negative infinity */
-        case _FPCLASS_PINF: /* positive infinity */
-            return FP_INFINITE;
-        case _FPCLASS_NN:   /* negative normal */
-        case _FPCLASS_PN:   /* positive normal */
-            return FP_NORMAL;
-        case _FPCLASS_ND:   /* negative denormalized */
-        case _FPCLASS_PD:   /* positive denormalized */
-            return FP_SUBNORMAL;
-        case _FPCLASS_NZ:   /* negative zero */
-        case _FPCLASS_PZ:   /* positive zero */
-            return FP_ZERO;
-        default:
-            /* Should never get here; but if we do, this will guarantee
-             * that the pattern is not treated like a number.
-             */
-            return FP_NAN;
-    }
-}
-
-#else
-
-enum {FP_NAN, FP_INFINITE, FP_ZERO, FP_SUBNORMAL, FP_NORMAL}
-fpclassify(double x)
-{
-   /* XXX do something better someday */
-   return FP_NORMAL;
-}
-
-#endif

  GLbitfield GLAPIENTRY _mesa_QueryMatrixxOES(GLfixed mantissa[16],
GLint exponent[16])
  {


Otherwise series looks good.

Jose

_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to