public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* Avoid _Rb_tree_rotate_[left,right] symbols export
@ 2017-05-11 20:31 François Dumont
  2017-05-12 11:06 ` Jonathan Wakely
  0 siblings, 1 reply; 5+ messages in thread
From: François Dumont @ 2017-05-11 20:31 UTC (permalink / raw)
  To: libstdc++, gcc-patches

[-- Attachment #1: Type: text/plain, Size: 649 bytes --]

Hi

     When versioned namespace is active we can avoid export of 
_Rb_tree_rotate_[left,right] symbols. I also took the opportunity to put 
static functions in the anonymous namespace rather than using static. Is 
this usage of static still planned to be deprecated ?

     * src/c++98/tree.cc [_GLIBCXX_INLINE_VERSION]
     (_Rb_tree_rotate_left, _Rb_tree_rotate_right): Remove.
     * src/c++98/tree.cc (local_Rb_tree_increment, local_Rb_tree_decrement):
     Move to anonymous namespace.
     (local_Rb_tree_rotate_left, local_Rb_tree_rotate_right): Likewise.

Tested under Linux x86_64 with versioned namespace.

Ok to commit ?

François



[-- Attachment #2: tree.cc.patch --]
[-- Type: text/x-patch, Size: 5269 bytes --]

diff --git a/libstdc++-v3/src/c++98/tree.cc b/libstdc++-v3/src/c++98/tree.cc
index 50fa7cf..89ea108 100644
--- a/libstdc++-v3/src/c++98/tree.cc
+++ b/libstdc++-v3/src/c++98/tree.cc
@@ -52,12 +52,10 @@
 
 #include <bits/stl_tree.h>
 
-namespace std _GLIBCXX_VISIBILITY(default)
+namespace
 {
-_GLIBCXX_BEGIN_NAMESPACE_VERSION
-
-  static _Rb_tree_node_base*
-  local_Rb_tree_increment(_Rb_tree_node_base* __x) throw ()
+  std::_Rb_tree_node_base*
+  local_Rb_tree_increment(std::_Rb_tree_node_base* __x) throw ()
   {
     if (__x->_M_right != 0)
       {
@@ -67,7 +65,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       }
     else
       {
-        _Rb_tree_node_base* __y = __x->_M_parent;
+	std::_Rb_tree_node_base* __y = __x->_M_parent;
         while (__x == __y->_M_right)
           {
             __x = __y;
@@ -79,34 +77,22 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     return __x;
   }
 
-  _Rb_tree_node_base*
-  _Rb_tree_increment(_Rb_tree_node_base* __x) throw ()
+  std::_Rb_tree_node_base*
+  local_Rb_tree_decrement(std::_Rb_tree_node_base* __x) throw ()
   {
-    return local_Rb_tree_increment(__x);
-  }
-
-  const _Rb_tree_node_base*
-  _Rb_tree_increment(const _Rb_tree_node_base* __x) throw ()
-  {
-    return local_Rb_tree_increment(const_cast<_Rb_tree_node_base*>(__x));
-  }
-
-  static _Rb_tree_node_base*
-  local_Rb_tree_decrement(_Rb_tree_node_base* __x) throw ()
-  {
-    if (__x->_M_color == _S_red
+    if (__x->_M_color == std::_S_red
         && __x->_M_parent->_M_parent == __x)
       __x = __x->_M_right;
     else if (__x->_M_left != 0)
       {
-        _Rb_tree_node_base* __y = __x->_M_left;
+	std::_Rb_tree_node_base* __y = __x->_M_left;
         while (__y->_M_right != 0)
           __y = __y->_M_right;
         __x = __y;
       }
     else
       {
-        _Rb_tree_node_base* __y = __x->_M_parent;
+	std::_Rb_tree_node_base* __y = __x->_M_parent;
         while (__x == __y->_M_left)
           {
             __x = __y;
@@ -117,23 +103,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     return __x;
   }
 
-  _Rb_tree_node_base*
-  _Rb_tree_decrement(_Rb_tree_node_base* __x) throw ()
-  {
-    return local_Rb_tree_decrement(__x);
-  }
-
-  const _Rb_tree_node_base*
-  _Rb_tree_decrement(const _Rb_tree_node_base* __x) throw ()
-  {
-    return local_Rb_tree_decrement(const_cast<_Rb_tree_node_base*>(__x));
-  }
-
-  static void
-  local_Rb_tree_rotate_left(_Rb_tree_node_base* const __x,
-		             _Rb_tree_node_base*& __root)
+  void
+  local_Rb_tree_rotate_left(std::_Rb_tree_node_base* const __x,
+			    std::_Rb_tree_node_base*& __root)
   {
-    _Rb_tree_node_base* const __y = __x->_M_right;
+    std::_Rb_tree_node_base* const __y = __x->_M_right;
 
     __x->_M_right = __y->_M_left;
     if (__y->_M_left !=0)
@@ -150,21 +124,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     __x->_M_parent = __y;
   }
 
-  /* Static keyword was missing on _Rb_tree_rotate_left.
-     Export the symbol for backward compatibility until
-     next ABI change.  */
   void
-  _Rb_tree_rotate_left(_Rb_tree_node_base* const __x,
-		       _Rb_tree_node_base*& __root)
+  local_Rb_tree_rotate_right(std::_Rb_tree_node_base* const __x,
+			     std::_Rb_tree_node_base*& __root)
   {
-    local_Rb_tree_rotate_left (__x, __root);
-  }
-
-  static void
-  local_Rb_tree_rotate_right(_Rb_tree_node_base* const __x,
-			     _Rb_tree_node_base*& __root)
-  {
-    _Rb_tree_node_base* const __y = __x->_M_left;
+    std::_Rb_tree_node_base* const __y = __x->_M_left;
 
     __x->_M_left = __y->_M_right;
     if (__y->_M_right != 0)
@@ -180,6 +144,46 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     __y->_M_right = __x;
     __x->_M_parent = __y;
   }
+}
+
+namespace std _GLIBCXX_VISIBILITY(default)
+{
+_GLIBCXX_BEGIN_NAMESPACE_VERSION
+
+  _Rb_tree_node_base*
+  _Rb_tree_increment(_Rb_tree_node_base* __x) throw ()
+  {
+    return local_Rb_tree_increment(__x);
+  }
+
+  const _Rb_tree_node_base*
+  _Rb_tree_increment(const _Rb_tree_node_base* __x) throw ()
+  {
+    return local_Rb_tree_increment(const_cast<_Rb_tree_node_base*>(__x));
+  }
+
+  _Rb_tree_node_base*
+  _Rb_tree_decrement(_Rb_tree_node_base* __x) throw ()
+  {
+    return local_Rb_tree_decrement(__x);
+  }
+
+  const _Rb_tree_node_base*
+  _Rb_tree_decrement(const _Rb_tree_node_base* __x) throw ()
+  {
+    return local_Rb_tree_decrement(const_cast<_Rb_tree_node_base*>(__x));
+  }
+
+#if !_GLIBCXX_INLINE_VERSION
+  /* Static keyword was missing on _Rb_tree_rotate_left.
+     Export the symbol for backward compatibility until
+     next ABI change.  */
+  void
+  _Rb_tree_rotate_left(_Rb_tree_node_base* const __x,
+		       _Rb_tree_node_base*& __root)
+  {
+    local_Rb_tree_rotate_left (__x, __root);
+  }
 
   /* Static keyword was missing on _Rb_tree_rotate_right
      Export the symbol for backward compatibility until
@@ -190,9 +194,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   {
     local_Rb_tree_rotate_right (__x, __root);
   }
+#endif
 
   void
-  _Rb_tree_insert_and_rebalance(const bool          __insert_left,
+  _Rb_tree_insert_and_rebalance(const bool __insert_left,
                                 _Rb_tree_node_base* __x,
                                 _Rb_tree_node_base* __p,
                                 _Rb_tree_node_base& __header) throw ()


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2017-06-15 11:04 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-11 20:31 Avoid _Rb_tree_rotate_[left,right] symbols export François Dumont
2017-05-12 11:06 ` Jonathan Wakely
2017-05-14 20:47   ` François Dumont
2017-06-13 19:51   ` François Dumont
2017-06-15 11:04     ` Jonathan Wakely

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).