2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
7 #ifndef _ASM_ARCH_HWEIGHT_H
8 #define _ASM_ARCH_HWEIGHT_H
10 #ifdef ARCH_HAS_USABLE_BUILTIN_POPCOUNT
12 #include <asm/types.h>
14 static inline unsigned int __arch_hweight32(unsigned int w
)
16 return __builtin_popcount(w
);
19 static inline unsigned int __arch_hweight16(unsigned int w
)
21 return __builtin_popcount(w
& 0xffff);
24 static inline unsigned int __arch_hweight8(unsigned int w
)
26 return __builtin_popcount(w
& 0xff);
29 static inline unsigned long __arch_hweight64(__u64 w
)
31 return __builtin_popcountll(w
);
35 #include <asm-generic/bitops/arch_hweight.h>
38 #endif /* _ASM_ARCH_HWEIGHT_H */