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

Alexander von Gluck kallisti5 at unixzen.com
Wed Jan 4 09:32:24 PST 2012


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

-- 
1.7.7.2



More information about the mesa-dev mailing list