xref: /csrg-svn/sys/hp300/include/endian.h (revision 52003)
133277Sbostic /*
247794Sbostic  * Copyright (c) 1987, 1991 Regents of the University of California.
333277Sbostic  * All rights reserved.
433277Sbostic  *
544526Sbostic  * %sccs.include.redist.c%
633277Sbostic  *
7*52003Smckusick  *	@(#)endian.h	7.8 (Berkeley) 12/19/91
833277Sbostic  */
933277Sbostic 
1033277Sbostic /*
11*52003Smckusick  * Define _NOQUAD if the compiler does NOT support 64-bit integers.
12*52003Smckusick  */
13*52003Smckusick /* #define _NOQUAD */
14*52003Smckusick 
15*52003Smckusick /*
16*52003Smckusick  * Define the order of 32-bit words in 64-bit words.
17*52003Smckusick  */
18*52003Smckusick #define _QUAD_HIGHWORD 0
19*52003Smckusick #define _QUAD_LOWWORD 1
20*52003Smckusick 
21*52003Smckusick #ifndef _POSIX_SOURCE
22*52003Smckusick /*
2347794Sbostic  * Definitions for byte order, according to byte significance from low
2447794Sbostic  * address to high.
2533277Sbostic  */
2647794Sbostic #define	LITTLE_ENDIAN	1234	/* LSB first: i386, vax */
2747794Sbostic #define	BIG_ENDIAN	4321	/* MSB first: 68000, ibm, net */
2847794Sbostic #define	PDP_ENDIAN	3412	/* LSB first in word, MSW first in long */
2933277Sbostic 
3047792Sbostic #define	BYTE_ORDER	BIG_ENDIAN
3133277Sbostic 
3247794Sbostic #include <sys/cdefs.h>
3347794Sbostic 
3447794Sbostic __BEGIN_DECLS
3547794Sbostic unsigned long	htonl __P((unsigned long));
3647794Sbostic unsigned short	htons __P((unsigned short));
3747794Sbostic unsigned long	ntohl __P((unsigned long));
3847794Sbostic unsigned short	ntohs __P((unsigned short));
3947794Sbostic __END_DECLS
4047794Sbostic 
4133277Sbostic /*
4233277Sbostic  * Macros for network/external number representation conversion.
4333277Sbostic  */
4433380Skarels #if BYTE_ORDER == BIG_ENDIAN && !defined(lint)
4533277Sbostic #define	ntohl(x)	(x)
4633277Sbostic #define	ntohs(x)	(x)
4733277Sbostic #define	htonl(x)	(x)
4833277Sbostic #define	htons(x)	(x)
4940611Skarels 
5040611Skarels #define	NTOHL(x)	(x)
5140611Skarels #define	NTOHS(x)	(x)
5240611Skarels #define	HTONL(x)	(x)
5340611Skarels #define	HTONS(x)	(x)
5440611Skarels 
5533277Sbostic #else
5640611Skarels 
5747794Sbostic #define	NTOHL(x)	(x) = ntohl((u_long)x)
5847794Sbostic #define	NTOHS(x)	(x) = ntohs((u_short)x)
5947794Sbostic #define	HTONL(x)	(x) = htonl((u_long)x)
6047794Sbostic #define	HTONS(x)	(x) = htons((u_short)x)
6133277Sbostic #endif
62*52003Smckusick #endif /* !_POSIX_SOURCE */
63