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