mirror of
https://github.com/sockspls/badfish
synced 2025-04-30 08:43:09 +00:00
Use posix_memalign for Apple Silicon instead of _mm_malloc
fails to build on that target, because of missing Intel Intrinsics. macOS has posix_memalign() since ~2014 so we can simplify the code and just use that for all Apple platforms. closes https://github.com/official-stockfish/Stockfish/pull/2985 No functional change.
This commit is contained in:
parent
992f549ae7
commit
6bc0256292
1 changed files with 3 additions and 3 deletions
|
@ -51,7 +51,7 @@ typedef bool(*fun3_t)(HANDLE, CONST GROUP_AFFINITY*, PGROUP_AFFINITY);
|
|||
#include <sys/mman.h>
|
||||
#endif
|
||||
|
||||
#if (defined(__APPLE__) && defined(_LIBCPP_HAS_C11_FEATURES)) || defined(__ANDROID__) || defined(__OpenBSD__) || (defined(__GLIBCXX__) && !defined(_GLIBCXX_HAVE_ALIGNED_ALLOC) && !defined(_WIN32))
|
||||
#if defined(__APPLE__) || defined(__ANDROID__) || defined(__OpenBSD__) || (defined(__GLIBCXX__) && !defined(_GLIBCXX_HAVE_ALIGNED_ALLOC) && !defined(_WIN32))
|
||||
#define POSIXALIGNEDALLOC
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
|
@ -328,7 +328,7 @@ void* std_aligned_alloc(size_t alignment, size_t size) {
|
|||
if(posix_memalign(&pointer, alignment, size) == 0)
|
||||
return pointer;
|
||||
return nullptr;
|
||||
#elif (defined(_WIN32) || (defined(__APPLE__) && !defined(_LIBCPP_HAS_C11_FEATURES)))
|
||||
#elif defined(_WIN32)
|
||||
return _mm_malloc(size, alignment);
|
||||
#else
|
||||
return std::aligned_alloc(alignment, size);
|
||||
|
@ -338,7 +338,7 @@ void* std_aligned_alloc(size_t alignment, size_t size) {
|
|||
void std_aligned_free(void* ptr) {
|
||||
#if defined(POSIXALIGNEDALLOC)
|
||||
free(ptr);
|
||||
#elif (defined(_WIN32) || (defined(__APPLE__) && !defined(_LIBCPP_HAS_C11_FEATURES)))
|
||||
#elif defined(_WIN32)
|
||||
_mm_free(ptr);
|
||||
#else
|
||||
free(ptr);
|
||||
|
|
Loading…
Add table
Reference in a new issue