endian.h

Go to the documentation of this file.
00001 /*
00002  * Asterisk -- An open source telephony toolkit.
00003  *
00004  * Copyright (C) 1999 - 2005, Digium, Inc.
00005  *
00006  * Mark Spencer <markster@digium.com>
00007  *
00008  * See http://www.asterisk.org for more information about
00009  * the Asterisk project. Please do not directly contact
00010  * any of the maintainers of this project for assistance;
00011  * the project provides a web site, mailing lists and IRC
00012  * channels for your use.
00013  *
00014  * This program is free software, distributed under the terms of
00015  * the GNU General Public License Version 2. See the LICENSE file
00016  * at the top of the source tree.
00017  */
00018 
00019 /*! \file
00020  * \brief Asterisk architecture endianess compatibility definitions
00021  */
00022 
00023 #ifndef _ASTERISK_ENDIAN_H
00024 #define _ASTERISK_ENDIAN_H
00025 
00026 /*
00027  * Autodetect system endianess
00028  */
00029 
00030 
00031 #ifndef __BYTE_ORDER
00032 #ifdef __linux__
00033 #include <endian.h>
00034 #elif defined(__OpenBSD__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__APPLE__)
00035 #if defined(__OpenBSD__)
00036 #include "asterisk/compat.h"
00037 #endif
00038 #include <machine/endian.h>
00039 #define __BYTE_ORDER BYTE_ORDER
00040 #define __LITTLE_ENDIAN LITTLE_ENDIAN
00041 #define __BIG_ENDIAN BIG_ENDIAN
00042 #else
00043 
00044 #ifndef  __LITTLE_ENDIAN
00045 #define  __LITTLE_ENDIAN      1234
00046 #endif
00047 
00048 #ifndef  __BIG_ENDIAN
00049 #define  __BIG_ENDIAN      4321
00050 #endif
00051 
00052 #ifdef __LITTLE_ENDIAN__
00053 #define __BYTE_ORDER __LITTLE_ENDIAN
00054 #endif /* __LITTLE_ENDIAN */
00055 
00056 #if defined(i386) || defined(__i386__)
00057 #define __BYTE_ORDER __LITTLE_ENDIAN
00058 #endif /* defined i386 */
00059 
00060 #if defined(sun) && defined(unix) && defined(sparc)
00061 #define __BYTE_ORDER __BIG_ENDIAN
00062 #endif /* sun unix sparc */
00063 
00064 #endif /* linux */
00065 
00066 #endif /* __BYTE_ORDER */
00067 
00068 #ifndef __BYTE_ORDER
00069 #error Need to know endianess
00070 #endif /* __BYTE_ORDER */
00071 
00072 #endif /* _ASTERISK_ENDIAN_H */
00073 

Generated on Thu Apr 16 06:27:33 2015 for Asterisk - The Open Source Telephony Project by  doxygen 1.5.6