summaryrefslogtreecommitdiffstats
path: root/include/asm-generic
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2014-07-10 09:21:50 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2014-07-17 19:00:27 +0200
commit92df1ff5f1443cec9c43f6826b99a43e110a67ed (patch)
treedfbbe1928e37f5213ffa60d9898787eebefbe9bb /include/asm-generic
parent90ff524be3846acbc2a7f9d5d0c2a2199db3d0a5 (diff)
downloadbarebox-92df1ff5f1443cec9c43f6826b99a43e110a67ed.tar.gz
barebox-92df1ff5f1443cec9c43f6826b99a43e110a67ed.tar.xz
include: update bitop functions from kernel
Updates the bitop functions from v3.16-rc4 Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'include/asm-generic')
-rw-r--r--include/asm-generic/bitops/hweight.h15
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_ */