Index: libcxx/CMakeLists.txt =================================================================== --- libcxx/CMakeLists.txt +++ libcxx/CMakeLists.txt @@ -101,59 +101,71 @@ to provide compile-time errors when using features unavailable on some version of the shared library they shipped should turn this on and see `include/__availability` for more details." OFF) - -if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") - set(LIBCXX_DEFAULT_TEST_CONFIG "llvm-libc++-shared-gcc.cfg.in") -elseif(MINGW) - set(LIBCXX_DEFAULT_TEST_CONFIG "llvm-libc++-mingw.cfg.in") -elseif(WIN32) # clang-cl - if (LIBCXX_ENABLE_SHARED) - set(LIBCXX_DEFAULT_TEST_CONFIG "llvm-libc++-shared-clangcl.cfg.in") - else() - set(LIBCXX_DEFAULT_TEST_CONFIG "llvm-libc++-static-clangcl.cfg.in") - endif() +option(LIBCXX_FREESTANDING OFF + "Build libc++ with freestanding headers. This toggle allows the libc to work for + freestanding environments like operating systems kernels or embedded systems.") + +if (LIBCXX_FREESTANDING) + set(LIBCXX_ENABLE_FILESYSTEM OFF) + set(LIBCXX_ENABLE_SHARED OFF) + set(LIBCXX_ENABLE_STATIC OFF) + set(CMAKE_C_COMPILER_WORKS ON) + set(CMAKE_CXX_COMPILER_WORKS ON) + set(LIBCXX_ENABLE_LOCALIZATION OFF) else() - if (LIBCXX_ENABLE_SHARED) - set(LIBCXX_DEFAULT_TEST_CONFIG "llvm-libc++-shared.cfg.in") + if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") + set(LIBCXX_DEFAULT_TEST_CONFIG "llvm-libc++-shared-gcc.cfg.in") + elseif(MINGW) + set(LIBCXX_DEFAULT_TEST_CONFIG "llvm-libc++-mingw.cfg.in") + elseif(WIN32) # clang-cl + if (LIBCXX_ENABLE_SHARED) + set(LIBCXX_DEFAULT_TEST_CONFIG "llvm-libc++-shared-clangcl.cfg.in") + else() + set(LIBCXX_DEFAULT_TEST_CONFIG "llvm-libc++-static-clangcl.cfg.in") + endif() else() - set(LIBCXX_DEFAULT_TEST_CONFIG "llvm-libc++-static.cfg.in") + if (LIBCXX_ENABLE_SHARED) + set(LIBCXX_DEFAULT_TEST_CONFIG "llvm-libc++-shared.cfg.in") + else() + set(LIBCXX_DEFAULT_TEST_CONFIG "llvm-libc++-static.cfg.in") + endif() endif() -endif() -set(LIBCXX_TEST_CONFIG "${LIBCXX_DEFAULT_TEST_CONFIG}" CACHE STRING - "The path to the Lit testing configuration to use when running the tests. - If a relative path is provided, it is assumed to be relative to '/libcxx/test/configs'.") -if (NOT IS_ABSOLUTE "${LIBCXX_TEST_CONFIG}") - set(LIBCXX_TEST_CONFIG "${CMAKE_CURRENT_SOURCE_DIR}/test/configs/${LIBCXX_TEST_CONFIG}") -endif() -message(STATUS "Using libc++ testing configuration: ${LIBCXX_TEST_CONFIG}") -set(LIBCXX_TEST_PARAMS "" CACHE STRING - "A list of parameters to run the Lit test suite with.") - -# Benchmark options ----------------------------------------------------------- -option(LIBCXX_INCLUDE_BENCHMARKS "Build the libc++ benchmarks and their dependencies" ON) - -set(LIBCXX_BENCHMARK_TEST_ARGS_DEFAULT --benchmark_min_time=0.01) -set(LIBCXX_BENCHMARK_TEST_ARGS "${LIBCXX_BENCHMARK_TEST_ARGS_DEFAULT}" CACHE STRING - "Arguments to pass when running the benchmarks using check-cxx-benchmarks") - -set(LIBCXX_BENCHMARK_NATIVE_STDLIB "" CACHE STRING - "Build the benchmarks against the specified native STL. - The value must be one of libc++/libstdc++") -set(LIBCXX_BENCHMARK_NATIVE_GCC_TOOLCHAIN "" CACHE STRING - "Use alternate GCC toolchain when building the native benchmarks") - -if (LIBCXX_BENCHMARK_NATIVE_STDLIB) - if (NOT (LIBCXX_BENCHMARK_NATIVE_STDLIB STREQUAL "libc++" - OR LIBCXX_BENCHMARK_NATIVE_STDLIB STREQUAL "libstdc++")) - message(FATAL_ERROR "Invalid value for LIBCXX_BENCHMARK_NATIVE_STDLIB: " - "'${LIBCXX_BENCHMARK_NATIVE_STDLIB}'") + set(LIBCXX_TEST_CONFIG "${LIBCXX_DEFAULT_TEST_CONFIG}" CACHE STRING + "The path to the Lit testing configuration to use when running the tests. + If a relative path is provided, it is assumed to be relative to '/libcxx/test/configs'.") + if (NOT IS_ABSOLUTE "${LIBCXX_TEST_CONFIG}") + set(LIBCXX_TEST_CONFIG "${CMAKE_CURRENT_SOURCE_DIR}/test/configs/${LIBCXX_TEST_CONFIG}") + endif() + message(STATUS "Using libc++ testing configuration: ${LIBCXX_TEST_CONFIG}") + set(LIBCXX_TEST_PARAMS "" CACHE STRING + "A list of parameters to run the Lit test suite with.") + + # Benchmark options ----------------------------------------------------------- + option(LIBCXX_INCLUDE_BENCHMARKS "Build the libc++ benchmarks and their dependencies" ON) + + set(LIBCXX_BENCHMARK_TEST_ARGS_DEFAULT --benchmark_min_time=0.01) + set(LIBCXX_BENCHMARK_TEST_ARGS "${LIBCXX_BENCHMARK_TEST_ARGS_DEFAULT}" CACHE STRING + "Arguments to pass when running the benchmarks using check-cxx-benchmarks") + + set(LIBCXX_BENCHMARK_NATIVE_STDLIB "" CACHE STRING + "Build the benchmarks against the specified native STL. + The value must be one of libc++/libstdc++") + set(LIBCXX_BENCHMARK_NATIVE_GCC_TOOLCHAIN "" CACHE STRING + "Use alternate GCC toolchain when building the native benchmarks") + + if (LIBCXX_BENCHMARK_NATIVE_STDLIB) + if (NOT (LIBCXX_BENCHMARK_NATIVE_STDLIB STREQUAL "libc++" + OR LIBCXX_BENCHMARK_NATIVE_STDLIB STREQUAL "libstdc++")) + message(FATAL_ERROR "Invalid value for LIBCXX_BENCHMARK_NATIVE_STDLIB: " + "'${LIBCXX_BENCHMARK_NATIVE_STDLIB}'") + endif() endif() endif() - option(LIBCXX_INCLUDE_DOCS "Build the libc++ documentation." ${LLVM_INCLUDE_DOCS}) set(LIBCXX_LIBDIR_SUFFIX "${LLVM_LIBDIR_SUFFIX}" CACHE STRING "Define suffix of library directory name (32/64)") option(LIBCXX_INSTALL_HEADERS "Install the libc++ headers." ON) +if(NOT LIBCXX_FREESTANDING) option(LIBCXX_INSTALL_LIBRARY "Install the libc++ library." ON) cmake_dependent_option(LIBCXX_INSTALL_STATIC_LIBRARY "Install the static libc++ library." ON @@ -161,6 +173,7 @@ cmake_dependent_option(LIBCXX_INSTALL_SHARED_LIBRARY "Install the shared libc++ library." ON "LIBCXX_ENABLE_SHARED;LIBCXX_INSTALL_LIBRARY" OFF) +endif() option(LIBCXX_ABI_UNSTABLE "Use the unstable ABI of libc++. This is equivalent to specifying LIBCXX_ABI_VERSION=n, where n is the not-yet-stable version." OFF) if (LIBCXX_ABI_UNSTABLE) @@ -299,6 +312,11 @@ set(LIBCXX_COVERAGE_LIBRARY "" CACHE STRING "The Profile-rt library used to build with code coverage") +if (LIBCXX_FREESTANDING) +set(LIBCXX_ENABLE_THREADS OFF) +set(LIBCXX_ENABLE_MONOTONIC_CLOCK OFF) +endif() + set(LIBCXX_CONFIGURE_IDE_DEFAULT OFF) if (XCODE OR MSVC_IDE) set(LIBCXX_CONFIGURE_IDE_DEFAULT ON) @@ -319,6 +337,7 @@ # Ensure LIBCXX_ENABLE_MONOTONIC_CLOCK is set to ON only when # LIBCXX_ENABLE_THREADS is on. +if (NOT LIBCXX_FREESTANDING) if(LIBCXX_ENABLE_THREADS AND NOT LIBCXX_ENABLE_MONOTONIC_CLOCK) message(FATAL_ERROR "LIBCXX_ENABLE_MONOTONIC_CLOCK can only be set to OFF" " when LIBCXX_ENABLE_THREADS is also set to OFF.") @@ -341,7 +360,6 @@ message(FATAL_ERROR "LIBCXX_HAS_WIN32_THREAD_API can only be set to ON" " when LIBCXX_ENABLE_THREADS is also set to ON.") endif() - endif() if (LIBCXX_HAS_EXTERNAL_THREAD_API) @@ -394,7 +412,7 @@ if (LIBCXX_ABI_FORCE_ITANIUM AND LIBCXX_ABI_FORCE_MICROSOFT) message(FATAL_ERROR "Only one of LIBCXX_ABI_FORCE_ITANIUM and LIBCXX_ABI_FORCE_MICROSOFT can be specified.") endif () - +endif () #=============================================================================== # Configure System #=============================================================================== @@ -745,7 +763,7 @@ # default libunwind (which may be missing still). target_add_link_flags_if_supported(${target} PRIVATE "--unwindlib=none") endif() - + if (NOT LIBCXX_FREESTANDING) if (LIBCXX_HAS_SYSTEM_LIB) target_link_libraries(${target} PRIVATE System) endif() @@ -799,12 +817,12 @@ # Required for standards-complaint wide character formatting functions # (e.g. `printfw`/`scanfw`) target_link_libraries(${target} PRIVATE iso_stdio_wide_specifiers) - endif() - + endif() if (ANDROID AND ANDROID_PLATFORM_LEVEL LESS 21) target_link_libraries(${target} PUBLIC android_support) endif() target_link_libraries(${target} PUBLIC "${LIBCXX_ADDITIONAL_LIBRARIES}") + endif() endfunction() # Windows-related flags ======================================================= @@ -870,6 +888,10 @@ config_define(0 _LIBCPP_ENABLE_ASSERTIONS_DEFAULT) endif() +if (LIBCXX_FREESTANDING) + config_define(LIBCXX_FREESTANDING _LIBCPP_FREESTANDING) +endif() + if (LIBCXX_ABI_DEFINES) set(abi_defines) foreach (abi_define ${LIBCXX_ABI_DEFINES}) @@ -922,6 +944,7 @@ # Setup Source Code And Tests #=============================================================================== add_subdirectory(include) +if (NOT LIBCXX_FREESTANDING) add_subdirectory(src) add_subdirectory(utils) @@ -939,6 +962,7 @@ add_subdirectory(test) add_subdirectory(lib/abi) endif() +endif() if (LIBCXX_INCLUDE_DOCS) add_subdirectory(docs) Index: libcxx/include/__compare/strong_order.h =================================================================== --- libcxx/include/__compare/strong_order.h +++ libcxx/include/__compare/strong_order.h @@ -16,7 +16,7 @@ #include <__utility/forward.h> #include <__utility/priority_tag.h> #ifndef _LIBCPP_FREESTANDING -#include +# include #endif #include #include @@ -43,7 +43,7 @@ noexcept(noexcept(strong_ordering(strong_order(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u))))) -> decltype( strong_ordering(strong_order(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u)))) { return strong_ordering(strong_order(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u))); } -#ifndef _LIBCPP_FREESTANDING +# ifndef _LIBCPP_FREESTANDING template> requires is_same_v<_Dp, decay_t<_Up>> && is_floating_point_v<_Dp> _LIBCPP_HIDE_FROM_ABI static constexpr strong_ordering @@ -108,7 +108,7 @@ } } } -#endif +# endif template requires is_same_v, decay_t<_Up>> _LIBCPP_HIDE_FROM_ABI static constexpr auto Index: libcxx/include/__compare/weak_order.h =================================================================== --- libcxx/include/__compare/weak_order.h +++ libcxx/include/__compare/weak_order.h @@ -16,7 +16,7 @@ #include <__utility/forward.h> #include <__utility/priority_tag.h> #ifndef _LIBCPP_FREESTANDING -#include +# include #endif #include @@ -39,7 +39,7 @@ -> decltype( weak_ordering(weak_order(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u)))) { return weak_ordering(weak_order(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u))); } -#ifndef _LIBCPP_FREESTANDING +# ifndef _LIBCPP_FREESTANDING template> requires is_same_v<_Dp, decay_t<_Up>> && is_floating_point_v<_Dp> _LIBCPP_HIDE_FROM_ABI static constexpr weak_ordering @@ -67,7 +67,7 @@ } } } -#endif +# endif template requires is_same_v, decay_t<_Up>> Index: libcxx/include/__random/uniform_int_distribution.h =================================================================== --- libcxx/include/__random/uniform_int_distribution.h +++ libcxx/include/__random/uniform_int_distribution.h @@ -17,7 +17,7 @@ #include #include #ifndef _LIBCPP_FREESTANDING -#include +# include #endif #include #include Index: libcxx/include/__string/char_traits.h =================================================================== --- libcxx/include/__string/char_traits.h +++ libcxx/include/__string/char_traits.h @@ -22,12 +22,12 @@ #include #include #ifndef _LIBCPP_FREESTANDING -#include +# include #endif #include #if !defined(_LIBCPP_HAS_NO_WIDE_CHARACTERS) && !defined(_LIBCPP_FREESTANDING) -# include // for wmemcpy +# include // for wmemcpy #endif #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) @@ -318,13 +318,13 @@ struct _LIBCPP_TEMPLATE_VIS char_traits { using char_type = wchar_t; -#if defined(WEOF) +# if defined(WEOF) using int_type = wint_t; using off_type = streamoff; using pos_type = streampos; using state_type = mbstate_t; -#endif -#if _LIBCPP_STD_VER > 17 +# endif +# if _LIBCPP_STD_VER > 17 using comparison_category = strong_ordering; #endif @@ -360,7 +360,7 @@ std::fill_n(__s, __n, __a); return __s; } -#if defined(WEOF) +# if defined(WEOF) static inline _LIBCPP_CONSTEXPR int_type not_eof(int_type __c) _NOEXCEPT {return eq_int_type(__c, eof()) ? ~eof() : __c;} static inline _LIBCPP_CONSTEXPR char_type to_char_type(int_type __c) _NOEXCEPT @@ -372,7 +372,7 @@ {return __c1 == __c2;} static inline _LIBCPP_CONSTEXPR int_type eof() _NOEXCEPT {return int_type(WEOF);} -#endif +# endif }; inline _LIBCPP_CONSTEXPR_SINCE_CXX17 @@ -383,9 +383,9 @@ return 0; #if __has_feature(cxx_constexpr_string_builtins) return __builtin_wmemcmp(__s1, __s2, __n); -#elif _LIBCPP_STD_VER <= 14 && !defined(_LIBCPP_FREESTANDING) +# elif _LIBCPP_STD_VER <= 14 && !defined(_LIBCPP_FREESTANDING) return _VSTD::wmemcmp(__s1, __s2, __n); -#else +# else for (; __n; --__n, ++__s1, ++__s2) { if (lt(*__s1, *__s2)) @@ -394,7 +394,7 @@ return 1; } return 0; -#endif +# endif } inline _LIBCPP_CONSTEXPR_SINCE_CXX17 @@ -421,9 +421,9 @@ return nullptr; #if __has_feature(cxx_constexpr_string_builtins) return __builtin_wmemchr(__s, __a, __n); -#elif _LIBCPP_STD_VER <= 14 && !defined(_LIBCPP_FREESTANDING) +# elif _LIBCPP_STD_VER <= 14 && !defined(_LIBCPP_FREESTANDING) return _VSTD::wmemchr(__s, __a, __n); -#else +# else for (; __n; --__n) { if (eq(*__s, __a)) @@ -431,7 +431,7 @@ ++__s; } return nullptr; -#endif +# endif } #endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS @@ -442,12 +442,12 @@ { using char_type = char8_t; using int_type = unsigned int; -#ifndef _LIBCPP_FREESTANDING +# ifndef _LIBCPP_FREESTANDING using off_type = streamoff; using pos_type = u8streampos; using state_type = mbstate_t; -#endif -#if _LIBCPP_STD_VER > 17 +# endif +# if _LIBCPP_STD_VER > 17 using comparison_category = strong_ordering; #endif @@ -485,20 +485,20 @@ std::fill_n(__s, __n, __a); return __s; } -#if defined(EOF) +# if defined(EOF) static inline constexpr int_type not_eof(int_type __c) noexcept {return eq_int_type(__c, eof()) ? ~eof() : __c;} -#endif +# endif static inline constexpr char_type to_char_type(int_type __c) noexcept {return char_type(__c);} static inline constexpr int_type to_int_type(char_type __c) noexcept {return int_type(__c);} static inline constexpr bool eq_int_type(int_type __c1, int_type __c2) noexcept {return __c1 == __c2;} -#if defined(EOF) +# if defined(EOF) static inline constexpr int_type eof() noexcept {return int_type(EOF);} -#endif +# endif }; // TODO use '__builtin_strlen' if it ever supports char8_t ?? Index: libcxx/include/__thread/poll_with_backoff.h =================================================================== --- libcxx/include/__thread/poll_with_backoff.h +++ libcxx/include/__thread/poll_with_backoff.h @@ -12,12 +12,12 @@ #include <__config> #ifndef _LIBCPP_FREESTANDING -#include <__availability> -#include <__chrono/duration.h> -#include <__chrono/high_resolution_clock.h> -#include <__chrono/steady_clock.h> -#include <__chrono/time_point.h> -#include <__filesystem/file_time_type.h> +# include <__availability> +# include <__chrono/duration.h> +# include <__chrono/high_resolution_clock.h> +# include <__chrono/steady_clock.h> +# include <__chrono/time_point.h> +# include <__filesystem/file_time_type.h> #endif #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) @@ -26,14 +26,12 @@ _LIBCPP_BEGIN_NAMESPACE_STD - -template -_LIBCPP_INLINE_VISIBILITY -bool __libcpp_thread_poll_with_backoff_freestanding(_Fn&& __f) { - for (;;) { - if (__f()) - return true; // _Fn completion means success - } +template +_LIBCPP_INLINE_VISIBILITY bool __libcpp_thread_poll_with_backoff_freestanding(_Fn&& __f) { + for (;;) { + if (__f()) + return true; // _Fn completion means success + } } #ifndef _LIBCPP_FREESTANDING @@ -69,7 +67,6 @@ } } - // A trivial backoff policy that always immediately returns the control to // the polling loop. // Index: libcxx/include/stdlib.h =================================================================== --- libcxx/include/stdlib.h +++ libcxx/include/stdlib.h @@ -90,45 +90,45 @@ # pragma GCC system_header #endif -#if defined(_LIBCPP_FREESTANDING) -#include +# if defined(_LIBCPP_FREESTANDING) +# include using std::abort; using std::atexit; using std::exit; -#if __cplusplus >= 201103L - using std::at_quick_exit; - using std::quick_exit; -#endif +# if __cplusplus >= 201103L +using std::at_quick_exit; +using std::quick_exit; +# endif -#else -#include_next +# else +# include_next -#ifdef __cplusplus +# ifdef __cplusplus extern "C++" { // abs -#ifdef abs -# undef abs -#endif -#ifdef labs -# undef labs -#endif -#ifdef llabs -# undef llabs -#endif +# ifdef abs +# undef abs +# endif +# ifdef labs +# undef labs +# endif +# ifdef llabs +# undef llabs +# endif // MSVCRT already has the correct prototype in if __cplusplus is defined -#if !defined(_LIBCPP_MSVCRT) && !defined(__sun__) +# if !defined(_LIBCPP_MSVCRT) && !defined(__sun__) inline _LIBCPP_INLINE_VISIBILITY long abs(long __x) _NOEXCEPT { return __builtin_labs(__x); } inline _LIBCPP_INLINE_VISIBILITY long long abs(long long __x) _NOEXCEPT { return __builtin_llabs(__x); } -#endif // !defined(_LIBCPP_MSVCRT) && !defined(__sun__) +# endif // !defined(_LIBCPP_MSVCRT) && !defined(__sun__) -#if !defined(__sun__) +# if !defined(__sun__) inline _LIBCPP_INLINE_VISIBILITY float abs(float __lcpp_x) _NOEXCEPT { return __builtin_fabsf(__lcpp_x); // Use builtins to prevent needing math.h } @@ -141,34 +141,34 @@ abs(long double __lcpp_x) _NOEXCEPT { return __builtin_fabsl(__lcpp_x); } -#endif // !defined(__sun__) +# endif // !defined(__sun__) // div -#ifdef div -# undef div -#endif -#ifdef ldiv -# undef ldiv -#endif -#ifdef lldiv -# undef lldiv -#endif +# ifdef div +# undef div +# endif +# ifdef ldiv +# undef ldiv +# endif +# ifdef lldiv +# undef lldiv +# endif // MSVCRT already has the correct prototype in if __cplusplus is defined -#if !defined(_LIBCPP_MSVCRT) && !defined(__sun__) +# if !defined(_LIBCPP_MSVCRT) && !defined(__sun__) inline _LIBCPP_INLINE_VISIBILITY ldiv_t div(long __x, long __y) _NOEXCEPT { return ::ldiv(__x, __y); } -#if !(defined(__FreeBSD__) && !defined(__LONG_LONG_SUPPORTED)) +# if !(defined(__FreeBSD__) && !defined(__LONG_LONG_SUPPORTED)) inline _LIBCPP_INLINE_VISIBILITY lldiv_t div(long long __x, long long __y) _NOEXCEPT { return ::lldiv(__x, __y); } -#endif -#endif // _LIBCPP_MSVCRT / __sun__ +# endif +# endif // _LIBCPP_MSVCRT / __sun__ } // extern "C++" -#endif // __cplusplus -#endif +# endif // __cplusplus +# endif #endif // _LIBCPP_STDLIB_H Index: libcxx/include/string.h =================================================================== --- libcxx/include/string.h +++ libcxx/include/string.h @@ -58,35 +58,34 @@ #endif #ifdef _LIBCPP_FREESTANDING -#include +# include -#ifdef __cplusplus +# ifdef __cplusplus extern "C" { -#endif +# endif -void* memcpy(void*,void const*,size_t); -void* memmove(void*,void const*,size_t); +void* memcpy(void*, void const*, size_t); +void* memmove(void*, void const*, size_t); int memcmp(void const*, void const*, size_t); int memset(void const*, int, size_t); size_t strlen(void const*); -#ifdef __cplusplus +# ifdef __cplusplus } -#endif - +# endif #else -#include_next +# include_next // MSVCRT, GNU libc and its derivates may already have the correct prototype in // . This macro can be defined by users if their C library provides // the right signature. -#if defined(__CORRECT_ISO_CPP_STRING_H_PROTO) || defined(_LIBCPP_MSVCRT) || \ - defined(__sun__) || defined(_STRING_H_CPLUSPLUS_98_CONFORMANCE_) -#define _LIBCPP_STRING_H_HAS_CONST_OVERLOADS -#endif +# if defined(__CORRECT_ISO_CPP_STRING_H_PROTO) || defined(_LIBCPP_MSVCRT) || defined(__sun__) || \ + defined(_STRING_H_CPLUSPLUS_98_CONFORMANCE_) +# define _LIBCPP_STRING_H_HAS_CONST_OVERLOADS +# endif -#if defined(__cplusplus) && !defined(_LIBCPP_STRING_H_HAS_CONST_OVERLOADS) && defined(_LIBCPP_PREFERRED_OVERLOAD) +# if defined(__cplusplus) && !defined(_LIBCPP_STRING_H_HAS_CONST_OVERLOADS) && defined(_LIBCPP_PREFERRED_OVERLOAD) extern "C++" { inline _LIBCPP_INLINE_VISIBILITY char* __libcpp_strchr(const char* __s, int __c) {return (char*)strchr(__s, __c);} @@ -123,6 +122,6 @@ inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_PREFERRED_OVERLOAD char* strstr( char* __s1, const char* __s2) {return __libcpp_strstr(__s1, __s2);} } -#endif +# endif #endif #endif // _LIBCPP_STRING_H Index: libcxx/test/libcxx/libcpp_freestanding.sh.cpp =================================================================== --- libcxx/test/libcxx/libcpp_freestanding.sh.cpp +++ libcxx/test/libcxx/libcpp_freestanding.sh.cpp @@ -19,35 +19,33 @@ defined in non-freestanding mode #endif - -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include #if __has_include() -#include +# include #endif -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include /* * libc++ Extensions @@ -55,15 +53,15 @@ * just like libstdc++ do */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include