From 5cb4f6aeaf9d55bb37eea492d402eb850324a99e Mon Sep 17 00:00:00 2001 From: Shauren Date: Sat, 17 Feb 2024 12:03:06 +0100 Subject: Core/Random: Use correct headers to obtain _mm_malloc definitions (cherry picked from commit b9c2dca59f350edd5b2b877d8a34001389f17a13) --- src/common/Utilities/SFMTRand.cpp | 60 ++++++++++++++++++--------------------- 1 file changed, 28 insertions(+), 32 deletions(-) (limited to 'src/common/Utilities/SFMTRand.cpp') diff --git a/src/common/Utilities/SFMTRand.cpp b/src/common/Utilities/SFMTRand.cpp index e409b09a808..6aeb49b9e38 100644 --- a/src/common/Utilities/SFMTRand.cpp +++ b/src/common/Utilities/SFMTRand.cpp @@ -22,39 +22,35 @@ #include #include -#if defined(__aarch64__) - #if defined(__clang__) - #include - #elif defined(__GNUC__) - static __inline__ void *__attribute__((__always_inline__, __nodebug__, __malloc__)) - _mm_malloc(size_t __size, size_t __align) - { - if (__align == 1) - { - return malloc(__size); - } - - if (!(__align & (__align - 1)) && __align < sizeof(void *)) - __align = sizeof(void *); - - void *__mallocedMemory; - - if (posix_memalign(&__mallocedMemory, __align, __size)) - return NULL; - - return __mallocedMemory; - } - - static __inline__ void __attribute__((__always_inline__, __nodebug__)) - _mm_free(void *__p) - { - free(__p); - } - #else - #error aarch64 only on clang and gcc - #endif +#if __has_include() +#include +#elif __has_include() +#include #else - #include +static __inline__ void *__attribute__((__always_inline__, __nodebug__, __malloc__)) +_mm_malloc(size_t __size, size_t __align) +{ + if (__align == 1) + { + return malloc(__size); + } + + if (!(__align & (__align - 1)) && __align < sizeof(void *)) + __align = sizeof(void *); + + void *__mallocedMemory; + + if (posix_memalign(&__mallocedMemory, __align, __size)) + return NULL; + + return __mallocedMemory; +} + +static __inline__ void __attribute__((__always_inline__, __nodebug__)) +_mm_free(void *__p) +{ + free(__p); +} #endif SFMTRand::SFMTRand() -- cgit v1.2.3