From e5f6d71b96b5149e5e1df30721e1870abdb218ce Mon Sep 17 00:00:00 2001 From: borg323 Date: Thu, 9 Feb 2023 21:14:59 +0200 Subject: [PATCH] Fix build on arm windows avoids the use of _mm_malloc on arm windows. fixes #4379 closes https://github.com/official-stockfish/Stockfish/pull/4388 No functional change --- AUTHORS | 1 + src/misc.cpp | 8 ++++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/AUTHORS b/AUTHORS index 42ba5930..634de4a3 100644 --- a/AUTHORS +++ b/AUTHORS @@ -35,6 +35,7 @@ Ben Chaney (Chaneybenjamini) Ben Koshy (BKSpurgeon) Bill Henry (VoyagerOne) Bojun Guo (noobpwnftw, Nooby) +borg323 Boštjan Mejak (PedanticHacker) braich Brian Sheppard (SapphireBrand, briansheppard-toast) diff --git a/src/misc.cpp b/src/misc.cpp index 7d848d32..e65faab9 100644 --- a/src/misc.cpp +++ b/src/misc.cpp @@ -448,8 +448,10 @@ void* std_aligned_alloc(size_t alignment, size_t size) { #if defined(POSIXALIGNEDALLOC) void *mem; return posix_memalign(&mem, alignment, size) ? nullptr : mem; -#elif defined(_WIN32) +#elif defined(_WIN32) && !defined(_M_ARM) && !defined(_M_ARM64) return _mm_malloc(size, alignment); +#elif defined(_WIN32) + return _aligned_malloc(size, alignment); #else return std::aligned_alloc(alignment, size); #endif @@ -459,8 +461,10 @@ void std_aligned_free(void* ptr) { #if defined(POSIXALIGNEDALLOC) free(ptr); -#elif defined(_WIN32) +#elif defined(_WIN32) && !defined(_M_ARM) && !defined(_M_ARM64) _mm_free(ptr); +#elif defined(_WIN32) + _aligned_free(ptr); #else free(ptr); #endif -- 2.39.2