xref: /csrg-svn/sys/pmax/include/endian.h (revision 33381)
133280Sbostic /*
233280Sbostic  * Copyright (c) 1987 Regents of the University of California.
333280Sbostic  * All rights reserved.
433280Sbostic  *
533280Sbostic  * Redistribution and use in source and binary forms are permitted
633280Sbostic  * provided that this notice is preserved and that due credit is given
733280Sbostic  * to the University of California at Berkeley. The name of the University
833280Sbostic  * may not be used to endorse or promote products derived from this
933280Sbostic  * software without specific prior written permission. This software
1033280Sbostic  * is provided ``as is'' without express or implied warranty.
1133280Sbostic  *
12*33381Skarels  *	@(#)endian.h	7.2 (Berkeley) 01/21/88
1333280Sbostic  */
1433280Sbostic 
1533280Sbostic /*
1633280Sbostic  * Definitions for byte order,
1733280Sbostic  * according to byte significance from low address to high.
1833280Sbostic  */
1933280Sbostic #define	LITTLE_ENDIAN	1234	/* least-significant byte first (vax) */
2033280Sbostic #define	BIG_ENDIAN	4321	/* most-significant byte first (IBM, net) */
2133280Sbostic #define	PDP_ENDIAN	3412	/* LSB first in word, MSW first in long (pdp) */
2233280Sbostic 
2333280Sbostic #define	BYTE_ORDER	LITTLE_ENDIAN	/* byte order on vax */
2433280Sbostic 
2533280Sbostic /*
2633280Sbostic  * Macros for network/external number representation conversion.
2733280Sbostic  */
28*33381Skarels #if BYTE_ORDER == BIG_ENDIAN && !defined(lint)
2933280Sbostic #define	ntohl(x)	(x)
3033280Sbostic #define	ntohs(x)	(x)
3133280Sbostic #define	htonl(x)	(x)
3233280Sbostic #define	htons(x)	(x)
3333280Sbostic #else
3433280Sbostic unsigned short	ntohs(), htons();
3533280Sbostic unsigned long	ntohl(), htonl();
3633280Sbostic #endif
37