// these functions and make the users do their own byte swapping since
// the memory system does not in fact have an endianness.
-template<>
-inline Twin64_t
-Packet::get()
-{
- Twin64_t d;
- assert(staticData || dynamicData);
- assert(sizeof(Twin64_t) <= size);
- d.a = TheISA::gtoh(*(uint64_t*)data);
- d.b = TheISA::gtoh(*((uint64_t*)data + 1));
- return d;
-}
-
-template<>
-inline Twin32_t
-Packet::get()
-{
- Twin32_t d;
- assert(staticData || dynamicData);
- assert(sizeof(Twin32_t) <= size);
- d.a = TheISA::gtoh(*(uint32_t*)data);
- d.b = TheISA::gtoh(*((uint32_t*)data + 1));
- return d;
-}
-
-
/** return the value of what is pointed to in the packet. */
template <typename T>
inline T
#ifndef __SIM_BYTE_SWAP_HH__
#define __SIM_BYTE_SWAP_HH__
+#include "base/bigint.hh"
#include "base/misc.hh"
#include "sim/host.hh"
// 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) {
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);}