diff options
author | Jason Ekstrand <[email protected]> | 2019-05-01 05:31:11 -0500 |
---|---|---|
committer | Jason Ekstrand <[email protected]> | 2019-05-02 03:12:54 +0000 |
commit | bf774b56be46d5812868d9f6e7e63437d36754e0 (patch) | |
tree | bff2ebad8e36fb1947c4a4bc907e6afa4f9ab061 | |
parent | 413e55b5b99d7d135624f461797d450745b3bfbf (diff) |
util/bitset: Return an actual bool from test macros
I want to be able to do BITSET_TEST() != BITSET_TEST() and this isn't
currently possible because BITSET_TEST() returns a random bit. Compare
to zero to get an actual Boolean.
Reviewed-by: Eric Engestrom <[email protected]>
Reviewed-by: Ian Romanick <[email protected]>
-rw-r--r-- | src/util/bitset.h | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/util/bitset.h b/src/util/bitset.h index 3b18abac793..e610d5f897e 100644 --- a/src/util/bitset.h +++ b/src/util/bitset.h @@ -58,7 +58,7 @@ /* single bit operations */ -#define BITSET_TEST(x, b) ((x)[BITSET_BITWORD(b)] & BITSET_BIT(b)) +#define BITSET_TEST(x, b) (((x)[BITSET_BITWORD(b)] & BITSET_BIT(b)) != 0) #define BITSET_SET(x, b) ((x)[BITSET_BITWORD(b)] |= BITSET_BIT(b)) #define BITSET_CLEAR(x, b) ((x)[BITSET_BITWORD(b)] &= ~BITSET_BIT(b)) @@ -69,7 +69,7 @@ */ #define BITSET_TEST_RANGE(x, b, e) \ (BITSET_BITWORD(b) == BITSET_BITWORD(e) ? \ - ((x)[BITSET_BITWORD(b)] & BITSET_RANGE(b, e)) : \ + (((x)[BITSET_BITWORD(b)] & BITSET_RANGE(b, e)) != 0) : \ (assert (!"BITSET_TEST_RANGE: bit range crosses word boundary"), 0)) #define BITSET_SET_RANGE(x, b, e) \ (BITSET_BITWORD(b) == BITSET_BITWORD(e) ? \ |