]> git.ipfire.org Git - thirdparty/gcc.git/blame - libstdc++-v3/testsuite/22_locale/locale/cons/12658_thread-1.cc
Update copyright years.
[thirdparty/gcc.git] / libstdc++-v3 / testsuite / 22_locale / locale / cons / 12658_thread-1.cc
CommitLineData
fb211fce 1// { dg-do run { target *-*-freebsd* *-*-dragonfly* *-*-netbsd* *-*-linux* *-*-gnu* *-*-solaris* *-*-cygwin *-*-rtems* *-*-darwin* } }
c9fcfee0 2// { dg-options "-pthread" { target *-*-freebsd* *-*-dragonfly* *-*-netbsd* *-*-linux* *-*-gnu* } }
0042b796 3// { dg-options "-pthreads" { target *-*-solaris* } }
be803e41 4// { dg-require-namedlocale "en_US.ISO8859-1" }
5// { dg-require-namedlocale "fr_FR.ISO8859-15" }
0042b796 6
f1717362 7// Copyright (C) 2004-2016 Free Software Foundation, Inc.
0042b796 8//
9// This file is part of the GNU ISO C++ Library. This library is free
10// software; you can redistribute it and/or modify it under the
11// terms of the GNU General Public License as published by the
6bc9506f 12// Free Software Foundation; either version 3, or (at your option)
0042b796 13// any later version.
14
15// This library is distributed in the hope that it will be useful,
16// but WITHOUT ANY WARRANTY; without even the implied warranty of
17// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18// GNU General Public License for more details.
19
20// You should have received a copy of the GNU General Public License along
6bc9506f 21// with this library; see the file COPYING3. If not see
22// <http://www.gnu.org/licenses/>.
0042b796 23
24// 22.1.1.2 locale constructors and destructors [lib.locale.cons]
25
26#include <locale>
27#include <pthread.h>
6642075d 28#include <testsuite_hooks.h>
29
0042b796 30const int max_thread_count = 20;
31//const int max_loop_count = 1000000; // orig value
32const int max_loop_count = 100000;
33const int max_locales = 10;
34
35void* thread_main(void*)
36{
f8244ba2 37 try
0042b796 38 {
f8244ba2 39 std::locale loc_c = std::locale::classic();
40 std::locale loc[max_locales];
41 for (int j = 0; j < max_locales; ++j)
be803e41 42 loc[j] = std::locale(j % 2 ? ISO_8859(1,en_US) : ISO_8859(15,fr_FR));
0042b796 43
f8244ba2 44 for (int i = 0; i < max_loop_count; ++i)
45 {
46 int k = i % max_locales;
47 loc[k] = std::locale::global(loc[k]);
48
49 if (i % 37 == 0)
50 loc[k] = loc[k].combine<std::ctype<char> >(loc_c);
51 }
0042b796 52 }
f8244ba2 53 catch (...) { }
0042b796 54 return 0;
55}
56
57int
58main()
59{
60 pthread_t tid[max_thread_count];
f8244ba2 61
0042b796 62 for (int i = 0; i < max_thread_count; i++)
e4bb1925 63 pthread_create (&tid[i], 0, thread_main, 0);
0042b796 64
65 for (int i = 0; i < max_thread_count; i++)
e4bb1925 66 pthread_join (tid[i], 0);
0042b796 67
68 return 0;
69}