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

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [gcc-4.5.1/] [libstdc++-v3/] [testsuite/] [22_locale/] [locale/] [cons/] [12658_thread-2.cc] - Blame information for rev 424

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 424 jeremybenn
// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-solaris* *-*-cygwin *-*-darwin* alpha*-*-osf* mips-sgi-irix6* } }
2
// { dg-options "-pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* alpha*-*-osf* mips-sgi-irix6* } }
3
// { dg-options "-pthreads" { target *-*-solaris* } }
4
// { dg-require-namedlocale "" }
5
 
6
// Copyright (C) 2004, 2005, 2007, 2009 Free Software Foundation
7
//
8
// This file is part of the GNU ISO C++ Library.  This library is free
9
// software; you can redistribute it and/or modify it under the
10
// terms of the GNU General Public License as published by the
11
// Free Software Foundation; either version 3, or (at your option)
12
// any later version.
13
 
14
// This library is distributed in the hope that it will be useful,
15
// but WITHOUT ANY WARRANTY; without even the implied warranty of
16
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17
// GNU General Public License for more details.
18
 
19
// You should have received a copy of the GNU General Public License along
20
// with this library; see the file COPYING3.  If not see
21
// <http://www.gnu.org/licenses/>.
22
 
23
// 22.1.1.2 locale constructors and destructors [lib.locale.cons]
24
 
25
#include <locale>
26
#include <pthread.h>
27
#include <testsuite_hooks.h>
28
 
29
const int max_thread_count = 20;
30
//const int max_loop_count = 1000000; // orig value
31
const int max_loop_count = 100000;
32
const int max_locales = 10;
33
std::locale loc[max_locales];
34
 
35
void* thread_main(void*)
36
{
37
  try
38
    {
39
      for (int i = 0; i < max_loop_count; ++i)
40
        {
41
          int k = i % max_locales;
42
          std::locale::global(loc[k]);
43
        }
44
    }
45
  catch (...) { }
46
  return 0;
47
}
48
 
49
int
50
main()
51
{
52
  pthread_t tid[max_thread_count];
53
 
54
  for (int j = 0; j < max_locales; ++j)
55
    loc[j] = std::locale(j % 2 ? "en_US" : "fr_FR");
56
 
57
  for (int i = 0; i < max_thread_count; i++)
58
    pthread_create(&tid[i], NULL, thread_main, 0);
59
 
60
  for (int i = 0; i < max_thread_count; i++)
61
    pthread_join(tid[i], NULL);
62
 
63
  return 0;
64
}

powered by: WebSVN 2.1.0

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