lists.openwall.net | lists / announce owl-users owl-dev john-users john-dev passwdqc-users yescrypt popa3d-users / oss-security kernel-hardening musl sabotage tlsify passwords / crypt-dev xvendor / Bugtraq Full-Disclosure linux-kernel linux-netdev linux-ext4 linux-hardening PHC | |
Open Source and information security mailing list archives
| ||
|
Date: Tue, 4 Aug 2020 20:10:35 -0400 From: Sasha Levin <sashal@...nel.org> To: torvalds@...ux-foundation.org Cc: mingo@...nel.org, peterz@...radead.org, linux-kernel@...r.kernel.org, Sasha Levin <sashal@...nel.org> Subject: [PATCH v4 06/14] tools bitmap: add bitmap_clear definition This is needed as a result of de4643a77356 ("locking/lockdep: Reuse lock chains that have been freed"). Signed-off-by: Sasha Levin <sashal@...nel.org> --- tools/lib/bitmap.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/tools/lib/bitmap.c b/tools/lib/bitmap.c index b6bc037623fc1..873176c501e43 100644 --- a/tools/lib/bitmap.c +++ b/tools/lib/bitmap.c @@ -101,3 +101,23 @@ int __bitmap_andnot(unsigned long *dst, const unsigned long *bitmap1, BITMAP_LAST_WORD_MASK(bits)); return result != 0; } + +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; + } +} -- 2.25.1
Powered by blists - more mailing lists