From: Mathias Fröhlich <mathias.froehl...@web.de>

The function is yet unused but will be used with the
next changes.

Signed-off-by: Mathias Fröhlich <mathias.froehl...@web.de>
---
 src/mesa/main/imports.h | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/src/mesa/main/imports.h b/src/mesa/main/imports.h
index d96d666..3ccfb80 100644
--- a/src/mesa/main/imports.h
+++ b/src/mesa/main/imports.h
@@ -400,6 +400,30 @@ _mesa_flsll(uint64_t n)
 #endif
 }
 
+/* Destructively loop over all of the bits in a mask as in:
+ *
+ * while (mymask) {
+ *   int i = _mesa_bit_scan(&mymask);
+ *   ... process element i
+ * }
+ *
+ */
+static inline int
+_mesa_bit_scan(unsigned *mask)
+{
+   const int i = ffs(*mask) - 1;
+   *mask ^= (1u << i);
+   return i;
+}
+
+static inline int
+_mesa_bit_scan64(uint64_t *mask)
+{
+   const int i = ffsll(*mask) - 1;
+   *mask ^= (1llu << i);
+   return i;
+}
+
 static inline bool
 _mesa_half_is_negative(GLhalfARB h)
 {
-- 
2.5.5

_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to