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. 21TARGET_OS(TARGET_OS_WIN32, Triple.isOSWindows()) 22TARGET_OS(TARGET_OS_WINDOWS, Triple.isOSWindows()) 23 24// Linux target. 25TARGET_OS(TARGET_OS_LINUX, Triple.isOSLinux()) 26 27// Unix target. 28TARGET_OS(TARGET_OS_UNIX, Triple.isOSNetBSD() || 29 Triple.isOSFreeBSD() || 30 Triple.isOSOpenBSD() || 31 Triple.isOSSolaris()) 32 33// Apple (Mac) targets. 34TARGET_OS(TARGET_OS_MAC, Triple.isOSDarwin()) 35TARGET_OS(TARGET_OS_OSX, Triple.isMacOSX()) 36TARGET_OS(TARGET_OS_IPHONE, Triple.isiOS() || Triple.isTvOS() || 37 Triple.isWatchOS() || Triple.isXROS()) 38// Triple::isiOS() also includes tvOS 39TARGET_OS(TARGET_OS_IOS, Triple.getOS() == llvm::Triple::IOS) 40TARGET_OS(TARGET_OS_TV, Triple.isTvOS()) 41TARGET_OS(TARGET_OS_WATCH, Triple.isWatchOS()) 42TARGET_OS(TARGET_OS_VISION, Triple.isXROS()) 43TARGET_OS(TARGET_OS_DRIVERKIT, Triple.isDriverKit()) 44TARGET_OS(TARGET_OS_MACCATALYST, Triple.isMacCatalystEnvironment()) 45TARGET_OS(TARGET_OS_SIMULATOR, Triple.isSimulatorEnvironment()) 46 47// Deprecated Apple target conditionals. 48TARGET_OS(TARGET_OS_EMBEDDED, (Triple.isiOS() || Triple.isTvOS() \ 49 || Triple.isWatchOS() || Triple.isXROS()) \ 50 && !Triple.isMacCatalystEnvironment() \ 51 && !Triple.isSimulatorEnvironment()) 52TARGET_OS(TARGET_OS_NANO, Triple.isWatchOS()) 53TARGET_OS(TARGET_IPHONE_SIMULATOR, Triple.isSimulatorEnvironment()) 54TARGET_OS(TARGET_OS_UIKITFORMAC, Triple.isMacCatalystEnvironment()) 55 56#undef TARGET_OS 57