diff options
author | Mathias Fröhlich <Mathias.Froehlich@web.de> | 2011-12-01 18:29:18 +0100 |
---|---|---|
committer | Mathias Fröhlich <Mathias.Froehlich@web.de> | 2011-12-02 07:04:49 +0100 |
commit | a4f345e0d21d13186b22f78718547b862d63fdf6 (patch) | |
tree | cedc2dc0d840d3fa17af70ffec1c8b414e2b1a51 | |
parent | 52b75c6165f2b100fe3f8a55ea3f91fbc79e1bf5 (diff) |
mesa: Extend BITSET64_*_RANGE to work on arbitrary ranges.
The BITSET64_{TEST,SET,CLEAR}_RANGE macros only work on ranges
wither in the lower 32 or in the upper 32 bits of the bitset.
This change extends these macros to work on arbitrary ranges
possibly crossing the bitset word boundary.
Signed-off-by: Mathias Froehlich <Mathias.Froehlich@web.de>
Reviewed-by: Brian Paul <brianp@vmware.com>
-rw-r--r-- | src/mesa/main/bitset.h | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/src/mesa/main/bitset.h b/src/mesa/main/bitset.h index 7a0704b147..c27b4c474e 100644 --- a/src/mesa/main/bitset.h +++ b/src/mesa/main/bitset.h @@ -129,17 +129,32 @@ __bitset_ffs(const BITSET_WORD *x, int n) /* bit range operations */ -#define BITSET64_TEST_RANGE(x, b, e) \ +#define BITSET64_TEST_SUBRANGE(x, b, e) \ (BITSET64_BITWORD(b) == BITSET64_BITWORD(e) ? \ ((x)[BITSET64_BITWORD(b)] & BITSET64_RANGE(b, e)) : \ (assert (!"BITSET64_TEST_RANGE: bit range crosses word boundary"), 0)) -#define BITSET64_SET_RANGE(x, b, e) \ +#define BITSET64_TEST_RANGE(x, b, e) \ + (BITSET64_BITWORD(b) == BITSET64_BITWORD(e) ? \ + (BITSET64_TEST_SUBRANGE(x, b, e)) : \ + (BITSET64_TEST_SUBRANGE(x, b, BITSET64_WORDBITS - 1) | \ + BITSET64_TEST_SUBRANGE(x, BITSET64_WORDBITS, e))) +#define BITSET64_SET_SUBRANGE(x, b, e) \ (BITSET64_BITWORD(b) == BITSET64_BITWORD(e) ? \ ((x)[BITSET64_BITWORD(b)] |= BITSET64_RANGE(b, e)) : \ (assert (!"BITSET64_SET_RANGE: bit range crosses word boundary"), 0)) -#define BITSET64_CLEAR_RANGE(x, b, e) \ +#define BITSET64_SET_RANGE(x, b, e) \ + (BITSET64_BITWORD(b) == BITSET64_BITWORD(e) ? \ + (BITSET64_SET_SUBRANGE(x, b, e)) : \ + (BITSET64_SET_SUBRANGE(x, b, BITSET64_WORDBITS - 1) | \ + BITSET64_SET_SUBRANGE(x, BITSET64_WORDBITS, e))) +#define BITSET64_CLEAR_SUBRANGE(x, b, e) \ (BITSET64_BITWORD(b) == BITSET64_BITWORD(e) ? \ ((x)[BITSET64_BITWORD(b)] &= ~BITSET64_RANGE(b, e)) : \ (assert (!"BITSET64_CLEAR_RANGE: bit range crosses word boundary"), 0)) +#define BITSET64_CLEAR_RANGE(x, b, e) \ + (BITSET64_BITWORD(b) == BITSET64_BITWORD(e) ? \ + (BITSET64_CLEAR_SUBRANGE(x, b, e)) : \ + (BITSET64_CLEAR_SUBRANGE(x, b, BITSET64_WORDBITS - 1) | \ + BITSET64_CLEAR_SUBRANGE(x, BITSET64_WORDBITS, e))) #endif |