1 #ifndef PROTOZERO_BYTESWAP_HPP 2 #define PROTOZERO_BYTESWAP_HPP 31 inline void byteswap(
const char* ,
char* ) noexcept {
32 static_assert(N == 1,
"Can only swap 4 or 8 byte values");
39 inline void byteswap<4>(
const char* data,
char* result) noexcept {
40 #ifdef PROTOZERO_USE_BUILTIN_BSWAP 41 *
reinterpret_cast<uint32_t*
>(result) = __builtin_bswap32(*reinterpret_cast<const uint32_t*>(data));
54 inline void byteswap<8>(
const char* data,
char* result) noexcept {
55 #ifdef PROTOZERO_USE_BUILTIN_BSWAP 56 *
reinterpret_cast<uint64_t*
>(result) = __builtin_bswap64(*reinterpret_cast<const uint64_t*>(data));
71 #endif // PROTOZERO_BYTESWAP_HPP void byteswap(const char *, char *) noexcept
Definition: byteswap.hpp:31
Contains macro checks for different configurations.
void byteswap< 8 >(const char *data, char *result) noexcept
Definition: byteswap.hpp:54
void byteswap< 4 >(const char *data, char *result) noexcept
Definition: byteswap.hpp:39
All parts of the protozero header-only library are in this namespace.
Definition: byteswap.hpp:24