Mesa (master): util: added ffsll() function
Brian Paul
brianp at kemper.freedesktop.org
Tue Sep 1 22:30:57 UTC 2015
Module: Mesa
Branch: master
Commit: 56852e925e262c9a10454ed59a42ce12fb9c801c
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=56852e925e262c9a10454ed59a42ce12fb9c801c
Author: Brian Paul <brianp at vmware.com>
Date: Tue Sep 1 16:29:17 2015 -0600
util: added ffsll() function
v2: fix errant _GNU_SOURCE test, per Matt Turner.
Reviewed-by: Matt Turner <mattst88 at gmail.com>
Reviewed-by: Jason Ekstrand <jason.ekstrand at intel.com>
---
src/gallium/auxiliary/util/u_math.h | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/src/gallium/auxiliary/util/u_math.h b/src/gallium/auxiliary/util/u_math.h
index 7175d1d..e92f83a 100644
--- a/src/gallium/auxiliary/util/u_math.h
+++ b/src/gallium/auxiliary/util/u_math.h
@@ -389,6 +389,26 @@ unsigned ffs( unsigned u )
#define ffs __builtin_ffs
#endif
+#ifdef HAVE___BUILTIN_FFSLL
+#define ffsll __builtin_ffsll
+#else
+static inline int
+ffsll(long long int val)
+{
+ int bit;
+
+ bit = ffs((unsigned) (val & 0xffffffff));
+ if (bit != 0)
+ return bit;
+
+ bit = ffs((unsigned) (val >> 32));
+ if (bit != 0)
+ return 32 + bit;
+
+ return 0;
+}
+#endif
+
#endif /* FFS_DEFINED */
/**
More information about the mesa-commit
mailing list