aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Maydell <peter.maydell@linaro.org>2021-06-07 17:31:04 +0100
committerPeter Maydell <peter.maydell@linaro.org>2021-06-07 17:31:24 +0100
commitb78fc314eb2105411aaaced3ec82d199ec02cd9f (patch)
tree5bc1e2e9aa9bb8ec5c8b71c0854946f344a9b409
parentcbb27125fc328ebeacb6fe3df82e6e6ea1c2fa81 (diff)
include/qemu/int128.h: Add function to create Int128 from int64_t
int128_make64() creates an Int128 from an unsigned 64 bit value; add a function int128_makes64() creating an Int128 from a signed 64 bit value. Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
-rw-r--r--include/qemu/int128.h10
1 files changed, 10 insertions, 0 deletions
diff --git a/include/qemu/int128.h b/include/qemu/int128.h
index 52fc238421..64500385e3 100644
--- a/include/qemu/int128.h
+++ b/include/qemu/int128.h
@@ -11,6 +11,11 @@ static inline Int128 int128_make64(uint64_t a)
return a;
}
+static inline Int128 int128_makes64(int64_t a)
+{
+ return a;
+}
+
static inline Int128 int128_make128(uint64_t lo, uint64_t hi)
{
return (__uint128_t)hi << 64 | lo;
@@ -167,6 +172,11 @@ static inline Int128 int128_make64(uint64_t a)
return (Int128) { a, 0 };
}
+static inline Int128 int128_makes64(int64_t a)
+{
+ return (Int128) { a, a >> 63 };
+}
+
static inline Int128 int128_make128(uint64_t lo, uint64_t hi)
{
return (Int128) { lo, hi };