diff --git a/common/src/Utilities/AlignedMalloc.cpp b/common/src/Utilities/AlignedMalloc.cpp index ab2fdf0612..06ff8bd989 100644 --- a/common/src/Utilities/AlignedMalloc.cpp +++ b/common/src/Utilities/AlignedMalloc.cpp @@ -30,6 +30,9 @@ void* __fastcall pcsx2_aligned_malloc(size_t size, size_t align) { pxAssert( align < 0x10000 ); +#ifdef __USE_ISOC11 + return aligned_alloc(align, size); +#else u8* p = (u8*)malloc(size+align+headsize); // start alignment calculations from past the header. @@ -43,6 +46,7 @@ void* __fastcall pcsx2_aligned_malloc(size_t size, size_t align) header->size = size; return (void*)aligned; +#endif } void* __fastcall pcsx2_aligned_realloc(void* handle, size_t size, size_t align) @@ -53,18 +57,27 @@ void* __fastcall pcsx2_aligned_realloc(void* handle, size_t size, size_t align) if( handle != NULL ) { +#ifdef __USE_ISOC11 + memcpy_fast( newbuf, handle, size ); + free( handle ); +#else AlignedMallocHeader* header = (AlignedMallocHeader*)((uptr)handle - headsize); memcpy_fast( newbuf, handle, std::min( size, header->size ) ); free( header->baseptr ); +#endif } return newbuf; } __fi void pcsx2_aligned_free(void* pmem) { +#ifdef __USE_ISOC11 + free(pmem); +#else if( pmem == NULL ) return; AlignedMallocHeader* header = (AlignedMallocHeader*)((uptr)pmem - headsize); free( header->baseptr ); +#endif } // ---------------------------------------------------------------------------- diff --git a/plugins/GSdx/stdafx.cpp b/plugins/GSdx/stdafx.cpp index aec09d6034..bb1a419acb 100644 --- a/plugins/GSdx/stdafx.cpp +++ b/plugins/GSdx/stdafx.cpp @@ -107,6 +107,8 @@ void vmfree(void* ptr, size_t size) // declare linux equivalents (alignment must be power of 2 (1,2,4...2^15) +#if !defined(__USE_ISOC11) + void* _aligned_malloc(size_t size, size_t alignment) { ASSERT(alignment <= 0x8000); @@ -124,3 +126,5 @@ void _aligned_free(void* p) } #endif + +#endif diff --git a/plugins/GSdx/stdafx.h b/plugins/GSdx/stdafx.h index deac8889b1..f0f035a433 100644 --- a/plugins/GSdx/stdafx.h +++ b/plugins/GSdx/stdafx.h @@ -71,6 +71,7 @@ typedef uint32 uptr; #include #include #include +#include #include #include #include @@ -185,8 +186,6 @@ using namespace std; #else - #define _BACKWARD_BACKWARD_WARNING_H - #define hash_map map #define hash_set set @@ -359,7 +358,12 @@ struct aligned_free_second {template void operator()(T& p) {_aligned_fr #if !defined(_MSC_VER) - #if !defined(HAVE_ALIGNED_MALLOC) + #if defined(__USE_ISOC11) + + #define _aligned_malloc(size, a) aligned_alloc(a, size) + static void _aligned_free(void* p) { free(p); } + + #elif !defined(HAVE_ALIGNED_MALLOC) extern void* _aligned_malloc(size_t size, size_t alignment); extern void _aligned_free(void* p);