summaryrefslogtreecommitdiff
path: root/libstdc++-v3/testsuite/ext/mt_allocator
diff options
context:
space:
mode:
authorupstream source tree <ports@midipix.org>2015-03-15 20:14:05 -0400
committerupstream source tree <ports@midipix.org>2015-03-15 20:14:05 -0400
commit554fd8c5195424bdbcabf5de30fdc183aba391bd (patch)
tree976dc5ab7fddf506dadce60ae936f43f58787092 /libstdc++-v3/testsuite/ext/mt_allocator
downloadcbb-gcc-4.6.4-554fd8c5195424bdbcabf5de30fdc183aba391bd.tar.bz2
cbb-gcc-4.6.4-554fd8c5195424bdbcabf5de30fdc183aba391bd.tar.xz
obtained gcc-4.6.4.tar.bz2 from upstream website;upstream
verified gcc-4.6.4.tar.bz2.sig; imported gcc-4.6.4 source tree from verified upstream tarball. downloading a git-generated archive based on the 'upstream' tag should provide you with a source tree that is binary identical to the one extracted from the above tarball. if you have obtained the source via the command 'git clone', however, do note that line-endings of files in your working directory might differ from line-endings of the respective files in the upstream repository.
Diffstat (limited to 'libstdc++-v3/testsuite/ext/mt_allocator')
-rw-r--r--libstdc++-v3/testsuite/ext/mt_allocator/22309_thread.cc99
-rw-r--r--libstdc++-v3/testsuite/ext/mt_allocator/check_allocate_big_per_type.cc54
-rw-r--r--libstdc++-v3/testsuite/ext/mt_allocator/check_allocate_max_size.cc30
-rw-r--r--libstdc++-v3/testsuite/ext/mt_allocator/check_deallocate_null.cc33
-rw-r--r--libstdc++-v3/testsuite/ext/mt_allocator/check_deallocate_null_thread.cc33
-rw-r--r--libstdc++-v3/testsuite/ext/mt_allocator/check_delete.cc31
-rw-r--r--libstdc++-v3/testsuite/ext/mt_allocator/check_new.cc32
-rw-r--r--libstdc++-v3/testsuite/ext/mt_allocator/deallocate_global-2.cc46
-rw-r--r--libstdc++-v3/testsuite/ext/mt_allocator/deallocate_global-4.cc46
-rw-r--r--libstdc++-v3/testsuite/ext/mt_allocator/deallocate_global_thread-1.cc46
-rw-r--r--libstdc++-v3/testsuite/ext/mt_allocator/deallocate_global_thread-3.cc46
-rw-r--r--libstdc++-v3/testsuite/ext/mt_allocator/deallocate_local-2.cc43
-rw-r--r--libstdc++-v3/testsuite/ext/mt_allocator/deallocate_local-4.cc44
-rw-r--r--libstdc++-v3/testsuite/ext/mt_allocator/deallocate_local-6.cc55
-rw-r--r--libstdc++-v3/testsuite/ext/mt_allocator/deallocate_local-8.cc56
-rw-r--r--libstdc++-v3/testsuite/ext/mt_allocator/deallocate_local_thread-1.cc43
-rw-r--r--libstdc++-v3/testsuite/ext/mt_allocator/deallocate_local_thread-3.cc44
-rw-r--r--libstdc++-v3/testsuite/ext/mt_allocator/deallocate_local_thread-5.cc54
-rw-r--r--libstdc++-v3/testsuite/ext/mt_allocator/deallocate_local_thread-7.cc56
-rw-r--r--libstdc++-v3/testsuite/ext/mt_allocator/explicit_instantiation.cc34
-rw-r--r--libstdc++-v3/testsuite/ext/mt_allocator/tune-1.cc70
-rw-r--r--libstdc++-v3/testsuite/ext/mt_allocator/tune-2.cc72
-rw-r--r--libstdc++-v3/testsuite/ext/mt_allocator/tune-3.cc94
-rw-r--r--libstdc++-v3/testsuite/ext/mt_allocator/tune-4.cc111
-rw-r--r--libstdc++-v3/testsuite/ext/mt_allocator/variadic_construct.cc45
25 files changed, 1317 insertions, 0 deletions
diff --git a/libstdc++-v3/testsuite/ext/mt_allocator/22309_thread.cc b/libstdc++-v3/testsuite/ext/mt_allocator/22309_thread.cc
new file mode 100644
index 000000000..609f188aa
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/mt_allocator/22309_thread.cc
@@ -0,0 +1,99 @@
+// { dg-require-sharedlib "" }
+// { dg-options "-g -O2 -pthread -ldl" { target *-*-linux* } }
+
+// Copyright (C) 2004, 2005, 2009, 2010 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.
+//
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <dlfcn.h>
+#include <pthread.h>
+#include <cstdlib>
+#include <stdexcept>
+
+void
+check_dlopen(void*& h)
+{
+ dlerror();
+ void* tmp = dlopen("./testsuite_shared.so", RTLD_LAZY);
+ if (!tmp)
+ {
+ try
+ {
+ // Throws std::logic_error on NULL string.
+ std::string error(dlerror());
+ throw std::runtime_error(error);
+ }
+ catch (const std::logic_error&)
+ { }
+ }
+ h = tmp;
+}
+
+void
+check_dlsym(void*& h)
+{
+ dlerror();
+
+ typedef void (*function_type) (void);
+ function_type fn;
+ fn = reinterpret_cast<function_type>(dlsym(h, "try_allocation"));
+
+ try
+ {
+ std::string error(dlerror());
+ throw std::runtime_error(error);
+ }
+ catch (const std::logic_error&)
+ { }
+
+ fn();
+}
+
+void
+check_dlclose(void*& h)
+{
+ dlerror();
+ if (dlclose(h) != 0)
+ {
+ try
+ {
+ std::string error(dlerror());
+ throw std::runtime_error(error);
+ }
+ catch (const std::logic_error&)
+ { }
+ }
+}
+
+void*
+tf(void* arg)
+{
+ void* h;
+ check_dlopen(h);
+ check_dlsym(h);
+ check_dlclose(h);
+ return 0;
+}
+
+// libstdc++/22309
+int
+main (void)
+{
+ pthread_t th;
+ pthread_create(&th, 0, tf, 0);
+ pthread_join(th, 0);
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/ext/mt_allocator/check_allocate_big_per_type.cc b/libstdc++-v3/testsuite/ext/mt_allocator/check_allocate_big_per_type.cc
new file mode 100644
index 000000000..eaea215a0
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/mt_allocator/check_allocate_big_per_type.cc
@@ -0,0 +1,54 @@
+// 2005-01-26 Paolo Carlini <pcarlini@suse.de>
+//
+// Copyright (C) 2005, 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.
+//
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <memory>
+#include <ext/mt_allocator.h>
+#include <cstring>
+#include <testsuite_hooks.h>
+
+struct big { char array[256]; };
+
+// __per_type_pool_policy
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+
+ typedef big value_type;
+
+ using __gnu_cxx::__pool;
+ using __gnu_cxx::__per_type_pool_policy;
+
+#ifdef __GTHREADS
+ typedef __per_type_pool_policy<value_type, __pool, true> policy_type;
+#else
+ typedef __per_type_pool_policy<value_type, __pool, false> policy_type;
+#endif
+ typedef __gnu_cxx::__mt_alloc<value_type, policy_type> allocator_type;
+
+ allocator_type a;
+ allocator_type::pointer p1 = a.allocate(64);
+ std::memset((void*)p1, 0, sizeof(big) * 64);
+ a.deallocate(p1, 64);
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/ext/mt_allocator/check_allocate_max_size.cc b/libstdc++-v3/testsuite/ext/mt_allocator/check_allocate_max_size.cc
new file mode 100644
index 000000000..9cde43b8e
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/mt_allocator/check_allocate_max_size.cc
@@ -0,0 +1,30 @@
+//
+// Copyright (C) 2004, 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.
+//
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 20.4.1.1 allocator members
+
+#include <ext/mt_allocator.h>
+#include <testsuite_allocator.h>
+
+int main()
+{
+ typedef int value_type;
+ typedef __gnu_cxx::__mt_alloc<value_type> allocator_type;
+ __gnu_test::check_allocate_max_size<allocator_type>();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/ext/mt_allocator/check_deallocate_null.cc b/libstdc++-v3/testsuite/ext/mt_allocator/check_deallocate_null.cc
new file mode 100644
index 000000000..46d1d8548
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/mt_allocator/check_deallocate_null.cc
@@ -0,0 +1,33 @@
+//
+// Copyright (C) 2004, 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.
+//
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 20.4.1.1 allocator members
+
+#include <ext/mt_allocator.h>
+#include <testsuite_allocator.h>
+
+int main()
+{
+ typedef int value_type;
+ using __gnu_cxx::__pool;
+ typedef __gnu_cxx::__common_pool_policy<__pool, false> policy_type;
+ typedef __gnu_cxx::__mt_alloc<value_type, policy_type> allocator_type;
+ __gnu_test::check_deallocate_null<allocator_type>();
+ return 0;
+}
+
diff --git a/libstdc++-v3/testsuite/ext/mt_allocator/check_deallocate_null_thread.cc b/libstdc++-v3/testsuite/ext/mt_allocator/check_deallocate_null_thread.cc
new file mode 100644
index 000000000..94000ab98
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/mt_allocator/check_deallocate_null_thread.cc
@@ -0,0 +1,33 @@
+//
+// Copyright (C) 2004, 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.
+//
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 20.4.1.1 allocator members
+
+#include <ext/mt_allocator.h>
+#include <testsuite_allocator.h>
+
+int main()
+{
+ typedef int value_type;
+ using __gnu_cxx::__pool;
+ typedef __gnu_cxx::__common_pool_policy<__pool, true> policy_type;
+ typedef __gnu_cxx::__mt_alloc<value_type, policy_type> allocator_type;
+ __gnu_test::check_deallocate_null<allocator_type>();
+ return 0;
+}
+
diff --git a/libstdc++-v3/testsuite/ext/mt_allocator/check_delete.cc b/libstdc++-v3/testsuite/ext/mt_allocator/check_delete.cc
new file mode 100644
index 000000000..374c56706
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/mt_allocator/check_delete.cc
@@ -0,0 +1,31 @@
+// 2001-11-25 Phil Edwards <pme@gcc.gnu.org>
+//
+// Copyright (C) 2001, 2003, 2004, 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.
+//
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 20.4.1.1 allocator members
+
+#include <cstdlib>
+#include <ext/mt_allocator.h>
+#include <replacement_memory_operators.h>
+
+int main()
+{
+ 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
new file mode 100644
index 000000000..527932640
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/mt_allocator/check_new.cc
@@ -0,0 +1,32 @@
+// 2001-11-25 Phil Edwards <pme@gcc.gnu.org>
+//
+// Copyright (C) 2001, 2003, 2004, 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.
+//
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 20.4.1.1 allocator members
+
+#include <cstdlib>
+#include <ext/mt_allocator.h>
+#include <replacement_memory_operators.h>
+
+int main()
+{
+ // Uses new but delete only optionally.
+ 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
new file mode 100644
index 000000000..fcc5006bd
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/mt_allocator/deallocate_global-2.cc
@@ -0,0 +1,46 @@
+//
+// Copyright (C) 2004, 2005, 2006, 2007, 2008, 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.
+//
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 20.4.1.1 allocator members
+
+#include <list>
+#include <string>
+#include <stdexcept>
+#include <cstdio>
+#include <ext/mt_allocator.h>
+#include <replacement_memory_operators.h>
+
+typedef std::string value_type;
+using __gnu_cxx::__pool;
+using __gnu_cxx::__common_pool_policy;
+typedef __common_pool_policy<__pool, false> policy_type;
+typedef __gnu_cxx::__mt_alloc<value_type, policy_type> allocator_type;
+typedef std::char_traits<value_type> traits_type;
+typedef std::list<value_type, allocator_type> list_type;
+
+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
new file mode 100644
index 000000000..cafbffb34
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/mt_allocator/deallocate_global-4.cc
@@ -0,0 +1,46 @@
+//
+// Copyright (C) 2004, 2005, 2006, 2007, 2008, 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.
+//
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 20.4.1.1 allocator members
+
+#include <list>
+#include <string>
+#include <stdexcept>
+#include <cstdio>
+#include <ext/mt_allocator.h>
+#include <replacement_memory_operators.h>
+
+typedef std::string value_t;
+using __gnu_cxx::__pool;
+using __gnu_cxx::__per_type_pool_policy;
+typedef __per_type_pool_policy<value_t, __pool, false> policy_type;
+typedef __gnu_cxx::__mt_alloc<value_t, policy_type> allocator_type;
+typedef std::char_traits<value_t> traits_type;
+typedef std::list<value_t, allocator_type> list_type;
+
+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
new file mode 100644
index 000000000..f61cd38b7
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/mt_allocator/deallocate_global_thread-1.cc
@@ -0,0 +1,46 @@
+//
+// Copyright (C) 2004, 2005, 2006, 2007, 2008, 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.
+//
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 20.4.1.1 allocator members
+
+#include <list>
+#include <string>
+#include <stdexcept>
+#include <cstdio>
+#include <ext/mt_allocator.h>
+#include <replacement_memory_operators.h>
+
+typedef std::string value_type;
+using __gnu_cxx::__pool;
+using __gnu_cxx::__common_pool_policy;
+typedef __common_pool_policy<__pool, true> policy_type;
+typedef __gnu_cxx::__mt_alloc<value_type, policy_type> allocator_type;
+typedef std::char_traits<value_type> traits_type;
+typedef std::list<value_type, allocator_type> list_type;
+
+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
new file mode 100644
index 000000000..62074f0a4
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/mt_allocator/deallocate_global_thread-3.cc
@@ -0,0 +1,46 @@
+//
+// Copyright (C) 2004, 2005, 2006, 2007, 2008, 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.
+//
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 20.4.1.1 allocator members
+
+#include <list>
+#include <string>
+#include <stdexcept>
+#include <cstdio>
+#include <ext/mt_allocator.h>
+#include <replacement_memory_operators.h>
+
+typedef std::string value_type;
+using __gnu_cxx::__pool;
+using __gnu_cxx::__per_type_pool_policy;
+typedef __per_type_pool_policy<value_type, __pool, true> policy_type;
+typedef __gnu_cxx::__mt_alloc<value_type, policy_type> allocator_type;
+typedef std::char_traits<value_type> traits_type;
+typedef std::list<value_type, allocator_type> list_type;
+
+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
new file mode 100644
index 000000000..9ccebd57e
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/mt_allocator/deallocate_local-2.cc
@@ -0,0 +1,43 @@
+//
+// Copyright (C) 2004, 2005, 2006, 2007, 2008, 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.
+//
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 20.4.1.1 allocator members
+
+#include <string>
+#include <stdexcept>
+#include <cstdio>
+#include <ext/mt_allocator.h>
+#include <replacement_memory_operators.h>
+
+typedef char value_type;
+typedef std::char_traits<value_type> traits_type;
+using __gnu_cxx::__pool;
+typedef __gnu_cxx::__common_pool_policy<__pool, false> policy_type;
+typedef __gnu_cxx::__mt_alloc<value_type, policy_type> allocator_type;
+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
new file mode 100644
index 000000000..9265a15a9
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/mt_allocator/deallocate_local-4.cc
@@ -0,0 +1,44 @@
+//
+// Copyright (C) 2004, 2005, 2006, 2007, 2008, 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.
+//
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 20.4.1.1 allocator members
+
+#include <string>
+#include <stdexcept>
+#include <cstdio>
+#include <ext/mt_allocator.h>
+#include <replacement_memory_operators.h>
+
+typedef char value_type;
+typedef std::char_traits<value_type> traits_type;
+using __gnu_cxx::__pool;
+using __gnu_cxx::__per_type_pool_policy;
+typedef __per_type_pool_policy<value_type, __pool, false> policy_type;
+typedef __gnu_cxx::__mt_alloc<value_type, policy_type> allocator_type;
+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
new file mode 100644
index 000000000..017557138
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/mt_allocator/deallocate_local-6.cc
@@ -0,0 +1,55 @@
+// { dg-require-cxa-atexit "" }
+
+// Copyright (C) 2004, 2005, 2006, 2007, 2008, 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.
+//
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 20.4.1.1 allocator members
+
+#include <string>
+#include <stdexcept>
+#include <cstdio>
+#include <ext/mt_allocator.h>
+#include <replacement_memory_operators.h>
+
+template<bool _Thread>
+ struct cleanup_pool : public __gnu_cxx::__pool<false>
+ {
+ cleanup_pool() : __gnu_cxx::__pool<false>() { }
+
+ cleanup_pool(const __gnu_cxx::__pool_base::_Tune& t)
+ : __gnu_cxx::__pool<false>(t) { }
+
+ ~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, false> policy_type;
+typedef __gnu_cxx::__mt_alloc<value_type, policy_type> allocator_type;
+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
new file mode 100644
index 000000000..34005e4b0
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/mt_allocator/deallocate_local-8.cc
@@ -0,0 +1,56 @@
+// { dg-require-cxa-atexit "" }
+
+// Copyright (C) 2004, 2005, 2006, 2007, 2008, 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.
+//
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 20.4.1.1 allocator members
+
+#include <string>
+#include <stdexcept>
+#include <cstdio>
+#include <ext/mt_allocator.h>
+#include <replacement_memory_operators.h>
+
+template<bool _Thread>
+ struct cleanup_pool : public __gnu_cxx::__pool<false>
+ {
+ cleanup_pool() : __gnu_cxx::__pool<false>() { }
+
+ cleanup_pool(const __gnu_cxx::__pool_base::_Tune& t)
+ : __gnu_cxx::__pool<false>(t) { }
+
+ ~cleanup_pool() throw() { this->_M_destroy(); }
+ };
+
+typedef char value_type;
+typedef std::char_traits<value_type> traits_type;
+using __gnu_cxx::__pool;
+using __gnu_cxx::__per_type_pool_policy;
+typedef __per_type_pool_policy<value_type, cleanup_pool, false> policy_type;
+typedef __gnu_cxx::__mt_alloc<value_type, policy_type> allocator_type;
+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
new file mode 100644
index 000000000..012a7585a
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/mt_allocator/deallocate_local_thread-1.cc
@@ -0,0 +1,43 @@
+//
+// Copyright (C) 2004, 2005, 2006, 2007, 2008, 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.
+//
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 20.4.1.1 allocator members
+
+#include <string>
+#include <stdexcept>
+#include <cstdio>
+#include <ext/mt_allocator.h>
+#include <replacement_memory_operators.h>
+
+typedef char value_type;
+typedef std::char_traits<value_type> traits_type;
+using __gnu_cxx::__pool;
+typedef __gnu_cxx::__common_pool_policy<__pool, true> policy_type;
+typedef __gnu_cxx::__mt_alloc<value_type, policy_type> allocator_type;
+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
new file mode 100644
index 000000000..0a9fde02b
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/mt_allocator/deallocate_local_thread-3.cc
@@ -0,0 +1,44 @@
+//
+// Copyright (C) 2004, 2005, 2006, 2007, 2008, 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.
+//
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 20.4.1.1 allocator members
+
+#include <string>
+#include <stdexcept>
+#include <cstdio>
+#include <ext/mt_allocator.h>
+#include <replacement_memory_operators.h>
+
+typedef char value_type;
+typedef std::char_traits<value_type> traits_type;
+using __gnu_cxx::__pool;
+using __gnu_cxx::__per_type_pool_policy;
+typedef __per_type_pool_policy<value_type, __pool, true> policy_type;
+typedef __gnu_cxx::__mt_alloc<value_type, policy_type> allocator_type;
+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
new file mode 100644
index 000000000..a812aecf2
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/mt_allocator/deallocate_local_thread-5.cc
@@ -0,0 +1,54 @@
+// { dg-require-cxa-atexit "" }
+
+// Copyright (C) 2004, 2005, 2006, 2007, 2008, 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.
+//
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 20.4.1.1 allocator members
+
+#include <string>
+#include <stdexcept>
+#include <cstdio>
+#include <ext/mt_allocator.h>
+#include <replacement_memory_operators.h>
+
+template<bool _Thread>
+ struct cleanup_pool : public __gnu_cxx::__pool<true>
+ {
+ cleanup_pool() : __gnu_cxx::__pool<true>() { }
+
+ cleanup_pool(const __gnu_cxx::__pool_base::_Tune& t)
+ : __gnu_cxx::__pool<true>(t) { }
+
+ ~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;
+typedef __gnu_cxx::__mt_alloc<value_type, policy_type> allocator_type;
+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
new file mode 100644
index 000000000..ac8426ee9
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/mt_allocator/deallocate_local_thread-7.cc
@@ -0,0 +1,56 @@
+// { dg-require-cxa-atexit "" }
+
+// Copyright (C) 2004, 2005, 2006, 2007, 2008, 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.
+//
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 20.4.1.1 allocator members
+
+#include <string>
+#include <stdexcept>
+#include <cstdio>
+#include <ext/mt_allocator.h>
+#include <replacement_memory_operators.h>
+
+template<bool _Thread>
+ struct cleanup_pool : public __gnu_cxx::__pool<true>
+ {
+ cleanup_pool() : __gnu_cxx::__pool<true>() { }
+
+ cleanup_pool(const __gnu_cxx::__pool_base::_Tune& t)
+ : __gnu_cxx::__pool<true>(t) { }
+
+ ~cleanup_pool() throw() { this->_M_destroy(); }
+ };
+
+typedef char value_type;
+typedef std::char_traits<value_type> traits_type;
+using __gnu_cxx::__pool;
+using __gnu_cxx::__per_type_pool_policy;
+typedef __per_type_pool_policy<value_type, cleanup_pool, true> policy_type;
+typedef __gnu_cxx::__mt_alloc<value_type, policy_type> allocator_type;
+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/explicit_instantiation.cc b/libstdc++-v3/testsuite/ext/mt_allocator/explicit_instantiation.cc
new file mode 100644
index 000000000..03be65d01
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/mt_allocator/explicit_instantiation.cc
@@ -0,0 +1,34 @@
+// { dg-do compile }
+
+// 2001-11-25 Phil Edwards <pme@gcc.gnu.org>
+//
+// Copyright (C) 2001, 2003, 2004, 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.
+//
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 20.4.1.1 allocator members
+
+#include <cstdlib>
+#include <ext/mt_allocator.h>
+
+using namespace __gnu_cxx;
+template class __mt_alloc<int>;
+template class __mt_alloc<short, __common_pool_policy<__pool, false> >;
+template class __mt_alloc<short, __per_type_pool_policy<short, __pool, false> >;
+#ifdef __GTHREADS
+template class __mt_alloc<short, __common_pool_policy<__pool, true> >;
+template class __mt_alloc<short, __per_type_pool_policy<short, __pool, true> >;
+#endif
diff --git a/libstdc++-v3/testsuite/ext/mt_allocator/tune-1.cc b/libstdc++-v3/testsuite/ext/mt_allocator/tune-1.cc
new file mode 100644
index 000000000..9630accbe
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/mt_allocator/tune-1.cc
@@ -0,0 +1,70 @@
+// 2004-08-25 Benjamin Kosnik <bkoz@redhat.com>
+//
+// Copyright (C) 2004, 2005, 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.
+//
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <memory>
+#include <ext/mt_allocator.h>
+#include <testsuite_hooks.h>
+#include <testsuite_character.h>
+
+#ifdef __GTHREADS
+#define __cxxthread true
+#else
+#define __cxxthread false
+#endif
+
+// Tune characteristics.
+// __common_pool_policy
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+
+ using __gnu_cxx::__pool;
+ using __gnu_cxx::__common_pool_policy;
+
+ typedef __gnu_test::pod_int value_type;
+ typedef __common_pool_policy<__pool, __cxxthread> policy_type;
+ typedef __gnu_cxx::__mt_alloc<value_type, policy_type> allocator_type;
+ typedef __gnu_cxx::__pool_base::_Tune tune_type;
+
+ allocator_type a;
+ tune_type t_default = a._M_get_options();
+ tune_type t_opt(32, 5120, 32, 5120, 20, 10, false);
+ tune_type t_small(16, 1024, 32, 2048, 1, 10, false);
+
+ tune_type t1 = t_default;
+ a._M_set_options(t_opt);
+ tune_type t2 = a._M_get_options();
+ VERIFY( t1._M_align != t2._M_align );
+
+ allocator_type::pointer p1 = a.allocate(128);
+ allocator_type::pointer p2 = a.allocate(5128);
+ a._M_set_options(t_small);
+ tune_type t3 = a._M_get_options();
+ VERIFY( t3._M_chunk_size != t_small._M_chunk_size );
+ VERIFY( t3._M_chunk_size == t_opt._M_chunk_size );
+
+ a.deallocate(p1, 128);
+ a.deallocate(p2, 5128);
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/ext/mt_allocator/tune-2.cc b/libstdc++-v3/testsuite/ext/mt_allocator/tune-2.cc
new file mode 100644
index 000000000..c3f6b3b68
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/mt_allocator/tune-2.cc
@@ -0,0 +1,72 @@
+// 2004-08-25 Benjamin Kosnik <bkoz@redhat.com>
+//
+// Copyright (C) 2004, 2005, 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.
+//
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <memory>
+#include <ext/mt_allocator.h>
+#include <testsuite_hooks.h>
+#include <testsuite_character.h>
+
+#ifdef __GTHREADS
+#define __cxxthread true
+#else
+#define __cxxthread false
+#endif
+
+// Tune characteristics.
+// __per_type_pool_policy
+void test02()
+{
+ bool test __attribute__((unused)) = true;
+
+ typedef __gnu_test::pod_int value_type;
+
+ using __gnu_cxx::__pool;
+ using __gnu_cxx::__per_type_pool_policy;
+
+ typedef __per_type_pool_policy<value_type, __pool, __cxxthread> policy_type;
+ typedef __gnu_cxx::__mt_alloc<value_type, policy_type> allocator_type;
+ typedef __gnu_cxx::__pool_base::_Tune tune_type;
+
+ allocator_type a;
+ tune_type t_default = a._M_get_options();
+ tune_type t_opt(32, 5120, 32, 5120, 20, 10, false);
+ tune_type t_small(16, 1024, 32, 2048, 1, 10, false);
+
+ tune_type t1 = t_default;
+ a._M_set_options(t_opt);
+ tune_type t2 = a._M_get_options();
+ VERIFY( t1._M_align != t2._M_align );
+
+ allocator_type::pointer p1 = a.allocate(128);
+ allocator_type::pointer p2 = a.allocate(5128);
+ a._M_set_options(t_small);
+ tune_type t3 = a._M_get_options();
+ VERIFY( t3._M_chunk_size != t_small._M_chunk_size );
+ VERIFY( t3._M_chunk_size == t_opt._M_chunk_size );
+
+ a.deallocate(p1, 128);
+ a.deallocate(p2, 5128);
+}
+
+int main()
+{
+ test02();
+
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/ext/mt_allocator/tune-3.cc b/libstdc++-v3/testsuite/ext/mt_allocator/tune-3.cc
new file mode 100644
index 000000000..b4e822d27
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/mt_allocator/tune-3.cc
@@ -0,0 +1,94 @@
+// 2004-08-25 Benjamin Kosnik <bkoz@redhat.com>
+//
+// Copyright (C) 2004, 2005, 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.
+//
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <testsuite_hooks.h>
+#include <memory>
+#include <ext/mt_allocator.h>
+
+// Tune characteristics, two of same type
+template<typename _Tp>
+struct test_policy
+{ static bool per_type() { return true; } };
+
+using __gnu_cxx::__pool;
+using __gnu_cxx::__common_pool_policy;
+
+template<>
+struct test_policy<__common_pool_policy<__pool, true> >
+{ static bool per_type() { return false; } };
+
+template<>
+struct test_policy<__common_pool_policy<__pool, false> >
+{ static bool per_type() { return false; } };
+
+// Tune characteristics, two of different types
+template<typename _Tp, typename _Cp>
+void test03()
+{
+ bool test __attribute__((unused)) = true;
+
+ typedef __gnu_cxx::__pool_base::_Tune tune_type;
+ typedef _Tp value_type;
+ typedef _Cp policy_type;
+ typedef __gnu_cxx::__mt_alloc<value_type, policy_type> allocator_type;
+
+ allocator_type a;
+ tune_type t_default = a._M_get_options();
+ tune_type t_opt(32, 5120, 32, 5120, 20, 10, false);
+ tune_type t_small(16, 1024, 32, 2048, 1, 10, false);
+
+ // First instances assured.
+ tune_type t1 = t_default;
+ if (test_policy<policy_type>::per_type())
+ {
+ a._M_set_options(t_opt);
+ t1 = a._M_get_options();
+ VERIFY( t1._M_align != t_default._M_align );
+ }
+
+ // Lock tune settings.
+ typename allocator_type::pointer p1 = a.allocate(128);
+
+ allocator_type a2;
+ tune_type t2 = a2._M_get_options();
+ VERIFY( t2._M_chunk_size == t1._M_chunk_size );
+
+ typename allocator_type::pointer p2 = a2.allocate(5128);
+
+ a2._M_set_options(t_small);
+ tune_type t3 = a2._M_get_options();
+ VERIFY( t3._M_chunk_size != t_small._M_chunk_size );
+ VERIFY( t3._M_chunk_size == t2._M_chunk_size );
+
+ a.deallocate(p1, 128);
+ a2.deallocate(p2, 5128);
+}
+
+int main()
+{
+#ifdef __GTHREADS
+ test03<int, __gnu_cxx::__per_type_pool_policy<int, __pool, true> >();
+ test03<int, __gnu_cxx::__common_pool_policy<__pool, true> >();
+#endif
+
+ test03<int, __gnu_cxx::__per_type_pool_policy<int, __pool, false> >();
+ test03<int, __gnu_cxx::__common_pool_policy<__pool, false> >();
+
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/ext/mt_allocator/tune-4.cc b/libstdc++-v3/testsuite/ext/mt_allocator/tune-4.cc
new file mode 100644
index 000000000..4d3c81181
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/mt_allocator/tune-4.cc
@@ -0,0 +1,111 @@
+// 2004-08-25 Benjamin Kosnik <bkoz@redhat.com>
+//
+// Copyright (C) 2004, 2005, 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.
+//
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <testsuite_hooks.h>
+#include <memory>
+#include <ext/mt_allocator.h>
+
+// Tune characteristics, two of same type
+template<typename _Tp>
+struct test_policy
+{ static bool per_type() { return true; } };
+
+using __gnu_cxx::__pool;
+using __gnu_cxx::__common_pool_policy;
+
+template<>
+struct test_policy<__common_pool_policy<__pool, true> >
+{ static bool per_type() { return false; } };
+
+template<>
+struct test_policy<__common_pool_policy<__pool, false> >
+{ static bool per_type() { return false; } };
+
+struct pod2
+{
+ int i;
+ int j;
+ int k;
+};
+
+// Tune characteristics, two of different instantiations
+template<typename _Tp, typename _Cp>
+void test04()
+{
+ bool test __attribute__((unused)) = true;
+
+ typedef __gnu_cxx::__pool_base::_Tune tune_type;
+ typedef _Tp value_type;
+ typedef _Cp policy_type;
+ typedef __gnu_cxx::__mt_alloc<value_type, policy_type> allocator_type;
+
+ allocator_type a;
+ tune_type t_default = a._M_get_options();
+ tune_type t_opt(32, 5120, 32, 5120, 20, 10, false);
+ tune_type t_small(16, 1024, 32, 2048, 1, 10, false);
+
+ // First instance of local type assured.
+ tune_type t1 = t_default;
+ if (test_policy<policy_type>::per_type())
+ {
+ a._M_set_options(t_opt);
+ t1 = a._M_get_options();
+ VERIFY( t1._M_align != t_default._M_align );
+ }
+
+ // Lock tune settings.
+ typename allocator_type::pointer p1 = a.allocate(128);
+
+ typedef pod2 value2_type;
+ typedef typename allocator_type::template rebind<value2_type>::other rebind_type;
+
+ rebind_type a2;
+ tune_type t2 = a2._M_get_options();
+
+ // Both policy_type and rebind_type::policy_type have same characteristics.
+ if (test_policy<policy_type>::per_type())
+ {
+ a2._M_set_options(t_opt);
+ tune_type t = a2._M_get_options();
+ VERIFY( t2._M_align != t._M_align );
+ t2 = t;
+ }
+
+ typename rebind_type::pointer p2 = a2.allocate(5128);
+
+ a2._M_set_options(t_small);
+ tune_type t4 = a2._M_get_options();
+ VERIFY( t4._M_chunk_size != t_small._M_chunk_size );
+ VERIFY( t4._M_chunk_size == t2._M_chunk_size );
+
+ a.deallocate(p1, 128);
+ a2.deallocate(p2, 5128);
+}
+
+int main()
+{
+#ifdef __GTHREADS
+ test04<float, __gnu_cxx::__common_pool_policy<__pool, true> >();
+ test04<double, __gnu_cxx::__per_type_pool_policy<double, __pool, true> >();
+#endif
+ test04<float, __gnu_cxx::__common_pool_policy<__pool, false> >();
+ test04<double, __gnu_cxx::__per_type_pool_policy<double, __pool, false> >();
+
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/ext/mt_allocator/variadic_construct.cc b/libstdc++-v3/testsuite/ext/mt_allocator/variadic_construct.cc
new file mode 100644
index 000000000..d4c2315f3
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/mt_allocator/variadic_construct.cc
@@ -0,0 +1,45 @@
+// { dg-options "-std=gnu++0x" }
+
+// 2007-10-26 Paolo Carlini <pcarlini@suse.de>
+
+// Copyright (C) 2007, 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.
+//
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <ext/mt_allocator.h>
+#include <utility>
+#include <testsuite_hooks.h>
+
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+ typedef std::pair<int, char> pair_type;
+ __gnu_cxx::__mt_alloc<pair_type> alloc1;
+
+ pair_type* ptp1 = alloc1.allocate(1);
+ alloc1.construct(ptp1, 3, 'a');
+
+ VERIFY( ptp1->first == 3 );
+ VERIFY( ptp1->second == 'a' );
+
+ alloc1.deallocate(ptp1, 1);
+}
+
+int main()
+{
+ test01();
+ return 0;
+}