]> git.ipfire.org Git - thirdparty/gcc.git/blame - libstdc++-v3/testsuite/22_locale/locale/cons/12658_thread-1.cc
Simplify dg-options for tests using pthreads
[thirdparty/gcc.git] / libstdc++-v3 / testsuite / 22_locale / locale / cons / 12658_thread-1.cc
CommitLineData
37d13ae6 1// { dg-do run { target *-*-freebsd* *-*-dragonfly* *-*-netbsd* *-*-linux* *-*-gnu* *-*-solaris* *-*-cygwin *-*-rtems* *-*-darwin* } }
71c54f8e 2// { dg-options "-pthread" { target *-*-freebsd* *-*-dragonfly* *-*-netbsd* *-*-linux* *-*-gnu* *-*-solaris* } }
4216708a
JM
3// { dg-require-namedlocale "en_US.ISO8859-1" }
4// { dg-require-namedlocale "fr_FR.ISO8859-15" }
5a66cfb2 5
818ab71a 6// Copyright (C) 2004-2016 Free Software Foundation, Inc.
5a66cfb2
PR
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
748086b7 11// Free Software Foundation; either version 3, or (at your option)
5a66cfb2
PR
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
748086b7
JJ
20// with this library; see the file COPYING3. If not see
21// <http://www.gnu.org/licenses/>.
5a66cfb2
PR
22
23// 22.1.1.2 locale constructors and destructors [lib.locale.cons]
24
25#include <locale>
26#include <pthread.h>
8063a355
PC
27#include <testsuite_hooks.h>
28
5a66cfb2
PR
29const int max_thread_count = 20;
30//const int max_loop_count = 1000000; // orig value
31const int max_loop_count = 100000;
32const int max_locales = 10;
33
34void* thread_main(void*)
35{
6dde938c 36 try
5a66cfb2 37 {
6dde938c
BK
38 std::locale loc_c = std::locale::classic();
39 std::locale loc[max_locales];
40 for (int j = 0; j < max_locales; ++j)
4216708a 41 loc[j] = std::locale(j % 2 ? ISO_8859(1,en_US) : ISO_8859(15,fr_FR));
5a66cfb2 42
6dde938c
BK
43 for (int i = 0; i < max_loop_count; ++i)
44 {
45 int k = i % max_locales;
46 loc[k] = std::locale::global(loc[k]);
47
48 if (i % 37 == 0)
49 loc[k] = loc[k].combine<std::ctype<char> >(loc_c);
50 }
5a66cfb2 51 }
6dde938c 52 catch (...) { }
5a66cfb2
PR
53 return 0;
54}
55
56int
57main()
58{
59 pthread_t tid[max_thread_count];
6dde938c 60
5a66cfb2 61 for (int i = 0; i < max_thread_count; i++)
8fc81078 62 pthread_create (&tid[i], 0, thread_main, 0);
5a66cfb2
PR
63
64 for (int i = 0; i < max_thread_count; i++)
8fc81078 65 pthread_join (tid[i], 0);
5a66cfb2
PR
66
67 return 0;
68}