summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGabe Black <gabeblack@google.com>2017-12-12 17:49:35 -0800
committerGabe Black <gabeblack@google.com>2017-12-13 19:12:23 +0000
commita8f82f545abd27657e19a91dd6b9675a576b116b (patch)
tree02f5422bfaa98f0b17be7af3eb7c427f14ee0b88
parent5a4b143c2d53ee4eb0ff881278e35a35493b9de1 (diff)
downloadgem5-a8f82f545abd27657e19a91dd6b9675a576b116b.tar.xz
base: Add endianness conversion functions for std::array types.
These swap the endianness of each element within the array individually. They probably obsolute the Twin(32|64)_t types which I believe were used for SPARC. Change-Id: Ic389eb24bdcdc0081068b0c5a37abdf416f6c924 Reviewed-on: https://gem5-review.googlesource.com/6581 Reviewed-by: Andreas Sandberg <andreas.sandberg@arm.com> Reviewed-by: Jason Lowe-Power <jason@lowepower.com> Maintainer: Andreas Sandberg <andreas.sandberg@arm.com>
-rw-r--r--src/sim/byteswap.hh9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/sim/byteswap.hh b/src/sim/byteswap.hh
index 23786bb71..02a053308 100644
--- a/src/sim/byteswap.hh
+++ b/src/sim/byteswap.hh
@@ -139,6 +139,15 @@ inline Twin32_t swap_byte<Twin32_t>(Twin32_t x)
return x;
}
+template <typename T, size_t N>
+inline std::array<T, N>
+swap_byte(std::array<T, N> a)
+{
+ for (T &v: a)
+ v = swap_byte(v);
+ return a;
+}
+
//The conversion functions with fixed endianness on both ends don't need to
//be in a namespace
template <typename T> inline T betole(T value) {return swap_byte(value);}