Only use system aligned_alloc on mac/ios if the SDK has them.

Bug: chromium:1098741
Change-Id: I4df73f581c2a6895c7f136ff974db0371c48cc5e
This commit is contained in:
Nico Weber 2020-06-25 14:15:27 -04:00 committed by Peng Huang
parent 5ef3d923d5
commit c331971b30

View File

@ -3955,11 +3955,18 @@ void *vma_aligned_alloc(size_t alignment, size_t size)
}
#elif defined(__APPLE__) || defined(__ANDROID__) || (defined(__linux__) && defined(__GLIBCXX__) && !defined(_GLIBCXX_HAVE_ALIGNED_ALLOC))
#include <cstdlib>
#if defined(__APPLE__)
#include <AvailabilityMacros.h>
#endif
void *vma_aligned_alloc(size_t alignment, size_t size)
{
#if defined(__APPLE__)
#if defined(__APPLE__) && (defined(MAC_OS_X_VERSION_10_15) || defined(__IPHONE_13_0))
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_15 || __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_13_0
if (__builtin_available(macOS 10.15, iOS 13, *))
return aligned_alloc(alignment, size);
#endif
#endif
// alignment must be >= sizeof(void*)
if(alignment < sizeof(void*))