[Mesa-dev] [PATCH 1/2] mesa: add signbit() macro

Jose Fonseca jfonseca at vmware.com
Mon Sep 24 13:53:30 PDT 2012


>From signbit manpage:

  This is not the same as x < 0.0, because IEEE 754 floating point allows zero to be signed.   The  comparison  -0.0  <  0.0  is    false, but signbit(-0.0) will return a nonzero value.

I think that for consistency (and especially because MSVC ends not being as widely tested as gcc), we should match the spec. This can easily be done using an inline and an union.

Jose

----- Original Message -----
> Fixes compilation failure with MSVC since 0f3ba405.
> ---
>  src/mesa/main/imports.h |    7 +++++++
>  1 files changed, 7 insertions(+), 0 deletions(-)
> 
> diff --git a/src/mesa/main/imports.h b/src/mesa/main/imports.h
> index 81da510..4deca6a 100644
> --- a/src/mesa/main/imports.h
> +++ b/src/mesa/main/imports.h
> @@ -145,6 +145,13 @@ static inline int isblank(int ch) { return ch ==
> ' ' || ch == '\t'; }
>  /*@}*/
>  
>  
> +/*
> + * signbit() is a macro on Linux.  Not available on Windows.
> + */
> +#ifndef signbit
> +#define signbit(x) ((x) < 0.0)
> +#endif
> +
>  
>  /** single-precision inverse square root */
>  static inline float
> --
> 1.7.3.4
> 
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev
> 


More information about the mesa-dev mailing list