Removed TSan annotations, tuned memory ordering
[libcds.git] / cds / details / allocator.h
index cbc634c08deb0f8ee5b73e091fafacce6a35546f..0b8b36f55688a8b08d9d6dd0b32179f9975b8518 100644 (file)
@@ -42,52 +42,20 @@ namespace cds {
             template <typename... S>
             value_type *  New( S const&... src )
             {
-#           if CDS_THREAD_SANITIZER_ENABLED
-                if ( c_bStdAllocator ) {
-                    CDS_TSAN_ANNOTATE_IGNORE_WRITES_BEGIN;
-                }
-                value_type * pv = Construct( allocator_type::allocate(1), src... );
-                if ( c_bStdAllocator ) {
-                    CDS_TSAN_ANNOTATE_IGNORE_WRITES_END;
-                }
-                return pv;
-#           else
                 return Construct( allocator_type::allocate(1), src... );
-#           endif
             }
 
             /// Analogue of <tt>operator new T( std::forward<Args>(args)... )</tt> (move semantics)
             template <typename... Args>
             value_type * MoveNew( Args&&... args )
             {
-#           if CDS_THREAD_SANITIZER_ENABLED
-                if ( c_bStdAllocator ) {
-                    CDS_TSAN_ANNOTATE_IGNORE_WRITES_BEGIN;
-                }
-                value_type * pv = MoveConstruct( allocator_type::allocate(1), std::forward<Args>(args)... );
-                if ( c_bStdAllocator ) {
-                    CDS_TSAN_ANNOTATE_IGNORE_WRITES_END;
-                }
-                return pv;
-#           else
                 return MoveConstruct( allocator_type::allocate(1), std::forward<Args>(args)... );
-#           endif
             }
 
             /// Analogue of operator new T[\p nCount ]
             value_type * NewArray( size_t nCount )
             {
-#           if CDS_THREAD_SANITIZER_ENABLED
-                if ( c_bStdAllocator ) {
-                    CDS_TSAN_ANNOTATE_IGNORE_WRITES_BEGIN;
-                }
-#           endif
                 value_type * p = allocator_type::allocate( nCount );
-#           if CDS_THREAD_SANITIZER_ENABLED
-                if ( c_bStdAllocator ) {
-                    CDS_TSAN_ANNOTATE_IGNORE_WRITES_END;
-                }
-#           endif
                 for ( size_t i = 0; i < nCount; ++i )
                     Construct( p + i );
                 return p;
@@ -100,17 +68,7 @@ namespace cds {
             template <typename S>
             value_type * NewArray( size_t nCount, S const& src )
             {
-#           if CDS_THREAD_SANITIZER_ENABLED
-                if ( c_bStdAllocator ) {
-                    CDS_TSAN_ANNOTATE_IGNORE_WRITES_BEGIN;
-                }
-#           endif
                 value_type * p = allocator_type::allocate( nCount );
-#           if CDS_THREAD_SANITIZER_ENABLED
-                if ( c_bStdAllocator ) {
-                    CDS_TSAN_ANNOTATE_IGNORE_WRITES_END;
-                }
-#           endif
                 for ( size_t i = 0; i < nCount; ++i )
                     Construct( p + i, src );
                 return p;
@@ -140,22 +98,16 @@ namespace cds {
             /// Analogue of operator delete
             void Delete( value_type * p )
             {
-                // TSan false positive possible
-                CDS_TSAN_ANNOTATE_IGNORE_WRITES_BEGIN;
                 allocator_type::destroy( p );
                 allocator_type::deallocate( p, 1 );
-                CDS_TSAN_ANNOTATE_IGNORE_WRITES_END;
             }
 
             /// Analogue of operator delete []
             void Delete( value_type * p, size_t nCount )
             {
-                // TSan false positive possible
-                CDS_TSAN_ANNOTATE_IGNORE_WRITES_BEGIN;
                  for ( size_t i = 0; i < nCount; ++i )
                      allocator_type::destroy( p + i );
                 allocator_type::deallocate( p, nCount );
-                CDS_TSAN_ANNOTATE_IGNORE_WRITES_END;
             }
 
 #       if CDS_COMPILER == CDS_COMPILER_INTEL
@@ -170,10 +122,7 @@ namespace cds {
             template <typename... S>
             value_type * Construct( void * p, S const&... src )
             {
-                // TSan false positive possible
-                CDS_TSAN_ANNOTATE_IGNORE_WRITES_BEGIN;
                 value_type * pv = new( p ) value_type( src... );
-                CDS_TSAN_ANNOTATE_IGNORE_WRITES_END;
                 return pv;
             }
 
@@ -181,10 +130,7 @@ namespace cds {
             template <typename... Args>
             value_type * MoveConstruct( void * p, Args&&... args )
             {
-                // TSan false positive possible
-                CDS_TSAN_ANNOTATE_IGNORE_WRITES_BEGIN;
                 value_type * pv = new( p ) value_type( std::forward<Args>(args)... );
-                CDS_TSAN_ANNOTATE_IGNORE_WRITES_END;
                 return pv;
             }
 
@@ -202,18 +148,7 @@ namespace cds {
 
                 size_t const nPtrSize = ( nByteSize + sizeof(void *) - 1 ) / sizeof(void *);
                 typedef typename allocator_type::template rebind< void * >::other void_allocator;
-#           if CDS_THREAD_SANITIZER_ENABLED
-                if ( c_bStdAllocator ) {
-                    CDS_TSAN_ANNOTATE_IGNORE_WRITES_BEGIN;
-                }
-#           endif
-                void * p = void_allocator().allocate( nPtrSize );
-#           if CDS_THREAD_SANITIZER_ENABLED
-                if ( c_bStdAllocator ) {
-                    CDS_TSAN_ANNOTATE_IGNORE_WRITES_END;
-                }
-#           endif
-                return p;
+                return void_allocator().allocate( nPtrSize );
             }
             //@endcond
         };