1 /* 2 * Copyright (c) 1987, 1991 Regents of the University of California. 3 * All rights reserved. 4 * 5 * %sccs.include.redist.c% 6 * 7 * @(#)endian.h 7.8 (Berkeley) 12/19/91 8 */ 9 10 /* 11 * Define _NOQUAD if the compiler does NOT support 64-bit integers. 12 */ 13 /* #define _NOQUAD */ 14 15 /* 16 * Define the order of 32-bit words in 64-bit words. 17 */ 18 #define _QUAD_HIGHWORD 0 19 #define _QUAD_LOWWORD 1 20 21 #ifndef _POSIX_SOURCE 22 /* 23 * Definitions for byte order, according to byte significance from low 24 * address to high. 25 */ 26 #define LITTLE_ENDIAN 1234 /* LSB first: i386, vax */ 27 #define BIG_ENDIAN 4321 /* MSB first: 68000, ibm, net */ 28 #define PDP_ENDIAN 3412 /* LSB first in word, MSW first in long */ 29 30 #define BYTE_ORDER BIG_ENDIAN 31 32 #include <sys/cdefs.h> 33 34 __BEGIN_DECLS 35 unsigned long htonl __P((unsigned long)); 36 unsigned short htons __P((unsigned short)); 37 unsigned long ntohl __P((unsigned long)); 38 unsigned short ntohs __P((unsigned short)); 39 __END_DECLS 40 41 /* 42 * Macros for network/external number representation conversion. 43 */ 44 #if BYTE_ORDER == BIG_ENDIAN && !defined(lint) 45 #define ntohl(x) (x) 46 #define ntohs(x) (x) 47 #define htonl(x) (x) 48 #define htons(x) (x) 49 50 #define NTOHL(x) (x) 51 #define NTOHS(x) (x) 52 #define HTONL(x) (x) 53 #define HTONS(x) (x) 54 55 #else 56 57 #define NTOHL(x) (x) = ntohl((u_long)x) 58 #define NTOHS(x) (x) = ntohs((u_short)x) 59 #define HTONL(x) (x) = htonl((u_long)x) 60 #define HTONS(x) (x) = htons((u_short)x) 61 #endif 62 #endif /* !_POSIX_SOURCE */ 63