summaryrefslogtreecommitdiff
path: root/src/base/bitfield.hh
diff options
context:
space:
mode:
Diffstat (limited to 'src/base/bitfield.hh')
-rw-r--r--src/base/bitfield.hh12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/base/bitfield.hh b/src/base/bitfield.hh
index 177279678..1fc0bad5d 100644
--- a/src/base/bitfield.hh
+++ b/src/base/bitfield.hh
@@ -58,6 +58,18 @@ bits(T val, int first, int last)
}
/**
+ * Mask off the given bits in place like bits() but without shifting.
+ * msb = 63, lsb = 0
+ */
+template <class T>
+inline
+T
+mbits(T val, int first, int last)
+{
+ return val & (mask(first+1) & ~mask(last));
+}
+
+/**
* Sign-extend an N-bit value to 64 bits.
*/
template <int N>