0.9.8.10
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
endian-c.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2007-2015 Hypertable, Inc.
3  *
4  * This file is part of Hypertable.
5  *
6  * Hypertable is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 3
9  * of the License, or any later version.
10  *
11  * Hypertable is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19  * 02110-1301, USA.
20  */
21 
27 #ifndef HT_ENDIAN_C_H
28 #define HT_ENDIAN_C_H
29 
30 /* GNU libc offers the helpful header <endian.h> which defines __BYTE_ORDER */
31 #if defined (__GLIBC__)
32 # include <endian.h>
33 # if (__BYTE_ORDER == __LITTLE_ENDIAN)
34 # define HT_LITTLE_ENDIAN
35 # elif (__BYTE_ORDER == __BIG_ENDIAN)
36 # define HT_BIG_ENDIAN
37 # elif (__BYTE_ORDER == __PDP_ENDIAN)
38 # define HT_PDP_ENDIAN
39 # else
40 # error Unknown machine endianness detected.
41 # endif
42 # define HT_BYTE_ORDER __BYTE_ORDER
43 #elif defined(__sparc) || defined(__sparc__) \
44  || defined(_POWER) || defined(__powerpc__) \
45  || defined(__ppc__) || defined(__hpux) \
46  || defined(_MIPSEB) || defined(_POWER) \
47  || defined(__s390__)
48 # define HT_BIG_ENDIAN
49 # define HT_BYTE_ORDER 4321
50 #elif defined(__i386__) || defined(__alpha__) \
51  || defined(__ia64) || defined(__ia64__) \
52  || defined(_M_IX86) || defined(_M_IA64) \
53  || defined(_M_ALPHA) || defined(__amd64) \
54  || defined(__amd64__) || defined(_M_AMD64) \
55  || defined(__x86_64) || defined(__x86_64__) \
56  || defined(_M_X64)
57 
58 # define HT_LITTLE_ENDIAN
59 # define HT_BYTE_ORDER 1234
60 #else
61 # error The file Common/endian.h needs to be set up for your CPU type.
62 #endif
63 
64 #endif /* HT_ENDIAN_C_H */