From edd429c9cc2af99df9dda10002cc59011edf0cac Mon Sep 17 00:00:00 2001 From: Julien Grall Date: Fri, 22 Apr 2016 16:58:32 +0100 Subject: [PATCH] xen/bitops: Introduce GENMASK to generate mask The code has been imported from the header include/linux/bitops.h in Linux v4.6-rc3. Signed-off-by: Julien Grall Acked-by: Stefano Stabellini --- xen/include/xen/bitops.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/xen/include/xen/bitops.h b/xen/include/xen/bitops.h index cb56f247ab..bd0883ab22 100644 --- a/xen/include/xen/bitops.h +++ b/xen/include/xen/bitops.h @@ -2,6 +2,14 @@ #define _LINUX_BITOPS_H #include +/* + * Create a contiguous bitmask starting at bit position @l and ending at + * position @h. For example + * GENMASK(30, 21) gives us the 32bit vector 0x01fe00000. + */ +#define GENMASK(h, l) \ + (((~0UL) << (l)) & (~0UL >> (BITS_PER_LONG - 1 - (h)))) + /* * ffs: find first bit set. This is defined the same way as * the libc and compiler builtin ffs routines, therefore -- 2.39.5