Move cds/int_algo.h to cds/algo/int_algo.h
authorkhizmax <khizmax@gmail.com>
Thu, 18 Sep 2014 15:38:50 +0000 (19:38 +0400)
committerkhizmax <khizmax@gmail.com>
Thu, 18 Sep 2014 15:38:50 +0000 (19:38 +0400)
cds/algo/flat_combining.h
cds/algo/int_algo.h [new file with mode: 0644]
cds/int_algo.h [deleted file]
cds/intrusive/segmented_queue.h
cds/intrusive/split_list_base.h
cds/numtraits.h
cds/opt/buffer.h
projects/Win/vc12/cds.vcxproj
projects/Win/vc12/cds.vcxproj.filters
src/ptb_gc.cpp
tests/test-hdr/misc/bitop_st.cpp

index 4499dc031257e51a712469c4d48de28a130e5129..4c7078166a7ef64d0902e4d42b24467cf2119402 100644 (file)
@@ -9,7 +9,7 @@
 #include <cds/lock/spinlock.h>
 #include <cds/details/std/mutex.h>  // lock_guard
 #include <cds/opt/options.h>
-#include <cds/int_algo.h>
+#include <cds/algo/int_algo.h>
 #include <boost/thread/tss.hpp>     // thread_specific_ptr
 
 namespace cds { namespace algo {
diff --git a/cds/algo/int_algo.h b/cds/algo/int_algo.h
new file mode 100644 (file)
index 0000000..b4db2b8
--- /dev/null
@@ -0,0 +1,74 @@
+//$$CDS-header$$
+
+#ifndef __CDS_INT_ALGO_H
+#define __CDS_INT_ALGO_H
+
+#include <cds/algo/bitop.h>
+
+namespace cds { namespace beans {
+
+    /// Returns largest previous integer for <tt>log2( n )</tt>
+    static inline size_t log2floor( size_t n )
+    {
+        return n ? cds::bitop::MSBnz( n ) : 0;
+    }
+
+    /// Returns smallest following integer for <tt>log2( n )</tt>
+    static inline size_t log2ceil( size_t n )
+    {
+        size_t i = log2floor( n );
+        return size_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 size_t floor2( size_t n )
+    {
+        return size_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 size_t ceil2( size_t n )
+    {
+        return size_t(1) << log2ceil( n );
+    }
+
+    /// Checks if \p n is power of 2
+    CDS_CONSTEXPR static inline bool is_power2( size_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 size_t log2( size_t n )
+    {
+        return is_power2(n) ? log2floor(n) : 0;
+    }
+}}   // namespace cds::beans
+
+#endif  // #ifndef __CDS_INT_ALGO_H
diff --git a/cds/int_algo.h b/cds/int_algo.h
deleted file mode 100644 (file)
index b4db2b8..0000000
+++ /dev/null
@@ -1,74 +0,0 @@
-//$$CDS-header$$
-
-#ifndef __CDS_INT_ALGO_H
-#define __CDS_INT_ALGO_H
-
-#include <cds/algo/bitop.h>
-
-namespace cds { namespace beans {
-
-    /// Returns largest previous integer for <tt>log2( n )</tt>
-    static inline size_t log2floor( size_t n )
-    {
-        return n ? cds::bitop::MSBnz( n ) : 0;
-    }
-
-    /// Returns smallest following integer for <tt>log2( n )</tt>
-    static inline size_t log2ceil( size_t n )
-    {
-        size_t i = log2floor( n );
-        return size_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 size_t floor2( size_t n )
-    {
-        return size_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 size_t ceil2( size_t n )
-    {
-        return size_t(1) << log2ceil( n );
-    }
-
-    /// Checks if \p n is power of 2
-    CDS_CONSTEXPR static inline bool is_power2( size_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 size_t log2( size_t n )
-    {
-        return is_power2(n) ? log2floor(n) : 0;
-    }
-}}   // namespace cds::beans
-
-#endif  // #ifndef __CDS_INT_ALGO_H
index 2fb03952faede17f0a0c943b540f34098f518275..18a9d45aa51048039e1fcb3881abc671dcbd4624 100644 (file)
@@ -5,7 +5,7 @@
 
 #include <cds/intrusive/base.h>
 #include <cds/details/marked_ptr.h>
-#include <cds/int_algo.h>
+#include <cds/algo/int_algo.h>
 #include <cds/details/std/mutex.h>
 #include <cds/lock/spinlock.h>
 #include <cds/opt/permutation.h>
index a5365535229477add34ac022a2e2805549142a96..a7bc10abca813e9e1e8e589fd7bf1d2e7c730062 100644 (file)
@@ -6,7 +6,7 @@
 #include <cds/intrusive/base.h>
 #include <cds/cxx11_atomic.h>
 #include <cds/details/allocator.h>
-#include <cds/int_algo.h>
+#include <cds/algo/int_algo.h>
 #include <cds/algo/bitop.h>
 #include <cds/details/functor_wrapper.h>
 
index 89f5aa76fd5e623207ae4c7b66122e28390da217..df262a0a7e0b343498f867f219a18ad09d758473 100644 (file)
@@ -55,31 +55,6 @@ namespace cds {
         };
         //@endcond
 
-        //TODO - deprecated. Use is_power2 from int_algo.h
-        /// A tricky runtime algorithm to ensure that @p n is power of 2
-        static inline bool isExp2( size_t n )
-        {
-            return(n & (n - 1)) == 0 && n;
-        }
-
-        //TODO: deprecated. Use log2 from int_algo.h
-        /// Runtime algorithm to compute log2( @p nTest ). If @p nTest is not power of two then -1 returns
-        static inline int exponent2( size_t nTest )
-        {
-            int nExp = -1;
-            size_t nMask = 1;
-            for ( size_t n = 0; n < CDS_BUILD_BITS; n++ ) {
-                if ( nTest & nMask ) {
-                    if ( nExp == -1 )
-                        nExp = (int) n;
-                    else
-                        return -1    ;    // nTest íå ÿâëÿåòñÿ ñòåïåíüþ äâîéêè
-                }
-                nMask = nMask << 1;
-            }
-            return nExp;
-        }
-
         /// Returns @a N: 2**N is nearest to @p nNumber, 2**N < nNumber
         static inline size_t exp2Ceil( size_t nNumber )
         {
index fe1d08151751a81a67d1d3014561c8d1d944ea17..71af760db7366c6817a457f2a8c14ab3fdeb6538 100644 (file)
@@ -6,7 +6,7 @@
 #include <cds/details/defs.h>
 #include <cds/user_setup/allocator.h>
 #include <cds/details/allocator.h>
-#include <cds/int_algo.h>
+#include <cds/algo/int_algo.h>
 
 namespace cds { namespace opt {
 
index 90d9b8c995cdfe132e735cd741598ae21a82ccb2..2ef5e971161b5cff73b52152be843defef10e2ca 100644 (file)
     <ClInclude Include="..\..\..\cds\urcu\signal_threaded.h" />\r
     <ClInclude Include="..\..\..\src\hzp_const.h" />\r
     <ClInclude Include="..\..\..\cds\init.h" />\r
-    <ClInclude Include="..\..\..\cds\int_algo.h" />\r
     <ClInclude Include="..\..\..\cds\numtraits.h" />\r
     <ClInclude Include="..\..\..\cds\ref.h" />\r
     <ClInclude Include="..\..\..\cds\refcounter.h" />\r
index 9a573f084838a2f162c875d395a6708b836a286d..3f678be620a1c2f15ba3b4c6c0eb7b021e8f08c2 100644 (file)
     <ClInclude Include="..\..\..\cds\init.h">\r
       <Filter>Header Files\cds</Filter>\r
     </ClInclude>\r
-    <ClInclude Include="..\..\..\cds\int_algo.h">\r
-      <Filter>Header Files\cds</Filter>\r
-    </ClInclude>\r
     <ClInclude Include="..\..\..\cds\numtraits.h">\r
       <Filter>Header Files\cds</Filter>\r
     </ClInclude>\r
index 12ceb7f9c33a146288e4a2e1136b4804cc3eeb83..9a11b0bf8d68fe854948e4ff9edc8cf3ad419cc2 100644 (file)
@@ -3,7 +3,7 @@
 // Pass The Buck (PTB) Memory manager implementation
 
 #include <cds/gc/ptb/ptb.h>
-#include <cds/int_algo.h>
+#include <cds/algo/int_algo.h>
 
 #include <cds/details/hash_functor_selector.h>
 #include <algorithm>   // std::fill
index 01d4de775caea55ba4b7a461d392f9eaae0744af..391a2a7024247f9f07864f22c9f16e5b720f2995 100644 (file)
@@ -2,7 +2,7 @@
 
 #include "cppunit/cppunit_proxy.h"
 
-#include <cds/int_algo.h>
+#include <cds/algo/int_algo.h>
 #include <cds/os/timer.h>
 
 class bitop_ST : public CppUnitMini::TestCase