From: khizmax Date: Thu, 18 Sep 2014 15:33:46 +0000 (+0400) Subject: Move cds/bitop.h to cds/algo/bitop.h X-Git-Tag: v2.0.0~343 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=c9a406f8701070dc88ae03ed36a13c51f1aeb3af;p=libcds.git Move cds/bitop.h to cds/algo/bitop.h --- diff --git a/cds/algo/bitop.h b/cds/algo/bitop.h new file mode 100644 index 00000000..2ab7a5ef --- /dev/null +++ b/cds/algo/bitop.h @@ -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 +#include + +namespace cds { + /// Bit operations + namespace bitop { + + ///@cond none + namespace details { + template 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 + static inline int LSB( T nArg ) + { + return details::BitOps< sizeof(T) >::LSB( (typename details::BitOps::TUInt) nArg ); + } + + /// Get least significant bit (LSB) number (0..31/63) + /** + Precondition: nArg != 0 + */ + template + static inline int LSBnz( T nArg ) + { + assert( nArg != 0 ); + return details::BitOps< sizeof(T) >::LSBnz( (typename details::BitOps::TUInt) nArg ); + } + + /// Get most significant bit (MSB) number (1..32/64), 0 if nArg == 0 + template + static inline int MSB( T nArg ) + { + return details::BitOps< sizeof(T) >::MSB( (typename details::BitOps::TUInt) nArg ); + } + + /// Get most significant bit (MSB) number (0..31/63) + /** + Precondition: nArg != 0 + */ + template + static inline int MSBnz( T nArg ) + { + assert( nArg != 0 ); + return details::BitOps< sizeof(T) >::MSBnz( (typename details::BitOps::TUInt) nArg ); + } + + /// Get non-zero bit count of a word + template + static inline int SBC( T nArg ) + { + return details::BitOps< sizeof(T) >::SBC( (typename details::BitOps::TUInt) nArg ); + } + + /// Get zero bit count of a word + template + static inline int ZBC( T nArg ) + { + return details::BitOps< sizeof(T) >::ZBC( (typename details::BitOps::TUInt) nArg ); + } + + /// Reverse bit order of \p nArg + template + static inline T RBO( T nArg ) + { + return (T) details::BitOps< sizeof(T) >::RBO( (typename details::BitOps::TUInt) nArg ); + } + + /// Complement bit \p nBit in \p nArg + template + static inline bool complement( T& nArg, int nBit ) + { + return details::BitOps< sizeof(T) >::complement( reinterpret_cast< typename details::BitOps::TUInt& >( nArg ), nBit ); + } + + /// Simple random number generator + template + 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 index 2ab7a5ef..00000000 --- a/cds/bitop.h +++ /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 -#include - -namespace cds { - /// Bit operations - namespace bitop { - - ///@cond none - namespace details { - template 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 - static inline int LSB( T nArg ) - { - return details::BitOps< sizeof(T) >::LSB( (typename details::BitOps::TUInt) nArg ); - } - - /// Get least significant bit (LSB) number (0..31/63) - /** - Precondition: nArg != 0 - */ - template - static inline int LSBnz( T nArg ) - { - assert( nArg != 0 ); - return details::BitOps< sizeof(T) >::LSBnz( (typename details::BitOps::TUInt) nArg ); - } - - /// Get most significant bit (MSB) number (1..32/64), 0 if nArg == 0 - template - static inline int MSB( T nArg ) - { - return details::BitOps< sizeof(T) >::MSB( (typename details::BitOps::TUInt) nArg ); - } - - /// Get most significant bit (MSB) number (0..31/63) - /** - Precondition: nArg != 0 - */ - template - static inline int MSBnz( T nArg ) - { - assert( nArg != 0 ); - return details::BitOps< sizeof(T) >::MSBnz( (typename details::BitOps::TUInt) nArg ); - } - - /// Get non-zero bit count of a word - template - static inline int SBC( T nArg ) - { - return details::BitOps< sizeof(T) >::SBC( (typename details::BitOps::TUInt) nArg ); - } - - /// Get zero bit count of a word - template - static inline int ZBC( T nArg ) - { - return details::BitOps< sizeof(T) >::ZBC( (typename details::BitOps::TUInt) nArg ); - } - - /// Reverse bit order of \p nArg - template - static inline T RBO( T nArg ) - { - return (T) details::BitOps< sizeof(T) >::RBO( (typename details::BitOps::TUInt) nArg ); - } - - /// Complement bit \p nBit in \p nArg - template - static inline bool complement( T& nArg, int nBit ) - { - return details::BitOps< sizeof(T) >::complement( reinterpret_cast< typename details::BitOps::TUInt& >( nArg ), nBit ); - } - - /// Simple random number generator - template - 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/details/bit_reverse_counter.h b/cds/details/bit_reverse_counter.h index 5f0df6ee..d12f8532 100644 --- a/cds/details/bit_reverse_counter.h +++ b/cds/details/bit_reverse_counter.h @@ -3,7 +3,7 @@ #ifndef __CDS_DETAILS_BIT_REVERSE_COUNTER_H #define __CDS_DETAILS_BIT_REVERSE_COUNTER_H -#include +#include //@cond namespace cds { namespace bitop { diff --git a/cds/int_algo.h b/cds/int_algo.h index 5e20a7b0..b4db2b82 100644 --- a/cds/int_algo.h +++ b/cds/int_algo.h @@ -3,7 +3,7 @@ #ifndef __CDS_INT_ALGO_H #define __CDS_INT_ALGO_H -#include +#include namespace cds { namespace beans { diff --git a/cds/intrusive/michael_set_base.h b/cds/intrusive/michael_set_base.h index abd6169c..acc35c85 100644 --- a/cds/intrusive/michael_set_base.h +++ b/cds/intrusive/michael_set_base.h @@ -6,7 +6,7 @@ #include #include #include -#include +#include #include #include diff --git a/cds/intrusive/skip_list_base.h b/cds/intrusive/skip_list_base.h index 9715c43a..36af85e6 100644 --- a/cds/intrusive/skip_list_base.h +++ b/cds/intrusive/skip_list_base.h @@ -5,7 +5,7 @@ #include #include -#include +#include #include #include diff --git a/cds/intrusive/split_list_base.h b/cds/intrusive/split_list_base.h index 2b1b73a9..a5365535 100644 --- a/cds/intrusive/split_list_base.h +++ b/cds/intrusive/split_list_base.h @@ -7,7 +7,7 @@ #include #include #include -#include +#include #include namespace cds { namespace intrusive { diff --git a/projects/Win/vc12/cds.vcxproj b/projects/Win/vc12/cds.vcxproj index 2c7c3604..90d9b8c9 100644 --- a/projects/Win/vc12/cds.vcxproj +++ b/projects/Win/vc12/cds.vcxproj @@ -809,7 +809,6 @@ - diff --git a/projects/Win/vc12/cds.vcxproj.filters b/projects/Win/vc12/cds.vcxproj.filters index 7ac92ccf..9a573f08 100644 --- a/projects/Win/vc12/cds.vcxproj.filters +++ b/projects/Win/vc12/cds.vcxproj.filters @@ -194,9 +194,6 @@ Source Files - - Header Files\cds - Header Files\cds diff --git a/src/dllmain.cpp b/src/dllmain.cpp index 06921f14..1fc9b85c 100644 --- a/src/dllmain.cpp +++ b/src/dllmain.cpp @@ -20,7 +20,7 @@ static HINSTANCE s_DllInstance = NULL; // For Windows below Windows 7 #include -#include +#include static unsigned int s_nProcessorCount = 1; static unsigned int s_nProcessorGroupCount = 1;