From 4092c2b0cee6546c8d2fee891e9a6b618e051bd7 Mon Sep 17 00:00:00 2001 From: khizmax Date: Sat, 1 Aug 2015 18:07:56 +0300 Subject: [PATCH] Replaced deprecated atomic64_xxx types with int64_t, uint64_t --- cds/algo/bitop.h | 2 +- cds/compiler/gcc/amd64/bitop.h | 17 ++++++++--------- cds/compiler/gcc/ia64/bitop.h | 6 +++--- cds/compiler/gcc/sparc/bitop.h | 6 +++--- cds/compiler/vc/amd64/bitop.h | 10 +++++----- cds/compiler/vc/x86/bitop.h | 2 +- cds/details/bitop_generic.h | 28 ++++++++++++++-------------- cds/details/defs.h | 23 ----------------------- cds/intrusive/michael_list_rcu.h | 2 +- cds/memory/michael/allocator.h | 8 ++++---- cds/memory/michael/bound_check.h | 2 +- cds/memory/michael/osalloc_stat.h | 8 ++++---- cds/memory/michael/procheap_stat.h | 8 ++++---- cds/opt/options.h | 3 ++- tests/test-hdr/misc/bitop_st.cpp | 2 +- 15 files changed, 52 insertions(+), 75 deletions(-) diff --git a/cds/algo/bitop.h b/cds/algo/bitop.h index 4f9803b4..a8ebb340 100644 --- a/cds/algo/bitop.h +++ b/cds/algo/bitop.h @@ -44,7 +44,7 @@ namespace cds { // 64-bit bit ops template <> struct BitOps<8> { - typedef atomic64u_unaligned TUInt; + typedef uint64_t TUInt; static int MSB( TUInt x ) { return bitop::platform::msb64( x ); } static int LSB( TUInt x ) { return bitop::platform::lsb64( x ); } diff --git a/cds/compiler/gcc/amd64/bitop.h b/cds/compiler/gcc/amd64/bitop.h index 6c2f3037..912bf80e 100644 --- a/cds/compiler/gcc/amd64/bitop.h +++ b/cds/compiler/gcc/amd64/bitop.h @@ -77,9 +77,9 @@ namespace cds { } # define cds_bitop_msb64_DEFINED - static inline int msb64( atomic64u_unaligned nArg ) + static inline int msb64( uint64_t nArg ) { - atomic64u_unaligned nRet; + uint64_t nRet; asm volatile ( "bsrq %[nArg], %[nRet] ;\n\t" "jnz 1f ;\n\t" @@ -95,10 +95,10 @@ namespace cds { } # define cds_bitop_msb64nz_DEFINED - static inline int msb64nz( atomic64u_unaligned nArg ) + static inline int msb64nz( uint64_t nArg ) { assert( nArg != 0 ); - atomic64u_unaligned nRet; + uint64_t nRet; __asm__ __volatile__ ( "bsrq %[nArg], %[nRet] ;" : [nRet] "=a" (nRet) @@ -110,10 +110,9 @@ namespace cds { // LSB - return index (0..31) of least significant bit in nArg. If nArg == 0 return -1U # define cds_bitop_lsb64_DEFINED - static inline int lsb64( atomic64u_unaligned nArg ) + static inline int lsb64( uint64_t nArg ) { - - atomic64u_unaligned nRet; + uint64_t nRet; __asm__ __volatile__ ( "bsfq %[nArg], %[nRet] ;" "jnz 1f ;" @@ -132,10 +131,10 @@ namespace cds { // LSB - return index (0..31) of least significant bit in nArg. // Condition: nArg != 0 # define cds_bitop_lsb64nz_DEFINED - static inline int lsb64nz( atomic64u_unaligned nArg ) + static inline int lsb64nz( uint64_t nArg ) { assert( nArg != 0 ); - atomic64u_unaligned nRet; + uint64_t nRet; __asm__ __volatile__ ( "bsfq %[nArg], %[nRet] ;" : [nRet] "=a" (nRet) diff --git a/cds/compiler/gcc/ia64/bitop.h b/cds/compiler/gcc/ia64/bitop.h index ef684608..2eec2031 100644 --- a/cds/compiler/gcc/ia64/bitop.h +++ b/cds/compiler/gcc/ia64/bitop.h @@ -13,14 +13,14 @@ namespace cds { { if ( !nArg ) return 0; - atomic64u_t x = nArg; + uint64_t x = nArg; x |= x >> 1; x |= x >> 2; x |= x >> 4; x |= x >> 8; x |= x >> 16; - atomic64u_t nRes; + uint64_t nRes; asm __volatile__( "popcnt %0=%1\n\t" : "=r" (nRes) : "r" (x) ); return (int) nRes; } @@ -42,7 +42,7 @@ namespace cds { // MSB - return index (0..63) of most significant bit in nArg. // !!! nArg != 0 # define cds_bitop_msb64nz_DEFINED - static inline int msb64nz( atomic64u_t nArg ) + static inline int msb64nz( uint64_t nArg ) { assert( nArg != 0 ); long double d = nArg; diff --git a/cds/compiler/gcc/sparc/bitop.h b/cds/compiler/gcc/sparc/bitop.h index 99ee9fba..12ea15f4 100644 --- a/cds/compiler/gcc/sparc/bitop.h +++ b/cds/compiler/gcc/sparc/bitop.h @@ -11,9 +11,9 @@ namespace cds { // Source: UltraSPARC Architecture 2007 // // Test result: this variant and its variation about 100 times slower then generic implementation :-( - static inline int sparc_msb64( atomic64u_t nArg ) + static inline int sparc_msb64( uint64_t nArg ) { - atomic64u_t result; + uint64_t result; asm volatile ( "neg %[nArg], %[result] \n\t" "xnor %[nArg], %[result], %%g5 \n\t" @@ -29,7 +29,7 @@ namespace cds { // MSB - return index (1..32) of most significant bit in nArg. If nArg == 0 return 0 static inline int sparc_msb32( uint32_t nArg ) { - return sparc_msb64( (atomic64u_t) nArg ); + return sparc_msb64( (uint64_t) nArg ); } }} // namespace gcc::Sparc diff --git a/cds/compiler/vc/amd64/bitop.h b/cds/compiler/vc/amd64/bitop.h index c870bf1a..5c678cf4 100644 --- a/cds/compiler/vc/amd64/bitop.h +++ b/cds/compiler/vc/amd64/bitop.h @@ -68,7 +68,7 @@ namespace cds { # define cds_bitop_msb64_DEFINED - static inline int msb64( atomic64u_unaligned nArg ) + static inline int msb64( uint64_t nArg ) { unsigned long nIndex; if ( _BitScanReverse64( &nIndex, nArg )) @@ -77,7 +77,7 @@ namespace cds { } # define cds_bitop_msb64nz_DEFINED - static inline int msb64nz( atomic64u_unaligned nArg ) + static inline int msb64nz( uint64_t nArg ) { assert( nArg != 0 ); unsigned long nIndex; @@ -86,7 +86,7 @@ namespace cds { } # define cds_bitop_lsb64_DEFINED - static inline int lsb64( atomic64u_unaligned nArg ) + static inline int lsb64( uint64_t nArg ) { unsigned long nIndex; if ( _BitScanForward64( &nIndex, nArg )) @@ -95,7 +95,7 @@ namespace cds { } # define cds_bitop_lsb64nz_DEFINED - static inline int lsb64nz( atomic64u_unaligned nArg ) + static inline int lsb64nz( uint64_t nArg ) { assert( nArg != 0 ); unsigned long nIndex; @@ -110,7 +110,7 @@ namespace cds { } # define cds_bitop_complement64_DEFINED - static inline bool complement64( atomic64u_t * pArg, unsigned int nBit ) + static inline bool complement64( uint64_t * pArg, unsigned int nBit ) { return _bittestandcomplement64( reinterpret_cast<__int64 *>( pArg ), nBit ) != 0; } diff --git a/cds/compiler/vc/x86/bitop.h b/cds/compiler/vc/x86/bitop.h index 16ddf764..89fdd4f6 100644 --- a/cds/compiler/vc/x86/bitop.h +++ b/cds/compiler/vc/x86/bitop.h @@ -65,7 +65,7 @@ namespace cds { } # define cds_bitop_complement64_DEFINED - static inline bool complement64( atomic64u_t * pArg, unsigned int nBit ) + static inline bool complement64( uint64_t * pArg, unsigned int nBit ) { if ( nBit < 32 ) return _bittestandcomplement( reinterpret_cast( pArg ), nBit ) != 0; diff --git a/cds/details/bitop_generic.h b/cds/details/bitop_generic.h index 6859847a..ed90be6b 100644 --- a/cds/details/bitop_generic.h +++ b/cds/details/bitop_generic.h @@ -15,7 +15,7 @@ namespace cds { #endif #ifndef cds_bitop_isPow2_64_DEFINED - static inline bool isPow2_64( atomic64_unaligned x ) + static inline bool isPow2_64( uint64_t x ) { return (x & ( x - 1 )) == 0 && x; } @@ -67,7 +67,7 @@ namespace cds { #endif #ifndef cds_bitop_msb64_DEFINED - static inline int msb64( atomic64u_unaligned x ) + static inline int msb64( uint64_t x ) { uint32_t h = (uint32_t) (x >> 32); if ( h ) @@ -77,7 +77,7 @@ namespace cds { #endif #ifndef cds_bitop_msb64nz_DEFINED - static inline int msb64nz( atomic64u_unaligned x ) + static inline int msb64nz( uint64_t x ) { return msb64( x ) - 1; } @@ -129,7 +129,7 @@ namespace cds { #endif #ifndef cds_bitop_lsb64_DEFINED - static inline int lsb64( atomic64u_unaligned x ) + static inline int lsb64( uint64_t x ) { if ( !x ) return 0; @@ -140,7 +140,7 @@ namespace cds { #endif #ifndef cds_bitop_lsb64nz_DEFINED - static inline int lsb64nz( atomic64u_unaligned x ) + static inline int lsb64nz( uint64_t x ) { return lsb64( x ) - 1; } @@ -166,10 +166,10 @@ namespace cds { #endif #ifndef cds_bitop_rbo64_DEFINED - static inline atomic64u_t rbo64( atomic64u_unaligned x ) + static inline uint64_t rbo64( uint64_t x ) { // Low 32bit Hight 32bit - return ( ((atomic64u_t) rbo32( (uint32_t) x )) << 32 ) | ((atomic64u_t) rbo32( (uint32_t) (x >> 32) )); + return ( static_cast(rbo32( (uint32_t) x )) << 32 ) | ( static_cast( rbo32( (uint32_t) (x >> 32) ))); } #endif @@ -191,7 +191,7 @@ namespace cds { #endif #ifndef cds_bitop_sbc64_DEFINED - static inline int sbc64( atomic64u_unaligned x ) + static inline int sbc64( uint64_t x ) { # ifdef cds_beans_zbc64_DEFINED return 64 - zbc64( x ); @@ -212,7 +212,7 @@ namespace cds { #endif #ifndef cds_bitop_zbc64_DEFINED - static inline int zbc64( atomic64u_unaligned x ) + static inline int zbc64( uint64_t x ) { return 64 - sbc64( x ); } @@ -230,11 +230,11 @@ namespace cds { #endif #ifndef cds_bitop_complement64_DEFINED - static inline bool complement64( atomic64u_t * pArg, unsigned int nBit ) + static inline bool complement64( uint64_t * pArg, unsigned int nBit ) { assert( pArg ); - atomic64u_t nVal = *pArg & (atomic64u_t(1) << nBit); - *pArg ^= atomic64u_t(1) << nBit; + uint64_t nVal = *pArg & (uint64_t(1) << nBit); + *pArg ^= uint64_t(1) << nBit; return nVal != 0; } #endif @@ -257,8 +257,8 @@ namespace cds { static inline uint64_t RandXorShift64(uint64_t x) { - //static atomic64u_t xRandom = 88172645463325252LL; - //atomic64u_t x = xRandom; + //static uint64_t xRandom = 88172645463325252LL; + //uint64_t x = xRandom; if ( !x ) x = 88172645463325252LL; x ^= x << 13; diff --git a/cds/details/defs.h b/cds/details/defs.h index a7769cb3..4f593330 100644 --- a/cds/details/defs.h +++ b/cds/details/defs.h @@ -346,29 +346,6 @@ namespace cds {} # define CDS_CXX11_INLINE_NAMESPACE #endif -//@cond -// typedefs for back compatibility -namespace cds { - /// 64bit unaligned int - typedef int64_t atomic64_unaligned; - - /// 64bit unaligned unsigned int - typedef uint64_t atomic64u_unaligned; - - /// 64bit aligned int - typedef atomic64_unaligned CDS_TYPE_ALIGNMENT(8) atomic64_aligned; - - /// 64bit aligned unsigned int - typedef atomic64u_unaligned CDS_TYPE_ALIGNMENT(8) atomic64u_aligned; - - /// 64bit atomic int (aligned) - typedef atomic64_aligned atomic64_t; - - /// 64bit atomic unsigned int (aligned) - typedef atomic64u_aligned atomic64u_t; -} // namespace cds -//@endcond - /************************************************************************* Common things **************************************************************************/ diff --git a/cds/intrusive/michael_list_rcu.h b/cds/intrusive/michael_list_rcu.h index 8b4adbf3..b8e61530 100644 --- a/cds/intrusive/michael_list_rcu.h +++ b/cds/intrusive/michael_list_rcu.h @@ -682,7 +682,7 @@ namespace cds { namespace intrusive { /// Finds \p key using \p pred predicate for searching /** - The function is an analog of \ref cds_intrusive_MichaelList_rcu_find_func "find(Q&, Func)" + The function is an analog of \p find(Q&, Func) but \p pred is used for key comparing. \p Less functor has the interface like \p std::less. \p pred must imply the same element order as the comparator used for building the list. diff --git a/cds/memory/michael/allocator.h b/cds/memory/michael/allocator.h index 02711395..9ef279b0 100644 --- a/cds/memory/michael/allocator.h +++ b/cds/memory/michael/allocator.h @@ -430,13 +430,13 @@ namespace michael { size_t nPageDeallocCount ; ///< Count of page (superblock) deallocated size_t nDescAllocCount ; ///< Count of superblock descriptors size_t nDescFull ; ///< Count of full superblock - atomic64u_t nBytesAllocated ; ///< Count of allocated bytes (for heap managed memory blocks) - atomic64u_t nBytesDeallocated ; ///< Count of deallocated bytes (for heap managed memory blocks) + uint64_t nBytesAllocated ; ///< Count of allocated bytes (for heap managed memory blocks) + uint64_t nBytesDeallocated ; ///< Count of deallocated bytes (for heap managed memory blocks) size_t nSysAllocCount ; ///< Count of \p alloc and \p alloc_aligned function call (for large memory blocks that allocated directly from OS) size_t nSysFreeCount ; ///< Count of \p free and \p free_aligned function call (for large memory blocks that allocated directly from OS) - atomic64u_t nSysBytesAllocated ; ///< Count of allocated bytes (for large memory blocks that allocated directly from OS) - atomic64_t nSysBytesDeallocated; ///< Count of deallocated bytes (for large memory blocks that allocated directly from OS) + uint64_t nSysBytesAllocated ; ///< Count of allocated bytes (for large memory blocks that allocated directly from OS) + int64_t nSysBytesDeallocated; ///< Count of deallocated bytes (for large memory blocks that allocated directly from OS) // Internal contention indicators /// CAS failure counter for updating active field of active block of \p alloc_from_active Heap internal function diff --git a/cds/memory/michael/bound_check.h b/cds/memory/michael/bound_check.h index 21752d24..7b9ba973 100644 --- a/cds/memory/michael/bound_check.h +++ b/cds/memory/michael/bound_check.h @@ -14,7 +14,7 @@ namespace cds { namespace memory { namespace michael { class bound_checker { protected: - typedef atomic64u_t trailer_type; + typedef uint64_t trailer_type; static const trailer_type s_BoundCheckerTrailer = 0xbadcafeedeadc0feULL; public: diff --git a/cds/memory/michael/osalloc_stat.h b/cds/memory/michael/osalloc_stat.h index 0ceae287..0477f7d7 100644 --- a/cds/memory/michael/osalloc_stat.h +++ b/cds/memory/michael/osalloc_stat.h @@ -51,13 +51,13 @@ namespace cds { namespace memory { namespace michael { } /// Returns current value of nBytesAllocated counter - atomic64u_t allocatedBytes() const + uint64_t allocatedBytes() const { return nBytesAllocated.load(atomics::memory_order_relaxed); } /// Returns current value of nBytesAllocated counter - atomic64u_t deallocatedBytes() const + uint64_t deallocatedBytes() const { return nBytesDeallocated.load(atomics::memory_order_relaxed); } @@ -92,13 +92,13 @@ namespace cds { namespace memory { namespace michael { } /// Returns current value of nBytesAllocated counter - atomic64u_t allocatedBytes() const + uint64_t allocatedBytes() const { return 0; } /// Returns current value of nBytesAllocated counter - atomic64u_t deallocatedBytes() const + uint64_t deallocatedBytes() const { return 0; } diff --git a/cds/memory/michael/procheap_stat.h b/cds/memory/michael/procheap_stat.h index e7b0e7b5..d8b81485 100644 --- a/cds/memory/michael/procheap_stat.h +++ b/cds/memory/michael/procheap_stat.h @@ -247,7 +247,7 @@ namespace cds { namespace memory { namespace michael { To get count of bytes allocated but not yet deallocated you should call \code allocatedBytes() - deallocatedBytes() \endcode */ - atomic64u_t allocatedBytes() const + uint64_t allocatedBytes() const { return nBytesAllocated.load(atomics::memory_order_relaxed); } @@ -258,7 +258,7 @@ namespace cds { namespace memory { namespace michael { See \ref allocatedBytes notes */ - atomic64u_t deallocatedBytes() const + uint64_t deallocatedBytes() const { return nBytesDeallocated.load(atomics::memory_order_relaxed); } @@ -370,9 +370,9 @@ namespace cds { namespace memory { namespace michael { { return 0; } size_t descFull() const { return 0; } - atomic64u_t allocatedBytes() const + uint64_t allocatedBytes() const { return 0; } - atomic64u_t deallocatedBytes() const + uint64_t deallocatedBytes() const { return 0; } size_t activeDescCASFailureCount() const { return 0; } diff --git a/cds/opt/options.h b/cds/opt/options.h index 11e01a0a..2e52fa71 100644 --- a/cds/opt/options.h +++ b/cds/opt/options.h @@ -10,11 +10,12 @@ 2011.01.23 khizmax Created */ +#include // rand, srand + #include #include #include #include -#include // rand, srand namespace cds { diff --git a/tests/test-hdr/misc/bitop_st.cpp b/tests/test-hdr/misc/bitop_st.cpp index e224b627..81e543be 100644 --- a/tests/test-hdr/misc/bitop_st.cpp +++ b/tests/test-hdr/misc/bitop_st.cpp @@ -32,7 +32,7 @@ protected: void bitop64() { - cds::atomic64u_t n; + uint64_t n; n = 0; CPPUNIT_ASSERT_EX( cds::bitop::MSB(n) == 0, "n=" << n ); CPPUNIT_ASSERT_EX( cds::bitop::LSB(n) == 0, "n=" << n ); -- 2.34.1