Skip to content

Commit a719101

Browse files
YuryNorovtorvalds
authored andcommitted
tools: sync BITMAP_LAST_WORD_MASK() macro with the kernel
Kernel version generates better code. Link: https://lkml.kernel.org/r/20210401003153.97325-4-yury.norov@gmail.com Signed-off-by: Yury Norov <yury.norov@gmail.com> Acked-by: Rasmus Villemoes <linux@rasmusvillemoes.dk> Cc: Alexey Klimov <aklimov@redhat.com> Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Cc: Arnd Bergmann <arnd@arndb.de> Cc: David Sterba <dsterba@suse.com> Cc: Dennis Zhou <dennis@kernel.org> Cc: Geert Uytterhoeven <geert@linux-m68k.org> Cc: Jianpeng Ma <jianpeng.ma@intel.com> Cc: Joe Perches <joe@perches.com> Cc: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de> Cc: Josh Poimboeuf <jpoimboe@redhat.com> Cc: Rich Felker <dalias@libc.org> Cc: Stefano Brivio <sbrivio@redhat.com> Cc: Wei Yang <richard.weiyang@linux.alibaba.com> Cc: Wolfram Sang <wsa+renesas@sang-engineering.com> Cc: Yoshinori Sato <ysato@users.osdn.me> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent e5b9252 commit a719101

1 file changed

Lines changed: 1 addition & 6 deletions

File tree

‎tools/include/linux/bitmap.h‎

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,7 @@ int __bitmap_equal(const unsigned long *bitmap1,
2020
void bitmap_clear(unsigned long *map, unsigned int start, int len);
2121

2222
#define BITMAP_FIRST_WORD_MASK(start) (~0UL << ((start) & (BITS_PER_LONG - 1)))
23-
24-
#define BITMAP_LAST_WORD_MASK(nbits) \
25-
( \
26-
((nbits) % BITS_PER_LONG) ? \
27-
(1UL<<((nbits) % BITS_PER_LONG))-1 : ~0UL \
28-
)
23+
#define BITMAP_LAST_WORD_MASK(nbits) (~0UL >> (-(nbits) & (BITS_PER_LONG - 1)))
2924

3025
#define small_const_nbits(nbits) \
3126
(__builtin_constant_p(nbits) && (nbits) <= BITS_PER_LONG)

0 commit comments

Comments
 (0)