On 14 September 2012 16:20, Matt Turner <span dir="ltr"><<a href="mailto:mattst88@gmail.com" target="_blank">mattst88@gmail.com</a>></span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
signbit() appears to be available everywhere (even MSVC according to<br>
MSDN), so let's use it instead of open-coding some messy and confusing<br>
bit twiddling macros.<br>
<br>
Bugzilla: <a href="https://bugs.freedesktop.org/show_bug.cgi?id=54805" target="_blank">https://bugs.freedesktop.org/show_bug.cgi?id=54805</a><br>
Cc: Alan Coopersmith <<a href="mailto:alan.coopersmith@oracle.com">alan.coopersmith@oracle.com</a>><br>
Suggested-by: Ian Romanick <<a href="mailto:ian.d.romanick@intel.com">ian.d.romanick@intel.com</a>><br></blockquote><div><br>LGTM.<br><br>Reviewed-by: Paul Berry <<a href="mailto:stereotype441@gmail.com">stereotype441@gmail.com</a>><br>
</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
---<br>
I'd prefer to see if we can use this everywhere before we decide to keep<br>
the open-coded macros around for other platforms.<br>
<br>
Alan, does this work for you on Solaris?<br>
<br>
<a href="http://configure.ac" target="_blank">configure.ac</a> | 7 +++++++<br>
src/mesa/main/macros.h | 21 ++-------------------<br>
2 files changed, 9 insertions(+), 19 deletions(-)<br>
<br>
diff --git a/<a href="http://configure.ac" target="_blank">configure.ac</a> b/<a href="http://configure.ac" target="_blank">configure.ac</a><br>
index 4193496..f23bfb8 100644<br>
--- a/<a href="http://configure.ac" target="_blank">configure.ac</a><br>
+++ b/<a href="http://configure.ac" target="_blank">configure.ac</a><br>
@@ -499,6 +499,13 @@ AC_SUBST([DLOPEN_LIBS])<br>
dnl See if posix_memalign is available<br>
AC_CHECK_FUNC([posix_memalign], [DEFINES="$DEFINES -DHAVE_POSIX_MEMALIGN"])<br>
<br>
+dnl signbit() is a macro in glibc's math.h, so AC_CHECK_FUNC fails. To handle<br>
+dnl this, use AC_CHECK_DECLS and fallback to AC_CHECK_FUNC in case it fails.<br>
+AC_CHECK_DECLS([signbit],[],<br>
+ AC_CHECK_FUNC([signbit],[],<br>
+ AC_MSG_ERROR([could not find signbit()])),<br>
+ [#include <math.h>])<br>
+<br>
dnl SELinux awareness.<br>
AC_ARG_ENABLE([selinux],<br>
[AS_HELP_STRING([--enable-selinux],<br>
diff --git a/src/mesa/main/macros.h b/src/mesa/main/macros.h<br>
index 04d59d7..7b7fd1b 100644<br>
--- a/src/mesa/main/macros.h<br>
+++ b/src/mesa/main/macros.h<br>
@@ -693,31 +693,14 @@ NORMALIZE_3FV(GLfloat v[3])<br>
static inline GLboolean<br>
IS_NEGATIVE(float x)<br>
{<br>
-#if defined(USE_IEEE)<br>
- fi_type fi;<br>
- fi.f = x;<br>
- return fi.i < 0;<br>
-#else<br>
- return x < 0.0F;<br>
-#endif<br>
+ return signbit(x) != 0;<br>
}<br>
<br>
-<br>
/** Test two floats have opposite signs */<br>
static inline GLboolean<br>
DIFFERENT_SIGNS(GLfloat x, GLfloat y)<br>
{<br>
-#if defined(USE_IEEE)<br>
- fi_type xfi, yfi;<br>
- xfi.f = x;<br>
- yfi.f = y;<br>
- return !!((xfi.i ^ yfi.i) & (1u << 31));<br>
-#else<br>
- /* Could just use (x*y<0) except for the flatshading requirements.<br>
- * Maybe there's a better way?<br>
- */<br>
- return ((x) * (y) <= 0.0F && (x) - (y) != 0.0F);<br>
-#endif<br>
+ return signbit(x) != signbit(y);<br>
}<br>
<span class="HOEnZb"><font color="#888888"><br>
<br>
--<br>
1.7.8.6<br>
<br>
_______________________________________________<br>
mesa-dev mailing list<br>
<a href="mailto:mesa-dev@lists.freedesktop.org">mesa-dev@lists.freedesktop.org</a><br>
<a href="http://lists.freedesktop.org/mailman/listinfo/mesa-dev" target="_blank">http://lists.freedesktop.org/mailman/listinfo/mesa-dev</a><br>
</font></span></blockquote></div><br>