]> git.saurik.com Git - apple/xnu.git/blobdiff - bsd/sys/_endian.h
xnu-792.13.8.tar.gz
[apple/xnu.git] / bsd / sys / _endian.h
index 82bbe4611743b8638a53ba19d27f90559303aa73..e423f5dd9fc9ec8d6200b8c7a5c34b46a2c95918 100644 (file)
@@ -1,6 +1,6 @@
 /*
- * Copyright (c) 2006 Apple Computer, Inc. All Rights Reserved.
- * 
+ * Copyright (c) 2004 Apple Computer, Inc. All rights reserved.
+ *
  * @APPLE_LICENSE_OSREFERENCE_HEADER_START@
  * 
  * This file contains Original Code and/or Modifications of Original Code 
 /*
  * Macros for network/external number representation conversion.
  */
-#if __DARWIN_BYTE_ORDER == __DARWIN_BIG_ENDIAN && !defined(lint)
-#define        ntohl(x)        (x)
-#define        ntohs(x)        (x)
-#define        htonl(x)        (x)
-#define        htons(x)        (x)
-
-#if    defined(KERNEL) || !defined(_POSIX_C_SOURCE)
-#define        NTOHL(x)        (x)
-#define        NTOHS(x)        (x)
-#define        HTONL(x)        (x)
-#define        HTONS(x)        (x)
-#endif /* defined(KERNEL) || !defined(_POSIX_C_SOURCE) */
-
-#else
-
 #if !defined(__ASSEMBLER__) 
 
 #include <stdint.h>
-#include <machine/byte_order.h>
+#include <libkern/OSByteOrder.h>
  
 __BEGIN_DECLS
 uint16_t       ntohs(uint16_t);
@@ -127,16 +112,11 @@ uint32_t  htonl(uint32_t);
 __END_DECLS
 #endif /* !defined(__ASSEMBLER__) */
 
-#define ntohs(x)       NXSwapBigShortToHost(x)
-#define htons(x)       NXSwapHostShortToBig(x)
+#define ntohs(x)       OSSwapBigToHostInt16(x)
+#define htons(x)       OSSwapHostToBigInt16(x)
 
-#if defined(__LP64__)
-#define ntohl(x)       NXSwapBigIntToHost(x)
-#define htonl(x)       NXSwapHostIntToBig(x)
-#else 
-#define ntohl(x)       NXSwapBigLongToHost(x)
-#define htonl(x)       NXSwapHostLongToBig(x)
-#endif /* defined(__LP64__) */
+#define ntohl(x)       OSSwapBigToHostInt32(x)
+#define htonl(x)       OSSwapHostToBigInt32(x)
 
 #if    defined(KERNEL) || !defined(_POSIX_C_SOURCE)
 #define        NTOHL(x)        (x) = ntohl((u_long)x)
@@ -144,5 +124,4 @@ __END_DECLS
 #define        HTONL(x)        (x) = htonl((u_long)x)
 #define        HTONS(x)        (x) = htons((u_short)x)
 #endif /* defined(KERNEL) || !defined(_POSIX_C_SOURCE) */
-#endif /* __DARWIN_BYTE_ORDER != __DARWIN_BIG_ENDIAN || defined(lint) */ 
 #endif /* !_SYS__ENDIAN_H_ */