[Mesa-dev] [PATCH 2/3] mesa: move IS_NEGATIVE() and DIFFERENT_SIGNS() to macros.h

Brian Paul brian.e.paul at gmail.com
Thu Aug 30 19:16:30 PDT 2012


From: Brian Paul <brianp at vmware.com>

---
 src/mesa/main/imports.h |   29 -----------------------------
 src/mesa/main/macros.h  |   32 ++++++++++++++++++++++++++++++++
 2 files changed, 32 insertions(+), 29 deletions(-)

diff --git a/src/mesa/main/imports.h b/src/mesa/main/imports.h
index 1aedba4..5e526f1 100644
--- a/src/mesa/main/imports.h
+++ b/src/mesa/main/imports.h
@@ -220,35 +220,6 @@ static inline int IS_INF_OR_NAN( float x )
 
 
 /***
- *** IS_NEGATIVE: test if float is negative
- ***/
-#if defined(USE_IEEE)
-static inline int GET_FLOAT_BITS( float x )
-{
-   fi_type fi;
-   fi.f = x;
-   return fi.i;
-}
-#define IS_NEGATIVE(x) (GET_FLOAT_BITS(x) < 0)
-#else
-#define IS_NEGATIVE(x) (x < 0.0F)
-#endif
-
-
-/***
- *** DIFFERENT_SIGNS: test if two floats have opposite signs
- ***/
-#if defined(USE_IEEE)
-#define DIFFERENT_SIGNS(x,y) ((GET_FLOAT_BITS(x) ^ GET_FLOAT_BITS(y)) & (1<<31))
-#else
-/* Could just use (x*y<0) except for the flatshading requirements.
- * Maybe there's a better way?
- */
-#define DIFFERENT_SIGNS(x,y) ((x) * (y) <= 0.0F && (x) - (y) != 0.0F)
-#endif
-
-
-/***
  *** CEILF: ceiling of float
  *** FLOORF: floor of float
  *** FABSF: absolute value of float
diff --git a/src/mesa/main/macros.h b/src/mesa/main/macros.h
index 5af9487..7d0a375 100644
--- a/src/mesa/main/macros.h
+++ b/src/mesa/main/macros.h
@@ -689,6 +689,38 @@ NORMALIZE_3FV(GLfloat v[3])
 }
 
 
+/** Is float value negative? */
+static inline GLboolean
+IS_NEGATIVE(float x)
+{
+#if defined(USE_IEEE)
+   fi_type fi;
+   fi.f = x;
+   return fi.i < 0;
+#else
+   return x < 0.0F;
+#endif
+}
+
+
+/** Test two floats have opposite signs */
+static inline GLboolean
+DIFFERENT_SIGNS(GLfloat x, GLfloat y)
+{
+#if defined(USE_IEEE)
+   fi_type xfi, yfi;
+   xfi.f = x;
+   yfi.f = y;
+   return (xfi.i ^ yfi.i) & (1u << 31);
+#else
+   /* Could just use (x*y<0) except for the flatshading requirements.
+    * Maybe there's a better way?
+    */
+   return ((x) * (y) <= 0.0F && (x) - (y) != 0.0F);
+#endif
+}
+
+
 /** Compute ceiling of integer quotient of A divided by B. */
 #define CEILING( A, B )  ( (A) % (B) == 0 ? (A)/(B) : (A)/(B)+1 )
 
-- 
1.7.4.1



More information about the mesa-dev mailing list