[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <0306bec0ec270b01b09441da3200252396abed27.camel@perches.com>
Date: Sun, 28 Jul 2019 16:45:22 -0700
From: Joe Perches <joe@...ches.com>
To: Rikard Falkeborn <rikard.falkeborn@...il.com>,
Andrew Morton <akpm@...ux-foundation.org>
Cc: johannes@...solutions.net, linux-kernel@...r.kernel.org
Subject: Re: [PATCH 00/12] treewide: Fix GENMASK misuses
On Sat, 2019-07-27 at 21:54 +0200, Rikard Falkeborn wrote:
> Trimming CC-list.
>
> > It'd can't be done as it's used in declarations
> > and included in asm files and it uses the UL()
> > macro.
>
> Can the BUILD_BUG_ON_ZERO() macro be used instead? It works in
> declarations. I don't know if it works in asm-files, but the below
> changes builds an x86-64 allyesconfig without problems (after the rest
> of this series have been applied.
Maybe, fine by me if it works.
Perhaps you should submit this and let the build-bot
verify it.
> /Rikard
>
> ---
> include/linux/bits.h | 9 +++++++--
> 1 file changed, 7 insertions(+), 2 deletions(-)
>
> diff --git a/include/linux/bits.h b/include/linux/bits.h
> index 669d69441a62..52e747d27f87 100644
> --- a/include/linux/bits.h
> +++ b/include/linux/bits.h
> @@ -2,6 +2,7 @@
> #ifndef __LINUX_BITS_H
> #define __LINUX_BITS_H
>
> +#include <linux/build_bug.h>
> #include <linux/const.h>
> #include <asm/bitsperlong.h>
>
> @@ -19,11 +20,15 @@
> * GENMASK_ULL(39, 21) gives us the 64bit vector 0x000000ffffe00000.
> */
> #define GENMASK(h, l) \
> + (BUILD_BUG_ON_ZERO(__builtin_choose_expr( \
> + __is_constexpr(h) && __is_constexpr(l), (l) > (h), 0)) + \
> (((~UL(0)) - (UL(1) << (l)) + 1) & \
> - (~UL(0) >> (BITS_PER_LONG - 1 - (h))))
> + (~UL(0) >> (BITS_PER_LONG - 1 - (h)))))
>
> #define GENMASK_ULL(h, l) \
> + (BUILD_BUG_ON_ZERO(__builtin_choose_expr( \
> + __is_constexpr(h) && __is_constexpr(l), (l) > (h), 0)) + \
> (((~ULL(0)) - (ULL(1) << (l)) + 1) & \
> - (~ULL(0) >> (BITS_PER_LONG_LONG - 1 - (h))))
> + (~ULL(0) >> (BITS_PER_LONG_LONG - 1 - (h)))))
>
> #endif /* __LINUX_BITS_H */
Powered by blists - more mailing lists