lkml.org 
[lkml]   [2019]   [Jul]   [28]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH 00/12] treewide: Fix GENMASK misuses
From
Date
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 */

\
 
 \ /
  Last update: 2019-07-29 01:47    [W:0.265 / U:0.712 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site