From ce449f6b5332ab466d935de0077bccfdde716d1b Mon Sep 17 00:00:00 2001 From: daMaex Date: Sun, 1 Mar 2020 20:16:57 +0100 Subject: Core: build on aarch64 with gcc (#24216) * build on aarch64 with gcc * Core/aarch64: readability on preprocessor macro * Core/aarch64: TC C++ codestyle adjustment --- src/common/Utilities/SFMTRand.cpp | 36 +++++++++++++++++++++++++++++++++--- 1 file changed, 33 insertions(+), 3 deletions(-) (limited to 'src/common/Utilities/SFMTRand.cpp') diff --git a/src/common/Utilities/SFMTRand.cpp b/src/common/Utilities/SFMTRand.cpp index eb6e993c856..e409b09a808 100644 --- a/src/common/Utilities/SFMTRand.cpp +++ b/src/common/Utilities/SFMTRand.cpp @@ -20,12 +20,42 @@ #include #include #include +#include + #if defined(__aarch64__) -#include + #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 #else -#include + #include #endif -#include SFMTRand::SFMTRand() { -- cgit v1.2.3