]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - runtime/src/kmp_platform.h
Vendor import of LLVM openmp trunk r351319 (just before the release_80
[FreeBSD/FreeBSD.git] / runtime / src / kmp_platform.h
1 /*
2  * kmp_platform.h -- header for determining operating system and architecture
3  */
4
5 //===----------------------------------------------------------------------===//
6 //
7 //                     The LLVM Compiler Infrastructure
8 //
9 // This file is dual licensed under the MIT and the University of Illinois Open
10 // Source Licenses. See LICENSE.txt for details.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #ifndef KMP_PLATFORM_H
15 #define KMP_PLATFORM_H
16
17 /* ---------------------- Operating system recognition ------------------- */
18
19 #define KMP_OS_LINUX 0
20 #define KMP_OS_DRAGONFLY 0
21 #define KMP_OS_FREEBSD 0
22 #define KMP_OS_NETBSD 0
23 #define KMP_OS_OPENBSD 0
24 #define KMP_OS_DARWIN 0
25 #define KMP_OS_WINDOWS 0
26 #define KMP_OS_CNK 0
27 #define KMP_OS_HURD 0
28 #define KMP_OS_UNIX 0 /* disjunction of KMP_OS_LINUX, KMP_OS_DARWIN etc. */
29
30 #ifdef _WIN32
31 #undef KMP_OS_WINDOWS
32 #define KMP_OS_WINDOWS 1
33 #endif
34
35 #if (defined __APPLE__ && defined __MACH__)
36 #undef KMP_OS_DARWIN
37 #define KMP_OS_DARWIN 1
38 #endif
39
40 // in some ppc64 linux installations, only the second condition is met
41 #if (defined __linux)
42 #undef KMP_OS_LINUX
43 #define KMP_OS_LINUX 1
44 #elif (defined __linux__)
45 #undef KMP_OS_LINUX
46 #define KMP_OS_LINUX 1
47 #else
48 #endif
49
50 #if (defined __DragonFly__)
51 #undef KMP_OS_DRAGONFLY
52 #define KMP_OS_DRAGONFLY 1
53 #endif
54
55 #if (defined __FreeBSD__)
56 #undef KMP_OS_FREEBSD
57 #define KMP_OS_FREEBSD 1
58 #endif
59
60 #if (defined __NetBSD__)
61 #undef KMP_OS_NETBSD
62 #define KMP_OS_NETBSD 1
63 #endif
64
65 #if (defined __OpenBSD__)
66 #undef KMP_OS_OPENBSD
67 #define KMP_OS_OPENBSD 1
68 #endif
69
70 #if (defined __bgq__)
71 #undef KMP_OS_CNK
72 #define KMP_OS_CNK 1
73 #endif
74
75 #if (defined __GNU__)
76 #undef KMP_OS_HURD
77 #define KMP_OS_HURD 1
78 #endif
79
80 #if (1 !=                                                                      \
81      KMP_OS_LINUX + KMP_OS_DRAGONFLY + KMP_OS_FREEBSD + KMP_OS_NETBSD +        \
82          KMP_OS_OPENBSD + KMP_OS_DARWIN + KMP_OS_WINDOWS + KMP_OS_HURD)
83 #error Unknown OS
84 #endif
85
86 #if KMP_OS_LINUX || KMP_OS_DRAGONFLY || KMP_OS_FREEBSD || KMP_OS_NETBSD ||     \
87         KMP_OS_OPENBSD || KMP_OS_DARWIN || KMP_OS_HURD
88 #undef KMP_OS_UNIX
89 #define KMP_OS_UNIX 1
90 #endif
91
92 /* ---------------------- Architecture recognition ------------------- */
93
94 #define KMP_ARCH_X86 0
95 #define KMP_ARCH_X86_64 0
96 #define KMP_ARCH_AARCH64 0
97 #define KMP_ARCH_PPC64_BE 0
98 #define KMP_ARCH_PPC64_LE 0
99 #define KMP_ARCH_PPC64 (KMP_ARCH_PPC64_LE || KMP_ARCH_PPC64_BE)
100 #define KMP_ARCH_MIPS 0
101 #define KMP_ARCH_MIPS64 0
102
103 #if KMP_OS_WINDOWS
104 #if defined(_M_AMD64) || defined(__x86_64)
105 #undef KMP_ARCH_X86_64
106 #define KMP_ARCH_X86_64 1
107 #else
108 #undef KMP_ARCH_X86
109 #define KMP_ARCH_X86 1
110 #endif
111 #endif
112
113 #if KMP_OS_UNIX
114 #if defined __x86_64
115 #undef KMP_ARCH_X86_64
116 #define KMP_ARCH_X86_64 1
117 #elif defined __i386
118 #undef KMP_ARCH_X86
119 #define KMP_ARCH_X86 1
120 #elif defined __powerpc64__
121 #if defined __LITTLE_ENDIAN__
122 #undef KMP_ARCH_PPC64_LE
123 #define KMP_ARCH_PPC64_LE 1
124 #else
125 #undef KMP_ARCH_PPC64_BE
126 #define KMP_ARCH_PPC64_BE 1
127 #endif
128 #elif defined __aarch64__
129 #undef KMP_ARCH_AARCH64
130 #define KMP_ARCH_AARCH64 1
131 #elif defined __mips__
132 #if defined __mips64
133 #undef KMP_ARCH_MIPS64
134 #define KMP_ARCH_MIPS64 1
135 #else
136 #undef KMP_ARCH_MIPS
137 #define KMP_ARCH_MIPS 1
138 #endif
139 #endif
140 #endif
141
142 #if defined(__ARM_ARCH_7__) || defined(__ARM_ARCH_7R__) ||                     \
143     defined(__ARM_ARCH_7A__)
144 #define KMP_ARCH_ARMV7 1
145 #endif
146
147 #if defined(KMP_ARCH_ARMV7) || defined(__ARM_ARCH_6__) ||                      \
148     defined(__ARM_ARCH_6J__) || defined(__ARM_ARCH_6K__) ||                    \
149     defined(__ARM_ARCH_6Z__) || defined(__ARM_ARCH_6T2__) ||                   \
150     defined(__ARM_ARCH_6ZK__)
151 #define KMP_ARCH_ARMV6 1
152 #endif
153
154 #if defined(KMP_ARCH_ARMV6) || defined(__ARM_ARCH_5T__) ||                     \
155     defined(__ARM_ARCH_5E__) || defined(__ARM_ARCH_5TE__) ||                   \
156     defined(__ARM_ARCH_5TEJ__)
157 #define KMP_ARCH_ARMV5 1
158 #endif
159
160 #if defined(KMP_ARCH_ARMV5) || defined(__ARM_ARCH_4__) ||                      \
161     defined(__ARM_ARCH_4T__)
162 #define KMP_ARCH_ARMV4 1
163 #endif
164
165 #if defined(KMP_ARCH_ARMV4) || defined(__ARM_ARCH_3__) ||                      \
166     defined(__ARM_ARCH_3M__)
167 #define KMP_ARCH_ARMV3 1
168 #endif
169
170 #if defined(KMP_ARCH_ARMV3) || defined(__ARM_ARCH_2__)
171 #define KMP_ARCH_ARMV2 1
172 #endif
173
174 #if defined(KMP_ARCH_ARMV2)
175 #define KMP_ARCH_ARM 1
176 #endif
177
178 #if defined(__MIC__) || defined(__MIC2__)
179 #define KMP_MIC 1
180 #if __MIC2__ || __KNC__
181 #define KMP_MIC1 0
182 #define KMP_MIC2 1
183 #else
184 #define KMP_MIC1 1
185 #define KMP_MIC2 0
186 #endif
187 #else
188 #define KMP_MIC 0
189 #define KMP_MIC1 0
190 #define KMP_MIC2 0
191 #endif
192
193 /* Specify 32 bit architectures here */
194 #define KMP_32_BIT_ARCH (KMP_ARCH_X86 || KMP_ARCH_ARM || KMP_ARCH_MIPS)
195
196 // Platforms which support Intel(R) Many Integrated Core Architecture
197 #define KMP_MIC_SUPPORTED                                                      \
198   ((KMP_ARCH_X86 || KMP_ARCH_X86_64) && (KMP_OS_LINUX || KMP_OS_WINDOWS))
199
200 // TODO: Fixme - This is clever, but really fugly
201 #if (1 !=                                                                      \
202      KMP_ARCH_X86 + KMP_ARCH_X86_64 + KMP_ARCH_ARM + KMP_ARCH_PPC64 +          \
203          KMP_ARCH_AARCH64 + KMP_ARCH_MIPS + KMP_ARCH_MIPS64)
204 #error Unknown or unsupported architecture
205 #endif
206
207 #endif // KMP_PLATFORM_H