@@ -78,14 +78,6 @@ bool clear_mask16_timeout(uint16_t mask, volatile void *p,
#define arch_fls(x) ((x) ? 32 - __builtin_clz(x) : 0)
#define arch_flsl(x) ((x) ? BITS_PER_LONG - __builtin_clzl(x) : 0)
-/**
- * hweightN - returns the hamming weight of a N-bit word
- * @x: the word to weigh
- *
- * The Hamming Weight of a number is the total number of bits set in it.
- */
-#define hweight64(x) generic_hweight64(x)
-
#endif /* _ARM_BITOPS_H */
/*
* Local variables:
@@ -126,12 +126,4 @@ static inline int test_and_set_bit(unsigned int nr, volatile void *addr)
#define arch_hweightl(x) __builtin_popcountl(x)
-/**
- * hweightN - returns the hamming weight of a N-bit word
- * @x: the word to weigh
- *
- * The Hamming Weight of a number is the total number of bits set in it.
- */
-#define hweight64(x) __builtin_popcountll(x)
-
#endif /* _ASM_PPC_BITOPS_H */
@@ -475,12 +475,4 @@ static always_inline unsigned int arch_flsl(unsigned long x)
}
#define arch_flsl arch_flsl
-/**
- * hweightN - returns the hamming weight of a N-bit word
- * @x: the word to weigh
- *
- * The Hamming Weight of a number is the total number of bits set in it.
- */
-#define hweight64(x) generic_hweight64(x)
-
#endif /* _X86_BITOPS_H */
@@ -144,6 +144,9 @@ static void __init test_hweight(void)
CHECK(hweightl, 1 | (1UL << (BITS_PER_LONG - 1)), 2);
CHECK(hweightl, -1UL, BITS_PER_LONG);
+
+ /* unsigned int hweight64(uint64_t) */
+ CHECK(hweight64, -1ULL, 64);
}
static void __init __constructor test_bitops(void)
@@ -331,6 +331,14 @@ static always_inline attr_const unsigned int hweight32(uint32_t x)
return hweightl(x);
}
+static always_inline attr_const unsigned int hweight64(uint64_t x)
+{
+ if ( BITS_PER_LONG >= 64 )
+ return hweightl(x);
+ else
+ return hweight32(x >> 32) + hweight32(x);
+}
+
/* --------------------- Please tidy below here --------------------- */
#ifndef find_next_bit
@@ -399,43 +407,6 @@ static inline int get_count_order(unsigned int count)
return order;
}
-/*
- * hweightN: returns the hamming weight (i.e. the number
- * of bits set) of a N-bit word
- */
-
-static inline unsigned int generic_hweight32(unsigned int w)
-{
- w -= (w >> 1) & 0x55555555;
- w = (w & 0x33333333) + ((w >> 2) & 0x33333333);
- w = (w + (w >> 4)) & 0x0f0f0f0f;
-
- if ( IS_ENABLED(CONFIG_HAS_FAST_MULTIPLY) )
- return (w * 0x01010101) >> 24;
-
- w += w >> 8;
-
- return (w + (w >> 16)) & 0xff;
-}
-
-static inline unsigned int generic_hweight64(uint64_t w)
-{
- if ( BITS_PER_LONG < 64 )
- return generic_hweight32(w >> 32) + generic_hweight32(w);
-
- w -= (w >> 1) & 0x5555555555555555UL;
- w = (w & 0x3333333333333333UL) + ((w >> 2) & 0x3333333333333333UL);
- w = (w + (w >> 4)) & 0x0f0f0f0f0f0f0f0fUL;
-
- if ( IS_ENABLED(CONFIG_HAS_FAST_MULTIPLY) )
- return (w * 0x0101010101010101UL) >> 56;
-
- w += w >> 8;
- w += w >> 16;
-
- return (w + (w >> 32)) & 0xFF;
-}
-
/*
* rol32 - rotate a 32-bit value left
*