aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBjoern A. Zeeb <bz@FreeBSD.org>2021-05-27 13:09:40 +0000
committerBjoern A. Zeeb <bz@FreeBSD.org>2021-07-18 00:35:03 +0000
commitb5519f2ce733deec02e3fd398fe8a02dc6826899 (patch)
treedbfe1c490ffc4677e41c412e22306c0d3c340d87
parent1b9b5de489c23790c33614e6db3fe6d8984e3a74 (diff)
downloadsrc-b5519f2ce733deec02e3fd398fe8a02dc6826899.tar.gz
src-b5519f2ce733deec02e3fd398fe8a02dc6826899.zip
LinuxKPI: add HWEIGHT32()
Add HWEIGHT32() macro needed by iwlwifi and while here add the 8/16/64 variants likewise. Sponsored by: The FreeBSD Foundation Reviewed by: hselasky Differential Revision: https://reviews.freebsd.org/D30501 (cherry picked from commit 4cc8a9da491d10f1b4bad6a50730b67dd5e899c7)
-rw-r--r--sys/compat/linuxkpi/common/include/linux/bitops.h5
1 files changed, 5 insertions, 0 deletions
diff --git a/sys/compat/linuxkpi/common/include/linux/bitops.h b/sys/compat/linuxkpi/common/include/linux/bitops.h
index 0e25fd3cfb1d..49bfc4cc7414 100644
--- a/sys/compat/linuxkpi/common/include/linux/bitops.h
+++ b/sys/compat/linuxkpi/common/include/linux/bitops.h
@@ -63,6 +63,11 @@
#define hweight64(x) bitcount64(x)
#define hweight_long(x) bitcountl(x)
+#define HWEIGHT8(x) (bitcount8((uint8_t)(x)) + 1)
+#define HWEIGHT16(x) (bitcount16(x) + 1)
+#define HWEIGHT32(x) (bitcount32(x) + 1)
+#define HWEIGHT64(x) (bitcount64(x) + 1)
+
static inline int
__ffs(int mask)
{