mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-04-25 07:00:45 +02:00
util/bitset: add BITSET_SIZE()
To get the size (in bits) of a bitset. And minor clean-up in __bitset_ffs(). Signed-off-by: Brian Paul <brianp@vmware.com> Reviewed-by: Roland Scheidegger <sroland@vmware.com> cc: mesa-stable Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17062>
This commit is contained in:
parent
938767e835
commit
8bd6feaca5
1 changed files with 3 additions and 4 deletions
|
|
@ -52,6 +52,7 @@
|
|||
#define BITSET_EQUAL(x, y) (memcmp( (x), (y), sizeof (x) ) == 0)
|
||||
#define BITSET_ZERO(x) memset( (x), 0, sizeof (x) )
|
||||
#define BITSET_ONES(x) memset( (x), 0xff, sizeof (x) )
|
||||
#define BITSET_SIZE(x) (8 * sizeof(x)) // bitset size in bits
|
||||
|
||||
#define BITSET_BITWORD(b) ((b) / BITSET_WORDBITS)
|
||||
#define BITSET_BIT(b) (1u << ((b) % BITSET_WORDBITS))
|
||||
|
|
@ -300,11 +301,9 @@ __bitset_count(const BITSET_WORD *x, unsigned n)
|
|||
static inline int
|
||||
__bitset_ffs(const BITSET_WORD *x, int n)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < n; i++) {
|
||||
for (int i = 0; i < n; i++) {
|
||||
if (x[i])
|
||||
return ffs(x[i]) + BITSET_WORDBITS * i;
|
||||
return ffs(x[i]) + BITSET_WORDBITS * i;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue