]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/compiler-rt/lib/builtins/int_endianness.h
MFV ntp 4.2.8p1 (r258945, r275970, r276091, r276092, r276093, r278284)
[FreeBSD/FreeBSD.git] / contrib / compiler-rt / lib / builtins / int_endianness.h
1 /* ===-- int_endianness.h - configuration header for compiler-rt ------------===
2  *
3  *                     The LLVM Compiler Infrastructure
4  *
5  * This file is dual licensed under the MIT and the University of Illinois Open
6  * Source Licenses. See LICENSE.TXT for details.
7  *
8  * ===----------------------------------------------------------------------===
9  *
10  * This file is a configuration header for compiler-rt.
11  * This file is not part of the interface of this library.
12  *
13  * ===----------------------------------------------------------------------===
14  */
15
16 #ifndef INT_ENDIANNESS_H
17 #define INT_ENDIANNESS_H
18
19 #if defined(__SVR4) && defined(__sun)
20 #include <sys/byteorder.h>
21
22 #if defined(_BIG_ENDIAN)
23 #define _YUGA_LITTLE_ENDIAN 0
24 #define _YUGA_BIG_ENDIAN    1
25 #elif defined(_LITTLE_ENDIAN)
26 #define _YUGA_LITTLE_ENDIAN 1
27 #define _YUGA_BIG_ENDIAN    0
28 #else /* !_LITTLE_ENDIAN */
29 #error "unknown endianness"
30 #endif /* !_LITTLE_ENDIAN */
31
32 #endif /* Solaris and AuroraUX. */
33
34 /* .. */
35
36 #if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__DragonFly__) ||   \
37     defined(__minix)
38 #include <sys/endian.h>
39
40 #if _BYTE_ORDER == _BIG_ENDIAN
41 #define _YUGA_LITTLE_ENDIAN 0
42 #define _YUGA_BIG_ENDIAN    1
43 #elif _BYTE_ORDER == _LITTLE_ENDIAN
44 #define _YUGA_LITTLE_ENDIAN 1
45 #define _YUGA_BIG_ENDIAN    0
46 #endif /* _BYTE_ORDER */
47
48 #endif /* *BSD */
49
50 #if defined(__OpenBSD__) || defined(__Bitrig__)
51 #include <machine/endian.h>
52
53 #if _BYTE_ORDER == _BIG_ENDIAN
54 #define _YUGA_LITTLE_ENDIAN 0
55 #define _YUGA_BIG_ENDIAN    1
56 #elif _BYTE_ORDER == _LITTLE_ENDIAN
57 #define _YUGA_LITTLE_ENDIAN 1
58 #define _YUGA_BIG_ENDIAN    0
59 #endif /* _BYTE_ORDER */
60
61 #endif /* OpenBSD and Bitrig. */
62
63 /* .. */
64
65 /* Mac OSX has __BIG_ENDIAN__ or __LITTLE_ENDIAN__ automatically set by the
66  * compiler (at least with GCC) */
67 #if defined(__APPLE__) || defined(__ellcc__ )
68
69 #ifdef __BIG_ENDIAN__
70 #if __BIG_ENDIAN__
71 #define _YUGA_LITTLE_ENDIAN 0
72 #define _YUGA_BIG_ENDIAN    1
73 #endif
74 #endif /* __BIG_ENDIAN__ */
75
76 #ifdef __LITTLE_ENDIAN__
77 #if __LITTLE_ENDIAN__
78 #define _YUGA_LITTLE_ENDIAN 1
79 #define _YUGA_BIG_ENDIAN    0
80 #endif
81 #endif /* __LITTLE_ENDIAN__ */
82
83 #endif /* Mac OSX */
84
85 /* .. */
86
87 #if defined(__linux__)
88
89 #if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
90 #define _YUGA_LITTLE_ENDIAN 0
91 #define _YUGA_BIG_ENDIAN    1
92 #elif __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
93 #define _YUGA_LITTLE_ENDIAN 1
94 #define _YUGA_BIG_ENDIAN    0
95 #endif /* __BYTE_ORDER__ */
96
97 #endif /* GNU/Linux */
98
99 #if defined(_WIN32)
100
101 #define _YUGA_LITTLE_ENDIAN 1
102 #define _YUGA_BIG_ENDIAN    0
103
104 #endif /* Windows */
105
106 /* . */
107
108 #if !defined(_YUGA_LITTLE_ENDIAN) || !defined(_YUGA_BIG_ENDIAN)
109 #error Unable to determine endian
110 #endif /* Check we found an endianness correctly. */
111
112 #endif /* INT_ENDIANNESS_H */