[ASan/Win] Handle SEH exceptions (best-effort, similar to longjmp)
[blocksruntime.git] / lib / builtins / int_endianness.h
blobc465a985eeb6d7cf11edb45f0ceef3e9d2155356
1 /* ===-- int_endianness.h - configuration header for compiler-rt ------------===
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 compiler-rt.
11 * This file is not part of the interface of this library.
13 * ===----------------------------------------------------------------------===
16 #ifndef INT_ENDIANNESS_H
17 #define INT_ENDIANNESS_H
19 #if defined(__SVR4) && defined(__sun)
20 #include <sys/byteorder.h>
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 */
32 #endif /* Solaris and AuroraUX. */
34 /* .. */
36 #if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__DragonFly__) || defined(__minix)
37 #include <sys/endian.h>
39 #if _BYTE_ORDER == _BIG_ENDIAN
40 #define _YUGA_LITTLE_ENDIAN 0
41 #define _YUGA_BIG_ENDIAN 1
42 #elif _BYTE_ORDER == _LITTLE_ENDIAN
43 #define _YUGA_LITTLE_ENDIAN 1
44 #define _YUGA_BIG_ENDIAN 0
45 #endif /* _BYTE_ORDER */
47 #endif /* *BSD */
49 #if defined(__OpenBSD__) || defined(__Bitrig__)
50 #include <machine/endian.h>
52 #if _BYTE_ORDER == _BIG_ENDIAN
53 #define _YUGA_LITTLE_ENDIAN 0
54 #define _YUGA_BIG_ENDIAN 1
55 #elif _BYTE_ORDER == _LITTLE_ENDIAN
56 #define _YUGA_LITTLE_ENDIAN 1
57 #define _YUGA_BIG_ENDIAN 0
58 #endif /* _BYTE_ORDER */
60 #endif /* OpenBSD and Bitrig. */
62 /* .. */
64 /* Mac OSX has __BIG_ENDIAN__ or __LITTLE_ENDIAN__ automatically set by the compiler (at least with GCC) */
65 #if defined(__APPLE__) || defined(__ellcc__ )
67 #ifdef __BIG_ENDIAN__
68 #if __BIG_ENDIAN__
69 #define _YUGA_LITTLE_ENDIAN 0
70 #define _YUGA_BIG_ENDIAN 1
71 #endif
72 #endif /* __BIG_ENDIAN__ */
74 #ifdef __LITTLE_ENDIAN__
75 #if __LITTLE_ENDIAN__
76 #define _YUGA_LITTLE_ENDIAN 1
77 #define _YUGA_BIG_ENDIAN 0
78 #endif
79 #endif /* __LITTLE_ENDIAN__ */
81 #endif /* Mac OSX */
83 /* .. */
85 #if defined(__linux__)
86 #include <endian.h>
88 #if __BYTE_ORDER == __BIG_ENDIAN
89 #define _YUGA_LITTLE_ENDIAN 0
90 #define _YUGA_BIG_ENDIAN 1
91 #elif __BYTE_ORDER == __LITTLE_ENDIAN
92 #define _YUGA_LITTLE_ENDIAN 1
93 #define _YUGA_BIG_ENDIAN 0
94 #endif /* __BYTE_ORDER */
96 #endif /* GNU/Linux */
98 #if defined(_WIN32)
100 #define _YUGA_LITTLE_ENDIAN 1
101 #define _YUGA_BIG_ENDIAN 0
103 #endif /* Windows */
105 /* . */
107 #if !defined(_YUGA_LITTLE_ENDIAN) || !defined(_YUGA_BIG_ENDIAN)
108 #error Unable to determine endian
109 #endif /* Check we found an endianness correctly. */
111 #endif /* INT_ENDIANNESS_H */