mirror of
https://github.com/GPUOpen-LibrariesAndSDKs/VulkanMemoryAllocator.git
synced 2024-11-10 10:41:52 +00:00
Merge pull request #137 from phuang/master
changes for fixing problems on mac
This commit is contained in:
commit
e9f387a31d
@ -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,25 @@ 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)
|
||||
|
||||
#if defined(__APPLE__)
|
||||
#include <AvailabilityMacros.h>
|
||||
#endif
|
||||
|
||||
void *vma_aligned_alloc(size_t alignment, size_t size)
|
||||
{
|
||||
#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
|
||||
#endif
|
||||
// alignment must be >= sizeof(void*)
|
||||
if(alignment < sizeof(void*))
|
||||
{
|
||||
@ -3968,6 +3985,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 +4026,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