#ifndef RAVEN_COMPAT_ENDIAN_H
#define RAVEN_COMPAT_ENDIAN_H
#include "compat/byteswap.h"
#include <stdint.h>
#if defined(HAVE_ENDIAN_H)
#include <endian.h>
#elif defined(HAVE_SYS_ENDIAN_H)
#include <sys/endian.h>
#endif
#if defined(WORDS_BIGENDIAN)
#if HAVE_DECL_HTOBE16 == 0
#ifdef htobe16
#undef htobe16
#endif
inline uint16_t htobe16(uint16_t host_16bits)
{
return host_16bits;
}
#endif
#if HAVE_DECL_HTOLE16 == 0
#ifdef htole16
#undef htole16
#endif
inline uint16_t htole16(uint16_t host_16bits)
{
return bswap_16(host_16bits);
}
#endif
#if HAVE_DECL_BE16TOH == 0
#ifdef be16toh
#undef be16toh
#endif
inline uint16_t be16toh(uint16_t big_endian_16bits)
{
return big_endian_16bits;
}
#endif
#if HAVE_DECL_LE16TOH == 0
#ifdef le16toh
#undef le16toh
#endif
inline uint16_t le16toh(uint16_t little_endian_16bits)
{
return bswap_16(little_endian_16bits);
}
#endif
#if HAVE_DECL_HTOBE32 == 0
#ifdef htobe32
#undef htobe32
#endif
inline uint32_t htobe32(uint32_t host_32bits)
{
return host_32bits;
}
#endif
#if HAVE_DECL_HTOLE32 == 0
#ifdef htole32
#undef htole32
#endif
inline uint32_t htole32(uint32_t host_32bits)
{
return bswap_32(host_32bits);
}
#endif
#if HAVE_DECL_BE32TOH == 0
#ifdef be32toh
#undef be32toh
#endif
inline uint32_t be32toh(uint32_t big_endian_32bits)
{
return big_endian_32bits;
}
#endif
#if HAVE_DECL_LE32TOH == 0
#ifdef le32toh
#undef le32toh
#endif
inline uint32_t le32toh(uint32_t little_endian_32bits)
{
return bswap_32(little_endian_32bits);
}
#endif
#if HAVE_DECL_HTOBE64 == 0
#ifdef htobe64
#undef htobe64
#endif
inline uint64_t htobe64(uint64_t host_64bits)
{
return host_64bits;
}
#endif
#if HAVE_DECL_HTOLE64 == 0
#ifdef htole64
#undef htole64
#endif
inline uint64_t htole64(uint64_t host_64bits)
{
return bswap_64(host_64bits);
}
#endif
#if HAVE_DECL_BE64TOH == 0
#ifdef be64toh
#undef be64toh
#endif
inline uint64_t be64toh(uint64_t big_endian_64bits)
{
return big_endian_64bits;
}
#endif
#if HAVE_DECL_LE64TOH == 0
#ifdef le64toh
#undef le64toh
#endif
inline uint64_t le64toh(uint64_t little_endian_64bits)
{
return bswap_64(little_endian_64bits);
}
#endif
#else
#if HAVE_DECL_HTOBE16 == 0
#ifdef htobe16
#undef htobe16
#endif
inline uint16_t htobe16(uint16_t host_16bits)
{
return bswap_16(host_16bits);
}
#endif
#if HAVE_DECL_HTOLE16 == 0
#ifdef htole16
#undef htole16
#endif
inline uint16_t htole16(uint16_t host_16bits)
{
return host_16bits;
}
#endif
#if HAVE_DECL_BE16TOH == 0
#ifdef be16toh
#undef be16toh
#endif
inline uint16_t be16toh(uint16_t big_endian_16bits)
{
return bswap_16(big_endian_16bits);
}
#endif
#if HAVE_DECL_LE16TOH == 0
#ifdef le16toh
#undef le16toh
#endif
inline uint16_t le16toh(uint16_t little_endian_16bits)
{
return little_endian_16bits;
}
#endif
#if HAVE_DECL_HTOBE32 == 0
#ifdef htobe32
#undef htobe32
#endif
inline uint32_t htobe32(uint32_t host_32bits)
{
return bswap_32(host_32bits);
}
#endif
#if HAVE_DECL_HTOLE32 == 0
#ifdef htole32
#undef htole32
#endif
inline uint32_t htole32(uint32_t host_32bits)
{
return host_32bits;
}
#endif
#if HAVE_DECL_BE32TOH == 0
#ifdef be32toh
#undef be32toh
#endif
inline uint32_t be32toh(uint32_t big_endian_32bits)
{
return bswap_32(big_endian_32bits);
}
#endif
#if HAVE_DECL_LE32TOH == 0
#ifdef le32toh
#undef le32toh
#endif
inline uint32_t le32toh(uint32_t little_endian_32bits)
{
return little_endian_32bits;
}
#endif
#if HAVE_DECL_HTOBE64 == 0
#ifdef htobe64
#undef htobe64
#endif
inline uint64_t htobe64(uint64_t host_64bits)
{
return bswap_64(host_64bits);
}
#endif
#if HAVE_DECL_HTOLE64 == 0
#ifdef htole64
#undef htole64
#endif
inline uint64_t htole64(uint64_t host_64bits)
{
return host_64bits;
}
#endif
#if HAVE_DECL_BE64TOH == 0
#ifdef be64toh
#undef be64toh
#endif
inline uint64_t be64toh(uint64_t big_endian_64bits)
{
return bswap_64(big_endian_64bits);
}
#endif
#if HAVE_DECL_LE64TOH == 0
#ifdef le64toh
#undef le64toh
#endif
inline uint64_t le64toh(uint64_t little_endian_64bits)
{
return little_endian_64bits;
}
#endif
#endif
#endif