1 /* 2 * Copyright (c) 1987 Regents of the University of California. 3 * All rights reserved. 4 * 5 * %sccs.include.redist.c% 6 * 7 * @(#)endian.h 7.6 (Berkeley) 06/28/90 8 */ 9 10 /* 11 * Definitions for byte order, 12 * according to byte significance from low address to high. 13 */ 14 #define LITTLE_ENDIAN 1234 /* least-significant byte first (vax) */ 15 #define BIG_ENDIAN 4321 /* most-significant byte first (IBM, net) */ 16 #define PDP_ENDIAN 3412 /* LSB first in word, MSW first in long (pdp) */ 17 18 #define BYTE_ORDER LITTLE_ENDIAN /* byte order on vax */ 19 20 /* 21 * Macros for network/external number representation conversion. 22 */ 23 #if BYTE_ORDER == BIG_ENDIAN && !defined(lint) 24 #define ntohl(x) (x) 25 #define ntohs(x) (x) 26 #define htonl(x) (x) 27 #define htons(x) (x) 28 29 #define NTOHL(x) (x) 30 #define NTOHS(x) (x) 31 #define HTONL(x) (x) 32 #define HTONS(x) (x) 33 34 #else 35 36 unsigned short ntohs(), htons(); 37 unsigned long ntohl(), htonl(); 38 39 #define NTOHL(x) (x) = ntohl((u_long)x) 40 #define NTOHS(x) (x) = ntohs((u_short)x) 41 #define HTONL(x) (x) = htonl((u_long)x) 42 #define HTONS(x) (x) = htons((u_short)x) 43 #endif 44