1 // Compatibility symbols for previous versions, list bits -*- C++ -*-
2 
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.
10 
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.
15 
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.
19 
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/>.
24 
25 #include <bits/move.h>
26 
27 #ifdef _GLIBCXX_SHARED
28 
29 #ifndef _GLIBCXX_BEGIN_NAMESPACE_COMPAT
30 # define _GLIBCXX_BEGIN_NAMESPACE_COMPAT
31 #endif
32 
33 #ifndef _GLIBCXX_END_NAMESPACE_COMPAT
34 # define _GLIBCXX_END_NAMESPACE_COMPAT
35 #endif
36 
37 namespace std _GLIBCXX_VISIBILITY(default)
38 {
39 _GLIBCXX_BEGIN_NAMESPACE_COMPAT
40 
41   struct _List_node_base
42   {
43     _List_node_base* _M_next;
44     _List_node_base* _M_prev;
45 
46     void
47     _M_transfer(_List_node_base * const __first,
48 		_List_node_base * const __last) _GLIBCXX_USE_NOEXCEPT;
49 
50     void
51     _M_reverse() _GLIBCXX_USE_NOEXCEPT;
52 
53     void
54     _M_hook(_List_node_base * const __position) _GLIBCXX_USE_NOEXCEPT;
55 
56     void
57     _M_unhook() _GLIBCXX_USE_NOEXCEPT;
58   };
59 
60   void
61   _List_node_base::
62   _M_transfer(_List_node_base * const __first,
63 	      _List_node_base * const __last) _GLIBCXX_USE_NOEXCEPT
64   {
65     if (this != __last)
66     {
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;
71 
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;
77     }
78   }
79 
80   void
81   _List_node_base::_M_reverse() _GLIBCXX_USE_NOEXCEPT
82   {
83     _List_node_base* __tmp = this;
84     do
85     {
86       std::swap(__tmp->_M_next, __tmp->_M_prev);
87 
88       // Old next node is now prev.
89       __tmp = __tmp->_M_prev;
90     }
91     while (__tmp != this);
92   }
93 
94   void
95   _List_node_base::
96   _M_hook(_List_node_base* const __position) _GLIBCXX_USE_NOEXCEPT
97   {
98     this->_M_next = __position;
99     this->_M_prev = __position->_M_prev;
100     __position->_M_prev->_M_next = this;
101     __position->_M_prev = this;
102   }
103 
104   void
105   _List_node_base::_M_unhook() _GLIBCXX_USE_NOEXCEPT
106   {
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;
111   }
112 
113 _GLIBCXX_END_NAMESPACE_COMPAT
114 
115 } // namespace std
116 
117 #endif
118