1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-31 08:13:04 +04:00

3rdparty(mlas): fix MinGW build of aligned scratch buffer

MlasThreadedBufAlloc() and its ThreadedBufHolder guarded the
_aligned_malloc / _aligned_free path on _MSC_VER. Non-MSVC Windows
toolchains (MinGW, clang) therefore fell through to posix_memalign(),
which the Windows CRT does not provide, so the build failed with
"'posix_memalign' was not declared in this scope".

Guard the aligned-allocation path on _WIN32 instead, in both the holder
declaration (mlasi.h) and definition (platform.cpp) so the unique_ptr
deleter type stays consistent across translation units, and include
<malloc.h> on Windows since MinGW only declares the _aligned_* functions
there. The non-Windows posix_memalign / aligned_alloc fallback is
unchanged.

Fixes #29350
This commit is contained in:
ShivaPriyanShanmuga
2026-06-20 22:32:07 -04:00
parent 6d2cd14bb2
commit f831c94309
2 changed files with 4 additions and 3 deletions
+1 -1
View File
@@ -1088,7 +1088,7 @@ MlasPlatformU8S8Overflow(
#endif
thread_local size_t ThreadedBufSize = 0;
#ifdef _MSC_VER
#ifdef _WIN32
thread_local std::unique_ptr<uint8_t, decltype(&_aligned_free)> ThreadedBufHolder(nullptr, &_aligned_free);
#else
thread_local std::unique_ptr<uint8_t, decltype(&free)> ThreadedBufHolder(nullptr, &free);