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