remaining endian.h fixes for FreeBSD (bug #3867)
[asterisk/asterisk.git] / include / asterisk / endian.h
1 /*
2  * Asterisk -- A telephony toolkit for Linux.
3  *
4  * Asterisk internal frame definitions.
5  * 
6  * Copyright (C) 1999 - 2005, Digium, Inc.
7  *
8  * Mark Spencer <markster@digium.com>
9  *
10  * This program is free software, distributed under the terms of
11  * the GNU Lesser General Public License.  Other components of
12  * Asterisk are distributed under The GNU General Public License
13  * only.
14  */
15
16 #ifndef _ASTERISK_ENDIAN_H
17 #define _ASTERISK_ENDIAN_H
18
19 /*
20  * Autodetect system endianess
21  */
22
23 #ifdef SOLARIS
24 #include "solaris-compat/compat.h"
25 #endif
26
27 #ifndef __BYTE_ORDER
28 #ifdef __linux__
29 #include <endian.h>
30 #elif defined(__OpenBSD__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__APPLE__)
31 #if defined(__OpenBSD__)
32 #include <machine/types.h>
33 #endif /* __OpenBSD__ */
34 #include <machine/endian.h>
35 #define __BYTE_ORDER BYTE_ORDER
36 #define __LITTLE_ENDIAN LITTLE_ENDIAN
37 #define __BIG_ENDIAN BIG_ENDIAN
38 #else
39 #ifdef __LITTLE_ENDIAN__
40 #define __BYTE_ORDER __LITTLE_ENDIAN
41 #endif /* __LITTLE_ENDIAN */
42
43 #if defined(i386) || defined(__i386__)
44 #define __BYTE_ORDER __LITTLE_ENDIAN
45 #endif /* defined i386 */
46
47 #if defined(sun) && defined(unix) && defined(sparc)
48 #define __BYTE_ORDER __BIG_ENDIAN
49 #endif /* sun unix sparc */
50
51 #endif /* linux */
52
53 #endif /* __BYTE_ORDER */
54
55 #ifndef __BYTE_ORDER
56 #error Need to know endianess
57 #endif /* __BYTE_ORDER */
58
59 #endif /* _ASTERISK_ENDIAN_H */
60