Move cds/bitop.h to cds/algo/bitop.h
authorkhizmax <khizmax@gmail.com>
Thu, 18 Sep 2014 15:33:46 +0000 (19:33 +0400)
committerkhizmax <khizmax@gmail.com>
Thu, 18 Sep 2014 15:33:46 +0000 (19:33 +0400)
cds/algo/bitop.h [new file with mode: 0644]
cds/bitop.h [deleted file]
cds/details/bit_reverse_counter.h
cds/int_algo.h
cds/intrusive/michael_set_base.h
cds/intrusive/skip_list_base.h
cds/intrusive/split_list_base.h
projects/Win/vc12/cds.vcxproj
projects/Win/vc12/cds.vcxproj.filters
src/dllmain.cpp

diff --git a/cds/algo/bitop.h b/cds/algo/bitop.h
new file mode 100644 (file)
index 0000000..2ab7a5e
--- /dev/null
@@ -0,0 +1,140 @@
+//$$CDS-header$$
+
+#ifndef __CDS_BITOP_H
+#define __CDS_BITOP_H
+
+/*
+    Different bit algorithms:
+        LSB        get least significant bit number
+        MSB        get most significant bit number
+        bswap    swap byte order of word
+        RBO        reverse bit order of word
+
+    Editions:
+        2007.10.08    Maxim.Khiszinsky    Created
+*/
+
+#include <cds/details/defs.h>
+#include <cds/compiler/bitop.h>
+
+namespace cds {
+    /// Bit operations
+    namespace bitop {
+
+        ///@cond none
+        namespace details {
+            template <int> struct BitOps;
+
+            // 32-bit bit ops
+            template <> struct BitOps<4> {
+                typedef atomic32u_t        TUInt;
+
+                static int      MSB( TUInt x )      { return bitop::platform::msb32( x );   }
+                static int      LSB( TUInt x )      { return bitop::platform::lsb32( x );   }
+                static int      MSBnz( TUInt x )    { return bitop::platform::msb32nz( x ); }
+                static int      LSBnz( TUInt x )    { return bitop::platform::lsb32nz( x ); }
+                static int      SBC( TUInt x )      { return bitop::platform::sbc32( x ) ;  }
+                static int      ZBC( TUInt x )      { return bitop::platform::zbc32( x ) ;  }
+
+                static TUInt    RBO( TUInt x )      { return bitop::platform::rbo32( x );   }
+                static bool     complement( TUInt& x, int nBit ) { return bitop::platform::complement32( &x, nBit ); }
+
+                static TUInt    RandXorShift(TUInt x) { return bitop::platform::RandXorShift32(x); }
+            };
+
+            // 64-bit bit ops
+            template <> struct BitOps<8> {
+                typedef atomic64u_unaligned        TUInt;
+
+                static int      MSB( TUInt x )        { return bitop::platform::msb64( x );     }
+                static int      LSB( TUInt x )        { return bitop::platform::lsb64( x );     }
+                static int      MSBnz( TUInt x )      { return bitop::platform::msb64nz( x );   }
+                static int      LSBnz( TUInt x )      { return bitop::platform::lsb64nz( x );   }
+                static  int     SBC( TUInt x )        { return bitop::platform::sbc64( x ) ;    }
+                static  int     ZBC( TUInt x )        { return bitop::platform::zbc64( x ) ;    }
+
+                static TUInt    RBO( TUInt x )        { return bitop::platform::rbo64( x );     }
+                static bool     complement( TUInt& x, int nBit ) { return bitop::platform::complement64( &x, nBit ); }
+
+                static TUInt    RandXorShift(TUInt x) { return bitop::platform::RandXorShift64(x); }
+            };
+        }    // namespace details
+        //@endcond
+
+
+        /// Get least significant bit (LSB) number (1..32/64), 0 if nArg == 0
+        template <typename T>
+        static inline int LSB( T nArg )
+        {
+            return details::BitOps< sizeof(T) >::LSB( (typename details::BitOps<sizeof(T)>::TUInt) nArg );
+        }
+
+        /// Get least significant bit (LSB) number (0..31/63)
+        /**
+            Precondition: nArg != 0
+        */
+        template <typename T>
+        static inline int LSBnz( T nArg )
+        {
+            assert( nArg != 0 );
+            return details::BitOps< sizeof(T) >::LSBnz( (typename details::BitOps<sizeof(T)>::TUInt) nArg );
+        }
+
+        /// Get most significant bit (MSB) number (1..32/64), 0 if nArg == 0
+        template <typename T>
+        static inline int MSB( T nArg )
+        {
+            return details::BitOps< sizeof(T) >::MSB( (typename details::BitOps<sizeof(T)>::TUInt) nArg );
+        }
+
+        /// Get most significant bit (MSB) number (0..31/63)
+        /**
+            Precondition: nArg != 0
+        */
+        template <typename T>
+        static inline int MSBnz( T nArg )
+        {
+            assert( nArg != 0 );
+            return details::BitOps< sizeof(T) >::MSBnz( (typename details::BitOps<sizeof(T)>::TUInt) nArg );
+        }
+
+        /// Get non-zero bit count of a word
+        template <typename T>
+        static inline int SBC( T nArg )
+        {
+            return details::BitOps< sizeof(T) >::SBC( (typename details::BitOps<sizeof(T)>::TUInt) nArg );
+        }
+
+        /// Get zero bit count of a word
+        template <typename T>
+        static inline int ZBC( T nArg )
+        {
+            return details::BitOps< sizeof(T) >::ZBC( (typename details::BitOps<sizeof(T)>::TUInt) nArg );
+        }
+
+        /// Reverse bit order of \p nArg
+        template <typename T>
+        static inline T RBO( T nArg )
+        {
+            return (T) details::BitOps< sizeof(T) >::RBO( (typename details::BitOps<sizeof(T)>::TUInt) nArg );
+        }
+
+        /// Complement bit \p nBit in \p nArg
+        template <typename T>
+        static inline bool complement( T& nArg, int nBit )
+        {
+            return details::BitOps< sizeof(T) >::complement( reinterpret_cast< typename details::BitOps<sizeof(T)>::TUInt& >( nArg ), nBit );
+        }
+
+        /// Simple random number generator
+        template <typename T>
+        static inline T RandXorShift( T x)
+        {
+            return (T) details::BitOps< sizeof(T) >::RandXorShift(x);
+        }
+
+    } // namespace bitop
+} //namespace cds
+
+#endif    // #ifndef __CDS_BITOP_H
+
diff --git a/cds/bitop.h b/cds/bitop.h
deleted file mode 100644 (file)
index 2ab7a5e..0000000
+++ /dev/null
@@ -1,140 +0,0 @@
-//$$CDS-header$$
-
-#ifndef __CDS_BITOP_H
-#define __CDS_BITOP_H
-
-/*
-    Different bit algorithms:
-        LSB        get least significant bit number
-        MSB        get most significant bit number
-        bswap    swap byte order of word
-        RBO        reverse bit order of word
-
-    Editions:
-        2007.10.08    Maxim.Khiszinsky    Created
-*/
-
-#include <cds/details/defs.h>
-#include <cds/compiler/bitop.h>
-
-namespace cds {
-    /// Bit operations
-    namespace bitop {
-
-        ///@cond none
-        namespace details {
-            template <int> struct BitOps;
-
-            // 32-bit bit ops
-            template <> struct BitOps<4> {
-                typedef atomic32u_t        TUInt;
-
-                static int      MSB( TUInt x )      { return bitop::platform::msb32( x );   }
-                static int      LSB( TUInt x )      { return bitop::platform::lsb32( x );   }
-                static int      MSBnz( TUInt x )    { return bitop::platform::msb32nz( x ); }
-                static int      LSBnz( TUInt x )    { return bitop::platform::lsb32nz( x ); }
-                static int      SBC( TUInt x )      { return bitop::platform::sbc32( x ) ;  }
-                static int      ZBC( TUInt x )      { return bitop::platform::zbc32( x ) ;  }
-
-                static TUInt    RBO( TUInt x )      { return bitop::platform::rbo32( x );   }
-                static bool     complement( TUInt& x, int nBit ) { return bitop::platform::complement32( &x, nBit ); }
-
-                static TUInt    RandXorShift(TUInt x) { return bitop::platform::RandXorShift32(x); }
-            };
-
-            // 64-bit bit ops
-            template <> struct BitOps<8> {
-                typedef atomic64u_unaligned        TUInt;
-
-                static int      MSB( TUInt x )        { return bitop::platform::msb64( x );     }
-                static int      LSB( TUInt x )        { return bitop::platform::lsb64( x );     }
-                static int      MSBnz( TUInt x )      { return bitop::platform::msb64nz( x );   }
-                static int      LSBnz( TUInt x )      { return bitop::platform::lsb64nz( x );   }
-                static  int     SBC( TUInt x )        { return bitop::platform::sbc64( x ) ;    }
-                static  int     ZBC( TUInt x )        { return bitop::platform::zbc64( x ) ;    }
-
-                static TUInt    RBO( TUInt x )        { return bitop::platform::rbo64( x );     }
-                static bool     complement( TUInt& x, int nBit ) { return bitop::platform::complement64( &x, nBit ); }
-
-                static TUInt    RandXorShift(TUInt x) { return bitop::platform::RandXorShift64(x); }
-            };
-        }    // namespace details
-        //@endcond
-
-
-        /// Get least significant bit (LSB) number (1..32/64), 0 if nArg == 0
-        template <typename T>
-        static inline int LSB( T nArg )
-        {
-            return details::BitOps< sizeof(T) >::LSB( (typename details::BitOps<sizeof(T)>::TUInt) nArg );
-        }
-
-        /// Get least significant bit (LSB) number (0..31/63)
-        /**
-            Precondition: nArg != 0
-        */
-        template <typename T>
-        static inline int LSBnz( T nArg )
-        {
-            assert( nArg != 0 );
-            return details::BitOps< sizeof(T) >::LSBnz( (typename details::BitOps<sizeof(T)>::TUInt) nArg );
-        }
-
-        /// Get most significant bit (MSB) number (1..32/64), 0 if nArg == 0
-        template <typename T>
-        static inline int MSB( T nArg )
-        {
-            return details::BitOps< sizeof(T) >::MSB( (typename details::BitOps<sizeof(T)>::TUInt) nArg );
-        }
-
-        /// Get most significant bit (MSB) number (0..31/63)
-        /**
-            Precondition: nArg != 0
-        */
-        template <typename T>
-        static inline int MSBnz( T nArg )
-        {
-            assert( nArg != 0 );
-            return details::BitOps< sizeof(T) >::MSBnz( (typename details::BitOps<sizeof(T)>::TUInt) nArg );
-        }
-
-        /// Get non-zero bit count of a word
-        template <typename T>
-        static inline int SBC( T nArg )
-        {
-            return details::BitOps< sizeof(T) >::SBC( (typename details::BitOps<sizeof(T)>::TUInt) nArg );
-        }
-
-        /// Get zero bit count of a word
-        template <typename T>
-        static inline int ZBC( T nArg )
-        {
-            return details::BitOps< sizeof(T) >::ZBC( (typename details::BitOps<sizeof(T)>::TUInt) nArg );
-        }
-
-        /// Reverse bit order of \p nArg
-        template <typename T>
-        static inline T RBO( T nArg )
-        {
-            return (T) details::BitOps< sizeof(T) >::RBO( (typename details::BitOps<sizeof(T)>::TUInt) nArg );
-        }
-
-        /// Complement bit \p nBit in \p nArg
-        template <typename T>
-        static inline bool complement( T& nArg, int nBit )
-        {
-            return details::BitOps< sizeof(T) >::complement( reinterpret_cast< typename details::BitOps<sizeof(T)>::TUInt& >( nArg ), nBit );
-        }
-
-        /// Simple random number generator
-        template <typename T>
-        static inline T RandXorShift( T x)
-        {
-            return (T) details::BitOps< sizeof(T) >::RandXorShift(x);
-        }
-
-    } // namespace bitop
-} //namespace cds
-
-#endif    // #ifndef __CDS_BITOP_H
-
index 5f0df6ee3b621d9e6b47c7e98feedda7eca2d557..d12f8532c25224fb7e9984558c08e4940a77890c 100644 (file)
@@ -3,7 +3,7 @@
 #ifndef __CDS_DETAILS_BIT_REVERSE_COUNTER_H
 #define __CDS_DETAILS_BIT_REVERSE_COUNTER_H
 
-#include <cds/bitop.h>
+#include <cds/algo/bitop.h>
 
 //@cond
 namespace cds { namespace bitop {
index 5e20a7b0adb5bfcc6ea6a52ed6a5f7a279e3d975..b4db2b8230500dbab560e95f2be8dd12e2686955 100644 (file)
@@ -3,7 +3,7 @@
 #ifndef __CDS_INT_ALGO_H
 #define __CDS_INT_ALGO_H
 
-#include <cds/bitop.h>
+#include <cds/algo/bitop.h>
 
 namespace cds { namespace beans {
 
index abd6169c7b1389e5f864a82bedb9bf4477830283..acc35c853c6ee10c96a6eebeb5565bc16b86e8ed 100644 (file)
@@ -6,7 +6,7 @@
 #include <cds/intrusive/base.h>
 #include <cds/opt/compare.h>
 #include <cds/opt/hash.h>
-#include <cds/bitop.h>
+#include <cds/algo/bitop.h>
 #include <cds/cxx11_atomic.h>
 #include <cds/ref.h>
 
index 9715c43a5dd1c49fa21b61500a76d868f328e97a..36af85e6cc924dc128c141392d1f7aa576b9d87f 100644 (file)
@@ -5,7 +5,7 @@
 
 #include <cds/intrusive/base.h>
 #include <cds/details/marked_ptr.h>
-#include <cds/bitop.h>
+#include <cds/algo/bitop.h>
 #include <cds/os/timer.h>
 #include <cds/urcu/options.h>
 
index 2b1b73a9d2d03962dd019a472949aaa61c30ba7b..a5365535229477add34ac022a2e2805549142a96 100644 (file)
@@ -7,7 +7,7 @@
 #include <cds/cxx11_atomic.h>
 #include <cds/details/allocator.h>
 #include <cds/int_algo.h>
-#include <cds/bitop.h>
+#include <cds/algo/bitop.h>
 #include <cds/details/functor_wrapper.h>
 
 namespace cds { namespace intrusive {
index 2c7c36048b9c2a8569cd21cbe08806bb782d84ae..90d9b8c995cdfe132e735cd741598ae21a82ccb2 100644 (file)
     <ClInclude Include="..\..\..\cds\urcu\signal_buffered.h" />\r
     <ClInclude Include="..\..\..\cds\urcu\signal_threaded.h" />\r
     <ClInclude Include="..\..\..\src\hzp_const.h" />\r
-    <ClInclude Include="..\..\..\cds\bitop.h" />\r
     <ClInclude Include="..\..\..\cds\init.h" />\r
     <ClInclude Include="..\..\..\cds\int_algo.h" />\r
     <ClInclude Include="..\..\..\cds\numtraits.h" />\r
index 7ac92ccffff47de96b0ddce2ba169315ba3aca75..9a573f084838a2f162c875d395a6708b836a286d 100644 (file)
     <ClInclude Include="..\..\..\src\hzp_const.h">\r
       <Filter>Source Files</Filter>\r
     </ClInclude>\r
-    <ClInclude Include="..\..\..\cds\bitop.h">\r
-      <Filter>Header Files\cds</Filter>\r
-    </ClInclude>\r
     <ClInclude Include="..\..\..\cds\init.h">\r
       <Filter>Header Files\cds</Filter>\r
     </ClInclude>\r
index 06921f14695b2d3606e643b51340c10c2f2b6aeb..1fc9b85cedcdf0aa93fc3bb47415862ba0fba03b 100644 (file)
@@ -20,7 +20,7 @@ static HINSTANCE            s_DllInstance = NULL;
 // For Windows below Windows 7
 
 #include <cds/os/topology.h>
-#include <cds/bitop.h>
+#include <cds/algo/bitop.h>
 
 static unsigned int     s_nProcessorCount = 1;
 static unsigned int     s_nProcessorGroupCount = 1;