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