Replace IS_INF_OR_NAN with util_is_inf_or_nan
authorDylan Baker <dylan@pnwbakers.com>
Mon, 10 Sep 2018 18:31:49 +0000 (11:31 -0700)
committerDylan Baker <dylan@pnwbakers.com>
Tue, 21 Apr 2020 18:09:03 +0000 (11:09 -0700)
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Reviewed-by: Kristian H. Kristensen <hoegsberg@google.com>
Reviewed-by: Matt Turner <mattst88@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/3024>

src/mesa/main/draw.c
src/mesa/program/prog_execute.c
src/mesa/swrast/s_aalinetemp.h
src/mesa/swrast/s_aatritemp.h
src/mesa/swrast/s_linetemp.h
src/mesa/swrast/s_points.c
src/mesa/swrast/s_tritemp.h
src/mesa/tnl/t_split_copy.c
src/mesa/tnl/t_vb_cliptmp.h
src/mesa/tnl/t_vb_program.c
src/util/imports.h

index a33862f517bd905f6c2ca0742f1b85ede99e59a1..253e2fdbee72079a0df4743b3458da6617bfc56f 100644 (file)
@@ -82,7 +82,7 @@ check_array_data(struct gl_context *ctx, struct gl_vertex_array_object *vao,
             GLfloat *f = (GLfloat *) ((GLubyte *) data + binding->Stride * j);
             GLint k;
             for (k = 0; k < array->Format.Size; k++) {
-               if (IS_INF_OR_NAN(f[k]) || f[k] >= 1.0e20F || f[k] <= -1.0e10F) {
+               if (util_is_inf_or_nan(f[k]) || f[k] >= 1.0e20F || f[k] <= -1.0e10F) {
                   printf("Bad array data:\n");
                   printf("  Element[%u].%u = %f\n", j, k, f[k]);
                   printf("  Array %u at %p\n", attrib, (void *) array);
@@ -93,7 +93,7 @@ check_array_data(struct gl_context *ctx, struct gl_vertex_array_object *vao,
                          array->Ptr, bo ? bo->Name : 0);
                   f[k] = 1.0F;  /* XXX replace the bad value! */
                }
-               /*assert(!IS_INF_OR_NAN(f[k])); */
+               /*assert(!util_is_inf_or_nan(f[k])); */
             }
          }
          break;
index 6ada78565cc2af454247ea6aa170acf5ff5a553f..956b84a20d6496c7c9ebe61f592ff27c0b0fc9c6 100644 (file)
@@ -213,10 +213,10 @@ fetch_vector4(const struct prog_src_register *source,
    }
 
 #ifdef NAN_CHECK
-   assert(!IS_INF_OR_NAN(result[0]));
-   assert(!IS_INF_OR_NAN(result[0]));
-   assert(!IS_INF_OR_NAN(result[0]));
-   assert(!IS_INF_OR_NAN(result[0]));
+   assert(!util_is_inf_or_nan(result[0]));
+   assert(!util_is_inf_or_nan(result[0]));
+   assert(!util_is_inf_or_nan(result[0]));
+   assert(!util_is_inf_or_nan(result[0]));
 #endif
 }
 
@@ -332,9 +332,9 @@ store_vector4(const struct prog_instruction *inst,
 
 #if 0
    if (value[0] > 1.0e10 ||
-       IS_INF_OR_NAN(value[0]) ||
-       IS_INF_OR_NAN(value[1]) ||
-       IS_INF_OR_NAN(value[2]) || IS_INF_OR_NAN(value[3]))
+       util_is_inf_or_nan(value[0]) ||
+       util_is_inf_or_nan(value[1]) ||
+       util_is_inf_or_nan(value[2]) || util_is_inf_or_nan(value[3]))
       printf("store %g %g %g %g\n", value[0], value[1], value[2], value[3]);
 #endif
 
@@ -347,10 +347,10 @@ store_vector4(const struct prog_instruction *inst,
    }
 
 #ifdef NAN_CHECK
-   assert(!IS_INF_OR_NAN(value[0]));
-   assert(!IS_INF_OR_NAN(value[0]));
-   assert(!IS_INF_OR_NAN(value[0]));
-   assert(!IS_INF_OR_NAN(value[0]));
+   assert(!util_is_inf_or_nan(value[0]));
+   assert(!util_is_inf_or_nan(value[0]));
+   assert(!util_is_inf_or_nan(value[0]));
+   assert(!util_is_inf_or_nan(value[0]));
 #endif
 
    if (writeMask & WRITEMASK_X)
@@ -614,7 +614,7 @@ _mesa_execute_program(struct gl_context * ctx,
             fetch_vector1(&inst->SrcReg[0], machine, a);
             val = exp2f(a[0]);
             /*
-            if (IS_INF_OR_NAN(val))
+            if (util_is_inf_or_nan(val))
                val = 1.0e10;
             */
             result[0] = result[1] = result[2] = result[3] = val;
@@ -744,7 +744,7 @@ _mesa_execute_program(struct gl_context * ctx,
             fetch_vector1(&inst->SrcReg[0], machine, t);
             abs_t0 = fabsf(t[0]);
             if (abs_t0 != 0.0F) {
-               if (IS_INF_OR_NAN(abs_t0))
+               if (util_is_inf_or_nan(abs_t0))
                {
                   SET_POS_INFINITY(q[0]);
                   q[1] = 1.0F;
@@ -931,7 +931,7 @@ _mesa_execute_program(struct gl_context * ctx,
             if (DEBUG_PROG) {
                if (a[0] == 0)
                   printf("RCP(0)\n");
-               else if (IS_INF_OR_NAN(a[0]))
+               else if (util_is_inf_or_nan(a[0]))
                   printf("RCP(inf)\n");
             }
             result[0] = result[1] = result[2] = result[3] = 1.0F / a[0];
index 64767a3a5644d4475f5768b926cfbcad666fa324..9997d03753adebafef49946ae1fb39b0015e2ca7 100644 (file)
@@ -123,7 +123,7 @@ NAME(line)(struct gl_context *ctx, const SWvertex *v0, const SWvertex *v1)
                                  ctx->Const.MinLineWidthAA,
                                  ctx->Const.MaxLineWidthAA);
 
-   if (line.len == 0.0F || IS_INF_OR_NAN(line.len))
+   if (line.len == 0.0F || util_is_inf_or_nan(line.len))
       return;
 
    INIT_SPAN(line.span, GL_LINE);
index 230dab81633da908709247f077b89b663a3a2b2e..1de627208a1580dfabc2528401fb516c319fd41a 100644 (file)
       const GLfloat botDy = vMid->attrib[VARYING_SLOT_POS][1] - vMin->attrib[VARYING_SLOT_POS][1];
       const GLfloat area = majDx * botDy - botDx * majDy;
       /* Do backface culling */
-      if (area * bf < 0 || area == 0 || IS_INF_OR_NAN(area))
+      if (area * bf < 0 || area == 0 || util_is_inf_or_nan(area))
         return;
       ltor = (GLboolean) (area < 0.0F);
 
index 035a1e6409a39655e0900608c6f822bbbeb8089c..6706ec788b136a7b47cd35f6e83e1dc634f5c456 100644 (file)
@@ -101,7 +101,7 @@ NAME( struct gl_context *ctx, const SWvertex *vert0, const SWvertex *vert1 )
    {
       GLfloat tmp = vert0->attrib[VARYING_SLOT_POS][0] + vert0->attrib[VARYING_SLOT_POS][1]
                   + vert1->attrib[VARYING_SLOT_POS][0] + vert1->attrib[VARYING_SLOT_POS][1];
-      if (IS_INF_OR_NAN(tmp))
+      if (util_is_inf_or_nan(tmp))
         return;
    }
 
index de5cd6921705f3e2e6c46b7f0e6f1aa23f299d78..1c6c239042aaef8aac20d1be8a3c2f417b3afd3d 100644 (file)
@@ -38,7 +38,7 @@
    do {                                              \
       float tmp = (V)->attrib[VARYING_SLOT_POS][0]   \
                 + (V)->attrib[VARYING_SLOT_POS][1];  \
-      if (IS_INF_OR_NAN(tmp))                        \
+      if (util_is_inf_or_nan(tmp))                   \
         return;                                     \
    } while(0)
 
index 1d71839713c34041476be033bf737e4c4efa2082..4dc42a80a729a16594a89c1fb810870a731f6f51 100644 (file)
@@ -90,6 +90,7 @@
  * SUB_PIXEL_BITS.
  */
 
+#include "util/u_math.h"
 
 #ifndef MAX_GLUINT
 #define MAX_GLUINT     0xffffffffu
@@ -239,7 +240,7 @@ static void NAME(struct gl_context *ctx, const SWvertex *v0,
    {
       const GLfloat area = eMaj.dx * eBot.dy - eBot.dx * eMaj.dy;
 
-      if (IS_INF_OR_NAN(area) || area == 0.0F)
+      if (util_is_inf_or_nan(area) || area == 0.0F)
          return;
 
       if (area * bf * swrast->_BackfaceCullSign < 0.0F)
index 87c0020e311f43144e9ddd672900ce95ed2eeaf0..f1d8274766aa090e352a3675b295e0b48340d6ae 100644 (file)
@@ -267,7 +267,7 @@ elt(struct copy_context *copy, GLuint elt_idx)
             GLuint k;
             GLfloat *f = (GLfloat *) srcptr;
             for (k = 0; k < srcarray->Size; k++) {
-               assert(!IS_INF_OR_NAN(f[k]));
+               assert(!util_is_inf_or_nan(f[k]));
                assert(f[k] <= 1.0e20 && f[k] >= -1.0e20);
             }
          }
index c6546668806eda497499200b3d259e5ccbc08386..9f2d5161d99a98f52ede59da4b1eec4c7e45da13 100644 (file)
@@ -206,10 +206,10 @@ TAG(clip_tri)( struct gl_context *ctx, GLuint v0, GLuint v1, GLuint v2, GLubyte
          printf("  %u: %u: %f, %f, %f, %f\n",
                i, j,
                coord[j][0], coord[j][1], coord[j][2], coord[j][3]);
-         assert(!IS_INF_OR_NAN(coord[j][0]));
-         assert(!IS_INF_OR_NAN(coord[j][1]));
-         assert(!IS_INF_OR_NAN(coord[j][2]));
-         assert(!IS_INF_OR_NAN(coord[j][3]));
+         assert(!util_is_inf_or_nan(coord[j][0]));
+         assert(!util_is_inf_or_nan(coord[j][1]));
+         assert(!util_is_inf_or_nan(coord[j][2]));
+         assert(!util_is_inf_or_nan(coord[j][3]));
       }
    }
 
index 099d37eed7264d68f5d5c711630fd0eb46a269c3..7a49e3934642ee5ea062d1bb1d6ce57aace7f7b3 100644 (file)
@@ -53,7 +53,7 @@
 static inline void
 check_float(float x)
 {
-   assert(!IS_INF_OR_NAN(x));
+   assert(!util_is_inf_or_nan(x));
    assert(1.0e-15 <= x && x <= 1.0e15);
 }
 #endif
index 9556223b3ba37b28d1206f60d60ed951ce0d376d..783423bae81e94d6ec7aaafe49dc5e0a5f5a2af3 100644 (file)
@@ -73,28 +73,6 @@ typedef union { float f; int i; unsigned u; } fi_type;
 /*@}*/
 
 
-/**
- * finite macro.
- */
-#if defined(_MSC_VER)
-#  define finite _finite
-#endif
-
-
-/***
- *** IS_INF_OR_NAN: test if float is infinite or NaN
- ***/
-#if defined(isfinite)
-#define IS_INF_OR_NAN(x)        (!isfinite(x))
-#elif defined(finite)
-#define IS_INF_OR_NAN(x)        (!finite(x))
-#elif defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
-#define IS_INF_OR_NAN(x)        (!isfinite(x))
-#else
-#define IS_INF_OR_NAN(x)        (!finite(x))
-#endif
-
-
 /**********************************************************************
  * Functions
  */