]> xenbits.xensource.com Git - people/aperard/xen-unstable.git/commitdiff
xen/bitops: Implement hweight32() in terms of hweightl()
authorAndrew Cooper <andrew.cooper3@citrix.com>
Thu, 22 Aug 2024 20:40:11 +0000 (21:40 +0100)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Mon, 9 Sep 2024 13:59:05 +0000 (14:59 +0100)
... and drop generic_hweight32().

As noted previously, the only two users of hweight32() are in __init paths.

The int-optimised form of generic_hweight() is only two instructions shorter
than the long-optimised form, and even then only on architectures which lack
fast multiplication, so there's no point providing an int-optimised form.

No functional change.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Stefano Stabellini <sstabellini@kernel.org>
xen/arch/arm/include/asm/bitops.h
xen/arch/ppc/include/asm/bitops.h
xen/arch/x86/include/asm/bitops.h
xen/include/xen/bitops.h

index 91cd167b6bbb1663451acdc3dd7f0b5734032499..b28c25b3d52dde867e9c0023cf42ea4567f7f403 100644 (file)
@@ -85,7 +85,6 @@ bool clear_mask16_timeout(uint16_t mask, volatile void *p,
  * The Hamming Weight of a number is the total number of bits set in it.
  */
 #define hweight64(x) generic_hweight64(x)
-#define hweight32(x) generic_hweight32(x)
 
 #endif /* _ARM_BITOPS_H */
 /*
index 64512e949530b358e572df169ae641b1ecf4c71f..f488a7c0342544f1845b0d9c81a6e3d4169257fa 100644 (file)
@@ -133,6 +133,5 @@ static inline int test_and_set_bit(unsigned int nr, volatile void *addr)
  * The Hamming Weight of a number is the total number of bits set in it.
  */
 #define hweight64(x) __builtin_popcountll(x)
-#define hweight32(x) __builtin_popcount(x)
 
 #endif /* _ASM_PPC_BITOPS_H */
index 4c5b21907a643918adba0e27a23acc70ebdbcb1a..507b043b8a86591ad00f7fa8ac8f5e13c53adcc9 100644 (file)
@@ -482,6 +482,5 @@ static always_inline unsigned int arch_flsl(unsigned long x)
  * The Hamming Weight of a number is the total number of bits set in it.
  */
 #define hweight64(x) generic_hweight64(x)
-#define hweight32(x) generic_hweight32(x)
 
 #endif /* _X86_BITOPS_H */
index 58c600155f7eb997a92bce10a47f5bb0f6608a63..a462c3065158e029bc88d819919c19b3f70d792d 100644 (file)
@@ -326,6 +326,11 @@ static always_inline attr_const unsigned int hweightl(unsigned long x)
 #endif
 }
 
+static always_inline attr_const unsigned int hweight32(uint32_t x)
+{
+    return hweightl(x);
+}
+
 /* --------------------- Please tidy below here --------------------- */
 
 #ifndef find_next_bit