#ifndef RTC_BASE_BYTE_ORDER_H_
#define RTC_BASE_BYTE_ORDER_H_
#include <stdint.h>
#include <cstring>
#if defined(WEBRTC_POSIX) && !defined(__native_client__)
#include <arpa/inet.h>
#endif
#include "rtc_base/system/arch.h"
#if defined(WEBRTC_MAC)
#include <libkern/OSByteOrder.h>
#define htobe16 …
#define htobe32 …
#define htobe64 …
#define be16toh …
#define be32toh …
#define be64toh …
#define htole16 …
#define htole32 …
#define htole64 …
#define le16toh …
#define le32toh …
#define le64toh …
#elif defined(WEBRTC_WIN) || defined(__native_client__)
#if defined(WEBRTC_WIN)
#include <stdlib.h>
#include <winsock2.h>
#else
#include <netinet/in.h>
#endif
#if defined(WEBRTC_ARCH_LITTLE_ENDIAN)
#define htobe16 …
#define htobe32 …
#define be16toh …
#define be32toh …
#define htole16 …
#define htole32 …
#define htole64 …
#define le16toh …
#define le32toh …
#define le64toh …
#if defined(WEBRTC_WIN)
#define htobe64 …
#define be64toh …
#endif
#if defined(__native_client__)
#define htobe64 …
#define be64toh …
#endif
#elif defined(WEBRTC_ARCH_BIG_ENDIAN)
#define htobe16 …
#define htobe32 …
#define be16toh …
#define be32toh …
#define htole16 …
#define htole32 …
#define htole64 …
#define le16toh …
#define le32toh …
#define le64toh …
#if defined(WEBRTC_WIN)
#define htobe64 …
#define be64toh …
#endif
#if defined(__native_client__)
#define htobe64 …
#define be64toh …
#endif
#else
#error WEBRTC_ARCH_BIG_ENDIAN or WEBRTC_ARCH_LITTLE_ENDIAN must be defined.
#endif
#elif defined(WEBRTC_POSIX)
#include <endian.h>
#else
#error "Missing byte order functions for this arch."
#endif
namespace rtc {
inline void Set8(void* memory, size_t offset, uint8_t v) { … }
inline uint8_t Get8(const void* memory, size_t offset) { … }
inline void SetBE16(void* memory, uint16_t v) { … }
inline void SetBE32(void* memory, uint32_t v) { … }
inline void SetBE64(void* memory, uint64_t v) { … }
inline uint16_t GetBE16(const void* memory) { … }
inline uint32_t GetBE32(const void* memory) { … }
inline uint64_t GetBE64(const void* memory) { … }
inline void SetLE16(void* memory, uint16_t v) { … }
inline void SetLE32(void* memory, uint32_t v) { … }
inline void SetLE64(void* memory, uint64_t v) { … }
inline uint16_t GetLE16(const void* memory) { … }
inline uint32_t GetLE32(const void* memory) { … }
inline uint64_t GetLE64(const void* memory) { … }
inline bool IsHostBigEndian() { … }
inline uint16_t HostToNetwork16(uint16_t n) { … }
inline uint32_t HostToNetwork32(uint32_t n) { … }
inline uint64_t HostToNetwork64(uint64_t n) { … }
inline uint16_t NetworkToHost16(uint16_t n) { … }
inline uint32_t NetworkToHost32(uint32_t n) { … }
inline uint64_t NetworkToHost64(uint64_t n) { … }
}
#endif