On 23.08.2024 01:06, Andrew Cooper wrote: > ... and drop generic_hweight64(). > > This is identical on all architectures except ARM32. Add one extra SELF_TEST > to check that hweight64() works when the input is split in half. > > No functional change. > > Signed-off-by: Andrew Cooper <andrew.coop...@citrix.com>
Reviewed-by: Jan Beulich <jbeul...@suse.com> with one remark: > --- a/xen/include/xen/bitops.h > +++ b/xen/include/xen/bitops.h > @@ -302,6 +302,14 @@ static always_inline __pure unsigned int > hweightl(unsigned long x) > #endif > } > > +static always_inline __pure unsigned int hweight64(uint64_t x) > +{ > + if ( BITS_PER_LONG == 64 ) > + return hweightl(x); > + else > + return hweightl(x >> 32) + hweightl(x); This assume BITS_PER_LONG == 32, which of course is true right now, but doesn't need to be in general. Better add an explicit cast to uint32_t (or masking by 0xffffffffU)? Jan