[PATCH/committed] sim: riscv: fix building on 32-bit hosts w/out int128

Message ID 20210501202716.29579-1-vapier@gentoo.org
State New
Headers show
Series
  • [PATCH/committed] sim: riscv: fix building on 32-bit hosts w/out int128
Related show

Commit Message

Wei-min Pan via Gdb-patches May 1, 2021, 8:27 p.m.
Check for __SIZEOF_INT128__ before trying to use the builtin type.
This fixes building on some 32-bit systems like x86.
---
 sim/riscv/ChangeLog  | 4 ++++
 sim/riscv/sim-main.c | 2 +-
 2 files changed, 5 insertions(+), 1 deletion(-)

-- 
2.31.1

Patch

diff --git a/sim/riscv/ChangeLog b/sim/riscv/ChangeLog
index 37284a982a9b..367faac9d4ed 100644
--- a/sim/riscv/ChangeLog
+++ b/sim/riscv/ChangeLog
@@ -1,3 +1,7 @@ 
+2021-05-01  Mike Frysinger  <vapier@gentoo.org>
+
+	* sim-main.c (mulhu): Check if __SIZEOF_INT128__ is defined.
+
 2021-04-26  Mike Frysinger  <vapier@gentoo.org>
 
 	* sim-main.c (MAX, MIN): Delete.
diff --git a/sim/riscv/sim-main.c b/sim/riscv/sim-main.c
index a80dc6838260..6a2904cced73 100644
--- a/sim/riscv/sim-main.c
+++ b/sim/riscv/sim-main.c
@@ -603,7 +603,7 @@  execute_i (SIM_CPU *cpu, unsigned_word iw, const struct riscv_opcode *op)
 static unsigned64
 mulhu (unsigned64 a, unsigned64 b)
 {
-#ifdef __GNUC__
+#if defined(__GNUC__) && defined(__SIZEOF_INT128__)
   return ((__int128)a * b) >> 64;
 #else
   uint64_t t;