Add missing specializations.
This commit is contained in:
parent
c92f132007
commit
979b1bf1cb
1 changed files with 44 additions and 0 deletions
|
@ -93,6 +93,28 @@ namespace dhandy {
|
|||
return static_cast<int64_t>(__builtin_bswap64(static_cast<uint64_t>(parV)));
|
||||
#else
|
||||
# error "Unsupported endianness"
|
||||
#endif
|
||||
}
|
||||
template <>
|
||||
[[gnu::pure]] inline constexpr long long int htobe (long long int parV) {
|
||||
static_assert(sizeof(long long int) == sizeof(uint64_t), "Size mismatch");
|
||||
#if __BYTE_ORDER == __BIG_ENDIAN
|
||||
return parV;
|
||||
#elif __BYTE_ORDER == __LITTLE_ENDIAN
|
||||
return static_cast<long long int>(__builtin_bswap64(static_cast<uint64_t>(parV)));
|
||||
#else
|
||||
# error "Unsupported endianness"
|
||||
#endif
|
||||
}
|
||||
template <>
|
||||
[[gnu::pure]] inline constexpr unsigned long long int htobe (unsigned long long int parV) {
|
||||
static_assert(sizeof(unsigned long long int) == sizeof(uint64_t), "Size mismatch");
|
||||
#if __BYTE_ORDER == __BIG_ENDIAN
|
||||
return parV;
|
||||
#elif __BYTE_ORDER == __LITTLE_ENDIAN
|
||||
return static_cast<unsigned long long int>(__builtin_bswap64(static_cast<uint64_t>(parV)));
|
||||
#else
|
||||
# error "Unsupported endianness"
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -162,6 +184,28 @@ namespace dhandy {
|
|||
return parV;
|
||||
#else
|
||||
# error "Unsupported endianness"
|
||||
#endif
|
||||
}
|
||||
template <>
|
||||
[[gnu::pure]] inline constexpr long long int htole (long long int parV) {
|
||||
static_assert(sizeof(long long int) == sizeof(uint64_t), "Size mismatch");
|
||||
#if __BYTE_ORDER == __BIG_ENDIAN
|
||||
return static_cast<long long int>(__builtin_bswap64(static_cast<uint64_t>(parV)));
|
||||
#elif __BYTE_ORDER == __LITTLE_ENDIAN
|
||||
return parV;
|
||||
#else
|
||||
# error "Unsupported endianness"
|
||||
#endif
|
||||
}
|
||||
template <>
|
||||
[[gnu::pure]] inline constexpr unsigned long long int htole (unsigned long long int parV) {
|
||||
static_assert(sizeof(unsigned long long int) == sizeof(uint64_t), "Size mismatch");
|
||||
#if __BYTE_ORDER == __BIG_ENDIAN
|
||||
return static_cast<unsigned long long int>(__builtin_bswap64(static_cast<uint64_t>(parV)));
|
||||
#elif __BYTE_ORDER == __LITTLE_ENDIAN
|
||||
return parV;
|
||||
#else
|
||||
# error "Unsupported endianness"
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue