Back to home page

OSCL-LXR

 
 

    


0001 /*
0002  * This file is subject to the terms and conditions of the GNU General Public
0003  * License.  See the file "COPYING" in the main directory of this archive
0004  * for more details.
0005  *
0006  */
0007 #ifndef _ASM_ARCH_HWEIGHT_H
0008 #define _ASM_ARCH_HWEIGHT_H
0009 
0010 #ifdef ARCH_HAS_USABLE_BUILTIN_POPCOUNT
0011 
0012 #include <asm/types.h>
0013 
0014 static inline unsigned int __arch_hweight32(unsigned int w)
0015 {
0016     return __builtin_popcount(w);
0017 }
0018 
0019 static inline unsigned int __arch_hweight16(unsigned int w)
0020 {
0021     return __builtin_popcount(w & 0xffff);
0022 }
0023 
0024 static inline unsigned int __arch_hweight8(unsigned int w)
0025 {
0026     return __builtin_popcount(w & 0xff);
0027 }
0028 
0029 static inline unsigned long __arch_hweight64(__u64 w)
0030 {
0031     return __builtin_popcountll(w);
0032 }
0033 
0034 #else
0035 #include <asm-generic/bitops/arch_hweight.h>
0036 #endif
0037 
0038 #endif /* _ASM_ARCH_HWEIGHT_H */