[Mesa-dev] [PATCH 5/6] gallium/util: Add an implementation of ffsl

Jason Ekstrand jason at jlekstrand.net
Sat Aug 15 11:31:26 PDT 2015


---
 src/gallium/auxiliary/util/u_math.h | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/src/gallium/auxiliary/util/u_math.h b/src/gallium/auxiliary/util/u_math.h
index 56bd185..5814421 100644
--- a/src/gallium/auxiliary/util/u_math.h
+++ b/src/gallium/auxiliary/util/u_math.h
@@ -391,6 +391,18 @@ unsigned ffs( unsigned u )
 
 #endif /* FFS_DEFINED */
 
+#ifndef FFSL_DEFINED
+#define FFSL_DEFINED 1
+
+#ifdef _MSC_VER
+/* With MSVC, int and long are the same type even on 64-bit */
+#define ffsl ffs
+#else
+#define ffsl(x) ((sizeof(long) == sizeof(int)) ? ffs(x) : ffsll(x))
+#endif
+
+#endif /* FFSL_DEFINED */
+
 /**
  * Find first bit set in long long.  Least significant bit is 1.
  * Return 0 if no bits set.
-- 
2.4.3



More information about the mesa-dev mailing list