version 1.1.1.1, 2016/10/18 13:28:18
|
version 1.1.1.2, 2021/03/17 00:36:46
|
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(__OpenBSD__) |
|
|
|
# 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(__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 46
|
Line 65
|
# 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) |