diff mbox

[v5,01/15] bitops: Add MAKE_64BIT_MASK macro

Message ID 912f91bdbccf665fddd51b186027a3ae702d768a.1457470980.git.alistair.francis@xilinx.com (mailing list archive)
State New, archived
Headers show

Commit Message

Alistair Francis March 8, 2016, 9:06 p.m. UTC
Add a macro that creates a 64bit value which has length number of ones
shifted acrros by the value of shift.

Signed-off-by: Alistair Francis <alistair.francis@xilinx.com>
---
V5:
 - Re-write to a 64-bit mask instead of ONES()
 - Re-order this patch in the series

 include/qemu/bitops.h | 3 +++
 1 file changed, 3 insertions(+)

Comments

Alex Bennée March 22, 2016, 3:26 p.m. UTC | #1
Alistair Francis <alistair.francis@xilinx.com> writes:

> Add a macro that creates a 64bit value which has length number of ones
> shifted acrros by the value of shift.
>
> Signed-off-by: Alistair Francis <alistair.francis@xilinx.com>

Reviewed-by: Alex Bennée <alex.bennee@linaro.org>

> ---
> V5:
>  - Re-write to a 64-bit mask instead of ONES()
>  - Re-order this patch in the series
>
>  include/qemu/bitops.h | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/include/qemu/bitops.h b/include/qemu/bitops.h
> index 755fdd1..3c45791 100644
> --- a/include/qemu/bitops.h
> +++ b/include/qemu/bitops.h
> @@ -24,6 +24,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) \
> +    (((1ull << (length)) - 1) << shift)
> +
>  /**
>   * set_bit - Set a bit in memory
>   * @nr: the bit to set


--
Alex Bennée
diff mbox

Patch

diff --git a/include/qemu/bitops.h b/include/qemu/bitops.h
index 755fdd1..3c45791 100644
--- a/include/qemu/bitops.h
+++ b/include/qemu/bitops.h
@@ -24,6 +24,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) \
+    (((1ull << (length)) - 1) << shift)
+
 /**
  * set_bit - Set a bit in memory
  * @nr: the bit to set