1 // { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-solaris* *-*-cygwin *-*-darwin* alpha*-*-osf* mips-sgi-irix6* } }
2 // { dg-options "-pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* alpha*-*-osf* mips-sgi-irix6* } }
3 // { dg-options "-pthreads" { target *-*-solaris* } }
4 // { dg-require-namedlocale "en_US" }
5 // { dg-require-namedlocale "fr_FR" }
7 // Copyright (C) 2004, 2005, 2007, 2009, 2010 Free Software Foundation
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
12 // Free Software Foundation; either version 3, or (at your option)
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.
20 // You should have received a copy of the GNU General Public License along
21 // with this library; see the file COPYING3. If not see
22 // <http://www.gnu.org/licenses/>.
24 // 22.1.1.2 locale constructors and destructors [lib.locale.cons]
28 #include <testsuite_hooks.h>
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;
35 void* thread_main(void*)
39 std::locale loc_c = std::locale::classic();
40 std::locale loc[max_locales];
41 for (int j = 0; j < max_locales; ++j)
42 loc[j] = std::locale(j % 2 ? "en_US" : "fr_FR");
44 for (int i = 0; i < max_loop_count; ++i)
46 int k = i % max_locales;
47 loc[k] = std::locale::global(loc[k]);
50 loc[k] = loc[k].combine<std::ctype<char> >(loc_c);
60 pthread_t tid[max_thread_count];
62 for (int i = 0; i < max_thread_count; i++)
63 pthread_create (&tid[i], 0, thread_main, 0);
65 for (int i = 0; i < max_thread_count; i++)
66 pthread_join (tid[i], 0);