From 08bce5328b8ab7302e408ef9ecb6ebd82ea634ad Mon Sep 17 00:00:00 2001 From: Nico Weber Date: Thu, 25 Jun 2020 18:43:09 -0400 Subject: [PATCH] mac: Only call system aligned_alloc() with the 11.0+ SDK. The 10.15 SDK only declares it for C++17 and C11. In Chromium, we only call this from .cc files, and these are C++14 still for now. The 11.0 SDK declares it independent of language version (as long as __DARWIN_C_LEVEL >= __DARWIN_C_FULL, which it is by default, at least on macOS). So this calls the system version in fewer scenarios than possible, but it keeps the preprocessor checks fairly small. Bug: chromium:1098741 Change-Id: I1e30f88bb040876bca2b59adee0a1cff33b9ff03 --- src/vk_mem_alloc.h | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/vk_mem_alloc.h b/src/vk_mem_alloc.h index c5febc6..5a1f2da 100644 --- a/src/vk_mem_alloc.h +++ b/src/vk_mem_alloc.h @@ -3962,8 +3962,14 @@ void *vma_aligned_alloc(size_t alignment, size_t size) void *vma_aligned_alloc(size_t alignment, size_t size) { -#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 defined(__APPLE__) && (defined(MAC_OS_X_VERSION_10_16) || defined(__IPHONE_14_0)) +#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_16 || __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_14_0 + // For C++14, usr/include/malloc/_malloc.h declares aligned_alloc()) only + // with the MacOSX11.0 SDK in Xcode 12 (which is what adds + // MAC_OS_X_VERSION_10_16), even though the function is marked + // availabe for 10.15. That's why the preprocessor checks for 10.16 but + // the __builtin_available checks for 10.15. + // People who use C++17 could call aligned_alloc with the 10.15 SDK already. if (__builtin_available(macOS 10.15, iOS 13, *)) return aligned_alloc(alignment, size); #endif