From b3b03e33c9f11adb0c4d84311a651ea6016a0885 Mon Sep 17 00:00:00 2001 From: Christian Gmeiner Date: Wed, 12 May 2021 19:46:12 +0200 Subject: util/bitset: add BITSET_SET_RANGE(..) This version works across word boundary. Signed-off-by: Christian Gmeiner Reviewed-by: Rob Clark Part-of: --- src/util/bitset.h | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'src/util/bitset.h') diff --git a/src/util/bitset.h b/src/util/bitset.h index f0b16ea9964..279ad553e79 100644 --- a/src/util/bitset.h +++ b/src/util/bitset.h @@ -205,6 +205,25 @@ __bitset_shl(BITSET_WORD *x, unsigned amount, unsigned n) ((x)[BITSET_BITWORD(b)] &= ~BITSET_RANGE(b, e)) : \ (assert (!"BITSET_CLEAR_RANGE: bit range crosses word boundary"), 0)) +static inline void +__bitset_set_range(BITSET_WORD *r, unsigned start, unsigned end) +{ + const unsigned size = end - start; + const unsigned start_mod = start % BITSET_WORDBITS; + + if (start_mod + size <= BITSET_WORDBITS) { + BITSET_SET_RANGE_INSIDE_WORD(r, start, end); + } else { + const unsigned first_size = BITSET_WORDBITS - start_mod; + + __bitset_set_range(r, start, start + first_size - 1); + __bitset_set_range(r, start + first_size, end); + } +} + +#define BITSET_SET_RANGE(x, b, e) \ + __bitset_set_range(x, b, e) + static inline unsigned __bitset_prefix_sum(const BITSET_WORD *x, unsigned b, unsigned n) { -- cgit v1.2.3 22a'>refslogtreecommitdiff
AgeCommit message (Expand)Author
2025-09-24intel/mda: Add code to produce mesa debug archivesCaio Oliveira
2025-07-24.gitignore: Add KDevelop *.kdev4Vitaliy Triang3l Kuzmin
2024-05-13.gitignore: add .cache folderJuan A. Suarez Romero
2024-01-24.gitignore: Add .venv folderChristian Gmeiner
2022-11-21.gitignore: add VSCode and VSCodiumDavid Heidelberg
2022-06-09.gitignore: Qualify the path for the ignored build directory.Emma Anholt