diff options
author | Alexander Kabaev <kan@FreeBSD.org> | 2007-05-19 01:25:07 +0000 |
---|---|---|
committer | Alexander Kabaev <kan@FreeBSD.org> | 2007-05-19 01:25:07 +0000 |
commit | f8a1b7d9d8e7e8113637568c296021aea90c1b72 (patch) | |
tree | ea6c2718dc1e45ed535d194df808ef31f0ebac92 /contrib/libstdc++/include/debug | |
parent | 6b834ef156bcf24dcf0e281f57ee5bde03ca07cf (diff) |
GCC 4.2.0 release C++ standard library and runtime support code.
Notes
Notes:
svn path=/vendor/gcc/dist/; revision=169691
Diffstat (limited to 'contrib/libstdc++/include/debug')
25 files changed, 1074 insertions, 682 deletions
diff --git a/contrib/libstdc++/include/debug/bitset b/contrib/libstdc++/include/debug/bitset index 2e2364ff9300..58d4e6b82d91 100644 --- a/contrib/libstdc++/include/debug/bitset +++ b/contrib/libstdc++/include/debug/bitset @@ -1,6 +1,6 @@ // Debugging bitset implementation -*- C++ -*- -// Copyright (C) 2003, 2004 +// Copyright (C) 2003, 2004, 2005 // Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free @@ -16,7 +16,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software @@ -28,6 +28,10 @@ // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. +/** @file debug/bitset + * This file is a GNU debug extension to the Standard C++ Library. + */ + #ifndef _GLIBCXX_DEBUG_BITSET #define _GLIBCXX_DEBUG_BITSET @@ -35,7 +39,9 @@ #include <debug/safe_sequence.h> #include <debug/safe_iterator.h> -namespace __gnu_debug_def +namespace std +{ +namespace __debug { template<size_t _Nb> class bitset @@ -68,7 +74,7 @@ namespace __gnu_debug_def operator=(bool __x) { _GLIBCXX_DEBUG_VERIFY(! this->_M_singular(), - _M_message(::__gnu_debug::__msg_bad_bitset_write) + _M_message(__gnu_debug::__msg_bad_bitset_write) ._M_iterator(*this)); *static_cast<_Base_ref*>(this) = __x; return *this; @@ -78,10 +84,10 @@ namespace __gnu_debug_def operator=(const reference& __x) { _GLIBCXX_DEBUG_VERIFY(! __x._M_singular(), - _M_message(::__gnu_debug::__msg_bad_bitset_read) + _M_message(__gnu_debug::__msg_bad_bitset_read) ._M_iterator(__x)); _GLIBCXX_DEBUG_VERIFY(! this->_M_singular(), - _M_message(::__gnu_debug::__msg_bad_bitset_write) + _M_message(__gnu_debug::__msg_bad_bitset_write) ._M_iterator(*this)); *static_cast<_Base_ref*>(this) = __x; return *this; @@ -91,7 +97,7 @@ namespace __gnu_debug_def operator~() const { _GLIBCXX_DEBUG_VERIFY(! this->_M_singular(), - _M_message(::__gnu_debug::__msg_bad_bitset_read) + _M_message(__gnu_debug::__msg_bad_bitset_read) ._M_iterator(*this)); return ~(*static_cast<const _Base_ref*>(this)); } @@ -99,7 +105,7 @@ namespace __gnu_debug_def operator bool() const { _GLIBCXX_DEBUG_VERIFY(! this->_M_singular(), - _M_message(::__gnu_debug::__msg_bad_bitset_read) + _M_message(__gnu_debug::__msg_bad_bitset_read) ._M_iterator(*this)); return *static_cast<const _Base_ref*>(this); } @@ -108,7 +114,7 @@ namespace __gnu_debug_def flip() { _GLIBCXX_DEBUG_VERIFY(! this->_M_singular(), - _M_message(::__gnu_debug::__msg_bad_bitset_flip) + _M_message(__gnu_debug::__msg_bad_bitset_flip) ._M_iterator(*this)); _Base_ref::flip(); return *this; @@ -239,6 +245,28 @@ namespace __gnu_debug_def to_string() const { return _M_base().template to_string<_CharT, _Traits, _Allocator>(); } + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 434. bitset::to_string() hard to use. + template<typename _CharT, typename _Traits> + std::basic_string<_CharT, _Traits, std::allocator<_CharT> > + to_string() const + { return to_string<_CharT, _Traits, std::allocator<_CharT> >(); } + + template<typename _CharT> + std::basic_string<_CharT, std::char_traits<_CharT>, + std::allocator<_CharT> > + to_string() const + { + return to_string<_CharT, std::char_traits<_CharT>, + std::allocator<_CharT> >(); + } + + std::basic_string<char, std::char_traits<char>, std::allocator<char> > + to_string() const + { + return to_string<char,std::char_traits<char>,std::allocator<char> >(); + } + using _Base::count; using _Base::size; @@ -294,6 +322,7 @@ namespace __gnu_debug_def operator<<(std::basic_ostream<_CharT, _Traits>& __os, const bitset<_Nb>& __x) { return __os << __x._M_base(); } -} // namespace __gnu_debug_def +} // namespace __debug +} // namespace std #endif diff --git a/contrib/libstdc++/include/debug/debug.h b/contrib/libstdc++/include/debug/debug.h index 87bbcfa4db68..b914a2cca4de 100644 --- a/contrib/libstdc++/include/debug/debug.h +++ b/contrib/libstdc++/include/debug/debug.h @@ -1,6 +1,6 @@ // Debugging support implementation -*- C++ -*- -// Copyright (C) 2003 +// Copyright (C) 2003, 2005, 2006 // Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free @@ -16,7 +16,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software @@ -28,504 +28,118 @@ // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. -#ifndef _GLIBCXX_DEBUG_DEBUG_H -#define _GLIBCXX_DEBUG_DEBUG_H 1 - -/** - * Macros used by the implementation to verify certain - * properties. These macros may only be used directly by the debug - * wrappers. Note that these are macros (instead of the more obviously - * "correct" choice of making them functions) because we need line and - * file information at the call site, to minimize the distance between - * the user error and where the error is reported. - * +/** @file debug/debug.h + * This file is a GNU debug extension to the Standard C++ Library. */ -#define _GLIBCXX_DEBUG_VERIFY(_Condition,_ErrorMessage) \ - do { \ - if (! (_Condition)) \ - ::__gnu_debug::_Error_formatter::_M_at(__FILE__, __LINE__) \ - ._ErrorMessage._M_error(); \ - } while (false) - -// Verify that [_First, _Last) forms a valid iterator range. -#define __glibcxx_check_valid_range(_First,_Last) \ -_GLIBCXX_DEBUG_VERIFY(::__gnu_debug::__valid_range(_First, _Last), \ - _M_message(::__gnu_debug::__msg_valid_range) \ - ._M_iterator(_First, #_First) \ - ._M_iterator(_Last, #_Last)) -/** Verify that we can insert into *this with the iterator _Position. - * Insertion into a container at a specific position requires that - * the iterator be nonsingular (i.e., either dereferenceable or - * past-the-end) and that it reference the sequence we are inserting - * into. Note that this macro is only valid when the container is a - * _Safe_sequence and the iterator is a _Safe_iterator. -*/ -#define __glibcxx_check_insert(_Position) \ -_GLIBCXX_DEBUG_VERIFY(!_Position._M_singular(), \ - _M_message(::__gnu_debug::__msg_insert_singular) \ - ._M_sequence(*this, "this") \ - ._M_iterator(_Position, #_Position)); \ -_GLIBCXX_DEBUG_VERIFY(_Position._M_attached_to(this), \ - _M_message(::__gnu_debug::__msg_insert_different) \ - ._M_sequence(*this, "this") \ - ._M_iterator(_Position, #_Position)) - -/** Verify that we can insert the values in the iterator range - * [_First, _Last) into *this with the iterator _Position. Insertion - * into a container at a specific position requires that the iterator - * be nonsingular (i.e., either dereferenceable or past-the-end), - * that it reference the sequence we are inserting into, and that the - * iterator range [_First, Last) is a valid (possibly empty) - * range. Note that this macro is only valid when the container is a - * _Safe_sequence and the iterator is a _Safe_iterator. - * - * @tbd We would like to be able to check for noninterference of - * _Position and the range [_First, _Last), but that can't (in - * general) be done. -*/ -#define __glibcxx_check_insert_range(_Position,_First,_Last) \ -__glibcxx_check_valid_range(_First,_Last); \ -_GLIBCXX_DEBUG_VERIFY(!_Position._M_singular(), \ - _M_message(::__gnu_debug::__msg_insert_singular) \ - ._M_sequence(*this, "this") \ - ._M_iterator(_Position, #_Position)); \ -_GLIBCXX_DEBUG_VERIFY(_Position._M_attached_to(this), \ - _M_message(::__gnu_debug::__msg_insert_different) \ - ._M_sequence(*this, "this") \ - ._M_iterator(_Position, #_Position)) +#ifndef _GLIBCXX_DEBUG_MACRO_SWITCH_H +#define _GLIBCXX_DEBUG_MACRO_SWITCH_H 1 -/** Verify that we can erase the element referenced by the iterator - * _Position. We can erase the element if the _Position iterator is - * dereferenceable and references this sequence. +/** Macros and namespaces used by the implementation outside of debug + * wrappers to verify certain properties. The __glibcxx_requires_xxx + * macros are merely wrappers around the __glibcxx_check_xxx wrappers + * when we are compiling with debug mode, but disappear when we are + * in release mode so that there is no checking performed in, e.g., + * the standard library algorithms. */ -#define __glibcxx_check_erase(_Position) \ -_GLIBCXX_DEBUG_VERIFY(_Position._M_dereferenceable(), \ - _M_message(::__gnu_debug::__msg_erase_bad) \ - ._M_sequence(*this, "this") \ - ._M_iterator(_Position, #_Position)); \ -_GLIBCXX_DEBUG_VERIFY(_Position._M_attached_to(this), \ - _M_message(::__gnu_debug::__msg_erase_different) \ - ._M_sequence(*this, "this") \ - ._M_iterator(_Position, #_Position)) - -/** Verify that we can erase the elements in the iterator range - * [_First, _Last). We can erase the elements if [_First, _Last) is a - * valid iterator range within this sequence. -*/ -#define __glibcxx_check_erase_range(_First,_Last) \ -__glibcxx_check_valid_range(_First,_Last); \ -_GLIBCXX_DEBUG_VERIFY(_First._M_attached_to(this), \ - _M_message(::__gnu_debug::__msg_erase_different) \ - ._M_sequence(*this, "this") \ - ._M_iterator(_First, #_First) \ - ._M_iterator(_Last, #_Last)) - -// Verify that the subscript _N is less than the container's size. -#define __glibcxx_check_subscript(_N) \ -_GLIBCXX_DEBUG_VERIFY(_N < this->size(), \ - _M_message(::__gnu_debug::__msg_subscript_oob) \ - ._M_sequence(*this, "this") \ - ._M_integer(_N, #_N) \ - ._M_integer(this->size(), "size")) - -// Verify that the container is nonempty -#define __glibcxx_check_nonempty() \ -_GLIBCXX_DEBUG_VERIFY(! this->empty(), \ - _M_message(::__gnu_debug::__msg_empty) \ - ._M_sequence(*this, "this")) - -// Verify that the < operator for elements in the sequence is a -// StrictWeakOrdering by checking that it is irreflexive. -#define __glibcxx_check_strict_weak_ordering(_First,_Last) \ -_GLIBCXX_DEBUG_ASSERT(_First == _Last || !(*_First < *_First)) -// Verify that the predicate is StrictWeakOrdering by checking that it -// is irreflexive. -#define __glibcxx_check_strict_weak_ordering_pred(_First,_Last,_Pred) \ -_GLIBCXX_DEBUG_ASSERT(_First == _Last || !_Pred(*_First, *_First)) +// Debug mode namespaces. +namespace std +{ + namespace __debug { } +} +namespace __gnu_cxx +{ + namespace __debug { }; +} -// Verify that the iterator range [_First, _Last) is sorted -#define __glibcxx_check_sorted(_First,_Last) \ -__glibcxx_check_valid_range(_First,_Last); \ -__glibcxx_check_strict_weak_ordering(_First,_Last); \ -_GLIBCXX_DEBUG_VERIFY(::__gnu_debug::__check_sorted(_First, _Last), \ - _M_message(::__gnu_debug::__msg_unsorted) \ - ._M_iterator(_First, #_First) \ - ._M_iterator(_Last, #_Last)) - -/** Verify that the iterator range [_First, _Last) is sorted by the - predicate _Pred. */ -#define __glibcxx_check_sorted_pred(_First,_Last,_Pred) \ -__glibcxx_check_valid_range(_First,_Last); \ -__glibcxx_check_strict_weak_ordering_pred(_First,_Last,_Pred); \ -_GLIBCXX_DEBUG_VERIFY(::__gnu_debug::__check_sorted(_First, _Last, _Pred), \ - _M_message(::__gnu_debug::__msg_unsorted_pred) \ - ._M_iterator(_First, #_First) \ - ._M_iterator(_Last, #_Last) \ - ._M_string(#_Pred)) - -/** Verify that the iterator range [_First, _Last) is partitioned - w.r.t. the value _Value. */ -#define __glibcxx_check_partitioned(_First,_Last,_Value) \ -__glibcxx_check_valid_range(_First,_Last); \ -_GLIBCXX_DEBUG_VERIFY(::__gnu_debug::__check_partitioned(_First, _Last, \ - _Value), \ - _M_message(::__gnu_debug::__msg_unpartitioned) \ - ._M_iterator(_First, #_First) \ - ._M_iterator(_Last, #_Last) \ - ._M_string(#_Value)) +namespace __gnu_debug +{ + using namespace std::__debug; + using namespace __gnu_cxx::__debug; +} + +#ifndef _GLIBCXX_DEBUG + +# define _GLIBCXX_DEBUG_ASSERT(_Condition) +# define _GLIBCXX_DEBUG_PEDASSERT(_Condition) +# define _GLIBCXX_DEBUG_ONLY(_Statement) ; +# define __glibcxx_requires_cond(_Cond,_Msg) +# define __glibcxx_requires_valid_range(_First,_Last) +# define __glibcxx_requires_sorted(_First,_Last) +# define __glibcxx_requires_sorted_pred(_First,_Last,_Pred) +# define __glibcxx_requires_partitioned(_First,_Last,_Value) +# define __glibcxx_requires_partitioned_pred(_First,_Last,_Value,_Pred) +# define __glibcxx_requires_heap(_First,_Last) +# define __glibcxx_requires_heap_pred(_First,_Last,_Pred) +# define __glibcxx_requires_nonempty() +# define __glibcxx_requires_string(_String) +# define __glibcxx_requires_string_len(_String,_Len) +# define __glibcxx_requires_subscript(_N) -/** Verify that the iterator range [_First, _Last) is partitioned - w.r.t. the value _Value and predicate _Pred. */ -#define __glibcxx_check_partitioned_pred(_First,_Last,_Value,_Pred) \ -__glibcxx_check_valid_range(_First,_Last); \ -_GLIBCXX_DEBUG_VERIFY(::__gnu_debug::__check_partitioned(_First, _Last, \ - _Value, _Pred), \ - _M_message(::__gnu_debug::__msg_unpartitioned_pred) \ - ._M_iterator(_First, #_First) \ - ._M_iterator(_Last, #_Last) \ - ._M_string(#_Pred) \ - ._M_string(#_Value)) +#else -// Verify that the iterator range [_First, _Last) is a heap -#define __glibcxx_check_heap(_First,_Last) \ -__glibcxx_check_valid_range(_First,_Last); \ -_GLIBCXX_DEBUG_VERIFY(::std::__is_heap(_First, _Last), \ - _M_message(::__gnu_debug::__msg_not_heap) \ - ._M_iterator(_First, #_First) \ - ._M_iterator(_Last, #_Last)) +# include <cstdlib> +# include <cstdio> +# include <debug/macros.h> -/** Verify that the iterator range [_First, _Last) is a heap - w.r.t. the predicate _Pred. */ -#define __glibcxx_check_heap_pred(_First,_Last,_Pred) \ -__glibcxx_check_valid_range(_First,_Last); \ -_GLIBCXX_DEBUG_VERIFY(::std::__is_heap(_First, _Last, _Pred), \ - _M_message(::__gnu_debug::__msg_not_heap_pred) \ - ._M_iterator(_First, #_First) \ - ._M_iterator(_Last, #_Last) \ - ._M_string(#_Pred)) +namespace std +{ + namespace __debug + { + // Avoid the use of assert, because we're trying to keep the <cassert> + // include out of the mix. + inline void + __replacement_assert(const char* __file, int __line, + const char* __function, const char* __condition) + { + printf("%s:%d: %s: Assertion '%s' failed.\n", __file, __line, + __function, __condition); + abort(); + } + } // namespace __debug +} // namespace std + +#define _GLIBCXX_DEBUG_ASSERT(_Condition) \ + do \ + { \ + if (! (_Condition)) \ + std::__debug::__replacement_assert(__FILE__, __LINE__, \ + __PRETTY_FUNCTION__, #_Condition); \ + } while (false) #ifdef _GLIBCXX_DEBUG_PEDANTIC -# define __glibcxx_check_string(_String) _GLIBCXX_DEBUG_ASSERT(_String != 0) -# define __glibcxx_check_string_len(_String,_Len) \ - _GLIBCXX_DEBUG_ASSERT(_String != 0 || _Len == 0) +# define _GLIBCXX_DEBUG_PEDASSERT(_Condition) _GLIBCXX_DEBUG_ASSERT(_Condition) #else -# define __glibcxx_check_string(_String) -# define __glibcxx_check_string_len(_String,_Len) +# define _GLIBCXX_DEBUG_PEDASSERT(_Condition) #endif +# define _GLIBCXX_DEBUG_ONLY(_Statement) _Statement -/** Macros used by the implementation outside of debug wrappers to - * verify certain properties. The __glibcxx_requires_xxx macros are - * merely wrappers around the __glibcxx_check_xxx wrappers when we - * are compiling with debug mode, but disappear when we are in - * release mode so that there is no checking performed in, e.g., the - * standard library algorithms. -*/ -#ifdef _GLIBCXX_DEBUG -# define _GLIBCXX_DEBUG_ASSERT(_Condition) assert(_Condition) - -# ifdef _GLIBXX_DEBUG_PEDANTIC -# define _GLIBCXX_DEBUG_PEDASSERT(_Condition) assert(_Condition) -# else -# define _GLIBCXX_DEBUG_PEDASSERT(_Condition) -# endif - -# define __glibcxx_requires_cond(_Cond,_Msg) _GLIBCXX_DEBUG_VERIFY(_Cond,_Msg) -# define __glibcxx_requires_valid_range(_First,_Last) \ +# define __glibcxx_requires_cond(_Cond,_Msg) _GLIBCXX_DEBUG_VERIFY(_Cond,_Msg) +# define __glibcxx_requires_valid_range(_First,_Last) \ __glibcxx_check_valid_range(_First,_Last) -# define __glibcxx_requires_sorted(_First,_Last) \ +# define __glibcxx_requires_sorted(_First,_Last) \ __glibcxx_check_sorted(_First,_Last) -# define __glibcxx_requires_sorted_pred(_First,_Last,_Pred) \ +# define __glibcxx_requires_sorted_pred(_First,_Last,_Pred) \ __glibcxx_check_sorted_pred(_First,_Last,_Pred) -# define __glibcxx_requires_partitioned(_First,_Last,_Value) \ +# define __glibcxx_requires_partitioned(_First,_Last,_Value) \ __glibcxx_check_partitioned(_First,_Last,_Value) -# define __glibcxx_requires_partitioned_pred(_First,_Last,_Value,_Pred) \ +# define __glibcxx_requires_partitioned_pred(_First,_Last,_Value,_Pred) \ __glibcxx_check_partitioned_pred(_First,_Last,_Value,_Pred) -# define __glibcxx_requires_heap(_First,_Last) \ +# define __glibcxx_requires_heap(_First,_Last) \ __glibcxx_check_heap(_First,_Last) -# define __glibcxx_requires_heap_pred(_First,_Last,_Pred) \ +# define __glibcxx_requires_heap_pred(_First,_Last,_Pred) \ __glibcxx_check_heap_pred(_First,_Last,_Pred) -# define __glibcxx_requires_nonempty() __glibcxx_check_nonempty() -# define __glibcxx_requires_string(_String) __glibcxx_check_string(_String) -# define __glibcxx_requires_string_len(_String,_Len) \ +# define __glibcxx_requires_nonempty() __glibcxx_check_nonempty() +# define __glibcxx_requires_string(_String) __glibcxx_check_string(_String) +# define __glibcxx_requires_string_len(_String,_Len) \ __glibcxx_check_string_len(_String,_Len) -# define __glibcxx_requires_subscript(_N) __glibcxx_check_subscript(_N) -#else -# define _GLIBCXX_DEBUG_ASSERT(_Condition) -# define _GLIBCXX_DEBUG_PEDASSERT(_Condition) -# define __glibcxx_requires_cond(_Cond,_Msg) -# define __glibcxx_requires_valid_range(_First,_Last) -# define __glibcxx_requires_sorted(_First,_Last) -# define __glibcxx_requires_sorted_pred(_First,_Last,_Pred) -# define __glibcxx_requires_partitioned(_First,_Last,_Value) -# define __glibcxx_requires_partitioned_pred(_First,_Last,_Value,_Pred) -# define __glibcxx_requires_heap(_First,_Last) -# define __glibcxx_requires_heap_pred(_First,_Last,_Pred) -# define __glibcxx_requires_nonempty() -# define __glibcxx_requires_string(_String) -# define __glibcxx_requires_string_len(_String,_Len) -# define __glibcxx_requires_subscript(_N) -#endif - -#include <cassert> // TBD: temporary - -#include <stddef.h> // for ptrdiff_t -#include <bits/stl_iterator_base_types.h> // for iterator_traits, categories -#include <bits/type_traits.h> // for _Is_integer - -namespace __gnu_debug -{ - template<typename _Iterator, typename _Sequence> - class _Safe_iterator; - - // An arbitrary iterator pointer is not singular. - inline bool - __check_singular_aux(const void*) { return false; } - - // We may have an iterator that derives from _Safe_iterator_base but isn't - // a _Safe_iterator. - template<typename _Iterator> - inline bool - __check_singular(_Iterator& __x) - { return __gnu_debug::__check_singular_aux(&__x); } - - /** Non-NULL pointers are nonsingular. */ - template<typename _Tp> - inline bool - __check_singular(const _Tp* __ptr) - { return __ptr == 0; } - - /** Safe iterators know if they are singular. */ - template<typename _Iterator, typename _Sequence> - inline bool - __check_singular(const _Safe_iterator<_Iterator, _Sequence>& __x) - { return __x._M_singular(); } - - /** Assume that some arbitrary iterator is dereferenceable, because we - can't prove that it isn't. */ - template<typename _Iterator> - inline bool - __check_dereferenceable(_Iterator&) - { return true; } - - /** Non-NULL pointers are dereferenceable. */ - template<typename _Tp> - inline bool - __check_dereferenceable(const _Tp* __ptr) - { return __ptr; } - - /** Safe iterators know if they are singular. */ - template<typename _Iterator, typename _Sequence> - inline bool - __check_dereferenceable(const _Safe_iterator<_Iterator, _Sequence>& __x) - { return __x._M_dereferenceable(); } - - /** If the distance between two random access iterators is - * nonnegative, assume the range is valid. - */ - template<typename _RandomAccessIterator> - inline bool - __valid_range_aux2(const _RandomAccessIterator& __first, - const _RandomAccessIterator& __last, - std::random_access_iterator_tag) - { return __last - __first >= 0; } - - /** Can't test for a valid range with input iterators, because - * iteration may be destructive. So we just assume that the range - * is valid. - */ - template<typename _InputIterator> - inline bool - __valid_range_aux2(const _InputIterator&, const _InputIterator&, - std::input_iterator_tag) - { return true; } - - /** We say that integral types for a valid range, and defer to other - * routines to realize what to do with integral types instead of - * iterators. - */ - template<typename _Integral> - inline bool - __valid_range_aux(const _Integral&, const _Integral&, __true_type) - { return true; } - - /** We have iterators, so figure out what kind of iterators that are - * to see if we can check the range ahead of time. - */ - template<typename _InputIterator> - inline bool - __valid_range_aux(const _InputIterator& __first, - const _InputIterator& __last, __false_type) - { - typedef typename std::iterator_traits<_InputIterator>::iterator_category - _Category; - return __gnu_debug::__valid_range_aux2(__first, __last, _Category()); - } +# define __glibcxx_requires_subscript(_N) __glibcxx_check_subscript(_N) - /** Don't know what these iterators are, or if they are even - * iterators (we may get an integral type for InputIterator), so - * see if they are integral and pass them on to the next phase - * otherwise. - */ - template<typename _InputIterator> - inline bool - __valid_range(const _InputIterator& __first, const _InputIterator& __last) - { - typedef typename _Is_integer<_InputIterator>::_Integral _Integral; - return __gnu_debug::__valid_range_aux(__first, __last, _Integral()); - } - - /** Safe iterators know how to check if they form a valid range. */ - template<typename _Iterator, typename _Sequence> - inline bool - __valid_range(const _Safe_iterator<_Iterator, _Sequence>& __first, - const _Safe_iterator<_Iterator, _Sequence>& __last) - { return __first._M_valid_range(__last); } - - /* Checks that [first, last) is a valid range, and then returns - * __first. This routine is useful when we can't use a separate - * assertion statement because, e.g., we are in a constructor. - */ - template<typename _InputIterator> - inline _InputIterator - __check_valid_range(const _InputIterator& __first, - const _InputIterator& __last) - { - _GLIBCXX_DEBUG_ASSERT(__gnu_debug::__valid_range(__first, __last)); - return __first; - } +# include <debug/functions.h> +# include <debug/formatter.h> - /** Checks that __s is non-NULL or __n == 0, and then returns __s. */ - template<typename _CharT, typename _Integer> - inline const _CharT* - __check_string(const _CharT* __s, const _Integer& __n) - { -#ifdef _GLIBCXX_DEBUG_PEDANTIC - _GLIBCXX_DEBUG_ASSERT(__s != 0 || __n == 0); #endif - return __s; - } - - /** Checks that __s is non-NULL and then returns __s. */ - template<typename _CharT> - inline const _CharT* - __check_string(const _CharT* __s) - { -#ifdef _GLIBCXX_DEBUG_PEDANTIC - _GLIBCXX_DEBUG_ASSERT(__s != 0); -#endif - return __s; - } - - // Can't check if an input iterator sequence is sorted, because we - // can't step through the sequence. - template<typename _InputIterator> - inline bool - __check_sorted_aux(const _InputIterator&, const _InputIterator&, - std::input_iterator_tag) - { return true; } - - // Can verify if a forward iterator sequence is in fact sorted using - // std::__is_sorted - template<typename _ForwardIterator> - inline bool - __check_sorted_aux(_ForwardIterator __first, _ForwardIterator __last, - std::forward_iterator_tag) - { - if (__first == __last) - return true; - - _ForwardIterator __next = __first; - for (++__next; __next != __last; __first = __next, ++__next) { - if (*__next < *__first) - return false; - } - - return true; - } - - // Can't check if an input iterator sequence is sorted, because we can't step - // through the sequence. - template<typename _InputIterator, typename _Predicate> - inline bool - __check_sorted_aux(const _InputIterator&, const _InputIterator&, - _Predicate, std::input_iterator_tag) - { return true; } - // Can verify if a forward iterator sequence is in fact sorted using - // std::__is_sorted - template<typename _ForwardIterator, typename _Predicate> - inline bool - __check_sorted_aux(_ForwardIterator __first, _ForwardIterator __last, - _Predicate __pred, std::forward_iterator_tag) - { - if (__first == __last) - return true; - - _ForwardIterator __next = __first; - for (++__next; __next != __last; __first = __next, ++__next) { - if (__pred(*__next, *__first)) - return false; - } - - return true; - } - - // Determine if a sequence is sorted. - template<typename _InputIterator> - inline bool - __check_sorted(const _InputIterator& __first, const _InputIterator& __last) - { - typedef typename std::iterator_traits<_InputIterator>::iterator_category - _Category; - return __gnu_debug::__check_sorted_aux(__first, __last, _Category()); - } - - template<typename _InputIterator, typename _Predicate> - inline bool - __check_sorted(const _InputIterator& __first, const _InputIterator& __last, - _Predicate __pred) - { - typedef typename std::iterator_traits<_InputIterator>::iterator_category - _Category; - return __gnu_debug::__check_sorted_aux(__first, __last, __pred, - _Category()); - } - - // _GLIBCXX_RESOLVE_LIB_DEFECTS - // 270. Binary search requirements overly strict - // Determine if a sequence is partitioned w.r.t. this element. - template<typename _ForwardIterator, typename _Tp> - inline bool - __check_partitioned(_ForwardIterator __first, _ForwardIterator __last, - const _Tp& __value) - { - while (__first != __last && *__first < __value) - ++__first; - while (__first != __last && !(*__first < __value)) - ++__first; - return __first == __last; - } - - // Determine if a sequence is partitioned w.r.t. this element. - template<typename _ForwardIterator, typename _Tp, typename _Pred> - inline bool - __check_partitioned(_ForwardIterator __first, _ForwardIterator __last, - const _Tp& __value, _Pred __pred) - { - while (__first != __last && __pred(*__first, __value)) - ++__first; - while (__first != __last && !__pred(*__first, __value)) - ++__first; - return __first == __last; - } -} // namespace __gnu_debug - -#ifdef _GLIBCXX_DEBUG -// We need the error formatter -# include <debug/formatter.h> -#endif - -#endif +#endif // _GLIBCXX_DEBUG_MACRO_SWITCH_H diff --git a/contrib/libstdc++/include/debug/deque b/contrib/libstdc++/include/debug/deque index c39a49c04610..79142d9ef2a4 100644 --- a/contrib/libstdc++/include/debug/deque +++ b/contrib/libstdc++/include/debug/deque @@ -1,6 +1,6 @@ // Debugging deque implementation -*- C++ -*- -// Copyright (C) 2003, 2004 +// Copyright (C) 2003, 2004, 2005 // Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free @@ -16,7 +16,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software @@ -28,6 +28,10 @@ // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. +/** @file debug/deque + * This file is a GNU debug extension to the Standard C++ Library. + */ + #ifndef _GLIBCXX_DEBUG_DEQUE #define _GLIBCXX_DEBUG_DEQUE 1 @@ -35,7 +39,9 @@ #include <debug/safe_sequence.h> #include <debug/safe_iterator.h> -namespace __gnu_debug_def +namespace std +{ +namespace __debug { template<typename _Tp, typename _Allocator = std::allocator<_Tp> > class deque @@ -46,8 +52,8 @@ namespace __gnu_debug_def typedef __gnu_debug::_Safe_sequence<deque> _Safe_base; public: - typedef typename _Allocator::reference reference; - typedef typename _Allocator::const_reference const_reference; + typedef typename _Base::reference reference; + typedef typename _Base::const_reference const_reference; typedef __gnu_debug::_Safe_iterator<typename _Base::iterator,deque> iterator; @@ -59,8 +65,8 @@ namespace __gnu_debug_def typedef _Tp value_type; typedef _Allocator allocator_type; - typedef typename _Allocator::pointer pointer; - typedef typename _Allocator::const_pointer const_pointer; + typedef typename _Base::pointer pointer; + typedef typename _Base::const_pointer const_pointer; typedef std::reverse_iterator<iterator> reverse_iterator; typedef std::reverse_iterator<const_iterator> const_reverse_iterator; @@ -381,6 +387,7 @@ namespace __gnu_debug_def inline void swap(deque<_Tp, _Alloc>& __lhs, deque<_Tp, _Alloc>& __rhs) { __lhs.swap(__rhs); } -} // namespace __gnu_debug_def +} // namespace __debug +} // namespace std #endif diff --git a/contrib/libstdc++/include/debug/formatter.h b/contrib/libstdc++/include/debug/formatter.h index db555b0030db..8975285b9d71 100644 --- a/contrib/libstdc++/include/debug/formatter.h +++ b/contrib/libstdc++/include/debug/formatter.h @@ -1,7 +1,6 @@ // Debug-mode error formatting implementation -*- C++ -*- -// Copyright (C) 2003, 2004 -// Free Software Foundation, Inc. +// Copyright (C) 2003, 2004, 2005, 2006 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the @@ -16,7 +15,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software @@ -28,6 +27,10 @@ // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. +/** @file debug/formatter.h + * This file is a GNU debug extension to the Standard C++ Library. + */ + #ifndef _GLIBCXX_DEBUG_FORMATTER_H #define _GLIBCXX_DEBUG_FORMATTER_H 1 @@ -310,7 +313,7 @@ namespace __gnu_debug const _Error_formatter& _M_iterator(const _Iterator& __it, const char* __name = 0) const { - if (_M_num_parameters < __max_parameters) + if (_M_num_parameters < size_t(__max_parameters)) _M_parameters[_M_num_parameters++] = _Parameter(__it, __name, _Is_iterator()); return *this; @@ -319,7 +322,7 @@ namespace __gnu_debug const _Error_formatter& _M_integer(long __value, const char* __name = 0) const { - if (_M_num_parameters < __max_parameters) + if (_M_num_parameters < size_t(__max_parameters)) _M_parameters[_M_num_parameters++] = _Parameter(__value, __name); return *this; } @@ -327,7 +330,7 @@ namespace __gnu_debug const _Error_formatter& _M_string(const char* __value, const char* __name = 0) const { - if (_M_num_parameters < __max_parameters) + if (_M_num_parameters < size_t(__max_parameters)) _M_parameters[_M_num_parameters++] = _Parameter(__value, __name); return *this; } @@ -336,7 +339,7 @@ namespace __gnu_debug const _Error_formatter& _M_sequence(const _Sequence& __seq, const char* __name = 0) const { - if (_M_num_parameters < __max_parameters) + if (_M_num_parameters < size_t(__max_parameters)) _M_parameters[_M_num_parameters++] = _Parameter(__seq, __name, _Is_sequence()); return *this; diff --git a/contrib/libstdc++/include/debug/functions.h b/contrib/libstdc++/include/debug/functions.h new file mode 100644 index 000000000000..a61c0b9f4ee7 --- /dev/null +++ b/contrib/libstdc++/include/debug/functions.h @@ -0,0 +1,293 @@ +// Debugging support implementation -*- C++ -*- + +// Copyright (C) 2003, 2005, 2006 +// Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +/** @file debug/functions.h + * This file is a GNU debug extension to the Standard C++ Library. + */ + +#ifndef _GLIBCXX_DEBUG_FUNCTIONS_H +#define _GLIBCXX_DEBUG_FUNCTIONS_H 1 + +#include <bits/c++config.h> +#include <stddef.h> // for ptrdiff_t +#include <bits/stl_iterator_base_types.h> // for iterator_traits, categories +#include <bits/cpp_type_traits.h> // for __is_integer + +namespace __gnu_debug +{ + template<typename _Iterator, typename _Sequence> + class _Safe_iterator; + + // An arbitrary iterator pointer is not singular. + inline bool + __check_singular_aux(const void*) { return false; } + + // We may have an iterator that derives from _Safe_iterator_base but isn't + // a _Safe_iterator. + template<typename _Iterator> + inline bool + __check_singular(_Iterator& __x) + { return __check_singular_aux(&__x); } + + /** Non-NULL pointers are nonsingular. */ + template<typename _Tp> + inline bool + __check_singular(const _Tp* __ptr) + { return __ptr == 0; } + + /** Safe iterators know if they are singular. */ + template<typename _Iterator, typename _Sequence> + inline bool + __check_singular(const _Safe_iterator<_Iterator, _Sequence>& __x) + { return __x._M_singular(); } + + /** Assume that some arbitrary iterator is dereferenceable, because we + can't prove that it isn't. */ + template<typename _Iterator> + inline bool + __check_dereferenceable(_Iterator&) + { return true; } + + /** Non-NULL pointers are dereferenceable. */ + template<typename _Tp> + inline bool + __check_dereferenceable(const _Tp* __ptr) + { return __ptr; } + + /** Safe iterators know if they are singular. */ + template<typename _Iterator, typename _Sequence> + inline bool + __check_dereferenceable(const _Safe_iterator<_Iterator, _Sequence>& __x) + { return __x._M_dereferenceable(); } + + /** If the distance between two random access iterators is + * nonnegative, assume the range is valid. + */ + template<typename _RandomAccessIterator> + inline bool + __valid_range_aux2(const _RandomAccessIterator& __first, + const _RandomAccessIterator& __last, + std::random_access_iterator_tag) + { return __last - __first >= 0; } + + /** Can't test for a valid range with input iterators, because + * iteration may be destructive. So we just assume that the range + * is valid. + */ + template<typename _InputIterator> + inline bool + __valid_range_aux2(const _InputIterator&, const _InputIterator&, + std::input_iterator_tag) + { return true; } + + /** We say that integral types for a valid range, and defer to other + * routines to realize what to do with integral types instead of + * iterators. + */ + template<typename _Integral> + inline bool + __valid_range_aux(const _Integral&, const _Integral&, std::__true_type) + { return true; } + + /** We have iterators, so figure out what kind of iterators that are + * to see if we can check the range ahead of time. + */ + template<typename _InputIterator> + inline bool + __valid_range_aux(const _InputIterator& __first, + const _InputIterator& __last, std::__false_type) + { + typedef typename std::iterator_traits<_InputIterator>::iterator_category + _Category; + return __valid_range_aux2(__first, __last, _Category()); + } + + /** Don't know what these iterators are, or if they are even + * iterators (we may get an integral type for InputIterator), so + * see if they are integral and pass them on to the next phase + * otherwise. + */ + template<typename _InputIterator> + inline bool + __valid_range(const _InputIterator& __first, const _InputIterator& __last) + { + typedef typename std::__is_integer<_InputIterator>::__type _Integral; + return __valid_range_aux(__first, __last, _Integral()); + } + + /** Safe iterators know how to check if they form a valid range. */ + template<typename _Iterator, typename _Sequence> + inline bool + __valid_range(const _Safe_iterator<_Iterator, _Sequence>& __first, + const _Safe_iterator<_Iterator, _Sequence>& __last) + { return __first._M_valid_range(__last); } + + /* Checks that [first, last) is a valid range, and then returns + * __first. This routine is useful when we can't use a separate + * assertion statement because, e.g., we are in a constructor. + */ + template<typename _InputIterator> + inline _InputIterator + __check_valid_range(const _InputIterator& __first, + const _InputIterator& __last + __attribute__((__unused__))) + { + _GLIBCXX_DEBUG_ASSERT(__valid_range(__first, __last)); + return __first; + } + + /** Checks that __s is non-NULL or __n == 0, and then returns __s. */ + template<typename _CharT, typename _Integer> + inline const _CharT* + __check_string(const _CharT* __s, + const _Integer& __n __attribute__((__unused__))) + { +#ifdef _GLIBCXX_DEBUG_PEDANTIC + _GLIBCXX_DEBUG_ASSERT(__s != 0 || __n == 0); +#endif + return __s; + } + + /** Checks that __s is non-NULL and then returns __s. */ + template<typename _CharT> + inline const _CharT* + __check_string(const _CharT* __s) + { +#ifdef _GLIBCXX_DEBUG_PEDANTIC + _GLIBCXX_DEBUG_ASSERT(__s != 0); +#endif + return __s; + } + + // Can't check if an input iterator sequence is sorted, because we + // can't step through the sequence. + template<typename _InputIterator> + inline bool + __check_sorted_aux(const _InputIterator&, const _InputIterator&, + std::input_iterator_tag) + { return true; } + + // Can verify if a forward iterator sequence is in fact sorted using + // std::__is_sorted + template<typename _ForwardIterator> + inline bool + __check_sorted_aux(_ForwardIterator __first, _ForwardIterator __last, + std::forward_iterator_tag) + { + if (__first == __last) + return true; + + _ForwardIterator __next = __first; + for (++__next; __next != __last; __first = __next, ++__next) { + if (*__next < *__first) + return false; + } + + return true; + } + + // Can't check if an input iterator sequence is sorted, because we can't step + // through the sequence. + template<typename _InputIterator, typename _Predicate> + inline bool + __check_sorted_aux(const _InputIterator&, const _InputIterator&, + _Predicate, std::input_iterator_tag) + { return true; } + + // Can verify if a forward iterator sequence is in fact sorted using + // std::__is_sorted + template<typename _ForwardIterator, typename _Predicate> + inline bool + __check_sorted_aux(_ForwardIterator __first, _ForwardIterator __last, + _Predicate __pred, std::forward_iterator_tag) + { + if (__first == __last) + return true; + + _ForwardIterator __next = __first; + for (++__next; __next != __last; __first = __next, ++__next) { + if (__pred(*__next, *__first)) + return false; + } + + return true; + } + + // Determine if a sequence is sorted. + template<typename _InputIterator> + inline bool + __check_sorted(const _InputIterator& __first, const _InputIterator& __last) + { + typedef typename std::iterator_traits<_InputIterator>::iterator_category + _Category; + return __check_sorted_aux(__first, __last, _Category()); + } + + template<typename _InputIterator, typename _Predicate> + inline bool + __check_sorted(const _InputIterator& __first, const _InputIterator& __last, + _Predicate __pred) + { + typedef typename std::iterator_traits<_InputIterator>::iterator_category + _Category; + return __check_sorted_aux(__first, __last, __pred, + _Category()); + } + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 270. Binary search requirements overly strict + // Determine if a sequence is partitioned w.r.t. this element. + template<typename _ForwardIterator, typename _Tp> + inline bool + __check_partitioned(_ForwardIterator __first, _ForwardIterator __last, + const _Tp& __value) + { + while (__first != __last && *__first < __value) + ++__first; + while (__first != __last && !(*__first < __value)) + ++__first; + return __first == __last; + } + + // Determine if a sequence is partitioned w.r.t. this element. + template<typename _ForwardIterator, typename _Tp, typename _Pred> + inline bool + __check_partitioned(_ForwardIterator __first, _ForwardIterator __last, + const _Tp& __value, _Pred __pred) + { + while (__first != __last && __pred(*__first, __value)) + ++__first; + while (__first != __last && !__pred(*__first, __value)) + ++__first; + return __first == __last; + } +} // namespace __gnu_debug + +#endif diff --git a/contrib/libstdc++/include/debug/hash_map b/contrib/libstdc++/include/debug/hash_map index 570a9af6b692..f44586b0ab6c 100644 --- a/contrib/libstdc++/include/debug/hash_map +++ b/contrib/libstdc++/include/debug/hash_map @@ -1,6 +1,6 @@ // Debugging hash_map/hash_multimap implementation -*- C++ -*- -// Copyright (C) 2003 +// Copyright (C) 2003, 2005 // Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free @@ -16,7 +16,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software @@ -28,11 +28,15 @@ // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. +/** @file debug/hash_map + * This file is a GNU debug extension to the Standard C++ Library. + */ + #ifndef _GLIBCXX_DEBUG_HASH_MAP #define _GLIBCXX_DEBUG_HASH_MAP 1 -#include <hash_map> -#include <debug/dbg_hash_map.h> -#include <debug/dbg_hash_multimap.h> +#include <ext/hash_map> +#include <debug/hash_map.h> +#include <debug/hash_multimap.h> #endif diff --git a/contrib/libstdc++/include/debug/hash_map.h b/contrib/libstdc++/include/debug/hash_map.h index c2cd7b8ca693..1eb6acb869c3 100644 --- a/contrib/libstdc++/include/debug/hash_map.h +++ b/contrib/libstdc++/include/debug/hash_map.h @@ -1,6 +1,6 @@ // Debugging hash_map implementation -*- C++ -*- -// Copyright (C) 2003 +// Copyright (C) 2003, 2005, 2006 // Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free @@ -16,7 +16,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software @@ -28,24 +28,30 @@ // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. +/** @file debug/hash_map.h + * This file is a GNU debug extension to the Standard C++ Library. + */ + #ifndef _GLIBCXX_DEBUG_HASH_MAP_H #define _GLIBCXX_DEBUG_HASH_MAP_H 1 #include <debug/safe_sequence.h> #include <debug/safe_iterator.h> -namespace __gnu_debug_def +namespace __gnu_cxx +{ +namespace __debug { template<typename _Value, typename _Tp, typename _HashFcn = __gnu_cxx::hash<_Value>, typename _EqualKey = std::equal_to<_Value>, typename _Alloc = std::allocator<_Value> > class hash_map - : public __gnu_cxx::hash_map<_Value, _Tp, _HashFcn, _EqualKey, _Alloc>, + : public _GLIBCXX_EXT::hash_map<_Value, _Tp, _HashFcn, _EqualKey, _Alloc>, public __gnu_debug::_Safe_sequence<hash_map<_Value, _Tp, _HashFcn, _EqualKey, _Alloc> > { - typedef __gnu_cxx::hash_map<_Value, _Tp, _HashFcn, _EqualKey, _Alloc> + typedef _GLIBCXX_EXT::hash_map<_Value, _Tp, _HashFcn, _EqualKey, _Alloc> _Base; typedef __gnu_debug::_Safe_sequence<hash_map> _Safe_base; @@ -139,7 +145,14 @@ namespace __gnu_debug_def return std::make_pair(iterator(__res.first, this), __res.second); } - template <typename _InputIterator> + void + insert(const value_type* __first, const value_type* __last) + { + __glibcxx_check_valid_range(__first, __last); + _Base::insert(__first, __last); + } + + template<typename _InputIterator> void insert(_InputIterator __first, _InputIterator __last) { @@ -265,6 +278,7 @@ namespace __gnu_debug_def swap(hash_map<_Value, _Tp, _HashFcn, _EqualKey, _Alloc>& __x, hash_map<_Value, _Tp, _HashFcn, _EqualKey, _Alloc>& __y) { __x.swap(__y); } -} // namespace __gnu_debug_def +} // namespace __debug +} // namespace __gnu_cxx #endif diff --git a/contrib/libstdc++/include/debug/hash_multimap.h b/contrib/libstdc++/include/debug/hash_multimap.h index 83b4425aaf0c..e3c689ac7cd2 100644 --- a/contrib/libstdc++/include/debug/hash_multimap.h +++ b/contrib/libstdc++/include/debug/hash_multimap.h @@ -1,6 +1,6 @@ // Debugging hash_multimap implementation -*- C++ -*- -// Copyright (C) 2003 +// Copyright (C) 2003, 2005, 2006 // Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free @@ -16,7 +16,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software @@ -28,24 +28,30 @@ // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. +/** @file debug/hash_multimap.h + * This file is a GNU debug extension to the Standard C++ Library. + */ + #ifndef _GLIBCXX_DEBUG_HASH_MULTIMAP_H #define _GLIBCXX_DEBUG_HASH_MULTIMAP_H 1 #include <debug/safe_sequence.h> #include <debug/safe_iterator.h> -namespace __gnu_debug_def +namespace __gnu_cxx +{ +namespace __debug { template<typename _Value, typename _Tp, typename _HashFcn = __gnu_cxx::hash<_Value>, typename _EqualKey = std::equal_to<_Value>, typename _Alloc = std::allocator<_Value> > class hash_multimap - : public __gnu_cxx::hash_multimap<_Value,_Tp,_HashFcn, _EqualKey,_Alloc>, + : public _GLIBCXX_EXT::hash_multimap<_Value,_Tp,_HashFcn,_EqualKey,_Alloc>, public __gnu_debug::_Safe_sequence<hash_multimap<_Value, _Tp, _HashFcn, _EqualKey, _Alloc> > { - typedef __gnu_cxx::hash_multimap<_Value,_Tp,_HashFcn, _EqualKey,_Alloc> + typedef _GLIBCXX_EXT::hash_multimap<_Value,_Tp,_HashFcn,_EqualKey,_Alloc> _Base; typedef __gnu_debug::_Safe_sequence<hash_multimap> _Safe_base; @@ -179,7 +185,7 @@ namespace __gnu_debug_def erase(const key_type& __key) { std::pair<iterator, iterator> __victims = this->equal_range(__key); - size_t __num_victims = 0; + std::size_t __num_victims = 0; while (__victims.first != __victims.second) { this->erase(__victims.first++); @@ -256,6 +262,7 @@ namespace __gnu_debug_def swap(hash_multimap<_Value, _Tp, _HashFcn, _EqualKey, _Alloc>& __x, hash_multimap<_Value, _Tp, _HashFcn, _EqualKey, _Alloc>& __y) { __x.swap(__y); } -} // namespace __gnu_debug_def +} // namespace __debug +} // namespace __gnu_cxx #endif diff --git a/contrib/libstdc++/include/debug/hash_multiset.h b/contrib/libstdc++/include/debug/hash_multiset.h index 705d8da25329..934649694871 100644 --- a/contrib/libstdc++/include/debug/hash_multiset.h +++ b/contrib/libstdc++/include/debug/hash_multiset.h @@ -1,6 +1,6 @@ // Debugging hash_multiset implementation -*- C++ -*- -// Copyright (C) 2003 +// Copyright (C) 2003, 2005, 2006 // Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free @@ -16,7 +16,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software @@ -28,24 +28,30 @@ // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. +/** @file debug/hash_multiset.h + * This file is a GNU debug extension to the Standard C++ Library. + */ + #ifndef _GLIBCXX_DEBUG_HASH_MULTISET_H #define _GLIBCXX_DEBUG_HASH_MULTISET_H 1 #include <debug/safe_sequence.h> #include <debug/safe_iterator.h> -namespace __gnu_debug_def +namespace __gnu_cxx +{ +namespace __debug { template<typename _Value, typename _HashFcn = __gnu_cxx::hash<_Value>, typename _EqualKey = std::equal_to<_Value>, typename _Alloc = std::allocator<_Value> > class hash_multiset - : public __gnu_cxx::hash_multiset<_Value, _HashFcn, _EqualKey, _Alloc>, + : public _GLIBCXX_EXT::hash_multiset<_Value, _HashFcn, _EqualKey, _Alloc>, public __gnu_debug::_Safe_sequence<hash_multiset<_Value, _HashFcn, _EqualKey, _Alloc> > { - typedef __gnu_cxx:: hash_multiset<_Value,_HashFcn, _EqualKey,_Alloc> + typedef _GLIBCXX_EXT:: hash_multiset<_Value,_HashFcn, _EqualKey,_Alloc> _Base; typedef __gnu_debug::_Safe_sequence<hash_multiset> _Safe_base; @@ -231,6 +237,7 @@ template<typename _Value, typename _HashFcn, typename _EqualKey, typename _Alloc swap(hash_multiset<_Value, _HashFcn, _EqualKey, _Alloc>& __x, hash_multiset<_Value, _HashFcn, _EqualKey, _Alloc>& __y) { __x.swap(__y); } -} // namespace __gnu_debug_def +} // namespace __debug +} // namespace __gnu_cxx #endif diff --git a/contrib/libstdc++/include/debug/hash_set b/contrib/libstdc++/include/debug/hash_set index 282cba27613a..4b98fefab1f6 100644 --- a/contrib/libstdc++/include/debug/hash_set +++ b/contrib/libstdc++/include/debug/hash_set @@ -1,6 +1,6 @@ // Debugging hash_set/hash_multiset implementation -*- C++ -*- -// Copyright (C) 2003 +// Copyright (C) 2003, 2005 // Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free @@ -16,7 +16,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software @@ -28,11 +28,15 @@ // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. +/** @file debug/hash_set + * This file is a GNU debug extension to the Standard C++ Library. + */ + #ifndef _GLIBCXX_DEBUG_HASH_SET #define _GLIBCXX_DEBUG_HASH_SET 1 -#include <hash_set> -#include <debug/dbg_hash_set.h> -#include <debug/dbg_hash_multiset.h> +#include <ext/hash_set> +#include <debug/hash_set.h> +#include <debug/hash_multiset.h> #endif diff --git a/contrib/libstdc++/include/debug/hash_set.h b/contrib/libstdc++/include/debug/hash_set.h index 0f56d882935c..2d3e0b303fb6 100644 --- a/contrib/libstdc++/include/debug/hash_set.h +++ b/contrib/libstdc++/include/debug/hash_set.h @@ -1,6 +1,6 @@ // Debugging hash_set implementation -*- C++ -*- -// Copyright (C) 2003 +// Copyright (C) 2003, 2005, 2006 // Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free @@ -16,7 +16,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software @@ -28,24 +28,30 @@ // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. +/** @file debug/hash_set.h + * This file is a GNU debug extension to the Standard C++ Library. + */ + #ifndef _GLIBCXX_DEBUG_HASH_SET_H #define _GLIBCXX_DEBUG_HASH_SET_H 1 #include <debug/safe_sequence.h> #include <debug/safe_iterator.h> -namespace __gnu_debug_def +namespace __gnu_cxx +{ +namespace __debug { template<typename _Value, typename _HashFcn = __gnu_cxx::hash<_Value>, typename _EqualKey = std::equal_to<_Value>, typename _Alloc = std::allocator<_Value> > class hash_set - : public __gnu_cxx::hash_set<_Value, _HashFcn, _EqualKey, _Alloc>, + : public _GLIBCXX_EXT::hash_set<_Value, _HashFcn, _EqualKey,_Alloc>, public __gnu_debug::_Safe_sequence<hash_set<_Value, _HashFcn, _EqualKey, _Alloc> > { - typedef __gnu_cxx::hash_set<_Value, _HashFcn, _EqualKey, _Alloc> _Base; + typedef _GLIBCXX_EXT::hash_set<_Value, _HashFcn, _EqualKey,_Alloc> _Base; typedef __gnu_debug::_Safe_sequence<hash_set> _Safe_base; public: @@ -129,7 +135,14 @@ namespace __gnu_debug_def return std::make_pair(iterator(__res.first, this), __res.second); } - template <typename _InputIterator> + void + insert(const value_type* __first, const value_type* __last) + { + __glibcxx_check_valid_range(__first, __last); + _Base::insert(__first, __last); + } + + template<typename _InputIterator> void insert(_InputIterator __first, _InputIterator __last) { @@ -240,6 +253,7 @@ namespace __gnu_debug_def swap(hash_set<_Value, _HashFcn, _EqualKey, _Alloc>& __x, hash_set<_Value, _HashFcn, _EqualKey, _Alloc>& __y) { __x.swap(__y); } -} // namespace __gnu_debug_def +} // namespace __debug +} // namespace __gnu_cxx #endif diff --git a/contrib/libstdc++/include/debug/list b/contrib/libstdc++/include/debug/list index 556c9d9acff7..939fe4da48d3 100644 --- a/contrib/libstdc++/include/debug/list +++ b/contrib/libstdc++/include/debug/list @@ -1,6 +1,6 @@ // Debugging list implementation -*- C++ -*- -// Copyright (C) 2003, 2004 +// Copyright (C) 2003, 2004, 2005, 2006 // Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free @@ -16,7 +16,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software @@ -28,6 +28,37 @@ // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. +// Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +/** @file debug/list + * This file is a GNU debug extension to the Standard C++ Library. + */ + #ifndef _GLIBCXX_DEBUG_LIST #define _GLIBCXX_DEBUG_LIST 1 @@ -36,7 +67,9 @@ #include <debug/safe_sequence.h> #include <debug/safe_iterator.h> -namespace __gnu_debug_def +namespace std +{ +namespace __debug { template<typename _Tp, typename _Allocator = std::allocator<_Tp> > class list @@ -47,8 +80,8 @@ namespace __gnu_debug_def typedef __gnu_debug::_Safe_sequence<list> _Safe_base; public: - typedef typename _Allocator::reference reference; - typedef typename _Allocator::const_reference const_reference; + typedef typename _Base::reference reference; + typedef typename _Base::const_reference const_reference; typedef __gnu_debug::_Safe_iterator<typename _Base::iterator, list> iterator; @@ -60,8 +93,8 @@ namespace __gnu_debug_def typedef _Tp value_type; typedef _Allocator allocator_type; - typedef typename _Allocator::pointer pointer; - typedef typename _Allocator::const_pointer const_pointer; + typedef typename _Base::pointer pointer; + typedef typename _Base::const_pointer const_pointer; typedef std::reverse_iterator<iterator> reverse_iterator; typedef std::reverse_iterator<const_iterator> const_reverse_iterator; @@ -296,7 +329,7 @@ namespace __gnu_debug_def splice(iterator __position, list& __x) { _GLIBCXX_DEBUG_VERIFY(&__x != this, - _M_message(::__gnu_debug::__msg_self_splice) + _M_message(__gnu_debug::__msg_self_splice) ._M_sequence(*this, "this")); this->splice(__position, __x, __x.begin(), __x.end()); } @@ -305,14 +338,15 @@ namespace __gnu_debug_def splice(iterator __position, list& __x, iterator __i) { __glibcxx_check_insert(__position); - _GLIBCXX_DEBUG_VERIFY(__x.get_allocator() == this->get_allocator(), - _M_message(::__gnu_debug::__msg_splice_alloc) - ._M_sequence(*this)._M_sequence(__x, "__x")); + + // We used to perform the splice_alloc check: not anymore, redundant + // after implementing the relevant bits of N1599. + _GLIBCXX_DEBUG_VERIFY(__i._M_dereferenceable(), - _M_message(::__gnu_debug::__msg_splice_bad) + _M_message(__gnu_debug::__msg_splice_bad) ._M_iterator(__i, "__i")); _GLIBCXX_DEBUG_VERIFY(__i._M_attached_to(&__x), - _M_message(::__gnu_debug::__msg_splice_other) + _M_message(__gnu_debug::__msg_splice_other) ._M_iterator(__i, "__i")._M_sequence(__x, "__x")); // _GLIBCXX_RESOLVE_LIB_DEFECTS @@ -327,17 +361,17 @@ namespace __gnu_debug_def __glibcxx_check_insert(__position); __glibcxx_check_valid_range(__first, __last); _GLIBCXX_DEBUG_VERIFY(__first._M_attached_to(&__x), - _M_message(::__gnu_debug::__msg_splice_other) + _M_message(__gnu_debug::__msg_splice_other) ._M_sequence(__x, "x") ._M_iterator(__first, "first")); - _GLIBCXX_DEBUG_VERIFY(__x.get_allocator() == this->get_allocator(), - _M_message(::__gnu_debug::__msg_splice_alloc) - ._M_sequence(*this)._M_sequence(__x)); + + // We used to perform the splice_alloc check: not anymore, redundant + // after implementing the relevant bits of N1599. for (iterator __tmp = __first; __tmp != __last; ) { _GLIBCXX_DEBUG_VERIFY(&__x != this || __tmp != __position, - _M_message(::__gnu_debug::__msg_splice_overlap) + _M_message(__gnu_debug::__msg_splice_overlap) ._M_iterator(__tmp, "position") ._M_iterator(__first, "first") ._M_iterator(__last, "last")); @@ -500,6 +534,7 @@ namespace __gnu_debug_def inline void swap(list<_Tp, _Alloc>& __lhs, list<_Tp, _Alloc>& __rhs) { __lhs.swap(__rhs); } -} // namespace __gnu_debug_def +} // namespace __debug +} // namespace std #endif diff --git a/contrib/libstdc++/include/debug/macros.h b/contrib/libstdc++/include/debug/macros.h new file mode 100644 index 000000000000..ce4091924b1b --- /dev/null +++ b/contrib/libstdc++/include/debug/macros.h @@ -0,0 +1,224 @@ +// Debugging support implementation -*- C++ -*- + +// Copyright (C) 2003, 2005, 2006 +// Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +/** @file debug/macros.h + * This file is a GNU debug extension to the Standard C++ Library. + */ + +#ifndef _GLIBCXX_DEBUG_MACROS_H +#define _GLIBCXX_DEBUG_MACROS_H 1 + +/** + * Macros used by the implementation to verify certain + * properties. These macros may only be used directly by the debug + * wrappers. Note that these are macros (instead of the more obviously + * "correct" choice of making them functions) because we need line and + * file information at the call site, to minimize the distance between + * the user error and where the error is reported. + * + */ +#define _GLIBCXX_DEBUG_VERIFY(_Condition,_ErrorMessage) \ + do \ + { \ + if (! (_Condition)) \ + __gnu_debug::_Error_formatter::_M_at(__FILE__, __LINE__) \ + ._ErrorMessage._M_error(); \ + } while (false) + +// Verify that [_First, _Last) forms a valid iterator range. +#define __glibcxx_check_valid_range(_First,_Last) \ +_GLIBCXX_DEBUG_VERIFY(__gnu_debug::__valid_range(_First, _Last), \ + _M_message(__gnu_debug::__msg_valid_range) \ + ._M_iterator(_First, #_First) \ + ._M_iterator(_Last, #_Last)) + +/** Verify that we can insert into *this with the iterator _Position. + * Insertion into a container at a specific position requires that + * the iterator be nonsingular (i.e., either dereferenceable or + * past-the-end) and that it reference the sequence we are inserting + * into. Note that this macro is only valid when the container is a + * _Safe_sequence and the iterator is a _Safe_iterator. +*/ +#define __glibcxx_check_insert(_Position) \ +_GLIBCXX_DEBUG_VERIFY(!_Position._M_singular(), \ + _M_message(__gnu_debug::__msg_insert_singular) \ + ._M_sequence(*this, "this") \ + ._M_iterator(_Position, #_Position)); \ +_GLIBCXX_DEBUG_VERIFY(_Position._M_attached_to(this), \ + _M_message(__gnu_debug::__msg_insert_different) \ + ._M_sequence(*this, "this") \ + ._M_iterator(_Position, #_Position)) + +/** Verify that we can insert the values in the iterator range + * [_First, _Last) into *this with the iterator _Position. Insertion + * into a container at a specific position requires that the iterator + * be nonsingular (i.e., either dereferenceable or past-the-end), + * that it reference the sequence we are inserting into, and that the + * iterator range [_First, Last) is a valid (possibly empty) + * range. Note that this macro is only valid when the container is a + * _Safe_sequence and the iterator is a _Safe_iterator. + * + * @tbd We would like to be able to check for noninterference of + * _Position and the range [_First, _Last), but that can't (in + * general) be done. +*/ +#define __glibcxx_check_insert_range(_Position,_First,_Last) \ +__glibcxx_check_valid_range(_First,_Last); \ +_GLIBCXX_DEBUG_VERIFY(!_Position._M_singular(), \ + _M_message(__gnu_debug::__msg_insert_singular) \ + ._M_sequence(*this, "this") \ + ._M_iterator(_Position, #_Position)); \ +_GLIBCXX_DEBUG_VERIFY(_Position._M_attached_to(this), \ + _M_message(__gnu_debug::__msg_insert_different) \ + ._M_sequence(*this, "this") \ + ._M_iterator(_Position, #_Position)) + +/** Verify that we can erase the element referenced by the iterator + * _Position. We can erase the element if the _Position iterator is + * dereferenceable and references this sequence. +*/ +#define __glibcxx_check_erase(_Position) \ +_GLIBCXX_DEBUG_VERIFY(_Position._M_dereferenceable(), \ + _M_message(__gnu_debug::__msg_erase_bad) \ + ._M_sequence(*this, "this") \ + ._M_iterator(_Position, #_Position)); \ +_GLIBCXX_DEBUG_VERIFY(_Position._M_attached_to(this), \ + _M_message(__gnu_debug::__msg_erase_different) \ + ._M_sequence(*this, "this") \ + ._M_iterator(_Position, #_Position)) + +/** Verify that we can erase the elements in the iterator range + * [_First, _Last). We can erase the elements if [_First, _Last) is a + * valid iterator range within this sequence. +*/ +#define __glibcxx_check_erase_range(_First,_Last) \ +__glibcxx_check_valid_range(_First,_Last); \ +_GLIBCXX_DEBUG_VERIFY(_First._M_attached_to(this), \ + _M_message(__gnu_debug::__msg_erase_different) \ + ._M_sequence(*this, "this") \ + ._M_iterator(_First, #_First) \ + ._M_iterator(_Last, #_Last)) + +// Verify that the subscript _N is less than the container's size. +#define __glibcxx_check_subscript(_N) \ +_GLIBCXX_DEBUG_VERIFY(_N < this->size(), \ + _M_message(__gnu_debug::__msg_subscript_oob) \ + ._M_sequence(*this, "this") \ + ._M_integer(_N, #_N) \ + ._M_integer(this->size(), "size")) + +// Verify that the container is nonempty +#define __glibcxx_check_nonempty() \ +_GLIBCXX_DEBUG_VERIFY(! this->empty(), \ + _M_message(__gnu_debug::__msg_empty) \ + ._M_sequence(*this, "this")) + +// Verify that the < operator for elements in the sequence is a +// StrictWeakOrdering by checking that it is irreflexive. +#define __glibcxx_check_strict_weak_ordering(_First,_Last) \ +_GLIBCXX_DEBUG_ASSERT(_First == _Last || !(*_First < *_First)) + +// Verify that the predicate is StrictWeakOrdering by checking that it +// is irreflexive. +#define __glibcxx_check_strict_weak_ordering_pred(_First,_Last,_Pred) \ +_GLIBCXX_DEBUG_ASSERT(_First == _Last || !_Pred(*_First, *_First)) + + +// Verify that the iterator range [_First, _Last) is sorted +#define __glibcxx_check_sorted(_First,_Last) \ +__glibcxx_check_valid_range(_First,_Last); \ +__glibcxx_check_strict_weak_ordering(_First,_Last); \ +_GLIBCXX_DEBUG_VERIFY(__gnu_debug::__check_sorted(_First, _Last), \ + _M_message(__gnu_debug::__msg_unsorted) \ + ._M_iterator(_First, #_First) \ + ._M_iterator(_Last, #_Last)) + +/** Verify that the iterator range [_First, _Last) is sorted by the + predicate _Pred. */ +#define __glibcxx_check_sorted_pred(_First,_Last,_Pred) \ +__glibcxx_check_valid_range(_First,_Last); \ +__glibcxx_check_strict_weak_ordering_pred(_First,_Last,_Pred); \ +_GLIBCXX_DEBUG_VERIFY(__gnu_debug::__check_sorted(_First, _Last, _Pred), \ + _M_message(__gnu_debug::__msg_unsorted_pred) \ + ._M_iterator(_First, #_First) \ + ._M_iterator(_Last, #_Last) \ + ._M_string(#_Pred)) + +/** Verify that the iterator range [_First, _Last) is partitioned + w.r.t. the value _Value. */ +#define __glibcxx_check_partitioned(_First,_Last,_Value) \ +__glibcxx_check_valid_range(_First,_Last); \ +_GLIBCXX_DEBUG_VERIFY(__gnu_debug::__check_partitioned(_First, _Last, \ + _Value), \ + _M_message(__gnu_debug::__msg_unpartitioned) \ + ._M_iterator(_First, #_First) \ + ._M_iterator(_Last, #_Last) \ + ._M_string(#_Value)) + +/** Verify that the iterator range [_First, _Last) is partitioned + w.r.t. the value _Value and predicate _Pred. */ +#define __glibcxx_check_partitioned_pred(_First,_Last,_Value,_Pred) \ +__glibcxx_check_valid_range(_First,_Last); \ +_GLIBCXX_DEBUG_VERIFY(__gnu_debug::__check_partitioned(_First, _Last, \ + _Value, _Pred), \ + _M_message(__gnu_debug::__msg_unpartitioned_pred) \ + ._M_iterator(_First, #_First) \ + ._M_iterator(_Last, #_Last) \ + ._M_string(#_Pred) \ + ._M_string(#_Value)) + +// Verify that the iterator range [_First, _Last) is a heap +#define __glibcxx_check_heap(_First,_Last) \ +__glibcxx_check_valid_range(_First,_Last); \ +_GLIBCXX_DEBUG_VERIFY(std::__is_heap(_First, _Last), \ + _M_message(__gnu_debug::__msg_not_heap) \ + ._M_iterator(_First, #_First) \ + ._M_iterator(_Last, #_Last)) + +/** Verify that the iterator range [_First, _Last) is a heap + w.r.t. the predicate _Pred. */ +#define __glibcxx_check_heap_pred(_First,_Last,_Pred) \ +__glibcxx_check_valid_range(_First,_Last); \ +_GLIBCXX_DEBUG_VERIFY(std::__is_heap(_First, _Last, _Pred), \ + _M_message(__gnu_debug::__msg_not_heap_pred) \ + ._M_iterator(_First, #_First) \ + ._M_iterator(_Last, #_Last) \ + ._M_string(#_Pred)) + +#ifdef _GLIBCXX_DEBUG_PEDANTIC +# define __glibcxx_check_string(_String) _GLIBCXX_DEBUG_ASSERT(_String != 0) +# define __glibcxx_check_string_len(_String,_Len) \ + _GLIBCXX_DEBUG_ASSERT(_String != 0 || _Len == 0) +#else +# define __glibcxx_check_string(_String) +# define __glibcxx_check_string_len(_String,_Len) +#endif + +#endif diff --git a/contrib/libstdc++/include/debug/map b/contrib/libstdc++/include/debug/map index 2c384048718a..2435154da2ea 100644 --- a/contrib/libstdc++/include/debug/map +++ b/contrib/libstdc++/include/debug/map @@ -1,6 +1,6 @@ // Debugging map/multimap implementation -*- C++ -*- -// Copyright (C) 2003 +// Copyright (C) 2003, 2006 // Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free @@ -16,7 +16,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software @@ -28,6 +28,10 @@ // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. +/** @file debug/map + * This file is a GNU debug extension to the Standard C++ Library. + */ + #ifndef _GLIBCXX_DEBUG_MAP #define _GLIBCXX_DEBUG_MAP 1 diff --git a/contrib/libstdc++/include/debug/map.h b/contrib/libstdc++/include/debug/map.h index 017158479d1c..96591ca15c8a 100644 --- a/contrib/libstdc++/include/debug/map.h +++ b/contrib/libstdc++/include/debug/map.h @@ -1,6 +1,6 @@ // Debugging map implementation -*- C++ -*- -// Copyright (C) 2003, 2004 +// Copyright (C) 2003, 2004, 2005 // Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free @@ -16,7 +16,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software @@ -28,6 +28,10 @@ // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. +/** @file debug/map.h + * This file is a GNU debug extension to the Standard C++ Library. + */ + #ifndef _GLIBCXX_DEBUG_MAP_H #define _GLIBCXX_DEBUG_MAP_H 1 @@ -35,7 +39,9 @@ #include <debug/safe_iterator.h> #include <utility> -namespace __gnu_debug_def +namespace std +{ +namespace __debug { template<typename _Key, typename _Tp, typename _Compare = std::less<_Key>, typename _Allocator = std::allocator<std::pair<const _Key, _Tp> > > @@ -53,8 +59,8 @@ namespace __gnu_debug_def typedef std::pair<const _Key, _Tp> value_type; typedef _Compare key_compare; typedef _Allocator allocator_type; - typedef typename _Allocator::reference reference; - typedef typename _Allocator::const_reference const_reference; + typedef typename _Base::reference reference; + typedef typename _Base::const_reference const_reference; typedef __gnu_debug::_Safe_iterator<typename _Base::iterator, map> iterator; @@ -63,8 +69,8 @@ namespace __gnu_debug_def typedef typename _Base::size_type size_type; typedef typename _Base::difference_type difference_type; - typedef typename _Allocator::pointer pointer; - typedef typename _Allocator::const_pointer const_pointer; + typedef typename _Base::pointer pointer; + typedef typename _Base::const_pointer const_pointer; typedef std::reverse_iterator<iterator> reverse_iterator; typedef std::reverse_iterator<const_iterator> const_reverse_iterator; @@ -142,6 +148,10 @@ namespace __gnu_debug_def // 23.3.1.2 element access: using _Base::operator[]; + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // DR 464. Suggestion for new member functions in standard containers. + using _Base::at; + // modifiers: std::pair<iterator, bool> insert(const value_type& __x) @@ -318,6 +328,7 @@ namespace __gnu_debug_def swap(map<_Key,_Tp,_Compare,_Allocator>& __lhs, map<_Key,_Tp,_Compare,_Allocator>& __rhs) { __lhs.swap(__rhs); } -} // namespace __gnu_debug_def +} // namespace __debug +} // namespace std #endif diff --git a/contrib/libstdc++/include/debug/multimap.h b/contrib/libstdc++/include/debug/multimap.h index 4de1e3b58f47..cbd6704520f2 100644 --- a/contrib/libstdc++/include/debug/multimap.h +++ b/contrib/libstdc++/include/debug/multimap.h @@ -1,6 +1,6 @@ // Debugging multimap implementation -*- C++ -*- -// Copyright (C) 2003, 2004 +// Copyright (C) 2003, 2004, 2005 // Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free @@ -16,7 +16,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software @@ -28,6 +28,10 @@ // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. +/** @file debug/multimap.h + * This file is a GNU debug extension to the Standard C++ Library. + */ + #ifndef _GLIBCXX_DEBUG_MULTIMAP_H #define _GLIBCXX_DEBUG_MULTIMAP_H 1 @@ -35,7 +39,9 @@ #include <debug/safe_iterator.h> #include <utility> -namespace __gnu_debug_def +namespace std +{ +namespace __debug { template<typename _Key, typename _Tp, typename _Compare = std::less<_Key>, typename _Allocator = std::allocator<std::pair<const _Key, _Tp> > > @@ -53,8 +59,8 @@ namespace __gnu_debug_def typedef std::pair<const _Key, _Tp> value_type; typedef _Compare key_compare; typedef _Allocator allocator_type; - typedef typename _Allocator::reference reference; - typedef typename _Allocator::const_reference const_reference; + typedef typename _Base::reference reference; + typedef typename _Base::const_reference const_reference; typedef __gnu_debug::_Safe_iterator<typename _Base::iterator, multimap> iterator; @@ -63,8 +69,8 @@ namespace __gnu_debug_def typedef typename _Base::size_type size_type; typedef typename _Base::difference_type difference_type; - typedef typename _Allocator::pointer pointer; - typedef typename _Allocator::const_pointer const_pointer; + typedef typename _Base::pointer pointer; + typedef typename _Base::const_pointer const_pointer; typedef std::reverse_iterator<iterator> reverse_iterator; typedef std::reverse_iterator<const_iterator> const_reverse_iterator; @@ -309,6 +315,7 @@ namespace __gnu_debug_def swap(multimap<_Key,_Tp,_Compare,_Allocator>& __lhs, multimap<_Key,_Tp,_Compare,_Allocator>& __rhs) { __lhs.swap(__rhs); } -} // namespace __gnu_debug_def +} // namespace __debug +} // namespace std #endif diff --git a/contrib/libstdc++/include/debug/multiset.h b/contrib/libstdc++/include/debug/multiset.h index 92042fef68ce..a37099e1ac80 100644 --- a/contrib/libstdc++/include/debug/multiset.h +++ b/contrib/libstdc++/include/debug/multiset.h @@ -1,6 +1,6 @@ // Debugging multiset implementation -*- C++ -*- -// Copyright (C) 2003, 2004 +// Copyright (C) 2003, 2004, 2005 // Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free @@ -16,7 +16,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software @@ -28,6 +28,10 @@ // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. +/** @file debug/multiset.h + * This file is a GNU debug extension to the Standard C++ Library. + */ + #ifndef _GLIBCXX_DEBUG_MULTISET_H #define _GLIBCXX_DEBUG_MULTISET_H 1 @@ -35,7 +39,9 @@ #include <debug/safe_iterator.h> #include <utility> -namespace __gnu_debug_def +namespace std +{ +namespace __debug { template<typename _Key, typename _Compare = std::less<_Key>, typename _Allocator = std::allocator<_Key> > @@ -53,8 +59,8 @@ namespace __gnu_debug_def typedef _Compare key_compare; typedef _Compare value_compare; typedef _Allocator allocator_type; - typedef typename _Allocator::reference reference; - typedef typename _Allocator::const_reference const_reference; + typedef typename _Base::reference reference; + typedef typename _Base::const_reference const_reference; typedef __gnu_debug::_Safe_iterator<typename _Base::iterator, multiset> iterator; @@ -63,8 +69,8 @@ namespace __gnu_debug_def typedef typename _Base::size_type size_type; typedef typename _Base::difference_type difference_type; - typedef typename _Allocator::pointer pointer; - typedef typename _Allocator::const_pointer const_pointer; + typedef typename _Base::pointer pointer; + typedef typename _Base::const_pointer const_pointer; typedef std::reverse_iterator<iterator> reverse_iterator; typedef std::reverse_iterator<const_iterator> const_reverse_iterator; @@ -315,6 +321,7 @@ namespace __gnu_debug_def swap(multiset<_Key,_Compare,_Allocator>& __x, multiset<_Key,_Compare,_Allocator>& __y) { return __x.swap(__y); } -} // namespace __gnu_debug_def +} // namespace __debug +} // namespace std #endif diff --git a/contrib/libstdc++/include/debug/safe_base.h b/contrib/libstdc++/include/debug/safe_base.h index a1af33ac5f77..2d26f57a396c 100644 --- a/contrib/libstdc++/include/debug/safe_base.h +++ b/contrib/libstdc++/include/debug/safe_base.h @@ -1,6 +1,6 @@ // Safe sequence/iterator base implementation -*- C++ -*- -// Copyright (C) 2003, 2004 +// Copyright (C) 2003, 2004, 2005, 2006 // Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free @@ -16,7 +16,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software @@ -28,9 +28,15 @@ // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. +/** @file debug/safe_base.h + * This file is a GNU debug extension to the Standard C++ Library. + */ + #ifndef _GLIBCXX_DEBUG_SAFE_BASE_H #define _GLIBCXX_DEBUG_SAFE_BASE_H 1 +#include <ext/concurrence.h> + namespace __gnu_debug { class _Safe_sequence_base; @@ -103,6 +109,9 @@ namespace __gnu_debug ~_Safe_iterator_base() { this->_M_detach(); } + /** For use in _Safe_iterator. */ + __gnu_cxx::__mutex& _M_get_mutex(); + public: /** Attaches this iterator to the given sequence, detaching it * from whatever sequence it was attached to originally. If the @@ -111,11 +120,17 @@ namespace __gnu_debug */ void _M_attach(_Safe_sequence_base* __seq, bool __constant); + /** Likewise, but not thread-safe. */ + void _M_attach_single(_Safe_sequence_base* __seq, bool __constant); + /** Detach the iterator for whatever sequence it is attached to, * if any. */ void _M_detach(); + /** Likewise, but not thread-safe. */ + void _M_detach_single(); + /** Determines if we are attached to the given sequence. */ bool _M_attached_to(const _Safe_sequence_base* __seq) const { return _M_sequence == __seq; } @@ -196,6 +211,9 @@ namespace __gnu_debug void _M_swap(_Safe_sequence_base& __x); + /** For use in _Safe_sequence. */ + __gnu_cxx::__mutex& _M_get_mutex(); + public: /** Invalidates all iterators. */ void diff --git a/contrib/libstdc++/include/debug/safe_iterator.h b/contrib/libstdc++/include/debug/safe_iterator.h index 8a4123af6944..3d8ba59419b1 100644 --- a/contrib/libstdc++/include/debug/safe_iterator.h +++ b/contrib/libstdc++/include/debug/safe_iterator.h @@ -1,6 +1,6 @@ // Safe iterator implementation -*- C++ -*- -// Copyright (C) 2003, 2004 +// Copyright (C) 2003, 2004, 2005, 2006 // Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free @@ -16,7 +16,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software @@ -28,25 +28,29 @@ // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. +/** @file debug/safe_iterator.h + * This file is a GNU debug extension to the Standard C++ Library. + */ + #ifndef _GLIBCXX_DEBUG_SAFE_ITERATOR_H #define _GLIBCXX_DEBUG_SAFE_ITERATOR_H 1 -#include <bits/stl_pair.h> #include <debug/debug.h> +#include <debug/macros.h> +#include <debug/functions.h> #include <debug/formatter.h> #include <debug/safe_base.h> -#include <bits/cpp_type_traits.h> +#include <bits/stl_pair.h> +#include <ext/type_traits.h> namespace __gnu_debug { - using std::iterator_traits; - using std::pair; - /** Iterators that derive from _Safe_iterator_base but that aren't * _Safe_iterators can be determined singular or non-singular via * _Safe_iterator_base. */ - inline bool __check_singular_aux(const _Safe_iterator_base* __x) + inline bool + __check_singular_aux(const _Safe_iterator_base* __x) { return __x->_M_singular(); } /** \brief Safe iterator wrapper. @@ -86,7 +90,7 @@ namespace __gnu_debug return __is_same<const_iterator, _Safe_iterator>::value; } - typedef iterator_traits<_Iterator> _Traits; + typedef std::iterator_traits<_Iterator> _Traits; public: typedef _Iterator _Base_iterator; @@ -136,11 +140,9 @@ namespace __gnu_debug template<typename _MutableIterator> _Safe_iterator( const _Safe_iterator<_MutableIterator, - typename std::__enable_if< - _Sequence, - (std::__are_same<_MutableIterator, - typename _Sequence::iterator::_Base_iterator>::_M_type) - >::_M_type>& __x) + typename __gnu_cxx::__enable_if<(std::__are_same<_MutableIterator, + typename _Sequence::iterator::_Base_iterator>::__value), + _Sequence>::__type>& __x) : _Safe_iterator_base(__x, _M_constant()), _M_current(__x.base()) { _GLIBCXX_DEBUG_VERIFY(!__x._M_singular(), @@ -323,10 +325,22 @@ namespace __gnu_debug _M_constant()); } + /** Likewise, but not thread-safe. */ + void + _M_attach_single(const _Sequence* __seq) + { + _Safe_iterator_base::_M_attach_single(const_cast<_Sequence*>(__seq), + _M_constant()); + } + /** Invalidate the iterator, making it singular. */ void _M_invalidate(); + /** Likewise, but not thread-safe. */ + void + _M_invalidate_single(); + /// Is the iterator dereferenceable? bool _M_dereferenceable() const @@ -358,16 +372,16 @@ namespace __gnu_debug * precision. */ template<typename _Iterator1, typename _Iterator2> - static pair<difference_type, _Distance_precision> + static std::pair<difference_type, _Distance_precision> _M_get_distance(const _Iterator1& __lhs, const _Iterator2& __rhs) { - typedef typename iterator_traits<_Iterator1>::iterator_category + typedef typename std::iterator_traits<_Iterator1>::iterator_category _Category; return _M_get_distance(__lhs, __rhs, _Category()); } template<typename _Iterator1, typename _Iterator2> - static pair<difference_type, _Distance_precision> + static std::pair<difference_type, _Distance_precision> _M_get_distance(const _Iterator1& __lhs, const _Iterator2& __rhs, std::random_access_iterator_tag) { @@ -375,7 +389,7 @@ namespace __gnu_debug } template<typename _Iterator1, typename _Iterator2> - static pair<difference_type, _Distance_precision> + static std::pair<difference_type, _Distance_precision> _M_get_distance(const _Iterator1& __lhs, const _Iterator2& __rhs, std::forward_iterator_tag) { @@ -604,6 +618,22 @@ namespace __gnu_debug return __lhs.base() - __rhs.base(); } + template<typename _Iterator, typename _Sequence> + inline typename _Safe_iterator<_Iterator, _Sequence>::difference_type + operator-(const _Safe_iterator<_Iterator, _Sequence>& __lhs, + const _Safe_iterator<_Iterator, _Sequence>& __rhs) + { + _GLIBCXX_DEBUG_VERIFY(! __lhs._M_singular() && ! __rhs._M_singular(), + _M_message(__msg_distance_bad) + ._M_iterator(__lhs, "lhs") + ._M_iterator(__rhs, "rhs")); + _GLIBCXX_DEBUG_VERIFY(__lhs._M_can_compare(__rhs), + _M_message(__msg_distance_different) + ._M_iterator(__lhs, "lhs") + ._M_iterator(__rhs, "rhs")); + return __lhs.base() - __rhs.base(); + } + template<typename _Iterator, typename _Sequence> inline _Safe_iterator<_Iterator, _Sequence> operator+(typename _Safe_iterator<_Iterator,_Sequence>::difference_type __n, diff --git a/contrib/libstdc++/include/debug/safe_iterator.tcc b/contrib/libstdc++/include/debug/safe_iterator.tcc index cede969d168d..d23e90f048aa 100644 --- a/contrib/libstdc++/include/debug/safe_iterator.tcc +++ b/contrib/libstdc++/include/debug/safe_iterator.tcc @@ -1,6 +1,6 @@ // Debugging iterator implementation (out of line) -*- C++ -*- -// Copyright (C) 2003, 2004 +// Copyright (C) 2003, 2004, 2005, 2006 // Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free @@ -16,7 +16,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software @@ -28,9 +28,8 @@ // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. -/** @file safe_iterator.tcc - * This is an internal header file, included by other library headers. - * You should not attempt to use it directly. +/** @file debug/safe_iterator.tcc + * This file is a GNU debug extension to the Standard C++ Library. */ #ifndef _GLIBCXX_DEBUG_SAFE_ITERATOR_TCC @@ -53,7 +52,7 @@ namespace __gnu_debug { const_iterator __begin = static_cast<const _Sequence*>(_M_sequence)->begin(); - pair<difference_type, _Distance_precision> __dist = + std::pair<difference_type, _Distance_precision> __dist = this->_M_get_distance(__begin, *this); bool __ok = (__dist.second == __dp_exact && __dist.first >= -__n || __dist.second != __dp_exact && __dist.first > 0); @@ -63,7 +62,7 @@ namespace __gnu_debug { const_iterator __end = static_cast<const _Sequence*>(_M_sequence)->end(); - pair<difference_type, _Distance_precision> __dist = + std::pair<difference_type, _Distance_precision> __dist = this->_M_get_distance(*this, __end); bool __ok = (__dist.second == __dp_exact && __dist.first >= __n || __dist.second != __dp_exact && __dist.first > 0); @@ -82,7 +81,7 @@ namespace __gnu_debug /* Determine if we can order the iterators without the help of the container */ - pair<difference_type, _Distance_precision> __dist = + std::pair<difference_type, _Distance_precision> __dist = this->_M_get_distance(*this, __rhs); switch (__dist.second) { case __dp_equality: @@ -111,24 +110,33 @@ namespace __gnu_debug _Safe_iterator<_Iterator, _Sequence>:: _M_invalidate() { + __gnu_cxx::__scoped_lock sentry(this->_M_get_mutex()); + _M_invalidate_single(); + } + + template<typename _Iterator, typename _Sequence> + void + _Safe_iterator<_Iterator, _Sequence>:: + _M_invalidate_single() + { typedef typename _Sequence::iterator iterator; typedef typename _Sequence::const_iterator const_iterator; if (!this->_M_singular()) { - for (_Safe_iterator_base* iter = _M_sequence->_M_iterators; iter; ) + for (_Safe_iterator_base* __iter = _M_sequence->_M_iterators; + __iter; __iter = __iter->_M_next) { - iterator* __victim = static_cast<iterator*>(iter); - iter = iter->_M_next; + iterator* __victim = static_cast<iterator*>(__iter); if (this->base() == __victim->base()) __victim->_M_version = 0; } - for (_Safe_iterator_base* iter2 = _M_sequence->_M_const_iterators; - iter2; /* increment in loop */) + + for (_Safe_iterator_base* __iter2 = _M_sequence->_M_const_iterators; + __iter2; __iter2 = __iter2->_M_next) { - const_iterator* __victim = static_cast<const_iterator*>(iter2); - iter2 = iter2->_M_next; - if (this->base() == __victim->base()) + const_iterator* __victim = static_cast<const_iterator*>(__iter2); + if (__victim->base() == this->base()) __victim->_M_version = 0; } _M_version = 0; diff --git a/contrib/libstdc++/include/debug/safe_sequence.h b/contrib/libstdc++/include/debug/safe_sequence.h index f050530a997c..b5d6cce320dc 100644 --- a/contrib/libstdc++/include/debug/safe_sequence.h +++ b/contrib/libstdc++/include/debug/safe_sequence.h @@ -1,6 +1,6 @@ // Safe sequence implementation -*- C++ -*- -// Copyright (C) 2003, 2004 +// Copyright (C) 2003, 2004, 2005, 2006 // Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free @@ -16,7 +16,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software @@ -28,10 +28,16 @@ // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. +/** @file debug/safe_sequence.h + * This file is a GNU debug extension to the Standard C++ Library. + */ + #ifndef _GLIBCXX_DEBUG_SAFE_SEQUENCE_H #define _GLIBCXX_DEBUG_SAFE_SEQUENCE_H 1 #include <debug/debug.h> +#include <debug/macros.h> +#include <debug/functions.h> #include <debug/safe_base.h> namespace __gnu_debug @@ -122,27 +128,28 @@ namespace __gnu_debug typedef typename _Sequence::iterator iterator; typedef typename _Sequence::const_iterator const_iterator; - for (_Safe_iterator_base* __iter = _M_iterators; __iter; ) - { - iterator* __victim = static_cast<iterator*>(__iter); - __iter = __iter->_M_next; - if (!__victim->_M_singular()) - { - if (__pred(__victim->base())) - __victim->_M_invalidate(); - } - } - - for (_Safe_iterator_base* __iter2 = _M_const_iterators; __iter2; ) - { - const_iterator* __victim = static_cast<const_iterator*>(__iter2); - __iter2 = __iter2->_M_next; - if (!__victim->_M_singular()) - { - if (__pred(__victim->base())) - __victim->_M_invalidate(); - } - } + __gnu_cxx::__scoped_lock sentry(this->_M_get_mutex()); + for (_Safe_iterator_base* __iter = _M_iterators; __iter;) + { + iterator* __victim = static_cast<iterator*>(__iter); + __iter = __iter->_M_next; + if (!__victim->_M_singular()) + { + if (__pred(__victim->base())) + __victim->_M_invalidate_single(); + } + } + + for (_Safe_iterator_base* __iter2 = _M_const_iterators; __iter2;) + { + const_iterator* __victim = static_cast<const_iterator*>(__iter2); + __iter2 = __iter2->_M_next; + if (!__victim->_M_singular()) + { + if (__pred(__victim->base())) + __victim->_M_invalidate_single(); + } + } } template<typename _Sequence> @@ -158,22 +165,23 @@ namespace __gnu_debug typedef typename _Sequence::iterator iterator; typedef typename _Sequence::const_iterator const_iterator; - for (_Safe_iterator_base* __iter = __from->_M_iterators; __iter; ) - { - iterator* __victim = static_cast<iterator*>(__iter); - __iter = __iter->_M_next; - if (!__victim->_M_singular() && __victim->base() == __x.base()) - __victim->_M_attach(static_cast<_Sequence*>(this)); - } + __gnu_cxx::__scoped_lock sentry(this->_M_get_mutex()); + for (_Safe_iterator_base* __iter = __from->_M_iterators; __iter;) + { + iterator* __victim = static_cast<iterator*>(__iter); + __iter = __iter->_M_next; + if (!__victim->_M_singular() && __victim->base() == __x.base()) + __victim->_M_attach_single(static_cast<_Sequence*>(this)); + } for (_Safe_iterator_base* __iter2 = __from->_M_const_iterators; __iter2;) - { - const_iterator* __victim = static_cast<const_iterator*>(__iter2); - __iter2 = __iter2->_M_next; - if (!__victim->_M_singular() && __victim->base() == __x.base()) - __victim->_M_attach(static_cast<_Sequence*>(this)); - } + { + const_iterator* __victim = static_cast<const_iterator*>(__iter2); + __iter2 = __iter2->_M_next; + if (!__victim->_M_singular() && __victim->base() == __x.base()) + __victim->_M_attach_single(static_cast<_Sequence*>(this)); + } } } // namespace __gnu_debug diff --git a/contrib/libstdc++/include/debug/set b/contrib/libstdc++/include/debug/set index a1a69efb4f4c..e5f4e37afb77 100644 --- a/contrib/libstdc++/include/debug/set +++ b/contrib/libstdc++/include/debug/set @@ -16,7 +16,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software @@ -28,6 +28,10 @@ // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. +/** @file debug/set + * This file is a GNU debug extension to the Standard C++ Library. + */ + #ifndef _GLIBCXX_DEBUG_SET #define _GLIBCXX_DEBUG_SET 1 diff --git a/contrib/libstdc++/include/debug/set.h b/contrib/libstdc++/include/debug/set.h index 8656cb0aff67..6c2ce9fd1fc6 100644 --- a/contrib/libstdc++/include/debug/set.h +++ b/contrib/libstdc++/include/debug/set.h @@ -1,6 +1,6 @@ // Debugging set implementation -*- C++ -*- -// Copyright (C) 2003, 2004 +// Copyright (C) 2003, 2004, 2005 // Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free @@ -16,7 +16,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software @@ -28,6 +28,10 @@ // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. +/** @file debug/set.h + * This file is a GNU debug extension to the Standard C++ Library. + */ + #ifndef _GLIBCXX_DEBUG_SET_H #define _GLIBCXX_DEBUG_SET_H 1 @@ -35,7 +39,9 @@ #include <debug/safe_iterator.h> #include <utility> -namespace __gnu_debug_def +namespace std +{ +namespace __debug { template<typename _Key, typename _Compare = std::less<_Key>, typename _Allocator = std::allocator<_Key> > @@ -53,8 +59,8 @@ namespace __gnu_debug_def typedef _Compare key_compare; typedef _Compare value_compare; typedef _Allocator allocator_type; - typedef typename _Allocator::reference reference; - typedef typename _Allocator::const_reference const_reference; + typedef typename _Base::reference reference; + typedef typename _Base::const_reference const_reference; typedef __gnu_debug::_Safe_iterator<typename _Base::iterator, set> iterator; @@ -63,8 +69,8 @@ namespace __gnu_debug_def typedef typename _Base::size_type size_type; typedef typename _Base::difference_type difference_type; - typedef typename _Allocator::pointer pointer; - typedef typename _Allocator::const_pointer const_pointer; + typedef typename _Base::pointer pointer; + typedef typename _Base::const_pointer const_pointer; typedef std::reverse_iterator<iterator> reverse_iterator; typedef std::reverse_iterator<const_iterator> const_reverse_iterator; @@ -320,6 +326,7 @@ namespace __gnu_debug_def swap(set<_Key,_Compare,_Allocator>& __x, set<_Key,_Compare,_Allocator>& __y) { return __x.swap(__y); } -} // namespace __gnu_debug_def +} // namespace __debug +} // namespace std #endif diff --git a/contrib/libstdc++/include/debug/string b/contrib/libstdc++/include/debug/string index a91c004e9379..070ca1fe58b7 100644 --- a/contrib/libstdc++/include/debug/string +++ b/contrib/libstdc++/include/debug/string @@ -1,6 +1,6 @@ // Debugging string implementation -*- C++ -*- -// Copyright (C) 2003 +// Copyright (C) 2003, 2005, 2006 // Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free @@ -16,7 +16,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software @@ -28,6 +28,10 @@ // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. +/** @file debug/string + * This file is a GNU debug extension to the Standard C++ Library. + */ + #ifndef _GLIBCXX_DEBUG_STRING #define _GLIBCXX_DEBUG_STRING 1 @@ -37,7 +41,8 @@ namespace __gnu_debug { - template<typename _CharT, typename _Traits, typename _Allocator> + template<typename _CharT, typename _Traits = std::char_traits<_CharT>, + typename _Allocator = std::allocator<_CharT> > class basic_string : public std::basic_string<_CharT, _Traits, _Allocator>, public __gnu_debug::_Safe_sequence<basic_string<_CharT, _Traits, @@ -51,12 +56,12 @@ namespace __gnu_debug typedef _Traits traits_type; typedef typename _Traits::char_type value_type; typedef _Allocator allocator_type; - typedef typename _Allocator::size_type size_type; - typedef typename _Allocator::difference_type difference_type; - typedef typename _Allocator::reference reference; - typedef typename _Allocator::const_reference const_reference; - typedef typename _Allocator::pointer pointer; - typedef typename _Allocator::const_pointer const_pointer; + typedef typename _Base::size_type size_type; + typedef typename _Base::difference_type difference_type; + typedef typename _Base::reference reference; + typedef typename _Base::const_reference const_reference; + typedef typename _Base::pointer pointer; + typedef typename _Base::const_pointer const_pointer; typedef __gnu_debug::_Safe_iterator<typename _Base::iterator, basic_string> iterator; @@ -203,7 +208,7 @@ namespace __gnu_debug operator[](size_type __pos) const { _GLIBCXX_DEBUG_VERIFY(__pos <= this->size(), - _M_message(::__gnu_debug::__msg_subscript_oob) + _M_message(__gnu_debug::__msg_subscript_oob) ._M_sequence(*this, "this") ._M_integer(__pos, "__pos") ._M_integer(this->size(), "size")); @@ -213,7 +218,16 @@ namespace __gnu_debug reference operator[](size_type __pos) { +#ifdef _GLIBCXX_DEBUG_PEDANTIC __glibcxx_check_subscript(__pos); +#else + // as an extension v3 allows s[s.size()] when s is non-const. + _GLIBCXX_DEBUG_VERIFY(__pos <= this->size(), + _M_message(__gnu_debug::__msg_subscript_oob) + ._M_sequence(*this, "this") + ._M_integer(__pos, "__pos") + ._M_integer(this->size(), "size")); +#endif return _M_base()[__pos]; } @@ -652,7 +666,8 @@ namespace __gnu_debug { return _Base::find_first_of(__c, __pos); } size_type - find_last_of(const basic_string& __str, size_type __pos = _Base::npos) const + find_last_of(const basic_string& __str, + size_type __pos = _Base::npos) const { return _Base::find_last_of(__str, __pos); } size_type @@ -996,6 +1011,13 @@ namespace __gnu_debug __str._M_invalidate_all(); return __res; } + + typedef basic_string<char> string; + +#ifdef _GLIBCXX_USE_WCHAR_T + typedef basic_string<wchar_t> wstring; +#endif + } // namespace __gnu_debug #endif diff --git a/contrib/libstdc++/include/debug/vector b/contrib/libstdc++/include/debug/vector index 0cc2997b9754..33b8b638a779 100644 --- a/contrib/libstdc++/include/debug/vector +++ b/contrib/libstdc++/include/debug/vector @@ -1,6 +1,6 @@ // Debugging vector implementation -*- C++ -*- -// Copyright (C) 2003, 2004 +// Copyright (C) 2003, 2004, 2005 // Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free @@ -16,7 +16,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software @@ -28,15 +28,21 @@ // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. +/** @file debug/vector + * This file is a GNU debug extension to the Standard C++ Library. + */ + #ifndef _GLIBCXX_DEBUG_VECTOR #define _GLIBCXX_DEBUG_VECTOR 1 #include <vector> +#include <utility> #include <debug/safe_sequence.h> #include <debug/safe_iterator.h> -#include <utility> -namespace __gnu_debug_def +namespace std +{ +namespace __debug { template<typename _Tp, typename _Allocator = std::allocator<_Tp> > @@ -64,8 +70,8 @@ namespace __gnu_debug_def typedef _Tp value_type; typedef _Allocator allocator_type; - typedef typename _Allocator::pointer pointer; - typedef typename _Allocator::const_pointer const_pointer; + typedef typename _Base::pointer pointer; + typedef typename _Base::const_pointer const_pointer; typedef std::reverse_iterator<iterator> reverse_iterator; typedef std::reverse_iterator<const_iterator> const_reverse_iterator; @@ -230,6 +236,10 @@ namespace __gnu_debug_def return _Base::back(); } + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // DR 464. Suggestion for new member functions in standard containers. + using _Base::data; + // 23.2.4.3 modifiers: void push_back(const _Tp& __x) @@ -407,6 +417,7 @@ namespace __gnu_debug_def inline void swap(vector<_Tp, _Alloc>& __lhs, vector<_Tp, _Alloc>& __rhs) { __lhs.swap(__rhs); } -} // namespace __gnu_debug_def +} // namespace __debug +} // namespace std #endif |