mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-01-11 21:00:17 +01:00
util: make BITSET_TEST_RANGE_INSIDE_WORD take a value to compare with
Reviewed-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26307>
This commit is contained in:
parent
6d2a7f53ac
commit
fb994f44d9
2 changed files with 7 additions and 7 deletions
|
|
@ -205,11 +205,11 @@ __bitset_shl(BITSET_WORD *x, unsigned amount, unsigned n)
|
|||
#define BITSET_SHL(x, n) \
|
||||
__bitset_shl(x, n, ARRAY_SIZE(x));
|
||||
|
||||
/* bit range operations
|
||||
/* bit range operations (e=end is inclusive)
|
||||
*/
|
||||
#define BITSET_TEST_RANGE_INSIDE_WORD(x, b, e) \
|
||||
#define BITSET_TEST_RANGE_INSIDE_WORD(x, b, e, mask) \
|
||||
(BITSET_BITWORD(b) == BITSET_BITWORD(e) ? \
|
||||
(((x)[BITSET_BITWORD(b)] & BITSET_RANGE(b, e)) != 0) : \
|
||||
(((x)[BITSET_BITWORD(b)] & BITSET_RANGE(b, e)) == mask) : \
|
||||
(assert (!"BITSET_TEST_RANGE: bit range crosses word boundary"), 0))
|
||||
#define BITSET_SET_RANGE_INSIDE_WORD(x, b, e) \
|
||||
(BITSET_BITWORD(b) == BITSET_BITWORD(e) ? \
|
||||
|
|
@ -227,7 +227,7 @@ __bitset_test_range(const BITSET_WORD *r, unsigned start, unsigned end)
|
|||
const unsigned start_mod = start % BITSET_WORDBITS;
|
||||
|
||||
if (start_mod + size <= BITSET_WORDBITS) {
|
||||
return BITSET_TEST_RANGE_INSIDE_WORD(r, start, end);
|
||||
return !BITSET_TEST_RANGE_INSIDE_WORD(r, start, end, 0);
|
||||
} else {
|
||||
const unsigned first_size = BITSET_WORDBITS - start_mod;
|
||||
|
||||
|
|
|
|||
|
|
@ -74,8 +74,8 @@ TEST(bitset, test_basic_range)
|
|||
|
||||
const int max_set = 15;
|
||||
BITSET_SET_RANGE_INSIDE_WORD(mask128, 0, max_set);
|
||||
EXPECT_EQ(BITSET_TEST_RANGE_INSIDE_WORD(mask128, 0, max_set), true);
|
||||
EXPECT_EQ(BITSET_TEST_RANGE_INSIDE_WORD(mask128, max_set + 1, max_set + 15), false);
|
||||
EXPECT_EQ(!BITSET_TEST_RANGE_INSIDE_WORD(mask128, 0, max_set, 0), true);
|
||||
EXPECT_EQ(!BITSET_TEST_RANGE_INSIDE_WORD(mask128, max_set + 1, max_set + 15, 0), false);
|
||||
for (int i = 0; i < 128; i++) {
|
||||
if (i <= max_set)
|
||||
EXPECT_EQ(BITSET_TEST(mask128, i), true);
|
||||
|
|
@ -83,7 +83,7 @@ TEST(bitset, test_basic_range)
|
|||
EXPECT_EQ(BITSET_TEST(mask128, i), false);
|
||||
}
|
||||
BITSET_CLEAR_RANGE(mask128, 0, max_set);
|
||||
EXPECT_EQ(BITSET_TEST_RANGE_INSIDE_WORD(mask128, 0, max_set), false);
|
||||
EXPECT_EQ(!BITSET_TEST_RANGE_INSIDE_WORD(mask128, 0, max_set, 0), false);
|
||||
for (int i = 0; i < 128; i++) {
|
||||
EXPECT_EQ(BITSET_TEST(mask128, i), false);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue