1 | //===--- TargetOSMacros.def - Target OS macros ------------------*- C++ -*-===// |
2 | // |
3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
4 | // See https://llvm.org/LICENSE.txt for license information. |
5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
6 | // |
7 | //===----------------------------------------------------------------------===// |
8 | // |
9 | // This file specifies the predefined TARGET_OS_* conditional macros. |
10 | // A target macro `Name` should be defined if `Predicate` evaluates to true. |
11 | // The macro expects `const llvm::Triple &Triple` and the class `llvm::Triple` |
12 | // to be available for the predicate. |
13 | // |
14 | //===----------------------------------------------------------------------===// |
15 | |
16 | #ifndef TARGET_OS |
17 | #define TARGET_OS(Name, Predicate) |
18 | #endif |
19 | |
20 | // Windows targets. |
21 | TARGET_OS(TARGET_OS_WIN32, Triple.isOSWindows()) |
22 | TARGET_OS(TARGET_OS_WINDOWS, Triple.isOSWindows()) |
23 | |
24 | // Linux target. |
25 | TARGET_OS(TARGET_OS_LINUX, Triple.isOSLinux()) |
26 | |
27 | // Unix target. |
28 | TARGET_OS(TARGET_OS_UNIX, Triple.isOSNetBSD() || |
29 | Triple.isOSFreeBSD() || |
30 | Triple.isOSOpenBSD() || |
31 | Triple.isOSSolaris()) |
32 | |
33 | // Apple (Mac) targets. |
34 | TARGET_OS(TARGET_OS_MAC, Triple.isOSDarwin()) |
35 | TARGET_OS(TARGET_OS_OSX, Triple.isMacOSX()) |
36 | TARGET_OS(TARGET_OS_IPHONE, Triple.isiOS() || Triple.isTvOS() || |
37 | Triple.isWatchOS() || Triple.isXROS()) |
38 | // Triple::isiOS() also includes tvOS |
39 | TARGET_OS(TARGET_OS_IOS, Triple.getOS() == llvm::Triple::IOS) |
40 | TARGET_OS(TARGET_OS_TV, Triple.isTvOS()) |
41 | TARGET_OS(TARGET_OS_WATCH, Triple.isWatchOS()) |
42 | TARGET_OS(TARGET_OS_VISION, Triple.isXROS()) |
43 | TARGET_OS(TARGET_OS_DRIVERKIT, Triple.isDriverKit()) |
44 | TARGET_OS(TARGET_OS_MACCATALYST, Triple.isMacCatalystEnvironment()) |
45 | TARGET_OS(TARGET_OS_SIMULATOR, Triple.isSimulatorEnvironment()) |
46 | |
47 | // Deprecated Apple target conditionals. |
48 | TARGET_OS(TARGET_OS_EMBEDDED, (Triple.isiOS() || Triple.isTvOS() \ |
49 | || Triple.isWatchOS() || Triple.isXROS()) \ |
50 | && !Triple.isMacCatalystEnvironment() \ |
51 | && !Triple.isSimulatorEnvironment()) |
52 | TARGET_OS(TARGET_OS_NANO, Triple.isWatchOS()) |
53 | TARGET_OS(TARGET_IPHONE_SIMULATOR, Triple.isSimulatorEnvironment()) |
54 | TARGET_OS(TARGET_OS_UIKITFORMAC, Triple.isMacCatalystEnvironment()) |
55 | |
56 | #undef TARGET_OS |
57 | |