summaryrefslogtreecommitdiffstats
path: root/libcxx/include/new
diff options
context:
space:
mode:
Diffstat (limited to 'libcxx/include/new')
-rw-r--r--libcxx/include/new101
1 files changed, 13 insertions, 88 deletions
diff --git a/libcxx/include/new b/libcxx/include/new
index 412d51bd027..09d5162aeab 100644
--- a/libcxx/include/new
+++ b/libcxx/include/new
@@ -104,17 +104,12 @@ void operator delete[](void* ptr, void*) noexcept;
#pragma GCC system_header
#endif
-#if !defined(__cpp_sized_deallocation) || __cpp_sized_deallocation < 201309L
-#define _LIBCPP_HAS_NO_LANGUAGE_SIZED_DEALLOCATION
-#endif
-
-#if !defined(_LIBCPP_BUILDING_LIBRARY) && _LIBCPP_STD_VER < 14 && \
- defined(_LIBCPP_HAS_NO_LANGUAGE_SIZED_DEALLOCATION)
+#if !defined(_LIBCPP_BUILDING_LIBRARY) && _LIBCPP_STD_VER < 14
# define _LIBCPP_HAS_NO_LIBRARY_SIZED_DEALLOCATION
#endif
#if defined(_LIBCPP_HAS_NO_LIBRARY_SIZED_DEALLOCATION) || \
- defined(_LIBCPP_HAS_NO_LANGUAGE_SIZED_DEALLOCATION)
+ !defined(__cpp_sized_deallocation) || __cpp_sized_deallocation < 201309
# define _LIBCPP_HAS_NO_SIZED_DEALLOCATION
#endif
@@ -260,94 +255,24 @@ inline _LIBCPP_INLINE_VISIBILITY void *__libcpp_allocate(size_t __size, size_t _
#endif
}
-struct _DeallocateCaller {
- static inline _LIBCPP_INLINE_VISIBILITY
- void __do_deallocate_handle_size_align(void *__ptr, size_t __size, size_t __align) {
-#if defined(_LIBCPP_HAS_NO_ALIGNED_ALLOCATION)
- ((void)__align);
- return __do_deallocate_handle_size(__ptr, __size);
-#else
- if (__is_overaligned_for_new(__align)) {
- const align_val_t __align_val = static_cast<align_val_t>(__align);
- return __do_deallocate_handle_size(__ptr, __size, __align_val);
- } else {
- return __do_deallocate_handle_size(__ptr, __size);
- }
-#endif
- }
-
- static inline _LIBCPP_INLINE_VISIBILITY
- void __do_deallocate_handle_align(void *__ptr, size_t __align) {
-#if defined(_LIBCPP_HAS_NO_ALIGNED_ALLOCATION)
- ((void)__align);
- return __do_call(__ptr);
-#else
- if (__is_overaligned_for_new(__align)) {
- const align_val_t __align_val = static_cast<align_val_t>(__align);
- return __do_call(__ptr, __align_val);
- } else {
- return __do_call(__ptr);
- }
-#endif
- }
-
- private:
- static inline void __do_deallocate_handle_size(void *__ptr, size_t __size) {
-#ifdef _LIBCPP_HAS_NO_SIZED_DEALLOCATION
- ((void)__size);
- return __do_call(__ptr);
-#else
- return __do_call(__ptr, __size);
-#endif
- }
-
+inline _LIBCPP_INLINE_VISIBILITY void __libcpp_deallocate(void* __ptr, size_t __align) {
#ifndef _LIBCPP_HAS_NO_ALIGNED_ALLOCATION
- static inline void __do_deallocate_handle_size(void *__ptr, size_t __size, align_val_t __align) {
-#ifdef _LIBCPP_HAS_NO_SIZED_DEALLOCATION
- ((void)__size);
- return __do_call(__ptr, __align);
-#else
- return __do_call(__ptr, __size, __align);
-#endif
- }
-#endif
-
-private:
- template <class _A1, class _A2>
- static inline void __do_call(void *__ptr, _A1 __a1, _A2 __a2) {
-#if defined(_LIBCPP_HAS_NO_BUILTIN_OPERATOR_NEW_DELETE) || \
- defined(_LIBCPP_HAS_NO_BUILTIN_OVERLOADED_OPERATOR_NEW_DELETE)
- return ::operator delete(__ptr, __a1, __a2);
-#else
- return __builtin_operator_delete(__ptr, __a1, __a2);
-#endif
+ if (__is_overaligned_for_new(__align)) {
+ const align_val_t __align_val = static_cast<align_val_t>(__align);
+# ifdef _LIBCPP_HAS_NO_BUILTIN_OVERLOADED_OPERATOR_NEW_DELETE
+ return ::operator delete(__ptr, __align_val);
+# else
+ return __builtin_operator_delete(__ptr, __align_val);
+# endif
}
-
- template <class _A1>
- static inline void __do_call(void *__ptr, _A1 __a1) {
-#if defined(_LIBCPP_HAS_NO_BUILTIN_OPERATOR_NEW_DELETE) || \
- defined(_LIBCPP_HAS_NO_BUILTIN_OVERLOADED_OPERATOR_NEW_DELETE)
- return ::operator delete(__ptr, __a1);
#else
- return __builtin_operator_delete(__ptr, __a1);
+ ((void)__align);
#endif
- }
-
- static inline void __do_call(void *__ptr) {
#ifdef _LIBCPP_HAS_NO_BUILTIN_OPERATOR_NEW_DELETE
- return ::operator delete(__ptr);
+ return ::operator delete(__ptr);
#else
- return __builtin_operator_delete(__ptr);
+ return __builtin_operator_delete(__ptr);
#endif
- }
-};
-
-inline _LIBCPP_INLINE_VISIBILITY void __libcpp_deallocate(void* __ptr, size_t __size, size_t __align) {
- _DeallocateCaller::__do_deallocate_handle_size_align(__ptr, __size, __align);
-}
-
-inline _LIBCPP_INLINE_VISIBILITY void __libcpp_deallocate_unsized(void* __ptr, size_t __align) {
- _DeallocateCaller::__do_deallocate_handle_align(__ptr, __align);
}
#ifdef _LIBCPP_BAD_ARRAY_LENGTH_DEFINED
OpenPOWER on IntegriCloud