From 62ae928b404d19f22ace80c61fee584c0c942b5e Mon Sep 17 00:00:00 2001 From: Leo Yuriev Date: Wed, 21 Mar 2018 21:15:21 +0300 Subject: [PATCH] mdbx: add neutral __ia32__ and __amd64__ marcos. --- src/osal.h | 25 +++++++++++++++++++++---- test/utils.cc | 4 ++-- test/utils.h | 5 ++--- 3 files changed, 25 insertions(+), 9 deletions(-) diff --git a/src/osal.h b/src/osal.h index 8a34915d..3819fa4a 100644 --- a/src/osal.h +++ b/src/osal.h @@ -117,11 +117,28 @@ typedef pthread_mutex_t mdbx_fastmutex_t; #include #endif +#if defined(i386) || defined(__386) || defined(__i386) || defined(__i386__) || \ + defined(i486) || defined(__i486) || defined(__i486__) || \ + defined(i586) | defined(__i586) || defined(__i586__) || defined(i686) || \ + defined(__i686) || defined(__i686__) || defined(_M_IX86) || \ + defined(_X86_) || defined(__THW_INTEL__) || defined(__I86__) || \ + defined(__INTEL__) || defined(__x86_64) || defined(__x86_64__) || \ + defined(__amd64__) || defined(__amd64) || defined(_M_X64) || \ + defined(_M_AMD64) || defined(__IA32__) || defined(__INTEL__) +#ifndef __ia32__ +/* LY: define neutral __ia32__ for x86 and x86-64 archs */ +#define __ia32__ 1 +#endif /* __ia32__ */ +#if !defined(__amd64__) && (defined(__x86_64) || defined(__x86_64__) || \ + defined(__amd64) || defined(_M_X64)) +/* LY: define trusty __amd64__ for all AMD64/x86-64 arch */ +#define __amd64__ 1 +#endif /* __amd64__ */ +#endif /* all x86 */ + #if !defined(UNALIGNED_OK) -#if (defined(__i386) || defined(__x86_64__) || defined(_M_IX86) || \ - defined(_M_X64) || defined(i386) || defined(_X86_) || \ - defined(__i386__) || defined(_X86_64_) || \ - defined(__ARM_FEATURE_UNALIGNED) || defined(__e2k__)) && \ +#if (defined(__ia32__) || defined(__e2k__) || \ + defined(__ARM_FEATURE_UNALIGNED)) && \ !defined(__ALIGNED__) #define UNALIGNED_OK 1 #else diff --git a/test/utils.cc b/test/utils.cc index 96866f61..25c215b0 100644 --- a/test/utils.cc +++ b/test/utils.cc @@ -127,6 +127,7 @@ bool hex2data(const char *hex_begin, const char *hex_end, void *ptr, //----------------------------------------------------------------------------- +/* TODO: replace my 'libmera' fomr t1ha. */ uint64_t entropy_ticks(void) { #if defined(__GNUC__) || defined(__clang__) #if defined(__ia64__) @@ -165,8 +166,7 @@ uint64_t entropy_ticks(void) { #endif /* arch selector */ #endif /* __GNUC__ || __clang__ */ -#if defined(__e2k__) || defined(__elbrus__) || defined(_M_IX86) || \ - defined(_M_X64) || defined(__x86_64__) || defined(__i386__) +#if defined(__e2k__) || defined(__ia32__) return __rdtsc(); #elif defined(_WIN32) || defined(_WIN64) || defined(_WINDOWS) LARGE_INTEGER PerformanceCount; diff --git a/test/utils.h b/test/utils.h index 176823c6..c44f0ee4 100644 --- a/test/utils.h +++ b/test/utils.h @@ -274,7 +274,7 @@ static __inline void memory_barrier(void) { #elif defined(__INTEL_COMPILER) /* LY: Intel Compiler may mimic GCC and MSC */ #if defined(__ia64__) || defined(__ia64) || defined(_M_IA64) __mf(); -#elif defined(__i386__) || defined(__x86_64__) +#elif defined(__ia32__) _mm_mfence(); #else #error "Unknown target for Intel Compiler, please report to us." @@ -293,8 +293,7 @@ static __inline void memory_barrier(void) { } static __inline void cpu_relax() { -#if defined(__i386__) || defined(__x86_64__) || defined(_M_IX86) || \ - defined(_M_X64) +#if defined(__ia32__) _mm_pause(); #elif defined(_WIN32) || defined(_WIN64) || defined(_WINDOWS) || \ defined(YieldProcessor)