[Mesa-dev] [PATCH] mesa: simplify detection of fpclassify
Ian Romanick
idr at freedesktop.org
Mon Jan 19 20:06:21 PST 2015
On 01/17/2015 07:10 AM, Felix Janda wrote:
> Fixes compilation with musl libc.
> ---
> src/mesa/main/querymatrix.c | 16 +++++-----------
> 1 file changed, 5 insertions(+), 11 deletions(-)
>
> diff --git a/src/mesa/main/querymatrix.c b/src/mesa/main/querymatrix.c
> index eb36c76..57c536f 100644
> --- a/src/mesa/main/querymatrix.c
> +++ b/src/mesa/main/querymatrix.c
> @@ -37,8 +37,10 @@
> #define INT_TO_FIXED(x) ((GLfixed) ((x) << 16))
> #define FLOAT_TO_FIXED(x) ((GLfixed) ((x) * 65536.0))
>
> -#if defined(_MSC_VER)
> -#if _MSC_VER < 1800 /* Not required on VS2013 and above. */
> +#if defined(fpclassify)
> +/* fpclassify is available. */
At first I thought, "This is hinky because it assumes that fpclassify
is a #define." After that I looked up the documentation of fpclassify,
and I found, "ISO C99 defines macros that let you determine what sort
of floating-point number a variable holds."
Could we change the comment here to be:
/* ISO C99 says that fpclassify is a macro. Assume that any implementation
* of fpclassify, whether it's in a C99 compiler or not, will be a macro.
*/
That way the next person doesn't have to do the same research.
With that change, the patch is
Reviewed-by: Ian Romanick <ian.d.romanick at intel.com>
> +#elif defined(_MSC_VER)
> +/* Not required on VS2013 and above. */
> /* Oddly, the fpclassify() function doesn't exist in such a form
> * on MSVC. This is an implementation using slightly different
> * lower-level Windows functions.
> @@ -71,16 +73,8 @@ fpclassify(double x)
> return FP_NAN;
> }
> }
> -#endif /* _MSC_VER < 1800 */
> -
> -#elif defined(__APPLE__) || defined(__CYGWIN__) || defined(__FreeBSD__) || \
> - defined(__OpenBSD__) || defined(__NetBSD__) || defined(__DragonFly__) || \
> - (defined(__sun) && defined(__C99FEATURES__)) || defined(__MINGW32__) || \
> - (defined(__sun) && defined(__GNUC__)) || defined(ANDROID) || defined(__HAIKU__)
> -
> -/* fpclassify is available. */
>
> -#elif !defined(_XOPEN_SOURCE) || _XOPEN_SOURCE < 600
> +#else
>
> enum {FP_NAN, FP_INFINITE, FP_ZERO, FP_SUBNORMAL, FP_NORMAL}
> fpclassify(double x)
>
More information about the mesa-dev
mailing list