diff options
author | armenqa <armenqa@yandex-team.com> | 2024-01-19 12:23:50 +0300 |
---|---|---|
committer | armenqa <armenqa@yandex-team.com> | 2024-01-19 13:10:03 +0300 |
commit | 2de0149d0151c514b22bca0760b95b26c9b0b578 (patch) | |
tree | 2bfed9f3bce7e643ddf048bb61ce3dc0a714bcc2 /contrib/libs/cxxsupp/libcxx/src | |
parent | a8c06d218f12b2406fbce24d194885c5d7b68503 (diff) | |
download | ydb-2de0149d0151c514b22bca0760b95b26c9b0b578.tar.gz |
feat contrib: aiogram 3
Relates: https://st.yandex-team.ru/, https://st.yandex-team.ru/
Diffstat (limited to 'contrib/libs/cxxsupp/libcxx/src')
16 files changed, 683 insertions, 195 deletions
diff --git a/contrib/libs/cxxsupp/libcxx/src/atomic.cpp b/contrib/libs/cxxsupp/libcxx/src/atomic.cpp index 5968aafb53..ec7bb7d9b2 100644 --- a/contrib/libs/cxxsupp/libcxx/src/atomic.cpp +++ b/contrib/libs/cxxsupp/libcxx/src/atomic.cpp @@ -52,11 +52,11 @@ static void __libcpp_platform_wake_by_address(__cxx_atomic_contention_t const vo #elif defined(__APPLE__) && defined(_LIBCPP_USE_ULOCK) extern "C" int __ulock_wait(uint32_t operation, void *addr, uint64_t value, - uint32_t timeout); /* timeout is specified in microseconds */ + uint32_t timeout); /* timeout is specified in microseconds */ extern "C" int __ulock_wake(uint32_t operation, void *addr, uint64_t wake_value); -#define UL_COMPARE_AND_WAIT 1 -#define ULF_WAKE_ALL 0x00000100 +#define UL_COMPARE_AND_WAIT 1 +#define ULF_WAKE_ALL 0x00000100 static void __libcpp_platform_wait_on_address(__cxx_atomic_contention_t const volatile* __ptr, __cxx_contention_t __val) diff --git a/contrib/libs/cxxsupp/libcxx/src/charconv.cpp b/contrib/libs/cxxsupp/libcxx/src/charconv.cpp index 4cccbab59d..d01ecddc46 100644 --- a/contrib/libs/cxxsupp/libcxx/src/charconv.cpp +++ b/contrib/libs/cxxsupp/libcxx/src/charconv.cpp @@ -21,13 +21,13 @@ namespace __itoa _LIBCPP_FUNC_VIS char* __u32toa(uint32_t value, char* buffer) noexcept { - return __base_10_u32(buffer, value); + return __base_10_u32(buffer, value); } _LIBCPP_FUNC_VIS char* __u64toa(uint64_t value, char* buffer) noexcept { - return __base_10_u64(buffer, value); + return __base_10_u64(buffer, value); } } // namespace __itoa diff --git a/contrib/libs/cxxsupp/libcxx/src/filesystem/filesystem_common.h b/contrib/libs/cxxsupp/libcxx/src/filesystem/filesystem_common.h index 0bd2bbe6f7..0e71569d87 100644 --- a/contrib/libs/cxxsupp/libcxx/src/filesystem/filesystem_common.h +++ b/contrib/libs/cxxsupp/libcxx/src/filesystem/filesystem_common.h @@ -124,7 +124,7 @@ error_code make_windows_error(int err) { template <class T> T error_value(); template <> -_LIBCPP_CONSTEXPR_AFTER_CXX11 void error_value<void>() {} +_LIBCPP_CONSTEXPR_SINCE_CXX14 void error_value<void>() {} template <> bool error_value<bool>() { return false; @@ -140,7 +140,7 @@ uintmax_t error_value<uintmax_t>() { return uintmax_t(-1); } template <> -_LIBCPP_CONSTEXPR_AFTER_CXX11 file_time_type error_value<file_time_type>() { +_LIBCPP_CONSTEXPR_SINCE_CXX14 file_time_type error_value<file_time_type>() { return file_time_type::min(); } template <> @@ -309,7 +309,7 @@ struct time_util_base { .count(); private: - static _LIBCPP_CONSTEXPR_AFTER_CXX11 fs_duration get_min_nsecs() { + static _LIBCPP_CONSTEXPR_SINCE_CXX14 fs_duration get_min_nsecs() { return duration_cast<fs_duration>( fs_nanoseconds(min_nsec_timespec) - duration_cast<fs_nanoseconds>(fs_seconds(1))); @@ -319,7 +319,7 @@ private: FileTimeT::duration::min(), "value doesn't roundtrip"); - static _LIBCPP_CONSTEXPR_AFTER_CXX11 bool check_range() { + static _LIBCPP_CONSTEXPR_SINCE_CXX14 bool check_range() { // This kinda sucks, but it's what happens when we don't have __int128_t. if (sizeof(TimeT) == sizeof(rep)) { typedef duration<long long, ratio<3600 * 24 * 365> > Years; @@ -385,7 +385,7 @@ struct time_util : time_util_base<FileTimeT, TimeT> { public: template <class CType, class ChronoType> - static _LIBCPP_CONSTEXPR_AFTER_CXX11 bool checked_set(CType* out, + static _LIBCPP_CONSTEXPR_SINCE_CXX14 bool checked_set(CType* out, ChronoType time) { using Lim = numeric_limits<CType>; if (time > Lim::max() || time < Lim::min()) @@ -394,7 +394,7 @@ public: return true; } - static _LIBCPP_CONSTEXPR_AFTER_CXX11 bool is_representable(TimeSpecT tm) { + static _LIBCPP_CONSTEXPR_SINCE_CXX14 bool is_representable(TimeSpecT tm) { if (tm.tv_sec >= 0) { return tm.tv_sec < max_seconds || (tm.tv_sec == max_seconds && tm.tv_nsec <= max_nsec); @@ -405,7 +405,7 @@ public: } } - static _LIBCPP_CONSTEXPR_AFTER_CXX11 bool is_representable(FileTimeT tm) { + static _LIBCPP_CONSTEXPR_SINCE_CXX14 bool is_representable(FileTimeT tm) { auto secs = duration_cast<fs_seconds>(tm.time_since_epoch()); auto nsecs = duration_cast<fs_nanoseconds>(tm.time_since_epoch() - secs); if (nsecs.count() < 0) { @@ -418,7 +418,7 @@ public: return secs.count() >= TLim::min(); } - static _LIBCPP_CONSTEXPR_AFTER_CXX11 FileTimeT + static _LIBCPP_CONSTEXPR_SINCE_CXX14 FileTimeT convert_from_timespec(TimeSpecT tm) { if (tm.tv_sec >= 0 || tm.tv_nsec == 0) { return FileTimeT(fs_seconds(tm.tv_sec) + @@ -432,7 +432,7 @@ public: } template <class SubSecT> - static _LIBCPP_CONSTEXPR_AFTER_CXX11 bool + static _LIBCPP_CONSTEXPR_SINCE_CXX14 bool set_times_checked(TimeT* sec_out, SubSecT* subsec_out, FileTimeT tp) { auto dur = tp.time_since_epoch(); auto sec_dur = duration_cast<fs_seconds>(dur); @@ -449,7 +449,7 @@ public: return checked_set(sec_out, sec_dur.count()) && checked_set(subsec_out, subsec_dur.count()); } - static _LIBCPP_CONSTEXPR_AFTER_CXX11 bool convert_to_timespec(TimeSpecT& dest, + static _LIBCPP_CONSTEXPR_SINCE_CXX14 bool convert_to_timespec(TimeSpecT& dest, FileTimeT tp) { if (!is_representable(tp)) return false; diff --git a/contrib/libs/cxxsupp/libcxx/src/filesystem/operations.cpp b/contrib/libs/cxxsupp/libcxx/src/filesystem/operations.cpp index 3c02723046..f9b74120e0 100644 --- a/contrib/libs/cxxsupp/libcxx/src/filesystem/operations.cpp +++ b/contrib/libs/cxxsupp/libcxx/src/filesystem/operations.cpp @@ -1352,7 +1352,7 @@ bool __remove(const path& p, error_code* ec) { // // The second implementation is used on platforms where `openat()` & friends are available, // and it threads file descriptors through recursive calls to avoid such race conditions. -#if defined(_LIBCPP_WIN32API) +#if defined(_LIBCPP_WIN32API) || defined (__MVS__) # define REMOVE_ALL_USE_DIRECTORY_ITERATOR #endif @@ -1412,6 +1412,7 @@ struct scope_exit { private: Cleanup cleanup_; }; +_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(scope_exit); uintmax_t remove_all_impl(int parent_directory, const path& p, error_code& ec) { // First, try to open the path as a directory. diff --git a/contrib/libs/cxxsupp/libcxx/src/format.cpp b/contrib/libs/cxxsupp/libcxx/src/format.cpp index cdbcbf8b05..401cccf172 100644 --- a/contrib/libs/cxxsupp/libcxx/src/format.cpp +++ b/contrib/libs/cxxsupp/libcxx/src/format.cpp @@ -10,6 +10,8 @@ _LIBCPP_BEGIN_NAMESPACE_STD +#ifndef _LIBCPP_INLINE_FORMAT_ERROR_DTOR format_error::~format_error() noexcept = default; +#endif _LIBCPP_END_NAMESPACE_STD diff --git a/contrib/libs/cxxsupp/libcxx/src/include/apple_availability.h b/contrib/libs/cxxsupp/libcxx/src/include/apple_availability.h index 504700ebd0..75bf79658d 100644 --- a/contrib/libs/cxxsupp/libcxx/src/include/apple_availability.h +++ b/contrib/libs/cxxsupp/libcxx/src/include/apple_availability.h @@ -5,6 +5,7 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// + #ifndef _LIBCPP_SRC_INCLUDE_APPLE_AVAILABILITY_H #define _LIBCPP_SRC_INCLUDE_APPLE_AVAILABILITY_H 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 c57a0966ef..bf660b0be7 100644 --- a/contrib/libs/cxxsupp/libcxx/src/include/ryu/digit_table.h +++ b/contrib/libs/cxxsupp/libcxx/src/include/ryu/digit_table.h @@ -50,7 +50,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD // 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; +inline constexpr auto& __DIGIT_TABLE = __itoa::__digits_base_10; _LIBCPP_END_NAMESPACE_STD diff --git a/contrib/libs/cxxsupp/libcxx/src/ios.instantiations.cpp b/contrib/libs/cxxsupp/libcxx/src/ios.instantiations.cpp index 2ff7057fa6..ca77ce11fd 100644 --- a/contrib/libs/cxxsupp/libcxx/src/ios.instantiations.cpp +++ b/contrib/libs/cxxsupp/libcxx/src/ios.instantiations.cpp @@ -36,9 +36,12 @@ template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS basic_stringbuf<char>; template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS basic_stringstream<char>; template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS basic_ostringstream<char>; template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS basic_istringstream<char>; + +#ifndef _LIBCPP_HAS_NO_FSTREAM template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS basic_ifstream<char>; template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS basic_ofstream<char>; template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS basic_filebuf<char>; +#endif // Add more here if needed... diff --git a/contrib/libs/cxxsupp/libcxx/src/locale.cpp b/contrib/libs/cxxsupp/libcxx/src/locale.cpp index 38319e32f5..c756c6fadf 100644 --- a/contrib/libs/cxxsupp/libcxx/src/locale.cpp +++ b/contrib/libs/cxxsupp/libcxx/src/locale.cpp @@ -735,25 +735,25 @@ locale::id::__get() collate_byname<char>::collate_byname(const char* n, size_t refs) : collate<char>(refs), - __l(newlocale(LC_ALL_MASK, n, 0)) + __l_(newlocale(LC_ALL_MASK, n, 0)) { - if (__l == 0) + if (__l_ == 0) __throw_runtime_error("collate_byname<char>::collate_byname" " failed to construct for " + string(n)); } collate_byname<char>::collate_byname(const string& name, size_t refs) : collate<char>(refs), - __l(newlocale(LC_ALL_MASK, name.c_str(), 0)) + __l_(newlocale(LC_ALL_MASK, name.c_str(), 0)) { - if (__l == 0) + if (__l_ == 0) __throw_runtime_error("collate_byname<char>::collate_byname" " failed to construct for " + name); } collate_byname<char>::~collate_byname() { - freelocale(__l); + freelocale(__l_); } int @@ -762,7 +762,7 @@ collate_byname<char>::do_compare(const char_type* __lo1, const char_type* __hi1, { string_type lhs(__lo1, __hi1); string_type rhs(__lo2, __hi2); - int r = strcoll_l(lhs.c_str(), rhs.c_str(), __l); + int r = strcoll_l(lhs.c_str(), rhs.c_str(), __l_); if (r < 0) return -1; if (r > 0) @@ -774,8 +774,8 @@ collate_byname<char>::string_type collate_byname<char>::do_transform(const char_type* lo, const char_type* hi) const { const string_type in(lo, hi); - string_type out(strxfrm_l(0, in.c_str(), 0, __l), char()); - strxfrm_l(const_cast<char*>(out.c_str()), in.c_str(), out.size()+1, __l); + string_type out(strxfrm_l(0, in.c_str(), 0, __l_), char()); + strxfrm_l(const_cast<char*>(out.c_str()), in.c_str(), out.size()+1, __l_); return out; } @@ -784,25 +784,25 @@ collate_byname<char>::do_transform(const char_type* lo, const char_type* hi) con #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS collate_byname<wchar_t>::collate_byname(const char* n, size_t refs) : collate<wchar_t>(refs), - __l(newlocale(LC_ALL_MASK, n, 0)) + __l_(newlocale(LC_ALL_MASK, n, 0)) { - if (__l == 0) + if (__l_ == 0) __throw_runtime_error("collate_byname<wchar_t>::collate_byname(size_t refs)" " failed to construct for " + string(n)); } collate_byname<wchar_t>::collate_byname(const string& name, size_t refs) : collate<wchar_t>(refs), - __l(newlocale(LC_ALL_MASK, name.c_str(), 0)) + __l_(newlocale(LC_ALL_MASK, name.c_str(), 0)) { - if (__l == 0) + if (__l_ == 0) __throw_runtime_error("collate_byname<wchar_t>::collate_byname(size_t refs)" " failed to construct for " + name); } collate_byname<wchar_t>::~collate_byname() { - freelocale(__l); + freelocale(__l_); } int @@ -811,7 +811,7 @@ collate_byname<wchar_t>::do_compare(const char_type* __lo1, const char_type* __h { string_type lhs(__lo1, __hi1); string_type rhs(__lo2, __hi2); - int r = wcscoll_l(lhs.c_str(), rhs.c_str(), __l); + int r = wcscoll_l(lhs.c_str(), rhs.c_str(), __l_); if (r < 0) return -1; if (r > 0) @@ -823,8 +823,8 @@ collate_byname<wchar_t>::string_type collate_byname<wchar_t>::do_transform(const char_type* lo, const char_type* hi) const { const string_type in(lo, hi); - string_type out(wcsxfrm_l(0, in.c_str(), 0, __l), wchar_t()); - wcsxfrm_l(const_cast<wchar_t*>(out.c_str()), in.c_str(), out.size()+1, __l); + string_type out(wcsxfrm_l(0, in.c_str(), 0, __l_), wchar_t()); + wcsxfrm_l(const_cast<wchar_t*>(out.c_str()), in.c_str(), out.size()+1, __l_); return out; } #endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS @@ -1289,52 +1289,52 @@ ctype<char>::__classic_upper_table() _NOEXCEPT ctype_byname<char>::ctype_byname(const char* name, size_t refs) : ctype<char>(0, false, refs), - __l(newlocale(LC_ALL_MASK, name, 0)) + __l_(newlocale(LC_ALL_MASK, name, 0)) { - if (__l == 0) + if (__l_ == 0) __throw_runtime_error("ctype_byname<char>::ctype_byname" " failed to construct for " + string(name)); } ctype_byname<char>::ctype_byname(const string& name, size_t refs) : ctype<char>(0, false, refs), - __l(newlocale(LC_ALL_MASK, name.c_str(), 0)) + __l_(newlocale(LC_ALL_MASK, name.c_str(), 0)) { - if (__l == 0) + if (__l_ == 0) __throw_runtime_error("ctype_byname<char>::ctype_byname" " failed to construct for " + name); } ctype_byname<char>::~ctype_byname() { - freelocale(__l); + freelocale(__l_); } char ctype_byname<char>::do_toupper(char_type c) const { - return static_cast<char>(toupper_l(static_cast<unsigned char>(c), __l)); + return static_cast<char>(toupper_l(static_cast<unsigned char>(c), __l_)); } const char* ctype_byname<char>::do_toupper(char_type* low, const char_type* high) const { for (; low != high; ++low) - *low = static_cast<char>(toupper_l(static_cast<unsigned char>(*low), __l)); + *low = static_cast<char>(toupper_l(static_cast<unsigned char>(*low), __l_)); return low; } char ctype_byname<char>::do_tolower(char_type c) const { - return static_cast<char>(tolower_l(static_cast<unsigned char>(c), __l)); + return static_cast<char>(tolower_l(static_cast<unsigned char>(c), __l_)); } const char* ctype_byname<char>::do_tolower(char_type* low, const char_type* high) const { for (; low != high; ++low) - *low = static_cast<char>(tolower_l(static_cast<unsigned char>(*low), __l)); + *low = static_cast<char>(tolower_l(static_cast<unsigned char>(*low), __l_)); return low; } @@ -1343,45 +1343,45 @@ ctype_byname<char>::do_tolower(char_type* low, const char_type* high) const #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS ctype_byname<wchar_t>::ctype_byname(const char* name, size_t refs) : ctype<wchar_t>(refs), - __l(newlocale(LC_ALL_MASK, name, 0)) + __l_(newlocale(LC_ALL_MASK, name, 0)) { - if (__l == 0) + if (__l_ == 0) __throw_runtime_error("ctype_byname<wchar_t>::ctype_byname" " failed to construct for " + string(name)); } ctype_byname<wchar_t>::ctype_byname(const string& name, size_t refs) : ctype<wchar_t>(refs), - __l(newlocale(LC_ALL_MASK, name.c_str(), 0)) + __l_(newlocale(LC_ALL_MASK, name.c_str(), 0)) { - if (__l == 0) + if (__l_ == 0) __throw_runtime_error("ctype_byname<wchar_t>::ctype_byname" " failed to construct for " + name); } ctype_byname<wchar_t>::~ctype_byname() { - freelocale(__l); + freelocale(__l_); } bool ctype_byname<wchar_t>::do_is(mask m, char_type c) const { #ifdef _LIBCPP_WCTYPE_IS_MASK - return static_cast<bool>(iswctype_l(c, m, __l)); + return static_cast<bool>(iswctype_l(c, m, __l_)); #else bool result = false; wint_t ch = static_cast<wint_t>(c); - if ((m & space) == space) result |= (iswspace_l(ch, __l) != 0); - if ((m & print) == print) result |= (iswprint_l(ch, __l) != 0); - if ((m & cntrl) == cntrl) result |= (iswcntrl_l(ch, __l) != 0); - if ((m & upper) == upper) result |= (iswupper_l(ch, __l) != 0); - if ((m & lower) == lower) result |= (iswlower_l(ch, __l) != 0); - if ((m & alpha) == alpha) result |= (iswalpha_l(ch, __l) != 0); - if ((m & digit) == digit) result |= (iswdigit_l(ch, __l) != 0); - if ((m & punct) == punct) result |= (iswpunct_l(ch, __l) != 0); - if ((m & xdigit) == xdigit) result |= (iswxdigit_l(ch, __l) != 0); - if ((m & blank) == blank) result |= (iswblank_l(ch, __l) != 0); + if ((m & space) == space) result |= (iswspace_l(ch, __l_) != 0); + if ((m & print) == print) result |= (iswprint_l(ch, __l_) != 0); + if ((m & cntrl) == cntrl) result |= (iswcntrl_l(ch, __l_) != 0); + if ((m & upper) == upper) result |= (iswupper_l(ch, __l_) != 0); + if ((m & lower) == lower) result |= (iswlower_l(ch, __l_) != 0); + if ((m & alpha) == alpha) result |= (iswalpha_l(ch, __l_) != 0); + if ((m & digit) == digit) result |= (iswdigit_l(ch, __l_) != 0); + if ((m & punct) == punct) result |= (iswpunct_l(ch, __l_) != 0); + if ((m & xdigit) == xdigit) result |= (iswxdigit_l(ch, __l_) != 0); + if ((m & blank) == blank) result |= (iswblank_l(ch, __l_) != 0); return result; #endif } @@ -1397,32 +1397,32 @@ ctype_byname<wchar_t>::do_is(const char_type* low, const char_type* high, mask* { *vec = 0; wint_t ch = static_cast<wint_t>(*low); - if (iswspace_l(ch, __l)) + if (iswspace_l(ch, __l_)) *vec |= space; #ifndef _LIBCPP_CTYPE_MASK_IS_COMPOSITE_PRINT - if (iswprint_l(ch, __l)) + if (iswprint_l(ch, __l_)) *vec |= print; #endif - if (iswcntrl_l(ch, __l)) + if (iswcntrl_l(ch, __l_)) *vec |= cntrl; - if (iswupper_l(ch, __l)) + if (iswupper_l(ch, __l_)) *vec |= upper; - if (iswlower_l(ch, __l)) + if (iswlower_l(ch, __l_)) *vec |= lower; #ifndef _LIBCPP_CTYPE_MASK_IS_COMPOSITE_ALPHA - if (iswalpha_l(ch, __l)) + if (iswalpha_l(ch, __l_)) *vec |= alpha; #endif - if (iswdigit_l(ch, __l)) + if (iswdigit_l(ch, __l_)) *vec |= digit; - if (iswpunct_l(ch, __l)) + if (iswpunct_l(ch, __l_)) *vec |= punct; #ifndef _LIBCPP_CTYPE_MASK_IS_COMPOSITE_XDIGIT - if (iswxdigit_l(ch, __l)) + if (iswxdigit_l(ch, __l_)) *vec |= xdigit; #endif #if !defined(__sun__) - if (iswblank_l(ch, __l)) + if (iswblank_l(ch, __l_)) *vec |= blank; #endif } @@ -1436,20 +1436,20 @@ ctype_byname<wchar_t>::do_scan_is(mask m, const char_type* low, const char_type* for (; low != high; ++low) { #ifdef _LIBCPP_WCTYPE_IS_MASK - if (iswctype_l(*low, m, __l)) + if (iswctype_l(*low, m, __l_)) break; #else wint_t ch = static_cast<wint_t>(*low); - if ((m & space) == space && iswspace_l(ch, __l)) break; - if ((m & print) == print && iswprint_l(ch, __l)) break; - if ((m & cntrl) == cntrl && iswcntrl_l(ch, __l)) break; - if ((m & upper) == upper && iswupper_l(ch, __l)) break; - if ((m & lower) == lower && iswlower_l(ch, __l)) break; - if ((m & alpha) == alpha && iswalpha_l(ch, __l)) break; - if ((m & digit) == digit && iswdigit_l(ch, __l)) break; - if ((m & punct) == punct && iswpunct_l(ch, __l)) break; - if ((m & xdigit) == xdigit && iswxdigit_l(ch, __l)) break; - if ((m & blank) == blank && iswblank_l(ch, __l)) break; + if ((m & space) == space && iswspace_l(ch, __l_)) break; + if ((m & print) == print && iswprint_l(ch, __l_)) break; + if ((m & cntrl) == cntrl && iswcntrl_l(ch, __l_)) break; + if ((m & upper) == upper && iswupper_l(ch, __l_)) break; + if ((m & lower) == lower && iswlower_l(ch, __l_)) break; + if ((m & alpha) == alpha && iswalpha_l(ch, __l_)) break; + if ((m & digit) == digit && iswdigit_l(ch, __l_)) break; + if ((m & punct) == punct && iswpunct_l(ch, __l_)) break; + if ((m & xdigit) == xdigit && iswxdigit_l(ch, __l_)) break; + if ((m & blank) == blank && iswblank_l(ch, __l_)) break; #endif } return low; @@ -1461,20 +1461,20 @@ ctype_byname<wchar_t>::do_scan_not(mask m, const char_type* low, const char_type for (; low != high; ++low) { #ifdef _LIBCPP_WCTYPE_IS_MASK - if (!iswctype_l(*low, m, __l)) + if (!iswctype_l(*low, m, __l_)) break; #else wint_t ch = static_cast<wint_t>(*low); - if ((m & space) == space && iswspace_l(ch, __l)) continue; - if ((m & print) == print && iswprint_l(ch, __l)) continue; - if ((m & cntrl) == cntrl && iswcntrl_l(ch, __l)) continue; - if ((m & upper) == upper && iswupper_l(ch, __l)) continue; - if ((m & lower) == lower && iswlower_l(ch, __l)) continue; - if ((m & alpha) == alpha && iswalpha_l(ch, __l)) continue; - if ((m & digit) == digit && iswdigit_l(ch, __l)) continue; - if ((m & punct) == punct && iswpunct_l(ch, __l)) continue; - if ((m & xdigit) == xdigit && iswxdigit_l(ch, __l)) continue; - if ((m & blank) == blank && iswblank_l(ch, __l)) continue; + if ((m & space) == space && iswspace_l(ch, __l_)) continue; + if ((m & print) == print && iswprint_l(ch, __l_)) continue; + if ((m & cntrl) == cntrl && iswcntrl_l(ch, __l_)) continue; + if ((m & upper) == upper && iswupper_l(ch, __l_)) continue; + if ((m & lower) == lower && iswlower_l(ch, __l_)) continue; + if ((m & alpha) == alpha && iswalpha_l(ch, __l_)) continue; + if ((m & digit) == digit && iswdigit_l(ch, __l_)) continue; + if ((m & punct) == punct && iswpunct_l(ch, __l_)) continue; + if ((m & xdigit) == xdigit && iswxdigit_l(ch, __l_)) continue; + if ((m & blank) == blank && iswblank_l(ch, __l_)) continue; break; #endif } @@ -1484,49 +1484,49 @@ ctype_byname<wchar_t>::do_scan_not(mask m, const char_type* low, const char_type wchar_t ctype_byname<wchar_t>::do_toupper(char_type c) const { - return towupper_l(c, __l); + return towupper_l(c, __l_); } const wchar_t* ctype_byname<wchar_t>::do_toupper(char_type* low, const char_type* high) const { for (; low != high; ++low) - *low = towupper_l(*low, __l); + *low = towupper_l(*low, __l_); return low; } wchar_t ctype_byname<wchar_t>::do_tolower(char_type c) const { - return towlower_l(c, __l); + return towlower_l(c, __l_); } const wchar_t* ctype_byname<wchar_t>::do_tolower(char_type* low, const char_type* high) const { for (; low != high; ++low) - *low = towlower_l(*low, __l); + *low = towlower_l(*low, __l_); return low; } wchar_t ctype_byname<wchar_t>::do_widen(char c) const { - return __libcpp_btowc_l(c, __l); + return __libcpp_btowc_l(c, __l_); } const char* ctype_byname<wchar_t>::do_widen(const char* low, const char* high, char_type* dest) const { for (; low != high; ++low, ++dest) - *dest = __libcpp_btowc_l(*low, __l); + *dest = __libcpp_btowc_l(*low, __l_); return low; } char ctype_byname<wchar_t>::do_narrow(char_type c, char dfault) const { - int r = __libcpp_wctob_l(c, __l); + int r = __libcpp_wctob_l(c, __l_); return (r != EOF) ? static_cast<char>(r) : dfault; } @@ -1535,7 +1535,7 @@ ctype_byname<wchar_t>::do_narrow(const char_type* low, const char_type* high, ch { for (; low != high; ++low, ++dest) { - int r = __libcpp_wctob_l(*low, __l); + int r = __libcpp_wctob_l(*low, __l_); *dest = (r != EOF) ? static_cast<char>(r) : dfault; } return low; @@ -1610,23 +1610,23 @@ locale::id codecvt<wchar_t, char, mbstate_t>::id; codecvt<wchar_t, char, mbstate_t>::codecvt(size_t refs) : locale::facet(refs), - __l(_LIBCPP_GET_C_LOCALE) + __l_(_LIBCPP_GET_C_LOCALE) { } codecvt<wchar_t, char, mbstate_t>::codecvt(const char* nm, size_t refs) : locale::facet(refs), - __l(newlocale(LC_ALL_MASK, nm, 0)) + __l_(newlocale(LC_ALL_MASK, nm, 0)) { - if (__l == 0) + if (__l_ == 0) __throw_runtime_error("codecvt_byname<wchar_t, char, mbstate_t>::codecvt_byname" " failed to construct for " + string(nm)); } codecvt<wchar_t, char, mbstate_t>::~codecvt() { - if (__l != _LIBCPP_GET_C_LOCALE) - freelocale(__l); + if (__l_ != _LIBCPP_GET_C_LOCALE) + freelocale(__l_); } codecvt<wchar_t, char, mbstate_t>::result @@ -1646,13 +1646,13 @@ codecvt<wchar_t, char, mbstate_t>::do_out(state_type& st, // save state in case it is needed to recover to_nxt on error mbstate_t save_state = st; size_t n = __libcpp_wcsnrtombs_l(to, &frm_nxt, static_cast<size_t>(fend-frm), - static_cast<size_t>(to_end-to), &st, __l); + static_cast<size_t>(to_end-to), &st, __l_); if (n == size_t(-1)) { // need to recover to_nxt for (to_nxt = to; frm != frm_nxt; ++frm) { - n = __libcpp_wcrtomb_l(to_nxt, *frm, &save_state, __l); + n = __libcpp_wcrtomb_l(to_nxt, *frm, &save_state, __l_); if (n == size_t(-1)) break; to_nxt += n; @@ -1669,7 +1669,7 @@ codecvt<wchar_t, char, mbstate_t>::do_out(state_type& st, { // Try to write the terminating null extern_type tmp[MB_LEN_MAX]; - n = __libcpp_wcrtomb_l(tmp, intern_type(), &st, __l); + n = __libcpp_wcrtomb_l(tmp, intern_type(), &st, __l_); if (n == size_t(-1)) // on error return error; if (n > static_cast<size_t>(to_end-to_nxt)) // is there room? @@ -1703,14 +1703,14 @@ codecvt<wchar_t, char, mbstate_t>::do_in(state_type& st, // save state in case it is needed to recover to_nxt on error mbstate_t save_state = st; size_t n = __libcpp_mbsnrtowcs_l(to, &frm_nxt, static_cast<size_t>(fend-frm), - static_cast<size_t>(to_end-to), &st, __l); + static_cast<size_t>(to_end-to), &st, __l_); if (n == size_t(-1)) { // need to recover to_nxt for (to_nxt = to; frm != frm_nxt; ++to_nxt) { n = __libcpp_mbrtowc_l(to_nxt, frm, static_cast<size_t>(fend-frm), - &save_state, __l); + &save_state, __l_); switch (n) { case 0: @@ -1738,7 +1738,7 @@ codecvt<wchar_t, char, mbstate_t>::do_in(state_type& st, if (fend != frm_end) // set up next null terminated sequence { // Try to write the terminating null - n = __libcpp_mbrtowc_l(to_nxt, frm_nxt, 1, &st, __l); + n = __libcpp_mbrtowc_l(to_nxt, frm_nxt, 1, &st, __l_); if (n != 0) // on error return error; ++to_nxt; @@ -1758,7 +1758,7 @@ codecvt<wchar_t, char, mbstate_t>::do_unshift(state_type& st, { to_nxt = to; extern_type tmp[MB_LEN_MAX]; - size_t n = __libcpp_wcrtomb_l(tmp, intern_type(), &st, __l); + size_t n = __libcpp_wcrtomb_l(tmp, intern_type(), &st, __l_); if (n == size_t(-1) || n == 0) // on error return error; --n; @@ -1772,11 +1772,11 @@ codecvt<wchar_t, char, mbstate_t>::do_unshift(state_type& st, int codecvt<wchar_t, char, mbstate_t>::do_encoding() const noexcept { - if (__libcpp_mbtowc_l(nullptr, nullptr, MB_LEN_MAX, __l) != 0) + if (__libcpp_mbtowc_l(nullptr, nullptr, MB_LEN_MAX, __l_) != 0) return -1; // stateless encoding - if (__l == 0 || __libcpp_mb_cur_max_l(__l) == 1) // there are no known constant length encodings + if (__l_ == 0 || __libcpp_mb_cur_max_l(__l_) == 1) // there are no known constant length encodings return 1; // which take more than 1 char to form a wchar_t return 0; } @@ -1794,7 +1794,7 @@ codecvt<wchar_t, char, mbstate_t>::do_length(state_type& st, int nbytes = 0; for (size_t nwchar_t = 0; nwchar_t < mx && frm != frm_end; ++nwchar_t) { - size_t n = __libcpp_mbrlen_l(frm, static_cast<size_t>(frm_end-frm), &st, __l); + size_t n = __libcpp_mbrlen_l(frm, static_cast<size_t>(frm_end-frm), &st, __l_); switch (n) { case 0: @@ -1816,7 +1816,7 @@ codecvt<wchar_t, char, mbstate_t>::do_length(state_type& st, int codecvt<wchar_t, char, mbstate_t>::do_max_length() const noexcept { - return __l == 0 ? 1 : static_cast<int>(__libcpp_mb_cur_max_l(__l)); + return __l_ == 0 ? 1 : static_cast<int>(__libcpp_mb_cur_max_l(__l_)); } #endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS @@ -3548,10 +3548,10 @@ __codecvt_utf8<wchar_t>::do_out(state_type&, uint8_t* _to_nxt = _to; #if defined(_LIBCPP_SHORT_WCHAR) result r = ucs2_to_utf8(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt, - _Maxcode_, _Mode_); + __maxcode_, __mode_); #else result r = ucs4_to_utf8(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt, - _Maxcode_, _Mode_); + __maxcode_, __mode_); #endif frm_nxt = frm + (_frm_nxt - _frm); to_nxt = to + (_to_nxt - _to); @@ -3571,13 +3571,13 @@ __codecvt_utf8<wchar_t>::do_in(state_type&, uint16_t* _to_end = reinterpret_cast<uint16_t*>(to_end); uint16_t* _to_nxt = _to; result r = utf8_to_ucs2(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt, - _Maxcode_, _Mode_); + __maxcode_, __mode_); #else uint32_t* _to = reinterpret_cast<uint32_t*>(to); uint32_t* _to_end = reinterpret_cast<uint32_t*>(to_end); uint32_t* _to_nxt = _to; result r = utf8_to_ucs4(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt, - _Maxcode_, _Mode_); + __maxcode_, __mode_); #endif frm_nxt = frm + (_frm_nxt - _frm); to_nxt = to + (_to_nxt - _to); @@ -3611,9 +3611,9 @@ __codecvt_utf8<wchar_t>::do_length(state_type&, const uint8_t* _frm = reinterpret_cast<const uint8_t*>(frm); const uint8_t* _frm_end = reinterpret_cast<const uint8_t*>(frm_end); #if defined(_LIBCPP_SHORT_WCHAR) - return utf8_to_ucs2_length(_frm, _frm_end, mx, _Maxcode_, _Mode_); + return utf8_to_ucs2_length(_frm, _frm_end, mx, __maxcode_, __mode_); #else - return utf8_to_ucs4_length(_frm, _frm_end, mx, _Maxcode_, _Mode_); + return utf8_to_ucs4_length(_frm, _frm_end, mx, __maxcode_, __mode_); #endif } @@ -3622,11 +3622,11 @@ int __codecvt_utf8<wchar_t>::do_max_length() const noexcept { #if defined(_LIBCPP_SHORT_WCHAR) - if (_Mode_ & consume_header) + if (__mode_ & consume_header) return 6; return 3; #else - if (_Mode_ & consume_header) + if (__mode_ & consume_header) return 7; return 4; #endif @@ -3647,7 +3647,7 @@ __codecvt_utf8<char16_t>::do_out(state_type&, uint8_t* _to_end = reinterpret_cast<uint8_t*>(to_end); uint8_t* _to_nxt = _to; result r = ucs2_to_utf8(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt, - _Maxcode_, _Mode_); + __maxcode_, __mode_); frm_nxt = frm + (_frm_nxt - _frm); to_nxt = to + (_to_nxt - _to); return r; @@ -3665,7 +3665,7 @@ __codecvt_utf8<char16_t>::do_in(state_type&, uint16_t* _to_end = reinterpret_cast<uint16_t*>(to_end); uint16_t* _to_nxt = _to; result r = utf8_to_ucs2(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt, - _Maxcode_, _Mode_); + __maxcode_, __mode_); frm_nxt = frm + (_frm_nxt - _frm); to_nxt = to + (_to_nxt - _to); return r; @@ -3697,14 +3697,14 @@ __codecvt_utf8<char16_t>::do_length(state_type&, { const uint8_t* _frm = reinterpret_cast<const uint8_t*>(frm); const uint8_t* _frm_end = reinterpret_cast<const uint8_t*>(frm_end); - return utf8_to_ucs2_length(_frm, _frm_end, mx, _Maxcode_, _Mode_); + return utf8_to_ucs2_length(_frm, _frm_end, mx, __maxcode_, __mode_); } _LIBCPP_SUPPRESS_DEPRECATED_PUSH int __codecvt_utf8<char16_t>::do_max_length() const noexcept { - if (_Mode_ & consume_header) + if (__mode_ & consume_header) return 6; return 3; } @@ -3724,7 +3724,7 @@ __codecvt_utf8<char32_t>::do_out(state_type&, uint8_t* _to_end = reinterpret_cast<uint8_t*>(to_end); uint8_t* _to_nxt = _to; result r = ucs4_to_utf8(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt, - _Maxcode_, _Mode_); + __maxcode_, __mode_); frm_nxt = frm + (_frm_nxt - _frm); to_nxt = to + (_to_nxt - _to); return r; @@ -3742,7 +3742,7 @@ __codecvt_utf8<char32_t>::do_in(state_type&, uint32_t* _to_end = reinterpret_cast<uint32_t*>(to_end); uint32_t* _to_nxt = _to; result r = utf8_to_ucs4(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt, - _Maxcode_, _Mode_); + __maxcode_, __mode_); frm_nxt = frm + (_frm_nxt - _frm); to_nxt = to + (_to_nxt - _to); return r; @@ -3774,14 +3774,14 @@ __codecvt_utf8<char32_t>::do_length(state_type&, { const uint8_t* _frm = reinterpret_cast<const uint8_t*>(frm); const uint8_t* _frm_end = reinterpret_cast<const uint8_t*>(frm_end); - return utf8_to_ucs4_length(_frm, _frm_end, mx, _Maxcode_, _Mode_); + return utf8_to_ucs4_length(_frm, _frm_end, mx, __maxcode_, __mode_); } _LIBCPP_SUPPRESS_DEPRECATED_PUSH int __codecvt_utf8<char32_t>::do_max_length() const noexcept { - if (_Mode_ & consume_header) + if (__mode_ & consume_header) return 7; return 4; } @@ -3809,10 +3809,10 @@ __codecvt_utf16<wchar_t, false>::do_out(state_type&, uint8_t* _to_nxt = _to; #if defined(_LIBCPP_SHORT_WCHAR) result r = ucs2_to_utf16be(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt, - _Maxcode_, _Mode_); + __maxcode_, __mode_); #else result r = ucs4_to_utf16be(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt, - _Maxcode_, _Mode_); + __maxcode_, __mode_); #endif frm_nxt = frm + (_frm_nxt - _frm); to_nxt = to + (_to_nxt - _to); @@ -3832,13 +3832,13 @@ __codecvt_utf16<wchar_t, false>::do_in(state_type&, uint16_t* _to_end = reinterpret_cast<uint16_t*>(to_end); uint16_t* _to_nxt = _to; result r = utf16be_to_ucs2(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt, - _Maxcode_, _Mode_); + __maxcode_, __mode_); #else uint32_t* _to = reinterpret_cast<uint32_t*>(to); uint32_t* _to_end = reinterpret_cast<uint32_t*>(to_end); uint32_t* _to_nxt = _to; result r = utf16be_to_ucs4(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt, - _Maxcode_, _Mode_); + __maxcode_, __mode_); #endif frm_nxt = frm + (_frm_nxt - _frm); to_nxt = to + (_to_nxt - _to); @@ -3872,9 +3872,9 @@ __codecvt_utf16<wchar_t, false>::do_length(state_type&, const uint8_t* _frm = reinterpret_cast<const uint8_t*>(frm); const uint8_t* _frm_end = reinterpret_cast<const uint8_t*>(frm_end); #if defined(_LIBCPP_SHORT_WCHAR) - return utf16be_to_ucs2_length(_frm, _frm_end, mx, _Maxcode_, _Mode_); + return utf16be_to_ucs2_length(_frm, _frm_end, mx, __maxcode_, __mode_); #else - return utf16be_to_ucs4_length(_frm, _frm_end, mx, _Maxcode_, _Mode_); + return utf16be_to_ucs4_length(_frm, _frm_end, mx, __maxcode_, __mode_); #endif } @@ -3882,11 +3882,11 @@ int __codecvt_utf16<wchar_t, false>::do_max_length() const noexcept { #if defined(_LIBCPP_SHORT_WCHAR) - if (_Mode_ & consume_header) + if (__mode_ & consume_header) return 4; return 2; #else - if (_Mode_ & consume_header) + if (__mode_ & consume_header) return 6; return 4; #endif @@ -3913,10 +3913,10 @@ __codecvt_utf16<wchar_t, true>::do_out(state_type&, uint8_t* _to_nxt = _to; #if defined(_LIBCPP_SHORT_WCHAR) result r = ucs2_to_utf16le(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt, - _Maxcode_, _Mode_); + __maxcode_, __mode_); #else result r = ucs4_to_utf16le(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt, - _Maxcode_, _Mode_); + __maxcode_, __mode_); #endif frm_nxt = frm + (_frm_nxt - _frm); to_nxt = to + (_to_nxt - _to); @@ -3936,13 +3936,13 @@ __codecvt_utf16<wchar_t, true>::do_in(state_type&, uint16_t* _to_end = reinterpret_cast<uint16_t*>(to_end); uint16_t* _to_nxt = _to; result r = utf16le_to_ucs2(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt, - _Maxcode_, _Mode_); + __maxcode_, __mode_); #else uint32_t* _to = reinterpret_cast<uint32_t*>(to); uint32_t* _to_end = reinterpret_cast<uint32_t*>(to_end); uint32_t* _to_nxt = _to; result r = utf16le_to_ucs4(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt, - _Maxcode_, _Mode_); + __maxcode_, __mode_); #endif frm_nxt = frm + (_frm_nxt - _frm); to_nxt = to + (_to_nxt - _to); @@ -3976,9 +3976,9 @@ __codecvt_utf16<wchar_t, true>::do_length(state_type&, const uint8_t* _frm = reinterpret_cast<const uint8_t*>(frm); const uint8_t* _frm_end = reinterpret_cast<const uint8_t*>(frm_end); #if defined(_LIBCPP_SHORT_WCHAR) - return utf16le_to_ucs2_length(_frm, _frm_end, mx, _Maxcode_, _Mode_); + return utf16le_to_ucs2_length(_frm, _frm_end, mx, __maxcode_, __mode_); #else - return utf16le_to_ucs4_length(_frm, _frm_end, mx, _Maxcode_, _Mode_); + return utf16le_to_ucs4_length(_frm, _frm_end, mx, __maxcode_, __mode_); #endif } @@ -3986,11 +3986,11 @@ int __codecvt_utf16<wchar_t, true>::do_max_length() const noexcept { #if defined(_LIBCPP_SHORT_WCHAR) - if (_Mode_ & consume_header) + if (__mode_ & consume_header) return 4; return 2; #else - if (_Mode_ & consume_header) + if (__mode_ & consume_header) return 6; return 4; #endif @@ -4011,7 +4011,7 @@ __codecvt_utf16<char16_t, false>::do_out(state_type&, uint8_t* _to_end = reinterpret_cast<uint8_t*>(to_end); uint8_t* _to_nxt = _to; result r = ucs2_to_utf16be(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt, - _Maxcode_, _Mode_); + __maxcode_, __mode_); frm_nxt = frm + (_frm_nxt - _frm); to_nxt = to + (_to_nxt - _to); return r; @@ -4029,7 +4029,7 @@ __codecvt_utf16<char16_t, false>::do_in(state_type&, uint16_t* _to_end = reinterpret_cast<uint16_t*>(to_end); uint16_t* _to_nxt = _to; result r = utf16be_to_ucs2(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt, - _Maxcode_, _Mode_); + __maxcode_, __mode_); frm_nxt = frm + (_frm_nxt - _frm); to_nxt = to + (_to_nxt - _to); return r; @@ -4061,14 +4061,14 @@ __codecvt_utf16<char16_t, false>::do_length(state_type&, { const uint8_t* _frm = reinterpret_cast<const uint8_t*>(frm); const uint8_t* _frm_end = reinterpret_cast<const uint8_t*>(frm_end); - return utf16be_to_ucs2_length(_frm, _frm_end, mx, _Maxcode_, _Mode_); + return utf16be_to_ucs2_length(_frm, _frm_end, mx, __maxcode_, __mode_); } _LIBCPP_SUPPRESS_DEPRECATED_PUSH int __codecvt_utf16<char16_t, false>::do_max_length() const noexcept { - if (_Mode_ & consume_header) + if (__mode_ & consume_header) return 4; return 2; } @@ -4088,7 +4088,7 @@ __codecvt_utf16<char16_t, true>::do_out(state_type&, uint8_t* _to_end = reinterpret_cast<uint8_t*>(to_end); uint8_t* _to_nxt = _to; result r = ucs2_to_utf16le(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt, - _Maxcode_, _Mode_); + __maxcode_, __mode_); frm_nxt = frm + (_frm_nxt - _frm); to_nxt = to + (_to_nxt - _to); return r; @@ -4106,7 +4106,7 @@ __codecvt_utf16<char16_t, true>::do_in(state_type&, uint16_t* _to_end = reinterpret_cast<uint16_t*>(to_end); uint16_t* _to_nxt = _to; result r = utf16le_to_ucs2(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt, - _Maxcode_, _Mode_); + __maxcode_, __mode_); frm_nxt = frm + (_frm_nxt - _frm); to_nxt = to + (_to_nxt - _to); return r; @@ -4138,14 +4138,14 @@ __codecvt_utf16<char16_t, true>::do_length(state_type&, { const uint8_t* _frm = reinterpret_cast<const uint8_t*>(frm); const uint8_t* _frm_end = reinterpret_cast<const uint8_t*>(frm_end); - return utf16le_to_ucs2_length(_frm, _frm_end, mx, _Maxcode_, _Mode_); + return utf16le_to_ucs2_length(_frm, _frm_end, mx, __maxcode_, __mode_); } _LIBCPP_SUPPRESS_DEPRECATED_PUSH int __codecvt_utf16<char16_t, true>::do_max_length() const noexcept { - if (_Mode_ & consume_header) + if (__mode_ & consume_header) return 4; return 2; } @@ -4165,7 +4165,7 @@ __codecvt_utf16<char32_t, false>::do_out(state_type&, uint8_t* _to_end = reinterpret_cast<uint8_t*>(to_end); uint8_t* _to_nxt = _to; result r = ucs4_to_utf16be(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt, - _Maxcode_, _Mode_); + __maxcode_, __mode_); frm_nxt = frm + (_frm_nxt - _frm); to_nxt = to + (_to_nxt - _to); return r; @@ -4183,7 +4183,7 @@ __codecvt_utf16<char32_t, false>::do_in(state_type&, uint32_t* _to_end = reinterpret_cast<uint32_t*>(to_end); uint32_t* _to_nxt = _to; result r = utf16be_to_ucs4(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt, - _Maxcode_, _Mode_); + __maxcode_, __mode_); frm_nxt = frm + (_frm_nxt - _frm); to_nxt = to + (_to_nxt - _to); return r; @@ -4215,14 +4215,14 @@ __codecvt_utf16<char32_t, false>::do_length(state_type&, { const uint8_t* _frm = reinterpret_cast<const uint8_t*>(frm); const uint8_t* _frm_end = reinterpret_cast<const uint8_t*>(frm_end); - return utf16be_to_ucs4_length(_frm, _frm_end, mx, _Maxcode_, _Mode_); + return utf16be_to_ucs4_length(_frm, _frm_end, mx, __maxcode_, __mode_); } _LIBCPP_SUPPRESS_DEPRECATED_PUSH int __codecvt_utf16<char32_t, false>::do_max_length() const noexcept { - if (_Mode_ & consume_header) + if (__mode_ & consume_header) return 6; return 4; } @@ -4249,10 +4249,10 @@ __codecvt_utf16<char32_t, true>::do_out(state_type&, uint8_t* _to_nxt = _to; #if defined(_LIBCPP_SHORT_WCHAR) result r = ucs2_to_utf16le(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt, - _Maxcode_, _Mode_); + __maxcode_, __mode_); #else result r = ucs4_to_utf16le(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt, - _Maxcode_, _Mode_); + __maxcode_, __mode_); #endif frm_nxt = frm + (_frm_nxt - _frm); to_nxt = to + (_to_nxt - _to); @@ -4271,7 +4271,7 @@ __codecvt_utf16<char32_t, true>::do_in(state_type&, uint32_t* _to_end = reinterpret_cast<uint32_t*>(to_end); uint32_t* _to_nxt = _to; result r = utf16le_to_ucs4(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt, - _Maxcode_, _Mode_); + __maxcode_, __mode_); frm_nxt = frm + (_frm_nxt - _frm); to_nxt = to + (_to_nxt - _to); return r; @@ -4303,14 +4303,14 @@ __codecvt_utf16<char32_t, true>::do_length(state_type&, { const uint8_t* _frm = reinterpret_cast<const uint8_t*>(frm); const uint8_t* _frm_end = reinterpret_cast<const uint8_t*>(frm_end); - return utf16le_to_ucs4_length(_frm, _frm_end, mx, _Maxcode_, _Mode_); + return utf16le_to_ucs4_length(_frm, _frm_end, mx, __maxcode_, __mode_); } _LIBCPP_SUPPRESS_DEPRECATED_PUSH int __codecvt_utf16<char32_t, true>::do_max_length() const noexcept { - if (_Mode_ & consume_header) + if (__mode_ & consume_header) return 6; return 4; } @@ -4337,7 +4337,7 @@ __codecvt_utf8_utf16<wchar_t>::do_out(state_type&, uint8_t* _to_end = reinterpret_cast<uint8_t*>(to_end); uint8_t* _to_nxt = _to; result r = utf16_to_utf8(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt, - _Maxcode_, _Mode_); + __maxcode_, __mode_); frm_nxt = frm + (_frm_nxt - _frm); to_nxt = to + (_to_nxt - _to); return r; @@ -4361,7 +4361,7 @@ __codecvt_utf8_utf16<wchar_t>::do_in(state_type&, uint32_t* _to_nxt = _to; #endif result r = utf8_to_utf16(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt, - _Maxcode_, _Mode_); + __maxcode_, __mode_); frm_nxt = frm + (_frm_nxt - _frm); to_nxt = to + (_to_nxt - _to); return r; @@ -4393,13 +4393,13 @@ __codecvt_utf8_utf16<wchar_t>::do_length(state_type&, { const uint8_t* _frm = reinterpret_cast<const uint8_t*>(frm); const uint8_t* _frm_end = reinterpret_cast<const uint8_t*>(frm_end); - return utf8_to_utf16_length(_frm, _frm_end, mx, _Maxcode_, _Mode_); + return utf8_to_utf16_length(_frm, _frm_end, mx, __maxcode_, __mode_); } int __codecvt_utf8_utf16<wchar_t>::do_max_length() const noexcept { - if (_Mode_ & consume_header) + if (__mode_ & consume_header) return 7; return 4; } @@ -4419,7 +4419,7 @@ __codecvt_utf8_utf16<char16_t>::do_out(state_type&, uint8_t* _to_end = reinterpret_cast<uint8_t*>(to_end); uint8_t* _to_nxt = _to; result r = utf16_to_utf8(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt, - _Maxcode_, _Mode_); + __maxcode_, __mode_); frm_nxt = frm + (_frm_nxt - _frm); to_nxt = to + (_to_nxt - _to); return r; @@ -4437,7 +4437,7 @@ __codecvt_utf8_utf16<char16_t>::do_in(state_type&, uint16_t* _to_end = reinterpret_cast<uint16_t*>(to_end); uint16_t* _to_nxt = _to; result r = utf8_to_utf16(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt, - _Maxcode_, _Mode_); + __maxcode_, __mode_); frm_nxt = frm + (_frm_nxt - _frm); to_nxt = to + (_to_nxt - _to); return r; @@ -4469,14 +4469,14 @@ __codecvt_utf8_utf16<char16_t>::do_length(state_type&, { const uint8_t* _frm = reinterpret_cast<const uint8_t*>(frm); const uint8_t* _frm_end = reinterpret_cast<const uint8_t*>(frm_end); - return utf8_to_utf16_length(_frm, _frm_end, mx, _Maxcode_, _Mode_); + return utf8_to_utf16_length(_frm, _frm_end, mx, __maxcode_, __mode_); } _LIBCPP_SUPPRESS_DEPRECATED_PUSH int __codecvt_utf8_utf16<char16_t>::do_max_length() const noexcept { - if (_Mode_ & consume_header) + if (__mode_ & consume_header) return 7; return 4; } @@ -4496,7 +4496,7 @@ __codecvt_utf8_utf16<char32_t>::do_out(state_type&, uint8_t* _to_end = reinterpret_cast<uint8_t*>(to_end); uint8_t* _to_nxt = _to; result r = utf16_to_utf8(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt, - _Maxcode_, _Mode_); + __maxcode_, __mode_); frm_nxt = frm + (_frm_nxt - _frm); to_nxt = to + (_to_nxt - _to); return r; @@ -4520,7 +4520,7 @@ __codecvt_utf8_utf16<char32_t>::do_in(state_type&, uint32_t* _to_nxt = _to; #endif result r = utf8_to_utf16(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt, - _Maxcode_, _Mode_); + __maxcode_, __mode_); frm_nxt = frm + (_frm_nxt - _frm); to_nxt = to + (_to_nxt - _to); return r; @@ -4552,14 +4552,14 @@ __codecvt_utf8_utf16<char32_t>::do_length(state_type&, { const uint8_t* _frm = reinterpret_cast<const uint8_t*>(frm); const uint8_t* _frm_end = reinterpret_cast<const uint8_t*>(frm_end); - return utf8_to_utf16_length(_frm, _frm_end, mx, _Maxcode_, _Mode_); + return utf8_to_utf16_length(_frm, _frm_end, mx, __maxcode_, __mode_); } _LIBCPP_SUPPRESS_DEPRECATED_PUSH int __codecvt_utf8_utf16<char32_t>::do_max_length() const noexcept { - if (_Mode_ & consume_header) + if (__mode_ & consume_header) return 7; return 4; } @@ -4858,7 +4858,7 @@ __num_put_base::__format_int(char* __fmtp, const char* __len, bool __signd, if ((__flags & ios_base::showpos) && (__flags & ios_base::basefield) != ios_base::oct && (__flags & ios_base::basefield) != ios_base::hex && - __signd) + __signd) *__fmtp++ = '+'; if (__flags & ios_base::showbase) *__fmtp++ = '#'; diff --git a/contrib/libs/cxxsupp/libcxx/src/memory.cpp b/contrib/libs/cxxsupp/libcxx/src/memory.cpp index 004634f3eb..9c0ee5d6f3 100644 --- a/contrib/libs/cxxsupp/libcxx/src/memory.cpp +++ b/contrib/libs/cxxsupp/libcxx/src/memory.cpp @@ -184,21 +184,21 @@ static constinit __libcpp_mutex_t mut_back[__sp_mut_count] = }; _LIBCPP_CONSTEXPR __sp_mut::__sp_mut(void* p) noexcept - : __lx(p) + : __lx_(p) { } void __sp_mut::lock() noexcept { - auto m = static_cast<__libcpp_mutex_t*>(__lx); + auto m = static_cast<__libcpp_mutex_t*>(__lx_); __libcpp_mutex_lock(m); } void __sp_mut::unlock() noexcept { - __libcpp_mutex_unlock(static_cast<__libcpp_mutex_t*>(__lx)); + __libcpp_mutex_unlock(static_cast<__libcpp_mutex_t*>(__lx_)); } __sp_mut& @@ -226,7 +226,7 @@ align(size_t alignment, size_t size, void*& ptr, size_t& space) if (size <= space) { char* p1 = static_cast<char*>(ptr); - char* p2 = reinterpret_cast<char*>(reinterpret_cast<size_t>(p1 + (alignment - 1)) & -alignment); + char* p2 = reinterpret_cast<char*>(reinterpret_cast<uintptr_t>(p1 + (alignment - 1)) & -alignment); size_t d = static_cast<size_t>(p2 - p1); if (d <= space - size) { diff --git a/contrib/libs/cxxsupp/libcxx/src/memory_resource.cpp b/contrib/libs/cxxsupp/libcxx/src/memory_resource.cpp new file mode 100644 index 0000000000..d4a735b423 --- /dev/null +++ b/contrib/libs/cxxsupp/libcxx/src/memory_resource.cpp @@ -0,0 +1,479 @@ +//===----------------------------------------------------------------------===// +// +// 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 <memory> +#include <memory_resource> + +#ifndef _LIBCPP_HAS_NO_ATOMIC_HEADER +# include <atomic> +#elif !defined(_LIBCPP_HAS_NO_THREADS) +# include <mutex> +# if defined(__ELF__) && defined(_LIBCPP_LINK_PTHREAD_LIB) +# pragma comment(lib, "pthread") +# endif +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +namespace pmr { + +// memory_resource + +memory_resource::~memory_resource() = default; + +// new_delete_resource() + +#ifdef _LIBCPP_HAS_NO_ALIGNED_ALLOCATION +static bool is_aligned_to(void* ptr, size_t align) { + void* p2 = ptr; + size_t space = 1; + void* result = std::align(align, 1, p2, space); + return (result == ptr); +} +#endif + +class _LIBCPP_TYPE_VIS __new_delete_memory_resource_imp : public memory_resource { + void* do_allocate(size_t bytes, size_t align) override { +#ifndef _LIBCPP_HAS_NO_ALIGNED_ALLOCATION + return std::__libcpp_allocate(bytes, align); +#else + if (bytes == 0) + bytes = 1; + void* result = std::__libcpp_allocate(bytes, align); + if (!is_aligned_to(result, align)) { + std::__libcpp_deallocate(result, bytes, align); + __throw_bad_alloc(); + } + return result; +#endif + } + + void do_deallocate(void* p, size_t bytes, size_t align) override { std::__libcpp_deallocate(p, bytes, align); } + + bool do_is_equal(const memory_resource& other) const noexcept override { return &other == this; } +}; + +// null_memory_resource() + +class _LIBCPP_TYPE_VIS __null_memory_resource_imp : public memory_resource { + void* do_allocate(size_t, size_t) override { __throw_bad_alloc(); } + void do_deallocate(void*, size_t, size_t) override {} + bool do_is_equal(const memory_resource& other) const noexcept override { return &other == this; } +}; + +namespace { + +union ResourceInitHelper { + struct { + __new_delete_memory_resource_imp new_delete_res; + __null_memory_resource_imp null_res; + } resources; + char dummy; + _LIBCPP_CONSTEXPR_SINCE_CXX14 ResourceInitHelper() : resources() {} + ~ResourceInitHelper() {} +}; + +// Pretend we're inside a system header so the compiler doesn't flag the use of the init_priority +// attribute with a value that's reserved for the implementation (we're the implementation). +#include "memory_resource_init_helper.h" + +} // end namespace + +memory_resource* new_delete_resource() noexcept { return &res_init.resources.new_delete_res; } + +memory_resource* null_memory_resource() noexcept { return &res_init.resources.null_res; } + +// default_memory_resource() + +static memory_resource* __default_memory_resource(bool set = false, memory_resource* new_res = nullptr) noexcept { +#ifndef _LIBCPP_HAS_NO_ATOMIC_HEADER + static constinit atomic<memory_resource*> __res{&res_init.resources.new_delete_res}; + if (set) { + new_res = new_res ? new_res : new_delete_resource(); + // TODO: Can a weaker ordering be used? + return std::atomic_exchange_explicit(&__res, new_res, memory_order_acq_rel); + } else { + return std::atomic_load_explicit(&__res, memory_order_acquire); + } +#elif !defined(_LIBCPP_HAS_NO_THREADS) + static constinit memory_resource* res = &res_init.resources.new_delete_res; + static mutex res_lock; + if (set) { + new_res = new_res ? new_res : new_delete_resource(); + lock_guard<mutex> guard(res_lock); + memory_resource* old_res = res; + res = new_res; + return old_res; + } else { + lock_guard<mutex> guard(res_lock); + return res; + } +#else + static constinit memory_resource* res = &res_init.resources.new_delete_res; + if (set) { + new_res = new_res ? new_res : new_delete_resource(); + memory_resource* old_res = res; + res = new_res; + return old_res; + } else { + return res; + } +#endif +} + +memory_resource* get_default_resource() noexcept { return __default_memory_resource(); } + +memory_resource* set_default_resource(memory_resource* __new_res) noexcept { + return __default_memory_resource(true, __new_res); +} + +// 23.12.5, mem.res.pool + +static size_t roundup(size_t count, size_t alignment) { + size_t mask = alignment - 1; + return (count + mask) & ~mask; +} + +struct unsynchronized_pool_resource::__adhoc_pool::__chunk_footer { + __chunk_footer* __next_; + char* __start_; + size_t __align_; + size_t __allocation_size() { return (reinterpret_cast<char*>(this) - __start_) + sizeof(*this); } +}; + +void unsynchronized_pool_resource::__adhoc_pool::__release_ptr(memory_resource* upstream) { + while (__first_ != nullptr) { + __chunk_footer* next = __first_->__next_; + upstream->deallocate(__first_->__start_, __first_->__allocation_size(), __first_->__align_); + __first_ = next; + } +} + +void* unsynchronized_pool_resource::__adhoc_pool::__do_allocate(memory_resource* upstream, size_t bytes, size_t align) { + const size_t footer_size = sizeof(__chunk_footer); + const size_t footer_align = alignof(__chunk_footer); + + if (align < footer_align) + align = footer_align; + + size_t aligned_capacity = roundup(bytes, footer_align) + footer_size; + + void* result = upstream->allocate(aligned_capacity, align); + + __chunk_footer* h = (__chunk_footer*)((char*)result + aligned_capacity - footer_size); + h->__next_ = __first_; + h->__start_ = (char*)result; + h->__align_ = align; + __first_ = h; + return result; +} + +void unsynchronized_pool_resource::__adhoc_pool::__do_deallocate( + memory_resource* upstream, void* p, size_t bytes, size_t align) { + _LIBCPP_ASSERT(__first_ != nullptr, "deallocating a block that was not allocated with this allocator"); + if (__first_->__start_ == p) { + __chunk_footer* next = __first_->__next_; + upstream->deallocate(p, __first_->__allocation_size(), __first_->__align_); + __first_ = next; + } else { + for (__chunk_footer* h = __first_; h->__next_ != nullptr; h = h->__next_) { + if (h->__next_->__start_ == p) { + __chunk_footer* next = h->__next_->__next_; + upstream->deallocate(p, h->__next_->__allocation_size(), h->__next_->__align_); + h->__next_ = next; + return; + } + } + _LIBCPP_ASSERT(false, "deallocating a block that was not allocated with this allocator"); + } +} + +class unsynchronized_pool_resource::__fixed_pool { + struct __chunk_footer { + __chunk_footer* __next_; + char* __start_; + size_t __align_; + size_t __allocation_size() { return (reinterpret_cast<char*>(this) - __start_) + sizeof(*this); } + }; + + struct __vacancy_header { + __vacancy_header* __next_vacancy_; + }; + + __chunk_footer* __first_chunk_ = nullptr; + __vacancy_header* __first_vacancy_ = nullptr; + +public: + explicit __fixed_pool() = default; + + void __release_ptr(memory_resource* upstream) { + __first_vacancy_ = nullptr; + while (__first_chunk_ != nullptr) { + __chunk_footer* next = __first_chunk_->__next_; + upstream->deallocate(__first_chunk_->__start_, __first_chunk_->__allocation_size(), __first_chunk_->__align_); + __first_chunk_ = next; + } + } + + void* __try_allocate_from_vacancies() { + if (__first_vacancy_ != nullptr) { + void* result = __first_vacancy_; + __first_vacancy_ = __first_vacancy_->__next_vacancy_; + return result; + } + return nullptr; + } + + void* __allocate_in_new_chunk(memory_resource* upstream, size_t block_size, size_t chunk_size) { + _LIBCPP_ASSERT(chunk_size % block_size == 0, ""); + static_assert(__default_alignment >= alignof(std::max_align_t), ""); + static_assert(__default_alignment >= alignof(__chunk_footer), ""); + static_assert(__default_alignment >= alignof(__vacancy_header), ""); + + const size_t footer_size = sizeof(__chunk_footer); + const size_t footer_align = alignof(__chunk_footer); + + size_t aligned_capacity = roundup(chunk_size, footer_align) + footer_size; + + void* result = upstream->allocate(aligned_capacity, __default_alignment); + + __chunk_footer* h = (__chunk_footer*)((char*)result + aligned_capacity - footer_size); + h->__next_ = __first_chunk_; + h->__start_ = (char*)result; + h->__align_ = __default_alignment; + __first_chunk_ = h; + + if (chunk_size > block_size) { + __vacancy_header* last_vh = this->__first_vacancy_; + for (size_t i = block_size; i != chunk_size; i += block_size) { + __vacancy_header* vh = (__vacancy_header*)((char*)result + i); + vh->__next_vacancy_ = last_vh; + last_vh = vh; + } + this->__first_vacancy_ = last_vh; + } + return result; + } + + void __evacuate(void* p) { + __vacancy_header* vh = (__vacancy_header*)(p); + vh->__next_vacancy_ = __first_vacancy_; + __first_vacancy_ = vh; + } + + size_t __previous_chunk_size_in_bytes() const { return __first_chunk_ ? __first_chunk_->__allocation_size() : 0; } + + static const size_t __default_alignment = alignof(max_align_t); +}; + +size_t unsynchronized_pool_resource::__pool_block_size(int i) const { return size_t(1) << __log2_pool_block_size(i); } + +int unsynchronized_pool_resource::__log2_pool_block_size(int i) const { return (i + __log2_smallest_block_size); } + +int unsynchronized_pool_resource::__pool_index(size_t bytes, size_t align) const { + if (align > alignof(std::max_align_t) || bytes > (size_t(1) << __num_fixed_pools_)) + return __num_fixed_pools_; + else { + int i = 0; + bytes = (bytes > align) ? bytes : align; + bytes -= 1; + bytes >>= __log2_smallest_block_size; + while (bytes != 0) { + bytes >>= 1; + i += 1; + } + return i; + } +} + +unsynchronized_pool_resource::unsynchronized_pool_resource(const pool_options& opts, memory_resource* upstream) + : __res_(upstream), __fixed_pools_(nullptr) { + size_t largest_block_size; + if (opts.largest_required_pool_block == 0) + largest_block_size = __default_largest_block_size; + else if (opts.largest_required_pool_block < __smallest_block_size) + largest_block_size = __smallest_block_size; + else if (opts.largest_required_pool_block > __max_largest_block_size) + largest_block_size = __max_largest_block_size; + else + largest_block_size = opts.largest_required_pool_block; + + if (opts.max_blocks_per_chunk == 0) + __options_max_blocks_per_chunk_ = __max_blocks_per_chunk; + else if (opts.max_blocks_per_chunk < __min_blocks_per_chunk) + __options_max_blocks_per_chunk_ = __min_blocks_per_chunk; + else if (opts.max_blocks_per_chunk > __max_blocks_per_chunk) + __options_max_blocks_per_chunk_ = __max_blocks_per_chunk; + else + __options_max_blocks_per_chunk_ = opts.max_blocks_per_chunk; + + __num_fixed_pools_ = 1; + size_t capacity = __smallest_block_size; + while (capacity < largest_block_size) { + capacity <<= 1; + __num_fixed_pools_ += 1; + } +} + +pool_options unsynchronized_pool_resource::options() const { + pool_options p; + p.max_blocks_per_chunk = __options_max_blocks_per_chunk_; + p.largest_required_pool_block = __pool_block_size(__num_fixed_pools_ - 1); + return p; +} + +void unsynchronized_pool_resource::release() { + __adhoc_pool_.__release_ptr(__res_); + if (__fixed_pools_ != nullptr) { + const int n = __num_fixed_pools_; + for (int i = 0; i < n; ++i) + __fixed_pools_[i].__release_ptr(__res_); + __res_->deallocate(__fixed_pools_, __num_fixed_pools_ * sizeof(__fixed_pool), alignof(__fixed_pool)); + __fixed_pools_ = nullptr; + } +} + +void* unsynchronized_pool_resource::do_allocate(size_t bytes, size_t align) { + // A pointer to allocated storage (6.6.4.4.1) with a size of at least bytes. + // The size and alignment of the allocated memory shall meet the requirements for + // a class derived from memory_resource (23.12). + // If the pool selected for a block of size bytes is unable to satisfy the memory request + // from its own internal data structures, it will call upstream_resource()->allocate() + // to obtain more memory. If bytes is larger than that which the largest pool can handle, + // then memory will be allocated using upstream_resource()->allocate(). + + int i = __pool_index(bytes, align); + if (i == __num_fixed_pools_) + return __adhoc_pool_.__do_allocate(__res_, bytes, align); + else { + if (__fixed_pools_ == nullptr) { + __fixed_pools_ = + (__fixed_pool*)__res_->allocate(__num_fixed_pools_ * sizeof(__fixed_pool), alignof(__fixed_pool)); + __fixed_pool* first = __fixed_pools_; + __fixed_pool* last = __fixed_pools_ + __num_fixed_pools_; + for (__fixed_pool* pool = first; pool != last; ++pool) + ::new ((void*)pool) __fixed_pool; + } + void* result = __fixed_pools_[i].__try_allocate_from_vacancies(); + if (result == nullptr) { + auto min = [](size_t a, size_t b) { return a < b ? a : b; }; + auto max = [](size_t a, size_t b) { return a < b ? b : a; }; + + size_t prev_chunk_size_in_bytes = __fixed_pools_[i].__previous_chunk_size_in_bytes(); + size_t prev_chunk_size_in_blocks = prev_chunk_size_in_bytes >> __log2_pool_block_size(i); + + size_t chunk_size_in_blocks; + + if (prev_chunk_size_in_blocks == 0) { + size_t min_blocks_per_chunk = max(__min_bytes_per_chunk >> __log2_pool_block_size(i), __min_blocks_per_chunk); + chunk_size_in_blocks = min_blocks_per_chunk; + } else { + static_assert(__max_bytes_per_chunk <= SIZE_MAX - (__max_bytes_per_chunk / 4), "unsigned overflow is possible"); + chunk_size_in_blocks = prev_chunk_size_in_blocks + (prev_chunk_size_in_blocks / 4); + } + + size_t max_blocks_per_chunk = + min((__max_bytes_per_chunk >> __log2_pool_block_size(i)), + min(__max_blocks_per_chunk, __options_max_blocks_per_chunk_)); + if (chunk_size_in_blocks > max_blocks_per_chunk) + chunk_size_in_blocks = max_blocks_per_chunk; + + size_t block_size = __pool_block_size(i); + + size_t chunk_size_in_bytes = (chunk_size_in_blocks << __log2_pool_block_size(i)); + result = __fixed_pools_[i].__allocate_in_new_chunk(__res_, block_size, chunk_size_in_bytes); + } + return result; + } +} + +void unsynchronized_pool_resource::do_deallocate(void* p, size_t bytes, size_t align) { + // Returns the memory at p to the pool. It is unspecified if, + // or under what circumstances, this operation will result in + // a call to upstream_resource()->deallocate(). + + int i = __pool_index(bytes, align); + if (i == __num_fixed_pools_) + return __adhoc_pool_.__do_deallocate(__res_, p, bytes, align); + else { + _LIBCPP_ASSERT(__fixed_pools_ != nullptr, "deallocating a block that was not allocated with this allocator"); + __fixed_pools_[i].__evacuate(p); + } +} + +bool synchronized_pool_resource::do_is_equal(const memory_resource& other) const noexcept { return &other == this; } + +// 23.12.6, mem.res.monotonic.buffer + +void* monotonic_buffer_resource::__initial_descriptor::__try_allocate_from_chunk(size_t bytes, size_t align) { + if (!__cur_) + return nullptr; + void* new_ptr = static_cast<void*>(__cur_); + size_t new_capacity = (__end_ - __cur_); + void* aligned_ptr = std::align(align, bytes, new_ptr, new_capacity); + if (aligned_ptr != nullptr) + __cur_ = static_cast<char*>(new_ptr) + bytes; + return aligned_ptr; +} + +void* monotonic_buffer_resource::__chunk_footer::__try_allocate_from_chunk(size_t bytes, size_t align) { + void* new_ptr = static_cast<void*>(__cur_); + size_t new_capacity = (reinterpret_cast<char*>(this) - __cur_); + void* aligned_ptr = std::align(align, bytes, new_ptr, new_capacity); + if (aligned_ptr != nullptr) + __cur_ = static_cast<char*>(new_ptr) + bytes; + return aligned_ptr; +} + +void* monotonic_buffer_resource::do_allocate(size_t bytes, size_t align) { + const size_t footer_size = sizeof(__chunk_footer); + const size_t footer_align = alignof(__chunk_footer); + + auto previous_allocation_size = [&]() { + if (__chunks_ != nullptr) + return __chunks_->__allocation_size(); + + size_t newsize = (__initial_.__start_ != nullptr) ? (__initial_.__end_ - __initial_.__start_) : __initial_.__size_; + + return roundup(newsize, footer_align) + footer_size; + }; + + if (void* result = __initial_.__try_allocate_from_chunk(bytes, align)) + return result; + if (__chunks_ != nullptr) { + if (void* result = __chunks_->__try_allocate_from_chunk(bytes, align)) + return result; + } + + // Allocate a brand-new chunk. + + if (align < footer_align) + align = footer_align; + + size_t aligned_capacity = roundup(bytes, footer_align) + footer_size; + size_t previous_capacity = previous_allocation_size(); + + if (aligned_capacity <= previous_capacity) { + size_t newsize = 2 * (previous_capacity - footer_size); + aligned_capacity = roundup(newsize, footer_align) + footer_size; + } + + char* start = (char*)__res_->allocate(aligned_capacity, align); + __chunk_footer* footer = (__chunk_footer*)(start + aligned_capacity - footer_size); + footer->__next_ = __chunks_; + footer->__start_ = start; + footer->__cur_ = start; + footer->__align_ = align; + __chunks_ = footer; + + return __chunks_->__try_allocate_from_chunk(bytes, align); +} + +} // namespace pmr + +_LIBCPP_END_NAMESPACE_STD diff --git a/contrib/libs/cxxsupp/libcxx/src/memory_resource_init_helper.h b/contrib/libs/cxxsupp/libcxx/src/memory_resource_init_helper.h new file mode 100644 index 0000000000..032edc12fa --- /dev/null +++ b/contrib/libs/cxxsupp/libcxx/src/memory_resource_init_helper.h @@ -0,0 +1,2 @@ +#pragma GCC system_header +static constinit ResourceInitHelper res_init _LIBCPP_INIT_PRIORITY_MAX; diff --git a/contrib/libs/cxxsupp/libcxx/src/optional.cpp b/contrib/libs/cxxsupp/libcxx/src/optional.cpp index e9573bfa30..e2b5ccef99 100644 --- a/contrib/libs/cxxsupp/libcxx/src/optional.cpp +++ b/contrib/libs/cxxsupp/libcxx/src/optional.cpp @@ -16,7 +16,7 @@ bad_optional_access::~bad_optional_access() noexcept = default; const char* bad_optional_access::what() const noexcept { return "bad_optional_access"; - } +} } // std @@ -28,13 +28,13 @@ const char* bad_optional_access::what() const noexcept { _LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL class _LIBCPP_EXCEPTION_ABI _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS bad_optional_access - : public std::logic_error + : public std::logic_error { public: - bad_optional_access() : std::logic_error("Bad optional Access") {} + bad_optional_access() : std::logic_error("Bad optional Access") {} -// Get the key function ~bad_optional_access() into the dylib - virtual ~bad_optional_access() noexcept; + // Get the key function ~bad_optional_access() into the dylib + virtual ~bad_optional_access() noexcept; }; bad_optional_access::~bad_optional_access() noexcept = default; diff --git a/contrib/libs/cxxsupp/libcxx/src/shared_mutex.cpp b/contrib/libs/cxxsupp/libcxx/src/shared_mutex.cpp index deb3ced014..73d4dc1c1c 100644 --- a/contrib/libs/cxxsupp/libcxx/src/shared_mutex.cpp +++ b/contrib/libs/cxxsupp/libcxx/src/shared_mutex.cpp @@ -106,13 +106,13 @@ __shared_mutex_base::unlock_shared() // Shared Timed Mutex // These routines are here for ABI stability -shared_timed_mutex::shared_timed_mutex() : __base() {} -void shared_timed_mutex::lock() { return __base.lock(); } -bool shared_timed_mutex::try_lock() { return __base.try_lock(); } -void shared_timed_mutex::unlock() { return __base.unlock(); } -void shared_timed_mutex::lock_shared() { return __base.lock_shared(); } -bool shared_timed_mutex::try_lock_shared() { return __base.try_lock_shared(); } -void shared_timed_mutex::unlock_shared() { return __base.unlock_shared(); } +shared_timed_mutex::shared_timed_mutex() : __base_() {} +void shared_timed_mutex::lock() { return __base_.lock(); } +bool shared_timed_mutex::try_lock() { return __base_.try_lock(); } +void shared_timed_mutex::unlock() { return __base_.unlock(); } +void shared_timed_mutex::lock_shared() { return __base_.lock_shared(); } +bool shared_timed_mutex::try_lock_shared() { return __base_.try_lock_shared(); } +void shared_timed_mutex::unlock_shared() { return __base_.unlock_shared(); } _LIBCPP_END_NAMESPACE_STD diff --git a/contrib/libs/cxxsupp/libcxx/src/string.cpp b/contrib/libs/cxxsupp/libcxx/src/string.cpp index 8db129520e..db211b2242 100644 --- a/contrib/libs/cxxsupp/libcxx/src/string.cpp +++ b/contrib/libs/cxxsupp/libcxx/src/string.cpp @@ -85,7 +85,7 @@ template<typename V, typename S, typename F> inline V as_integer_helper(const string& func, const S& str, size_t* idx, int base, F f) { typename S::value_type* ptr = nullptr; const typename S::value_type* const p = str.c_str(); - typename remove_reference<decltype(errno)>::type errno_save = errno; + __libcpp_remove_reference_t<decltype(errno)> errno_save = errno; errno = 0; V r = f(p, &ptr, base); swap(errno, errno_save); @@ -172,7 +172,7 @@ template<typename V, typename S, typename F> inline V as_float_helper(const string& func, const S& str, size_t* idx, F f) { typename S::value_type* ptr = nullptr; const typename S::value_type* const p = str.c_str(); - typename remove_reference<decltype(errno)>::type errno_save = errno; + __libcpp_remove_reference_t<decltype(errno)> errno_save = errno; errno = 0; V r = f(p, &ptr); swap(errno, errno_save); diff --git a/contrib/libs/cxxsupp/libcxx/src/support/runtime/stdexcept_vcruntime.ipp b/contrib/libs/cxxsupp/libcxx/src/support/runtime/stdexcept_vcruntime.ipp index 8a6d939cb0..db9097d097 100644 --- a/contrib/libs/cxxsupp/libcxx/src/support/runtime/stdexcept_vcruntime.ipp +++ b/contrib/libs/cxxsupp/libcxx/src/support/runtime/stdexcept_vcruntime.ipp @@ -7,7 +7,7 @@ //===----------------------------------------------------------------------===// #ifndef _LIBCPP_ABI_VCRUNTIME -#error This file may only be used when defering to vcruntime +#error This file may only be used when deferring to vcruntime #endif namespace std { |