OpenCores
URL https://opencores.org/ocsvn/scarts/scarts/trunk

Subversion Repositories scarts

[/] [scarts/] [trunk/] [toolchain/] [scarts-gcc/] [gcc-4.1.1/] [libstdc++-v3/] [testsuite/] [ext/] [mt_allocator/] [tune-1.cc] - Blame information for rev 19

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 19 jlechner
// 2004-08-25 Benjamin Kosnik <bkoz@redhat.com>
2
//
3
// Copyright (C) 2004, 2005 Free Software Foundation, Inc.
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
8
// Free Software Foundation; either version 2, or (at your option)
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
17
// with this library; see the file COPYING.  If not, write to the Free
18
// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
19
// USA.
20
 
21
#include <memory>
22
#include <ext/mt_allocator.h>
23
#include <testsuite_hooks.h>
24
#include <testsuite_character.h>
25
 
26
#ifdef __GTHREADS
27
#define __cxxthread true
28
#else
29
#define __cxxthread false
30
#endif
31
 
32
// Tune characteristics. 
33
// __common_pool_policy
34
void test01()
35
{
36
  bool test __attribute__((unused)) = true;
37
 
38
  using __gnu_cxx::__pool;
39
  using __gnu_cxx::__common_pool_policy;
40
 
41
  typedef __gnu_test::pod_int value_type;
42
  typedef __common_pool_policy<__pool, __cxxthread> policy_type;
43
  typedef __gnu_cxx::__mt_alloc<value_type, policy_type> allocator_type;
44
  typedef __gnu_cxx::__pool_base::_Tune tune_type;
45
 
46
  allocator_type a;
47
  tune_type t_default = a._M_get_options();
48
  tune_type t_opt(32, 5120, 32, 5120, 20, 10, false);
49
  tune_type t_small(16, 1024, 32, 2048, 1, 10, false);
50
 
51
  tune_type t1 = t_default;
52
  a._M_set_options(t_opt);
53
  tune_type t2 = a._M_get_options();
54
  VERIFY( t1._M_align != t2._M_align );
55
 
56
  allocator_type::pointer p1 = a.allocate(128);
57
  allocator_type::pointer p2 = a.allocate(5128);
58
  a._M_set_options(t_small);
59
  tune_type t3 = a._M_get_options();
60
  VERIFY( t3._M_chunk_size != t_small._M_chunk_size );
61
  VERIFY( t3._M_chunk_size == t_opt._M_chunk_size );
62
 
63
  a.deallocate(p1, 128);
64
  a.deallocate(p2, 5128);
65
}
66
 
67
int main()
68
{
69
  test01();
70
  return 0;
71
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.