diff options
| author | mikhnenko <[email protected]> | 2023-11-02 19:27:12 +0300 |
|---|---|---|
| committer | mikhnenko <[email protected]> | 2023-11-02 20:14:23 +0300 |
| commit | ea7266e3afdfe76274c756747fbd24626e1c205a (patch) | |
| tree | 9b8370f3cf8d4399fc960a2c50aa9759f5acf554 /contrib/libs/cxxsupp/libcxx/src | |
| parent | a528d5d25d42706fe385120b27e1df3a257823fb (diff) | |
Upd libc++ to 14 Jun 2022 1cf4113952ae3e4cc75decdf6feb3ce5dd8ca4a1
Diffstat (limited to 'contrib/libs/cxxsupp/libcxx/src')
4 files changed, 26 insertions, 147 deletions
diff --git a/contrib/libs/cxxsupp/libcxx/src/charconv.cpp b/contrib/libs/cxxsupp/libcxx/src/charconv.cpp index 9537b42de7f..63da85b0935 100644 --- a/contrib/libs/cxxsupp/libcxx/src/charconv.cpp +++ b/contrib/libs/cxxsupp/libcxx/src/charconv.cpp @@ -9,141 +9,31 @@ #include <charconv> #include <string.h> -#include "include/ryu/digit_table.h" #include "include/to_chars_floating_point.h" _LIBCPP_BEGIN_NAMESPACE_STD -namespace __itoa -{ - -template <typename T> -inline _LIBCPP_INLINE_VISIBILITY char* -append1(char* buffer, T i) noexcept -{ - *buffer = '0' + static_cast<char>(i); - return buffer + 1; -} - -template <typename T> -inline _LIBCPP_INLINE_VISIBILITY char* -append2(char* buffer, T i) noexcept -{ - memcpy(buffer, &__DIGIT_TABLE[(i)*2], 2); - return buffer + 2; -} - -template <typename T> -inline _LIBCPP_INLINE_VISIBILITY char* -append3(char* buffer, T i) noexcept -{ - return append2(append1(buffer, (i) / 100), (i) % 100); -} +#ifndef _LIBCPP_ABI_DO_NOT_EXPORT_TO_CHARS_BASE_10 -template <typename T> -inline _LIBCPP_INLINE_VISIBILITY char* -append4(char* buffer, T i) noexcept -{ - return append2(append2(buffer, (i) / 100), (i) % 100); -} - -template <typename T> -inline _LIBCPP_INLINE_VISIBILITY char* -append2_no_zeros(char* buffer, T v) noexcept -{ - if (v < 10) - return append1(buffer, v); - else - return append2(buffer, v); -} - -template <typename T> -inline _LIBCPP_INLINE_VISIBILITY char* -append4_no_zeros(char* buffer, T v) noexcept -{ - if (v < 100) - return append2_no_zeros(buffer, v); - else if (v < 1000) - return append3(buffer, v); - else - return append4(buffer, v); -} - -template <typename T> -inline _LIBCPP_INLINE_VISIBILITY char* -append8_no_zeros(char* buffer, T v) noexcept +namespace __itoa { - if (v < 10000) - { - buffer = append4_no_zeros(buffer, v); - } - else - { - buffer = append4_no_zeros(buffer, v / 10000); - buffer = append4(buffer, v % 10000); - } - return buffer; -} -char* +_LIBCPP_FUNC_VIS char* __u32toa(uint32_t value, char* buffer) noexcept { - if (value < 100000000) - { - buffer = append8_no_zeros(buffer, value); - } - else - { - // value = aabbbbcccc in decimal - const uint32_t a = value / 100000000; // 1 to 42 - value %= 100000000; - - buffer = append2_no_zeros(buffer, a); - buffer = append4(buffer, value / 10000); - buffer = append4(buffer, value % 10000); - } - - return buffer; + return __base_10_u32(value, buffer); } -char* +_LIBCPP_FUNC_VIS char* __u64toa(uint64_t value, char* buffer) noexcept { - if (value < 100000000) - { - uint32_t v = static_cast<uint32_t>(value); - buffer = append8_no_zeros(buffer, v); - } - else if (value < 10000000000000000) - { - const uint32_t v0 = static_cast<uint32_t>(value / 100000000); - const uint32_t v1 = static_cast<uint32_t>(value % 100000000); - - buffer = append8_no_zeros(buffer, v0); - buffer = append4(buffer, v1 / 10000); - buffer = append4(buffer, v1 % 10000); - } - else - { - const uint32_t a = - static_cast<uint32_t>(value / 10000000000000000); // 1 to 1844 - value %= 10000000000000000; - - buffer = append4_no_zeros(buffer, a); - - const uint32_t v0 = static_cast<uint32_t>(value / 100000000); - const uint32_t v1 = static_cast<uint32_t>(value % 100000000); - buffer = append4(buffer, v0 / 10000); - buffer = append4(buffer, v0 % 10000); - buffer = append4(buffer, v1 / 10000); - buffer = append4(buffer, v1 % 10000); - } - - return buffer; + return __base_10_u64(value, buffer); } } // namespace __itoa +#endif // _LIBCPP_ABI_DO_NOT_EXPORT_TO_CHARS_BASE_10 + // The original version of floating-point to_chars was written by Microsoft and // contributed with the following license. diff --git a/contrib/libs/cxxsupp/libcxx/src/include/ryu/digit_table.h b/contrib/libs/cxxsupp/libcxx/src/include/ryu/digit_table.h index e4ee94ce26c..c57a0966ef2 100644 --- a/contrib/libs/cxxsupp/libcxx/src/include/ryu/digit_table.h +++ b/contrib/libs/cxxsupp/libcxx/src/include/ryu/digit_table.h @@ -39,30 +39,19 @@ #ifndef _LIBCPP_SRC_INCLUDE_RYU_DIGIT_TABLE_H #define _LIBCPP_SRC_INCLUDE_RYU_DIGIT_TABLE_H -// Avoid formatting to keep the changes with the original code minimal. -// clang-format off - +#include <__charconv/tables.h> #include <__config> _LIBCPP_BEGIN_NAMESPACE_STD // A table of all two-digit numbers. This is used to speed up decimal digit // generation by copying pairs of digits into the final output. -inline constexpr char __DIGIT_TABLE[200] = { - '0','0','0','1','0','2','0','3','0','4','0','5','0','6','0','7','0','8','0','9', - '1','0','1','1','1','2','1','3','1','4','1','5','1','6','1','7','1','8','1','9', - '2','0','2','1','2','2','2','3','2','4','2','5','2','6','2','7','2','8','2','9', - '3','0','3','1','3','2','3','3','3','4','3','5','3','6','3','7','3','8','3','9', - '4','0','4','1','4','2','4','3','4','4','4','5','4','6','4','7','4','8','4','9', - '5','0','5','1','5','2','5','3','5','4','5','5','5','6','5','7','5','8','5','9', - '6','0','6','1','6','2','6','3','6','4','6','5','6','6','6','7','6','8','6','9', - '7','0','7','1','7','2','7','3','7','4','7','5','7','6','7','7','7','8','7','9', - '8','0','8','1','8','2','8','3','8','4','8','5','8','6','8','7','8','8','8','9', - '9','0','9','1','9','2','9','3','9','4','9','5','9','6','9','7','9','8','9','9' -}; +// +// In order to minimize the diff in the Ryu code between MSVC STL and libc++ +// the code uses the name __DIGIT_TABLE. In order to avoid code duplication it +// reuses the table already available in libc++. +inline constexpr auto& __DIGIT_TABLE = __itoa::__table<>::__digits_base_10; _LIBCPP_END_NAMESPACE_STD -// clang-format on - #endif // _LIBCPP_SRC_INCLUDE_RYU_DIGIT_TABLE_H diff --git a/contrib/libs/cxxsupp/libcxx/src/include/to_chars_floating_point.h b/contrib/libs/cxxsupp/libcxx/src/include/to_chars_floating_point.h index 0bb45d0b979..b99d790f65c 100644 --- a/contrib/libs/cxxsupp/libcxx/src/include/to_chars_floating_point.h +++ b/contrib/libs/cxxsupp/libcxx/src/include/to_chars_floating_point.h @@ -23,6 +23,7 @@ #include <__algorithm/min.h> #include <__assert> #include <__config> +#include <__functional/operations.h> #include <__iterator/access.h> #include <__iterator/size.h> #include <bit> diff --git a/contrib/libs/cxxsupp/libcxx/src/memory.cpp b/contrib/libs/cxxsupp/libcxx/src/memory.cpp index e207e05e158..f805acbaf59 100644 --- a/contrib/libs/cxxsupp/libcxx/src/memory.cpp +++ b/contrib/libs/cxxsupp/libcxx/src/memory.cpp @@ -170,12 +170,16 @@ __shared_weak_count::__get_deleter(const type_info&) const noexcept #if !defined(_LIBCPP_HAS_NO_THREADS) -static constexpr std::size_t __sp_mut_count = 16; +static constexpr std::size_t __sp_mut_count = 32; static _LIBCPP_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, _LIBCPP_MUTEX_INITIALIZER, _LIBCPP_MUTEX_INITIALIZER, _LIBCPP_MUTEX_INITIALIZER, _LIBCPP_MUTEX_INITIALIZER, + _LIBCPP_MUTEX_INITIALIZER, _LIBCPP_MUTEX_INITIALIZER, _LIBCPP_MUTEX_INITIALIZER, _LIBCPP_MUTEX_INITIALIZER, + _LIBCPP_MUTEX_INITIALIZER, _LIBCPP_MUTEX_INITIALIZER, _LIBCPP_MUTEX_INITIALIZER, _LIBCPP_MUTEX_INITIALIZER, + _LIBCPP_MUTEX_INITIALIZER, _LIBCPP_MUTEX_INITIALIZER, _LIBCPP_MUTEX_INITIALIZER, _LIBCPP_MUTEX_INITIALIZER, + _LIBCPP_MUTEX_INITIALIZER, _LIBCPP_MUTEX_INITIALIZER, _LIBCPP_MUTEX_INITIALIZER, _LIBCPP_MUTEX_INITIALIZER, _LIBCPP_MUTEX_INITIALIZER, _LIBCPP_MUTEX_INITIALIZER, _LIBCPP_MUTEX_INITIALIZER, _LIBCPP_MUTEX_INITIALIZER }; @@ -188,16 +192,7 @@ void __sp_mut::lock() noexcept { auto m = static_cast<__libcpp_mutex_t*>(__lx); - unsigned count = 0; - while (!__libcpp_mutex_trylock(m)) - { - if (++count > 16) - { - __libcpp_mutex_lock(m); - break; - } - this_thread::yield(); - } + __libcpp_mutex_lock(m); } void @@ -213,7 +208,11 @@ __get_sp_mut(const void* p) &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], - &mut_back[12], &mut_back[13], &mut_back[14], &mut_back[15] + &mut_back[12], &mut_back[13], &mut_back[14], &mut_back[15], + &mut_back[16], &mut_back[17], &mut_back[18], &mut_back[19], + &mut_back[20], &mut_back[21], &mut_back[22], &mut_back[23], + &mut_back[24], &mut_back[25], &mut_back[26], &mut_back[27], + &mut_back[28], &mut_back[29], &mut_back[30], &mut_back[31] }; return muts[hash<const void*>()(p) & (__sp_mut_count-1)]; } |
