diff options
author | Paolo Carlini <pcarlini@suse.de> | 2007-05-04 18:07:10 +0000 |
---|---|---|
committer | Paolo Carlini <paolo@gcc.gnu.org> | 2007-05-04 18:07:10 +0000 |
commit | acb8a4ef2dc4120ef9e03885e58138d58db192b4 (patch) | |
tree | 30d90c7d2c5cd8fa787229dc1434e823b72f2462 | |
parent | dcdc26dfd5606c0837de979ddd9b2d6c960f5102 (diff) | |
download | gcc-acb8a4ef2dc4120ef9e03885e58138d58db192b4.zip gcc-acb8a4ef2dc4120ef9e03885e58138d58db192b4.tar.gz gcc-acb8a4ef2dc4120ef9e03885e58138d58db192b4.tar.bz2 |
stl_memory.h: Rename to stl_auto_ptr.h.
2007-05-04 Paolo Carlini <pcarlini@suse.de>
* 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
<iterator>.
* include/bits/stl_iterator_base_types.h: Adjust includes.
* testsuite/25_algorithms/unique_copy/2.cc: Include <functional>.
From-SVN: r124438
-rw-r--r-- | libstdc++-v3/ChangeLog | 17 | ||||
-rw-r--r-- | libstdc++-v3/include/Makefile.am | 2 | ||||
-rw-r--r-- | libstdc++-v3/include/Makefile.in | 2 | ||||
-rw-r--r-- | libstdc++-v3/include/bits/stl_auto_ptr.h (renamed from libstdc++-v3/include/bits/stl_memory.h) | 78 | ||||
-rw-r--r-- | libstdc++-v3/include/bits/stl_iterator_base_types.h | 6 | ||||
-rw-r--r-- | libstdc++-v3/include/bits/stl_tempbuf.h | 70 | ||||
-rw-r--r-- | libstdc++-v3/include/std/memory | 9 | ||||
-rw-r--r-- | libstdc++-v3/testsuite/20_util/auto_ptr/assign_neg.cc | 4 | ||||
-rw-r--r-- | libstdc++-v3/testsuite/25_algorithms/unique_copy/2.cc | 3 | ||||
-rw-r--r-- | libstdc++-v3/testsuite/util/testsuite_iterators.h | 4 |
10 files changed, 109 insertions, 86 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index a1e6e30..70d304c 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,20 @@ +2007-05-04 Paolo Carlini <pcarlini@suse.de> + + * 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 + <iterator>. + * include/bits/stl_iterator_base_types.h: Adjust includes. + * testsuite/25_algorithms/unique_copy/2.cc: Include <functional>. + 2007-05-04 Mark Mitchell <mark@codesourcery.com> * libsupc++/atexit_arm.cc: New file. diff --git a/libstdc++-v3/include/Makefile.am b/libstdc++-v3/include/Makefile.am index ea27464..cfa995e 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 4402d84..c14ac8b 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 index 7dbd323..6e0f9c7 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,86 +27,20 @@ // 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 <bits/stl_algobase.h> -#include <bits/allocator.h> -#include <bits/stl_construct.h> -#include <bits/stl_uninitialized.h> -#include <bits/stl_raw_storage_iter.h> +#include <bits/c++config.h> #include <debug/debug.h> _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<typename _Tp> - pair<_Tp*, ptrdiff_t> - __get_temporary_buffer(ptrdiff_t __len, _Tp*) - { - const ptrdiff_t __max = - __gnu_cxx::__numeric_traits<ptrdiff_t>::__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<typename _Tp> - 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<typename _Tp> - 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) * the result of a function which returns an auto_ptr by value. @@ -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 c02cd26..1b74669 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 <bits/c++config.h> +#include <cstddef> + _GLIBCXX_BEGIN_NAMESPACE(std) //@{ diff --git a/libstdc++-v3/include/bits/stl_tempbuf.h b/libstdc++-v3/include/bits/stl_tempbuf.h index 5663844f..46c733f 100644 --- a/libstdc++-v3/include/bits/stl_tempbuf.h +++ b/libstdc++-v3/include/bits/stl_tempbuf.h @@ -62,12 +62,75 @@ #ifndef _TEMPBUF_H #define _TEMPBUF_H 1 -#include <bits/stl_memory.h> +#include <bits/stl_algobase.h> +#include <bits/stl_construct.h> +#include <bits/stl_uninitialized.h> _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<typename _Tp> + pair<_Tp*, ptrdiff_t> + __get_temporary_buffer(ptrdiff_t __len, _Tp*) + { + const ptrdiff_t __max = + __gnu_cxx::__numeric_traits<ptrdiff_t>::__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<typename _Tp> + 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<typename _Tp> + 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, * where it is wrapped as the temporary_buffer class. See * temporary_buffer docs for more notes. @@ -131,7 +194,6 @@ _GLIBCXX_BEGIN_NAMESPACE(std) operator=(const _Temporary_buffer&); }; - template<typename _ForwardIterator, typename _Tp> _Temporary_buffer<_ForwardIterator, _Tp>:: _Temporary_buffer(_ForwardIterator __first, _ForwardIterator __last) @@ -140,8 +202,8 @@ _GLIBCXX_BEGIN_NAMESPACE(std) { try { - pair<pointer, size_type> __p(get_temporary_buffer< - value_type>(_M_original_len)); + std::pair<pointer, size_type> __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 33bc216..28b8d85 100644 --- a/libstdc++-v3/include/std/memory +++ b/libstdc++-v3/include/std/memory @@ -51,8 +51,13 @@ #pragma GCC system_header -#include <bits/c++config.h> -#include <bits/stl_memory.h> +#include <bits/stl_algobase.h> +#include <bits/allocator.h> +#include <bits/stl_construct.h> +#include <bits/stl_uninitialized.h> +#include <bits/stl_tempbuf.h> +#include <bits/stl_auto_ptr.h> +#include <bits/stl_raw_storage_iter.h> #ifdef __GXX_EXPERIMENTAL_CXX0X__ # include <tr1/memory> 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 5ce62ee..ffca898 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 1350091..2c67cee 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 <algorithm> +#include <functional> #include <testsuite_hooks.h> #include <testsuite_iterators.h> diff --git a/libstdc++-v3/testsuite/util/testsuite_iterators.h b/libstdc++-v3/testsuite/util/testsuite_iterators.h index 7119783..073be0b 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 <testsuite_hooks.h> -#include <iterator> +#include <bits/stl_iterator_base_types.h> #ifndef _TESTSUITE_ITERATORS #define _TESTSUITE_ITERATORS |