aboutsummaryrefslogtreecommitdiff
path: root/include/qemu
diff options
context:
space:
mode:
authorWei Yang <richard.weiyang@gmail.com>2016-03-05 13:47:08 +0000
committerMichael Tokarev <mjt@tls.msk.ru>2016-10-08 11:25:29 +0300
commitcb57fb37051b11d04f1ddce736b0ec3f936e978e (patch)
tree83b9551dfd911cc2d13a1e5a6f4526be06c79727 /include/qemu
parent88071589e8c6665c40c39bdefc59ad615693b325 (diff)
downloadqemu-cb57fb37051b11d04f1ddce736b0ec3f936e978e.zip
qemu-cb57fb37051b11d04f1ddce736b0ec3f936e978e.tar.gz
qemu-cb57fb37051b11d04f1ddce736b0ec3f936e978e.tar.bz2
bitmap: refine and move BITMAP_{FIRST/LAST}_WORD_MASK
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>
Diffstat (limited to 'include/qemu')
-rw-r--r--include/qemu/bitmap.h7
1 files changed, 2 insertions, 5 deletions
diff --git a/include/qemu/bitmap.h b/include/qemu/bitmap.h
index 7247f14..63ea2d0 100644
--- a/include/qemu/bitmap.h
+++ b/include/qemu/bitmap.h
@@ -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)]