Implemented support for ARMv8 (64 bit arm)
authorMikhail Komarov <nemo1369@gmail.com>
Thu, 12 Jan 2017 03:56:19 +0000 (06:56 +0300)
committerMikhail Komarov <nemo1369@gmail.com>
Thu, 12 Jan 2017 03:56:19 +0000 (06:56 +0300)
cds/algo/int_algo.h
cds/compiler/gcc/compiler_macro.h
cds/details/defs.h

index 5c0436ea6d80f71692a0942eca4f198a0b4e585a..3380f5474845fc87a99d8d71e3233a670fa26530 100644 (file)
@@ -34,7 +34,7 @@
 #include <cds/algo/bitop.h>
 
 namespace cds { namespace beans {
-
+#if CDS_BUILD_BITS == 64
     /// Returns largest previous integer for <tt>log2( n )</tt>
     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 <tt>log2( n )</tt>
     static inline uint64_t log2floor( uint64_t n )
     {
         return n ? cds::bitop::MSBnz( n ) : 0;
     }
 
+/// Returns smallest following integer for <tt>log2( n )</tt>
     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;
index 5c03d8d4aba1ee5707b1a69f8cef44524efdfe1f..b65e99eafe6ae6216a8eccafcbd6a6f9f18c7807 100644 (file)
 // 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
 #    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"
 #   endif
 #else
 #   ifndef __declspec
-#       define __declspec( _x )
+#       define __declspec(_x)
 #   endif
 #endif
 
index 2d469d17fe3d9ae66632843df78caca801e06f90..3e4d53fbcf3ad955ec10ed7124d2097bbb44d4a2 100644 (file)
    to \p boost library root directory. The test projects search \p boost libraries in:
    - for 32bit: <tt>\$(BOOST_PATH)/stage/lib</tt>, <tt>\$(BOOST_PATH)/stage32/lib</tt>, and <tt>\$(BOOST_PATH)/bin</tt>.
    - for 64bit: <tt>\$(BOOST_PATH)/stage64/lib</tt> and <tt>\$(BOOST_PATH)/bin</tt>.
-   
+
    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. <tt>\$(GTEST_ROOT)/include</tt> 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