Fix endian issue in transform function for s390x

This commit is contained in:
HarryLeeIBM 2023-01-23 11:54:35 -08:00
parent ee31da9e1e
commit 61f55ebb8a

View File

@ -853,7 +853,12 @@ private:
{
const auto * it = table.find(bit_cast<UInt64>(src[i]));
if (it)
memcpy(&dst[i], &it->getMapped(), sizeof(dst[i])); /// little endian.
{
if (std::endian::native == std::endian::little)
memcpy(&dst[i], &it->getMapped(), sizeof(dst[i]));
else
memcpy(&dst[i], reinterpret_cast<const char *>(&it->getMapped()) + sizeof(UInt64) - sizeof(dst[i]), sizeof(dst[i]));
}
else
dst[i] = dst_default;
}
@ -869,7 +874,12 @@ private:
{
const auto * it = table.find(bit_cast<UInt64>(src[i]));
if (it)
memcpy(&dst[i], &it->getMapped(), sizeof(dst[i])); /// little endian.
{
if (std::endian::native == std::endian::little)
memcpy(&dst[i], &it->getMapped(), sizeof(dst[i]));
else
memcpy(&dst[i], reinterpret_cast<const char *>(&it->getMapped()) + sizeof(UInt64) - sizeof(dst[i]), sizeof(dst[i]));
}
else if constexpr (is_decimal<U>)
dst[i] = static_cast<typename U::NativeType>(dst_default[i]);
else
@ -887,7 +897,12 @@ private:
{
const auto * it = table.find(bit_cast<UInt64>(src[i]));
if (it)
memcpy(&dst[i], &it->getMapped(), sizeof(dst[i]));
{
if (std::endian::native == std::endian::little)
memcpy(&dst[i], &it->getMapped(), sizeof(dst[i]));
else
memcpy(&dst[i], reinterpret_cast<const char *>(&it->getMapped()) + sizeof(UInt64) - sizeof(dst[i]), sizeof(dst[i]));
}
else
dst[i] = src[i];
}
@ -958,7 +973,12 @@ private:
current_src_offset = src_offsets[i];
const auto * it = table.find(ref);
if (it)
memcpy(&dst[i], &it->getMapped(), sizeof(dst[i]));
{
if (std::endian::native == std::endian::little)
memcpy(&dst[i], &it->getMapped(), sizeof(dst[i]));
else
memcpy(&dst[i], reinterpret_cast<const char *>(&it->getMapped()) + sizeof(UInt64) - sizeof(dst[i]), sizeof(dst[i]));
}
else
dst[i] = dst_default;
}
@ -979,7 +999,12 @@ private:
current_src_offset = src_offsets[i];
const auto * it = table.find(ref);
if (it)
memcpy(&dst[i], &it->getMapped(), sizeof(dst[i]));
{
if (std::endian::native == std::endian::little)
memcpy(&dst[i], &it->getMapped(), sizeof(dst[i]));
else
memcpy(&dst[i], reinterpret_cast<const char *>(&it->getMapped()) + sizeof(UInt64) - sizeof(dst[i]), sizeof(dst[i]));
}
else if constexpr (is_decimal<U>)
dst[i] = static_cast<typename U::NativeType>(dst_default[i]);
else