Asterisk - The Open Source Telephony Project  18.5.0
endian.h
Go to the documentation of this file.
1 /*
2  * Asterisk -- An open source telephony toolkit.
3  *
4  * Copyright (C) 1999 - 2005, Digium, Inc.
5  *
6  * Mark Spencer <[email protected]>
7  *
8  * See http://www.asterisk.org for more information about
9  * the Asterisk project. Please do not directly contact
10  * any of the maintainers of this project for assistance;
11  * the project provides a web site, mailing lists and IRC
12  * channels for your use.
13  *
14  * This program is free software, distributed under the terms of
15  * the GNU General Public License Version 2. See the LICENSE file
16  * at the top of the source tree.
17  */
18 
19 /*! \file
20  * \brief Asterisk architecture endianess compatibility definitions
21  */
22 
23 #ifndef _ASTERISK_ENDIAN_H
24 #define _ASTERISK_ENDIAN_H
25 
26 /*
27  * Autodetect system endianess
28  */
29 
30 
31 #ifndef __BYTE_ORDER
32 #ifdef __linux__
33 #include <endian.h>
34 #elif defined(__OpenBSD__) || defined(__FreeBSD__) || defined(__DragonFly__) || defined(__NetBSD__) || defined(__APPLE__)
35 #if defined(__OpenBSD__)
36 #include "asterisk/compat.h"
37 #endif
38 #include <machine/endian.h>
39 #define __BYTE_ORDER BYTE_ORDER
40 #define __LITTLE_ENDIAN LITTLE_ENDIAN
41 #define __BIG_ENDIAN BIG_ENDIAN
42 #else
43 
44 #ifndef __LITTLE_ENDIAN
45 #define __LITTLE_ENDIAN 1234
46 #endif
47 
48 #ifndef __BIG_ENDIAN
49 #define __BIG_ENDIAN 4321
50 #endif
51 
52 #ifdef __LITTLE_ENDIAN__
53 #define __BYTE_ORDER __LITTLE_ENDIAN
54 #endif /* __LITTLE_ENDIAN */
55 
56 #if defined(i386) || defined(__i386__)
57 #define __BYTE_ORDER __LITTLE_ENDIAN
58 #endif /* defined i386 */
59 
60 #if defined(sun) && defined(unix) && defined(sparc)
61 #define __BYTE_ORDER __BIG_ENDIAN
62 #endif /* sun unix sparc */
63 
64 #endif /* linux */
65 
66 #endif /* __BYTE_ORDER */
67 
68 #ifndef __BYTE_ORDER
69 #error Need to know endianess
70 #endif /* __BYTE_ORDER */
71 
72 #endif /* _ASTERISK_ENDIAN_H */
Asterisk architecture endianess compatibility definitions.
General Definitions for Asterisk top level program Included by asterisk.h to handle platform-specific...