diff --git a/libcxx/include/__config b/libcxx/include/__config --- a/libcxx/include/__config +++ b/libcxx/include/__config @@ -720,6 +720,15 @@ # define _LIBCPP_HAS_NO_ALIGNED_ALLOCATION # endif +// It is not yet possible to use aligned_alloc() on all Apple platforms as 10.9 +// does not ship with an implementation of aligned_alloc(). +# if defined(__APPLE__) +# if (defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && \ + __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 101000) +# define _LIBCPP_HAS_NO_C11_ALIGNED_ALLOC +# endif +# endif + # if defined(__APPLE__) || defined(__FreeBSD__) # define _LIBCPP_HAS_DEFAULTRUNELOCALE # endif diff --git a/libcxx/include/new b/libcxx/include/new --- a/libcxx/include/new +++ b/libcxx/include/new @@ -341,6 +341,8 @@ 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 > 14 && !defined(_LIBCPP_HAS_NO_C11_ALIGNED_ALLOC) + return ::aligned_alloc(__alignment, __size); #else void* __result = nullptr; (void)::posix_memalign(&__result, __alignment, __size);