diff options
author | Louis Dionne <ldionne.2@gmail.com> | 2022-12-02 13:45:49 -0800 |
---|---|---|
committer | Louis Dionne <ldionne.2@gmail.com> | 2023-01-26 14:41:13 -0500 |
commit | 36080434a8858c33f2af2382be748caed131385f (patch) | |
tree | c1ff0a648ef822aa872d71e78ba5be2a534995c9 /libcxxabi | |
parent | 2e3153059c268700d4b399a8cbba28e9c2514e09 (diff) | |
download | llvm-36080434a8858c33f2af2382be748caed131385f.tar.gz |
[libc++] Move the definition of aligned allocation helpers outside of <new>
They are not needed in <new> -- in fact they are only needed in .cpp files.
Getting those out of the way makes the headers smaller and also makes it
easier to use the library on platforms where aligned allocation is not
available.
Differential Revision: https://reviews.llvm.org/D139231
Diffstat (limited to 'libcxxabi')
-rw-r--r-- | libcxxabi/src/fallback_malloc.cpp | 2 | ||||
-rw-r--r-- | libcxxabi/src/stdlib_new_delete.cpp | 3 | ||||
-rw-r--r-- | libcxxabi/test/test_fallback_malloc.pass.cpp | 3 |
3 files changed, 6 insertions, 2 deletions
diff --git a/libcxxabi/src/fallback_malloc.cpp b/libcxxabi/src/fallback_malloc.cpp index 591efbefc8a5..f9fb1bc46302 100644 --- a/libcxxabi/src/fallback_malloc.cpp +++ b/libcxxabi/src/fallback_malloc.cpp @@ -15,10 +15,10 @@ #endif #endif +#include <__memory/aligned_alloc.h> #include <assert.h> #include <stdlib.h> // for malloc, calloc, free #include <string.h> // for memset -#include <new> // for std::__libcpp_aligned_{alloc,free} // A small, simple heap manager based (loosely) on // the startup heap manager from FreeBSD, optimized for space. diff --git a/libcxxabi/src/stdlib_new_delete.cpp b/libcxxabi/src/stdlib_new_delete.cpp index 4a664e15a50f..483b9f1e81e9 100644 --- a/libcxxabi/src/stdlib_new_delete.cpp +++ b/libcxxabi/src/stdlib_new_delete.cpp @@ -9,8 +9,9 @@ //===----------------------------------------------------------------------===// #include "__cxxabi_config.h" -#include <new> +#include <__memory/aligned_alloc.h> #include <cstdlib> +#include <new> #if !defined(_THROW_BAD_ALLOC) || !defined(_LIBCXXABI_WEAK) #error The _THROW_BAD_ALLOC and _LIBCXXABI_WEAK libc++ macros must \ diff --git a/libcxxabi/test/test_fallback_malloc.pass.cpp b/libcxxabi/test/test_fallback_malloc.pass.cpp index d7decd9d7924..e7d22a57d2bc 100644 --- a/libcxxabi/test/test_fallback_malloc.pass.cpp +++ b/libcxxabi/test/test_fallback_malloc.pass.cpp @@ -24,9 +24,12 @@ typedef std::deque<void *> container; +TEST_DIAGNOSTIC_PUSH +TEST_CLANG_DIAGNOSTIC_IGNORED("-Wprivate-header") // #define DEBUG_FALLBACK_MALLOC #define INSTRUMENT_FALLBACK_MALLOC #include "../src/fallback_malloc.cpp" +TEST_DIAGNOSTIC_POP void assertAlignment(void* ptr) { assert(reinterpret_cast<size_t>(ptr) % alignof(FallbackMaxAlignType) == 0); } |