summaryrefslogtreecommitdiffstats
path: root/src/gallium/auxiliary
diff options
context:
space:
mode:
authorBrian Paul <brianp@vmware.com>2015-09-01 16:29:17 -0600
committerBrian Paul <brianp@vmware.com>2015-09-01 16:29:17 -0600
commit56852e925e262c9a10454ed59a42ce12fb9c801c (patch)
treea01d4d0d997c661bdd260d730ba4c210cc885b62 /src/gallium/auxiliary
parent84dad65088147fa8c177c3e6aea20c8ae0868fde (diff)
downloadexternal_mesa3d-56852e925e262c9a10454ed59a42ce12fb9c801c.zip
external_mesa3d-56852e925e262c9a10454ed59a42ce12fb9c801c.tar.gz
external_mesa3d-56852e925e262c9a10454ed59a42ce12fb9c801c.tar.bz2
util: added ffsll() function
v2: fix errant _GNU_SOURCE test, per Matt Turner. Reviewed-by: Matt Turner <mattst88@gmail.com> Reviewed-by: Jason Ekstrand <jason.ekstrand@intel.com>
Diffstat (limited to 'src/gallium/auxiliary')
-rw-r--r--src/gallium/auxiliary/util/u_math.h20
1 files changed, 20 insertions, 0 deletions
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 */
/**