1//===-- Target OS detection -------------------------------------*- 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#ifndef LLVM_LIBC_SRC___SUPPORT_MACROS_PROPERTIES_OS_H
9#define LLVM_LIBC_SRC___SUPPORT_MACROS_PROPERTIES_OS_H
10
11#if (defined(__freebsd__) || defined(__FreeBSD__))
12#define LIBC_TARGET_OS_IS_FREEBSD
13#endif
14
15#if defined(__ANDROID__)
16#define LIBC_TARGET_OS_IS_ANDROID
17#endif
18
19#if defined(__linux__) && !defined(LIBC_TARGET_OS_IS_FREEBSD) && \
20 !defined(LIBC_TARGET_OS_IS_ANDROID)
21#define LIBC_TARGET_OS_IS_LINUX
22#endif
23
24#if (defined(_WIN64) || defined(_WIN32))
25#define LIBC_TARGET_OS_IS_WINDOWS
26#endif
27
28#if (defined(__apple__) || defined(__APPLE__) || defined(__MACH__))
29// From https://stackoverflow.com/a/49560690
30#include "TargetConditionals.h"
31#if defined(TARGET_OS_OSX)
32#define LIBC_TARGET_OS_IS_MACOS
33#endif
34#if defined(TARGET_OS_IPHONE)
35// This is set for any non-Mac Apple products (IOS, TV, WATCH)
36#define LIBC_TARGET_OS_IS_IPHONE
37#endif
38#endif
39
40#if defined(__Fuchsia__)
41#define LIBC_TARGET_OS_IS_FUCHSIA
42#endif
43
44#endif // LLVM_LIBC_SRC___SUPPORT_MACROS_PROPERTIES_OS_H
45

source code of libc/src/__support/macros/properties/os.h