1// -*- C++ -*-
2//===----------------------------------------------------------------------===//
3//
4// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5// See https://llvm.org/LICENSE.txt for license information.
6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7//
8//===----------------------------------------------------------------------===//
9
10#ifndef _LIBCPP___CONFIGURATION_PLATFORM_H
11#define _LIBCPP___CONFIGURATION_PLATFORM_H
12
13#include <__config_site>
14
15#ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER
16# pragma GCC system_header
17#endif
18
19#if defined(__ELF__)
20# define _LIBCPP_OBJECT_FORMAT_ELF 1
21#elif defined(__MACH__)
22# define _LIBCPP_OBJECT_FORMAT_MACHO 1
23#elif defined(_WIN32)
24# define _LIBCPP_OBJECT_FORMAT_COFF 1
25#elif defined(__wasm__)
26# define _LIBCPP_OBJECT_FORMAT_WASM 1
27#elif defined(_AIX)
28# define _LIBCPP_OBJECT_FORMAT_XCOFF 1
29#else
30// ... add new file formats here ...
31#endif
32
33// Need to detect which libc we're using if we're on Linux.
34#if defined(__linux__) || defined(__AMDGPU__) || defined(__NVPTX__)
35# if __has_include(<features.h>)
36# include <features.h>
37# if defined(__GLIBC_PREREQ)
38# define _LIBCPP_GLIBC_PREREQ(a, b) __GLIBC_PREREQ(a, b)
39# else
40# define _LIBCPP_GLIBC_PREREQ(a, b) 0
41# endif // defined(__GLIBC_PREREQ)
42# endif
43#endif
44
45// This is required in order for _NEWLIB_VERSION to be defined in places where we use it.
46// TODO: We shouldn't be including arbitrarily-named headers from libc++ since this can break valid
47// user code. Move code paths that need _NEWLIB_VERSION to another customization mechanism.
48#if __has_include(<picolibc.h>)
49# include <picolibc.h>
50#endif
51
52#ifndef __BYTE_ORDER__
53# error \
54 "Your compiler doesn't seem to define __BYTE_ORDER__, which is required by libc++ to know the endianness of your target platform"
55#endif
56
57#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
58# define _LIBCPP_LITTLE_ENDIAN
59#elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
60# define _LIBCPP_BIG_ENDIAN
61#endif // __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
62
63#endif // _LIBCPP___CONFIGURATION_PLATFORM_H
64