version 1.1.1.1, 2016/10/18 13:28:18
|
version 1.1.1.3, 2023/09/27 11:14:54
|
Line 10
|
Line 10
|
|
|
#endif |
#endif |
|
|
// GLIBC / Linux with endian(3) support, which was added in glibc 2.9. | #if defined(__CYGWIN__) |
// Intended to support CentOS 6 and newer. | |
#if defined(__linux__) && \ | |
((__GLIBC__ > 3) || \ | |
(__GLIBC__ == 2 && __GLIBC_MINOR__ >= 9)) | |
|
|
# include <endian.h> |
# include <endian.h> |
|
|
#elif defined(__CYGWIN__) | #elif defined(HAVE_ENDIAN_H) |
| |
# include <endian.h> |
# include <endian.h> |
|
|
|
#elif defined(HAVE_SYS_ENDIAN_H) |
|
# include <sys/endian.h> |
|
|
|
# if defined(__sgi) |
|
|
|
# include <netinet/in.h> |
|
# include <inttypes.h> |
|
|
|
# define be64toh(x) (x) |
|
# define htobe64(x) (x) |
|
|
|
# endif |
|
|
#elif defined(__APPLE__) |
#elif defined(__APPLE__) |
|
|
# include <libkern/OSByteOrder.h> |
# include <libkern/OSByteOrder.h> |
Line 30
|
Line 38
|
# define htole16(x) OSSwapHostToLittleInt16(x) |
# define htole16(x) OSSwapHostToLittleInt16(x) |
# define be16toh(x) OSSwapBigToHostInt16(x) |
# define be16toh(x) OSSwapBigToHostInt16(x) |
# define le16toh(x) OSSwapLittleToHostInt16(x) |
# define le16toh(x) OSSwapLittleToHostInt16(x) |
| |
# define htobe32(x) OSSwapHostToBigInt32(x) |
# define htobe32(x) OSSwapHostToBigInt32(x) |
# define htole32(x) OSSwapHostToLittleInt32(x) |
# define htole32(x) OSSwapHostToLittleInt32(x) |
# define be32toh(x) OSSwapBigToHostInt32(x) |
# define be32toh(x) OSSwapBigToHostInt32(x) |
# define le32toh(x) OSSwapLittleToHostInt32(x) |
# define le32toh(x) OSSwapLittleToHostInt32(x) |
| |
# define htobe64(x) OSSwapHostToBigInt64(x) |
# define htobe64(x) OSSwapHostToBigInt64(x) |
# define htole64(x) OSSwapHostToLittleInt64(x) |
# define htole64(x) OSSwapHostToLittleInt64(x) |
# define be64toh(x) OSSwapBigToHostInt64(x) |
# define be64toh(x) OSSwapBigToHostInt64(x) |
Line 46
|
Line 54
|
# define __LITTLE_ENDIAN LITTLE_ENDIAN |
# define __LITTLE_ENDIAN LITTLE_ENDIAN |
# define __PDP_ENDIAN PDP_ENDIAN |
# define __PDP_ENDIAN PDP_ENDIAN |
|
|
#elif defined(__OpenBSD__) |
|
|
|
# include <sys/endian.h> |
|
|
|
# define be16toh(x) betoh16(x) |
|
# define le16toh(x) letoh16(x) |
|
|
|
# define be32toh(x) betoh32(x) |
|
# define le32toh(x) letoh32(x) |
|
|
|
# define be64toh(x) betoh64(x) |
|
# define le64toh(x) letoh64(x) |
|
|
|
#elif defined(__NetBSD__) || defined(__FreeBSD__) || defined(__DragonFly__) |
|
|
|
# include <sys/endian.h> |
|
|
|
#elif defined(__sun) && defined(__SVR4) |
#elif defined(__sun) && defined(__SVR4) |
|
|
# include <sys/types.h> |
# include <sys/types.h> |
# include <netinet/in.h> |
# include <netinet/in.h> |
# include <inttypes.h> |
# include <inttypes.h> |
|
|
|
# if !defined (ntohll) || !defined(htonll) |
|
# ifdef _BIG_ENDIAN |
|
# define htonll(x) (x) |
|
# define ntohll(x) (x) |
|
# else |
|
# define htonll(x) ((((uint64_t)htonl(x)) << 32) + htonl((uint64_t)(x) >> 32)) |
|
# define ntohll(x) ((((uint64_t)ntohl(x)) << 32) + ntohl((uint64_t)(x) >> 32)) |
|
# endif |
|
# endif |
|
|
# define be64toh(x) ntohll(x) |
# define be64toh(x) ntohll(x) |
# define htobe64(x) htonll(x) |
# define htobe64(x) htonll(x) |
|
|
Line 83
|
Line 84
|
# define htole16(x) (x) |
# define htole16(x) (x) |
# define be16toh(x) ntohs(x) |
# define be16toh(x) ntohs(x) |
# define le16toh(x) (x) |
# define le16toh(x) (x) |
| |
# define htobe32(x) htonl(x) |
# define htobe32(x) htonl(x) |
# define htole32(x) (x) |
# define htole32(x) (x) |
# define be32toh(x) ntohl(x) |
# define be32toh(x) ntohl(x) |
# define le32toh(x) (x) |
# define le32toh(x) (x) |
| |
# define htobe64(x) htonll(x) |
# define htobe64(x) htonll(x) |
# define htole64(x) (x) |
# define htole64(x) (x) |
# define be64toh(x) ntohll(x) |
# define be64toh(x) ntohll(x) |
Line 101
|
Line 102
|
# define htole16(x) __builtin_bswap16(x) |
# define htole16(x) __builtin_bswap16(x) |
# define be16toh(x) (x) |
# define be16toh(x) (x) |
# define le16toh(x) __builtin_bswap16(x) |
# define le16toh(x) __builtin_bswap16(x) |
| |
# define htobe32(x) (x) |
# define htobe32(x) (x) |
# define htole32(x) __builtin_bswap32(x) |
# define htole32(x) __builtin_bswap32(x) |
# define be32toh(x) (x) |
# define be32toh(x) (x) |
# define le32toh(x) __builtin_bswap32(x) |
# define le32toh(x) __builtin_bswap32(x) |
| |
# define htobe64(x) (x) |
# define htobe64(x) (x) |
# define htole64(x) __builtin_bswap64(x) |
# define htole64(x) __builtin_bswap64(x) |
# define be64toh(x) (x) |
# define be64toh(x) (x) |
Line 161
|
Line 162
|
#endif |
#endif |
|
|
#endif |
#endif |
|
|