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
This commit is contained in:
Alistair Francis 2018-02-25 00:30:30 -05:00 committed by Lioncash
parent efc6cc2b83
commit fbb0645fb3
No known key found for this signature in database
GPG key ID: 4E3C3CC1031BA9C7

View file

@ -26,6 +26,9 @@
#define BIT_WORD(nr) ((nr) / BITS_PER_LONG) #define BIT_WORD(nr) ((nr) / BITS_PER_LONG)
#define BITS_TO_LONGS(nr) DIV_ROUND_UP(nr, BITS_PER_BYTE * sizeof(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 * set_bit - Set a bit in memory
* @nr: the bit to set * @nr: the bit to set