]>
git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/testsuite/22_locale/locale/cons/12658_thread-2.cc
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-2024 Free Software Foundation, Inc.
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)
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]
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*)
41 for (int i
= 0; i
< max_loop_count
; ++i
)
43 int k
= i
% max_locales
;
44 std::locale::global(loc
[k
]);
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);