[igt-dev] [PATCH i-g-t v2 1/3] lib: Add igt_hweight()

Chris Wilson chris at chris-wilson.co.uk
Tue Mar 13 20:49:21 UTC 2018


Quoting Ville Syrjala (2018-03-13 18:29:47)
> From: Ville Syrjälä <ville.syrjala at linux.intel.com>
> 
> Add the binary hamming weight helper to igt_aux.h.
> 
> v2: Add just the one macro that works for 64 and 32 bits (Chris)
> 
> Signed-off-by: Ville Syrjälä <ville.syrjala at linux.intel.com>
> ---
>  lib/igt_aux.h                 |  5 +++++
>  tests/kms_atomic_transition.c | 14 ++++++--------
>  2 files changed, 11 insertions(+), 8 deletions(-)
> 
> diff --git a/lib/igt_aux.h b/lib/igt_aux.h
> index 43dd15fe3b32..faddd478f0d1 100644
> --- a/lib/igt_aux.h
> +++ b/lib/igt_aux.h
> @@ -385,4 +385,9 @@ static inline bool igt_list_empty(const struct igt_list *list)
>              &pos->member != (head);                                    \
>              pos = tmp, tmp = igt_list_next_entry(pos, member))
>  
> +#define igt_hweight(x) \
> +       __builtin_choose_expr(sizeof(x) == 8, \
> +                             __builtin_popcountll(x), \
> +                             __builtin_popcount(x))

Reviewed-by: Chris Wilson <chris at chris-wilson.co.uk>
-Chris


More information about the igt-dev mailing list