Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / compiler-rt / test / builtins / Unit / endianness.h
blobe02ca8795b32fd99ff080003e19f0dcffd68a41b
1 #ifndef ENDIANNESS_H
2 #define ENDIANNESS_H
4 /*
5 * Known limitations:
6 * Middle endian systems are not handled currently.
7 */
9 #if defined(__SVR4) && defined(__sun)
10 #include <sys/byteorder.h>
12 #if _BYTE_ORDER == _BIG_ENDIAN
13 #define _YUGA_LITTLE_ENDIAN 0
14 #define _YUGA_BIG_ENDIAN 1
15 #elif _BYTE_ORDER == _LITTLE_ENDIAN
16 #define _YUGA_LITTLE_ENDIAN 1
17 #define _YUGA_BIG_ENDIAN 0
18 #endif /* _BYTE_ORDER */
20 #endif /* Solaris */
22 /* .. */
24 #if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__DragonflyBSD__) || defined(__minix)
25 #include <sys/endian.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 /* *BSD */
37 /* .. */
39 #if defined(__OpenBSD__)
40 #include <machine/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 */
50 #endif /* OpenBSD */
52 /* .. */
54 /* Mac OSX has __BIG_ENDIAN__ or __LITTLE_ENDIAN__ automatically set by the compiler (at least with GCC) */
55 #if defined(__APPLE__) && defined(__MACH__) || defined(__ellcc__ )
57 #ifdef __BIG_ENDIAN__
58 #if __BIG_ENDIAN__
59 #define _YUGA_LITTLE_ENDIAN 0
60 #define _YUGA_BIG_ENDIAN 1
61 #endif
62 #endif /* __BIG_ENDIAN__ */
64 #ifdef __LITTLE_ENDIAN__
65 #if __LITTLE_ENDIAN__
66 #define _YUGA_LITTLE_ENDIAN 1
67 #define _YUGA_BIG_ENDIAN 0
68 #endif
69 #endif /* __LITTLE_ENDIAN__ */
71 #endif /* Mac OSX */
73 /* .. */
75 #if defined(__linux__)
76 #include <endian.h>
78 #if __BYTE_ORDER == __BIG_ENDIAN
79 #define _YUGA_LITTLE_ENDIAN 0
80 #define _YUGA_BIG_ENDIAN 1
81 #elif __BYTE_ORDER == __LITTLE_ENDIAN
82 #define _YUGA_LITTLE_ENDIAN 1
83 #define _YUGA_BIG_ENDIAN 0
84 #endif /* __BYTE_ORDER */
86 #endif /* GNU/Linux */
88 /* . */
90 #if !defined(_YUGA_LITTLE_ENDIAN) || !defined(_YUGA_BIG_ENDIAN)
91 #error Unable to determine endian
92 #endif /* Check we found an endianness correctly. */
94 #endif /* ENDIANNESS_H */