This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug libstdc++/51798] [4.7 regression] libstdc++ atomicity performance regression due to __sync_fetch_and_add


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51798

--- Comment #27 from Jonathan Wakely <redi at gcc dot gnu.org> 2012-02-09 09:16:11 UTC ---
Nice.  Now that we have an atomic load we can also do:

--- a/libstdc++-v3/include/bits/shared_ptr_base.h
+++ b/libstdc++-v3/include/bits/shared_ptr_base.h
@@ -193,7 +193,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       {
         // No memory barrier is used here so there is no synchronization
         // with other threads.
-        return const_cast<const volatile _Atomic_word&>(_M_use_count);
+        return __atomic_load_n(&_M_use_count, __ATOMIC_RELAXED);
       }

     private:


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]