Patchwork [v3,1/5] bitops: Add ONES macro

login
register
mail settings
Submitter Peter Crosthwaite
Date May 24, 2013, 5:46 a.m.
Message ID <280e55238ebc26cbce538493f451500fe1998d94.1369374096.git.peter.crosthwaite@xilinx.com>
Download mbox | patch
Permalink /patch/246074/
State New
Headers show

Comments

Peter Crosthwaite - May 24, 2013, 5:46 a.m.
From: Peter Crosthwaite <peter.crosthwaite@xilinx.com>

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(+)

Patch

diff --git a/include/qemu/bitops.h b/include/qemu/bitops.h
index affcc96..da47fc8 100644
--- a/include/qemu/bitops.h
+++ b/include/qemu/bitops.h
@@ -273,4 +273,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