]>
Commit | Line | Data |
---|---|---|
d1236680 RO |
1 | // { dg-do run } |
2 | // { dg-options "-pthread" } | |
3 | // { dg-require-effective-target pthread } | |
4216708a JM |
4 | // { dg-require-namedlocale "en_US.ISO8859-1" } |
5 | // { dg-require-namedlocale "fr_FR.ISO8859-15" } | |
85cefbc6 | 6 | // { dg-timeout-factor 2.0 { target hppa*-*-* } } |
5a66cfb2 | 7 | |
83ffe9cd | 8 | // Copyright (C) 2004-2023 Free Software Foundation, Inc. |
5a66cfb2 PR |
9 | // |
10 | // This file is part of the GNU ISO C++ Library. This library is free | |
11 | // software; you can redistribute it and/or modify it under the | |
12 | // terms of the GNU General Public License as published by the | |
748086b7 | 13 | // Free Software Foundation; either version 3, or (at your option) |
5a66cfb2 PR |
14 | // any later version. |
15 | ||
16 | // This library is distributed in the hope that it will be useful, | |
17 | // but WITHOUT ANY WARRANTY; without even the implied warranty of | |
18 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
19 | // GNU General Public License for more details. | |
20 | ||
21 | // You should have received a copy of the GNU General Public License along | |
748086b7 JJ |
22 | // with this library; see the file COPYING3. If not see |
23 | // <http://www.gnu.org/licenses/>. | |
5a66cfb2 PR |
24 | |
25 | // 22.1.1.2 locale constructors and destructors [lib.locale.cons] | |
26 | ||
27 | #include <locale> | |
28 | #include <pthread.h> | |
8063a355 PC |
29 | #include <testsuite_hooks.h> |
30 | ||
5a66cfb2 PR |
31 | const int max_thread_count = 20; |
32 | //const int max_loop_count = 1000000; // orig value | |
33 | const int max_loop_count = 100000; | |
34 | const int max_locales = 10; | |
9a2ba7af PC |
35 | std::locale loc[max_locales]; |
36 | ||
5a66cfb2 PR |
37 | void* thread_main(void*) |
38 | { | |
6dde938c | 39 | try |
5a66cfb2 | 40 | { |
6dde938c BK |
41 | for (int i = 0; i < max_loop_count; ++i) |
42 | { | |
43 | int k = i % max_locales; | |
9a2ba7af | 44 | std::locale::global(loc[k]); |
6dde938c | 45 | } |
5a66cfb2 | 46 | } |
6dde938c | 47 | catch (...) { } |
5a66cfb2 PR |
48 | return 0; |
49 | } | |
50 | ||
51 | int | |
52 | main() | |
53 | { | |
54 | pthread_t tid[max_thread_count]; | |
6dde938c | 55 | |
9a2ba7af | 56 | for (int j = 0; j < max_locales; ++j) |
4216708a | 57 | loc[j] = std::locale(j % 2 ? ISO_8859(1,en_US) : ISO_8859(15,fr_FR)); |
9a2ba7af | 58 | |
5a66cfb2 | 59 | for (int i = 0; i < max_thread_count; i++) |
445877a9 | 60 | pthread_create(&tid[i], 0, thread_main, 0); |
5a66cfb2 PR |
61 | |
62 | for (int i = 0; i < max_thread_count; i++) | |
445877a9 | 63 | pthread_join(tid[i], 0); |
5a66cfb2 PR |
64 | |
65 | return 0; | |
66 | } |