This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ 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]

Re: debug abi breaking change patch


Here is the patch I finally applied. Indeed, keeping _M_get_mutex made is lighter.

2012-02-13 François Dumont <fdumont@gcc.gnu.org>

        * include/debug/safe_base.h
        (_Safe_iterator_base::_M_get_mutex): Remove.
        (_Safe_sequence_base::_M_mutex): Add, use it...
        (_Safe_sequence_base::_M_get_mutex): ...here.
        * src/c++11/debug.cc:
        (anonymous::get_safe_base_mutex): Remove.

I have also introduced the ChangeLog.libstdcxx_so_7-2-branch file to track changes in this branch.

François

On 02/09/2012 10:39 PM, Jonathan Wakely wrote:
On 9 February 2012 21:36, François Dumont wrote:
About keeping _M_get_mutex, I can implement it inline or do you think that I
should keep in the debug.cc ? I guess gcc should be able to inline it where
ever it relies, no ?
I think I would make it inline.


Index: src/c++11/debug.cc
===================================================================
--- src/c++11/debug.cc	(revision 184171)
+++ src/c++11/debug.cc	(working copy)
@@ -28,30 +28,16 @@
 #include <debug/safe_unordered_container.h>
 #include <debug/safe_iterator.h>
 #include <debug/safe_local_iterator.h>
-#include <algorithm>
 #include <cassert>
 #include <cstring>
 #include <cctype>
 #include <cstdio>
 #include <cstdlib>
-#include <functional>
 
 using namespace std;
 
 namespace
 {
-  /** Returns different instances of __mutex depending on the passed address
-   *  in order to limit contention without breaking current library binary
-   *  compatibility. */
-  __gnu_cxx::__mutex&
-  get_safe_base_mutex(void* __address)
-  {
-    const size_t mask = 0xf;
-    static __gnu_cxx::__mutex safe_base_mutex[mask + 1];
-    const size_t index = _Hash_impl::hash(__address) & mask;
-    return safe_base_mutex[index];
-  }
-
   void
   swap_its(__gnu_debug::_Safe_sequence_base& __lhs,
 	   __gnu_debug::_Safe_iterator_base*& __lhs_its,
@@ -251,11 +237,6 @@
       }
   }
 
-  __gnu_cxx::__mutex&
-  _Safe_sequence_base::
-  _M_get_mutex() throw ()
-  { return get_safe_base_mutex(this); }
-
   void
   _Safe_sequence_base::
   _M_attach(_Safe_iterator_base* __it, bool __constant)
@@ -370,11 +351,6 @@
 	    && !__x._M_singular() && _M_sequence == __x._M_sequence);
   }
 
-  __gnu_cxx::__mutex&
-  _Safe_iterator_base::
-  _M_get_mutex() throw ()
-  { return get_safe_base_mutex(_M_sequence); }
-
   _Safe_unordered_container_base*
   _Safe_local_iterator_base::
   _M_get_container() const _GLIBCXX_NOEXCEPT
Index: include/debug/safe_base.h
===================================================================
--- include/debug/safe_base.h	(revision 184171)
+++ include/debug/safe_base.h	(working copy)
@@ -104,9 +104,6 @@
 
     ~_Safe_iterator_base() { this->_M_detach(); }
 
-    /** For use in _Safe_iterator. */
-    __gnu_cxx::__mutex& _M_get_mutex() throw ();
-
   public:
     /** Attaches this iterator to the given sequence, detaching it
      *	from whatever sequence it was attached to originally. If the
@@ -187,6 +184,9 @@
     /// The container version number. This number may never be 0.
     mutable unsigned int _M_version;
 
+    /** For use in _Safe_sequence. */
+    __gnu_cxx::__mutex _M_mutex;
+
   protected:
     // Initialize with a version number of 1 and no iterators
     _Safe_sequence_base()
@@ -226,7 +226,8 @@
     _M_swap(_Safe_sequence_base& __x);
 
     /** For use in _Safe_sequence. */
-    __gnu_cxx::__mutex& _M_get_mutex() throw ();
+    __gnu_cxx::__mutex& _M_get_mutex() throw ()
+    { return _M_mutex; }
 
   public:
     /** Invalidates all iterators. */

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