xref: /kernel/linux/linux-5.10/tools/testing/radix-tree/bitmap.c
  • Home
  • History
  • Annotate Annotate
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
  • only in /kernel/linux/linux-5.10/tools/testing/radix-tree/
18c2ecf20Sopenharmony_ci/* lib/bitmap.c pulls in at least two other files. */
28c2ecf20Sopenharmony_ci
38c2ecf20Sopenharmony_ci#include <linux/bitmap.h>
48c2ecf20Sopenharmony_ci
58c2ecf20Sopenharmony_civoid bitmap_clear(unsigned long *map, unsigned int start, int len)
68c2ecf20Sopenharmony_ci{
78c2ecf20Sopenharmony_ci	unsigned long *p = map + BIT_WORD(start);
88c2ecf20Sopenharmony_ci	const unsigned int size = start + len;
98c2ecf20Sopenharmony_ci	int bits_to_clear = BITS_PER_LONG - (start % BITS_PER_LONG);
108c2ecf20Sopenharmony_ci	unsigned long mask_to_clear = BITMAP_FIRST_WORD_MASK(start);
118c2ecf20Sopenharmony_ci
128c2ecf20Sopenharmony_ci	while (len - bits_to_clear >= 0) {
138c2ecf20Sopenharmony_ci		*p &= ~mask_to_clear;
148c2ecf20Sopenharmony_ci		len -= bits_to_clear;
158c2ecf20Sopenharmony_ci		bits_to_clear = BITS_PER_LONG;
168c2ecf20Sopenharmony_ci		mask_to_clear = ~0UL;
178c2ecf20Sopenharmony_ci		p++;
188c2ecf20Sopenharmony_ci	}
198c2ecf20Sopenharmony_ci	if (len) {
208c2ecf20Sopenharmony_ci		mask_to_clear &= BITMAP_LAST_WORD_MASK(size);
218c2ecf20Sopenharmony_ci		*p &= ~mask_to_clear;
228c2ecf20Sopenharmony_ci	}
238c2ecf20Sopenharmony_ci}
24

Indexes created Thu Nov 07 10:32:03 CST 2024