From ff7c755bc9324a24346b88ac6a69c9563aa908ce Mon Sep 17 00:00:00 2001 From: sephiroth99 Date: Tue, 22 Sep 2015 00:46:15 -0400 Subject: [PATCH] memory: AlignedAlloc: fallback to aligned_alloc() When compiling with clang++, __STDC_VERSION__ is not defined (obviously as clang++ is not a C compiler). Because of this, check if compiling with MSVC and fallback to the Linux implementation. If the latter is not supported, compilation will fail, as it previously would have with the --- src/xenia/base/memory.h | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/src/xenia/base/memory.h b/src/xenia/base/memory.h index abb83bb45..52aeb8ad3 100644 --- a/src/xenia/base/memory.h +++ b/src/xenia/base/memory.h @@ -67,25 +67,21 @@ bool Protect(void* base_address, size_t length, PageAccess access, // The memory must be freed with AlignedFree. template inline T* AlignedAlloc(size_t alignment) { -#if __STDC_VERSION__ >= 201112L - return reinterpret_cast(aligned_alloc(alignment, sizeof(T))); -#elif XE_COMPILER_MSVC +#if XE_COMPILER_MSVC return reinterpret_cast(_aligned_malloc(sizeof(T), alignment)); #else -#error No aligned alloc. -#endif // __STDC_VERSION__ >= 201112L + return reinterpret_cast(aligned_alloc(alignment, sizeof(T))); +#endif // XE_COMPILER_MSVC } // Frees memory previously allocated with AlignedAlloc. template void AlignedFree(T* ptr) { -#if __STDC_VERSION__ >= 201112L - free(ptr); -#elif XE_COMPILER_MSVC +#if XE_COMPILER_MSVC _aligned_free(ptr); #else -#error No aligned alloc. -#endif // __STDC_VERSION__ >= 201112L + free(ptr); +#endif // XE_COMPILER_MSVC } typedef void* FileMappingHandle;