diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index a1e6e306cdb..70d304c7aca 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,20 @@ +2007-05-04 Paolo Carlini + + * include/bits/stl_memory.h: Rename to stl_auto_ptr.h. + (__get_temporary_buffer, get_temporary_buffer, + return_temporary_buffer): Move... + * include/bits/stl_tempbuf.h: ... here. + * include/std/memory: Adjust includes. + * testsuite/20_util/auto_ptr/assign_neg.cc: Adjust dg-error line + numbers. + * include/Makefile.am: Adjust. + * include/Makefile.in: Regenerate. + + * testsuite/util/testsuite_iterators.h: Do not include the entire + . + * include/bits/stl_iterator_base_types.h: Adjust includes. + * testsuite/25_algorithms/unique_copy/2.cc: Include . + 2007-05-04 Mark Mitchell * libsupc++/atexit_arm.cc: New file. diff --git a/libstdc++-v3/include/Makefile.am b/libstdc++-v3/include/Makefile.am index ea27464432e..cfa995e4000 100644 --- a/libstdc++-v3/include/Makefile.am +++ b/libstdc++-v3/include/Makefile.am @@ -115,7 +115,7 @@ bits_headers = \ ${bits_srcdir}/stl_iterator_base_types.h \ ${bits_srcdir}/stl_list.h \ ${bits_srcdir}/stl_map.h \ - ${bits_srcdir}/stl_memory.h \ + ${bits_srcdir}/stl_auto_ptr.h \ ${bits_srcdir}/stl_multimap.h \ ${bits_srcdir}/stl_multiset.h \ ${bits_srcdir}/stl_numeric.h \ diff --git a/libstdc++-v3/include/Makefile.in b/libstdc++-v3/include/Makefile.in index 4402d84c67f..c14ac8bbe23 100644 --- a/libstdc++-v3/include/Makefile.in +++ b/libstdc++-v3/include/Makefile.in @@ -349,7 +349,7 @@ bits_headers = \ ${bits_srcdir}/stl_iterator_base_types.h \ ${bits_srcdir}/stl_list.h \ ${bits_srcdir}/stl_map.h \ - ${bits_srcdir}/stl_memory.h \ + ${bits_srcdir}/stl_auto_ptr.h \ ${bits_srcdir}/stl_multimap.h \ ${bits_srcdir}/stl_multiset.h \ ${bits_srcdir}/stl_numeric.h \ diff --git a/libstdc++-v3/include/bits/stl_memory.h b/libstdc++-v3/include/bits/stl_auto_ptr.h similarity index 80% rename from libstdc++-v3/include/bits/stl_memory.h rename to libstdc++-v3/include/bits/stl_auto_ptr.h index 7dbd32324e4..6e0f9c7e2ae 100644 --- a/libstdc++-v3/include/bits/stl_memory.h +++ b/libstdc++-v3/include/bits/stl_auto_ptr.h @@ -1,4 +1,4 @@ -// Memory implementation -*- C++ -*- +// auto_ptr implementation -*- C++ -*- // Copyright (C) 2007 Free Software Foundation, Inc. // @@ -27,85 +27,19 @@ // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. -/** @file stl_memory.h +/** @file stl_auto_ptr.h * This is an internal header file, included by other library headers. * You should not attempt to use it directly. */ -#ifndef _STL_MEMORY_H -#define _STL_MEMORY_H 1 +#ifndef _STL_AUTO_PTR_H +#define _STL_AUTO_PTR_H 1 -#include -#include -#include -#include -#include +#include #include _GLIBCXX_BEGIN_NAMESPACE(std) - /** - * @if maint - * This is a helper function. The unused second parameter exists to - * permit the real get_temporary_buffer to use template parameter deduction. - * - * XXX This should perhaps use the pool. - * @endif - */ - template - pair<_Tp*, ptrdiff_t> - __get_temporary_buffer(ptrdiff_t __len, _Tp*) - { - const ptrdiff_t __max = - __gnu_cxx::__numeric_traits::__max / sizeof(_Tp); - if (__len > __max) - __len = __max; - - while (__len > 0) - { - _Tp* __tmp = static_cast<_Tp*>(::operator new(__len * sizeof(_Tp), - nothrow)); - if (__tmp != 0) - return pair<_Tp*, ptrdiff_t>(__tmp, __len); - __len /= 2; - } - return pair<_Tp*, ptrdiff_t>(static_cast<_Tp*>(0), 0); - } - - /** - * @brief Allocates a temporary buffer. - * @param len The number of objects of type Tp. - * @return See full description. - * - * Reinventing the wheel, but this time with prettier spokes! - * - * This function tries to obtain storage for @c len adjacent Tp - * objects. The objects themselves are not constructed, of course. - * A pair<> is returned containing "the buffer s address and - * capacity (in the units of sizeof(Tp)), or a pair of 0 values if - * no storage can be obtained." Note that the capacity obtained - * may be less than that requested if the memory is unavailable; - * you should compare len with the .second return value. - * - * Provides the nothrow exception guarantee. - */ - template - inline pair<_Tp*, ptrdiff_t> - get_temporary_buffer(ptrdiff_t __len) - { return std::__get_temporary_buffer(__len, static_cast<_Tp*>(0)); } - - /** - * @brief The companion to get_temporary_buffer(). - * @param p A buffer previously allocated by get_temporary_buffer. - * @return None. - * - * Frees the memory pointed to by p. - */ - template - void - return_temporary_buffer(_Tp* __p) - { ::operator delete(__p, nothrow); } - /** * A wrapper class to provide auto_ptr with reference semantics. * For example, an auto_ptr can be assigned (or constructed from) @@ -364,4 +298,4 @@ _GLIBCXX_BEGIN_NAMESPACE(std) _GLIBCXX_END_NAMESPACE -#endif /* _STL_MEMORY_H */ +#endif /* _STL_AUTO_PTR_H */ diff --git a/libstdc++-v3/include/bits/stl_iterator_base_types.h b/libstdc++-v3/include/bits/stl_iterator_base_types.h index c02cd261d8d..1b746692eeb 100644 --- a/libstdc++-v3/include/bits/stl_iterator_base_types.h +++ b/libstdc++-v3/include/bits/stl_iterator_base_types.h @@ -1,6 +1,7 @@ // Types used in iterator implementation -*- C++ -*- -// Copyright (C) 2001, 2002, 2004, 2005 Free Software Foundation, Inc. +// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007 +// 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 @@ -66,6 +67,9 @@ #pragma GCC system_header +#include +#include + _GLIBCXX_BEGIN_NAMESPACE(std) //@{ diff --git a/libstdc++-v3/include/bits/stl_tempbuf.h b/libstdc++-v3/include/bits/stl_tempbuf.h index 5663844f143..46c733feb5c 100644 --- a/libstdc++-v3/include/bits/stl_tempbuf.h +++ b/libstdc++-v3/include/bits/stl_tempbuf.h @@ -62,10 +62,73 @@ #ifndef _TEMPBUF_H #define _TEMPBUF_H 1 -#include +#include +#include +#include _GLIBCXX_BEGIN_NAMESPACE(std) + /** + * @if maint + * This is a helper function. The unused second parameter exists to + * permit the real get_temporary_buffer to use template parameter deduction. + * @endif + */ + template + pair<_Tp*, ptrdiff_t> + __get_temporary_buffer(ptrdiff_t __len, _Tp*) + { + const ptrdiff_t __max = + __gnu_cxx::__numeric_traits::__max / sizeof(_Tp); + if (__len > __max) + __len = __max; + + while (__len > 0) + { + _Tp* __tmp = static_cast<_Tp*>(::operator new(__len * sizeof(_Tp), + std::nothrow)); + if (__tmp != 0) + return std::pair<_Tp*, ptrdiff_t>(__tmp, __len); + __len /= 2; + } + return std::pair<_Tp*, ptrdiff_t>(static_cast<_Tp*>(0), 0); + } + + /** + * @brief Allocates a temporary buffer. + * @param len The number of objects of type Tp. + * @return See full description. + * + * Reinventing the wheel, but this time with prettier spokes! + * + * This function tries to obtain storage for @c len adjacent Tp + * objects. The objects themselves are not constructed, of course. + * A pair<> is returned containing "the buffer s address and + * capacity (in the units of sizeof(Tp)), or a pair of 0 values if + * no storage can be obtained." Note that the capacity obtained + * may be less than that requested if the memory is unavailable; + * you should compare len with the .second return value. + * + * Provides the nothrow exception guarantee. + */ + template + inline pair<_Tp*, ptrdiff_t> + get_temporary_buffer(ptrdiff_t __len) + { return std::__get_temporary_buffer(__len, static_cast<_Tp*>(0)); } + + /** + * @brief The companion to get_temporary_buffer(). + * @param p A buffer previously allocated by get_temporary_buffer. + * @return None. + * + * Frees the memory pointed to by p. + */ + template + void + return_temporary_buffer(_Tp* __p) + { ::operator delete(__p, nothrow); } + + /** * @if maint * This class is used in two places: stl_algo.h and ext/memory, @@ -131,7 +194,6 @@ _GLIBCXX_BEGIN_NAMESPACE(std) operator=(const _Temporary_buffer&); }; - template _Temporary_buffer<_ForwardIterator, _Tp>:: _Temporary_buffer(_ForwardIterator __first, _ForwardIterator __last) @@ -140,8 +202,8 @@ _GLIBCXX_BEGIN_NAMESPACE(std) { try { - pair __p(get_temporary_buffer< - value_type>(_M_original_len)); + std::pair __p(std::get_temporary_buffer< + value_type>(_M_original_len)); _M_buffer = __p.first; _M_len = __p.second; if (!__is_pod(_Tp) && _M_len > 0) diff --git a/libstdc++-v3/include/std/memory b/libstdc++-v3/include/std/memory index 33bc2169f73..28b8d85d0e2 100644 --- a/libstdc++-v3/include/std/memory +++ b/libstdc++-v3/include/std/memory @@ -51,8 +51,13 @@ #pragma GCC system_header -#include -#include +#include +#include +#include +#include +#include +#include +#include #ifdef __GXX_EXPERIMENTAL_CXX0X__ # include diff --git a/libstdc++-v3/testsuite/20_util/auto_ptr/assign_neg.cc b/libstdc++-v3/testsuite/20_util/auto_ptr/assign_neg.cc index 5ce62eeac3b..ffca8986fad 100644 --- a/libstdc++-v3/testsuite/20_util/auto_ptr/assign_neg.cc +++ b/libstdc++-v3/testsuite/20_util/auto_ptr/assign_neg.cc @@ -46,5 +46,5 @@ main() test01(); return 0; } -// { dg-error "candidates" "" { target *-*-* } 207 } -// { dg-error "::auto_ptr" "" { target *-*-* } 337 } +// { dg-error "candidates" "" { target *-*-* } 141 } +// { dg-error "::auto_ptr" "" { target *-*-* } 271 } diff --git a/libstdc++-v3/testsuite/25_algorithms/unique_copy/2.cc b/libstdc++-v3/testsuite/25_algorithms/unique_copy/2.cc index 13500916542..2c67cee1e60 100644 --- a/libstdc++-v3/testsuite/25_algorithms/unique_copy/2.cc +++ b/libstdc++-v3/testsuite/25_algorithms/unique_copy/2.cc @@ -1,4 +1,4 @@ -// Copyright (C) 2006 Free Software Foundation, Inc. +// Copyright (C) 2006, 2007 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 @@ -19,6 +19,7 @@ // 25.2.8 [lib.alg.unique] #include +#include #include #include diff --git a/libstdc++-v3/testsuite/util/testsuite_iterators.h b/libstdc++-v3/testsuite/util/testsuite_iterators.h index 7119783c93b..073be0beb94 100644 --- a/libstdc++-v3/testsuite/util/testsuite_iterators.h +++ b/libstdc++-v3/testsuite/util/testsuite_iterators.h @@ -1,7 +1,7 @@ // -*- C++ -*- // Iterator Wrappers for the C++ library testsuite. // -// Copyright (C) 2004, 2005 Free Software Foundation, Inc. +// Copyright (C) 2004, 2005, 2006, 2007 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 @@ -37,7 +37,7 @@ // test_container, which is given two pointers to T and an iterator type. #include -#include +#include #ifndef _TESTSUITE_ITERATORS #define _TESTSUITE_ITERATORS