diff options
author | bkoz <bkoz@138bc75d-0d04-0410-961f-82ee72b054a4> | 2009-05-28 00:17:00 +0000 |
---|---|---|
committer | bkoz <bkoz@138bc75d-0d04-0410-961f-82ee72b054a4> | 2009-05-28 00:17:00 +0000 |
commit | b65cbad54772871969d7ef9b19bed67d9e0fb807 (patch) | |
tree | 2e359c3d5a629e6ade88c3f85b5972792348d575 /libstdc++-v3/testsuite/ext/mt_allocator | |
parent | 99385b4bf103b95e840017382cd671ec93ec2e15 (diff) | |
download | ppe42-gcc-b65cbad54772871969d7ef9b19bed67d9e0fb807.tar.gz ppe42-gcc-b65cbad54772871969d7ef9b19bed67d9e0fb807.zip |
2009-05-28 Benjamin Kosnik <bkoz@redhat.com>
* testsuite/util/testsuite_allocator.h (check_new, check_delete): Move
to ...
* testsuite/util/replacement_memory_operators.h: ...here. New.
* testsuite/util/testsuite_hooks.h (counter): To object_counter.
* testsuite/util/testsuite_hooks.cc: Same.
* testsuite/ext/mt_allocator/deallocate_local_thread-1.cc: Use
replacement_memory_operators.h.
* testsuite/ext/mt_allocator/deallocate_local_thread-3.cc: Same.
* testsuite/ext/mt_allocator/check_delete.cc: Same.
* testsuite/ext/mt_allocator/deallocate_local_thread-5.cc: Same.
* testsuite/ext/mt_allocator/deallocate_local_thread-7.cc: Same.
* testsuite/ext/mt_allocator/deallocate_global_thread-1.cc: Same.
* testsuite/ext/mt_allocator/deallocate_global_thread-3.cc: Same.
* testsuite/ext/mt_allocator/deallocate_local-2.cc: Same.
* testsuite/ext/mt_allocator/deallocate_local-4.cc: Same.
* testsuite/ext/mt_allocator/deallocate_local-6.cc: Same.
* testsuite/ext/mt_allocator/deallocate_local-8.cc: Same.
* testsuite/ext/mt_allocator/deallocate_global-2.cc: Same.
* testsuite/ext/mt_allocator/deallocate_global-4.cc: Same.
* testsuite/ext/mt_allocator/check_new.cc: Same.
* testsuite/ext/debug_allocator/check_delete.cc: Same.
* testsuite/ext/debug_allocator/check_new.cc: Same.
* testsuite/ext/new_allocator/deallocate_global.cc: Same.
* testsuite/ext/new_allocator/check_delete.cc: Same.
* testsuite/ext/new_allocator/check_new.cc: Same.
* testsuite/ext/new_allocator/deallocate_local.cc: Same.
* testsuite/ext/throw_allocator/deallocate_global.cc: Same.
* testsuite/ext/throw_allocator/check_delete.cc: Same.
* testsuite/ext/throw_allocator/check_new.cc: Same.
* testsuite/ext/throw_allocator/deallocate_local.cc: Same.
* testsuite/ext/malloc_allocator/deallocate_global.cc: Same.
* testsuite/ext/malloc_allocator/check_delete.cc: Same.
* testsuite/ext/malloc_allocator/check_new.cc: Same.
* testsuite/ext/malloc_allocator/deallocate_local.cc: Same.
* testsuite/ext/pool_allocator/check_delete.cc: Same.
* testsuite/ext/pool_allocator/check_new.cc: Same.
* testsuite/ext/bitmap_allocator/check_delete.cc: Same.
* testsuite/ext/bitmap_allocator/check_new.cc: Same.
* testsuite/ext/array_allocator/check_delete.cc: Same.
* testsuite/ext/array_allocator/check_new.cc: Same.
* testsuite/23_containers/deque/cons/1.cc: Same.
* testsuite/23_containers/deque/cons/2.cc: Same.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@147937 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libstdc++-v3/testsuite/ext/mt_allocator')
14 files changed, 56 insertions, 495 deletions
diff --git a/libstdc++-v3/testsuite/ext/mt_allocator/check_delete.cc b/libstdc++-v3/testsuite/ext/mt_allocator/check_delete.cc index 470b66f5cf6..374c567060a 100644 --- a/libstdc++-v3/testsuite/ext/mt_allocator/check_delete.cc +++ b/libstdc++-v3/testsuite/ext/mt_allocator/check_delete.cc @@ -21,34 +21,11 @@ #include <cstdlib> #include <ext/mt_allocator.h> -#include <testsuite_hooks.h> -#include <testsuite_allocator.h> - -using __gnu_cxx::__mt_alloc; - -void* -operator new(std::size_t n) throw(std::bad_alloc) -{ - new_called = true; - return std::malloc(n); -} - -void -operator delete(void* v) throw() -{ - delete_called = true; - return std::free(v); -} - -void test01() -{ - bool test __attribute__((unused)) = true; - typedef __mt_alloc<unsigned int> allocator_type; - VERIFY( bool(__gnu_test::check_delete<allocator_type, false>()) ); -} +#include <replacement_memory_operators.h> int main() -{ - test01(); +{ + typedef __gnu_cxx::__mt_alloc<unsigned int> allocator_type; + __gnu_test::check_delete<allocator_type, false>(); return 0; } diff --git a/libstdc++-v3/testsuite/ext/mt_allocator/check_new.cc b/libstdc++-v3/testsuite/ext/mt_allocator/check_new.cc index 171a2073f3c..52793264063 100644 --- a/libstdc++-v3/testsuite/ext/mt_allocator/check_new.cc +++ b/libstdc++-v3/testsuite/ext/mt_allocator/check_new.cc @@ -21,35 +21,12 @@ #include <cstdlib> #include <ext/mt_allocator.h> -#include <testsuite_hooks.h> -#include <testsuite_allocator.h> +#include <replacement_memory_operators.h> -using __gnu_cxx::__mt_alloc; - -void* -operator new(std::size_t n) throw(std::bad_alloc) -{ - new_called = true; - return std::malloc(n); -} - -void -operator delete(void* v) throw() -{ - delete_called = true; - return std::free(v); -} - -void test01() +int main() { // Uses new but delete only optionally. - bool test __attribute__((unused)) = true; - typedef __mt_alloc<unsigned int> allocator_type; - VERIFY( bool(__gnu_test::check_new<allocator_type, true>()) ); -} - -int main() -{ - test01(); + typedef __gnu_cxx::__mt_alloc<unsigned int> allocator_type; + __gnu_test::check_new<allocator_type, true>(); return 0; } diff --git a/libstdc++-v3/testsuite/ext/mt_allocator/deallocate_global-2.cc b/libstdc++-v3/testsuite/ext/mt_allocator/deallocate_global-2.cc index a75f38a0724..fcc5006bd3c 100644 --- a/libstdc++-v3/testsuite/ext/mt_allocator/deallocate_global-2.cc +++ b/libstdc++-v3/testsuite/ext/mt_allocator/deallocate_global-2.cc @@ -24,43 +24,7 @@ #include <stdexcept> #include <cstdio> #include <ext/mt_allocator.h> - -static size_t count; - -struct count_check -{ - count_check() { } - ~count_check() - { - // NB: __mt_allocator doesn't clean itself up. Thus, this will not - // be zero. - if (count != 0) - { - //throw std::runtime_error("allocation/deallocation count isn't zero"); - printf("allocation/deallocation count is %zu \n", count); - } - } -}; - -static count_check check; - -void* operator new(size_t size) throw(std::bad_alloc) -{ - printf("operator new is called \n"); - void* p = malloc(size); - if (p == NULL) - throw std::bad_alloc(); - count++; - return p; -} - -void operator delete(void* p) throw() -{ - printf("operator delete is called \n"); - if (p == NULL) - return; - count--; -} +#include <replacement_memory_operators.h> typedef std::string value_type; using __gnu_cxx::__pool; @@ -74,6 +38,9 @@ list_type l; int main() { + // NB: __mt_allocator doesn't clean itself up. Thus, the count will + // not be zero. + __gnu_test::counter::exceptions(false); l.push_back("bayou bend"); return 0; } diff --git a/libstdc++-v3/testsuite/ext/mt_allocator/deallocate_global-4.cc b/libstdc++-v3/testsuite/ext/mt_allocator/deallocate_global-4.cc index bc9c2c7d477..cafbffb3494 100644 --- a/libstdc++-v3/testsuite/ext/mt_allocator/deallocate_global-4.cc +++ b/libstdc++-v3/testsuite/ext/mt_allocator/deallocate_global-4.cc @@ -24,43 +24,7 @@ #include <stdexcept> #include <cstdio> #include <ext/mt_allocator.h> - -static size_t count; - -struct count_check -{ - count_check() { } - ~count_check() - { - // NB: __mt_allocator doesn't clean itself up. Thus, this will not - // be zero. - if (count != 0) - { - //throw std::runtime_error("allocation/deallocation count isn't zero"); - printf("allocation/deallocation count is %zu \n", count); - } - } -}; - -static count_check check; - -void* operator new(size_t size) throw(std::bad_alloc) -{ - printf("operator new is called \n"); - void* p = malloc(size); - if (p == NULL) - throw std::bad_alloc(); - count++; - return p; -} - -void operator delete(void* p) throw() -{ - printf("operator delete is called \n"); - if (p == NULL) - return; - count--; -} +#include <replacement_memory_operators.h> typedef std::string value_t; using __gnu_cxx::__pool; @@ -74,6 +38,9 @@ list_type l; int main() { + // NB: __mt_allocator doesn't clean itself up. Thus, the count will + // not be zero. + __gnu_test::counter::exceptions(false); l.push_back("bayou bend"); return 0; } diff --git a/libstdc++-v3/testsuite/ext/mt_allocator/deallocate_global_thread-1.cc b/libstdc++-v3/testsuite/ext/mt_allocator/deallocate_global_thread-1.cc index 6881c9f3d1a..f61cd38b790 100644 --- a/libstdc++-v3/testsuite/ext/mt_allocator/deallocate_global_thread-1.cc +++ b/libstdc++-v3/testsuite/ext/mt_allocator/deallocate_global_thread-1.cc @@ -24,43 +24,7 @@ #include <stdexcept> #include <cstdio> #include <ext/mt_allocator.h> - -static size_t count; - -struct count_check -{ - count_check() { } - ~count_check() - { - // NB: __mt_allocator doesn't clean itself up. Thus, this will not - // be zero. - if (count != 0) - { - //throw std::runtime_error("allocation/deallocation count isn't zero"); - printf("allocation/deallocation count is %zu \n", count); - } - } -}; - -static count_check check; - -void* operator new(size_t size) throw(std::bad_alloc) -{ - printf("operator new is called \n"); - void* p = malloc(size); - if (p == NULL) - throw std::bad_alloc(); - count++; - return p; -} - -void operator delete(void* p) throw() -{ - printf("operator delete is called \n"); - if (p == NULL) - return; - count--; -} +#include <replacement_memory_operators.h> typedef std::string value_type; using __gnu_cxx::__pool; @@ -74,6 +38,9 @@ list_type l; int main() { + // NB: __mt_allocator doesn't clean itself up. Thus, the count will + // not be zero. + __gnu_test::counter::exceptions(false); l.push_back("bayou bend"); return 0; } diff --git a/libstdc++-v3/testsuite/ext/mt_allocator/deallocate_global_thread-3.cc b/libstdc++-v3/testsuite/ext/mt_allocator/deallocate_global_thread-3.cc index 2724d36392f..62074f0a426 100644 --- a/libstdc++-v3/testsuite/ext/mt_allocator/deallocate_global_thread-3.cc +++ b/libstdc++-v3/testsuite/ext/mt_allocator/deallocate_global_thread-3.cc @@ -24,43 +24,7 @@ #include <stdexcept> #include <cstdio> #include <ext/mt_allocator.h> - -static size_t count; - -struct count_check -{ - count_check() { } - ~count_check() - { - // NB: __mt_allocator doesn't clean itself up. Thus, this will not - // be zero. - if (count != 0) - { - //throw std::runtime_error("allocation/deallocation count isn't zero"); - printf("allocation/deallocation count is %zu \n", count); - } - } -}; - -static count_check check; - -void* operator new(size_t size) throw(std::bad_alloc) -{ - printf("operator new is called \n"); - void* p = malloc(size); - if (p == NULL) - throw std::bad_alloc(); - count++; - return p; -} - -void operator delete(void* p) throw() -{ - printf("operator delete is called \n"); - if (p == NULL) - return; - count--; -} +#include <replacement_memory_operators.h> typedef std::string value_type; using __gnu_cxx::__pool; @@ -74,6 +38,9 @@ list_type l; int main() { + // NB: __mt_allocator doesn't clean itself up. Thus, the count will + // not be zero. + __gnu_test::counter::exceptions(false); l.push_back("bayou bend"); return 0; } diff --git a/libstdc++-v3/testsuite/ext/mt_allocator/deallocate_local-2.cc b/libstdc++-v3/testsuite/ext/mt_allocator/deallocate_local-2.cc index eec6dea8c1b..9ccebd57ed0 100644 --- a/libstdc++-v3/testsuite/ext/mt_allocator/deallocate_local-2.cc +++ b/libstdc++-v3/testsuite/ext/mt_allocator/deallocate_local-2.cc @@ -23,43 +23,7 @@ #include <stdexcept> #include <cstdio> #include <ext/mt_allocator.h> - -static size_t count; - -struct count_check -{ - count_check() { } - ~count_check() - { - // NB: __mt_allocator doesn't clean itself up. Thus, this will not - // be zero. - if (count != 0) - { - //throw std::runtime_error("allocation/deallocation count isn't zero"); - printf("allocation/deallocation count is %zu \n", count); - } - } -}; - -static count_check check; - -void* operator new(size_t size) throw(std::bad_alloc) -{ - printf("operator new is called \n"); - void* p = malloc(size); - if (p == NULL) - throw std::bad_alloc(); - count++; - return p; -} - -void operator delete(void* p) throw() -{ - printf("operator delete is called \n"); - if (p == NULL) - return; - count--; -} +#include <replacement_memory_operators.h> typedef char value_type; typedef std::char_traits<value_type> traits_type; @@ -70,6 +34,9 @@ typedef std::basic_string<value_type, traits_type, allocator_type> string_type; int main() { + // NB: __mt_allocator doesn't clean itself up. Thus, the count will + // not be zero. + __gnu_test::counter::exceptions(false); string_type s; s += "bayou bend"; return 0; diff --git a/libstdc++-v3/testsuite/ext/mt_allocator/deallocate_local-4.cc b/libstdc++-v3/testsuite/ext/mt_allocator/deallocate_local-4.cc index 793f6406164..9265a15a98b 100644 --- a/libstdc++-v3/testsuite/ext/mt_allocator/deallocate_local-4.cc +++ b/libstdc++-v3/testsuite/ext/mt_allocator/deallocate_local-4.cc @@ -23,43 +23,7 @@ #include <stdexcept> #include <cstdio> #include <ext/mt_allocator.h> - -static size_t count; - -struct count_check -{ - count_check() { } - ~count_check() - { - // NB: __mt_allocator doesn't clean itself up. Thus, this will not - // be zero. - if (count != 0) - { - printf("allocation/deallocation count is %zu \n", count); - //throw std::runtime_error("allocation/deallocation count isn't zero"); - } - } -}; - -static count_check check; - -void* operator new(size_t size) throw(std::bad_alloc) -{ - printf("operator new is called \n"); - void* p = malloc(size); - if (p == NULL) - throw std::bad_alloc(); - count++; - return p; -} - -void operator delete(void* p) throw() -{ - printf("operator delete is called \n"); - if (p == NULL) - return; - count--; -} +#include <replacement_memory_operators.h> typedef char value_type; typedef std::char_traits<value_type> traits_type; @@ -71,6 +35,9 @@ typedef std::basic_string<value_type, traits_type, allocator_type> string_type; int main() { + // NB: __mt_allocator doesn't clean itself up. Thus, the count will + // not be zero. + __gnu_test::counter::exceptions(false); string_type s; s += "bayou bend"; return 0; diff --git a/libstdc++-v3/testsuite/ext/mt_allocator/deallocate_local-6.cc b/libstdc++-v3/testsuite/ext/mt_allocator/deallocate_local-6.cc index fd1da97a53b..01755713885 100644 --- a/libstdc++-v3/testsuite/ext/mt_allocator/deallocate_local-6.cc +++ b/libstdc++-v3/testsuite/ext/mt_allocator/deallocate_local-6.cc @@ -24,42 +24,7 @@ #include <stdexcept> #include <cstdio> #include <ext/mt_allocator.h> - -static size_t count; - -struct count_check -{ - count_check() { } - ~count_check() - { - // NB: Using a pool that attempts to clean up resource use. - if (count != 0) - { - printf("allocation/deallocation count is %zu \n", count); - throw std::runtime_error("allocation/deallocation count isn't zero"); - } - } -}; - -static count_check check; - -void* operator new(size_t size) throw(std::bad_alloc) -{ - printf("operator new is called \n"); - void* p = malloc(size); - if (p == NULL) - throw std::bad_alloc(); - count++; - return p; -} - -void operator delete(void* p) throw() -{ - printf("operator delete is called \n"); - if (p == NULL) - return; - count--; -} +#include <replacement_memory_operators.h> template<bool _Thread> struct cleanup_pool : public __gnu_cxx::__pool<false> @@ -81,6 +46,9 @@ typedef std::basic_string<value_type, traits_type, allocator_type> string_type; int main() { + // NB: __mt_allocator doesn't clean itself up. Thus, the count will + // not be zero. + __gnu_test::counter::exceptions(false); string_type s; s += "bayou bend"; return 0; diff --git a/libstdc++-v3/testsuite/ext/mt_allocator/deallocate_local-8.cc b/libstdc++-v3/testsuite/ext/mt_allocator/deallocate_local-8.cc index 1574e8cb473..34005e4b091 100644 --- a/libstdc++-v3/testsuite/ext/mt_allocator/deallocate_local-8.cc +++ b/libstdc++-v3/testsuite/ext/mt_allocator/deallocate_local-8.cc @@ -24,42 +24,7 @@ #include <stdexcept> #include <cstdio> #include <ext/mt_allocator.h> - -static size_t count; - -struct count_check -{ - count_check() { } - ~count_check() - { - // NB: Using a pool that attempts to clean up resource use. - if (count != 0) - { - printf("allocation/deallocation count is %zu \n", count); - throw std::runtime_error("allocation/deallocation count isn't zero"); - } - } -}; - -static count_check check; - -void* operator new(size_t size) throw(std::bad_alloc) -{ - printf("operator new is called \n"); - void* p = malloc(size); - if (p == NULL) - throw std::bad_alloc(); - count++; - return p; -} - -void operator delete(void* p) throw() -{ - printf("operator delete is called \n"); - if (p == NULL) - return; - count--; -} +#include <replacement_memory_operators.h> template<bool _Thread> struct cleanup_pool : public __gnu_cxx::__pool<false> @@ -82,6 +47,9 @@ typedef std::basic_string<value_type, traits_type, allocator_type> string_type; int main() { + // NB: __mt_allocator doesn't clean itself up. Thus, the count will + // not be zero. + __gnu_test::counter::exceptions(false); string_type s; s += "bayou bend"; return 0; diff --git a/libstdc++-v3/testsuite/ext/mt_allocator/deallocate_local_thread-1.cc b/libstdc++-v3/testsuite/ext/mt_allocator/deallocate_local_thread-1.cc index 399d57686f1..012a7585acf 100644 --- a/libstdc++-v3/testsuite/ext/mt_allocator/deallocate_local_thread-1.cc +++ b/libstdc++-v3/testsuite/ext/mt_allocator/deallocate_local_thread-1.cc @@ -23,43 +23,7 @@ #include <stdexcept> #include <cstdio> #include <ext/mt_allocator.h> - -static size_t count; - -struct count_check -{ - count_check() { } - ~count_check() - { - // NB: __mt_allocator doesn't clean itself up. Thus, this will not - // be zero. - if (count != 0) - { - //throw std::runtime_error("allocation/deallocation count isn't zero"); - printf("allocation/deallocation count is %zu \n", count); - } - } -}; - -static count_check check; - -void* operator new(size_t size) throw(std::bad_alloc) -{ - printf("operator new is called \n"); - void* p = malloc(size); - if (p == NULL) - throw std::bad_alloc(); - count++; - return p; -} - -void operator delete(void* p) throw() -{ - printf("operator delete is called \n"); - if (p == NULL) - return; - count--; -} +#include <replacement_memory_operators.h> typedef char value_type; typedef std::char_traits<value_type> traits_type; @@ -70,6 +34,9 @@ typedef std::basic_string<value_type, traits_type, allocator_type> string_type; int main() { + // NB: __mt_allocator doesn't clean itself up. Thus, the count will + // not be zero. + __gnu_test::counter::exceptions(false); string_type s; s += "bayou bend"; return 0; diff --git a/libstdc++-v3/testsuite/ext/mt_allocator/deallocate_local_thread-3.cc b/libstdc++-v3/testsuite/ext/mt_allocator/deallocate_local_thread-3.cc index 38977c569dd..0a9fde02b12 100644 --- a/libstdc++-v3/testsuite/ext/mt_allocator/deallocate_local_thread-3.cc +++ b/libstdc++-v3/testsuite/ext/mt_allocator/deallocate_local_thread-3.cc @@ -23,43 +23,7 @@ #include <stdexcept> #include <cstdio> #include <ext/mt_allocator.h> - -static size_t count; - -struct count_check -{ - count_check() { } - ~count_check() - { - // NB: __mt_allocator doesn't clean itself up. Thus, this will not - // be zero. - if (count != 0) - { - //throw std::runtime_error("allocation/deallocation count isn't zero"); - printf("allocation/deallocation count is %zu \n", count); - } - } -}; - -static count_check check; - -void* operator new(size_t size) throw(std::bad_alloc) -{ - printf("operator new is called \n"); - void* p = malloc(size); - if (p == NULL) - throw std::bad_alloc(); - count++; - return p; -} - -void operator delete(void* p) throw() -{ - printf("operator delete is called \n"); - if (p == NULL) - return; - count--; -} +#include <replacement_memory_operators.h> typedef char value_type; typedef std::char_traits<value_type> traits_type; @@ -71,6 +35,9 @@ typedef std::basic_string<value_type, traits_type, allocator_type> string_type; int main() { + // NB: __mt_allocator doesn't clean itself up. Thus, the count will + // not be zero. + __gnu_test::counter::exceptions(false); string_type s; s += "bayou bend"; return 0; diff --git a/libstdc++-v3/testsuite/ext/mt_allocator/deallocate_local_thread-5.cc b/libstdc++-v3/testsuite/ext/mt_allocator/deallocate_local_thread-5.cc index 49701c09bbc..a812aecf26c 100644 --- a/libstdc++-v3/testsuite/ext/mt_allocator/deallocate_local_thread-5.cc +++ b/libstdc++-v3/testsuite/ext/mt_allocator/deallocate_local_thread-5.cc @@ -24,42 +24,7 @@ #include <stdexcept> #include <cstdio> #include <ext/mt_allocator.h> - -static size_t count; - -struct count_check -{ - count_check() { } - ~count_check() - { - // NB: Using a pool that attempts to clean up resource use. - if (count != 0) - { - printf("allocation/deallocation count is %zu \n", count); - throw std::runtime_error("allocation/deallocation count isn't zero"); - } - } -}; - -static count_check check; - -void* operator new(size_t size) throw(std::bad_alloc) -{ - printf("operator new is called \n"); - void* p = malloc(size); - if (p == NULL) - throw std::bad_alloc(); - count++; - return p; -} - -void operator delete(void* p) throw() -{ - printf("operator delete is called \n"); - if (p == NULL) - return; - count--; -} +#include <replacement_memory_operators.h> template<bool _Thread> struct cleanup_pool : public __gnu_cxx::__pool<true> @@ -72,7 +37,6 @@ template<bool _Thread> ~cleanup_pool() throw() { this->_M_destroy(); } }; - typedef char value_type; typedef std::char_traits<value_type> traits_type; typedef __gnu_cxx::__common_pool_policy<cleanup_pool, true> policy_type; @@ -81,6 +45,9 @@ typedef std::basic_string<value_type, traits_type, allocator_type> string_type; int main() { + // NB: __mt_allocator doesn't clean itself up. Thus, the count will + // not be zero. + __gnu_test::counter::exceptions(false); string_type s; s += "bayou bend"; return 0; diff --git a/libstdc++-v3/testsuite/ext/mt_allocator/deallocate_local_thread-7.cc b/libstdc++-v3/testsuite/ext/mt_allocator/deallocate_local_thread-7.cc index 5bdfd0db8bb..ac8426ee9fc 100644 --- a/libstdc++-v3/testsuite/ext/mt_allocator/deallocate_local_thread-7.cc +++ b/libstdc++-v3/testsuite/ext/mt_allocator/deallocate_local_thread-7.cc @@ -24,42 +24,7 @@ #include <stdexcept> #include <cstdio> #include <ext/mt_allocator.h> - -static size_t count; - -struct count_check -{ - count_check() { } - ~count_check() - { - // NB: Using a pool that attempts to clean up resource use. - if (count != 0) - { - printf("allocation/deallocation count is %zu \n", count); - throw std::runtime_error("allocation/deallocation count isn't zero"); - } - } -}; - -static count_check check; - -void* operator new(size_t size) throw(std::bad_alloc) -{ - printf("operator new is called \n"); - void* p = malloc(size); - if (p == NULL) - throw std::bad_alloc(); - count++; - return p; -} - -void operator delete(void* p) throw() -{ - printf("operator delete is called \n"); - if (p == NULL) - return; - count--; -} +#include <replacement_memory_operators.h> template<bool _Thread> struct cleanup_pool : public __gnu_cxx::__pool<true> @@ -82,6 +47,9 @@ typedef std::basic_string<value_type, traits_type, allocator_type> string_type; int main() { + // NB: __mt_allocator doesn't clean itself up. Thus, the count will + // not be zero. + __gnu_test::counter::exceptions(false); string_type s; s += "bayou bend"; return 0; |