util: add u_bit_scan helper
authorKeith Whitwell <keithw@vmware.com>
Wed, 21 Sep 2011 17:22:43 +0000 (11:22 -0600)
committerBrian Paul <brianp@vmware.com>
Thu, 22 Sep 2011 14:26:36 +0000 (08:26 -0600)
src/gallium/auxiliary/util/u_math.h
src/gallium/drivers/llvmpipe/lp_rast_debug.c

index 46d9322..c74c1da 100644 (file)
@@ -424,6 +424,22 @@ unsigned ffs( unsigned u )
 #endif
 
 
+/* Destructively loop over all of the bits in a mask as in:
+ *
+ * while (mymask) {
+ *   int i = u_bit_scan(&mymask);
+ *   ... process element i
+ * }
+ * 
+ */
+static INLINE int u_bit_scan(unsigned *mask)
+{
+   int i = ffs(*mask) - 1;
+   *mask &= ~(1 << i);
+   return i;
+}
+
+
 /**
  * Return float bits.
  */
index b7568ec..86f5f64 100644 (file)
@@ -2,13 +2,6 @@
 #include "lp_rast_priv.h"
 #include "lp_state_fs.h"
 
-static INLINE int u_bit_scan(unsigned *mask)
-{
-   int i = ffs(*mask) - 1;
-   *mask &= ~(1 << i);
-   return i;
-}
-
 struct tile {
    int coverage;
    int overdraw;