--- embedaddon/iperf/src/portable_endian.h 2016/10/18 13:28:18 1.1 +++ embedaddon/iperf/src/portable_endian.h 2023/09/27 11:14:54 1.1.1.3 @@ -10,18 +10,26 @@ #endif -// GLIBC / Linux with endian(3) support, which was added in glibc 2.9. -// Intended to support CentOS 6 and newer. -#if defined(__linux__) && \ - ((__GLIBC__ > 3) || \ - (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 9)) +#if defined(__CYGWIN__) # include -#elif defined(__CYGWIN__) - +#elif defined(HAVE_ENDIAN_H) # include +#elif defined(HAVE_SYS_ENDIAN_H) +# include + +# if defined(__sgi) + +# include +# include + +# define be64toh(x) (x) +# define htobe64(x) (x) + +# endif + #elif defined(__APPLE__) # include @@ -30,12 +38,12 @@ # define htole16(x) OSSwapHostToLittleInt16(x) # define be16toh(x) OSSwapBigToHostInt16(x) # define le16toh(x) OSSwapLittleToHostInt16(x) - + # define htobe32(x) OSSwapHostToBigInt32(x) # define htole32(x) OSSwapHostToLittleInt32(x) # define be32toh(x) OSSwapBigToHostInt32(x) # define le32toh(x) OSSwapLittleToHostInt32(x) - + # define htobe64(x) OSSwapHostToBigInt64(x) # define htole64(x) OSSwapHostToLittleInt64(x) # define be64toh(x) OSSwapBigToHostInt64(x) @@ -46,29 +54,22 @@ # define __LITTLE_ENDIAN LITTLE_ENDIAN # define __PDP_ENDIAN PDP_ENDIAN -#elif defined(__OpenBSD__) - -# include - -# 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 - #elif defined(__sun) && defined(__SVR4) # include # include # include +# 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 htobe64(x) htonll(x) @@ -83,12 +84,12 @@ # define htole16(x) (x) # define be16toh(x) ntohs(x) # define le16toh(x) (x) - + # define htobe32(x) htonl(x) # define htole32(x) (x) # define be32toh(x) ntohl(x) # define le32toh(x) (x) - + # define htobe64(x) htonll(x) # define htole64(x) (x) # define be64toh(x) ntohll(x) @@ -101,12 +102,12 @@ # define htole16(x) __builtin_bswap16(x) # define be16toh(x) (x) # define le16toh(x) __builtin_bswap16(x) - + # define htobe32(x) (x) # define htole32(x) __builtin_bswap32(x) # define be32toh(x) (x) # define le32toh(x) __builtin_bswap32(x) - + # define htobe64(x) (x) # define htole64(x) __builtin_bswap64(x) # define be64toh(x) (x) @@ -161,4 +162,3 @@ #endif #endif -