summaryrefslogtreecommitdiff
path: root/lib/mesa/src/util/bitscan.h
diff options
context:
space:
mode:
authorJonathan Gray <jsg@cvs.openbsd.org>2021-07-22 10:50:50 +0000
committerJonathan Gray <jsg@cvs.openbsd.org>2021-07-22 10:50:50 +0000
commit9130ec005fbc78a62420643414d8354d0929ca50 (patch)
tree6762777acdd2d4eee17ef87290e80dc7afe2b73d /lib/mesa/src/util/bitscan.h
parentca11beabae33eb59fb981b8adf50b1d47a2a98f0 (diff)
Merge Mesa 21.1.5
Diffstat (limited to 'lib/mesa/src/util/bitscan.h')
-rw-r--r--lib/mesa/src/util/bitscan.h10
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/mesa/src/util/bitscan.h b/lib/mesa/src/util/bitscan.h
index 895a1e7a3..1ea7b0735 100644
--- a/lib/mesa/src/util/bitscan.h
+++ b/lib/mesa/src/util/bitscan.h
@@ -104,6 +104,11 @@ u_bit_scan(unsigned *mask)
return i;
}
+#define u_foreach_bit(b, dword) \
+ for (uint32_t __dword = (dword), b; \
+ ((b) = ffs(__dword) - 1, __dword); \
+ __dword &= ~(1 << (b)))
+
static inline int
u_bit_scan64(uint64_t *mask)
{
@@ -112,6 +117,11 @@ u_bit_scan64(uint64_t *mask)
return i;
}
+#define u_foreach_bit64(b, dword) \
+ for (uint64_t __dword = (dword), b; \
+ ((b) = ffsll(__dword) - 1, __dword); \
+ __dword &= ~(1ull << (b)))
+
/* Determine if an unsigned value is a power of two.
*
* \note