Skip to content

Commit

Permalink
bitmap: refine and move BITMAP_{FIRST/LAST}_WORD_MASK
Browse files Browse the repository at this point in the history
According to linux kernel commit <89c1e79eb30> ("linux/bitmap.h: improve
BITMAP_{LAST,FIRST}_WORD_MASK"), these two macro could be improved.

This patch takes this change and also move them all in header file.

Signed-off-by: Wei Yang <richard.weiyang@gmail.com>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
  • Loading branch information
RichardWeiYang authored and Michael Tokarev committed Oct 8, 2016
1 parent 8807158 commit cb57fb3
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 7 deletions.
7 changes: 2 additions & 5 deletions include/qemu/bitmap.h
Expand Up @@ -57,11 +57,8 @@
* find_next_bit(addr, nbits, bit) Position next set bit in *addr >= bit
*/

#define BITMAP_LAST_WORD_MASK(nbits) \
( \
((nbits) % BITS_PER_LONG) ? \
(1UL<<((nbits) % BITS_PER_LONG))-1 : ~0UL \
)
#define BITMAP_FIRST_WORD_MASK(start) (~0UL << ((start) & (BITS_PER_LONG - 1)))
#define BITMAP_LAST_WORD_MASK(nbits) (~0UL >> (-(nbits) & (BITS_PER_LONG - 1)))

#define DECLARE_BITMAP(name,bits) \
unsigned long name[BITS_TO_LONGS(bits)]
Expand Down
2 changes: 0 additions & 2 deletions util/bitmap.c
Expand Up @@ -157,8 +157,6 @@ int slow_bitmap_andnot(unsigned long *dst, const unsigned long *bitmap1,
return result != 0;
}

#define BITMAP_FIRST_WORD_MASK(start) (~0UL << ((start) % BITS_PER_LONG))

void bitmap_set(unsigned long *map, long start, long nr)
{
unsigned long *p = map + BIT_WORD(start);
Expand Down

0 comments on commit cb57fb3

Please sign in to comment.