diff options
| author | mikhnenko <[email protected]> | 2024-11-15 10:28:14 +0300 | 
|---|---|---|
| committer | mikhnenko <[email protected]> | 2024-11-15 10:39:55 +0300 | 
| commit | 63e58b6e405f754c634aac8411c84da160b4c574 (patch) | |
| tree | e93aa558728b77f263074a89ea1e7ba7849f6b7a /contrib/libs/cxxsupp/libcxx/src | |
| parent | 423f17a2717306abbb05e18c17c1dcfe0bd89558 (diff) | |
Update libcxx to 19 Oct d173ce4a670e88b65c52f6fc1bf10d133ee35704
commit_hash:c1da7a8a6580c15e8af41b1a4847da2163706905
Diffstat (limited to 'contrib/libs/cxxsupp/libcxx/src')
| -rw-r--r-- | contrib/libs/cxxsupp/libcxx/src/ios.instantiations.cpp | 2 | ||||
| -rw-r--r-- | contrib/libs/cxxsupp/libcxx/src/new.cpp | 363 | 
2 files changed, 141 insertions, 224 deletions
diff --git a/contrib/libs/cxxsupp/libcxx/src/ios.instantiations.cpp b/contrib/libs/cxxsupp/libcxx/src/ios.instantiations.cpp index 01fe199acb3..070f9891947 100644 --- a/contrib/libs/cxxsupp/libcxx/src/ios.instantiations.cpp +++ b/contrib/libs/cxxsupp/libcxx/src/ios.instantiations.cpp @@ -31,7 +31,7 @@ template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS basic_ostream<wchar_t>;  #endif  // Additional instantiations added later. Whether programs rely on these being -// available is protected by _LIBCPP_ABI_ENABLE_ADDITIONAL_IOSTREAM_EXPLICIT_INSTANTIATIONS_1. +// available is protected by _LIBCPP_AVAILABILITY_HAS_NO_ADDITIONAL_IOSTREAM_EXPLICIT_INSTANTIATIONS_1.  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>; diff --git a/contrib/libs/cxxsupp/libcxx/src/new.cpp b/contrib/libs/cxxsupp/libcxx/src/new.cpp index 6d5b2211985..318b062bb0c 100644 --- a/contrib/libs/cxxsupp/libcxx/src/new.cpp +++ b/contrib/libs/cxxsupp/libcxx/src/new.cpp @@ -20,248 +20,165 @@  // in this shared library, so that they can be overridden by programs  // that define non-weak copies of the functions. -_LIBCPP_WEAK -void * -operator new(std::size_t size) _THROW_BAD_ALLOC -{ -    if (size == 0) -        size = 1; -    void* p; -    while ((p = std::malloc(size)) == nullptr) -    { -        // If malloc fails and there is a new_handler, -        // call it to try free up memory. -        std::new_handler nh = std::get_new_handler(); -        if (nh) -            nh(); -        else -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS -            throw std::bad_alloc(); -#else -#ifdef __EMSCRIPTEN__ -            // Abort here so that when exceptions are disabled, we do not just -            // return 0 when malloc returns 0. -            // We could also do this with set_new_handler, but that adds a -            // global constructor and a table entry, overhead that we can avoid -            // by doing it this way. -            abort(); -#else -            break; -#endif -#endif -    } -    return p; +static void* operator_new_impl(std::size_t size) noexcept { +  if (size == 0) +    size = 1; +  void* p; +  while ((p = std::malloc(size)) == nullptr) { +    // If malloc fails and there is a new_handler, +    // call it to try free up memory. +    std::new_handler nh = std::get_new_handler(); +    if (nh) +      nh(); +    else +      break; +  } +  return p; +} + +_LIBCPP_WEAK void* operator new(std::size_t size) _THROW_BAD_ALLOC { +  void* p = operator_new_impl(size); +#  ifndef _LIBCPP_HAS_NO_EXCEPTIONS +  if (p == nullptr) +    throw std::bad_alloc(); +#  else +#    ifdef __EMSCRIPTEN__ +  if (p == nullptr) +      // Abort here so that when exceptions are disabled, we do not just +      // return 0 when malloc returns 0. +      // We could also do this with set_new_handler, but that adds a +      // global constructor and a table entry, overhead that we can avoid +      // by doing it this way. +      abort(); +#    endif +#  endif +  return p; +} + +_LIBCPP_WEAK void* operator new(size_t size, const std::nothrow_t&) noexcept { +  void* p = nullptr; +#  ifndef _LIBCPP_HAS_NO_EXCEPTIONS +  try { +#  endif // _LIBCPP_HAS_NO_EXCEPTIONS +    p = ::operator new(size); +#  ifndef _LIBCPP_HAS_NO_EXCEPTIONS +  } catch (...) { +  } +#  endif // _LIBCPP_HAS_NO_EXCEPTIONS +  return p; +} + +_LIBCPP_WEAK void* operator new[](size_t size) _THROW_BAD_ALLOC { return ::operator new(size); } + +_LIBCPP_WEAK void* operator new[](size_t size, const std::nothrow_t&) noexcept { +  void* p = nullptr; +#  ifndef _LIBCPP_HAS_NO_EXCEPTIONS +  try { +#  endif // _LIBCPP_HAS_NO_EXCEPTIONS +    p = ::operator new[](size); +#  ifndef _LIBCPP_HAS_NO_EXCEPTIONS +  } catch (...) { +  } +#  endif // _LIBCPP_HAS_NO_EXCEPTIONS +  return p; +} + +_LIBCPP_WEAK void operator delete(void* ptr) noexcept { std::free(ptr); } + +_LIBCPP_WEAK void operator delete(void* ptr, const std::nothrow_t&) noexcept { ::operator delete(ptr); } + +_LIBCPP_WEAK void operator delete(void* ptr, size_t) noexcept { ::operator delete(ptr); } + +_LIBCPP_WEAK void operator delete[](void* ptr) noexcept { ::operator delete(ptr); } + +_LIBCPP_WEAK void operator delete[](void* ptr, const std::nothrow_t&) noexcept { ::operator delete[](ptr); } + +_LIBCPP_WEAK void operator delete[](void* ptr, size_t) noexcept { ::operator delete[](ptr); } + +#  if !defined(_LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION) + +static void* operator_new_aligned_impl(std::size_t size, std::align_val_t alignment) noexcept { +  if (size == 0) +    size = 1; +  if (static_cast<size_t>(alignment) < sizeof(void*)) +    alignment = std::align_val_t(sizeof(void*)); + +  // Try allocating memory. If allocation fails and there is a new_handler, +  // call it to try free up memory, and try again until it succeeds, or until +  // the new_handler decides to terminate. +  void* p; +  while ((p = std::__libcpp_aligned_alloc(static_cast<std::size_t>(alignment), size)) == nullptr) { +    std::new_handler nh = std::get_new_handler(); +    if (nh) +      nh(); +    else +      break; +  } +  return p; +} + +_LIBCPP_WEAK void* operator new(std::size_t size, std::align_val_t alignment) _THROW_BAD_ALLOC { +  void* p = operator_new_aligned_impl(size, alignment); +#    ifndef _LIBCPP_HAS_NO_EXCEPTIONS +  if (p == nullptr) +    throw std::bad_alloc(); +#    endif +  return p;  } -_LIBCPP_WEAK -void* -operator new(size_t size, const std::nothrow_t&) noexcept -{ -    void* p = nullptr; -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS -    try -    { -#endif // _LIBCPP_HAS_NO_EXCEPTIONS -        p = ::operator new(size); -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS -    } -    catch (...) -    { -    } -#endif // _LIBCPP_HAS_NO_EXCEPTIONS -    return p; +_LIBCPP_WEAK void* operator new(size_t size, std::align_val_t alignment, const std::nothrow_t&) noexcept { +  void* p = nullptr; +#    ifndef _LIBCPP_HAS_NO_EXCEPTIONS +  try { +#    endif // _LIBCPP_HAS_NO_EXCEPTIONS +    p = ::operator new(size, alignment); +#    ifndef _LIBCPP_HAS_NO_EXCEPTIONS +  } catch (...) { +  } +#    endif // _LIBCPP_HAS_NO_EXCEPTIONS +  return p;  } -_LIBCPP_WEAK -void* -operator new[](size_t size) _THROW_BAD_ALLOC -{ -    return ::operator new(size); +_LIBCPP_WEAK void* operator new[](size_t size, std::align_val_t alignment) _THROW_BAD_ALLOC { +  return ::operator new(size, alignment);  } -_LIBCPP_WEAK -void* -operator new[](size_t size, const std::nothrow_t&) noexcept -{ -    void* p = nullptr; -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS -    try -    { -#endif // _LIBCPP_HAS_NO_EXCEPTIONS -        p = ::operator new[](size); -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS -    } -    catch (...) -    { -    } -#endif // _LIBCPP_HAS_NO_EXCEPTIONS -    return p; +_LIBCPP_WEAK void* operator new[](size_t size, std::align_val_t alignment, const std::nothrow_t&) noexcept { +  void* p = nullptr; +#    ifndef _LIBCPP_HAS_NO_EXCEPTIONS +  try { +#    endif // _LIBCPP_HAS_NO_EXCEPTIONS +    p = ::operator new[](size, alignment); +#    ifndef _LIBCPP_HAS_NO_EXCEPTIONS +  } catch (...) { +  } +#    endif // _LIBCPP_HAS_NO_EXCEPTIONS +  return p;  } -_LIBCPP_WEAK -void -operator delete(void* ptr) noexcept -{ -    std::free(ptr); -} - -_LIBCPP_WEAK -void -operator delete(void* ptr, const std::nothrow_t&) noexcept -{ -    ::operator delete(ptr); -} - -_LIBCPP_WEAK -void -operator delete(void* ptr, size_t) noexcept -{ -    ::operator delete(ptr); -} - -_LIBCPP_WEAK -void -operator delete[] (void* ptr) noexcept -{ -    ::operator delete(ptr); -} - -_LIBCPP_WEAK -void -operator delete[] (void* ptr, const std::nothrow_t&) noexcept -{ -    ::operator delete[](ptr); -} - -_LIBCPP_WEAK -void -operator delete[] (void* ptr, size_t) noexcept -{ -    ::operator delete[](ptr); -} - -#if !defined(_LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION) - -_LIBCPP_WEAK -void * -operator new(std::size_t size, std::align_val_t alignment) _THROW_BAD_ALLOC -{ -    if (size == 0) -        size = 1; -    if (static_cast<size_t>(alignment) < sizeof(void*)) -      alignment = std::align_val_t(sizeof(void*)); - -    // Try allocating memory. If allocation fails and there is a new_handler, -    // call it to try free up memory, and try again until it succeeds, or until -    // the new_handler decides to terminate. -    // -    // If allocation fails and there is no new_handler, we throw bad_alloc -    // (or return nullptr if exceptions are disabled). -    void* p; -    while ((p = std::__libcpp_aligned_alloc(static_cast<std::size_t>(alignment), size)) == nullptr) -    { -        std::new_handler nh = std::get_new_handler(); -        if (nh) -            nh(); -        else { -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS -            throw std::bad_alloc(); -#else -            break; -#endif -        } -    } -    return p; -} - -_LIBCPP_WEAK -void* -operator new(size_t size, std::align_val_t alignment, const std::nothrow_t&) noexcept -{ -    void* p = nullptr; -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS -    try -    { -#endif // _LIBCPP_HAS_NO_EXCEPTIONS -        p = ::operator new(size, alignment); -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS -    } -    catch (...) -    { -    } -#endif // _LIBCPP_HAS_NO_EXCEPTIONS -    return p; -} - -_LIBCPP_WEAK -void* -operator new[](size_t size, std::align_val_t alignment) _THROW_BAD_ALLOC -{ -    return ::operator new(size, alignment); -} - -_LIBCPP_WEAK -void* -operator new[](size_t size, std::align_val_t alignment, const std::nothrow_t&) noexcept -{ -    void* p = nullptr; -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS -    try -    { -#endif // _LIBCPP_HAS_NO_EXCEPTIONS -        p = ::operator new[](size, alignment); -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS -    } -    catch (...) -    { -    } -#endif // _LIBCPP_HAS_NO_EXCEPTIONS -    return p; -} - -_LIBCPP_WEAK -void -operator delete(void* ptr, std::align_val_t) noexcept -{ -    std::__libcpp_aligned_free(ptr); -} +_LIBCPP_WEAK void operator delete(void* ptr, std::align_val_t) noexcept { std::__libcpp_aligned_free(ptr); } -_LIBCPP_WEAK -void -operator delete(void* ptr, std::align_val_t alignment, const std::nothrow_t&) noexcept -{ -    ::operator delete(ptr, alignment); +_LIBCPP_WEAK void operator delete(void* ptr, std::align_val_t alignment, const std::nothrow_t&) noexcept { +  ::operator delete(ptr, alignment);  } -_LIBCPP_WEAK -void -operator delete(void* ptr, size_t, std::align_val_t alignment) noexcept -{ -    ::operator delete(ptr, alignment); +_LIBCPP_WEAK void operator delete(void* ptr, size_t, std::align_val_t alignment) noexcept { +  ::operator delete(ptr, alignment);  } -_LIBCPP_WEAK -void -operator delete[] (void* ptr, std::align_val_t alignment) noexcept -{ -    ::operator delete(ptr, alignment); +_LIBCPP_WEAK void operator delete[](void* ptr, std::align_val_t alignment) noexcept { +  ::operator delete(ptr, alignment);  } -_LIBCPP_WEAK -void -operator delete[] (void* ptr, std::align_val_t alignment, const std::nothrow_t&) noexcept -{ -    ::operator delete[](ptr, alignment); +_LIBCPP_WEAK void operator delete[](void* ptr, std::align_val_t alignment, const std::nothrow_t&) noexcept { +  ::operator delete[](ptr, alignment);  } -_LIBCPP_WEAK -void -operator delete[] (void* ptr, size_t, std::align_val_t alignment) noexcept -{ -    ::operator delete[](ptr, alignment); +_LIBCPP_WEAK void operator delete[](void* ptr, size_t, std::align_val_t alignment) noexcept { +  ::operator delete[](ptr, alignment);  } -#endif // !_LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION +#  endif // !_LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION  // ------------------ END COPY ------------------  #endif // !__GLIBCXX__ && !_LIBCPP_ABI_VCRUNTIME  | 
