xref: /original-bsd/sys/hp300/include/endian.h (revision 6093a5ae)
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.9 (Berkeley) 06/19/92
8  */
9 
10 /*
11  * Define the order of 32-bit words in 64-bit words.
12  */
13 #define _QUAD_HIGHWORD 0
14 #define _QUAD_LOWWORD 1
15 
16 #ifndef _POSIX_SOURCE
17 /*
18  * Definitions for byte order, according to byte significance from low
19  * address to high.
20  */
21 #define	LITTLE_ENDIAN	1234	/* LSB first: i386, vax */
22 #define	BIG_ENDIAN	4321	/* MSB first: 68000, ibm, net */
23 #define	PDP_ENDIAN	3412	/* LSB first in word, MSW first in long */
24 
25 #define	BYTE_ORDER	BIG_ENDIAN
26 
27 #include <sys/cdefs.h>
28 
29 __BEGIN_DECLS
30 unsigned long	htonl __P((unsigned long));
31 unsigned short	htons __P((unsigned short));
32 unsigned long	ntohl __P((unsigned long));
33 unsigned short	ntohs __P((unsigned short));
34 __END_DECLS
35 
36 /*
37  * Macros for network/external number representation conversion.
38  */
39 #if BYTE_ORDER == BIG_ENDIAN && !defined(lint)
40 #define	ntohl(x)	(x)
41 #define	ntohs(x)	(x)
42 #define	htonl(x)	(x)
43 #define	htons(x)	(x)
44 
45 #define	NTOHL(x)	(x)
46 #define	NTOHS(x)	(x)
47 #define	HTONL(x)	(x)
48 #define	HTONS(x)	(x)
49 
50 #else
51 
52 #define	NTOHL(x)	(x) = ntohl((u_long)x)
53 #define	NTOHS(x)	(x) = ntohs((u_short)x)
54 #define	HTONL(x)	(x) = htonl((u_long)x)
55 #define	HTONS(x)	(x) = htons((u_short)x)
56 #endif
57 #endif /* !_POSIX_SOURCE */
58