diff options
author | AlexSm <[email protected]> | 2024-01-18 11:28:56 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2024-01-18 11:28:56 +0100 |
commit | 9d0a3761b3201e0d9db879a7adf91876ebdb0564 (patch) | |
tree | 541d11ac878c18efd7ebca81e35112aa0fef995b /contrib/libs/cxxsupp/libcxx/src | |
parent | 404ef8886ecc9736bc58ade6da2fbd83b486a408 (diff) |
Library import 8 (#1074)
* Library import 8
* Add contrib/libs/cxxsupp/libcxx/include/__verbose_abort
Diffstat (limited to 'contrib/libs/cxxsupp/libcxx/src')
8 files changed, 89 insertions, 31 deletions
diff --git a/contrib/libs/cxxsupp/libcxx/src/assert.cpp b/contrib/libs/cxxsupp/libcxx/src/assert.cpp deleted file mode 100644 index 54459800728..00000000000 --- a/contrib/libs/cxxsupp/libcxx/src/assert.cpp +++ /dev/null @@ -1,22 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#include <__assert> -#include <__config> -#include <cstdio> -#include <cstdlib> - -_LIBCPP_BEGIN_NAMESPACE_STD - -_LIBCPP_WEAK -void __libcpp_assertion_handler(char const* __file, int __line, char const* __expression, char const* __message) { - std::fprintf(stderr, "%s:%d: libc++ assertion '%s' failed. %s\n", __file, __line, __expression, __message); - std::abort(); -} - -_LIBCPP_END_NAMESPACE_STD diff --git a/contrib/libs/cxxsupp/libcxx/src/filesystem/operations.cpp b/contrib/libs/cxxsupp/libcxx/src/filesystem/operations.cpp index e205f0f7ade..3c02723046c 100644 --- a/contrib/libs/cxxsupp/libcxx/src/filesystem/operations.cpp +++ b/contrib/libs/cxxsupp/libcxx/src/filesystem/operations.cpp @@ -34,7 +34,7 @@ #include <time.h> #include <fcntl.h> /* values for fchmodat */ -#if __has_include(<sys/sendfile.h>) +#if __has_include(<sys/sendfile.h>) && !defined(__EMSCRIPTEN__) # include <sys/sendfile.h> # define _LIBCPP_FILESYSTEM_USE_SENDFILE #elif defined(__APPLE__) || __has_include(<copyfile.h>) diff --git a/contrib/libs/cxxsupp/libcxx/src/include/sso_allocator.h b/contrib/libs/cxxsupp/libcxx/src/include/sso_allocator.h index 2baf599c5c2..6a682fc43f8 100644 --- a/contrib/libs/cxxsupp/libcxx/src/include/sso_allocator.h +++ b/contrib/libs/cxxsupp/libcxx/src/include/sso_allocator.h @@ -41,6 +41,11 @@ public: typedef _Tp* pointer; typedef _Tp value_type; + template <class U> + struct rebind { + using other = __sso_allocator<U, _Np>; + }; + _LIBCPP_INLINE_VISIBILITY __sso_allocator() throw() : __allocated_(false) {} _LIBCPP_INLINE_VISIBILITY __sso_allocator(const __sso_allocator&) throw() : __allocated_(false) {} template <class _Up> _LIBCPP_INLINE_VISIBILITY __sso_allocator(const __sso_allocator<_Up, _Np>&) throw() diff --git a/contrib/libs/cxxsupp/libcxx/src/memory.cpp b/contrib/libs/cxxsupp/libcxx/src/memory.cpp index f805acbaf59..004634f3eb4 100644 --- a/contrib/libs/cxxsupp/libcxx/src/memory.cpp +++ b/contrib/libs/cxxsupp/libcxx/src/memory.cpp @@ -171,7 +171,7 @@ __shared_weak_count::__get_deleter(const type_info&) const noexcept #if !defined(_LIBCPP_HAS_NO_THREADS) static constexpr std::size_t __sp_mut_count = 32; -static _LIBCPP_CONSTINIT __libcpp_mutex_t mut_back[__sp_mut_count] = +static constinit __libcpp_mutex_t mut_back[__sp_mut_count] = { _LIBCPP_MUTEX_INITIALIZER, _LIBCPP_MUTEX_INITIALIZER, _LIBCPP_MUTEX_INITIALIZER, _LIBCPP_MUTEX_INITIALIZER, _LIBCPP_MUTEX_INITIALIZER, _LIBCPP_MUTEX_INITIALIZER, _LIBCPP_MUTEX_INITIALIZER, _LIBCPP_MUTEX_INITIALIZER, @@ -204,7 +204,7 @@ __sp_mut::unlock() noexcept __sp_mut& __get_sp_mut(const void* p) { - static _LIBCPP_CONSTINIT __sp_mut muts[__sp_mut_count] = { + static constinit __sp_mut muts[__sp_mut_count] = { &mut_back[ 0], &mut_back[ 1], &mut_back[ 2], &mut_back[ 3], &mut_back[ 4], &mut_back[ 5], &mut_back[ 6], &mut_back[ 7], &mut_back[ 8], &mut_back[ 9], &mut_back[10], &mut_back[11], diff --git a/contrib/libs/cxxsupp/libcxx/src/mutex.cpp b/contrib/libs/cxxsupp/libcxx/src/mutex.cpp index c247225e31a..f738cc013b3 100644 --- a/contrib/libs/cxxsupp/libcxx/src/mutex.cpp +++ b/contrib/libs/cxxsupp/libcxx/src/mutex.cpp @@ -203,8 +203,8 @@ recursive_timed_mutex::unlock() noexcept // keep in sync with: 7741191. #ifndef _LIBCPP_HAS_NO_THREADS -static _LIBCPP_CONSTINIT __libcpp_mutex_t mut = _LIBCPP_MUTEX_INITIALIZER; -static _LIBCPP_CONSTINIT __libcpp_condvar_t cv = _LIBCPP_CONDVAR_INITIALIZER; +static constinit __libcpp_mutex_t mut = _LIBCPP_MUTEX_INITIALIZER; +static constinit __libcpp_condvar_t cv = _LIBCPP_CONDVAR_INITIALIZER; #endif #ifdef _LIBCPP_ABI_MICROSOFT diff --git a/contrib/libs/cxxsupp/libcxx/src/random_shuffle.cpp b/contrib/libs/cxxsupp/libcxx/src/random_shuffle.cpp index a673035b485..e9087a97014 100644 --- a/contrib/libs/cxxsupp/libcxx/src/random_shuffle.cpp +++ b/contrib/libs/cxxsupp/libcxx/src/random_shuffle.cpp @@ -19,7 +19,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD #ifndef _LIBCPP_HAS_NO_THREADS -static _LIBCPP_CONSTINIT __libcpp_mutex_t __rs_mut = _LIBCPP_MUTEX_INITIALIZER; +static constinit __libcpp_mutex_t __rs_mut = _LIBCPP_MUTEX_INITIALIZER; #endif unsigned __rs_default::__c_ = 0; diff --git a/contrib/libs/cxxsupp/libcxx/src/support/runtime/new_handler_fallback.ipp b/contrib/libs/cxxsupp/libcxx/src/support/runtime/new_handler_fallback.ipp index 7556f693a92..2ec408327d6 100644 --- a/contrib/libs/cxxsupp/libcxx/src/support/runtime/new_handler_fallback.ipp +++ b/contrib/libs/cxxsupp/libcxx/src/support/runtime/new_handler_fallback.ipp @@ -7,11 +7,9 @@ // //===----------------------------------------------------------------------===// -#include "../../include/atomic_support.h" - namespace std { -static _LIBCPP_CONSTINIT std::new_handler __new_handler = nullptr; +static constinit std::new_handler __new_handler = nullptr; new_handler set_new_handler(new_handler handler) noexcept diff --git a/contrib/libs/cxxsupp/libcxx/src/verbose_abort.cpp b/contrib/libs/cxxsupp/libcxx/src/verbose_abort.cpp new file mode 100644 index 00000000000..a9fba5e3c00 --- /dev/null +++ b/contrib/libs/cxxsupp/libcxx/src/verbose_abort.cpp @@ -0,0 +1,77 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include <__config> +#include <__verbose_abort> +#include <cstdarg> +#include <cstdio> +#include <cstdlib> + +#ifdef __BIONIC__ +# include <android/api-level.h> +# if __ANDROID_API__ >= 21 +# include <syslog.h> +extern "C" void android_set_abort_message(const char* msg); +# else +# include <assert.h> +# endif // __ANDROID_API__ >= 21 +#endif // __BIONIC__ + +#if defined(__APPLE__) && __has_include(<CrashReporterClient.h>) +# include <CrashReporterClient.h> +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +_LIBCPP_WEAK +void __libcpp_verbose_abort(char const* format, ...) { + // Write message to stderr. We do this before formatting into a + // buffer so that we still get some information out if that fails. + { + va_list list; + va_start(list, format); + std::vfprintf(stderr, format, list); + va_end(list); + } + + // Format the arguments into an allocated buffer for CrashReport & friends. + // We leak the buffer on purpose, since we're about to abort() anyway. + char* buffer; (void)buffer; + va_list list; + va_start(list, format); + +#if defined(__APPLE__) && __has_include(<CrashReporterClient.h>) + // Note that we should technically synchronize accesses here (by e.g. taking a lock), + // however concretely we're only setting a pointer, so the likelihood of a race here + // is low. + vasprintf(&buffer, format, list); + CRSetCrashLogMessage(buffer); +#elif defined(__BIONIC__) + vasprintf(&buffer, format, list); + +# if __ANDROID_API__ >= 21 + // Show error in tombstone. + android_set_abort_message(buffer); + + // Show error in logcat. + openlog("libc++", 0, 0); + syslog(LOG_CRIT, "%s", buffer); + closelog(); +# else + // The good error reporting wasn't available in Android until L. Since we're + // about to abort anyway, just call __assert2, which will log _somewhere_ + // (tombstone and/or logcat) in older releases. + __assert2(__FILE__, __LINE__, __func__, buffer); +# endif // __ANDROID_API__ >= 21 +#endif + va_end(list); + + std::abort(); +} + +_LIBCPP_END_NAMESPACE_STD |