aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--fesvr/byteorder.h7
-rw-r--r--riscv/decode_macros.h5
2 files changed, 7 insertions, 5 deletions
diff --git a/fesvr/byteorder.h b/fesvr/byteorder.h
index 2b1dbf9..d9e503a 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<typename T> static inline T from_be(T n) { return n; }
template<typename T> static inline T to_be(T n) { return n; }
diff --git a/riscv/decode_macros.h b/riscv/decode_macros.h
index 7ba132c..f39149b 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())