2 * kmp_platform.h -- header for determining operating system and architecture
5 //===----------------------------------------------------------------------===//
7 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
8 // See https://llvm.org/LICENSE.txt for license information.
9 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
11 //===----------------------------------------------------------------------===//
13 #ifndef KMP_PLATFORM_H
14 #define KMP_PLATFORM_H
16 /* ---------------------- Operating system recognition ------------------- */
18 #define KMP_OS_LINUX 0
19 #define KMP_OS_DRAGONFLY 0
20 #define KMP_OS_FREEBSD 0
21 #define KMP_OS_NETBSD 0
22 #define KMP_OS_OPENBSD 0
23 #define KMP_OS_DARWIN 0
24 #define KMP_OS_WINDOWS 0
27 #define KMP_OS_UNIX 0 /* disjunction of KMP_OS_LINUX, KMP_OS_DARWIN etc. */
31 #define KMP_OS_WINDOWS 1
34 #if (defined __APPLE__ && defined __MACH__)
36 #define KMP_OS_DARWIN 1
39 // in some ppc64 linux installations, only the second condition is met
42 #define KMP_OS_LINUX 1
43 #elif (defined __linux__)
45 #define KMP_OS_LINUX 1
49 #if (defined __DragonFly__)
50 #undef KMP_OS_DRAGONFLY
51 #define KMP_OS_DRAGONFLY 1
54 #if (defined __FreeBSD__)
56 #define KMP_OS_FREEBSD 1
59 #if (defined __NetBSD__)
61 #define KMP_OS_NETBSD 1
64 #if (defined __OpenBSD__)
66 #define KMP_OS_OPENBSD 1
80 KMP_OS_LINUX + KMP_OS_DRAGONFLY + KMP_OS_FREEBSD + KMP_OS_NETBSD + \
81 KMP_OS_OPENBSD + KMP_OS_DARWIN + KMP_OS_WINDOWS + KMP_OS_HURD)
85 #if KMP_OS_LINUX || KMP_OS_DRAGONFLY || KMP_OS_FREEBSD || KMP_OS_NETBSD || \
86 KMP_OS_OPENBSD || KMP_OS_DARWIN || KMP_OS_HURD
91 /* ---------------------- Architecture recognition ------------------- */
93 #define KMP_ARCH_X86 0
94 #define KMP_ARCH_X86_64 0
95 #define KMP_ARCH_AARCH64 0
96 #define KMP_ARCH_PPC64_ELFv1 0
97 #define KMP_ARCH_PPC64_ELFv2 0
98 #define KMP_ARCH_PPC64 (KMP_ARCH_PPC64_ELFv2 || KMP_ARCH_PPC64_ELFv1)
99 #define KMP_ARCH_MIPS 0
100 #define KMP_ARCH_MIPS64 0
103 #if defined(_M_AMD64) || defined(__x86_64)
104 #undef KMP_ARCH_X86_64
105 #define KMP_ARCH_X86_64 1
108 #define KMP_ARCH_X86 1
114 #undef KMP_ARCH_X86_64
115 #define KMP_ARCH_X86_64 1
118 #define KMP_ARCH_X86 1
119 #elif defined __powerpc64__
120 #if defined(_CALL_ELF) && _CALL_ELF == 2
121 #undef KMP_ARCH_PPC64_ELFv2
122 #define KMP_ARCH_PPC64_ELFv2 1
124 #undef KMP_ARCH_PPC64_ELFv1
125 #define KMP_ARCH_PPC64_ELFv1 1
127 #elif defined __aarch64__
128 #undef KMP_ARCH_AARCH64
129 #define KMP_ARCH_AARCH64 1
130 #elif defined __mips__
132 #undef KMP_ARCH_MIPS64
133 #define KMP_ARCH_MIPS64 1
136 #define KMP_ARCH_MIPS 1
141 #if defined(__ARM_ARCH_7__) || defined(__ARM_ARCH_7R__) || \
142 defined(__ARM_ARCH_7A__)
143 #define KMP_ARCH_ARMV7 1
146 #if defined(KMP_ARCH_ARMV7) || defined(__ARM_ARCH_6__) || \
147 defined(__ARM_ARCH_6J__) || defined(__ARM_ARCH_6K__) || \
148 defined(__ARM_ARCH_6Z__) || defined(__ARM_ARCH_6T2__) || \
149 defined(__ARM_ARCH_6ZK__)
150 #define KMP_ARCH_ARMV6 1
153 #if defined(KMP_ARCH_ARMV6) || defined(__ARM_ARCH_5T__) || \
154 defined(__ARM_ARCH_5E__) || defined(__ARM_ARCH_5TE__) || \
155 defined(__ARM_ARCH_5TEJ__)
156 #define KMP_ARCH_ARMV5 1
159 #if defined(KMP_ARCH_ARMV5) || defined(__ARM_ARCH_4__) || \
160 defined(__ARM_ARCH_4T__)
161 #define KMP_ARCH_ARMV4 1
164 #if defined(KMP_ARCH_ARMV4) || defined(__ARM_ARCH_3__) || \
165 defined(__ARM_ARCH_3M__)
166 #define KMP_ARCH_ARMV3 1
169 #if defined(KMP_ARCH_ARMV3) || defined(__ARM_ARCH_2__)
170 #define KMP_ARCH_ARMV2 1
173 #if defined(KMP_ARCH_ARMV2)
174 #define KMP_ARCH_ARM 1
177 #if defined(__MIC__) || defined(__MIC2__)
179 #if __MIC2__ || __KNC__
192 /* Specify 32 bit architectures here */
193 #define KMP_32_BIT_ARCH (KMP_ARCH_X86 || KMP_ARCH_ARM || KMP_ARCH_MIPS)
195 // Platforms which support Intel(R) Many Integrated Core Architecture
196 #define KMP_MIC_SUPPORTED \
197 ((KMP_ARCH_X86 || KMP_ARCH_X86_64) && (KMP_OS_LINUX || KMP_OS_WINDOWS))
199 // TODO: Fixme - This is clever, but really fugly
201 KMP_ARCH_X86 + KMP_ARCH_X86_64 + KMP_ARCH_ARM + KMP_ARCH_PPC64 + \
202 KMP_ARCH_AARCH64 + KMP_ARCH_MIPS + KMP_ARCH_MIPS64)
203 #error Unknown or unsupported architecture
206 #endif // KMP_PLATFORM_H