From 16f7d22394a6ed34c64cb855e4e0d9f9ae5f7465 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Ol=C5=A1=C3=A1k?= Date: Sat, 30 Nov 2024 08:00:53 -0500 Subject: [PATCH] util/bitset: add BITSET_GET_RANGE_INSIDE_WORD to be used later Reviewed-by: Alyssa Rosenzweig Part-of: --- src/util/bitset.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/util/bitset.h b/src/util/bitset.h index 8f6979881bd..4fc4dbb6f3e 100644 --- a/src/util/bitset.h +++ b/src/util/bitset.h @@ -207,11 +207,13 @@ __bitset_shl(BITSET_WORD *x, unsigned amount, unsigned n) /* bit range operations (e=end is inclusive) */ -#define BITSET_TEST_RANGE_INSIDE_WORD(x, b, e, mask) \ +#define BITSET_GET_RANGE_INSIDE_WORD(x, b, e) \ (BITSET_BITWORD(b) == BITSET_BITWORD(e) ? \ - (((x)[BITSET_BITWORD(b)] & BITSET_RANGE(b, e)) == \ - (((BITSET_WORD)mask) << (b % BITSET_WORDBITS))) : \ + (((x)[BITSET_BITWORD(b)] >> (b % BITSET_WORDBITS)) & \ + BITSET_MASK((e) - (b) + 1)) : \ (assert (!"BITSET_TEST_RANGE: bit range crosses word boundary"), 0)) +#define BITSET_TEST_RANGE_INSIDE_WORD(x, b, e, mask) \ + (BITSET_GET_RANGE_INSIDE_WORD(x, b, e) == (mask)) #define BITSET_SET_RANGE_INSIDE_WORD(x, b, e) \ (BITSET_BITWORD(b) == BITSET_BITWORD(e) ? \ ((x)[BITSET_BITWORD(b)] |= BITSET_RANGE(b, e)) : \