From ae752f72d89fd2af75e560b7b3ef70a5f961232a Mon Sep 17 00:00:00 2001 From: kervala Date: Mon, 4 Jan 2016 19:18:19 +0100 Subject: [PATCH 1/2] Changed: Define CLANG_VERSION is using clang compiler --HG-- branch : develop --- code/nel/include/nel/misc/types_nl.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/code/nel/include/nel/misc/types_nl.h b/code/nel/include/nel/misc/types_nl.h index 32b6a85d0..64d82d5bf 100644 --- a/code/nel/include/nel/misc/types_nl.h +++ b/code/nel/include/nel/misc/types_nl.h @@ -191,6 +191,10 @@ # define NL_ISO_STDTR1_HEADER(header)
# define NL_ISO_STDTR1_NAMESPACE std # endif +# endif + // clang define GCC version for compatibility +# ifdef __clang__ +# define CLANG_VERSION (__clang_major__ * 10000 + __clang_minor__ * 100 + __clang_patchlevel__) # endif #endif From 0dc70105d534131aa3b1e336ec0f3f9db2bfa7e1 Mon Sep 17 00:00:00 2001 From: kervala Date: Mon, 4 Jan 2016 19:26:25 +0100 Subject: [PATCH 2/2] Fixed: __rdtsc() under old versions of GCC --HG-- branch : develop --- code/nel/include/nel/misc/common.h | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/code/nel/include/nel/misc/common.h b/code/nel/include/nel/misc/common.h index 191db5188..7dc394f24 100644 --- a/code/nel/include/nel/misc/common.h +++ b/code/nel/include/nel/misc/common.h @@ -39,7 +39,7 @@ #endif #if defined(NL_CPU_INTEL) && defined(NL_COMP_GCC) -#include "x86intrin.h" +#include #endif #include "string_common.h" @@ -69,8 +69,20 @@ namespace NLMISC inline uint64 rdtsc() { - // __rdtsc() is defined under all platforms +#if defined(NL_COMP_GCC) && !defined(CLANG_VERSION) && (GCC_VERSION <= 40405) +// for GCC versions that don't implement __rdtsc() +#ifdef NL_CPU_X86_64 + uint64 low, high; + __asm__ volatile("rdtsc" : "=a" (low), "=d" (high)); + return low | (high << 32); +#else + uint64 ticks; + __asm__ volatile("rdtsc" : "=A" (ticks)); + return ticks; +#endif +#else return uint64(__rdtsc()); +#endif } #endif // NL_CPU_INTEL