aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Kosnik <bkoz@redhat.com>2006-09-19 02:33:21 +0000
committerBenjamin Kosnik <bkoz@gcc.gnu.org>2006-09-19 02:33:21 +0000
commita86151e10bb9f2892cb24bdb646b85b1a46fcb13 (patch)
treed057a23b933b7403658f92f0655cb0ce31fadbb0
parent2fb31455672e34b697ca5b03622be6d59a7baa4a (diff)
downloadgcc-a86151e10bb9f2892cb24bdb646b85b1a46fcb13.zip
gcc-a86151e10bb9f2892cb24bdb646b85b1a46fcb13.tar.gz
gcc-a86151e10bb9f2892cb24bdb646b85b1a46fcb13.tar.bz2
res_mng: Remove.
2006-09-18 Benjamin Kosnik <bkoz@redhat.com> * testsuite/util/regression/res_mng: Remove. * testsuite/util/regression/res_mng/dbg_ex_allocator_base.cc: Merge.. * testsuite/util/regression/res_mng/forced_exception.hpp: Merge... * testsuite/util/regression/res_mng/dbg_ex_allocator_base.hpp: Merge.. * testsuite/util/regression/res_mng/dbg_ex_allocator.hpp: Merge.. * testsuite/util/testsuite_allocator.h (throw_allocator): Merge... * include/ext/throw_allocator.h (throw_allocator): ... into this. * src/throw_allocator.cc: ...and this. * include/Makefile.am (ext_headers): Add. * include/Makefile.in: Regenerate. * src/Makefile.am (sources): New. * src/Makefile.in: Regenerate. * testsuite/lib/libstdc++.exp: Subtract dbg_ex_allocator_base.cc. * include/ext/pb_ds/detail/map_debug_base.hpp: Adjust includes, names, and namespaces. * testsuite/23_containers/list/modifiers/insert/25288.cc: Same. * testsuite/util/regression/rand/priority_queue/detail/ erase_fn_imps.hpp: Same. * testsuite/util/regression/rand/priority_queue/detail/ constructor_destructor_fn_imps.hpp: Same. * testsuite/util/regression/rand/priority_queue/detail/ insert_fn_imps.hpp: Same. * testsuite/util/regression/rand/priority_queue/detail/ modify_fn_imps.hpp: Same. * testsuite/util/regression/rand/priority_queue/detail/ split_join_fn_imps.hpp: Same. * testsuite/util/regression/rand/priority_queue/detail/ operator_fn_imps.hpp: Same. * testsuite/util/regression/rand/priority_queue/ container_rand_regression_test.hpp: Same. * testsuite/util/regression/rand/assoc/detail/ subscript_fn_imps.hpp: Same. * testsuite/util/regression/rand/assoc/detail/ operator_fn_imps.hpp: Same. * testsuite/util/regression/rand/assoc/detail/erase_fn_imps.hpp: Same. * testsuite/util/regression/rand/assoc/detail/ constructor_destructor_fn_imps.hpp * testsuite/util/regression/rand/assoc/detail/insert_fn_imps.hpp: Same. * testsuite/util/regression/rand/assoc/detail/ split_join_fn_imps.hpp: Same. * testsuite/util/regression/rand/assoc/ container_rand_regression_test.hpp: Same. * testsuite/util/regression/priority_queue/common_type.hpp: Same. * testsuite/util/regression/assoc/common_type.hpp: Same. * testsuite/util/regression/basic_type.hpp: Same. * testsuite/util/rng/twister_rand_gen.cc: Tweak. From-SVN: r117050
-rw-r--r--libstdc++-v3/ChangeLog50
-rw-r--r--libstdc++-v3/include/Makefile.am1
-rw-r--r--libstdc++-v3/include/Makefile.in1
-rw-r--r--libstdc++-v3/include/ext/pb_ds/detail/map_debug_base.hpp8
-rw-r--r--libstdc++-v3/include/ext/throw_allocator.h384
-rw-r--r--libstdc++-v3/testsuite/23_containers/list/modifiers/insert/25288.cc31
-rw-r--r--libstdc++-v3/testsuite/lib/libstdc++.exp3
-rw-r--r--libstdc++-v3/testsuite/util/regression/assoc/common_type.hpp2
-rw-r--r--libstdc++-v3/testsuite/util/regression/basic_type.hpp5
-rw-r--r--libstdc++-v3/testsuite/util/regression/priority_queue/common_type.hpp2
-rw-r--r--libstdc++-v3/testsuite/util/regression/rand/assoc/container_rand_regression_test.hpp2
-rw-r--r--libstdc++-v3/testsuite/util/regression/rand/assoc/detail/constructor_destructor_fn_imps.hpp16
-rw-r--r--libstdc++-v3/testsuite/util/regression/rand/assoc/detail/erase_fn_imps.hpp8
-rw-r--r--libstdc++-v3/testsuite/util/regression/rand/assoc/detail/insert_fn_imps.hpp2
-rw-r--r--libstdc++-v3/testsuite/util/regression/rand/assoc/detail/operator_fn_imps.hpp34
-rw-r--r--libstdc++-v3/testsuite/util/regression/rand/assoc/detail/split_join_fn_imps.hpp2
-rw-r--r--libstdc++-v3/testsuite/util/regression/rand/assoc/detail/subscript_fn_imps.hpp4
-rw-r--r--libstdc++-v3/testsuite/util/regression/rand/priority_queue/container_rand_regression_test.hpp6
-rw-r--r--libstdc++-v3/testsuite/util/regression/rand/priority_queue/detail/constructor_destructor_fn_imps.hpp8
-rw-r--r--libstdc++-v3/testsuite/util/regression/rand/priority_queue/detail/erase_fn_imps.hpp6
-rw-r--r--libstdc++-v3/testsuite/util/regression/rand/priority_queue/detail/insert_fn_imps.hpp2
-rw-r--r--libstdc++-v3/testsuite/util/regression/rand/priority_queue/detail/modify_fn_imps.hpp2
-rw-r--r--libstdc++-v3/testsuite/util/regression/rand/priority_queue/detail/operator_fn_imps.hpp42
-rw-r--r--libstdc++-v3/testsuite/util/regression/rand/priority_queue/detail/split_join_fn_imps.hpp2
-rw-r--r--libstdc++-v3/testsuite/util/regression/res_mng/dbg_ex_allocator.hpp129
-rw-r--r--libstdc++-v3/testsuite/util/regression/res_mng/dbg_ex_allocator_base.cc210
-rw-r--r--libstdc++-v3/testsuite/util/regression/res_mng/dbg_ex_allocator_base.hpp163
-rw-r--r--libstdc++-v3/testsuite/util/regression/res_mng/forced_exception.hpp60
-rw-r--r--libstdc++-v3/testsuite/util/rng/twister_rand_gen.cc7
-rw-r--r--libstdc++-v3/testsuite/util/testsuite_allocator.h76
30 files changed, 518 insertions, 750 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index 505266b..d0c8d63 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,3 +1,53 @@
+2006-09-18 Benjamin Kosnik <bkoz@redhat.com>
+
+ * testsuite/util/regression/res_mng: Remove.
+ * testsuite/util/regression/res_mng/dbg_ex_allocator_base.cc: Merge..
+ * testsuite/util/regression/res_mng/forced_exception.hpp: Merge...
+ * testsuite/util/regression/res_mng/dbg_ex_allocator_base.hpp: Merge..
+ * testsuite/util/regression/res_mng/dbg_ex_allocator.hpp: Merge..
+ * testsuite/util/testsuite_allocator.h (throw_allocator): Merge...
+ * include/ext/throw_allocator.h (throw_allocator): ... into this.
+ * src/throw_allocator.cc: ...and this.
+ * include/Makefile.am (ext_headers): Add.
+ * include/Makefile.in: Regenerate.
+ * src/Makefile.am (sources): New.
+ * src/Makefile.in: Regenerate.
+ * testsuite/lib/libstdc++.exp: Subtract dbg_ex_allocator_base.cc.
+
+ * include/ext/pb_ds/detail/map_debug_base.hpp: Adjust
+ includes, names, and namespaces.
+ * testsuite/23_containers/list/modifiers/insert/25288.cc: Same.
+ * testsuite/util/regression/rand/priority_queue/detail/
+ erase_fn_imps.hpp: Same.
+ * testsuite/util/regression/rand/priority_queue/detail/
+ constructor_destructor_fn_imps.hpp: Same.
+ * testsuite/util/regression/rand/priority_queue/detail/
+ insert_fn_imps.hpp: Same.
+ * testsuite/util/regression/rand/priority_queue/detail/
+ modify_fn_imps.hpp: Same.
+ * testsuite/util/regression/rand/priority_queue/detail/
+ split_join_fn_imps.hpp: Same.
+ * testsuite/util/regression/rand/priority_queue/detail/
+ operator_fn_imps.hpp: Same.
+ * testsuite/util/regression/rand/priority_queue/
+ container_rand_regression_test.hpp: Same.
+ * testsuite/util/regression/rand/assoc/detail/
+ subscript_fn_imps.hpp: Same.
+ * testsuite/util/regression/rand/assoc/detail/
+ operator_fn_imps.hpp: Same.
+ * testsuite/util/regression/rand/assoc/detail/erase_fn_imps.hpp: Same.
+ * testsuite/util/regression/rand/assoc/detail/
+ constructor_destructor_fn_imps.hpp
+ * testsuite/util/regression/rand/assoc/detail/insert_fn_imps.hpp: Same.
+ * testsuite/util/regression/rand/assoc/detail/
+ split_join_fn_imps.hpp: Same.
+ * testsuite/util/regression/rand/assoc/
+ container_rand_regression_test.hpp: Same.
+ * testsuite/util/regression/priority_queue/common_type.hpp: Same.
+ * testsuite/util/regression/assoc/common_type.hpp: Same.
+ * testsuite/util/regression/basic_type.hpp: Same.
+ * testsuite/util/rng/twister_rand_gen.cc: Tweak.
+
2006-09-18 Tom Tromey <tromey@redhat.com>
* configure: Rebuilt.
diff --git a/libstdc++-v3/include/Makefile.am b/libstdc++-v3/include/Makefile.am
index 7170d84..7c941f7 100644
--- a/libstdc++-v3/include/Makefile.am
+++ b/libstdc++-v3/include/Makefile.am
@@ -552,6 +552,7 @@ ext_headers = \
${ext_srcdir}/rope \
${ext_srcdir}/ropeimpl.h \
${ext_srcdir}/slist \
+ ${ext_srcdir}/throw_allocator.h \
${ext_srcdir}/typelist.h \
${ext_srcdir}/type_traits.h \
${ext_srcdir}/rc_string_base.h \
diff --git a/libstdc++-v3/include/Makefile.in b/libstdc++-v3/include/Makefile.in
index f112020..eef91dd 100644
--- a/libstdc++-v3/include/Makefile.in
+++ b/libstdc++-v3/include/Makefile.in
@@ -773,6 +773,7 @@ ext_headers = \
${ext_srcdir}/rope \
${ext_srcdir}/ropeimpl.h \
${ext_srcdir}/slist \
+ ${ext_srcdir}/throw_allocator.h \
${ext_srcdir}/typelist.h \
${ext_srcdir}/type_traits.h \
${ext_srcdir}/rc_string_base.h \
diff --git a/libstdc++-v3/include/ext/pb_ds/detail/map_debug_base.hpp b/libstdc++-v3/include/ext/pb_ds/detail/map_debug_base.hpp
index fce6256..d31a0c2 100644
--- a/libstdc++-v3/include/ext/pb_ds/detail/map_debug_base.hpp
+++ b/libstdc++-v3/include/ext/pb_ds/detail/map_debug_base.hpp
@@ -51,7 +51,7 @@
#include <list>
#include <utility>
-#include <regression/res_mng/dbg_ex_allocator.hpp>
+#include <ext/throw_allocator.h>
#include <debug/debug.h>
namespace pb_ds
@@ -151,7 +151,7 @@ namespace pb_ds
insert_new(const_key_reference r_key)
{
_GLIBCXX_DEBUG_ONLY(assert_valid();)
- pb_ds::test::dbg_ex_allocator<char> alloc;
+ __gnu_cxx::throw_allocator<char> alloc;
const double orig_throw_prob = alloc.get_throw_prob();
alloc.set_throw_prob(0);
if (find(r_key) != m_key_set.end())
@@ -310,7 +310,7 @@ namespace pb_ds
PB_DS_CLASS_C_DEC::
split(const_key_reference r_key, Cmp_Fn cmp_fn, PB_DS_CLASS_C_DEC& other)
{
- pb_ds::test::dbg_ex_allocator<char> alloc;
+ __gnu_cxx::throw_allocator<char> alloc;
const double orig_throw_prob = alloc.get_throw_prob();
alloc.set_throw_prob(0);
other.clear();
@@ -331,7 +331,7 @@ namespace pb_ds
PB_DS_CLASS_C_DEC::
join(PB_DS_CLASS_C_DEC& other)
{
- pb_ds::test::dbg_ex_allocator<char> alloc;
+ __gnu_cxx::throw_allocator<char> alloc;
const double orig_throw_prob = alloc.get_throw_prob();
alloc.set_throw_prob(0);
key_set_iterator it = other.m_key_set.begin();
diff --git a/libstdc++-v3/include/ext/throw_allocator.h b/libstdc++-v3/include/ext/throw_allocator.h
new file mode 100644
index 0000000..38f6afb
--- /dev/null
+++ b/libstdc++-v3/include/ext/throw_allocator.h
@@ -0,0 +1,384 @@
+// -*- C++ -*-
+
+// Copyright (C) 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, 59 Temple Place - Suite 330, Boston,
+// MA 02111-1307, 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.
+
+// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
+
+// Permission to use, copy, modify, sell, and distribute this software
+// is hereby granted without fee, provided that the above copyright
+// notice appears in all copies, and that both that copyright notice
+// and this permission notice appear in supporting documentation. None
+// of the above authors, nor IBM Haifa Research Laboratories, make any
+// representation about the suitability of this software for any
+// purpose. It is provided "as is" without express or implied
+// warranty.
+
+/**
+ * @file throw_allocator.h Contains an exception-throwing allocator
+ * useful for testing exception safety. In addition, allocation
+ * addresses are stored and sanity checked.
+ */
+
+#ifndef _THROW_ALLOCATOR_H
+#define _THROW_ALLOCATOR_H 1
+
+#include <cmath>
+#include <map>
+#include <set>
+#include <string>
+#include <ostream>
+#include <stdexcept>
+#include <utility>
+#include <tr1/random>
+
+_GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
+
+ class twister_rand_gen
+ {
+ public:
+ twister_rand_gen(unsigned int seed =
+ static_cast<unsigned int>(std::time(0)));
+
+ void
+ init(unsigned int);
+
+ double
+ get_prob();
+
+ private:
+ std::tr1::mt19937 _M_generator;
+ };
+
+
+ struct forced_exception_error : public std::exception
+ { };
+
+ class throw_allocator_base
+ {
+ public:
+ void
+ init(unsigned long seed);
+
+ static void
+ set_throw_prob(double throw_prob);
+
+ static double
+ get_throw_prob();
+
+ static void
+ set_label(size_t l);
+
+ static bool
+ empty();
+
+ struct group_throw_prob_adjustor
+ {
+ group_throw_prob_adjustor(size_t size)
+ : _M_throw_prob_orig(_S_throw_prob)
+ {
+ _S_throw_prob =
+ 1 - ::pow(double(1 - _S_throw_prob), double(0.5 / (size + 1)));
+ }
+
+ ~group_throw_prob_adjustor()
+ { _S_throw_prob = _M_throw_prob_orig; }
+
+ private:
+ const double _M_throw_prob_orig;
+ };
+
+ struct zero_throw_prob_adjustor
+ {
+ zero_throw_prob_adjustor() : _M_throw_prob_orig(_S_throw_prob)
+ { _S_throw_prob = 0; }
+
+ ~zero_throw_prob_adjustor()
+ { _S_throw_prob = _M_throw_prob_orig; }
+
+ private:
+ const double _M_throw_prob_orig;
+ };
+
+ protected:
+ static void
+ insert(void*, size_t);
+
+ static void
+ erase(void*, size_t);
+
+ static void
+ throw_conditionally();
+
+ static void
+ assert_allocatod(const void*, size_t);
+
+ static void
+ check_allocated(void*, size_t);
+
+ private:
+ typedef std::pair<size_t, size_t> alloc_data_type;
+ typedef std::map<void*, alloc_data_type> map_type;
+ typedef map_type::value_type entry_type;
+ typedef map_type::const_iterator const_iterator;
+ typedef map_type::const_reference const_reference;
+
+ friend std::ostream&
+ operator<<(std::ostream&, const throw_allocator_base&);
+
+ static entry_type
+ make_entry(void*, size_t);
+
+ static void
+ print_to_string(std::string&);
+
+ static void
+ print_to_string(std::string&, const_reference);
+
+ static twister_rand_gen _S_g;
+ static map_type _S_map;
+ static double _S_throw_prob;
+ static size_t _S_label;
+ };
+
+
+ template<typename T>
+ class throw_allocator : public throw_allocator_base
+ {
+ public:
+ typedef size_t size_type;
+ typedef ptrdiff_t difference_type;
+ typedef T* pointer;
+ typedef const T* const_pointer;
+ typedef T& reference;
+ typedef const T& const_reference;
+ typedef T value_type;
+
+ template<typename U>
+ struct rebind
+ {
+ typedef throw_allocator<U> other;
+ };
+
+ throw_allocator() throw() { }
+
+ throw_allocator(const throw_allocator<T>&) throw() { }
+
+ template <class U>
+ throw_allocator(const throw_allocator<U>&) throw() { }
+
+ ~throw_allocator() throw() { }
+
+ size_type
+ max_size() const throw()
+ { return std::allocator<T>().max_size(); }
+
+ pointer
+ allocate(size_type num, std::allocator<void>::const_pointer hint = 0)
+ {
+ throw_conditionally();
+ T* const a = std::allocator<T>().allocate(num, hint);
+ insert(a, sizeof(T) * num);
+ return a;
+ }
+
+ void
+ construct(pointer p, const T& val)
+ { return std::allocator<T>().construct(p, val); }
+
+ void
+ destroy(pointer p)
+ { std::allocator<T>().destroy(p); }
+
+ void
+ deallocate(pointer p, size_type num)
+ {
+ erase(p, sizeof(T) * num);
+ std::allocator<T>().deallocate(p, num);
+ }
+
+ void
+ check_allocated(pointer p, size_type num)
+ { throw_allocator_base::check_allocated(p, sizeof(T) * num); }
+ };
+
+ template<typename T>
+ inline bool
+ operator==(const throw_allocator<T>&, const throw_allocator<T>&)
+ { return true; }
+
+ template<typename T>
+ inline bool
+ operator!=(const throw_allocator<T>&, const throw_allocator<T>&)
+ { return false; }
+
+ std::ostream&
+ operator<<(std::ostream& os, const throw_allocator_base& alloc)
+ {
+ std::string error;
+ throw_allocator_base::print_to_string(error);
+ os << error;
+ return os;
+ }
+
+ // XXX Should be in .cc.
+ twister_rand_gen::
+ twister_rand_gen(unsigned int seed) : _M_generator(seed) { }
+
+ void
+ twister_rand_gen::
+ init(unsigned int seed)
+ { _M_generator.seed(seed); }
+
+ double
+ twister_rand_gen::
+ get_prob()
+ {
+ const double eng_min = _M_generator.min();
+ const double eng_range =
+ static_cast<const double>(_M_generator.max() - eng_min);
+
+ const double eng_res =
+ static_cast<const double>(_M_generator() - eng_min);
+
+ const double ret = eng_res / eng_range;
+ _GLIBCXX_DEBUG_ASSERT(ret >= 0 && ret <= 1);
+ return ret;
+ }
+
+ twister_rand_gen throw_allocator_base::_S_g;
+
+ throw_allocator_base::map_type
+ throw_allocator_base::_S_map;
+
+ double throw_allocator_base::_S_throw_prob;
+
+ size_t throw_allocator_base::_S_label = 0;
+
+ throw_allocator_base::entry_type
+ throw_allocator_base::make_entry(void* p, size_t size)
+ { return std::make_pair(p, alloc_data_type(_S_label, size)); }
+
+ void
+ throw_allocator_base::init(unsigned long seed)
+ { _S_g.init(seed); }
+
+ void
+ throw_allocator_base::set_throw_prob(double throw_prob)
+ { _S_throw_prob = throw_prob; }
+
+ double
+ throw_allocator_base::get_throw_prob()
+ { return _S_throw_prob; }
+
+ void
+ throw_allocator_base::set_label(size_t l)
+ { _S_label = l; }
+
+ void
+ throw_allocator_base::insert(void* p, size_t size)
+ {
+ const_iterator found_it = _S_map.find(p);
+ if (found_it != _S_map.end())
+ {
+ std::string error("throw_allocator_base::insert");
+ error += "double insert!";
+ error += '\n';
+ print_to_string(error, make_entry(p, size));
+ print_to_string(error, *found_it);
+ throw std::logic_error(error);
+ }
+ _S_map.insert(make_entry(p, size));
+ }
+
+ bool
+ throw_allocator_base::empty()
+ { return _S_map.empty(); }
+
+ void
+ throw_allocator_base::erase(void* p, size_t size)
+ {
+ check_allocated(p, size);
+ _S_map.erase(p);
+ }
+
+ void
+ throw_allocator_base::check_allocated(void* p, size_t size)
+ {
+ const_iterator found_it = _S_map.find(p);
+ if (found_it == _S_map.end())
+ {
+ std::string error("throw_allocator_base::check_allocated");
+ error += "null erase!";
+ error += '\n';
+ print_to_string(error, make_entry(p, size));
+ throw std::logic_error(error);
+ }
+
+ if (found_it->second.second != size)
+ {
+ std::string error("throw_allocator_base::check_allocated");
+ error += "wrong-size erase!";
+ error += '\n';
+ print_to_string(error, make_entry(p, size));
+ print_to_string(error, *found_it);
+ throw std::logic_error(error);
+ }
+ }
+
+ void
+ throw_allocator_base::throw_conditionally()
+ {
+ if (_S_g.get_prob() < _S_throw_prob)
+ throw forced_exception_error();
+ }
+
+ void
+ throw_allocator_base::print_to_string(std::string& s)
+ {
+ const_iterator it = throw_allocator_base::_S_map.begin();
+ const_iterator end_it = throw_allocator_base::_S_map.end();
+ for (; it != end_it; ++it)
+ print_to_string(s, *it);
+ s += '\n';
+ }
+
+ void
+ throw_allocator_base::print_to_string(std::string& s, const_reference ref)
+ {
+ s += reinterpret_cast<const unsigned long>(ref.first);
+ s += ": ";
+ s += ref.second.first ;
+ s += ", ";
+ s += ref.second.second;
+ s += '\n';
+ }
+
+_GLIBCXX_END_NAMESPACE
+
+#endif
diff --git a/libstdc++-v3/testsuite/23_containers/list/modifiers/insert/25288.cc b/libstdc++-v3/testsuite/23_containers/list/modifiers/insert/25288.cc
index a229718..340f336 100644
--- a/libstdc++-v3/testsuite/23_containers/list/modifiers/insert/25288.cc
+++ b/libstdc++-v3/testsuite/23_containers/list/modifiers/insert/25288.cc
@@ -1,4 +1,4 @@
-// Copyright (C) 2005 Free Software Foundation, Inc.
+// Copyright (C) 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
@@ -20,31 +20,34 @@
#include <list>
#include <testsuite_hooks.h>
-#include <testsuite_allocator.h>
+#include <ext/throw_allocator.h>
// libstdc++/25288
void test01()
{
bool test __attribute__((unused)) = true;
- typedef __gnu_test::throw_allocator<int> my_alloc;
- typedef std::list<int, my_alloc > my_list;
+ typedef int value_type;
+ typedef __gnu_cxx::throw_allocator<value_type> allocator_type;
+ typedef std::list<value_type, allocator_type> list_type;
for (int j = 0; j < 10; ++j)
for (int i = 0; i < 10; ++i)
{
- my_alloc alloc1(j + i);
- my_list list1(alloc1);
+ allocator_type alloc1;
+ allocator_type::zero_throw_prob_adjustor adjust1;
+ list_type list1(alloc1);
for (int k = 0; k < j; ++k)
- list1.push_back(-(k + 1));
+ list1.push_back(value_type(-(k + 1)));
try
{
+ alloc1.set_throw_prob(1);
list1.insert(list1.begin(), 10, 99);
VERIFY( false );
}
- catch (std::bad_alloc&)
+ catch (__gnu_cxx::forced_exception_error&)
{
VERIFY( true );
}
@@ -53,12 +56,13 @@ void test01()
VERIFY( false );
}
- VERIFY( list1.size() == my_list::size_type(j) );
+ VERIFY( list1.size() == list_type::size_type(j) );
VERIFY( list1.size() == 0 || list1.back() == -j );
VERIFY( list1.size() == 0 || list1.front() == -1 );
- my_alloc alloc2(j + i);
- my_list list2(alloc2);
+ allocator_type alloc2;
+ allocator_type::zero_throw_prob_adjustor adjust2;
+ list_type list2(alloc2);
const int data[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
@@ -67,10 +71,11 @@ void test01()
try
{
+ alloc2.set_throw_prob(1);
list2.insert(list2.begin(), data, data + 10);
VERIFY( false );
}
- catch (std::bad_alloc&)
+ catch (__gnu_cxx::forced_exception_error&)
{
VERIFY( true );
}
@@ -79,7 +84,7 @@ void test01()
VERIFY( false );
}
- VERIFY( list2.size() == my_list::size_type(j) );
+ VERIFY( list2.size() == list_type::size_type(j) );
VERIFY( list2.size() == 0 || list2.back() == -j );
VERIFY( list2.size() == 0 || list2.front() == -1 );
}
diff --git a/libstdc++-v3/testsuite/lib/libstdc++.exp b/libstdc++-v3/testsuite/lib/libstdc++.exp
index 36c2e97..0d059cf 100644
--- a/libstdc++-v3/testsuite/lib/libstdc++.exp
+++ b/libstdc++-v3/testsuite/lib/libstdc++.exp
@@ -411,8 +411,7 @@ proc v3-build_support { } {
set source_files [list testsuite_abi.cc testsuite_allocator.cc \
testsuite_character.cc testsuite_hooks.cc \
rng/twister_rand_gen.cc io/verified_cmd_line_input.cc \
- io/prog_bar.cc regression/res_mng/dbg_ex_allocator_base.cc \
- performance/time/elapsed_timer.cc ]
+ io/prog_bar.cc performance/time/elapsed_timer.cc ]
foreach f $source_files {
set obj [file rootname $f].o
set object_file [file tail $obj]
diff --git a/libstdc++-v3/testsuite/util/regression/assoc/common_type.hpp b/libstdc++-v3/testsuite/util/regression/assoc/common_type.hpp
index fa34568..7567c5f 100644
--- a/libstdc++-v3/testsuite/util/regression/assoc/common_type.hpp
+++ b/libstdc++-v3/testsuite/util/regression/assoc/common_type.hpp
@@ -54,7 +54,7 @@ namespace pb_ds
{
namespace test
{
- typedef dbg_ex_allocator<basic_type> alloc_type;
+ typedef __gnu_cxx::throw_allocator<basic_type> alloc_type;
struct hash
{
diff --git a/libstdc++-v3/testsuite/util/regression/basic_type.hpp b/libstdc++-v3/testsuite/util/regression/basic_type.hpp
index 626f9e6f..279c288 100644
--- a/libstdc++-v3/testsuite/util/regression/basic_type.hpp
+++ b/libstdc++-v3/testsuite/util/regression/basic_type.hpp
@@ -48,14 +48,15 @@
#define PB_DS_BASIC_TYPE_HPP
#include <string>
-#include <regression/res_mng/dbg_ex_allocator.hpp>
+#include <ext/throw_allocator.h>
namespace pb_ds
{
namespace test
{
#define PB_DS_BASE_C_DEC \
- std::basic_string<char, std::char_traits<char>, dbg_ex_allocator<char> >
+ std::basic_string<char, std::char_traits<char>, \
+ __gnu_cxx::throw_allocator<char> >
struct basic_type : public PB_DS_BASE_C_DEC
{
diff --git a/libstdc++-v3/testsuite/util/regression/priority_queue/common_type.hpp b/libstdc++-v3/testsuite/util/regression/priority_queue/common_type.hpp
index c8e6b3d..ce5a9e8 100644
--- a/libstdc++-v3/testsuite/util/regression/priority_queue/common_type.hpp
+++ b/libstdc++-v3/testsuite/util/regression/priority_queue/common_type.hpp
@@ -54,7 +54,7 @@ namespace pb_ds
{
namespace test
{
- typedef dbg_ex_allocator<basic_type> alloc_type;
+ typedef __gnu_cxx::throw_allocator<basic_type> alloc_type;
typedef pq_common_types<basic_type, std::less<basic_type>, alloc_type>::regression_tl pq_tl_t;
diff --git a/libstdc++-v3/testsuite/util/regression/rand/assoc/container_rand_regression_test.hpp b/libstdc++-v3/testsuite/util/regression/rand/assoc/container_rand_regression_test.hpp
index 440c349..d53ce34 100644
--- a/libstdc++-v3/testsuite/util/regression/rand/assoc/container_rand_regression_test.hpp
+++ b/libstdc++-v3/testsuite/util/regression/rand/assoc/container_rand_regression_test.hpp
@@ -156,7 +156,7 @@ namespace detail
other_op
};
- typedef dbg_ex_allocator<char> alloc_t;
+ typedef __gnu_cxx::throw_allocator<char> alloc_t;
private:
diff --git a/libstdc++-v3/testsuite/util/regression/rand/assoc/detail/constructor_destructor_fn_imps.hpp b/libstdc++-v3/testsuite/util/regression/rand/assoc/detail/constructor_destructor_fn_imps.hpp
index 82cc024..00f74bb 100644
--- a/libstdc++-v3/testsuite/util/regression/rand/assoc/detail/constructor_destructor_fn_imps.hpp
+++ b/libstdc++-v3/testsuite/util/regression/rand/assoc/detail/constructor_destructor_fn_imps.hpp
@@ -81,7 +81,7 @@ default_constructor()
{
m_p_c = new Cntnr;
}
- catch(forced_exception& )
+ catch(__gnu_cxx::forced_exception_error& )
{
done = false;
}
@@ -136,7 +136,7 @@ copy_constructor()
std::swap(p_c, m_p_c);
}
- catch(forced_exception& )
+ catch(__gnu_cxx::forced_exception_error& )
{
done = false;
}
@@ -172,7 +172,7 @@ assignment_operator()
std::swap(p_c, m_p_c);
}
- catch(forced_exception& )
+ catch(__gnu_cxx::forced_exception_error& )
{
done = false;
}
@@ -270,7 +270,7 @@ it_constructor_imp(pb_ds::cc_hash_tag)
std::swap(p_c, m_p_c);
}
- catch(forced_exception& )
+ catch(__gnu_cxx::forced_exception_error& )
{
done = false;
}
@@ -384,7 +384,7 @@ it_constructor_imp(pb_ds::gp_hash_tag)
std::swap(p_c, m_p_c);
}
- catch(forced_exception& )
+ catch(__gnu_cxx::forced_exception_error& )
{
done = false;
}
@@ -429,7 +429,7 @@ it_constructor_imp(pb_ds::tree_tag)
std::swap(p_c, m_p_c);
}
- catch(forced_exception& )
+ catch(__gnu_cxx::forced_exception_error& )
{
done = false;
}
@@ -462,7 +462,7 @@ it_constructor_imp(pb_ds::list_update_tag)
std::swap(p_c, m_p_c);
}
- catch(forced_exception& )
+ catch(__gnu_cxx::forced_exception_error& )
{
done = false;
}
@@ -507,7 +507,7 @@ it_constructor_imp(pb_ds::pat_trie_tag)
std::swap(p_c, m_p_c);
}
- catch(forced_exception& )
+ catch(__gnu_cxx::forced_exception_error& )
{
done = false;
}
diff --git a/libstdc++-v3/testsuite/util/regression/rand/assoc/detail/erase_fn_imps.hpp b/libstdc++-v3/testsuite/util/regression/rand/assoc/detail/erase_fn_imps.hpp
index 0b2a62c..0622d9e 100644
--- a/libstdc++-v3/testsuite/util/regression/rand/assoc/detail/erase_fn_imps.hpp
+++ b/libstdc++-v3/testsuite/util/regression/rand/assoc/detail/erase_fn_imps.hpp
@@ -89,7 +89,7 @@ erase()
m_p_c,
& m_native_c);
}
- catch(forced_exception& )
+ catch(__gnu_cxx::forced_exception_error& )
{
done = false;
@@ -141,7 +141,7 @@ erase_if()
m_p_c,
& m_native_c);
}
- catch(forced_exception& )
+ catch(__gnu_cxx::forced_exception_error& )
{
done = false;
@@ -229,7 +229,7 @@ erase_it_imp(pb_ds::detail::true_type)
if (range_guarantee)
PB_DS_THROW_IF_FAILED( next_ers_it == next_it, "", m_p_c, & m_native_c);
}
- catch(forced_exception& )
+ catch(__gnu_cxx::forced_exception_error& )
{
done = false;
@@ -303,7 +303,7 @@ erase_rev_it_imp(pb_ds::detail::true_type)
if (native_it != m_native_c.end())
m_native_c.erase(native_it);
}
- catch(forced_exception& )
+ catch(__gnu_cxx::forced_exception_error& )
{
done = false;
diff --git a/libstdc++-v3/testsuite/util/regression/rand/assoc/detail/insert_fn_imps.hpp b/libstdc++-v3/testsuite/util/regression/rand/assoc/detail/insert_fn_imps.hpp
index 262b28b..94e74ce 100644
--- a/libstdc++-v3/testsuite/util/regression/rand/assoc/detail/insert_fn_imps.hpp
+++ b/libstdc++-v3/testsuite/util/regression/rand/assoc/detail/insert_fn_imps.hpp
@@ -73,7 +73,7 @@ insert()
}
m_native_c.insert(test_traits::native_value(v));
}
- catch(forced_exception& )
+ catch(__gnu_cxx::forced_exception_error& )
{
done = false;
}
diff --git a/libstdc++-v3/testsuite/util/regression/rand/assoc/detail/operator_fn_imps.hpp b/libstdc++-v3/testsuite/util/regression/rand/assoc/detail/operator_fn_imps.hpp
index 34df60e..e6298a8 100644
--- a/libstdc++-v3/testsuite/util/regression/rand/assoc/detail/operator_fn_imps.hpp
+++ b/libstdc++-v3/testsuite/util/regression/rand/assoc/detail/operator_fn_imps.hpp
@@ -52,15 +52,12 @@ operator()()
xml_result_set_regression_formatter* p_fmt = NULL;
if (m_disp)
- p_fmt = new xml_result_set_regression_formatter(
- string_form<Cntnr>::name(),
+ p_fmt = new xml_result_set_regression_formatter(string_form<Cntnr>::name(),
string_form<Cntnr>::desc());
m_g.init(m_seed);
m_alloc.init(m_seed);
-
prog_bar pb(m_n, std::cout, m_disp);
-
m_i = 0;
try
@@ -107,7 +104,7 @@ operator()()
PB_DS_RUN_MTHD(subscript)
break;
default:
- PB_DS_THROW_IF_FAILED( false, "", m_p_c, & m_native_c);
+ PB_DS_THROW_IF_FAILED(false, "", m_p_c, &m_native_c);
}
break;
case erase_op:
@@ -126,7 +123,7 @@ operator()()
PB_DS_RUN_MTHD(erase_rev_it)
break;
default:
- PB_DS_THROW_IF_FAILED( false, "", m_p_c, & m_native_c);
+ PB_DS_THROW_IF_FAILED(false, "", m_p_c, &m_native_c);
}
break;
case clear_op:
@@ -160,11 +157,11 @@ operator()()
get_set_loads();
break;
default:
- PB_DS_THROW_IF_FAILED( false, "", m_p_c, & m_native_c);
+ PB_DS_THROW_IF_FAILED(false, "", m_p_c, & m_native_c);
}
break;
default:
- PB_DS_THROW_IF_FAILED( false, "", m_p_c, & m_native_c);
+ PB_DS_THROW_IF_FAILED(false, "", m_p_c, & m_native_c);
};
}
@@ -173,29 +170,24 @@ operator()()
}
catch(...)
{
- std::cerr << "Failed at index " << static_cast<unsigned long>(m_i) <<
- std::endl;
-
+ std::cerr << "Failed at index " << static_cast<unsigned long>(m_i)
+ << std::endl;
delete m_p_c;
-
throw;
}
delete m_p_c;
- if (!m_alloc.dbg_ex_allocator<char>::empty())
+ if (!m_alloc.throw_allocator<char>::empty())
{
std::cerr << "detected leaks!" << std::endl;
-
std::cerr << m_alloc << std::endl;
-
- PB_DS_THROW_IF_FAILED( false, "", m_p_c, & m_native_c);
+ PB_DS_THROW_IF_FAILED(false, "", m_p_c, &m_native_c);
}
if (m_disp)
{
std::cout << std::endl;
-
delete p_fmt;
}
}
@@ -216,7 +208,7 @@ get_next_op()
if (prob < m_ip + m_ep + m_cp)
return (clear_op);
- PB_DS_THROW_IF_FAILED( prob <= 1, prob, m_p_c, & m_native_c);
+ PB_DS_THROW_IF_FAILED(prob <= 1, prob, m_p_c, &m_native_c);
return (other_op);
}
@@ -227,16 +219,12 @@ PB_DS_CLASS_C_DEC::
get_next_sub_op(size_t max)
{
const double p = m_g.get_prob();
-
const double delta = 1 / static_cast<double>(max);
-
size_t i = 0;
-
while (true)
if (p <= (i + 1)* delta)
{
- PB_DS_THROW_IF_FAILED(
- i < max,
+ PB_DS_THROW_IF_FAILED(i < max,
static_cast<unsigned long>(i) << " " <<
static_cast<unsigned long>(max),
m_p_c,
diff --git a/libstdc++-v3/testsuite/util/regression/rand/assoc/detail/split_join_fn_imps.hpp b/libstdc++-v3/testsuite/util/regression/rand/assoc/detail/split_join_fn_imps.hpp
index 3b0da01..073fda5 100644
--- a/libstdc++-v3/testsuite/util/regression/rand/assoc/detail/split_join_fn_imps.hpp
+++ b/libstdc++-v3/testsuite/util/regression/rand/assoc/detail/split_join_fn_imps.hpp
@@ -134,7 +134,7 @@ split_join_imp(pb_ds::detail::true_type)
m_p_c->swap(lhs);
}
- catch(forced_exception& )
+ catch(__gnu_cxx::forced_exception_error& )
{
done = false;
diff --git a/libstdc++-v3/testsuite/util/regression/rand/assoc/detail/subscript_fn_imps.hpp b/libstdc++-v3/testsuite/util/regression/rand/assoc/detail/subscript_fn_imps.hpp
index 561f230..a2c59e1 100644
--- a/libstdc++-v3/testsuite/util/regression/rand/assoc/detail/subscript_fn_imps.hpp
+++ b/libstdc++-v3/testsuite/util/regression/rand/assoc/detail/subscript_fn_imps.hpp
@@ -82,7 +82,7 @@ subscript_imp(pb_ds::detail::false_type)
m_native_c[test_traits::native_value(v).first] =
test_traits::native_value(v).second;
}
- catch(forced_exception& )
+ catch(__gnu_cxx::forced_exception_error& )
{
done = false;
}
@@ -114,7 +114,7 @@ subscript_imp(pb_ds::detail::true_type)
m_native_c.insert(test_traits::native_value(v));
}
- catch(forced_exception& )
+ catch(__gnu_cxx::forced_exception_error& )
{
done = false;
}
diff --git a/libstdc++-v3/testsuite/util/regression/rand/priority_queue/container_rand_regression_test.hpp b/libstdc++-v3/testsuite/util/regression/rand/priority_queue/container_rand_regression_test.hpp
index 310d59b..15ff02b 100644
--- a/libstdc++-v3/testsuite/util/regression/rand/priority_queue/container_rand_regression_test.hpp
+++ b/libstdc++-v3/testsuite/util/regression/rand/priority_queue/container_rand_regression_test.hpp
@@ -149,7 +149,7 @@ namespace pb_ds
typedef basic_type value_type;
- typedef native_priority_queue< std::string, true> native_type;
+ typedef native_priority_queue<std::string, true> native_type;
enum op
{
@@ -160,9 +160,9 @@ namespace pb_ds
other_op
};
- typedef dbg_ex_allocator< char> alloc_t;
+ typedef __gnu_cxx::throw_allocator<char> alloc_t;
- typedef regression_test_traits< Cntnr> test_traits;
+ typedef regression_test_traits<Cntnr> test_traits;
private:
diff --git a/libstdc++-v3/testsuite/util/regression/rand/priority_queue/detail/constructor_destructor_fn_imps.hpp b/libstdc++-v3/testsuite/util/regression/rand/priority_queue/detail/constructor_destructor_fn_imps.hpp
index e04627c..87282825 100644
--- a/libstdc++-v3/testsuite/util/regression/rand/priority_queue/detail/constructor_destructor_fn_imps.hpp
+++ b/libstdc++-v3/testsuite/util/regression/rand/priority_queue/detail/constructor_destructor_fn_imps.hpp
@@ -82,7 +82,7 @@ default_constructor()
{
m_p_c = new Cntnr;
}
- catch(forced_exception& )
+ catch(__gnu_cxx::forced_exception_error& )
{
done = false;
}
@@ -137,7 +137,7 @@ copy_constructor()
std::swap(p_c, m_p_c);
}
- catch(forced_exception& )
+ catch(__gnu_cxx::forced_exception_error& )
{
done = false;
}
@@ -173,7 +173,7 @@ assignment_operator()
std::swap(p_c, m_p_c);
}
- catch(forced_exception& )
+ catch(__gnu_cxx::forced_exception_error& )
{
done = false;
}
@@ -222,7 +222,7 @@ it_constructor()
std::swap(p_c, m_p_c);
}
- catch(forced_exception& )
+ catch(__gnu_cxx::forced_exception_error& )
{
done = false;
}
diff --git a/libstdc++-v3/testsuite/util/regression/rand/priority_queue/detail/erase_fn_imps.hpp b/libstdc++-v3/testsuite/util/regression/rand/priority_queue/detail/erase_fn_imps.hpp
index f5e287b..82b126a 100644
--- a/libstdc++-v3/testsuite/util/regression/rand/priority_queue/detail/erase_fn_imps.hpp
+++ b/libstdc++-v3/testsuite/util/regression/rand/priority_queue/detail/erase_fn_imps.hpp
@@ -66,7 +66,7 @@ pop()
m_native_c.pop();
}
}
- catch(forced_exception& )
+ catch(__gnu_cxx::forced_exception_error& )
{
done = false;
@@ -123,7 +123,7 @@ erase_if()
m_p_c,
& m_native_c);
}
- catch(forced_exception& )
+ catch(__gnu_cxx::forced_exception_error& )
{
done = false;
@@ -163,7 +163,7 @@ erase_it()
m_p_c->erase(it);
}
}
- catch(forced_exception& )
+ catch(__gnu_cxx::forced_exception_error& )
{
done = false;
diff --git a/libstdc++-v3/testsuite/util/regression/rand/priority_queue/detail/insert_fn_imps.hpp b/libstdc++-v3/testsuite/util/regression/rand/priority_queue/detail/insert_fn_imps.hpp
index 70eea25..24dc649 100644
--- a/libstdc++-v3/testsuite/util/regression/rand/priority_queue/detail/insert_fn_imps.hpp
+++ b/libstdc++-v3/testsuite/util/regression/rand/priority_queue/detail/insert_fn_imps.hpp
@@ -75,7 +75,7 @@ push()
m_native_c.push(test_traits::native_value(v));
}
- catch(forced_exception& )
+ catch(__gnu_cxx::forced_exception_error& )
{
done = false;
}
diff --git a/libstdc++-v3/testsuite/util/regression/rand/priority_queue/detail/modify_fn_imps.hpp b/libstdc++-v3/testsuite/util/regression/rand/priority_queue/detail/modify_fn_imps.hpp
index e213a2e..5e99e09 100644
--- a/libstdc++-v3/testsuite/util/regression/rand/priority_queue/detail/modify_fn_imps.hpp
+++ b/libstdc++-v3/testsuite/util/regression/rand/priority_queue/detail/modify_fn_imps.hpp
@@ -80,7 +80,7 @@ modify()
m_native_c.modify(native_v, new_native_v);
}
}
- catch(forced_exception& )
+ catch(__gnu_cxx::forced_exception_error& )
{
done = false;
diff --git a/libstdc++-v3/testsuite/util/regression/rand/priority_queue/detail/operator_fn_imps.hpp b/libstdc++-v3/testsuite/util/regression/rand/priority_queue/detail/operator_fn_imps.hpp
index 9b8c0dd..3041bda 100644
--- a/libstdc++-v3/testsuite/util/regression/rand/priority_queue/detail/operator_fn_imps.hpp
+++ b/libstdc++-v3/testsuite/util/regression/rand/priority_queue/detail/operator_fn_imps.hpp
@@ -52,15 +52,12 @@ operator()()
xml_result_set_regression_formatter* p_fmt = NULL;
if (m_disp)
- p_fmt = new xml_result_set_regression_formatter(
- string_form<Cntnr>::name(),
+ p_fmt = new xml_result_set_regression_formatter(string_form<Cntnr>::name(),
string_form<Cntnr>::desc());
m_g.init(m_seed);
m_alloc.init(m_seed);
-
prog_bar pb(m_n, std::cout, m_disp);
-
m_i = 0;
try
@@ -68,9 +65,7 @@ operator()()
for (m_i = 0; m_i < m_n; ++m_i)
{
PB_DS_TRACE("Op #" << static_cast<unsigned long>(m_i));
-
allocator::set_label(m_i);
-
switch(m_i)
{
case 0:
@@ -110,7 +105,7 @@ operator()()
PB_DS_RUN_MTHD(erase_it)
break;
default:
- PB_DS_THROW_IF_FAILED( false, "", m_p_c, & m_native_c);
+ PB_DS_THROW_IF_FAILED(false, "", m_p_c, &m_native_c);
}
break;
case clear_op:
@@ -135,42 +130,35 @@ operator()()
PB_DS_RUN_MTHD(split_join)
break;
default:
- PB_DS_THROW_IF_FAILED( false, "", m_p_c, & m_native_c);
+ PB_DS_THROW_IF_FAILED(false, "", m_p_c, &m_native_c);
}
break;
default:
- PB_DS_THROW_IF_FAILED( false, "", m_p_c, & m_native_c);
+ PB_DS_THROW_IF_FAILED(false, "", m_p_c, &m_native_c);
};
}
-
pb.inc();
}
}
catch(...)
{
- std::cerr << "Failed at index " << static_cast<unsigned long>(m_i) <<
- std::endl;
-
+ std::cerr << "Failed at index " << static_cast<unsigned long>(m_i)
+ << std::endl;
delete m_p_c;
-
throw;
}
-
delete m_p_c;
- if (!m_alloc.dbg_ex_allocator<char>::empty())
+ if (!m_alloc.throw_allocator<char>::empty())
{
std::cerr << "detected leaks!" << std::endl;
-
std::cerr << m_alloc << std::endl;
-
- PB_DS_THROW_IF_FAILED( false, "", m_p_c, & m_native_c);
+ PB_DS_THROW_IF_FAILED(false, "", m_p_c, &m_native_c);
}
if (m_disp)
{
std::cout << std::endl;
-
delete p_fmt;
}
}
@@ -194,9 +182,8 @@ get_next_op()
if (prob < m_ip + m_dp + m_ep + m_cp)
return (clear_op);
- PB_DS_THROW_IF_FAILED( prob <= 1, prob, m_p_c, & m_native_c);
-
- return (other_op);
+ PB_DS_THROW_IF_FAILED(prob <= 1, prob, m_p_c, &m_native_c);
+ return other_op;
}
PB_DS_CLASS_T_DEC
@@ -205,22 +192,17 @@ PB_DS_CLASS_C_DEC::
get_next_sub_op(size_t max)
{
const double p = m_g.get_prob();
-
const double delta = 1 / static_cast<double>(max);
-
size_t i = 0;
-
while (true)
if (p <= (i + 1)* delta)
{
- PB_DS_THROW_IF_FAILED(
- i < max,
+ PB_DS_THROW_IF_FAILED(i < max,
static_cast<unsigned long>(i) << " " <<
static_cast<unsigned long>(max),
m_p_c,
& m_native_c);
-
- return (i);
+ return i;
}
else
++i;
diff --git a/libstdc++-v3/testsuite/util/regression/rand/priority_queue/detail/split_join_fn_imps.hpp b/libstdc++-v3/testsuite/util/regression/rand/priority_queue/detail/split_join_fn_imps.hpp
index b3f7425..41c3027 100644
--- a/libstdc++-v3/testsuite/util/regression/rand/priority_queue/detail/split_join_fn_imps.hpp
+++ b/libstdc++-v3/testsuite/util/regression/rand/priority_queue/detail/split_join_fn_imps.hpp
@@ -105,7 +105,7 @@ split_join()
m_p_c,
& m_native_c);
}
- catch(forced_exception& )
+ catch(__gnu_cxx::forced_exception_error& )
{
done = false;
diff --git a/libstdc++-v3/testsuite/util/regression/res_mng/dbg_ex_allocator.hpp b/libstdc++-v3/testsuite/util/regression/res_mng/dbg_ex_allocator.hpp
deleted file mode 100644
index 53072db..0000000
--- a/libstdc++-v3/testsuite/util/regression/res_mng/dbg_ex_allocator.hpp
+++ /dev/null
@@ -1,129 +0,0 @@
-// -*- C++ -*-
-
-// Copyright (C) 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, 59 Temple Place - Suite 330, Boston,
-// MA 02111-1307, 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.
-
-// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
-
-// Permission to use, copy, modify, sell, and distribute this software
-// is hereby granted without fee, provided that the above copyright
-// notice appears in all copies, and that both that copyright notice
-// and this permission notice appear in supporting documentation. None
-// of the above authors, nor IBM Haifa Research Laboratories, make any
-// representation about the suitability of this software for any
-// purpose. It is provided "as is" without express or implied
-// warranty.
-
-/**
- * @file dbg_ex_allocator.hpp
- * Contains a debugging, exception throwing, allocator used for tests.
- */
-
-#ifndef PB_DS_DBG_EX_ALLOCATOR_HPP
-#define PB_DS_DBG_EX_ALLOCATOR_HPP
-
-#include <regression/res_mng/dbg_ex_allocator_base.hpp>
-
-namespace pb_ds
-{
- namespace test
- {
- template<typename T>
- class dbg_ex_allocator : public detail::dbg_ex_allocator_base
- {
- public:
- typedef size_t size_type;
- typedef ptrdiff_t difference_type;
- typedef T* pointer;
- typedef const T* const_pointer;
- typedef T& reference;
- typedef const T& const_reference;
- typedef T value_type;
-
- template<typename U>
- struct rebind
- {
- typedef dbg_ex_allocator<U> other;
- };
-
- dbg_ex_allocator() throw() { }
-
- dbg_ex_allocator(const dbg_ex_allocator<T>& ) throw() { }
-
- template <class U>
- dbg_ex_allocator(const dbg_ex_allocator<U>& ) throw() { }
-
- ~dbg_ex_allocator() throw() { }
-
- size_type
- max_size() const throw()
- { return std::allocator<T>().max_size(); }
-
- pointer
- allocate(size_type num, std::allocator<void>::const_pointer hint = 0);
-
- void
- construct(pointer p, const T& r_val)
- { return std::allocator<T>().construct(p, r_val); }
-
- void
- destroy(pointer p)
- { std::allocator<T>().destroy(p); }
-
- void
- deallocate(pointer p, size_type num)
- {
- erase(p, sizeof(T) * num);
- std::allocator<T>().deallocate(p, num);
- }
-
- void
- check_allocated(pointer p, size_type num)
- { detail::dbg_ex_allocator_base::check_allocated(p, sizeof(T) * num); }
- };
-
- template<typename T>
- typename dbg_ex_allocator<T>::pointer
- dbg_ex_allocator<T>::
- allocate(size_type num, std::allocator<void>::const_pointer hint/*= 0*/)
- {
- cond_throw();
- T* const a_t = std::allocator<T>().allocate(num, hint);
- insert(a_t, sizeof(T) * num);
- return a_t;
- }
-
- template<typename T>
- inline bool
- operator==(const dbg_ex_allocator<T>& , const dbg_ex_allocator<T>& )
- { return true; }
-
- } // namespace test
-} // namespace pb_ds
-
-#endif
diff --git a/libstdc++-v3/testsuite/util/regression/res_mng/dbg_ex_allocator_base.cc b/libstdc++-v3/testsuite/util/regression/res_mng/dbg_ex_allocator_base.cc
deleted file mode 100644
index 6038ab0..0000000
--- a/libstdc++-v3/testsuite/util/regression/res_mng/dbg_ex_allocator_base.cc
+++ /dev/null
@@ -1,210 +0,0 @@
-// -*- C++ -*-
-
-// Copyright (C) 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, 59 Temple Place - Suite 330, Boston,
-// MA 02111-1307, 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.
-
-// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
-
-// Permission to use, copy, modify, sell, and distribute this software
-// is hereby granted without fee, provided that the above copyright
-// notice appears in all copies, and that both that copyright notice
-// and this permission notice appear in supporting documentation. None
-// of the above authors, nor IBM Haifa Research Laboratories, make any
-// representation about the suitability of this software for any
-// purpose. It is provided "as is" without express or implied
-// warranty.
-
-/**
- * @file dbg_ex_allocator_base.cpp
- * Contains a debugging, exception throwing, allocator used for tests.
- */
-
-#include <util/regression/res_mng/dbg_ex_allocator_base.hpp>
-
-namespace pb_ds
-{
-
- namespace test
- {
-
- namespace detail
- {
-
- twister_rand_gen dbg_ex_allocator_base::s_g;
-
- dbg_ex_allocator_base::map_t
- dbg_ex_allocator_base::s_map;
-
- double dbg_ex_allocator_base::s_throw_prob;
-
- size_t dbg_ex_allocator_base::s_label = 0;
-
- dbg_ex_allocator_base::entry_t
- dbg_ex_allocator_base::
- make_entry(void* p_r, size_t size)
- {
- return std::make_pair(
- p_r,
- alloc_data_t(s_label, size));
- }
-
- void
- dbg_ex_allocator_base::
- init(unsigned long seed)
- {
- s_g.init(seed);
- }
-
- void
- dbg_ex_allocator_base::
- set_throw_prob(double throw_prob)
- {
- s_throw_prob = throw_prob;
- }
-
- double
- dbg_ex_allocator_base::
- get_throw_prob()
- {
- return (s_throw_prob);
- }
-
- void
- dbg_ex_allocator_base::
- set_label(size_t l)
- {
- s_label = l;
- }
-
- void
- dbg_ex_allocator_base::
- insert(void* p_r, size_t size)
- {
- const_iterator found_it = s_map.find(p_r);
-
- if (found_it != s_map.end())
- {
- std::cerr << "Double insert! " << std::endl;
- print_to_ostream(std::cerr, make_entry(p_r, size));
- print_to_ostream(std::cerr, * found_it);
-
- throw std::logic_error("double insert");
- }
-
- s_map.insert(make_entry(p_r, size));
- }
-
- bool
- dbg_ex_allocator_base::
- empty()
- {
- return (s_map.empty());
- }
-
- void
- dbg_ex_allocator_base::
- erase(void* p_r, size_t size)
- {
- check_allocated(p_r, size);
-
- s_map.erase(p_r);
- }
-
- void
- dbg_ex_allocator_base::
- check_allocated(void* p_r, size_t size)
- {
- const_iterator found_it =
- s_map.find(p_r);
-
- if (found_it == s_map.end())
- {
- std::cerr << "Null erase! " << std::endl;
- print_to_ostream(std::cerr, make_entry(p_r, size));
-
- throw std::logic_error("null erase");
- }
-
- if (found_it->second.second != size)
- {
- std::cerr << "Wrong-size erase! " << std::endl;
- print_to_ostream(std::cerr, make_entry(p_r, size));
- print_to_ostream(std::cerr, * found_it);
-
- throw std::logic_error("wrong-size erase");
- }
- }
-
- void
- dbg_ex_allocator_base::
- cond_throw()
- {
- if (s_g.get_prob() < s_throw_prob)
- throw forced_exception();
- }
-
- void
- dbg_ex_allocator_base::
- print_to_ostream(std::ostream& r_os)
- {
- const_iterator it =
- dbg_ex_allocator_base::s_map.begin();
-
- const_iterator end_it =
- dbg_ex_allocator_base::s_map.end();
-
- for (; it != end_it; ++it)
- print_to_ostream(r_os, * it);
-
- r_os << std::endl;
- }
-
- void
- dbg_ex_allocator_base::
- print_to_ostream(std::ostream& r_os, const_reference r_entry)
- {
- r_os << r_entry.first << ": ";
- r_os << r_entry.second.first << ", ";
- r_os << r_entry.second.second;
-
- r_os << std::endl;
- }
-
- std::ostream&
- operator<<(std::ostream& r_os, const dbg_ex_allocator_base& /*r_dbg*/)
- {
- dbg_ex_allocator_base::print_to_ostream(r_os);
-
- return r_os;
- }
-
- } // namespace detail
-
- } // namespace test
-
-} // namespace pb_ds
diff --git a/libstdc++-v3/testsuite/util/regression/res_mng/dbg_ex_allocator_base.hpp b/libstdc++-v3/testsuite/util/regression/res_mng/dbg_ex_allocator_base.hpp
deleted file mode 100644
index 9831281..0000000
--- a/libstdc++-v3/testsuite/util/regression/res_mng/dbg_ex_allocator_base.hpp
+++ /dev/null
@@ -1,163 +0,0 @@
-// -*- C++ -*-
-
-// Copyright (C) 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, 59 Temple Place - Suite 330, Boston,
-// MA 02111-1307, 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.
-
-// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
-
-// Permission to use, copy, modify, sell, and distribute this software
-// is hereby granted without fee, provided that the above copyright
-// notice appears in all copies, and that both that copyright notice
-// and this permission notice appear in supporting documentation. None
-// of the above authors, nor IBM Haifa Research Laboratories, make any
-// representation about the suitability of this software for any
-// purpose. It is provided "as is" without express or implied
-// warranty.
-
-/**
- * @file dbg_ex_allocator_base.hpp
- * Contains a debugging, exception throwing, allocator used for tests.
- */
-
-#ifndef PB_DS_DBG_EX_ALLOCATOR_BASE_HPP
-#define PB_DS_DBG_EX_ALLOCATOR_BASE_HPP
-
-#include <math.h>
-#include <map>
-#include <set>
-#include <iostream>
-#include <stdexcept>
-#include <regression/res_mng/forced_exception.hpp>
-#include <rng/twister_rand_gen.hpp>
-
-namespace pb_ds
-{
- namespace test
- {
- namespace detail
- {
- class dbg_ex_allocator_base;
-
- std::ostream&
- operator<<(std::ostream& r_os, const dbg_ex_allocator_base& r_dbg);
-
- class dbg_ex_allocator_base
- {
- public:
- typedef size_t label;
-
- public:
- void
- init(unsigned long seed);
-
- static void
- set_throw_prob(double throw_prob);
-
- static double
- get_throw_prob();
-
- static void
- set_label(size_t l);
-
- static bool
- empty();
-
- class group_throw_prob_adjustor
- {
- public:
- group_throw_prob_adjustor(size_t size) : m_orig_throw_prob(s_throw_prob)
- {
- s_throw_prob =
- 1 - ::pow(double(1 - s_throw_prob), double(0.5 / (size + 1)));
- }
-
- ~group_throw_prob_adjustor()
- { s_throw_prob = m_orig_throw_prob; }
-
- private:
- const double m_orig_throw_prob;
- };
-
- class zero_throw_prob_adjustor
- {
- public:
- zero_throw_prob_adjustor() : m_orig_throw_prob(s_throw_prob)
- { s_throw_prob = 0; }
-
- ~zero_throw_prob_adjustor()
- { s_throw_prob = m_orig_throw_prob; }
-
- private:
- const double m_orig_throw_prob;
- };
-
- protected:
- static void
- insert(void* p_r, size_t size);
-
- static void
- erase(void* p_r, size_t size);
-
- static void
- cond_throw();
-
- static void
- assert_allocatod(const void* p_r, size_t size);
-
- static void
- check_allocated(void* p_r, size_t size);
-
- private:
- typedef std::pair<label, size_t> alloc_data_t;
- typedef std::map<void*, alloc_data_t> map_t;
- typedef map_t::value_type entry_t;
- typedef map_t::const_iterator const_iterator;
- typedef map_t::const_reference const_reference;
-
- static void
- print_to_ostream(std::ostream& r_os);
-
- static void
- print_to_ostream(std::ostream& r_os, const_reference r_entry);
-
- static entry_t
- make_entry(void* p_r, size_t size);
-
- static twister_rand_gen s_g;
- static map_t s_map;
- static double s_throw_prob;
- static size_t s_label;
-
- friend std::ostream& operator<<(std::ostream& r_os,
- const dbg_ex_allocator_base& r_dbg);
- };
- } // namespace detail
- } // namespace test
-} // namespace pb_ds
-
-#endif // #ifndef PB_DS_DBG_EX_ALLOCATOR_BASE_HPP
diff --git a/libstdc++-v3/testsuite/util/regression/res_mng/forced_exception.hpp b/libstdc++-v3/testsuite/util/regression/res_mng/forced_exception.hpp
deleted file mode 100644
index 3694203..0000000
--- a/libstdc++-v3/testsuite/util/regression/res_mng/forced_exception.hpp
+++ /dev/null
@@ -1,60 +0,0 @@
-// -*- C++ -*-
-
-// Copyright (C) 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, 59 Temple Place - Suite 330, Boston,
-// MA 02111-1307, 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.
-
-// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
-
-// Permission to use, copy, modify, sell, and distribute this software
-// is hereby granted without fee, provided that the above copyright
-// notice appears in all copies, and that both that copyright notice
-// and this permission notice appear in supporting documentation. None
-// of the above authors, nor IBM Haifa Research Laboratories, make any
-// representation about the suitability of this software for any
-// purpose. It is provided "as is" without express or implied
-// warranty.
-
-/**
- * @file forced_exception.hpp
- * Contains an exception thrown by the debugging allocator.
- */
-
-#ifndef PB_DS_FORCED_EXCEPTION_HPP
-#define PB_DS_FORCED_EXCEPTION_HPP
-
-namespace pb_ds
-{
- namespace test
- {
- struct forced_exception
- { };
- } // namespace test
-} // namespace pb_ds
-
-#endif // #ifndef PB_DS_FORCED_EXCEPTION_HPP
-
diff --git a/libstdc++-v3/testsuite/util/rng/twister_rand_gen.cc b/libstdc++-v3/testsuite/util/rng/twister_rand_gen.cc
index 879844a..fbe7e8a 100644
--- a/libstdc++-v3/testsuite/util/rng/twister_rand_gen.cc
+++ b/libstdc++-v3/testsuite/util/rng/twister_rand_gen.cc
@@ -68,14 +68,11 @@ namespace pb_ds
get_unsigned_long(unsigned long min, unsigned long max)
{
_GLIBCXX_DEBUG_ASSERT(max >= min);
-
const double prob = get_prob();
-
const unsigned long rand_word =
(unsigned long)((max - min + 1) * prob) + min;
_GLIBCXX_DEBUG_ASSERT(rand_word <= max);
-
return rand_word;
}
@@ -91,9 +88,7 @@ namespace pb_ds
static_cast<const double>(m_base_generator() - eng_min);
const double ret = eng_res / eng_range;
-
- _GLIBCXX_DEBUG_ASSERT(ret >=0 && ret <= 1);
-
+ _GLIBCXX_DEBUG_ASSERT(ret >= 0 && ret <= 1);
return ret;
}
} // namespace test
diff --git a/libstdc++-v3/testsuite/util/testsuite_allocator.h b/libstdc++-v3/testsuite/util/testsuite_allocator.h
index 0ea1215..7c5f572 100644
--- a/libstdc++-v3/testsuite/util/testsuite_allocator.h
+++ b/libstdc++-v3/testsuite/util/testsuite_allocator.h
@@ -362,82 +362,6 @@ namespace __gnu_test
int personality;
};
-
-
- template<typename Tp>
- class throw_allocator
- {
- public:
- typedef std::size_t size_type;
- typedef std::ptrdiff_t difference_type;
- typedef Tp* pointer;
- typedef const Tp* const_pointer;
- typedef Tp& reference;
- typedef const Tp& const_reference;
- typedef Tp value_type;
-
- template<typename Tp1>
- struct rebind
- { typedef throw_allocator<Tp1> other; };
-
- throw_allocator() throw()
- : count(size_type(-1)) { }
-
- throw_allocator(size_type c) throw()
- : count(c) { }
-
- template<typename Tp1>
- throw_allocator(const throw_allocator<Tp1>& b) throw()
- : count(b.get_count()) { }
-
- size_type get_count() const { return count; }
-
- pointer
- address(reference x) const { return &x; }
-
- const_pointer
- address(const_reference x) const { return &x; }
-
- pointer
- allocate(size_type n, const void* = 0)
- {
- if (count == 0)
- throw std::bad_alloc();
-
- if (count != size_type(-1))
- --count;
-
- return static_cast<Tp*>(::operator new(n * sizeof(Tp)));
- }
-
- void
- deallocate(pointer p, size_type)
- { ::operator delete(p); }
-
- size_type
- max_size() const throw()
- { return size_type(-1) / sizeof(Tp); }
-
- void
- construct(pointer p, const Tp& val)
- { ::new(p) Tp(val); }
-
- void
- destroy(pointer p) { p->~Tp(); }
-
- private:
- template<typename Tp1>
- friend inline bool
- operator==(const throw_allocator&, const throw_allocator<Tp1>&)
- { return true; }
-
- template<typename Tp1>
- friend inline bool
- operator!=(const throw_allocator&, const throw_allocator<Tp1>&)
- { return false; }
-
- size_type count;
- };
}; // namespace __gnu_test
#endif // _GLIBCXX_TESTSUITE_ALLOCATOR_H