diff --git a/src/Geno.cpp b/src/Geno.cpp index 853a86a47ba5d7f422b9c4455ca3202685c9c641..77dc4a8a0ac1c51ea830795b8671c02b5114af35 100644 --- a/src/Geno.cpp +++ b/src/Geno.cpp @@ -43,6 +43,26 @@ #include "submods/Pgenlib/PgenReader.h" #include +#if defined( __i386__ ) || defined(i386) || defined(_M_IX86) + /* + * __i386__ is defined by gcc and Intel compiler on Linux, + * _M_IX86 by VS compiler, + * i386 by Sun compilers on opensolaris at least + */ + #define CPU_X86 +#elif defined(__x86_64__) || defined(__amd64__) || defined(__x86_64) || defined(_M_AMD64) + /* + * both __x86_64__ and __amd64__ are defined by gcc + * __x86_64 defined by sun compiler on opensolaris at least + * _M_AMD64 defined by MS compiler + */ + #define CPU_AMD64 +#elif defined(__arm__) || defined(__aarch64__) + #define CPU_ARM +#else + #error Unknown CPU +#endif + #ifdef _WIN64 #include uint32_t __inline CTZ64U(uint64_t value){ @@ -59,13 +79,13 @@ #else //#define CTZU __builtin_ctz //#define CLZU __builtin_clz - #ifdef __linux__ + #if defined(__linux__) && !defined(CPU_ARM) __attribute__((target("default"))) #endif uint32_t CTZ64U(uint64_t value){ return __builtin_ctzll(value); } - #ifdef __linux__ + #if defined(__linux__) && !defined(CPU_ARM) __attribute__((target("popcnt"))) uint32_t CTZ64U(uint64_t value){ return __builtin_ctzll(value); @@ -74,7 +94,7 @@ #endif -#ifdef __linux__ +#if defined(__linux__) && !defined(CPU_ARM) __attribute__((target("default"))) #endif uint64_t fill_inter_zero(uint64_t x) { @@ -91,7 +111,7 @@ uint64_t fill_inter_zero(uint64_t x) { x = x ^ t ^ (t << 1); return x; } -#ifdef __linux__ +#if defined(__linux__) && !defined(CPU_ARM) #include __attribute__((target("bmi2"))) uint64_t fill_inter_zero(uint64_t x) {