[libcxx-commits] [libcxx] [libc++] Improve aligned allocation support with picolibc. (PR #96086)
Louis Dionne via libcxx-commits
libcxx-commits at lists.llvm.org
Thu Jul 4 11:42:16 PDT 2024
================
@@ -30,7 +30,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
inline _LIBCPP_HIDE_FROM_ABI void* __libcpp_aligned_alloc(std::size_t __alignment, std::size_t __size) {
# if defined(_LIBCPP_MSVCRT_LIKE)
return ::_aligned_malloc(__size, __alignment);
-# elif _LIBCPP_STD_VER >= 17 && !defined(_LIBCPP_HAS_NO_C11_ALIGNED_ALLOC)
+# elif defined(_LIBCPP_HAS_C11_ALIGNED_ALLOC) || (_LIBCPP_STD_VER >= 17 && !defined(_LIBCPP_HAS_NO_C11_ALIGNED_ALLOC))
----------------
ldionne wrote:
> This change is intended to make it select aligned_alloc even when that's not true
You mean use `aligned_alloc` in C++ < 17? I'd rather not do that. We want to avoid relying on non-Standard behavior (or introducing any complexity for that purpose), and we can't be guaranteed that the C library provides `aligned_alloc` before C++17.
I think it's reasonable to require that picolibc users compile with C++ >= 17 when they use an allocator that doesn't provide `posix_memalign`.
https://github.com/llvm/llvm-project/pull/96086
More information about the libcxx-commits
mailing list