diff options
author | Jakub Kicinski <kuba@kernel.org> | 2024-08-01 10:43:15 -0700 |
---|---|---|
committer | Jakub Kicinski <kuba@kernel.org> | 2024-08-01 10:45:23 -0700 |
commit | 5fa35bd39ce106889909444c937a10b2d3a79f08 (patch) | |
tree | bb1fde34b2c9907b1c4b69f6db992bbda0b02355 /tools/lib/bitmap.c | |
parent | 743ff02152bc46bb4a2f2a49ec891c87eba6ab5b (diff) | |
parent | 183d46ff422ef9f3d755b6808ef3faa6d009ba3a (diff) | |
download | lwn-5fa35bd39ce106889909444c937a10b2d3a79f08.tar.gz lwn-5fa35bd39ce106889909444c937a10b2d3a79f08.zip |
Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net
Cross-merge networking fixes after downstream PR.
No conflicts or adjacent changes.
Link: https://patch.msgid.link/20240801131917.34494-1-pabeni@redhat.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Diffstat (limited to 'tools/lib/bitmap.c')
-rw-r--r-- | tools/lib/bitmap.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/tools/lib/bitmap.c b/tools/lib/bitmap.c index c3e4871967bc..2178862bb114 100644 --- a/tools/lib/bitmap.c +++ b/tools/lib/bitmap.c @@ -100,3 +100,23 @@ bool __bitmap_intersects(const unsigned long *bitmap1, return true; return false; } + +void __bitmap_clear(unsigned long *map, unsigned int start, int len) +{ + unsigned long *p = map + BIT_WORD(start); + const unsigned int size = start + len; + int bits_to_clear = BITS_PER_LONG - (start % BITS_PER_LONG); + unsigned long mask_to_clear = BITMAP_FIRST_WORD_MASK(start); + + while (len - bits_to_clear >= 0) { + *p &= ~mask_to_clear; + len -= bits_to_clear; + bits_to_clear = BITS_PER_LONG; + mask_to_clear = ~0UL; + p++; + } + if (len) { + mask_to_clear &= BITMAP_LAST_WORD_MASK(size); + *p &= ~mask_to_clear; + } +} |