#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 {
--- /dev/null
+//$$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
+++ /dev/null
-//$$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
#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>
#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>
};
//@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 )
{
#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 {
<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
<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
// 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
#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