mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-06-19 21:21:09 +00:00
[PATCH] bitops: hweight() related cleanup
By defining generic hweight*() routines - hweight64() will be defined on all architectures - hweight_long() will use architecture optimized hweight32() or hweight64() I found two possible cleanups by these reasons. Signed-off-by: Akinobu Mita <mita@miraclelinux.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
This commit is contained in:
parent
e9bebd6f3a
commit
37d54111c1
2 changed files with 3 additions and 19 deletions
19
lib/bitmap.c
19
lib/bitmap.c
|
@ -253,33 +253,18 @@ int __bitmap_subset(const unsigned long *bitmap1,
|
|||
}
|
||||
EXPORT_SYMBOL(__bitmap_subset);
|
||||
|
||||
#if BITS_PER_LONG == 32
|
||||
int __bitmap_weight(const unsigned long *bitmap, int bits)
|
||||
{
|
||||
int k, w = 0, lim = bits/BITS_PER_LONG;
|
||||
|
||||
for (k = 0; k < lim; k++)
|
||||
w += hweight32(bitmap[k]);
|
||||
w += hweight_long(bitmap[k]);
|
||||
|
||||
if (bits % BITS_PER_LONG)
|
||||
w += hweight32(bitmap[k] & BITMAP_LAST_WORD_MASK(bits));
|
||||
w += hweight_long(bitmap[k] & BITMAP_LAST_WORD_MASK(bits));
|
||||
|
||||
return w;
|
||||
}
|
||||
#else
|
||||
int __bitmap_weight(const unsigned long *bitmap, int bits)
|
||||
{
|
||||
int k, w = 0, lim = bits/BITS_PER_LONG;
|
||||
|
||||
for (k = 0; k < lim; k++)
|
||||
w += hweight64(bitmap[k]);
|
||||
|
||||
if (bits % BITS_PER_LONG)
|
||||
w += hweight64(bitmap[k] & BITMAP_LAST_WORD_MASK(bits));
|
||||
|
||||
return w;
|
||||
}
|
||||
#endif
|
||||
EXPORT_SYMBOL(__bitmap_weight);
|
||||
|
||||
/*
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue