diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 7d2eeeca..4ee284b2 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -29,7 +29,7 @@ jobs: - armv7 - aarch64 env: - LLVM_MINGW_URL: https://github.com/mstorsjo/llvm-mingw/releases/download/20220906/llvm-mingw-20220906-ucrt-x86_64.zip + LLVM_MINGW_URL: https://github.com/mstorsjo/llvm-mingw/releases/download/20241217/llvm-mingw-20241217-msvcrt-x86_64.zip defaults: run: shell: bash diff --git a/sse2neon.h b/sse2neon.h index a83c12ce..24f3b730 100644 --- a/sse2neon.h +++ b/sse2neon.h @@ -140,10 +140,8 @@ FORCE_INLINE int64_t sse2neon_recast_f64_s64(double f64) return i64; } -#if defined(_WIN32) -/* Definitions for _mm_{malloc,free} are provided by - * from both MinGW-w64 and MSVC. - */ +#if defined(_WIN32) && !defined(__MINGW32__) +/* Definitions for _mm_{malloc,free} are provided by from MSVC. */ #define SSE2NEON_ALLOC_DEFINED #endif @@ -1796,7 +1794,11 @@ FORCE_INLINE __m128 _mm_div_ss(__m128 a, __m128 b) #if !defined(SSE2NEON_ALLOC_DEFINED) FORCE_INLINE void _mm_free(void *addr) { +#if defined(_WIN32) + _aligned_free(addr); +#else free(addr); +#endif } #endif @@ -1979,8 +1981,14 @@ FORCE_INLINE void *_mm_malloc(size_t size, size_t align) return malloc(size); if (align == 2 || (sizeof(void *) == 8 && align == 4)) align = sizeof(void *); +#if defined(_WIN32) + ptr = _aligned_malloc(size, align); + if (ptr) + return ptr; +#else if (!posix_memalign(&ptr, align, size)) return ptr; +#endif return NULL; } #endif