[Mesa-dev] [PATCH] mesa: fix situations where ffs or ffsl may not be defined

Brian Paul brian.e.paul at gmail.com
Tue Jan 10 19:53:57 PST 2012


On Mon, Jan 9, 2012 at 2:39 PM, Alexander von Gluck
<kallisti5 at unixzen.com> wrote:
>
> ---
>  src/mesa/main/imports.h |   16 ++++++++++++----
>  1 files changed, 12 insertions(+), 4 deletions(-)
>
> diff --git a/src/mesa/main/imports.h b/src/mesa/main/imports.h
> index b7e8743..522ffeb 100644
> --- a/src/mesa/main/imports.h
> +++ b/src/mesa/main/imports.h
> @@ -568,13 +568,19 @@ _mesa_init_sqrt_table(void);
>
>  #ifdef __GNUC__
>
> -#if defined(__MINGW32__) || defined(__CYGWIN__) || defined(ANDROID) ||
> defined(__APPLE__)
> +#if ((__GNUC__ * 100 + __GNUC_MINOR__) >= 304) /* gcc 3.4 or later */
>  #define ffs __builtin_ffs
>  #define ffsll __builtin_ffsll
> +#define _mesa_ffs __builtin_ffs
> +#define _mesa_ffsll __builtin_ffsll
> +#else /* older GCC, no builtin */
> +#include <string.h>

string.h is already included via compiler.h above.


> +extern int
> +_mesa_ffs(int32_t i);
> +extern int
> +_mesa_ffsll(int64_t i);
>  #endif
>
> -#define _mesa_ffs(i)  ffs(i)
> -#define _mesa_ffsll(i)  ffsll(i)
>
>  #if ((__GNUC__ * 100 + __GNUC_MINOR__) >= 304) /* gcc 3.4 or later */
>  #define _mesa_bitcount(i) __builtin_popcount(i)
> @@ -586,7 +592,9 @@ extern unsigned int
>  _mesa_bitcount_64(uint64_t n);
>  #endif
>
> -#else
> +#else /* non-GNUC */
> +#include <strings.h>

Why include strings.h here?


> +
>  extern int
>  _mesa_ffs(int32_t i);
>
> --
> 1.7.7.2
>
> _______________________________________________
> 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