diff options
author | Shauren <shauren.trinity@gmail.com> | 2024-02-17 12:03:06 +0100 |
---|---|---|
committer | Shauren <shauren.trinity@gmail.com> | 2024-02-17 12:03:06 +0100 |
commit | b9c2dca59f350edd5b2b877d8a34001389f17a13 (patch) | |
tree | f0631baf0753c685fcaa880a11aa675be89f3ec5 /src/common/Utilities/SFMTRand.cpp | |
parent | ea68ead90dea3abbfc8bc0c5b3414fb5cc4ca6d1 (diff) |
Core/Random: Use correct headers to obtain _mm_malloc definitions
Diffstat (limited to 'src/common/Utilities/SFMTRand.cpp')
-rw-r--r-- | src/common/Utilities/SFMTRand.cpp | 60 |
1 files changed, 28 insertions, 32 deletions
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 <random> #include <ctime> -#if defined(__aarch64__) - #if defined(__clang__) - #include <mm_malloc.h> - #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(<mm_malloc.h>) +#include <mm_malloc.h> +#elif __has_include(<malloc.h>) +#include <malloc.h> #else - #include <emmintrin.h> +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() |