xref: /original-bsd/sys/pmax/include/endian.h (revision 95a66346)
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.7 (Berkeley) 02/22/91
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 #ifdef KERNEL
37 #include "cdefs.h"
38 #else
39 #include <sys/cdefs.h>
40 #endif
41 
42 __BEGIN_DECLS
43 unsigned long	htonl __P((unsigned long));
44 unsigned short	htons __P((unsigned short));
45 unsigned long	ntohl __P((unsigned long));
46 unsigned short	ntohs __P((unsigned short));
47 __END_DECLS
48 
49 #define	NTOHL(x)	(x) = ntohl((u_long)x)
50 #define	NTOHS(x)	(x) = ntohs((u_short)x)
51 #define	HTONL(x)	(x) = htonl((u_long)x)
52 #define	HTONS(x)	(x) = htons((u_short)x)
53 #endif
54