]> git.saurik.com Git - apple/xnu.git/blobdiff - bsd/sys/_endian.h
xnu-3789.31.2.tar.gz
[apple/xnu.git] / bsd / sys / _endian.h
index e1ec25078e09dc9463ed4c5bcdc745f683f6507a..6e00b6c0bd69f495074cb96585aa4d2cb2236799 100644 (file)
@@ -107,16 +107,22 @@ __END_DECLS
 
 #elif __DARWIN_BYTE_ORDER == __DARWIN_BIG_ENDIAN
 
-#define ntohl(x)        (x)
-#define ntohs(x)        (x)
-#define htonl(x)        (x)
-#define htons(x)        (x)
+#define ntohl(x)        ((__uint32_t)(x))
+#define ntohs(x)        ((__uint16_t)(x))
+#define htonl(x)        ((__uint32_t)(x))
+#define htons(x)        ((__uint16_t)(x))
 
 #if     defined(KERNEL) || (!defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE))
+
+#define ntohll(x)       ((__uint64_t)(x))
+#define htonll(x)       ((__uint64_t)(x))
+
 #define NTOHL(x)        (x)
 #define NTOHS(x)        (x)
+#define NTOHLL(x)       (x)
 #define HTONL(x)        (x)
 #define HTONS(x)        (x)
+#define HTONLL(x)       (x)
 #endif /* defined(KERNEL) || (!defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)) */
 
 #else  /* __DARWIN_BYTE_ORDER == __DARWIN_LITTLE_ENDIAN */
@@ -130,10 +136,16 @@ __END_DECLS
 #define htonl(x)       __DARWIN_OSSwapInt32(x)
 
 #if    defined(KERNEL) || (!defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE))
+
+#define ntohll(x)       __DARWIN_OSSwapInt64(x)
+#define htonll(x)       __DARWIN_OSSwapInt64(x)
+
 #define        NTOHL(x)        (x) = ntohl((__uint32_t)x)
 #define        NTOHS(x)        (x) = ntohs((__uint16_t)x)
+#define        NTOHLL(x)       (x) = ntohll((__uint64_t)x)
 #define        HTONL(x)        (x) = htonl((__uint32_t)x)
 #define        HTONS(x)        (x) = htons((__uint16_t)x)
+#define        HTONLL(x)       (x) = htonll((__uint64_t)x)
 #endif /* defined(KERNEL) || (!defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)) */
 #endif /* __DARWIN_BYTE_ORDER */
 #endif /* !_SYS__ENDIAN_H_ */