summaryrefslogtreecommitdiffstats
path: root/include/qemu/host-utils.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/qemu/host-utils.h')
-rw-r--r--include/qemu/host-utils.h10
1 files changed, 9 insertions, 1 deletions
diff --git a/include/qemu/host-utils.h b/include/qemu/host-utils.h
index 711b221704..ca9f3f021b 100644
--- a/include/qemu/host-utils.h
+++ b/include/qemu/host-utils.h
@@ -70,7 +70,7 @@ static inline int divs128(int64_t *plow, int64_t *phigh, int64_t divisor)
if (divisor == 0) {
return 1;
} else {
- __int128_t dividend = ((__int128_t)*phigh << 64) | *plow;
+ __int128_t dividend = ((__int128_t)*phigh << 64) | (uint64_t)*plow;
__int128_t result = dividend / divisor;
*plow = result;
*phigh = dividend % divisor;
@@ -358,6 +358,14 @@ static inline uint64_t revbit64(uint64_t x)
}
/**
+ * Return the absolute value of a 64-bit integer as an unsigned 64-bit value
+ */
+static inline uint64_t uabs64(int64_t v)
+{
+ return v < 0 ? -v : v;
+}
+
+/**
* sadd32_overflow - addition with overflow indication
* @x, @y: addends
* @ret: Output for sum