From 07e7626e5692ae6bb5773ddb5493ba838debca86 Mon Sep 17 00:00:00 2001 From: Gianluca Guida Date: Thu, 25 May 2023 13:19:47 +0100 Subject: [PATCH] fesvr: support int128_t/uint128_t Also remove now duplicate definition for types. --- fesvr/byteorder.h | 7 +++++++ riscv/decode_macros.h | 5 ----- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/fesvr/byteorder.h b/fesvr/byteorder.h index 2b1dbf98..d9e503a2 100644 --- a/fesvr/byteorder.h +++ b/fesvr/byteorder.h @@ -15,6 +15,13 @@ static inline int16_t swap(int16_t n) { return int16_t(swap(uint16_t(n))); } static inline int32_t swap(int32_t n) { return int32_t(swap(uint32_t(n))); } static inline int64_t swap(int64_t n) { return int64_t(swap(uint64_t(n))); } +#ifdef HAVE_INT128 +typedef __int128 int128_t; +typedef unsigned __int128 uint128_t; +static inline uint128_t swap(uint128_t n) { return (uint128_t(swap(uint64_t(n))) << 64) | swap(uint64_t(n >> 64)); } +static inline int128_t swap(int128_t n) { return int128_t(swap(uint128_t(n))); } +#endif + #ifdef WORDS_BIGENDIAN template static inline T from_be(T n) { return n; } template static inline T to_be(T n) { return n; } diff --git a/riscv/decode_macros.h b/riscv/decode_macros.h index 7ba132c1..f39149b1 100644 --- a/riscv/decode_macros.h +++ b/riscv/decode_macros.h @@ -10,11 +10,6 @@ #include "softfloat_types.h" #include "specialize.h" -#ifdef HAVE_INT128 -typedef __int128 int128_t; -typedef unsigned __int128 uint128_t; -#endif - // helpful macros, etc #define MMU (*p->get_mmu()) #define STATE (*p->get_state())