[Mesa-dev] [PATCH 2/2] mesa/gallium: add FFS_DEFINED to protect ffs() from multiple definitions

Jose Fonseca jfonseca at vmware.com
Thu Jan 12 08:06:43 PST 2012


Looks good Brian.

Jose

----- Original Message -----
> We include both imports.h and u_math.h in the state tracker.  This
> leads to multiple, conflicting definitions of ffs() with MSVC.
> Use FFS_DEFINED to skip the ffs() in u_math.h.
> ---
>  src/gallium/auxiliary/util/u_math.h |    5 +++++
>  src/mesa/main/imports.h             |    4 ++++
>  2 files changed, 9 insertions(+), 0 deletions(-)
> 
> diff --git a/src/gallium/auxiliary/util/u_math.h
> b/src/gallium/auxiliary/util/u_math.h
> index 404bd21..f619666 100644
> --- a/src/gallium/auxiliary/util/u_math.h
> +++ b/src/gallium/auxiliary/util/u_math.h
> @@ -340,6 +340,9 @@ util_is_inf_or_nan(float x)
>   * Find first bit set in word.  Least significant bit is 1.
>   * Return 0 if no bits set.
>   */
> +#ifndef FFS_DEFINED
> +#define FFS_DEFINED 1
> +
>  #if defined(_MSC_VER) && _MSC_VER >= 1300 && (_M_IX86 || _M_AMD64 ||
>  _M_IA64)
>  unsigned char _BitScanForward(unsigned long* Index, unsigned long
>  Mask);
>  #pragma intrinsic(_BitScanForward)
> @@ -372,6 +375,8 @@ unsigned ffs( unsigned u )
>  #define ffs __builtin_ffs
>  #endif
>  
> +#endif /* FFS_DEFINED */
> +
>  
>  /* Destructively loop over all of the bits in a mask as in:
>   *
> diff --git a/src/mesa/main/imports.h b/src/mesa/main/imports.h
> index bcf125a..ce7b45d 100644
> --- a/src/mesa/main/imports.h
> +++ b/src/mesa/main/imports.h
> @@ -566,6 +566,9 @@ _mesa_inv_sqrtf(float x);
>  extern void
>  _mesa_init_sqrt_table(void);
>  
> +
> +#ifndef FFS_DEFINED
> +#define FFS_DEFINED 1
>  #ifdef __GNUC__
>  
>  #if defined(__MINGW32__) || defined(__CYGWIN__) || defined(ANDROID)
>  || defined(__APPLE__)
> @@ -579,6 +582,7 @@ extern int ffs(int i);
>  extern int ffsll(long long int i);
>  
>  #endif /*__ GNUC__ */
> +#endif /* FFS_DEFINED */
>  
>  
>  #if defined(__GNUC__) && ((__GNUC__ * 100 + __GNUC_MINOR__) >= 304)
>  /* gcc 3.4 or later */
> --
> 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