xref: /csrg-svn/sys/hp300/include/endian.h (revision 40611)
133277Sbostic /*
233277Sbostic  * Copyright (c) 1987 Regents of the University of California.
333277Sbostic  * All rights reserved.
433277Sbostic  *
533277Sbostic  * Redistribution and use in source and binary forms are permitted
634863Sbostic  * provided that the above copyright notice and this paragraph are
734863Sbostic  * duplicated in all such forms and that any documentation,
834863Sbostic  * advertising materials, and other materials related to such
934863Sbostic  * distribution and use acknowledge that the software was developed
1034863Sbostic  * by the University of California, Berkeley.  The name of the
1134863Sbostic  * University may not be used to endorse or promote products derived
1234863Sbostic  * from this software without specific prior written permission.
1334863Sbostic  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
1434863Sbostic  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
1534863Sbostic  * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
1633277Sbostic  *
17*40611Skarels  *	@(#)endian.h	7.4 (Berkeley) 03/23/90
1833277Sbostic  */
1933277Sbostic 
2033277Sbostic /*
2133277Sbostic  * Definitions for byte order,
2233277Sbostic  * according to byte significance from low address to high.
2333277Sbostic  */
2433277Sbostic #define	LITTLE_ENDIAN	1234	/* least-significant byte first (vax) */
2533277Sbostic #define	BIG_ENDIAN	4321	/* most-significant byte first (IBM, net) */
2633277Sbostic #define	PDP_ENDIAN	3412	/* LSB first in word, MSW first in long (pdp) */
2733277Sbostic 
2833277Sbostic #define	BYTE_ORDER	BIG_ENDIAN	/* byte order on tahoe */
2933277Sbostic 
3033277Sbostic /*
3133277Sbostic  * Macros for network/external number representation conversion.
3233277Sbostic  */
3333380Skarels #if BYTE_ORDER == BIG_ENDIAN && !defined(lint)
3433277Sbostic #define	ntohl(x)	(x)
3533277Sbostic #define	ntohs(x)	(x)
3633277Sbostic #define	htonl(x)	(x)
3733277Sbostic #define	htons(x)	(x)
38*40611Skarels 
39*40611Skarels #define	NTOHL(x)	(x)
40*40611Skarels #define	NTOHS(x)	(x)
41*40611Skarels #define	HTONL(x)	(x)
42*40611Skarels #define	HTONS(x)	(x)
43*40611Skarels 
4433277Sbostic #else
45*40611Skarels 
4633277Sbostic unsigned short	ntohs(), htons();
4733277Sbostic unsigned long	ntohl(), htonl();
48*40611Skarels 
49*40611Skarels #define	NTOHL(x)	(x) = ntohl(x)
50*40611Skarels #define	NTOHS(x)	(x) = ntohs(x)
51*40611Skarels #define	HTONL(x)	(x) = htonl(x)
52*40611Skarels #define	HTONS(x)	(x) = htons(x)
5333277Sbostic #endif
54