diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2014-08-07 06:15:23 +0200 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2014-08-07 13:13:31 +0200 |
commit | 38c3b2455edea648f38d3e11baf478488fd698ed (patch) | |
tree | a66280a235dfd3fdb5c0411f4efc64b2b98aec0c /include/asm-generic | |
parent | 5b7b7ee5d943c6b58d9b7f974167d0105ca1b787 (diff) | |
parent | ca22ccd7cdbb6b2bd720dd7e14280ee1efa29074 (diff) | |
download | barebox-38c3b2455edea648f38d3e11baf478488fd698ed.tar.gz barebox-38c3b2455edea648f38d3e11baf478488fd698ed.tar.xz |
Merge branch 'for-next/misc'
Conflicts:
lib/Makefile
Diffstat (limited to 'include/asm-generic')
-rw-r--r-- | include/asm-generic/bitops/hweight.h | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/include/asm-generic/bitops/hweight.h b/include/asm-generic/bitops/hweight.h index af9770de4e..7268c8b9ab 100644 --- a/include/asm-generic/bitops/hweight.h +++ b/include/asm-generic/bitops/hweight.h @@ -32,4 +32,19 @@ static inline unsigned int hweight8(unsigned int w) return (res & 0x0F) + ((res >> 4) & 0x0F); } +static inline unsigned long hweight64(__u64 w) +{ +#if BITS_PER_LONG == 32 + return hweight32((unsigned int)(w >> 32)) + + hweight32((unsigned int)w); +#elif BITS_PER_LONG == 64 + __u64 res = w - ((w >> 1) & 0x5555555555555555ul); + res = (res & 0x3333333333333333ul) + ((res >> 2) & 0x3333333333333333ul); + res = (res + (res >> 4)) & 0x0F0F0F0F0F0F0F0Ful; + res = res + (res >> 8); + res = res + (res >> 16); + return (res + (res >> 32)) & 0x00000000000000FFul; +#endif +} + #endif /* _ASM_GENERIC_BITOPS_HWEIGHT_H_ */ |