Re: [PATCH 00/21] lib: add alternatives for GENMASK()
From: david laight
Date: Wed Nov 26 2025 - 17:17:34 EST
On Wed, 26 Nov 2025 11:44:59 -0800
Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx> wrote:
> On Wed, 26 Nov 2025 at 01:07, Rasmus Villemoes <ravi@xxxxxxxxx> wrote:
> >
> > There is, however, an alternative that resembles the syntax in data
> > sheets even more closely:
> >
> > #define BITS(low_high) GENMASK((0 ? low_high), (1 ? low_high))
>
> Oh, me likey. That's a much better idea than my crazy syntax.
Mark B. will accuse you of abusing ?: :-)
I've just looked at a .i file.
GENMASK() currently expands to 855 chars plus four copies of each argument.
Both FIELD_PREP/GET(GENMASK(), v) are about 18k plus three copies of v.
FIELD_GET(mask,v) has 18 expansions of 'mask'.
HWEIHT32(GENMASK(15,0)) is about 30k - don't ask why anyone would do it.
They all look excessive.
David