debac9f40d
2007-03-02 Paolo Carlini <pcarlini@suse.de> * testsuite/27_io/objects/wchar_t/9661-1.cc: Include <cstdlib>. * testsuite/27_io/objects/wchar_t/7.cc: Likewise. * testsuite/27_io/objects/char/9661-1.cc: Likewise. * testsuite/27_io/objects/char/7.cc: Likewise. * testsuite/27_io/basic_istream/ignore/wchar_t/2.cc: Likewise. * testsuite/27_io/basic_istream/ignore/char/2.cc: Likewise. * testsuite/27_io/basic_istream/getline/wchar_t/5.cc: Likewise. * testsuite/27_io/basic_istream/getline/char/5.cc: Likewise. * testsuite/27_io/basic_istream/extractors_arithmetic/char/ 11.cc: Likewise. * testsuite/27_io/basic_istream/extractors_character/wchar_t/ 4.cc: Likewise. * testsuite/27_io/basic_istream/extractors_character/char/ 4.cc: Likewise. * testsuite/27_io/basic_ostream/seekp/wchar_t/ 2346-fstream.cc: Likewise. * testsuite/27_io/basic_ostream/seekp/char/ 2346-fstream.cc: Likewise. * testsuite/27_io/basic_filebuf/seekoff/char/26777.cc: Likewise. * testsuite/27_io/basic_filebuf/imbue/wchar_t/13582-2.cc: Likewise. * testsuite/27_io/basic_filebuf/imbue/wchar_t/14975-2.cc: Likewise. * testsuite/27_io/basic_filebuf/imbue/char/13171-2.cc: Likewise. * testsuite/27_io/basic_filebuf/imbue/char/13582-2.cc: Likewise. * testsuite/27_io/basic_filebuf/close/char/4879.cc: Likewise. * testsuite/27_io/basic_filebuf/close/char/9964.cc: Likewise. * testsuite/27_io/basic_filebuf/underflow/char/10097.cc: Likewise. * testsuite/27_io/basic_filebuf/showmanyc/char/9533-1.cc: Likewise. * testsuite/21_strings/basic_string/inserters_extractors/ wchar_t/10.cc: Likewise. * testsuite/21_strings/basic_string/inserters_extractors/ wchar_t/11.cc: Likewise. * testsuite/21_strings/basic_string/inserters_extractors/ char/10.cc: Likewise. * testsuite/21_strings/basic_string/inserters_extractors/ char/11.cc: Likewise. * testsuite/ext/pb_ds/example/trie_dna.cc: Likewise. * testsuite/ext/new_allocator/deallocate_global.cc: Likewise. * testsuite/ext/new_allocator/deallocate_local.cc: Likewise. * testsuite/performance/27_io/filebuf_sgetn_unbuf.cc: Likewise. * testsuite/performance/27_io/ifstream_getline.cc: Likewise. * testsuite/22_locale/locale/cons/4.cc: Likewise. * testsuite/22_locale/locale/cons/5.cc: Likewise. * testsuite/tr1/2_general_utilities/shared_ptr/thread/ mutex_weaktoshared.cc: Likewise. * testsuite/tr1/2_general_utilities/shared_ptr/thread/ default_weaktoshared.cc: Likewise. * testsuite/thread/pthread5.cc: Likewise. * testsuite/thread/pthread1.cc: Likewise. * testsuite/23_containers/deque/cons/assign/1.cc: Likewise. From-SVN: r122482
126 lines
3.1 KiB
C++
126 lines
3.1 KiB
C++
// 2002-01-23 Loren J. Rittle <rittle@labs.mot.com> <ljrittle@acm.org>
|
|
// Adpated from libstdc++/5464 submitted by jjessel@amadeus.net
|
|
// Jean-Francois JESSEL (Amadeus SAS Development)
|
|
//
|
|
// Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007
|
|
// Free Software Foundation, Inc.
|
|
//
|
|
// This file is part of the GNU ISO C++ Library. This library is free
|
|
// software; you can redistribute it and/or modify it under the
|
|
// terms of the GNU General Public License as published by the
|
|
// Free Software Foundation; either version 2, or (at your option)
|
|
// any later version.
|
|
//
|
|
// This library is distributed in the hope that it will be useful,
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
// GNU General Public License for more details.
|
|
//
|
|
// You should have received a copy of the GNU General Public License along
|
|
// with this library; see the file COPYING. If not, write to the Free
|
|
// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
|
// USA.
|
|
|
|
// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-solaris* *-*-cygwin *-*-darwin* alpha*-*-osf* } }
|
|
// { dg-options "-pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* alpha*-*-osf* } }
|
|
// { dg-options "-pthreads" { target *-*-solaris* } }
|
|
|
|
#include <vector>
|
|
#include <list>
|
|
#include <string>
|
|
#include <cstdlib>
|
|
#include <pthread.h>
|
|
|
|
#ifdef _GLIBCXX_HAVE_UNISTD_H
|
|
#include <unistd.h> // To test for _POSIX_THREAD_PRIORITY_SCHEDULING
|
|
#endif
|
|
|
|
using namespace std;
|
|
|
|
#define NTHREADS 8
|
|
#define LOOPS 20
|
|
|
|
struct tt_t
|
|
{
|
|
char buf[100];
|
|
int i;
|
|
};
|
|
|
|
void*
|
|
thread_function (void* arg)
|
|
{
|
|
int myid __attribute__((unused)) = *(int*) arg;
|
|
for (int i = 0; i < LOOPS; i++)
|
|
{
|
|
vector<tt_t> myvect1;
|
|
|
|
for (int j = 0; j < 2000; j++)
|
|
{
|
|
vector<tt_t> myvect2;
|
|
tt_t v;
|
|
v.i = j;
|
|
myvect1.push_back (v);
|
|
myvect2.push_back (v);
|
|
list<std::string *> mylist;
|
|
std::string string_array[4];
|
|
string_array[0] = "toto";
|
|
string_array[1] = "titi";
|
|
string_array[2] = "tata";
|
|
string_array[3] = "tutu";
|
|
for (int k = 0; k < 4; k++)
|
|
{
|
|
if (mylist.size ())
|
|
{
|
|
list<std::string *>::iterator aIt;
|
|
for (aIt = mylist.begin (); aIt != mylist.end (); ++aIt)
|
|
{
|
|
if ((*aIt) == &(string_array[k]))
|
|
abort ();
|
|
}
|
|
}
|
|
mylist.push_back (&(string_array[k]));
|
|
}
|
|
}
|
|
}
|
|
|
|
return arg;
|
|
}
|
|
|
|
int
|
|
main ()
|
|
{
|
|
int worker;
|
|
pthread_t threads[NTHREADS];
|
|
int ids[NTHREADS];
|
|
void* status;
|
|
|
|
#if defined(__sun) && defined(__svr4__) && _XOPEN_VERSION >= 500
|
|
pthread_setconcurrency (NTHREADS);
|
|
#endif
|
|
|
|
pthread_attr_t tattr;
|
|
int ret = pthread_attr_init (&tattr);
|
|
#ifdef _POSIX_THREAD_PRIORITY_SCHEDULING
|
|
ret = pthread_attr_setscope(&tattr, PTHREAD_SCOPE_SYSTEM);
|
|
#endif
|
|
|
|
for (worker = 0; worker < NTHREADS; worker++)
|
|
{
|
|
ids[worker] = worker;
|
|
if (pthread_create(&threads[worker], &tattr,
|
|
thread_function, &ids[worker]))
|
|
abort ();
|
|
}
|
|
|
|
for (worker = 0; worker < NTHREADS; worker++)
|
|
{
|
|
if (pthread_join(threads[worker], static_cast<void **>(&status)))
|
|
abort ();
|
|
|
|
if (*((int *)status) != worker)
|
|
abort ();
|
|
}
|
|
|
|
return (0);
|
|
}
|