// Copyright 2021 The Fuchsia Authors // // Use of this source code is governed by a MIT-style // license that can be found in the LICENSE file or at // https://opensource.org/licenses/MIT #ifndef ZIRCON_KERNEL_LIB_KTL_INCLUDE___CONFIG_SITE_ #define ZIRCON_KERNEL_LIB_KTL_INCLUDE___CONFIG_SITE_ // The libc++ internal header <__config> does #include <__config_site> to get // definitions that vary by operating system, machine, or configuration. The // toolchain's libc++ installation provides include/$triple/.../__config_site // files for each $cpu-fuchsia appropriate for normal userland. But the ktl // abuse of libc++ is different from public userland libc++, so provide special // kernel-appropriate definitions here. This file will be in the include path // ahead of any toolchain-supplied header. Also, some special bare-metal build // environments such as phys32 or efi that reuse ktl and kernel libc code may // use settings that cause the compiler to change the $triple it injects into // the include path to one for which no runtimes are built and so there is no // __config_site file to be found at all. // These two are what <__config_site> for Fuchsia userland defines. #define _LIBCPP_ABI_VERSION 2 #define _LIBCPP_HAS_NO_VENDOR_AVAILABILITY_ANNOTATIONS 1 // This has to be defined to some `__*` string but what doesn't really matter. #define _LIBCPP_ABI_NAMESPACE __ktl // When compiling in the UEFI environment, the predefines look like Windows // but there is no Windows runtime environment to use. #define _LIBCPP_NO_VCRUNTIME 1 // This tells the headers not to use `extern template` declarations that // expect specific instantiations/specializations to come from the libc++ // library rather than the headers. In the kernel, only the headers are // ever going to be available. #define _LIBCPP_DISABLE_EXTERN_TEMPLATE 1 // This tells not to use threading APIs. #define _LIBCPP_HAS_NO_PLATFORM_WAIT 1 // This tells et al to use <__external_threading> instead // of expecting either POSIX or C11 threading APIs. #define _LIBCPP_HAS_THREAD_API_EXTERNAL 1 #define _LIBCPP_HAS_THREAD_LIBRARY_EXTERNAL 1 // <__config> requires that these be set if _LIBCPP_HAS_THREAD_API_EXTERNAL is. #define _LIBCPP_HAS_THREADS 1 #define _LIBCPP_HAS_MONOTONIC_CLOCK 1 // This tells not to use `aligned_alloc` from . #define _LIBCPP_HAS_NO_C11_ALIGNED_ALLOC 1 // This tells various headers to be strict about what includes what. #define _LIBCPP_REMOVE_TRANSITIVE_INCLUDES 1 // This tells libc++ not to expect full locale APIs in some places. #define _LIBCPP_HAS_NO_LOCALIZATION 1 // This is unfortunately required even though the kernel does not use wide // characters. #define _LIBCPP_HAS_WIDE_CHARACTERS 1 // This tells pstl headers to use serial algorithms and not try to // do any multithreading. #define _LIBCPP_PSTL_CPU_BACKEND_SERIAL 1 // This will probably never be used in code that ktl actually uses. // But define it for completeness. #define _LIBCPP_INSTRUMENTED_WITH_ASAN __has_feature(address_sanitizer) // TODO(https://fxbug.dev/42082322): make the hardening mode selectable through build // configurations. // This sets the default to tell libc++ to not enable assertions to prevent // undefined behavior, but may be overridden if _LIBCPP_HARDENING_MODE is // defined elsewhere. #define _LIBCPP_HARDENING_MODE_DEFAULT _LIBCPP_HARDENING_MODE_NONE #define _LIBCPP_ASSERTION_SEMANTIC_DEFAULT _LIBCPP_ASSERTION_SEMANTIC_HARDENING_DEPENDENT #endif // ZIRCON_KERNEL_LIB_KTL_INCLUDE___CONFIG_SITE_