Merge pull request #50365 from HarryLeeIBM/hlee-s390x-crc32

Fix CRC32(WeakHash) issue for s390x
This commit is contained in:
robot-ch-test-poll1 2023-07-14 19:00:01 +02:00 committed by GitHub
commit 186669a04a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -57,28 +57,25 @@ inline DB::UInt64 intHash64(DB::UInt64 x)
inline uint32_t s390x_crc32_u8(uint32_t crc, uint8_t v)
{
return crc32_be(crc, reinterpret_cast<unsigned char *>(&v), sizeof(v));
return crc32c_le_vx(crc, reinterpret_cast<unsigned char *>(&v), sizeof(v));
}
inline uint32_t s390x_crc32_u16(uint32_t crc, uint16_t v)
{
return crc32_be(crc, reinterpret_cast<unsigned char *>(&v), sizeof(v));
v = std::byteswap(v);
return crc32c_le_vx(crc, reinterpret_cast<unsigned char *>(&v), sizeof(v));
}
inline uint32_t s390x_crc32_u32(uint32_t crc, uint32_t v)
{
return crc32_be(crc, reinterpret_cast<unsigned char *>(&v), sizeof(v));
v = std::byteswap(v);
return crc32c_le_vx(crc, reinterpret_cast<unsigned char *>(&v), sizeof(v));
}
inline uint64_t s390x_crc32(uint64_t crc, uint64_t v)
{
uint64_t _crc = crc;
uint32_t value_h, value_l;
value_h = (v >> 32) & 0xffffffff;
value_l = v & 0xffffffff;
_crc = crc32_be(static_cast<uint32_t>(_crc), reinterpret_cast<unsigned char *>(&value_h), sizeof(uint32_t));
_crc = crc32_be(static_cast<uint32_t>(_crc), reinterpret_cast<unsigned char *>(&value_l), sizeof(uint32_t));
return _crc;
v = std::byteswap(v);
return crc32c_le_vx(static_cast<uint32_t>(crc), reinterpret_cast<unsigned char *>(&v), sizeof(uint64_t));
}
#endif