]> git.ipfire.org Git - thirdparty/gcc.git/blame - libstdc++-v3/testsuite/ext/mt_allocator/tune-1.cc
Update copyright years.
[thirdparty/gcc.git] / libstdc++-v3 / testsuite / ext / mt_allocator / tune-1.cc
CommitLineData
8bfd0a46
BK
1// 2004-08-25 Benjamin Kosnik <bkoz@redhat.com>
2//
8d9254fc 3// Copyright (C) 2004-2020 Free Software Foundation, Inc.
8bfd0a46
BK
4//
5// This file is part of the GNU ISO C++ Library. This library is free
6// software; you can redistribute it and/or modify it under the
7// terms of the GNU General Public License as published by the
748086b7 8// Free Software Foundation; either version 3, or (at your option)
8bfd0a46
BK
9// any later version.
10//
11// This library is distributed in the hope that it will be useful,
12// but WITHOUT ANY WARRANTY; without even the implied warranty of
13// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14// GNU General Public License for more details.
15//
16// You should have received a copy of the GNU General Public License along
748086b7
JJ
17// with this library; see the file COPYING3. If not see
18// <http://www.gnu.org/licenses/>.
8bfd0a46 19
8bfd0a46
BK
20#include <memory>
21#include <ext/mt_allocator.h>
5305b1ae
BK
22#include <testsuite_hooks.h>
23#include <testsuite_character.h>
8bfd0a46 24
8d4addde
BK
25#ifdef __GTHREADS
26#define __cxxthread true
27#else
28#define __cxxthread false
29#endif
30
8bfd0a46
BK
31// Tune characteristics.
32// __common_pool_policy
33void test01()
34{
6571df13
BK
35 using __gnu_cxx::__pool;
36 using __gnu_cxx::__common_pool_policy;
37
8d4addde
BK
38 typedef __gnu_test::pod_int value_type;
39 typedef __common_pool_policy<__pool, __cxxthread> policy_type;
8bfd0a46
BK
40 typedef __gnu_cxx::__mt_alloc<value_type, policy_type> allocator_type;
41 typedef __gnu_cxx::__pool_base::_Tune tune_type;
42
8bfd0a46 43 allocator_type a;
8d4addde
BK
44 tune_type t_default = a._M_get_options();
45 tune_type t_opt(32, 5120, 32, 5120, 20, 10, false);
46 tune_type t_small(16, 1024, 32, 2048, 1, 10, false);
47
48 tune_type t1 = t_default;
8bfd0a46 49 a._M_set_options(t_opt);
3641bd55
PC
50 tune_type t2 = a._M_get_options();
51 VERIFY( t1._M_align != t2._M_align );
8bfd0a46
BK
52
53 allocator_type::pointer p1 = a.allocate(128);
54 allocator_type::pointer p2 = a.allocate(5128);
8d4addde
BK
55 a._M_set_options(t_small);
56 tune_type t3 = a._M_get_options();
57 VERIFY( t3._M_chunk_size != t_small._M_chunk_size );
58 VERIFY( t3._M_chunk_size == t_opt._M_chunk_size );
8bfd0a46
BK
59
60 a.deallocate(p1, 128);
61 a.deallocate(p2, 5128);
62}
63
64int main()
65{
66 test01();
67 return 0;
68}