summaryrefslogtreecommitdiff
path: root/src/sim/byteswap.hh
diff options
context:
space:
mode:
authorGabe Black <gblack@eecs.umich.edu>2007-03-07 17:46:04 +0000
committerGabe Black <gblack@eecs.umich.edu>2007-03-07 17:46:04 +0000
commitb7ea19760ab96b70013cd0ce6f54ed6a89f0e1ca (patch)
tree53b4acf14af06c00a754db6d9e6e32e7c18c48b8 /src/sim/byteswap.hh
parentea7bdf9f60c404761dfc568d5291c75747a2dd88 (diff)
downloadgem5-b7ea19760ab96b70013cd0ce6f54ed6a89f0e1ca.tar.xz
Make byteswap work correctly on Twin??_t types.
--HG-- extra : convert_revision : a8a14078d62c24e480ffa69591edfc775d1d76cc
Diffstat (limited to 'src/sim/byteswap.hh')
-rw-r--r--src/sim/byteswap.hh19
1 files changed, 18 insertions, 1 deletions
diff --git a/src/sim/byteswap.hh b/src/sim/byteswap.hh
index cbc0b5088..062fc4513 100644
--- a/src/sim/byteswap.hh
+++ b/src/sim/byteswap.hh
@@ -37,6 +37,7 @@
#ifndef __SIM_BYTE_SWAP_HH__
#define __SIM_BYTE_SWAP_HH__
+#include "base/bigint.hh"
#include "base/misc.hh"
#include "sim/host.hh"
@@ -109,7 +110,7 @@ swap_byte16(uint16_t x)
// This function lets the compiler figure out how to call the
// swap_byte functions above for different data types. Since the
-// sizeof() values are known at compiel time, it should inline to a
+// sizeof() values are known at compile time, it should inline to a
// direct call to the right swap_byteNN() function.
template <typename T>
static inline T swap_byte(T x) {
@@ -125,6 +126,22 @@ static inline T swap_byte(T x) {
panic("Can't byte-swap values larger than 64 bits");
}
+template<>
+static inline Twin64_t swap_byte<Twin64_t>(Twin64_t x)
+{
+ x.a = swap_byte(x.a);
+ x.b = swap_byte(x.b);
+ return x;
+}
+
+template<>
+static inline Twin32_t swap_byte<Twin32_t>(Twin32_t x)
+{
+ x.a = swap_byte(x.a);
+ x.b = swap_byte(x.b);
+ return x;
+}
+
//The conversion functions with fixed endianness on both ends don't need to
//be in a namespace
template <typename T> static inline T betole(T value) {return swap_byte(value);}