Add detection for _aligned_malloc.

This commit is contained in:
XMRig 2025-06-15 20:06:19 +07:00
parent 3b863cf88f
commit d58061c903
No known key found for this signature in database
GPG key ID: 446A53638BE94409
2 changed files with 13 additions and 7 deletions

View file

@ -1,10 +1,16 @@
if (WITH_RANDOMX) if (WITH_RANDOMX)
include(CheckFunctionExists) include(CheckSymbolExists)
check_function_exists(posix_memalign HAVE_POSIX_MEMALIGN) if (WIN32)
check_symbol_exists(_aligned_malloc "stdlib.h" HAVE_ALIGNED_MALLOC)
if(HAVE_POSIX_MEMALIGN) if (HAVE_ALIGNED_MALLOC)
add_definitions(/DHAVE_POSIX_MEMALIGN) add_compile_definitions(HAVE_ALIGNED_MALLOC)
endif()
else()
check_symbol_exists(posix_memalign "stdlib.h" HAVE_POSIX_MEMALIGN)
if (HAVE_POSIX_MEMALIGN)
add_compile_definitions(HAVE_POSIX_MEMALIGN)
endif()
endif() endif()
add_definitions(/DXMRIG_ALGO_RANDOMX) add_definitions(/DXMRIG_ALGO_RANDOMX)

View file

@ -412,7 +412,7 @@ inline void* rx_aligned_alloc(size_t size, size_t align) {
return 0; return 0;
}; };
# define rx_aligned_free(a) free(a) # define rx_aligned_free(a) free(a)
#elif defined(_MSC_VER) #elif defined(HAVE_ALIGNED_MALLOC)
# define rx_aligned_alloc(a, b) _aligned_malloc(a, b) # define rx_aligned_alloc(a, b) _aligned_malloc(a, b)
# define rx_aligned_free(a) _aligned_free(a) # define rx_aligned_free(a) _aligned_free(a)
#else #else
@ -569,7 +569,7 @@ inline void* rx_aligned_alloc(size_t size, size_t align) {
return 0; return 0;
}; };
# define rx_aligned_free(a) free(a) # define rx_aligned_free(a) free(a)
#elif defined(_MSC_VER) #elif defined(HAVE_ALIGNED_MALLOC)
# define rx_aligned_alloc(a, b) _aligned_malloc(a, b) # define rx_aligned_alloc(a, b) _aligned_malloc(a, b)
# define rx_aligned_free(a) _aligned_free(a) # define rx_aligned_free(a) _aligned_free(a)
#else #else