Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix undefined _mm_malloc and _mm_free when building with LLVM/MinGW. #637

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions sse2neon.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,8 @@
#include <stdint.h>
#include <stdlib.h>

#if defined(_WIN32)
/* Definitions for _mm_{malloc,free} are provided by <malloc.h>
* from both MinGW-w64 and MSVC.
*/
#if defined(_WIN32) && !defined(__MINGW32__)
/* Definitions for _mm_{malloc,free} are provided by <malloc.h> from MSVC. */
#define SSE2NEON_ALLOC_DEFINED
#endif

Expand Down Expand Up @@ -1767,7 +1765,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

Expand Down Expand Up @@ -1955,8 +1957,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
Expand Down
Loading