Fix 22_locale/locale/cons/12658_thread-2.cc on hppa.
[official-gcc.git] / libstdc++-v3 / testsuite / 22_locale / locale / cons / 12658_thread-2.cc
blobd198a0ac30440aface1cc542d08ec5cfeccf7b70
1 // { dg-do run }
2 // { dg-options "-pthread" }
3 // { dg-require-effective-target pthread }
4 // { dg-require-namedlocale "en_US.ISO8859-1" }
5 // { dg-require-namedlocale "fr_FR.ISO8859-15" }
6 // { dg-timeout-factor 2.0 { target hppa*-*-* } }
8 // Copyright (C) 2004-2023 Free Software Foundation, Inc.
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
13 // Free Software Foundation; either version 3, or (at your option)
14 // any later version.
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.
21 // You should have received a copy of the GNU General Public License along
22 // with this library; see the file COPYING3. If not see
23 // <http://www.gnu.org/licenses/>.
25 // 22.1.1.2 locale constructors and destructors [lib.locale.cons]
27 #include <locale>
28 #include <pthread.h>
29 #include <testsuite_hooks.h>
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;
35 std::locale loc[max_locales];
37 void* thread_main(void*)
39 try
41 for (int i = 0; i < max_loop_count; ++i)
43 int k = i % max_locales;
44 std::locale::global(loc[k]);
47 catch (...) { }
48 return 0;
51 int
52 main()
54 pthread_t tid[max_thread_count];
56 for (int j = 0; j < max_locales; ++j)
57 loc[j] = std::locale(j % 2 ? ISO_8859(1,en_US) : ISO_8859(15,fr_FR));
59 for (int i = 0; i < max_thread_count; i++)
60 pthread_create(&tid[i], 0, thread_main, 0);
62 for (int i = 0; i < max_thread_count; i++)
63 pthread_join(tid[i], 0);
65 return 0;