mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-27 10:02:01 +00:00
update format
This commit is contained in:
parent
6ae4843b6d
commit
97d76771a4
@ -146,7 +146,7 @@ void formatIPv6(const unsigned char * src, char *& dst, uint8_t zeroed_tail_byte
|
||||
uint8_t ipv4_buffer[IPV4_BINARY_LENGTH] = {0};
|
||||
memcpy(ipv4_buffer, src + 12, IPV4_BINARY_LENGTH);
|
||||
// Due to historical reasons formatIPv4() takes ipv4 in BE format, but inside ipv6 we store it in LE-format.
|
||||
if (std::endian::native == std::endian::little)
|
||||
if constexpr (std::endian::native == std::endian::little)
|
||||
std::reverse(std::begin(ipv4_buffer), std::end(ipv4_buffer));
|
||||
|
||||
formatIPv4(ipv4_buffer, dst, std::min(zeroed_tail_bytes_count, static_cast<uint8_t>(IPV4_BINARY_LENGTH)), "0");
|
||||
|
@ -136,7 +136,7 @@ inline bool parseIPv6(const char * src, unsigned char * dst)
|
||||
if (!parseIPv4(curtok, tp))
|
||||
return clear_dst();
|
||||
|
||||
if (std::endian::native == std::endian::little)
|
||||
if constexpr (std::endian::native == std::endian::little)
|
||||
std::reverse(tp, tp + IPV4_BINARY_LENGTH);
|
||||
|
||||
tp += IPV4_BINARY_LENGTH;
|
||||
@ -207,7 +207,7 @@ inline void formatIPv4(const unsigned char * src, char *& dst, uint8_t mask_tail
|
||||
for (size_t octet = 0; octet < limit; ++octet)
|
||||
{
|
||||
uint8_t value = 0;
|
||||
if (std::endian::native == std::endian::little)
|
||||
if constexpr (std::endian::native == std::endian::little)
|
||||
value = static_cast<uint8_t>(src[IPV4_BINARY_LENGTH - octet - 1]);
|
||||
else
|
||||
value = static_cast<uint8_t>(src[octet]);
|
||||
|
@ -514,14 +514,11 @@ private:
|
||||
static void mapIPv4ToIPv6(UInt32 in, UInt8 * buf)
|
||||
{
|
||||
unalignedStore<UInt64>(buf, 0);
|
||||
if (std::endian::native == std::endian::little)
|
||||
{
|
||||
#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
|
||||
unalignedStoreLE<UInt64>(buf + 8, 0x00000000FFFF0000ull | (static_cast<UInt64>(ntohl(in)) << 32));
|
||||
}
|
||||
else
|
||||
{
|
||||
#else
|
||||
unalignedStoreLE<UInt64>(buf + 8, 0x00000000FFFF0000ull | (static_cast<UInt64>(__builtin_bswap32(ntohl(in))) << 32));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user