diff options
author | daMaex <damaex@live.de> | 2020-03-01 20:16:57 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-03-01 20:16:57 +0100 |
commit | ce449f6b5332ab466d935de0077bccfdde716d1b (patch) | |
tree | b76ad1e81aab8079a6a94116c2771e61143abecc | |
parent | 6067a996324dc4e36a414257e6abf7f9dfdfa934 (diff) |
Core: build on aarch64 with gcc (#24216)
* build on aarch64 with gcc
* Core/aarch64: readability on preprocessor macro
* Core/aarch64: TC C++ codestyle adjustment
-rw-r--r-- | cmake/compiler/gcc/settings.cmake | 12 | ||||
-rw-r--r-- | src/common/Utilities/SFMTRand.cpp | 36 |
2 files changed, 40 insertions, 8 deletions
diff --git a/cmake/compiler/gcc/settings.cmake b/cmake/compiler/gcc/settings.cmake index c0d806c3d64..c2fbfee0345 100644 --- a/cmake/compiler/gcc/settings.cmake +++ b/cmake/compiler/gcc/settings.cmake @@ -16,11 +16,13 @@ if(PLATFORM EQUAL 32) -msse2 -mfpmath=sse) endif() -target_compile_definitions(trinity-compile-option-interface - INTERFACE - -DHAVE_SSE2 - -D__SSE2__) -message(STATUS "GCC: SFMT enabled, SSE2 flags forced") +if(NOT CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64") + target_compile_definitions(trinity-compile-option-interface + INTERFACE + -DHAVE_SSE2 + -D__SSE2__) + message(STATUS "GCC: SFMT enabled, SSE2 flags forced") +endif() if( WITH_WARNINGS ) target_compile_options(trinity-warning-interface 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 <array> #include <functional> #include <random> +#include <ctime> + #if defined(__aarch64__) -#include <mm_malloc.h> + #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 #else -#include <emmintrin.h> + #include <emmintrin.h> #endif -#include <ctime> SFMTRand::SFMTRand() { |