From 6cdb7b5a9414b175238f44ed8d6d71e455850b32 Mon Sep 17 00:00:00 2001 From: HarryLeeIBM Date: Fri, 14 Oct 2022 07:16:18 -0700 Subject: [PATCH] Fix Codec T64 on s390x --- src/Compression/CompressionCodecT64.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/Compression/CompressionCodecT64.cpp b/src/Compression/CompressionCodecT64.cpp index 9ed37c2d676..887c8b9e9d2 100644 --- a/src/Compression/CompressionCodecT64.cpp +++ b/src/Compression/CompressionCodecT64.cpp @@ -307,7 +307,19 @@ void reverseTransposeBytes(const UInt64 * matrix, UInt32 col, T & value) template void load(const char * src, T * buf, UInt32 tail = 64) { - memcpy(buf, src, tail * sizeof(T)); + if constexpr (std::endian::native == std::endian::little) + { + memcpy(buf, src, tail * sizeof(T)); + } + else + { + /// Since the algorithm uses little-endian integers, data is loaded + /// as little-endian types on big-endian machine(s390x, etc.) + for (UInt32 i = 0; i < tail; i++) + { + buf[i] = unalignedLoadLE(src + i * sizeof(T)); + } + } } template