From a8f82f545abd27657e19a91dd6b9675a576b116b Mon Sep 17 00:00:00 2001 From: Gabe Black Date: Tue, 12 Dec 2017 17:49:35 -0800 Subject: 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 Reviewed-by: Jason Lowe-Power Maintainer: Andreas Sandberg --- src/sim/byteswap.hh | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/sim') 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 x) return x; } +template +inline std::array +swap_byte(std::array 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 inline T betole(T value) {return swap_byte(value);} -- cgit v1.2.3