Module: Mesa
Branch: staging/22.1
Commit: 3d7fe94c6a8a30e26d05dd06ca7b6e4e0a337374
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=3d7fe94c6a8a30e26d05dd06ca7b6e4e0a337374

Author: Brian Paul <[email protected]>
Date:   Wed May 25 10:21:21 2022 -0600

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 <[email protected]>
Reviewed-by: Roland Scheidegger <[email protected]>
cc: mesa-stable

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17062>
(cherry picked from commit 8bd6feaca5ac15e3375b5631f68013a5a9b336aa)

---

 .pick_status.json | 2 +-
 src/util/bitset.h | 7 +++----
 2 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/.pick_status.json b/.pick_status.json
index b6e93df7356..dbcc61662d0 100644
--- a/.pick_status.json
+++ b/.pick_status.json
@@ -5296,7 +5296,7 @@
         "description": "util/bitset: add BITSET_SIZE()",
         "nominated": true,
         "nomination_type": 0,
-        "resolution": 0,
+        "resolution": 1,
         "main_sha": null,
         "because_sha": null
     },
diff --git a/src/util/bitset.h b/src/util/bitset.h
index d8ec1af67ad..2e889cd6d4d 100644
--- a/src/util/bitset.h
+++ b/src/util/bitset.h
@@ -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))
@@ -262,11 +263,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;

Reply via email to