diff mbox

[RFC,v5,07/14] bitops: Add ONES macro

Message ID 0b105b364007636c195003545bfd8748c27676b6.1430169159.git.peter.crosthwaite@xilinx.com
State New
Headers show

Commit Message

Peter Crosthwaite April 27, 2015, 9:58 p.m. UTC
Little macro that just gives you N ones (justified to LSB).

Signed-off-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
---

 include/qemu/bitops.h | 2 ++
 1 file changed, 2 insertions(+)
diff mbox

Patch

diff --git a/include/qemu/bitops.h b/include/qemu/bitops.h
index 90ca8df..30bad78 100644
--- a/include/qemu/bitops.h
+++ b/include/qemu/bitops.h
@@ -415,4 +415,6 @@  static inline uint64_t deposit64(uint64_t value, int start, int length,
     return (value & ~mask) | ((fieldval << start) & mask);
 }
 
+#define ONES(num) ((num) == 64 ? ~0ull : (1ull << (num)) - 1)
+
 #endif