summaryrefslogtreecommitdiffstats
path: root/include/qemu/int128.h
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2013-05-27 10:08:27 +0200
committerPaolo Bonzini <pbonzini@redhat.com>2013-06-20 16:32:47 +0200
commit052e87b073cb70afcd767d32f45af2794a5a65de (patch)
treeef25073c63f9c7e2be0e2ddee46ce1524811becd /include/qemu/int128.h
parent733d5ef52721a836b1d9b5cd0f15a41db88829d0 (diff)
downloadhqemu-052e87b073cb70afcd767d32f45af2794a5a65de.zip
hqemu-052e87b073cb70afcd767d32f45af2794a5a65de.tar.gz
memory: make section size a 128-bit integer
So far, the size of all regions passed to listeners could fit in 64 bits, because artificial regions (containers and aliases) are eliminated by the memory core, leaving only device regions which have reasonable sizes An IOMMU however cannot be eliminated by the memory core, and may have an artificial size, hence we may need 65 bits to represent its size. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'include/qemu/int128.h')
-rw-r--r--include/qemu/int128.h19
1 files changed, 19 insertions, 0 deletions
diff --git a/include/qemu/int128.h b/include/qemu/int128.h
index b3864b6..bfe7678 100644
--- a/include/qemu/int128.h
+++ b/include/qemu/int128.h
@@ -34,6 +34,25 @@ static inline Int128 int128_2_64(void)
return (Int128) { 0, 1 };
}
+static inline Int128 int128_and(Int128 a, Int128 b)
+{
+ return (Int128) { a.lo & b.lo, a.hi & b.hi };
+}
+
+static inline Int128 int128_rshift(Int128 a, int n)
+{
+ int64_t h;
+ if (!n) {
+ return a;
+ }
+ h = a.hi >> (n & 63);
+ if (n >= 64) {
+ return (Int128) { h, h >> 63 };
+ } else {
+ return (Int128) { (a.lo >> n) | (a.hi << (64 - n)), h };
+ }
+}
+
static inline Int128 int128_add(Int128 a, Int128 b)
{
Int128 r = { a.lo + b.lo, a.hi + b.hi };
OpenPOWER on IntegriCloud