From: Gabe Black Date: Wed, 13 Dec 2017 01:49:35 +0000 (-0800) Subject: base: Add endianness conversion functions for std::array types. X-Git-Tag: v19.0.0.0~2436 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=a8f82f545abd27657e19a91dd6b9675a576b116b;p=gem5.git 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 --- 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);}