summaryrefslogtreecommitdiff
path: root/libstdc++-v3/src
diff options
context:
space:
mode:
authorpaolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4>2009-05-08 00:39:28 +0000
committerpaolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4>2009-05-08 00:39:28 +0000
commita369cef25f2b2f1feed00b322e360e4b07f86968 (patch)
tree099093ca41c5120a81e9862ef591de41962a0204 /libstdc++-v3/src
parent7089f75f4a7b1e393955a534d1345c4e5a79d933 (diff)
downloadgcc-a369cef25f2b2f1feed00b322e360e4b07f86968.tar.gz
2009-05-07 Paolo Carlini <paolo.carlini@oracle.com>
* include/ext/throw_allocator.h (throw_allocator_base): Avoid out of line member functions definitions. (throw_allocator_base::_S_g, _S_map, _S_throw_prob, _S_label): Remove, use static locals instead. (throw_allocator_base::do_check_allocated, print_to_string): Declare. * src/throw_allocator.cc: New. * src/Makefile.am: Add. * config/abi/pre/gnu.ver: Add exports. * src/Makefile.in: Regenerate. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@147264 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libstdc++-v3/src')
-rw-r--r--libstdc++-v3/src/Makefile.am1
-rw-r--r--libstdc++-v3/src/Makefile.in20
-rw-r--r--libstdc++-v3/src/throw_allocator.cc95
3 files changed, 107 insertions, 9 deletions
diff --git a/libstdc++-v3/src/Makefile.am b/libstdc++-v3/src/Makefile.am
index d218ceaa9ca..288243aab26 100644
--- a/libstdc++-v3/src/Makefile.am
+++ b/libstdc++-v3/src/Makefile.am
@@ -182,6 +182,7 @@ sources = \
streambuf-inst.cc \
streambuf.cc \
string-inst.cc \
+ throw_allocator.cc \
valarray-inst.cc \
wlocale-inst.cc \
wstring-inst.cc \
diff --git a/libstdc++-v3/src/Makefile.in b/libstdc++-v3/src/Makefile.in
index 9ee5275198b..24187af1dae 100644
--- a/libstdc++-v3/src/Makefile.in
+++ b/libstdc++-v3/src/Makefile.in
@@ -85,12 +85,13 @@ am__libstdc___la_SOURCES_DIST = atomic.cc bitmap_allocator.cc \
fstream-inst.cc ext-inst.cc ios-inst.cc iostream-inst.cc \
istream-inst.cc istream.cc locale-inst.cc misc-inst.cc \
ostream-inst.cc sstream-inst.cc streambuf-inst.cc streambuf.cc \
- string-inst.cc valarray-inst.cc wlocale-inst.cc \
- wstring-inst.cc mutex.cc condition_variable.cc chrono.cc \
- thread.cc atomicity.cc codecvt_members.cc collate_members.cc \
- ctype_members.cc messages_members.cc monetary_members.cc \
- numeric_members.cc time_members.cc basic_file.cc c++locale.cc \
- compatibility-ldbl.cc parallel_list.cc parallel_settings.cc
+ string-inst.cc throw_allocator.cc valarray-inst.cc \
+ wlocale-inst.cc wstring-inst.cc mutex.cc condition_variable.cc \
+ chrono.cc thread.cc atomicity.cc codecvt_members.cc \
+ collate_members.cc ctype_members.cc messages_members.cc \
+ monetary_members.cc numeric_members.cc time_members.cc \
+ basic_file.cc c++locale.cc compatibility-ldbl.cc \
+ parallel_list.cc parallel_settings.cc
am__objects_1 = atomicity.lo codecvt_members.lo collate_members.lo \
ctype_members.lo messages_members.lo monetary_members.lo \
numeric_members.lo time_members.lo
@@ -111,9 +112,9 @@ am__objects_5 = atomic.lo bitmap_allocator.lo pool_allocator.lo \
fstream-inst.lo ext-inst.lo ios-inst.lo iostream-inst.lo \
istream-inst.lo istream.lo locale-inst.lo misc-inst.lo \
ostream-inst.lo sstream-inst.lo streambuf-inst.lo streambuf.lo \
- string-inst.lo valarray-inst.lo wlocale-inst.lo \
- wstring-inst.lo mutex.lo condition_variable.lo chrono.lo \
- thread.lo $(am__objects_1) $(am__objects_4)
+ string-inst.lo throw_allocator.lo valarray-inst.lo \
+ wlocale-inst.lo wstring-inst.lo mutex.lo condition_variable.lo \
+ chrono.lo thread.lo $(am__objects_1) $(am__objects_4)
am_libstdc___la_OBJECTS = $(am__objects_5)
libstdc___la_OBJECTS = $(am_libstdc___la_OBJECTS)
DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir)
@@ -434,6 +435,7 @@ sources = \
streambuf-inst.cc \
streambuf.cc \
string-inst.cc \
+ throw_allocator.cc \
valarray-inst.cc \
wlocale-inst.cc \
wstring-inst.cc \
diff --git a/libstdc++-v3/src/throw_allocator.cc b/libstdc++-v3/src/throw_allocator.cc
new file mode 100644
index 00000000000..a8247ad9782
--- /dev/null
+++ b/libstdc++-v3/src/throw_allocator.cc
@@ -0,0 +1,95 @@
+// Throw Allocator. Out of line function definitions. -*- C++ -*-
+
+// Copyright (C) 2009 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 3, 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.
+
+// Under Section 7 of GPL version 3, you are granted additional
+// permissions described in the GCC Runtime Library Exception, version
+// 3.1, as published by the Free Software Foundation.
+
+// You should have received a copy of the GNU General Public License and
+// a copy of the GCC Runtime Library Exception along with this program;
+// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
+// <http://www.gnu.org/licenses/>.
+
+#include <ext/throw_allocator.h>
+
+_GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
+
+ void
+ throw_allocator_base::do_check_allocated(const_iterator found,
+ const_iterator end,
+ void* p, size_t size)
+ {
+ if (found == end)
+ {
+ std::string error("throw_allocator_base::check_allocated by value "
+ "null erase!\n");
+ print_to_string(error, make_entry(p, size));
+ std::__throw_logic_error(error.c_str());
+ }
+
+ if (found->second.second != size)
+ {
+ std::string error("throw_allocator_base::check_allocated by value "
+ "wrong-size erase!\n");
+ print_to_string(error, make_entry(p, size));
+ print_to_string(error, *found);
+ std::__throw_logic_error(error.c_str());
+ }
+ }
+
+ void
+ throw_allocator_base::do_check_allocated(const_iterator beg,
+ const_iterator end,
+ size_t label)
+ {
+ std::string found;
+ while (beg != end)
+ {
+ if (beg->second.first == label)
+ print_to_string(found, *beg);
+ ++beg;
+ }
+
+ if (!found.empty())
+ {
+ std::string error("throw_allocator_base::check_allocated by label \n");
+ error += found;
+ std::__throw_logic_error(error.c_str());
+ }
+ }
+
+ void
+ throw_allocator_base::print_to_string(std::string& s,
+ const_reference ref)
+ {
+ char buf[40];
+ const char tab('\t');
+ s += "address: ";
+ __builtin_sprintf(buf, "%p", ref.first);
+ s += buf;
+ s += tab;
+ s += "label: ";
+ unsigned long l = static_cast<unsigned long>(ref.second.first);
+ __builtin_sprintf(buf, "%lu", l);
+ s += buf;
+ s += tab;
+ s += "size: ";
+ l = static_cast<unsigned long>(ref.second.second);
+ __builtin_sprintf(buf, "%lu", l);
+ s += buf;
+ s += '\n';
+ }
+
+_GLIBCXX_END_NAMESPACE