On Sat, Jan 30, 2021 at 11:17:15AM -0800, Yury Norov wrote:
> BITMAP_{LAST,FIRST}_WORD_MASK() in linux/bitmap.h duplicates the
> functionality of GENMASK(). The scope of there macros is wider than just
> bitmap. This patch defines 4 new macros: BITS_FIRST(), BITS_LAST(),
> BITS_FIRST_MASK() and BITS_LAST_MASK() in linux/bits.h on top of GENMASK()
> and replaces BITMAP_{LAST,FIRST}_WORD_MASK() to avoid duplication and
> increases scope of the macros.

...

>  include/linux/bitmap.h            | 27 ++++++++++++---------------
>  include/linux/bits.h              |  6 ++++++
>  include/linux/cpumask.h           |  8 ++++----
>  include/linux/netdev_features.h   |  2 +-
>  include/linux/nodemask.h          |  2 +-
>  lib/bitmap.c                      | 26 +++++++++++++-------------
>  lib/find_bit.c                    |  4 ++--
>  lib/genalloc.c                    |  8 ++++----

Answering to your reply. I meant to split the below to a separate patch.

>  tools/include/linux/bitmap.h      | 20 ++++++--------------
>  tools/include/linux/bits.h        |  6 ++++++
>  tools/lib/bitmap.c                |  6 +++---
>  tools/lib/find_bit.c              |  2 +-
>  tools/testing/radix-tree/bitmap.c |  4 ++--

...

> +#define BITS_FIRST(nr)               GENMASK((nr), 0)
> +#define BITS_LAST(nr)                GENMASK(BITS_PER_LONG - 1, (nr))
> +
> +#define BITS_FIRST_MASK(nr)  BITS_FIRST((nr) % BITS_PER_LONG)
> +#define BITS_LAST_MASK(nr)   BITS_LAST((nr) % BITS_PER_LONG)

Any pointers to the difference in generated code for popular architectures
(x86. x86_64, arm, aarch64, ppc, ppc64)?

-- 
With Best Regards,
Andy Shevchenko


Reply via email to