diff options
author | Laszlo Agocs <laszlo.agocs@qt.io> | 2020-04-21 21:21:46 +0200 |
---|---|---|
committer | Laszlo Agocs <laszlo.agocs@qt.io> | 2020-04-23 10:20:00 +0200 |
commit | 574898c9ebb1c05797afa80747bde3b5836f8a85 (patch) | |
tree | d26ef325eb38d80fec3f23b81ca8b768a63b51ed /src/3rdparty | |
parent | 3ef7a760ff5ae61e4297ec2f271408ac453ca93d (diff) |
vkmemalloc: make it compile with macOS 10.15 SDK
Simply rename the function in order to not clash with aligned_alloc()
that is marked as 10.15 only (and thus would need annotation etc.) in
the 10.15 SDK. (note that aligned_alloc is a C11 function which was
presumably not present in earlier SDKs, by renaming our own version
everyone will be happy, hopefully)
Change-Id: Iee400d81df6a0af4fa2129358ed27b049720685b
Pick-to: 5.15
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
Diffstat (limited to 'src/3rdparty')
-rw-r--r-- | src/3rdparty/VulkanMemoryAllocator/patches/0004-Make-it-compile-macos-10-15.patch | 46 | ||||
-rw-r--r-- | src/3rdparty/VulkanMemoryAllocator/vk_mem_alloc.h | 21 |
2 files changed, 66 insertions, 1 deletions
diff --git a/src/3rdparty/VulkanMemoryAllocator/patches/0004-Make-it-compile-macos-10-15.patch b/src/3rdparty/VulkanMemoryAllocator/patches/0004-Make-it-compile-macos-10-15.patch new file mode 100644 index 0000000000..1da4b0feae --- /dev/null +++ b/src/3rdparty/VulkanMemoryAllocator/patches/0004-Make-it-compile-macos-10-15.patch @@ -0,0 +1,46 @@ +diff --git a/src/3rdparty/VulkanMemoryAllocator/vk_mem_alloc.h b/src/3rdparty/VulkanMemoryAllocator/vk_mem_alloc.h +index 2355de091f..5d311b750d 100644 +--- a/src/3rdparty/VulkanMemoryAllocator/vk_mem_alloc.h ++++ b/src/3rdparty/VulkanMemoryAllocator/vk_mem_alloc.h +@@ -3167,7 +3167,7 @@ void *aligned_alloc(size_t alignment, size_t size) + + return memalign(alignment, size); + } +-#elif defined(__APPLE__) || defined(__ANDROID__) ++#elif defined(__ANDROID__) + #include <cstdlib> + void *aligned_alloc(size_t alignment, size_t size) + { +@@ -3182,6 +3182,23 @@ void *aligned_alloc(size_t alignment, size_t size) + return pointer; + return VMA_NULL; + } ++#elif defined(__APPLE__) ++#include <cstdlib> ++// aligned_alloc() is marked as macOS 10.15 only in the 10.15 SDK, ++// avoid the mess by using a different name ++void *vma_aligned_alloc(size_t alignment, size_t size) ++{ ++ // alignment must be >= sizeof(void*) ++ if(alignment < sizeof(void*)) ++ { ++ alignment = sizeof(void*); ++ } ++ ++ void *pointer; ++ if(posix_memalign(&pointer, alignment, size) == 0) ++ return pointer; ++ return VMA_NULL; ++} + #endif + + // If your compiler is not compatible with C++11 and definition of +@@ -3215,6 +3232,8 @@ void *aligned_alloc(size_t alignment, size_t size) + #ifndef VMA_SYSTEM_ALIGNED_MALLOC + #if defined(_WIN32) + #define VMA_SYSTEM_ALIGNED_MALLOC(size, alignment) (_aligned_malloc((size), (alignment))) ++ #elif defined(__APPLE__) ++ #define VMA_SYSTEM_ALIGNED_MALLOC(size, alignment) (vma_aligned_alloc((alignment), (size) )) + #else + #define VMA_SYSTEM_ALIGNED_MALLOC(size, alignment) (aligned_alloc((alignment), (size) )) + #endif diff --git a/src/3rdparty/VulkanMemoryAllocator/vk_mem_alloc.h b/src/3rdparty/VulkanMemoryAllocator/vk_mem_alloc.h index 2355de091f..5d311b750d 100644 --- a/src/3rdparty/VulkanMemoryAllocator/vk_mem_alloc.h +++ b/src/3rdparty/VulkanMemoryAllocator/vk_mem_alloc.h @@ -3167,7 +3167,7 @@ void *aligned_alloc(size_t alignment, size_t size) return memalign(alignment, size); } -#elif defined(__APPLE__) || defined(__ANDROID__) +#elif defined(__ANDROID__) #include <cstdlib> void *aligned_alloc(size_t alignment, size_t size) { @@ -3182,6 +3182,23 @@ void *aligned_alloc(size_t alignment, size_t size) return pointer; return VMA_NULL; } +#elif defined(__APPLE__) +#include <cstdlib> +// aligned_alloc() is marked as macOS 10.15 only in the 10.15 SDK, +// avoid the mess by using a different name +void *vma_aligned_alloc(size_t alignment, size_t size) +{ + // alignment must be >= sizeof(void*) + if(alignment < sizeof(void*)) + { + alignment = sizeof(void*); + } + + void *pointer; + if(posix_memalign(&pointer, alignment, size) == 0) + return pointer; + return VMA_NULL; +} #endif // If your compiler is not compatible with C++11 and definition of @@ -3215,6 +3232,8 @@ void *aligned_alloc(size_t alignment, size_t size) #ifndef VMA_SYSTEM_ALIGNED_MALLOC #if defined(_WIN32) #define VMA_SYSTEM_ALIGNED_MALLOC(size, alignment) (_aligned_malloc((size), (alignment))) + #elif defined(__APPLE__) + #define VMA_SYSTEM_ALIGNED_MALLOC(size, alignment) (vma_aligned_alloc((alignment), (size) )) #else #define VMA_SYSTEM_ALIGNED_MALLOC(size, alignment) (aligned_alloc((alignment), (size) )) #endif |