This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[v3] in-line pthread tests


Collapses the old "thread" directory in the libstdc++ testsuite, and
moves each of the pthread tests into the appropriate subject directory. 

tested x86_64/linux

-benjamin
2009-03-02  Benjamin Kosnik  <bkoz@redhat.com>

	* testsuite/thread/pthread4.cc: Move...
	* testsuite/21_strings/basic_string/pthread4.cc: ...here.
	* testsuite/thread/pthread5.cc: Move...
	* testsuite/23_containers/list/pthread5.cc: ...here.
	* testsuite/thread/pthread6.cc: Move...
	* testsuite/23_containers/map/pthread6.cc: ...here.
	* testsuite/thread/pthread7-rope.cc: Move...
	* testsuite/ext/rope/pthread7-rope.cc: ...here.
	* testsuite/thread/guard.cc: Move...
	* testsuite/18_support/pthread_guard.cc: ...here.
	* testsuite/thread/18185.cc: Move...
	* testsuite/21_strings/basic_string/pthread18185.cc: ...here.
	* testsuite/thread/pthread1.cc: Move...
	* testsuite/23_containers/list/pthread1.cc: ...here.
	* testsuite/thread/pthread2.cc: Move...
	* testsuite/27_io/basic_ofstream/pthread2.cc: ...here.
	* testsuite/thread/pthread3.cc: Move...
	* testsuite/27_io/basic_ostringstream/pthread3.cc: ...here.


Property changes on: testsuite/27_io/basic_ofstream/pthread2.cc
___________________________________________________________________
Added: svn:mergeinfo


Property changes on: testsuite/27_io/basic_ostringstream/pthread3.cc
___________________________________________________________________
Added: svn:mergeinfo


Property changes on: testsuite/18_support/pthread_guard.cc
___________________________________________________________________
Added: svn:mergeinfo


Property changes on: testsuite/21_strings/basic_string/pthread18185.cc
___________________________________________________________________
Added: svn:mergeinfo


Property changes on: testsuite/21_strings/basic_string/pthread4.cc
___________________________________________________________________
Added: svn:mergeinfo


Property changes on: testsuite/ext/rope/pthread7-rope.cc
___________________________________________________________________
Added: svn:mergeinfo

Index: testsuite/thread/pthread4.cc
===================================================================
--- testsuite/thread/pthread4.cc	(revision 144543)
+++ testsuite/thread/pthread4.cc	(working copy)
@@ -1,107 +0,0 @@
-// 2002-01-23  Loren J. Rittle <rittle@labs.mot.com> <ljrittle@acm.org>
-// Adapted from http://gcc.gnu.org/ml/gcc-bugs/2002-01/msg00679.html
-// which was adapted from pthread1.cc by Mike Lu <MLu@dynamicsoft.com>
-//
-// 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* mips-sgi-irix6* } }
-// { dg-options "-pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* alpha*-*-osf* mips-sgi-irix6* } }
-// { dg-options "-pthreads" { target *-*-solaris* } }
-
-#include <string>
-#include <list>
-#include <pthread.h>
-
-using namespace std;
-
-static list<string> foo;
-static pthread_mutex_t fooLock = PTHREAD_MUTEX_INITIALIZER;
-static pthread_cond_t fooCondOverflow = PTHREAD_COND_INITIALIZER;
-static pthread_cond_t fooCondUnderflow = PTHREAD_COND_INITIALIZER;
-static unsigned max_size = 10;
-#if defined(__CYGWIN__)
-static int iters = 10000;
-#else
-static int iters = 300000;
-#endif
-
-void*
-produce (void*)
-{
-  for (int num = 0; num < iters; )
-    {
-      string str ("test string");
-
-      pthread_mutex_lock (&fooLock);
-      while (foo.size () >= max_size)
-	pthread_cond_wait (&fooCondOverflow, &fooLock);
-      foo.push_back (str);
-      num++;
-      if (foo.size () >= (max_size / 2))
-	pthread_cond_signal (&fooCondUnderflow);
-      pthread_mutex_unlock (&fooLock);
-    }
-
-  // No more data will ever be written, ensure no fini race
-  pthread_mutex_lock (&fooLock);
-  pthread_cond_signal (&fooCondUnderflow);
-  pthread_mutex_unlock (&fooLock);
-
-  return 0;
-}
-
-void*
-consume (void*)
-{
-  for (int num = 0; num < iters; )
-    {
-      pthread_mutex_lock (&fooLock);
-      while (foo.size () == 0)
-	pthread_cond_wait (&fooCondUnderflow, &fooLock);
-      while (foo.size () > 0)
-	{
-	  string str = foo.back ();
-	  foo.pop_back ();
-	  num++;
-	}
-      pthread_cond_signal (&fooCondOverflow);
-      pthread_mutex_unlock (&fooLock);
-    }
-
-  return 0;
-}
-
-int
-main (void)
-{
-#if defined(__sun) && defined(__svr4__) && _XOPEN_VERSION >= 500
-  pthread_setconcurrency (2);
-#endif
-
-  pthread_t prod;
-  pthread_create (&prod, NULL, produce, NULL);
-  pthread_t cons;
-  pthread_create (&cons, NULL, consume, NULL);
-
-  pthread_join (prod, NULL);
-  pthread_join (cons, NULL);
-
-  return 0;
-}
Index: testsuite/thread/pthread5.cc
===================================================================
--- testsuite/thread/pthread5.cc	(revision 144543)
+++ testsuite/thread/pthread5.cc	(working copy)
@@ -1,125 +0,0 @@
-// 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* mips-sgi-irix6* } }
-// { dg-options "-pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* alpha*-*-osf* mips-sgi-irix6* } }
-// { 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);
-}
Index: testsuite/thread/pthread6.cc
===================================================================
--- testsuite/thread/pthread6.cc	(revision 144543)
+++ testsuite/thread/pthread6.cc	(working copy)
@@ -1,88 +0,0 @@
-// 2002-01-23  Loren J. Rittle <rittle@labs.mot.com> <ljrittle@acm.org>
-// Adpated from libstdc++/5444 submitted by markus.breuer@materna.de
-//
-// 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* mips-sgi-irix6* } }
-// { dg-options "-pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* alpha*-*-osf* mips-sgi-irix6* } }
-// { dg-options "-pthreads" { target *-*-solaris* } }
-
-#include <string>
-#include <map>
-#include <vector>
-#include <pthread.h>
-
-const int max_thread_count = 8;
-const int loops = 100000;
-
-const char* my_default = "Hallo Welt!";
-
-const std::size_t upper_limit = 2500;
-const std::size_t lower_limit = 1000;
-
-typedef char charT;
-
-typedef std::string String;
-
-typedef String MyType;
-
-void*
-thread_main (void*)
-{
-  typedef std::map<unsigned int,MyType> Map;
-  typedef Map::value_type Value_Pair;
-  Map myMap;
-
-  for (int loop = 0; loop < loops; loop++)
-    {
-      String& str = myMap[loop];
-      str.append (my_default);
-      myMap.insert (Value_Pair (loop, str));
-      
-      if (myMap.size () > upper_limit)
-	{
-	  while (myMap.size () > lower_limit)
-	    {
-	      Map::iterator it = myMap.begin ();
-	      myMap.erase (it);
-	    }
-	}
-    }
-
-  return 0;
-}
-
-int
-main (void)
-{
-  pthread_t tid[max_thread_count];
-
-#if defined(__sun) && defined(__svr4__) && _XOPEN_VERSION >= 500
-  pthread_setconcurrency (max_thread_count);
-#endif
-
-  for (int i = 0; i < max_thread_count; i++)
-    pthread_create (&tid[i], NULL, thread_main, 0);
-
-  for (int i = 0; i < max_thread_count; i++)
-    pthread_join (tid[i], NULL);
-
-  return 0;
-}
Index: testsuite/thread/pthread7-rope.cc
===================================================================
--- testsuite/thread/pthread7-rope.cc	(revision 144543)
+++ testsuite/thread/pthread7-rope.cc	(working copy)
@@ -1,103 +0,0 @@
-// 2003-05-03  Loren J. Rittle <rittle@labs.mot.com> <ljrittle@acm.org>
-//
-// Copyright (C) 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* mips-sgi-irix6* } }
-// { dg-options "-pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* alpha*-*-osf* mips-sgi-irix6* } }
-// { dg-options "-pthreads" { target *-*-solaris* } }
-
-#include <ext/rope>
-#include <cstring>
-#include <pthread.h>
-#include <testsuite_hooks.h>
-
-const int max_thread_count = 4;
-const int max_loop_count = 10000;
-
-typedef __gnu_cxx::rope<char, std::allocator<char> > rope_type;
-rope_type foo2;
-rope_type foo4;
-
-void* thread_main(void *) 
-{
-  // To see a problem with gcc 3.3 and before, set a break point here.
-  // Single step through c_str implementation, call sched_yield after
-  // capture of NULL __old_c_string in any thread.  Single step
-  // through another thread past that same point.  Now, one thread
-  // will receive a bad pointer return.  Adding dummy sched_yield
-  // should never change program semantics under POSIX threads.
-  const char* data4 = foo4.c_str();
-
-  // Please note that the memory leak in the rope implementation with
-  // this test case, existed before and after fixing this bug...
-  bool test __attribute__((unused)) = true;
-  VERIFY( !std::strcmp (data4, "barbazbonglehellohellohello") );
-  return 0;
-}
-
-int
-main()
-{
-  bool test __attribute__((unused)) = true;
-
-  pthread_t tid[max_thread_count];
-
-#if defined(__sun) && defined(__svr4__) && _XOPEN_VERSION >= 500
-  pthread_setconcurrency (max_thread_count);
-#endif
-
-  rope_type foo;
-  foo += "bar";
-  foo += "baz";
-  foo += "bongle";
-  const char* data = foo.c_str();
-  VERIFY( !std::strcmp (data, "barbazbongle") );
-
-  const char* data2;
-  {
-    foo2 += "bar2";
-    foo2 += "baz2";
-    foo2 += "bongle2";
-    data2 = foo2.c_str();
-    VERIFY( !std::strcmp (data2, "bar2baz2bongle2") );
-  }
-
-  rope_type foo3 ("hello");
-  const char* data3 = foo3.c_str();
-  VERIFY( !std::strcmp (data3, "hello") );
-
-  for (int j = 0; j < max_loop_count; j++)
-    {
-      foo4 = foo;
-      foo4 += foo3;
-      foo4 += foo3;
-      foo4 += foo3;
-
-      for (int i = 0; i < max_thread_count; i++)
-	pthread_create (&tid[i], NULL, thread_main, 0);
-
-      for (int i = 0; i < max_thread_count; i++)
-	pthread_join (tid[i], NULL);
-    }
-
-  VERIFY( !std::strcmp (data, "barbazbongle") );
-  VERIFY( !std::strcmp (data2, "bar2baz2bongle2") );
-
-  return 0;
-}
Index: testsuite/thread/guard.cc
===================================================================
--- testsuite/thread/guard.cc	(revision 144543)
+++ testsuite/thread/guard.cc	(working copy)
@@ -1,66 +0,0 @@
-//
-// Copyright (C) 2007, 2008 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* *-*-solaris* *-*-darwin* alpha*-*-osf* } }
-
-#include <cstdlib>
-#include <pthread.h>
-
-// This used to deadlock with the old libstdc++ because there is only one
-// global mutex guarding initialization of statics and it is held during by
-// the initializer thread of a static until the variable is completely
-// initialized. If the initializer thread creates and waits for another thread
-// which also initializes a static variable, there will be a deadlock because
-// the first thread is holding the mutex and waiting for the second thread,
-// which is blocked when it is acquiring the mutex.
-
-int
-get_bar (void)
-{
-  return 1;
-}
-
-void*
-do_something (void *arg)
-{
-  static int bar __attribute__((unused)) = get_bar ();
-  return NULL;
-}
-
-int
-get_foo (void)
-{
-  pthread_t new_thread;
-
-  if (pthread_create (&new_thread, NULL, do_something, NULL) != 0)
-    std::abort ();
-
-  if (pthread_join (new_thread, NULL) != 0)
-    std::abort ();
-
-  return 1;
-}
-
-int
-main (int argc, char **argv)
-{
-  static int foo __attribute__((unused)) = get_foo ();
-  return 0;  
-}
Index: testsuite/thread/18185.cc
===================================================================
--- testsuite/thread/18185.cc	(revision 144543)
+++ testsuite/thread/18185.cc	(working copy)
@@ -1,53 +0,0 @@
-//
-// Copyright (C) 2004, 2005, 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* mips-sgi-irix6* } }
-// { dg-options "-pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* alpha*-*-osf* mips-sgi-irix6* } }
-// { dg-options "-pthreads" { target *-*-solaris* } }
-
-#include <ext/new_allocator.h>
-#include <string>
-#include <pthread.h>
-
-static void*
-foo (void*)
-{
-  typedef std::char_traits<char> traits_type;
-  typedef __gnu_cxx::new_allocator<char> allocator_type;
-  typedef std::basic_string<char, traits_type, allocator_type> string_type;
-  try
-    {
-      throw string_type("leak");
-    }
-  catch (const string_type&)
-    {
-      pthread_exit (0);
-    }
-}
-
-// c++/18185
-// This used to leak memory.
-int
-main ()
-{
-  pthread_t t;
-  pthread_create (&t, 0, foo, 0);
-  pthread_join (t, 0);
-  return 0;
-}
Index: testsuite/thread/pthread1.cc
===================================================================
--- testsuite/thread/pthread1.cc	(revision 144543)
+++ testsuite/thread/pthread1.cc	(working copy)
@@ -1,131 +0,0 @@
-// 2002-01-23  Loren J. Rittle <rittle@labs.mot.com> <ljrittle@acm.org>
-//
-// 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* mips-sgi-irix6* } }
-// { dg-options "-pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* alpha*-*-osf* mips-sgi-irix6* } }
-// { dg-options "-pthreads" { target *-*-solaris* } }
-
-// This multi-threading C++/STL/POSIX code adheres to rules outlined here:
-// http://www.sgi.com/tech/stl/thread_safety.html
-//
-// It is believed to exercise the allocation code in a manner that
-// should reveal memory leaks (and, under rare cases, race conditions,
-// if the STL threading support is fubar'd).
-
-#include <list>
-#include <cstdlib>
-#include <pthread.h>
-
-using namespace std;
-
-const int thread_cycles = 10;
-const int thread_pairs = 10;
-const unsigned max_size = 100;
-const int iters = 10000;
-
-class task_queue
-{
-public:
-  task_queue ()
-  {
-    pthread_mutex_init (&fooLock, NULL);
-    pthread_cond_init (&fooCond1, NULL);
-    pthread_cond_init (&fooCond2, NULL);
-  }
-  ~task_queue ()
-  {
-    pthread_mutex_destroy (&fooLock);
-    pthread_cond_destroy (&fooCond1);
-    pthread_cond_destroy (&fooCond2);
-  }
-  list<int> foo;
-  pthread_mutex_t fooLock;
-  pthread_cond_t fooCond1;
-  pthread_cond_t fooCond2;
-};
-
-void*
-produce (void* t)
-{
-  task_queue& tq = *(static_cast<task_queue*> (t));
-  int num = 0;
-  while (num < iters)
-    {
-      pthread_mutex_lock (&tq.fooLock);
-      while (tq.foo.size () >= max_size)
-	pthread_cond_wait (&tq.fooCond1, &tq.fooLock);
-      tq.foo.push_back (num++);
-      pthread_cond_signal (&tq.fooCond2);
-      pthread_mutex_unlock (&tq.fooLock);
-    }
-  return 0;
-}
-
-void*
-consume (void* t)
-{
-  task_queue& tq = *(static_cast<task_queue*> (t));
-  int num = 0;
-  while (num < iters)
-    {
-      pthread_mutex_lock (&tq.fooLock);
-      while (tq.foo.size () == 0)
-	pthread_cond_wait (&tq.fooCond2, &tq.fooLock);
-      if (tq.foo.front () != num++)
-	abort ();
-      tq.foo.pop_front ();
-      pthread_cond_signal (&tq.fooCond1);
-      pthread_mutex_unlock (&tq.fooLock);
-    }
-  return 0;
-}
-
-int
-main ()
-{
-  pthread_t prod[thread_pairs];
-  pthread_t cons[thread_pairs];
-
-  task_queue* tq[thread_pairs];
-
-#if defined(__sun) && defined(__svr4__) && _XOPEN_VERSION >= 500
-  pthread_setconcurrency (thread_pairs * 2);
-#endif
-
-  for (int j = 0; j < thread_cycles; j++)
-    {
-      for (int i = 0; i < thread_pairs; i++)
-	{
-	  tq[i] = new task_queue;
-	  pthread_create (&prod[i], NULL, produce, static_cast<void*> (tq[i]));
-	  pthread_create (&cons[i], NULL, consume, static_cast<void*> (tq[i]));
-	}
-
-      for (int i = 0; i < thread_pairs; i++)
-	{
-	  pthread_join (prod[i], NULL);
-	  pthread_join (cons[i], NULL);
-	  delete tq[i];
-	}
-    }
-
-  return 0;
-}
Index: testsuite/thread/pthread2.cc
===================================================================
--- testsuite/thread/pthread2.cc	(revision 144543)
+++ testsuite/thread/pthread2.cc	(working copy)
@@ -1,61 +0,0 @@
-// 2002-01-23  Loren J. Rittle <rittle@labs.mot.com> <ljrittle@acm.org>
-// Adpated from libstdc++/5347 submitted by markus.breuer@materna.de
-//
-// 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* mips-sgi-irix6* } }
-// { dg-options "-pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* alpha*-*-osf* mips-sgi-irix6* } }
-// { dg-options "-pthreads" { target *-*-solaris* } }
-
-#include <fstream>
-#include <pthread.h>
-
-const int max_thread_count = 2;
-const int max_loop_count = 1000000;
-
-void*
-thread_main (void *)
-{
-   for (int i = 0; i < max_loop_count; i++)
-   {
-      std::ofstream* pos1 = new std::ofstream;
-      delete pos1;
-   }
-
-   return 0;
-}
-
-int
-main()
-{
-  pthread_t tid[max_thread_count];
-
-#if defined(__sun) && defined(__svr4__) && _XOPEN_VERSION >= 500
-  pthread_setconcurrency (max_thread_count);
-#endif
-
-  for (int i = 0; i < max_thread_count; i++)
-    pthread_create (&tid[i], NULL, thread_main, 0);
-
-  for (int i = 0; i < max_thread_count; i++)
-    pthread_join (tid[i], NULL);
-
-  return 0;
-}
Index: testsuite/thread/pthread3.cc
===================================================================
--- testsuite/thread/pthread3.cc	(revision 144543)
+++ testsuite/thread/pthread3.cc	(working copy)
@@ -1,58 +0,0 @@
-// 2002-01-23  Loren J. Rittle <rittle@labs.mot.com> <ljrittle@acm.org>
-// Adpated from libstdc++/5347 submitted by markus.breuer@materna.de
-//
-// 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* mips-sgi-irix6* } }
-// { dg-options "-pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* alpha*-*-osf* mips-sgi-irix6* } }
-// { dg-options "-pthreads" { target *-*-solaris* } }
-
-#include <sstream>
-#include <pthread.h>
-
-const int max_thread_count = 2;
-const int max_loop_count = 1000000;
-
-void*
-thread_main (void *)
-{
-   for (int i = 0; i < max_loop_count; i++)
-     std::ostringstream oss;
-
-   return 0;
-}
-
-int
-main()
-{
-  pthread_t tid[max_thread_count];
-
-#if defined(__sun) && defined(__svr4__) && _XOPEN_VERSION >= 500
-  pthread_setconcurrency (max_thread_count);
-#endif
-
-  for (int i = 0; i < max_thread_count; i++)
-    pthread_create (&tid[i], NULL, thread_main, 0);
-
-  for (int i = 0; i < max_thread_count; i++)
-    pthread_join (tid[i], NULL);
-
-  return 0;
-}

Property changes on: testsuite/23_containers/list/pthread5.cc
___________________________________________________________________
Added: svn:mergeinfo


Property changes on: testsuite/23_containers/list/pthread1.cc
___________________________________________________________________
Added: svn:mergeinfo


Property changes on: testsuite/23_containers/map/pthread6.cc
___________________________________________________________________
Added: svn:mergeinfo


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]