diff options
author | David S. Miller <davem@davemloft.net> | 2011-07-29 12:42:07 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2011-08-03 00:28:50 -0400 |
commit | ef7c4d4675d2a9206f913f26ca1a5cd41bff9d41 (patch) | |
tree | 88839b80e603ba395882df98b8a8c8f8385337b1 /arch/sparc/include | |
parent | e95ade083939dcb4b0c51c1a2c8504ea9ef3d6ef (diff) |
sparc: Use popc if possible for hweight routines.
Just like powerpc, we code patch at boot time.
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'arch/sparc/include')
-rw-r--r-- | arch/sparc/include/asm/bitops_64.h | 42 |
1 files changed, 4 insertions, 38 deletions
diff --git a/arch/sparc/include/asm/bitops_64.h b/arch/sparc/include/asm/bitops_64.h index 325e295d60de..3588807baa6e 100644 --- a/arch/sparc/include/asm/bitops_64.h +++ b/arch/sparc/include/asm/bitops_64.h | |||
@@ -42,45 +42,11 @@ extern void change_bit(unsigned long nr, volatile unsigned long *addr); | |||
42 | * of bits set) of a N-bit word | 42 | * of bits set) of a N-bit word |
43 | */ | 43 | */ |
44 | 44 | ||
45 | #ifdef ULTRA_HAS_POPULATION_COUNT | 45 | extern unsigned long __arch_hweight64(__u64 w); |
46 | extern unsigned int __arch_hweight32(unsigned int w); | ||
47 | extern unsigned int __arch_hweight16(unsigned int w); | ||
48 | extern unsigned int __arch_hweight8(unsigned int w); | ||
46 | 49 | ||
47 | static inline unsigned int __arch_hweight64(unsigned long w) | ||
48 | { | ||
49 | unsigned int res; | ||
50 | |||
51 | __asm__ ("popc %1,%0" : "=r" (res) : "r" (w)); | ||
52 | return res; | ||
53 | } | ||
54 | |||
55 | static inline unsigned int __arch_hweight32(unsigned int w) | ||
56 | { | ||
57 | unsigned int res; | ||
58 | |||
59 | __asm__ ("popc %1,%0" : "=r" (res) : "r" (w & 0xffffffff)); | ||
60 | return res; | ||
61 | } | ||
62 | |||
63 | static inline unsigned int __arch_hweight16(unsigned int w) | ||
64 | { | ||
65 | unsigned int res; | ||
66 | |||
67 | __asm__ ("popc %1,%0" : "=r" (res) : "r" (w & 0xffff)); | ||
68 | return res; | ||
69 | } | ||
70 | |||
71 | static inline unsigned int __arch_hweight8(unsigned int w) | ||
72 | { | ||
73 | unsigned int res; | ||
74 | |||
75 | __asm__ ("popc %1,%0" : "=r" (res) : "r" (w & 0xff)); | ||
76 | return res; | ||
77 | } | ||
78 | |||
79 | #else | ||
80 | |||
81 | #include <asm-generic/bitops/arch_hweight.h> | ||
82 | |||
83 | #endif | ||
84 | #include <asm-generic/bitops/const_hweight.h> | 50 | #include <asm-generic/bitops/const_hweight.h> |
85 | #include <asm-generic/bitops/lock.h> | 51 | #include <asm-generic/bitops/lock.h> |
86 | #endif /* __KERNEL__ */ | 52 | #endif /* __KERNEL__ */ |