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

Subversion Repositories openrisc

[/] [openrisc/] [tags/] [gnu-dev/] [fsf-gcc-snapshot-1-mar-12/] [or1k-gcc/] [libstdc++-v3/] [testsuite/] [ext/] [mt_allocator/] [tune-3.cc] - Blame information for rev 847

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 742 jeremybenn
// 2004-08-25 Benjamin Kosnik <bkoz@redhat.com>
2
//
3
// Copyright (C) 2004, 2005, 2009 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 3, 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 COPYING3.  If not see
18
// <http://www.gnu.org/licenses/>.
19
 
20
#include <testsuite_hooks.h>
21
#include <memory>
22
#include <ext/mt_allocator.h>
23
 
24
// Tune characteristics, two of same type
25
template<typename _Tp>
26
struct test_policy
27
{ static bool per_type() { return true; } };
28
 
29
using __gnu_cxx::__pool;
30
using __gnu_cxx::__common_pool_policy;
31
 
32
template<>
33
struct test_policy<__common_pool_policy<__pool, true> >
34
{ static bool per_type() { return false; } };
35
 
36
template<>
37
struct test_policy<__common_pool_policy<__pool, false> >
38
{ static bool per_type() { return false; } };
39
 
40
// Tune characteristics, two of different types
41
template<typename _Tp, typename _Cp>
42
void test03()
43
{
44
  bool test __attribute__((unused)) = true;
45
 
46
  typedef __gnu_cxx::__pool_base::_Tune tune_type;
47
  typedef _Tp value_type;
48
  typedef _Cp policy_type;
49
  typedef __gnu_cxx::__mt_alloc<value_type, policy_type> allocator_type;
50
 
51
  allocator_type a;
52
  tune_type t_default = a._M_get_options();
53
  tune_type t_opt(32, 5120, 32, 5120, 20, 10, false);
54
  tune_type t_small(16, 1024, 32, 2048, 1, 10, false);
55
 
56
  // First instances assured.
57
  tune_type t1 = t_default;
58
  if (test_policy<policy_type>::per_type())
59
    {
60
      a._M_set_options(t_opt);
61
      t1 = a._M_get_options();
62
      VERIFY( t1._M_align != t_default._M_align );
63
    }
64
 
65
  // Lock tune settings.
66
  typename allocator_type::pointer p1 = a.allocate(128);
67
 
68
  allocator_type a2;
69
  tune_type t2 = a2._M_get_options();
70
  VERIFY( t2._M_chunk_size == t1._M_chunk_size );
71
 
72
  typename allocator_type::pointer p2 = a2.allocate(5128);
73
 
74
  a2._M_set_options(t_small);
75
  tune_type t3 = a2._M_get_options();
76
  VERIFY( t3._M_chunk_size != t_small._M_chunk_size );
77
  VERIFY( t3._M_chunk_size == t2._M_chunk_size );
78
 
79
  a.deallocate(p1, 128);
80
  a2.deallocate(p2, 5128);
81
}
82
 
83
int main()
84
{
85
#ifdef __GTHREADS
86
  test03<int, __gnu_cxx::__per_type_pool_policy<int, __pool, true> >();
87
  test03<int, __gnu_cxx::__common_pool_policy<__pool, true> >();
88
#endif
89
 
90
  test03<int, __gnu_cxx::__per_type_pool_policy<int, __pool, false> >();
91
  test03<int, __gnu_cxx::__common_pool_policy<__pool, false> >();
92
 
93
  return 0;
94
}

powered by: WebSVN 2.1.0

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