#ifndef ABSL_BASE_INTERNAL_ENDIAN_H_
#define ABSL_BASE_INTERNAL_ENDIAN_H_
#include <cstdint>
#include <cstdlib>
#include "absl/base/casts.h"
#include "absl/base/config.h"
#include "absl/base/internal/unaligned_access.h"
#include "absl/base/nullability.h"
#include "absl/base/port.h"
namespace absl {
ABSL_NAMESPACE_BEGIN
inline uint64_t gbswap_64(uint64_t host_int) { … }
inline uint32_t gbswap_32(uint32_t host_int) { … }
inline uint16_t gbswap_16(uint16_t host_int) { … }
#ifdef ABSL_IS_LITTLE_ENDIAN
inline uint16_t ghtons(uint16_t x) { … }
inline uint32_t ghtonl(uint32_t x) { … }
inline uint64_t ghtonll(uint64_t x) { … }
#elif defined ABSL_IS_BIG_ENDIAN
inline uint16_t ghtons(uint16_t x) { return x; }
inline uint32_t ghtonl(uint32_t x) { return x; }
inline uint64_t ghtonll(uint64_t x) { return x; }
#else
#error \
"Unsupported byte order: Either ABSL_IS_BIG_ENDIAN or " \
"ABSL_IS_LITTLE_ENDIAN must be defined"
#endif
inline uint16_t gntohs(uint16_t x) { … }
inline uint32_t gntohl(uint32_t x) { … }
inline uint64_t gntohll(uint64_t x) { … }
namespace little_endian {
#ifdef ABSL_IS_LITTLE_ENDIAN
inline uint16_t FromHost16(uint16_t x) { … }
inline uint16_t ToHost16(uint16_t x) { … }
inline uint32_t FromHost32(uint32_t x) { … }
inline uint32_t ToHost32(uint32_t x) { … }
inline uint64_t FromHost64(uint64_t x) { … }
inline uint64_t ToHost64(uint64_t x) { … }
inline constexpr bool IsLittleEndian() { … }
#elif defined ABSL_IS_BIG_ENDIAN
inline uint16_t FromHost16(uint16_t x) { return gbswap_16(x); }
inline uint16_t ToHost16(uint16_t x) { return gbswap_16(x); }
inline uint32_t FromHost32(uint32_t x) { return gbswap_32(x); }
inline uint32_t ToHost32(uint32_t x) { return gbswap_32(x); }
inline uint64_t FromHost64(uint64_t x) { return gbswap_64(x); }
inline uint64_t ToHost64(uint64_t x) { return gbswap_64(x); }
inline constexpr bool IsLittleEndian() { return false; }
#endif
inline uint8_t FromHost(uint8_t x) { … }
inline uint16_t FromHost(uint16_t x) { … }
inline uint32_t FromHost(uint32_t x) { … }
inline uint64_t FromHost(uint64_t x) { … }
inline uint8_t ToHost(uint8_t x) { … }
inline uint16_t ToHost(uint16_t x) { … }
inline uint32_t ToHost(uint32_t x) { … }
inline uint64_t ToHost(uint64_t x) { … }
inline int8_t FromHost(int8_t x) { … }
inline int16_t FromHost(int16_t x) { … }
inline int32_t FromHost(int32_t x) { … }
inline int64_t FromHost(int64_t x) { … }
inline int8_t ToHost(int8_t x) { … }
inline int16_t ToHost(int16_t x) { … }
inline int32_t ToHost(int32_t x) { … }
inline int64_t ToHost(int64_t x) { … }
inline uint16_t Load16(absl::Nonnull<const void *> p) { … }
inline void Store16(absl::Nonnull<void *> p, uint16_t v) { … }
inline uint32_t Load32(absl::Nonnull<const void *> p) { … }
inline void Store32(absl::Nonnull<void *> p, uint32_t v) { … }
inline uint64_t Load64(absl::Nonnull<const void *> p) { … }
inline void Store64(absl::Nonnull<void *> p, uint64_t v) { … }
}
namespace big_endian {
#ifdef ABSL_IS_LITTLE_ENDIAN
inline uint16_t FromHost16(uint16_t x) { … }
inline uint16_t ToHost16(uint16_t x) { … }
inline uint32_t FromHost32(uint32_t x) { … }
inline uint32_t ToHost32(uint32_t x) { … }
inline uint64_t FromHost64(uint64_t x) { … }
inline uint64_t ToHost64(uint64_t x) { … }
inline constexpr bool IsLittleEndian() { … }
#elif defined ABSL_IS_BIG_ENDIAN
inline uint16_t FromHost16(uint16_t x) { return x; }
inline uint16_t ToHost16(uint16_t x) { return x; }
inline uint32_t FromHost32(uint32_t x) { return x; }
inline uint32_t ToHost32(uint32_t x) { return x; }
inline uint64_t FromHost64(uint64_t x) { return x; }
inline uint64_t ToHost64(uint64_t x) { return x; }
inline constexpr bool IsLittleEndian() { return false; }
#endif
inline uint8_t FromHost(uint8_t x) { … }
inline uint16_t FromHost(uint16_t x) { … }
inline uint32_t FromHost(uint32_t x) { … }
inline uint64_t FromHost(uint64_t x) { … }
inline uint8_t ToHost(uint8_t x) { … }
inline uint16_t ToHost(uint16_t x) { … }
inline uint32_t ToHost(uint32_t x) { … }
inline uint64_t ToHost(uint64_t x) { … }
inline int8_t FromHost(int8_t x) { … }
inline int16_t FromHost(int16_t x) { … }
inline int32_t FromHost(int32_t x) { … }
inline int64_t FromHost(int64_t x) { … }
inline int8_t ToHost(int8_t x) { … }
inline int16_t ToHost(int16_t x) { … }
inline int32_t ToHost(int32_t x) { … }
inline int64_t ToHost(int64_t x) { … }
inline uint16_t Load16(absl::Nonnull<const void *> p) { … }
inline void Store16(absl::Nonnull<void *> p, uint16_t v) { … }
inline uint32_t Load32(absl::Nonnull<const void *> p) { … }
inline void Store32(absl::Nonnull<void *>p, uint32_t v) { … }
inline uint64_t Load64(absl::Nonnull<const void *> p) { … }
inline void Store64(absl::Nonnull<void *> p, uint64_t v) { … }
}
ABSL_NAMESPACE_END
}
#endif