mirror of
https://github.com/GPUOpen-LibrariesAndSDKs/VulkanMemoryAllocator
synced 2024-11-05 12:20:07 +00:00
Make vulkan_memory_allocator build with the MacOSX11.0 SDK.
The 11.0 SDK adds a declaration of aligned_malloc() that's available on macOS 10.15 and later. vulkan_memory_allocator also defines a symbol with the same name, which causes problems. As fix, rename the vulkan_memory_allocator version to vma_aligned_malloc(). Use this opportunity to use the same mechanism on Windows (a no-op), and, while here, call the system aligned_malloc() on macOS 10.15 from there too. Bug: chromium:1098741 Change-Id: If738a1451a08c0813532fc4b778d9118a23210b7
This commit is contained in:
parent
7cb859d3a0
commit
1268da7b97
@ -3943,7 +3943,7 @@ remove them if not needed.
|
||||
|
||||
#if defined(__ANDROID_API__) && (__ANDROID_API__ < 16)
|
||||
#include <cstdlib>
|
||||
void *aligned_alloc(size_t alignment, size_t size)
|
||||
void *vma_aligned_alloc(size_t alignment, size_t size)
|
||||
{
|
||||
// alignment must be >= sizeof(void*)
|
||||
if(alignment < sizeof(void*))
|
||||
@ -3955,8 +3955,12 @@ void *aligned_alloc(size_t alignment, size_t size)
|
||||
}
|
||||
#elif defined(__APPLE__) || defined(__ANDROID__) || (defined(__linux__) && defined(__GLIBCXX__) && !defined(_GLIBCXX_HAVE_ALIGNED_ALLOC))
|
||||
#include <cstdlib>
|
||||
void *aligned_alloc(size_t alignment, size_t size)
|
||||
void *vma_aligned_alloc(size_t alignment, size_t size)
|
||||
{
|
||||
#if defined(__APPLE__)
|
||||
if (__builtin_available(macOS 10.15, iOS 13, *))
|
||||
return aligned_alloc(size, alignment);
|
||||
#endif
|
||||
// alignment must be >= sizeof(void*)
|
||||
if(alignment < sizeof(void*))
|
||||
{
|
||||
@ -3968,6 +3972,16 @@ void *aligned_alloc(size_t alignment, size_t size)
|
||||
return pointer;
|
||||
return VMA_NULL;
|
||||
}
|
||||
#elif defined(_WIN32)
|
||||
void *vma_aligned_alloc(size_t alignment, size_t size)
|
||||
{
|
||||
return _aligned_malloc(size, alignment);
|
||||
}
|
||||
#else
|
||||
void *vma_aligned_alloc(size_t alignment, size_t size)
|
||||
{
|
||||
return aligned_alloc(alignment, size);
|
||||
}
|
||||
#endif
|
||||
|
||||
// If your compiler is not compatible with C++11 and definition of
|
||||
@ -3999,11 +4013,7 @@ void *aligned_alloc(size_t alignment, size_t size)
|
||||
#endif
|
||||
|
||||
#ifndef VMA_SYSTEM_ALIGNED_MALLOC
|
||||
#if defined(_WIN32)
|
||||
#define VMA_SYSTEM_ALIGNED_MALLOC(size, alignment) (_aligned_malloc((size), (alignment)))
|
||||
#else
|
||||
#define VMA_SYSTEM_ALIGNED_MALLOC(size, alignment) (aligned_alloc((alignment), (size) ))
|
||||
#endif
|
||||
#define VMA_SYSTEM_ALIGNED_MALLOC(size, alignment) vma_aligned_alloc((alignment), (size))
|
||||
#endif
|
||||
|
||||
#ifndef VMA_SYSTEM_FREE
|
||||
|
Loading…
Reference in New Issue
Block a user