mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-21 22:20:14 +01:00
Use signbit() in IS_NEGATIVE and DIFFERENT_SIGNS
signbit() appears to be available everywhere (even MSVC according to MSDN), so let's use it instead of open-coding some messy and confusing bit twiddling macros. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=54805 Reviewed-by: Paul Berry <stereotype441@gmail.com> Suggested-by: Ian Romanick <ian.d.romanick@intel.com>
This commit is contained in:
parent
959fe586fb
commit
0f3ba405ea
2 changed files with 9 additions and 19 deletions
|
|
@ -499,6 +499,13 @@ AC_SUBST([DLOPEN_LIBS])
|
||||||
dnl See if posix_memalign is available
|
dnl See if posix_memalign is available
|
||||||
AC_CHECK_FUNC([posix_memalign], [DEFINES="$DEFINES -DHAVE_POSIX_MEMALIGN"])
|
AC_CHECK_FUNC([posix_memalign], [DEFINES="$DEFINES -DHAVE_POSIX_MEMALIGN"])
|
||||||
|
|
||||||
|
dnl signbit() is a macro in glibc's math.h, so AC_CHECK_FUNC fails. To handle
|
||||||
|
dnl this, use AC_CHECK_DECLS and fallback to AC_CHECK_FUNC in case it fails.
|
||||||
|
AC_CHECK_DECLS([signbit],[],
|
||||||
|
AC_CHECK_FUNC([signbit],[],
|
||||||
|
AC_MSG_ERROR([could not find signbit()])),
|
||||||
|
[#include <math.h>])
|
||||||
|
|
||||||
dnl SELinux awareness.
|
dnl SELinux awareness.
|
||||||
AC_ARG_ENABLE([selinux],
|
AC_ARG_ENABLE([selinux],
|
||||||
[AS_HELP_STRING([--enable-selinux],
|
[AS_HELP_STRING([--enable-selinux],
|
||||||
|
|
|
||||||
|
|
@ -693,31 +693,14 @@ NORMALIZE_3FV(GLfloat v[3])
|
||||||
static inline GLboolean
|
static inline GLboolean
|
||||||
IS_NEGATIVE(float x)
|
IS_NEGATIVE(float x)
|
||||||
{
|
{
|
||||||
#if defined(USE_IEEE)
|
return signbit(x) != 0;
|
||||||
fi_type fi;
|
|
||||||
fi.f = x;
|
|
||||||
return fi.i < 0;
|
|
||||||
#else
|
|
||||||
return x < 0.0F;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/** Test two floats have opposite signs */
|
/** Test two floats have opposite signs */
|
||||||
static inline GLboolean
|
static inline GLboolean
|
||||||
DIFFERENT_SIGNS(GLfloat x, GLfloat y)
|
DIFFERENT_SIGNS(GLfloat x, GLfloat y)
|
||||||
{
|
{
|
||||||
#if defined(USE_IEEE)
|
return signbit(x) != signbit(y);
|
||||||
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
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue