Re: [PATCH] linux/bits.h: Fix compilation error with GENMASK

From: Andrew Morton
Date: Thu May 20 2021 - 16:41:17 EST


On Tue, 11 May 2021 22:37:15 +0200 Rikard Falkeborn <rikard.falkeborn@xxxxxxxxx> wrote:

> --- a/include/linux/const.h
> +++ b/include/linux/const.h
> @@ -3,4 +3,12 @@
>
> #include <vdso/const.h>
>
> +/*
> + * This returns a constant expression while determining if an argument is
> + * a constant expression, most importantly without evaluating the argument.
> + * Glory to Martin Uecker <Martin.Uecker@xxxxxxxxxxxxxxxxxxxxx>
> + */
> +#define __is_constexpr(x) \
> + (sizeof(int) == sizeof(*(8 ? ((void *)((long)(x) * 0l)) : (int *)8)))

Boggle.

Could someone please sometime enhance that comment a bit? What need
does this thing satisfy and how on earth does it work?