xref: /freebsd/sys/powerpc/include/endian.h (revision fd8e4ebc8c18caec3eefac6527831f9ee6a92959)
1fd8e4ebcSMike Barcroft /*-
2fa561e1eSDavid E. O'Brien  * Copyright (c) 1987, 1991, 1993
3fa561e1eSDavid E. O'Brien  *	The Regents of the University of California.  All rights reserved.
4fa561e1eSDavid E. O'Brien  *
5fa561e1eSDavid E. O'Brien  * Redistribution and use in source and binary forms, with or without
6fa561e1eSDavid E. O'Brien  * modification, are permitted provided that the following conditions
7fa561e1eSDavid E. O'Brien  * are met:
8fa561e1eSDavid E. O'Brien  * 1. Redistributions of source code must retain the above copyright
9fa561e1eSDavid E. O'Brien  *    notice, this list of conditions and the following disclaimer.
10fa561e1eSDavid E. O'Brien  * 2. Redistributions in binary form must reproduce the above copyright
11fa561e1eSDavid E. O'Brien  *    notice, this list of conditions and the following disclaimer in the
12fa561e1eSDavid E. O'Brien  *    documentation and/or other materials provided with the distribution.
13fa561e1eSDavid E. O'Brien  * 3. All advertising materials mentioning features or use of this software
14fa561e1eSDavid E. O'Brien  *    must display the following acknowledgement:
15fa561e1eSDavid E. O'Brien  *	This product includes software developed by the University of
16fa561e1eSDavid E. O'Brien  *	California, Berkeley and its contributors.
17fa561e1eSDavid E. O'Brien  * 4. Neither the name of the University nor the names of its contributors
18fa561e1eSDavid E. O'Brien  *    may be used to endorse or promote products derived from this software
19fa561e1eSDavid E. O'Brien  *    without specific prior written permission.
20fa561e1eSDavid E. O'Brien  *
21fa561e1eSDavid E. O'Brien  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22fa561e1eSDavid E. O'Brien  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23fa561e1eSDavid E. O'Brien  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24fa561e1eSDavid E. O'Brien  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25fa561e1eSDavid E. O'Brien  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26fa561e1eSDavid E. O'Brien  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27fa561e1eSDavid E. O'Brien  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28fa561e1eSDavid E. O'Brien  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29fa561e1eSDavid E. O'Brien  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30fa561e1eSDavid E. O'Brien  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31fa561e1eSDavid E. O'Brien  * SUCH DAMAGE.
32fa561e1eSDavid E. O'Brien  *
33fa561e1eSDavid E. O'Brien  *	@(#)endian.h	8.1 (Berkeley) 6/10/93
34fa561e1eSDavid E. O'Brien  *	$NetBSD: endian.h,v 1.7 1999/08/21 05:53:51 simonb Exp $
35fa561e1eSDavid E. O'Brien  * $FreeBSD$
36fa561e1eSDavid E. O'Brien  */
37fa561e1eSDavid E. O'Brien 
38fd8e4ebcSMike Barcroft #ifndef _MACHINE_ENDIAN_H_
39fd8e4ebcSMike Barcroft #define	_MACHINE_ENDIAN_H_
40fd8e4ebcSMike Barcroft 
41fd8e4ebcSMike Barcroft #include <machine/ansi.h>
42fa561e1eSDavid E. O'Brien 
43fa561e1eSDavid E. O'Brien /*
44fa561e1eSDavid E. O'Brien  * Define the order of 32-bit words in 64-bit words.
45fa561e1eSDavid E. O'Brien  */
46fa561e1eSDavid E. O'Brien #define	_QUAD_HIGHWORD 0
47fa561e1eSDavid E. O'Brien #define	_QUAD_LOWWORD 1
48fa561e1eSDavid E. O'Brien 
49fa561e1eSDavid E. O'Brien /*
50fa561e1eSDavid E. O'Brien  * Definitions for byte order, according to byte significance from low
51fa561e1eSDavid E. O'Brien  * address to high.
52fa561e1eSDavid E. O'Brien  */
53fd8e4ebcSMike Barcroft #ifndef _POSIX_SOURCE
54fa561e1eSDavid E. O'Brien #define	LITTLE_ENDIAN	1234	/* LSB first: i386, vax */
55fa561e1eSDavid E. O'Brien #define	BIG_ENDIAN	4321	/* MSB first: 68000, ibm, net */
56fa561e1eSDavid E. O'Brien #define	PDP_ENDIAN	3412	/* LSB first in word, MSW first in long */
57fa561e1eSDavid E. O'Brien 
58fa561e1eSDavid E. O'Brien #define	BYTE_ORDER	BIG_ENDIAN
59fd8e4ebcSMike Barcroft #endif /* !_POSIX_SOURCE */
60fa561e1eSDavid E. O'Brien 
6103516cfeSMike Barcroft #ifndef _KERNEL
62fa561e1eSDavid E. O'Brien #include <sys/cdefs.h>
63fa561e1eSDavid E. O'Brien 
64fa561e1eSDavid E. O'Brien __BEGIN_DECLS
65fd8e4ebcSMike Barcroft __uint32_t	__htonl __P((__uint32_t));
66fd8e4ebcSMike Barcroft __uint16_t	__htons __P((__uint16_t));
67fd8e4ebcSMike Barcroft __uint32_t	__ntohl __P((__uint32_t));
68fd8e4ebcSMike Barcroft __uint16_t	__ntohs __P((__uint16_t));
69fa561e1eSDavid E. O'Brien __END_DECLS
70fd8e4ebcSMike Barcroft #endif /* _KERNEL */
71fa561e1eSDavid E. O'Brien 
72fd8e4ebcSMike Barcroft #define	__htonl(x)	(x)
73fd8e4ebcSMike Barcroft #define	__htons(x)	(x)
74fd8e4ebcSMike Barcroft #define	__ntohl(x)	(x)
75fd8e4ebcSMike Barcroft #define	__ntohs(x)	(x)
76fa561e1eSDavid E. O'Brien 
77fd8e4ebcSMike Barcroft #endif /* !_MACHINE_ENDIAN_H_ */
78