From 109dabde47396bc0d73d67c635b808ec8f8efbae Mon Sep 17 00:00:00 2001 From: Mikhail Komarov Date: Thu, 12 Jan 2017 06:56:19 +0300 Subject: [PATCH] Implemented support for ARMv8 (64 bit arm) --- cds/algo/int_algo.h | 36 +++++++++++++++++++++++++++++-- cds/compiler/gcc/compiler_macro.h | 15 +++++++++---- cds/details/defs.h | 4 +++- 3 files changed, 48 insertions(+), 7 deletions(-) diff --git a/cds/algo/int_algo.h b/cds/algo/int_algo.h index 5c0436ea..3380f547 100644 --- a/cds/algo/int_algo.h +++ b/cds/algo/int_algo.h @@ -34,7 +34,7 @@ #include namespace cds { namespace beans { - +#if CDS_BUILD_BITS == 64 /// Returns largest previous integer for log2( n ) static inline size_t log2floor( size_t n ) { @@ -98,36 +98,68 @@ namespace cds { namespace beans { return is_power2(n) ? log2floor(n) : 0; } -#if CDS_BUILD_BITS == 32 +#elif CDS_BUILD_BITS == 32 //@cond // 64bit specializations +/// Returns largest previous integer for log2( n ) static inline uint64_t log2floor( uint64_t n ) { return n ? cds::bitop::MSBnz( n ) : 0; } +/// Returns smallest following integer for log2( n ) static inline uint64_t log2ceil( uint64_t n ) { uint64_t i = log2floor( n ); return (uint64_t( 1 ) << i) < n ? i + 1 : i; } +/// Returns largest previous power of 2 for \p n + /** + Examples: + \code + floor2(0) == 1 // !!! + floor2(1) == 1 + floor2(2) == 2 + floor2(3) == 2 + floor2(4) == 4 + floor2(15) == 8 + floor2(16) == 16 + floor2(17) == 16 + \endcode + */ static inline uint64_t floor2( uint64_t n ) { return uint64_t( 1 ) << log2floor( n ); } +/// Returns smallest following power of 2 for \p n + /** + Examples: + \code + ceil2(0) == 1 // !!! + ceil2(1) == 1 + ceil2(2) == 2 + ceil2(3) == 4 + ceil2(4) == 4 + ceil2(15) == 16 + ceil2(16) == 16 + ceil2(17) == 32 + \endcode + */ static inline uint64_t ceil2( uint64_t n ) { return uint64_t( 1 ) << log2ceil( n ); } +/// Checks if \p n is power of 2 CDS_CONSTEXPR static inline bool is_power2( uint64_t n ) CDS_NOEXCEPT { return (n & (n - 1)) == 0 && n; } +/// Returns binary logarithm of \p n if \p n is power of two, otherwise returns 0 static inline uint64_t log2( uint64_t n ) { return is_power2( n ) ? log2floor( n ) : 0; diff --git a/cds/compiler/gcc/compiler_macro.h b/cds/compiler/gcc/compiler_macro.h index 5c03d8d4..b65e99ea 100644 --- a/cds/compiler/gcc/compiler_macro.h +++ b/cds/compiler/gcc/compiler_macro.h @@ -89,8 +89,10 @@ // Processor architecture #if defined(__arm__) && !defined(__ARM_ARCH) - // GCC 4.6 does not defined __ARM_ARCH -# if defined(__ARM_ARCH_7A__) || defined(__ARM_ARCH_7R__) +// GCC 4.6 does not defined __ARM_ARCH +# if defined(__ARM_ARCH_8A__) || defined(__ARM_ARCH_8S__) || defined(__aarch64__) || defined(__ARM_ARCH_ISA_A64) +# define __ARM_ARCH 8 +# elif defined(__ARM_ARCH_7A__) || defined(__ARM_ARCH_7R__) || defined(__ARM_ARCH_7S__) # define __ARM_ARCH 7 # else # define __ARM_ARCH 5 @@ -126,11 +128,16 @@ # define CDS_BUILD_BITS 64 # define CDS_PROCESSOR__NAME "IBM PowerPC64" # define CDS_PROCESSOR__NICK "ppc64" -#elif defined(__arm__) && __SIZEOF_POINTER__ == 4 && __ARM_ARCH >= 7 +#elif defined(__arm__) && __SIZEOF_POINTER__ == 4 && __ARM_ARCH >= 7 && __ARM_ARCH < 8 # define CDS_PROCESSOR_ARCH CDS_PROCESSOR_ARM7 # define CDS_BUILD_BITS 32 # define CDS_PROCESSOR__NAME "ARM v7" # define CDS_PROCESSOR__NICK "arm7" +#elif defined(__arm__) && __ARM_ARCH >= 8 +# define CDS_PROCESSOR_ARCH CDS_PROCESSOR_ARM8 +# define CDS_BUILD_BITS 64 +# define CDS_PROCESSOR__NAME "ARM v8" +# define CDS_PROCESSOR__NICK "arm8" #else # if defined(CDS_USE_LIBCDS_ATOMIC) # error "Libcds does not support atomic implementation for the processor architecture. Try to use C++11-compatible compiler and remove CDS_USE_LIBCDS_ATOMIC flag from compiler command line" @@ -150,7 +157,7 @@ # endif #else # ifndef __declspec -# define __declspec( _x ) +# define __declspec(_x) # endif #endif diff --git a/cds/details/defs.h b/cds/details/defs.h index 2d469d17..3e4d53fb 100644 --- a/cds/details/defs.h +++ b/cds/details/defs.h @@ -183,7 +183,7 @@ to \p boost library root directory. The test projects search \p boost libraries in: - for 32bit: \$(BOOST_PATH)/stage/lib, \$(BOOST_PATH)/stage32/lib, and \$(BOOST_PATH)/bin. - for 64bit: \$(BOOST_PATH)/stage64/lib and \$(BOOST_PATH)/bin. - + All tests are based on googletest framework. The following environment variables specify where to find gtest include and library directories: - \p GTEST_ROOT - gtest root directory. \$(GTEST_ROOT)/include specifies full path to @@ -237,6 +237,7 @@ namespace cds {} - CDS_PROCESSOR_SPARC Sparc - CDS_PROCESSOR_PPC64 PowerPC64 - CDS_PROCESSOR_ARM7 ARM v7 + - CDS_PROCESSOR_ARM8 ARM v8 - CDS_PROCESSOR_UNKNOWN undefined processor architecture CDS_PROCESSOR__NAME The name (string) of processor architecture @@ -292,6 +293,7 @@ namespace cds {} #define CDS_PROCESSOR_AMD64 4 #define CDS_PROCESSOR_PPC64 5 // PowerPC 64bit #define CDS_PROCESSOR_ARM7 7 +#define CDS_PROCESSOR_ARM8 8 #define CDS_PROCESSOR_UNKNOWN -1 // Supported OS interfaces -- 2.34.1