xref: /csrg-svn/sys/pmax/include/endian.h (revision 44541)
133280Sbostic /*
233280Sbostic  * Copyright (c) 1987 Regents of the University of California.
333280Sbostic  * All rights reserved.
433280Sbostic  *
5*44541Sbostic  * %sccs.include.redist.c%
633280Sbostic  *
7*44541Sbostic  *	@(#)endian.h	7.6 (Berkeley) 06/28/90
833280Sbostic  */
933280Sbostic 
1033280Sbostic /*
1133280Sbostic  * Definitions for byte order,
1233280Sbostic  * according to byte significance from low address to high.
1333280Sbostic  */
1433280Sbostic #define	LITTLE_ENDIAN	1234	/* least-significant byte first (vax) */
1533280Sbostic #define	BIG_ENDIAN	4321	/* most-significant byte first (IBM, net) */
1633280Sbostic #define	PDP_ENDIAN	3412	/* LSB first in word, MSW first in long (pdp) */
1733280Sbostic 
1833280Sbostic #define	BYTE_ORDER	LITTLE_ENDIAN	/* byte order on vax */
1933280Sbostic 
2033280Sbostic /*
2133280Sbostic  * Macros for network/external number representation conversion.
2233280Sbostic  */
2333381Skarels #if BYTE_ORDER == BIG_ENDIAN && !defined(lint)
2433280Sbostic #define	ntohl(x)	(x)
2533280Sbostic #define	ntohs(x)	(x)
2633280Sbostic #define	htonl(x)	(x)
2733280Sbostic #define	htons(x)	(x)
2840610Skarels 
2940610Skarels #define	NTOHL(x)	(x)
3040610Skarels #define	NTOHS(x)	(x)
3140610Skarels #define	HTONL(x)	(x)
3240610Skarels #define	HTONS(x)	(x)
3340610Skarels 
3433280Sbostic #else
3540610Skarels 
3633280Sbostic unsigned short	ntohs(), htons();
3733280Sbostic unsigned long	ntohl(), htonl();
3840610Skarels 
3940804Ssklower #define	NTOHL(x)	(x) = ntohl((u_long)x)
4040804Ssklower #define	NTOHS(x)	(x) = ntohs((u_short)x)
4140804Ssklower #define	HTONL(x)	(x) = htonl((u_long)x)
4240804Ssklower #define	HTONS(x)	(x) = htons((u_short)x)
4333280Sbostic #endif
44