Allow dynamic initialization of thread_locals.
[official-gcc.git] / libstdc++-v3 / src / c++98 / list-aux-2.cc
blob0e118ff4371fb5655f869a3b9af6d04e745beb71
1 // Compatibility symbols for previous versions, list bits -*- C++ -*-
3 // Copyright (C) 2011, 2012 Free Software Foundation, Inc.
4 //
5 // This file is part of the GNU ISO C++ Library. This library is free
6 // software; you can redistribute it and/or modify it under the
7 // terms of the GNU General Public License as published by the
8 // Free Software Foundation; either version 3, or (at your option)
9 // any later version.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // Under Section 7 of GPL version 3, you are granted additional
17 // permissions described in the GCC Runtime Library Exception, version
18 // 3.1, as published by the Free Software Foundation.
20 // You should have received a copy of the GNU General Public License and
21 // a copy of the GCC Runtime Library Exception along with this program;
22 // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
23 // <http://www.gnu.org/licenses/>.
25 #include <bits/move.h>
27 #ifdef _GLIBCXX_SHARED
29 #ifndef _GLIBCXX_BEGIN_NAMESPACE_COMPAT
30 # define _GLIBCXX_BEGIN_NAMESPACE_COMPAT
31 #endif
33 #ifndef _GLIBCXX_END_NAMESPACE_COMPAT
34 # define _GLIBCXX_END_NAMESPACE_COMPAT
35 #endif
37 namespace std _GLIBCXX_VISIBILITY(default)
39 _GLIBCXX_BEGIN_NAMESPACE_COMPAT
41 struct _List_node_base
43 _List_node_base* _M_next;
44 _List_node_base* _M_prev;
46 void
47 _M_transfer(_List_node_base * const __first,
48 _List_node_base * const __last) _GLIBCXX_USE_NOEXCEPT;
50 void
51 _M_reverse() _GLIBCXX_USE_NOEXCEPT;
53 void
54 _M_hook(_List_node_base * const __position) _GLIBCXX_USE_NOEXCEPT;
56 void
57 _M_unhook() _GLIBCXX_USE_NOEXCEPT;
60 void
61 _List_node_base::
62 _M_transfer(_List_node_base * const __first,
63 _List_node_base * const __last) _GLIBCXX_USE_NOEXCEPT
65 if (this != __last)
67 // Remove [first, last) from its old position.
68 __last->_M_prev->_M_next = this;
69 __first->_M_prev->_M_next = __last;
70 this->_M_prev->_M_next = __first;
72 // Splice [first, last) into its new position.
73 _List_node_base* const __tmp = this->_M_prev;
74 this->_M_prev = __last->_M_prev;
75 __last->_M_prev = __first->_M_prev;
76 __first->_M_prev = __tmp;
80 void
81 _List_node_base::_M_reverse() _GLIBCXX_USE_NOEXCEPT
83 _List_node_base* __tmp = this;
86 std::swap(__tmp->_M_next, __tmp->_M_prev);
88 // Old next node is now prev.
89 __tmp = __tmp->_M_prev;
91 while (__tmp != this);
94 void
95 _List_node_base::
96 _M_hook(_List_node_base* const __position) _GLIBCXX_USE_NOEXCEPT
98 this->_M_next = __position;
99 this->_M_prev = __position->_M_prev;
100 __position->_M_prev->_M_next = this;
101 __position->_M_prev = this;
104 void
105 _List_node_base::_M_unhook() _GLIBCXX_USE_NOEXCEPT
107 _List_node_base* const __next_node = this->_M_next;
108 _List_node_base* const __prev_node = this->_M_prev;
109 __prev_node->_M_next = __next_node;
110 __next_node->_M_prev = __prev_node;
113 _GLIBCXX_END_NAMESPACE_COMPAT
115 } // namespace std
117 #endif