]> git.ipfire.org Git - thirdparty/gcc.git/blame - libstdc++-v3/testsuite/27_io/basic_ostringstream/pthread3.cc
Update copyright years.
[thirdparty/gcc.git] / libstdc++-v3 / testsuite / 27_io / basic_ostringstream / pthread3.cc
CommitLineData
7465ab71 1// 2002-01-23 Loren J. Rittle <rittle@labs.mot.com> <ljrittle@acm.org>
2// Adpated from libstdc++/5347 submitted by markus.breuer@materna.de
3//
fbd26352 4// Copyright (C) 2002-2019 Free Software Foundation, Inc.
7465ab71 5//
6// This file is part of the GNU ISO C++ Library. This library is free
7// software; you can redistribute it and/or modify it under the
8// terms of the GNU General Public License as published by the
6bc9506f 9// Free Software Foundation; either version 3, or (at your option)
7465ab71 10// any later version.
11//
12// This library is distributed in the hope that it will be useful,
13// but WITHOUT ANY WARRANTY; without even the implied warranty of
14// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15// GNU General Public License for more details.
16//
17// You should have received a copy of the GNU General Public License along
6bc9506f 18// with this library; see the file COPYING3. If not see
19// <http://www.gnu.org/licenses/>.
7465ab71 20
a8815ed2 21// { dg-do run }
22// { dg-options "-pthread" }
23// { dg-require-effective-target pthread }
7465ab71 24
25#include <sstream>
41de110f 26#include <pthread.h>
7465ab71 27
7465ab71 28const int max_thread_count = 2;
29const int max_loop_count = 1000000;
30
31void*
32thread_main (void *)
33{
34 for (int i = 0; i < max_loop_count; i++)
35 std::ostringstream oss;
36
37 return 0;
38}
39
40int
41main()
42{
43 pthread_t tid[max_thread_count];
44
f5f59ea4 45#if defined(__sun) && defined(__svr4__) && _XOPEN_VERSION >= 500
7465ab71 46 pthread_setconcurrency (max_thread_count);
47#endif
48
49 for (int i = 0; i < max_thread_count; i++)
e4bb1925 50 pthread_create (&tid[i], 0, thread_main, 0);
7465ab71 51
52 for (int i = 0; i < max_thread_count; i++)
e4bb1925 53 pthread_join (tid[i], 0);
7465ab71 54
55 return 0;
56}