Re: [PATCH 00/21] lib: add alternatives for GENMASK()

From: Linus Torvalds

Date: Wed Nov 26 2025 - 18:47:47 EST


On Wed, 26 Nov 2025 at 14:17, david laight <david.laight@xxxxxxxxxx> wrote:
>
> Mark B. will accuse you of abusing ?: :-)

Compared to '__is_constexpr()', this is child's play. Not *that* is
abusing the ternary op.

> I've just looked at a .i file.
> GENMASK() currently expands to 855 chars plus four copies of each argument.

Yeah, I don't love it. It's a horrid macro. But because of the odd
order of arguments, it needs all that crazy checking.

That said, I do think it could be simplified. Particularly if we just
make the rule be that GENMASK _has_ to take just constant values.

Right now, I think 99.9% of all users are constants, and we spend a
lot of effort on the 0.1% that isn't.

Linus