From fbb0645fb30140f33ff56cfbdc3f5ec5d8cfd6d5 Mon Sep 17 00:00:00 2001 From: Alistair Francis Date: Sun, 25 Feb 2018 00:30:30 -0500 Subject: [PATCH] bitops: Add MAKE_64BIT_MASK macro Add a macro that creates a 64bit value which has length number of ones shifted across by the value of shift. Backports commit ae2923b5c20a21c6457680330506a9c13873485c from qemu --- qemu/include/qemu/bitops.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/qemu/include/qemu/bitops.h b/qemu/include/qemu/bitops.h index 9f3995ec..c7587b0b 100644 --- a/qemu/include/qemu/bitops.h +++ b/qemu/include/qemu/bitops.h @@ -26,6 +26,9 @@ #define BIT_WORD(nr) ((nr) / BITS_PER_LONG) #define BITS_TO_LONGS(nr) DIV_ROUND_UP(nr, BITS_PER_BYTE * sizeof(long)) +#define MAKE_64BIT_MASK(shift, length) \ + (((~0ULL) >> (64 - (length))) << (shift)) + /** * set_bit - Set a bit in memory * @nr: the bit to set