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
This commit is contained in:
Jean-Sébastien Pédron 2025-06-22 11:59:01 +02:00
parent d17bfb2370
commit 7cbc4d8759
No known key found for this signature in database
GPG key ID: 39E99761A5FD94CC

View file

@ -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)