summaryrefslogtreecommitdiffstats
path: root/src/mesa/main/macros.h
diff options
context:
space:
mode:
authorBrian Paul <brianp@vmware.com>2012-08-31 08:33:31 -0600
committerBrian Paul <brianp@vmware.com>2012-09-01 07:41:26 -0600
commitc8a86f717f8e30204c615d06bcec159410ac06c5 (patch)
tree318b29b6b68d5b1cc8f4d69845e835adf04464fa /src/mesa/main/macros.h
parenta2cf265c8da51e9b7db363a98b0ee80c61b2f79e (diff)
downloadexternal_mesa3d-c8a86f717f8e30204c615d06bcec159410ac06c5.zip
external_mesa3d-c8a86f717f8e30204c615d06bcec159410ac06c5.tar.gz
external_mesa3d-c8a86f717f8e30204c615d06bcec159410ac06c5.tar.bz2
mesa: move IS_NEGATIVE() and DIFFERENT_SIGNS() to macros.h
Diffstat (limited to 'src/mesa/main/macros.h')
-rw-r--r--src/mesa/main/macros.h32
1 files changed, 32 insertions, 0 deletions
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 )