1*1a403d1dSDavid Daney /* 2*1a403d1dSDavid Daney * This file is subject to the terms and conditions of the GNU General Public 3*1a403d1dSDavid Daney * License. See the file "COPYING" in the main directory of this archive 4*1a403d1dSDavid Daney * for more details. 5*1a403d1dSDavid Daney * 6*1a403d1dSDavid Daney */ 7*1a403d1dSDavid Daney #ifndef _ASM_ARCH_HWEIGHT_H 8*1a403d1dSDavid Daney #define _ASM_ARCH_HWEIGHT_H 9*1a403d1dSDavid Daney 10*1a403d1dSDavid Daney #ifdef ARCH_HAS_USABLE_BUILTIN_POPCOUNT 11*1a403d1dSDavid Daney 12*1a403d1dSDavid Daney #include <asm/types.h> 13*1a403d1dSDavid Daney __arch_hweight32(unsigned int w)14*1a403d1dSDavid Daneystatic inline unsigned int __arch_hweight32(unsigned int w) 15*1a403d1dSDavid Daney { 16*1a403d1dSDavid Daney return __builtin_popcount(w); 17*1a403d1dSDavid Daney } 18*1a403d1dSDavid Daney __arch_hweight16(unsigned int w)19*1a403d1dSDavid Daneystatic inline unsigned int __arch_hweight16(unsigned int w) 20*1a403d1dSDavid Daney { 21*1a403d1dSDavid Daney return __builtin_popcount(w & 0xffff); 22*1a403d1dSDavid Daney } 23*1a403d1dSDavid Daney __arch_hweight8(unsigned int w)24*1a403d1dSDavid Daneystatic inline unsigned int __arch_hweight8(unsigned int w) 25*1a403d1dSDavid Daney { 26*1a403d1dSDavid Daney return __builtin_popcount(w & 0xff); 27*1a403d1dSDavid Daney } 28*1a403d1dSDavid Daney __arch_hweight64(__u64 w)29*1a403d1dSDavid Daneystatic inline unsigned long __arch_hweight64(__u64 w) 30*1a403d1dSDavid Daney { 31*1a403d1dSDavid Daney return __builtin_popcountll(w); 32*1a403d1dSDavid Daney } 33*1a403d1dSDavid Daney 34*1a403d1dSDavid Daney #else 35*1a403d1dSDavid Daney #include <asm-generic/bitops/arch_hweight.h> 36*1a403d1dSDavid Daney #endif 37*1a403d1dSDavid Daney 38*1a403d1dSDavid Daney #endif /* _ASM_ARCH_HWEIGHT_H */ 39