From c44059685f59b35559073dc89040297824bd381b Mon Sep 17 00:00:00 2001 From: Martijn Courteaux Date: Fri, 10 Jan 2025 18:04:26 +0100 Subject: [PATCH] Fix check for Windows never having aligned_alloc available. (#8551) Fix check for Windows having aligned_alloc available. --- src/runtime/HalideBuffer.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/runtime/HalideBuffer.h b/src/runtime/HalideBuffer.h index a02e0588afac..3ae0a1e5c33d 100644 --- a/src/runtime/HalideBuffer.h +++ b/src/runtime/HalideBuffer.h @@ -65,10 +65,12 @@ static_assert(((HALIDE_RUNTIME_BUFFER_ALLOCATION_ALIGNMENT & (HALIDE_RUNTIME_BUF #ifndef HALIDE_RUNTIME_BUFFER_USE_ALIGNED_ALLOC // clang-format off -#ifdef _MSC_VER +#ifdef _WIN32 - // MSVC doesn't implement aligned_alloc(), even in C++17 mode, and - // has stated they probably never will, so, always default it off here. + // Windows (regardless of which compiler) doesn't implement aligned_alloc(), + // even in C++17 mode, and has stated they probably never will, as the issue + // is in the incompatibility that free() needs to be able to free both pointers + // returned by malloc() and aligned_alloc(). So, always default it off here. #define HALIDE_RUNTIME_BUFFER_USE_ALIGNED_ALLOC 0 #elif defined(__ANDROID_API__) && __ANDROID_API__ < 28