summaryrefslogtreecommitdiff
path: root/src/sim/byteswap.hh
diff options
context:
space:
mode:
Diffstat (limited to 'src/sim/byteswap.hh')
-rw-r--r--src/sim/byteswap.hh14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/sim/byteswap.hh b/src/sim/byteswap.hh
index 2c3517f24..a46f8f591 100644
--- a/src/sim/byteswap.hh
+++ b/src/sim/byteswap.hh
@@ -154,6 +154,20 @@ template <typename T> inline T betoh(T value) {return swap_byte(value);}
#error Invalid Endianess
#endif
+template <typename T>
+inline T htog(T value, ByteOrder guest_byte_order)
+{
+ return guest_byte_order == BigEndianByteOrder ?
+ htobe(value) : htole(value);
+}
+
+template <typename T>
+inline T gtoh(T value, ByteOrder guest_byte_order)
+{
+ return guest_byte_order == BigEndianByteOrder ?
+ betoh(value) : letoh(value);
+}
+
namespace BigEndianGuest
{
const ByteOrder GuestByteOrder = BigEndianByteOrder;