Date: Sat, 9 Aug 2025 12:36:03 GMT From: =?utf-8?Q?Jean-S=C3=A9bastien?= =?utf-8?Q?P=C3=A9dron?= <dumbbell@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org Subject: git: 7cbc4d875971 - main - linuxkpi: Use `__builtin_popcountg()` instead of `bitcount*()` Message-ID: <202508091236.579Ca30g020773@gitrepo.freebsd.org>
next in thread | raw e-mail | index | archive | help
The branch main has been updated by dumbbell: URL: https://cgit.FreeBSD.org/src/commit/?id=7cbc4d875971860d941cc15d7f42e6cfeffbfe66 commit 7cbc4d875971860d941cc15d7f42e6cfeffbfe66 Author: Jean-Sébastien Pédron <dumbbell@FreeBSD.org> AuthorDate: 2025-06-22 09:59:01 +0000 Commit: Jean-Sébastien Pédron <dumbbell@FreeBSD.org> CommitDate: 2025-08-09 12:26:25 +0000 linuxkpi: Use `__builtin_popcountg()` instead of `bitcount*()` The DRM drivers generic code started to use `HWEIGHT64()` in the definition of an array field in a structure. Therefore, the array size needs to be known at compile time. This was not the case with the `HWEIGHT*()` macros based on `bitcount*()`. The use of `__builtin_popcountg()` solves that problem. Reviewed by: bz Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D50995 --- sys/compat/linuxkpi/common/include/linux/bitops.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sys/compat/linuxkpi/common/include/linux/bitops.h b/sys/compat/linuxkpi/common/include/linux/bitops.h index bc776a0db9c4..00dd1f9a1ec0 100644 --- a/sys/compat/linuxkpi/common/include/linux/bitops.h +++ b/sys/compat/linuxkpi/common/include/linux/bitops.h @@ -62,10 +62,10 @@ #define hweight64(x) bitcount64(x) #define hweight_long(x) bitcountl(x) -#define HWEIGHT8(x) (bitcount8((uint8_t)(x))) -#define HWEIGHT16(x) (bitcount16(x)) -#define HWEIGHT32(x) (bitcount32(x)) -#define HWEIGHT64(x) (bitcount64(x)) +#define HWEIGHT8(x) (__builtin_popcountg((uint8_t)(x))) +#define HWEIGHT16(x) (__builtin_popcountg((uint16_t)(x))) +#define HWEIGHT32(x) (__builtin_popcountg((uint32_t)(x))) +#define HWEIGHT64(x) (__builtin_popcountg((uint64_t)(x))) static inline int __ffs(int mask)
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202508091236.579Ca30g020773>