This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Avoid _Rb_tree_rotate_[left,right] symbols export
- From: François Dumont <frs dot dumont at gmail dot com>
- To: "libstdc++ at gcc dot gnu dot org" <libstdc++ at gcc dot gnu dot org>, gcc-patches <gcc-patches at gcc dot gnu dot org>
- Date: Thu, 11 May 2017 22:06:21 +0200
- Subject: Avoid _Rb_tree_rotate_[left,right] symbols export
- Authentication-results: sourceware.org; auth=none
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
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 ()