#ifndef LLVM_SUPPORT_ENDIAN_H
#define LLVM_SUPPORT_ENDIAN_H
#include "llvm/ADT/bit.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Support/SwapByteOrder.h"
#include <cassert>
#include <cstddef>
#include <cstdint>
#include <cstring>
#include <type_traits>
namespace llvm {
namespace support {
enum { … };
namespace detail {
template<class T, int alignment>
struct PickAlignment { … };
}
namespace endian {
template <typename value_type>
[[nodiscard]] inline value_type byte_swap(value_type value, endianness endian) { … }
template <typename value_type, endianness endian>
[[nodiscard]] inline value_type byte_swap(value_type value) { … }
template <typename value_type, std::size_t alignment = unaligned>
[[nodiscard]] inline value_type read(const void *memory, endianness endian) { … }
template <typename value_type, endianness endian, std::size_t alignment>
[[nodiscard]] inline value_type read(const void *memory) { … }
template <typename value_type, std::size_t alignment = unaligned,
typename CharT>
[[nodiscard]] inline value_type readNext(const CharT *&memory,
endianness endian) { … }
template <typename value_type, endianness endian,
std::size_t alignment = unaligned, typename CharT>
[[nodiscard]] inline value_type readNext(const CharT *&memory) { … }
template <typename value_type, std::size_t alignment = unaligned>
inline void write(void *memory, value_type value, endianness endian) { … }
template<typename value_type,
endianness endian,
std::size_t alignment>
inline void write(void *memory, value_type value) { … }
template <typename value_type, std::size_t alignment = unaligned,
typename CharT>
inline void writeNext(CharT *&memory, value_type value, endianness endian) { … }
template <typename value_type, endianness endian,
std::size_t alignment = unaligned, typename CharT>
inline void writeNext(CharT *&memory, value_type value) { … }
make_unsigned_t;
template <typename value_type, endianness endian, std::size_t alignment>
[[nodiscard]] inline value_type readAtBitAlignment(const void *memory,
uint64_t startBit) { … }
template <typename value_type, endianness endian, std::size_t alignment>
inline void writeAtBitAlignment(void *memory, value_type value,
uint64_t startBit) { … }
}
namespace detail {
template <typename ValueType, endianness Endian, std::size_t Alignment,
std::size_t ALIGN = PickAlignment<ValueType, Alignment>::value>
struct packed_endian_specific_integral { … };
}
ulittle16_t;
ulittle32_t;
ulittle64_t;
little16_t;
little32_t;
little64_t;
aligned_ulittle16_t;
aligned_ulittle32_t;
aligned_ulittle64_t;
aligned_little16_t;
aligned_little32_t;
aligned_little64_t;
ubig16_t;
ubig32_t;
ubig64_t;
big16_t;
big32_t;
big64_t;
aligned_ubig16_t;
aligned_ubig32_t;
aligned_ubig64_t;
aligned_big16_t;
aligned_big32_t;
aligned_big64_t;
unaligned_uint16_t;
unaligned_uint32_t;
unaligned_uint64_t;
unaligned_int16_t;
unaligned_int32_t;
unaligned_int64_t;
little_t;
big_t;
aligned_little_t;
aligned_big_t;
namespace endian {
template <typename T, endianness E> [[nodiscard]] inline T read(const void *P) { … }
[[nodiscard]] inline uint16_t read16(const void *P, endianness E) { … }
[[nodiscard]] inline uint32_t read32(const void *P, endianness E) { … }
[[nodiscard]] inline uint64_t read64(const void *P, endianness E) { … }
template <endianness E> [[nodiscard]] inline uint16_t read16(const void *P) { … }
template <endianness E> [[nodiscard]] inline uint32_t read32(const void *P) { … }
template <endianness E> [[nodiscard]] inline uint64_t read64(const void *P) { … }
[[nodiscard]] inline uint16_t read16le(const void *P) { … }
[[nodiscard]] inline uint32_t read32le(const void *P) { … }
[[nodiscard]] inline uint64_t read64le(const void *P) { … }
[[nodiscard]] inline uint16_t read16be(const void *P) { … }
[[nodiscard]] inline uint32_t read32be(const void *P) { … }
[[nodiscard]] inline uint64_t read64be(const void *P) { … }
template <typename T, endianness E> inline void write(void *P, T V) { … }
inline void write16(void *P, uint16_t V, endianness E) { … }
inline void write32(void *P, uint32_t V, endianness E) { … }
inline void write64(void *P, uint64_t V, endianness E) { … }
template <endianness E> inline void write16(void *P, uint16_t V) { … }
template <endianness E> inline void write32(void *P, uint32_t V) { … }
template <endianness E> inline void write64(void *P, uint64_t V) { … }
inline void write16le(void *P, uint16_t V) { … }
inline void write32le(void *P, uint32_t V) { … }
inline void write64le(void *P, uint64_t V) { … }
inline void write16be(void *P, uint16_t V) { … }
inline void write32be(void *P, uint32_t V) { … }
inline void write64be(void *P, uint64_t V) { … }
}
}
}
#endif