diff mbox

[v4,1/6] bitops: Add ONES macro

Message ID 15df2dad3642550b1e41604aa5f8284dc5dfb83b.1397024123.git.peter.crosthwaite@xilinx.com
State New
Headers show

Commit Message

Peter Crosthwaite April 9, 2014, 7:15 a.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 340b1e7..b9fd60f 100644
--- a/include/qemu/bitops.h
+++ b/include/qemu/bitops.h
@@ -403,4 +403,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