1 /* ===-- endianness.h - configuration header for libgcc replacement --------===
3 * The LLVM Compiler Infrastructure
5 * This file is dual licensed under the MIT and the University of Illinois Open
6 * Source Licenses. See LICENSE.TXT for details.
8 * ===----------------------------------------------------------------------===
10 * This file is a configuration header for libgcc replacement.
11 * This file is not part of the interface of this library.
13 * ===----------------------------------------------------------------------===
21 * Middle endian systems are not handled currently.
24 #if defined(__SVR4) && defined(__sun)
25 #include <sys/byteorder.h>
27 #if _BYTE_ORDER == _BIG_ENDIAN
28 #define _YUGA_LITTLE_ENDIAN 0
29 #define _YUGA_BIG_ENDIAN 1
30 #elif _BYTE_ORDER == _LITTLE_ENDIAN
31 #define _YUGA_LITTLE_ENDIAN 1
32 #define _YUGA_BIG_ENDIAN 0
33 #endif /* _BYTE_ORDER */
35 #endif /* Solaris and AuroraUX. */
39 #if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__DragonflyBSD__) || defined(__minix)
40 #include <sys/endian.h>
42 #if _BYTE_ORDER == _BIG_ENDIAN
43 #define _YUGA_LITTLE_ENDIAN 0
44 #define _YUGA_BIG_ENDIAN 1
45 #elif _BYTE_ORDER == _LITTLE_ENDIAN
46 #define _YUGA_LITTLE_ENDIAN 1
47 #define _YUGA_BIG_ENDIAN 0
48 #endif /* _BYTE_ORDER */
54 #if defined(__OpenBSD__) || defined(__Bitrig__)
55 #include <machine/endian.h>
57 #if _BYTE_ORDER == _BIG_ENDIAN
58 #define _YUGA_LITTLE_ENDIAN 0
59 #define _YUGA_BIG_ENDIAN 1
60 #elif _BYTE_ORDER == _LITTLE_ENDIAN
61 #define _YUGA_LITTLE_ENDIAN 1
62 #define _YUGA_BIG_ENDIAN 0
63 #endif /* _BYTE_ORDER */
65 #endif /* OpenBSD and Bitrig. */
69 /* Mac OSX has __BIG_ENDIAN__ or __LITTLE_ENDIAN__ automatically set by the compiler (at least with GCC) */
70 #if defined(__APPLE__) && defined(__MACH__) || defined(__ellcc__ )
74 #define _YUGA_LITTLE_ENDIAN 0
75 #define _YUGA_BIG_ENDIAN 1
77 #endif /* __BIG_ENDIAN__ */
79 #ifdef __LITTLE_ENDIAN__
81 #define _YUGA_LITTLE_ENDIAN 1
82 #define _YUGA_BIG_ENDIAN 0
84 #endif /* __LITTLE_ENDIAN__ */
90 #if defined(__linux__)
93 #if __BYTE_ORDER == __BIG_ENDIAN
94 #define _YUGA_LITTLE_ENDIAN 0
95 #define _YUGA_BIG_ENDIAN 1
96 #elif __BYTE_ORDER == __LITTLE_ENDIAN
97 #define _YUGA_LITTLE_ENDIAN 1
98 #define _YUGA_BIG_ENDIAN 0
99 #endif /* __BYTE_ORDER */
101 #endif /* GNU/Linux */
105 #if !defined(_YUGA_LITTLE_ENDIAN) || !defined(_YUGA_BIG_ENDIAN)
106 #error Unable to determine endian
107 #endif /* Check we found an endianness correctly. */
109 #endif /* ENDIANNESS_H */