diff options
author | heretic <heretic@yandex-team.ru> | 2022-02-10 16:45:43 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:45:43 +0300 |
commit | 397cbe258b9e064f49c4ca575279f02f39fef76e (patch) | |
tree | a0b0eb3cca6a14e4e8ea715393637672fa651284 /contrib/libs/cxxsupp/libcxx/include/new | |
parent | 43f5a35593ebc9f6bcea619bb170394ea7ae468e (diff) | |
download | ydb-397cbe258b9e064f49c4ca575279f02f39fef76e.tar.gz |
Restoring authorship annotation for <heretic@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'contrib/libs/cxxsupp/libcxx/include/new')
-rw-r--r-- | contrib/libs/cxxsupp/libcxx/include/new | 140 |
1 files changed, 70 insertions, 70 deletions
diff --git a/contrib/libs/cxxsupp/libcxx/include/new b/contrib/libs/cxxsupp/libcxx/include/new index 2d1417a975..5a1cd0741c 100644 --- a/contrib/libs/cxxsupp/libcxx/include/new +++ b/contrib/libs/cxxsupp/libcxx/include/new @@ -88,14 +88,14 @@ void operator delete[](void* ptr, void*) noexcept; #include <__availability> #include <__config> -#include <cstddef> -#include <cstdlib> +#include <cstddef> +#include <cstdlib> #include <exception> #include <type_traits> #include <version> #if defined(_LIBCPP_ABI_VCRUNTIME) -#include <new.h> +#include <new.h> #endif #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) @@ -228,54 +228,54 @@ _LIBCPP_CONSTEXPR inline _LIBCPP_INLINE_VISIBILITY bool __is_overaligned_for_new #endif } -template <class ..._Args> -_LIBCPP_INLINE_VISIBILITY -void* __libcpp_operator_new(_Args ...__args) { -#if __has_builtin(__builtin_operator_new) && __has_builtin(__builtin_operator_delete) - return __builtin_operator_new(__args...); -#else - return ::operator new(__args...); -#endif -} - -template <class ..._Args> -_LIBCPP_INLINE_VISIBILITY -void __libcpp_operator_delete(_Args ...__args) { -#if __has_builtin(__builtin_operator_new) && __has_builtin(__builtin_operator_delete) - __builtin_operator_delete(__args...); -#else - ::operator delete(__args...); -#endif -} - -inline _LIBCPP_INLINE_VISIBILITY -void *__libcpp_allocate(size_t __size, size_t __align) { +template <class ..._Args> +_LIBCPP_INLINE_VISIBILITY +void* __libcpp_operator_new(_Args ...__args) { +#if __has_builtin(__builtin_operator_new) && __has_builtin(__builtin_operator_delete) + return __builtin_operator_new(__args...); +#else + return ::operator new(__args...); +#endif +} + +template <class ..._Args> +_LIBCPP_INLINE_VISIBILITY +void __libcpp_operator_delete(_Args ...__args) { +#if __has_builtin(__builtin_operator_new) && __has_builtin(__builtin_operator_delete) + __builtin_operator_delete(__args...); +#else + ::operator delete(__args...); +#endif +} + +inline _LIBCPP_INLINE_VISIBILITY +void *__libcpp_allocate(size_t __size, size_t __align) { #ifndef _LIBCPP_HAS_NO_ALIGNED_ALLOCATION if (__is_overaligned_for_new(__align)) { const align_val_t __align_val = static_cast<align_val_t>(__align); - return __libcpp_operator_new(__size, __align_val); + return __libcpp_operator_new(__size, __align_val); } #endif - - (void)__align; - return __libcpp_operator_new(__size); -} - -template <class ..._Args> -_LIBCPP_INLINE_VISIBILITY -void __do_deallocate_handle_size(void *__ptr, size_t __size, _Args ...__args) { -#ifdef _LIBCPP_HAS_NO_SIZED_DEALLOCATION - (void)__size; - return __libcpp_operator_delete(__ptr, __args...); + + (void)__align; + return __libcpp_operator_new(__size); +} + +template <class ..._Args> +_LIBCPP_INLINE_VISIBILITY +void __do_deallocate_handle_size(void *__ptr, size_t __size, _Args ...__args) { +#ifdef _LIBCPP_HAS_NO_SIZED_DEALLOCATION + (void)__size; + return __libcpp_operator_delete(__ptr, __args...); #else - return __libcpp_operator_delete(__ptr, __size, __args...); + return __libcpp_operator_delete(__ptr, __size, __args...); #endif } -inline _LIBCPP_INLINE_VISIBILITY -void __libcpp_deallocate(void* __ptr, size_t __size, size_t __align) { +inline _LIBCPP_INLINE_VISIBILITY +void __libcpp_deallocate(void* __ptr, size_t __size, size_t __align) { #if defined(_LIBCPP_HAS_NO_ALIGNED_ALLOCATION) - (void)__align; + (void)__align; return __do_deallocate_handle_size(__ptr, __size); #else if (__is_overaligned_for_new(__align)) { @@ -285,50 +285,50 @@ void __libcpp_deallocate(void* __ptr, size_t __size, size_t __align) { return __do_deallocate_handle_size(__ptr, __size); } #endif -} +} -inline _LIBCPP_INLINE_VISIBILITY void __libcpp_deallocate_unsized(void* __ptr, size_t __align) { +inline _LIBCPP_INLINE_VISIBILITY void __libcpp_deallocate_unsized(void* __ptr, size_t __align) { #if defined(_LIBCPP_HAS_NO_ALIGNED_ALLOCATION) - (void)__align; - return __libcpp_operator_delete(__ptr); + (void)__align; + return __libcpp_operator_delete(__ptr); #else if (__is_overaligned_for_new(__align)) { const align_val_t __align_val = static_cast<align_val_t>(__align); - return __libcpp_operator_delete(__ptr, __align_val); + return __libcpp_operator_delete(__ptr, __align_val); } else { - return __libcpp_operator_delete(__ptr); + return __libcpp_operator_delete(__ptr); } #endif -} - -#if !defined(_LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION) -// Low-level helpers to call the aligned allocation and deallocation functions -// on the target platform. This is used to implement libc++'s own memory -// allocation routines -- if you need to allocate memory inside the library, -// chances are that you want to use `__libcpp_allocate` instead. -// -// Returns the allocated memory, or `nullptr` on failure. -inline _LIBCPP_INLINE_VISIBILITY -void* __libcpp_aligned_alloc(std::size_t __alignment, std::size_t __size) { -#if defined(_LIBCPP_MSVCRT_LIKE) - return ::_aligned_malloc(__size, __alignment); +} + +#if !defined(_LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION) +// Low-level helpers to call the aligned allocation and deallocation functions +// on the target platform. This is used to implement libc++'s own memory +// allocation routines -- if you need to allocate memory inside the library, +// chances are that you want to use `__libcpp_allocate` instead. +// +// Returns the allocated memory, or `nullptr` on failure. +inline _LIBCPP_INLINE_VISIBILITY +void* __libcpp_aligned_alloc(std::size_t __alignment, std::size_t __size) { +#if defined(_LIBCPP_MSVCRT_LIKE) + return ::_aligned_malloc(__size, __alignment); #else - void* __result = nullptr; + void* __result = nullptr; (void)::posix_memalign(&__result, __alignment, __size); - // If posix_memalign fails, __result is unmodified so we still return `nullptr`. - return __result; + // If posix_memalign fails, __result is unmodified so we still return `nullptr`. + return __result; #endif -} +} -inline _LIBCPP_INLINE_VISIBILITY -void __libcpp_aligned_free(void* __ptr) { -#if defined(_LIBCPP_MSVCRT_LIKE) - ::_aligned_free(__ptr); +inline _LIBCPP_INLINE_VISIBILITY +void __libcpp_aligned_free(void* __ptr) { +#if defined(_LIBCPP_MSVCRT_LIKE) + ::_aligned_free(__ptr); #else - ::free(__ptr); + ::free(__ptr); #endif } -#endif // !_LIBCPP_HAS_NO_ALIGNED_ALLOCATION +#endif // !_LIBCPP_HAS_NO_ALIGNED_ALLOCATION template <class _Tp> |