Merge remote-tracking branch 'freeradius/v3.0.x' into tr-upgrade
[freeradius.git] / src / include / missing-h
index b4dc2bf..90a402f 100644 (file)
@@ -403,21 +403,35 @@ typedef struct int128_t { uint8_t v[16]; } int128_t;
 #endif
 
 /* abcd efgh -> dcba hgfe -> hgfe dcba */
-#ifdef LITTLE_ENDIAN
-#  define ntohll(x) (((uint64_t)ntohl((uint32_t)(x >> 32))) | (((uint64_t)ntohl(((uint32_t) x)) << 32)))
-
-#  ifdef HAVE_128BIT_INTEGERS
-#    define ntohlll(x) (((uint128_t)ntohll((uint64_t)(x >> 64))) | (((uint128_t)ntohll(((uint64_t) x)) << 64)))
+#ifndef HAVE_HTON_LL
+#  ifdef LITTLE_ENDIAN
+#    ifdef HAVE_BUILTIN_BSWAP64
+#      define ntohll(x) __builtin_bswap64(x)
+#    else
+#      define ntohll(x) (((uint64_t)ntohl((uint32_t)(x >> 32))) | (((uint64_t)ntohl(((uint32_t) x)) << 32)))
+#    endif
 #  else
+#    define ntohll(x) (x)
+#  endif
+#  define htonll(x) ntohll(x)
+#endif
+
+#ifndef HAVE_HTON_LLL
+#  ifdef LITTLE_ENDIAN
+#    ifdef HAVE_128BIT_INTEGERS
+#      define ntohlll(x) (((uint128_t)ntohll((uint64_t)(x >> 64))) | (((uint128_t)ntohll(((uint64_t) x)) << 64)))
+#    else
 uint128_t ntohlll(uint128_t num);
+#    endif
+#  else
+#    define ntohlll(x) (x)
 #  endif
-#else
-#  define ntohll(x) (x)
-#  define ntohlll(x) (x)
+#  define htonlll(x) htohlll(x)
 #endif
 
-#define htonll(x) ntohll(x)
-#define htonlll(x) htohlll(x)
+#ifndef HAVE_SIG_T
+typedef void(*sig_t)(int);
+#endif
 
 #ifdef __cplusplus
 }