Commit f7459b6c by Benjamin Kosnik Committed by Benjamin Kosnik

condition_variable (condition_variable): Remove _M_internal_mutex.

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

	* include/std/condition_variable (condition_variable): Remove
	_M_internal_mutex. Add private __native_type typedef.
	* src/condition_variable.cc (condition_variable::notify_one):
	Remove _M_internal_mutex use. Use typedef.
	(condition_variable::notify_all): Same.
	* include/std/mutex (mutex): Add private __native_type typedef. Use it.
	(recursive_mutex): Same.
	(timed_mutex): Same.
	(recursive_timed_mutex): Same.
	(once_flag): Make __native_type typedef private.

	* include/std/thread (this_thread): Add minimal markup.

	* testsuite/30_threads/condition_variable_any/cons/assign_neg.cc:
	Adjust line numbers.
	* testsuite/30_threads/condition_variable_any/cons/copy_neg.cc: Same.
	* testsuite/30_threads/mutex/cons/assign_neg.cc: Same.
	* testsuite/30_threads/mutex/cons/copy_neg.cc: Same.
	* testsuite/30_threads/timed_mutex/cons/assign_neg.cc: Same.
	* testsuite/30_threads/timed_mutex/cons/copy_neg.cc: Same.
	* testsuite/30_threads/thread/cons/assign_neg.cc: Same.
	* testsuite/30_threads/thread/cons/copy_neg.cc: Same.
	* testsuite/30_threads/recursive_mutex/cons/assign_neg.cc: Same.
	* testsuite/30_threads/recursive_mutex/cons/copy_neg.cc: Same.
	* testsuite/30_threads/condition_variable/cons/assign_neg.cc: Same.
	* testsuite/30_threads/condition_variable/cons/copy_neg.cc: Same.
	* testsuite/30_threads/recursive_timed_mutex/cons/assign_neg.cc: Same.
	* testsuite/30_threads/recursive_timed_mutex/cons/copy_neg.cc: Same.

	* testsuite/util/thread/all.h: Testsuite utilities for testing thread.
	* testsuite/30_threads/condition_variable_any/native_handle/
	typesizes.cc: New.
	* testsuite/30_threads/mutex/native_handle/typesizes.cc: Same.
	* testsuite/30_threads/timed_mutex/native_handle/typesizes.cc: Same.
	* testsuite/30_threads/thread/native_handle/typesizes.cc: Same.
	* testsuite/30_threads/recursive_mutex/native_handle/typesizes.cc: Same.
	* testsuite/30_threads/condition_variable/native_handle/
	typesizes.cc: Same.
	* testsuite/30_threads/recursive_timed_mutex/native_handle/
	typesizes.cc: Same.

From-SVN: r144053
parent 7314b35a
2009-02-09 Benjamin Kosnik <bkoz@redhat.com>
* include/std/condition_variable (condition_variable): Remove
_M_internal_mutex. Add private __native_type typedef.
* src/condition_variable.cc (condition_variable::notify_one):
Remove _M_internal_mutex use. Use typedef.
(condition_variable::notify_all): Same.
* include/std/mutex (mutex): Add private __native_type typedef. Use it.
(recursive_mutex): Same.
(timed_mutex): Same.
(recursive_timed_mutex): Same.
(once_flag): Make __native_type typedef private.
* include/std/thread (this_thread): Add minimal markup.
* testsuite/30_threads/condition_variable_any/cons/assign_neg.cc:
Adjust line numbers.
* testsuite/30_threads/condition_variable_any/cons/copy_neg.cc: Same.
* testsuite/30_threads/mutex/cons/assign_neg.cc: Same.
* testsuite/30_threads/mutex/cons/copy_neg.cc: Same.
* testsuite/30_threads/timed_mutex/cons/assign_neg.cc: Same.
* testsuite/30_threads/timed_mutex/cons/copy_neg.cc: Same.
* testsuite/30_threads/thread/cons/assign_neg.cc: Same.
* testsuite/30_threads/thread/cons/copy_neg.cc: Same.
* testsuite/30_threads/recursive_mutex/cons/assign_neg.cc: Same.
* testsuite/30_threads/recursive_mutex/cons/copy_neg.cc: Same.
* testsuite/30_threads/condition_variable/cons/assign_neg.cc: Same.
* testsuite/30_threads/condition_variable/cons/copy_neg.cc: Same.
* testsuite/30_threads/recursive_timed_mutex/cons/assign_neg.cc: Same.
* testsuite/30_threads/recursive_timed_mutex/cons/copy_neg.cc: Same.
* testsuite/util/thread/all.h: Testsuite utilities for testing thread.
* testsuite/30_threads/condition_variable_any/native_handle/
typesizes.cc: New.
* testsuite/30_threads/mutex/native_handle/typesizes.cc: Same.
* testsuite/30_threads/timed_mutex/native_handle/typesizes.cc: Same.
* testsuite/30_threads/thread/native_handle/typesizes.cc: Same.
* testsuite/30_threads/recursive_mutex/native_handle/typesizes.cc: Same.
* testsuite/30_threads/condition_variable/native_handle/
typesizes.cc: Same.
* testsuite/30_threads/recursive_timed_mutex/native_handle/
typesizes.cc: Same.
2009-02-09 Jack Howarth <howarth@bromo.med.uc.edu> 2009-02-09 Jack Howarth <howarth@bromo.med.uc.edu>
PR testsuite/33300 PR testsuite/33300
......
// <condition_variable> -*- C++ -*- // <condition_variable> -*- C++ -*-
// Copyright (C) 2008 Free Software Foundation, Inc. // Copyright (C) 2008, 2009 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // 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 // software; you can redistribute it and/or modify it under the
...@@ -50,10 +50,12 @@ namespace std ...@@ -50,10 +50,12 @@ namespace std
/// condition_variable /// condition_variable
class condition_variable class condition_variable
{ {
typedef chrono::system_clock __clock_t; typedef chrono::system_clock __clock_t;
typedef __gthread_cond_t __native_type;
__native_type _M_cond;
public: public:
typedef __gthread_cond_t* native_handle_type; typedef __native_type* native_handle_type;
condition_variable(); condition_variable();
~condition_variable(); ~condition_variable();
...@@ -104,8 +106,8 @@ namespace std ...@@ -104,8 +106,8 @@ namespace std
const chrono::time_point<_Clock, _Duration>& __atime, const chrono::time_point<_Clock, _Duration>& __atime,
_Predicate __p) _Predicate __p)
{ {
while(!__p()) while (!__p())
if(!wait_until(__lock, __atime)) if (!wait_until(__lock, __atime))
return __p(); return __p();
return true; return true;
...@@ -129,9 +131,6 @@ namespace std ...@@ -129,9 +131,6 @@ namespace std
{ return &_M_cond; } { return &_M_cond; }
private: private:
__gthread_cond_t _M_cond;
mutex _M_internal_mutex;
template<typename _Clock, typename _Duration> template<typename _Clock, typename _Duration>
bool bool
__wait_until_impl(unique_lock<mutex>& __lock, __wait_until_impl(unique_lock<mutex>& __lock,
...@@ -160,8 +159,11 @@ namespace std ...@@ -160,8 +159,11 @@ namespace std
// Like above, only mutex may not have try_lock. // Like above, only mutex may not have try_lock.
class condition_variable_any class condition_variable_any
{ {
typedef __gthread_cond_t __native_type;
__native_type _M_cond;
public: public:
typedef __gthread_cond_t* native_handle_type; typedef __native_type* native_handle_type;
condition_variable_any(); condition_variable_any();
~condition_variable_any(); ~condition_variable_any();
...@@ -208,9 +210,6 @@ namespace std ...@@ -208,9 +210,6 @@ namespace std
native_handle_type native_handle_type
native_handle() native_handle()
{ return &_M_cond; } { return &_M_cond; }
private:
__gthread_cond_t _M_cond;
}; };
} }
......
...@@ -57,7 +57,9 @@ namespace std ...@@ -57,7 +57,9 @@ namespace std
class thread class thread
{ {
public: public:
typedef __gthread_t native_handle_type; typedef __gthread_t native_handle_type;
struct _Impl_base;
typedef shared_ptr<_Impl_base> __shared_base_type;
/// thread::id /// thread::id
class id class id
...@@ -86,9 +88,6 @@ namespace std ...@@ -86,9 +88,6 @@ namespace std
operator<<(basic_ostream<_CharT, _Traits>&& __out, thread::id __id); operator<<(basic_ostream<_CharT, _Traits>&& __out, thread::id __id);
}; };
struct _Impl_base;
typedef shared_ptr<_Impl_base> __shared_base_type;
struct _Impl_base struct _Impl_base
{ {
id _M_id; id _M_id;
...@@ -239,21 +238,25 @@ namespace std ...@@ -239,21 +238,25 @@ namespace std
// 30.2.2 Namespace this_thread. // 30.2.2 Namespace this_thread.
namespace this_thread namespace this_thread
{ {
/// get_id
inline thread::id inline thread::id
get_id() { return thread::id(__gthread_self()); } get_id() { return thread::id(__gthread_self()); }
#ifdef _GLIBCXX_USE_SCHED_YIELD #ifdef _GLIBCXX_USE_SCHED_YIELD
/// yield
inline void inline void
yield() yield()
{ __gthread_yield(); } { __gthread_yield(); }
#endif #endif
#ifdef _GLIBCXX_USE_NANOSLEEP #ifdef _GLIBCXX_USE_NANOSLEEP
/// sleep_until
template<typename _Clock, typename _Duration> template<typename _Clock, typename _Duration>
inline void inline void
sleep_until(const chrono::time_point<_Clock, _Duration>& __atime) sleep_until(const chrono::time_point<_Clock, _Duration>& __atime)
{ sleep_for(__atime - _Clock::now()); } { sleep_for(__atime - _Clock::now()); }
/// sleep_for
template<typename _Rep, typename _Period> template<typename _Rep, typename _Period>
inline void inline void
sleep_for(const chrono::duration<_Rep, _Period>& __rtime) sleep_for(const chrono::duration<_Rep, _Period>& __rtime)
......
// condition_variable -*- C++ -*- // condition_variable -*- C++ -*-
// Copyright (C) 2008 Free Software Foundation, Inc. // Copyright (C) 2008, 2009 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // 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 // software; you can redistribute it and/or modify it under the
...@@ -36,7 +36,7 @@ namespace std ...@@ -36,7 +36,7 @@ namespace std
condition_variable::condition_variable() condition_variable::condition_variable()
{ {
#ifdef __GTHREAD_COND_INIT #ifdef __GTHREAD_COND_INIT
__gthread_cond_t __tmp = __GTHREAD_COND_INIT; __native_type __tmp = __GTHREAD_COND_INIT;
_M_cond = __tmp; _M_cond = __tmp;
#else #else
int __e = __gthread_cond_init(&_M_cond, NULL); int __e = __gthread_cond_init(&_M_cond, NULL);
...@@ -65,7 +65,6 @@ namespace std ...@@ -65,7 +65,6 @@ namespace std
void void
condition_variable::notify_one() condition_variable::notify_one()
{ {
lock_guard<mutex> __lock(_M_internal_mutex);
int __e = __gthread_cond_signal(&_M_cond); int __e = __gthread_cond_signal(&_M_cond);
// XXX not in spec // XXX not in spec
...@@ -77,7 +76,6 @@ namespace std ...@@ -77,7 +76,6 @@ namespace std
void void
condition_variable::notify_all() condition_variable::notify_all()
{ {
lock_guard<mutex> __lock(_M_internal_mutex);
int __e = __gthread_cond_broadcast(&_M_cond); int __e = __gthread_cond_broadcast(&_M_cond);
// XXX not in spec // XXX not in spec
...@@ -89,7 +87,7 @@ namespace std ...@@ -89,7 +87,7 @@ namespace std
condition_variable_any::condition_variable_any() condition_variable_any::condition_variable_any()
{ {
#ifdef __GTHREAD_COND_INIT #ifdef __GTHREAD_COND_INIT
__gthread_cond_t __tmp = __GTHREAD_COND_INIT; __native_type __tmp = __GTHREAD_COND_INIT;
_M_cond = __tmp; _M_cond = __tmp;
#else #else
int __e = __gthread_cond_init(&_M_cond, NULL); int __e = __gthread_cond_init(&_M_cond, NULL);
......
...@@ -45,7 +45,7 @@ namespace std ...@@ -45,7 +45,7 @@ namespace std
__try __try
{ {
__local->_M_run(); __t->_M_run();
} }
__catch(...) __catch(...)
{ {
...@@ -90,7 +90,6 @@ namespace std ...@@ -90,7 +90,6 @@ namespace std
void void
thread::_M_start_thread() thread::_M_start_thread()
{ {
// _M_data->_M_this_ptr = _M_data;
_M_data->_M_this_ptr = _M_data; _M_data->_M_this_ptr = _M_data;
int __e = __gthread_create(&_M_data->_M_id._M_thread, int __e = __gthread_create(&_M_data->_M_id._M_thread,
&execute_native_thread_routine, _M_data.get()); &execute_native_thread_routine, _M_data.get());
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
// { dg-require-cstdint "" } // { dg-require-cstdint "" }
// { dg-require-gthreads "" } // { dg-require-gthreads "" }
// Copyright (C) 2008 Free Software Foundation, Inc. // Copyright (C) 2008, 2009 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // 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 // software; you can redistribute it and/or modify it under the
...@@ -41,4 +41,4 @@ void test01() ...@@ -41,4 +41,4 @@ void test01()
} }
// { dg-error "used here" "" { target *-*-* } 40 } // { dg-error "used here" "" { target *-*-* } 40 }
// { dg-error "deleted function" "" { target *-*-* } 62 } // { dg-error "deleted function" "" { target *-*-* } 64 }
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
// { dg-require-cstdint "" } // { dg-require-cstdint "" }
// { dg-require-gthreads "" } // { dg-require-gthreads "" }
// Copyright (C) 2008 Free Software Foundation, Inc. // Copyright (C) 2008, 2009 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // 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 // software; you can redistribute it and/or modify it under the
...@@ -40,4 +40,4 @@ void test01() ...@@ -40,4 +40,4 @@ void test01()
} }
// { dg-error "used here" "" { target *-*-* } 39 } // { dg-error "used here" "" { target *-*-* } 39 }
// { dg-error "deleted function" "" { target *-*-* } 61 } // { dg-error "deleted function" "" { target *-*-* } 63 }
// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-solaris* *-*-cygwin *-*-darwin* alpha*-*-osf* mips-sgi-irix6* } }
// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* alpha*-*-osf* mips-sgi-irix6* } }
// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } }
// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } }
// { dg-require-cstdint "" }
// { dg-require-gthreads "" }
// Copyright (C) 2009 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.
#include <thread/all.h>
#include <condition_variable>
int main()
{
typedef std::condition_variable test_type;
__gnu_test::compare_type_to_native_type_sizes<test_type>();
return 0;
}
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
// { dg-require-cstdint "" } // { dg-require-cstdint "" }
// { dg-require-gthreads "" } // { dg-require-gthreads "" }
// Copyright (C) 2008 Free Software Foundation, Inc. // Copyright (C) 2008, 2009 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // 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 // software; you can redistribute it and/or modify it under the
...@@ -41,4 +41,4 @@ void test01() ...@@ -41,4 +41,4 @@ void test01()
} }
// { dg-error "used here" "" { target *-*-* } 40 } // { dg-error "used here" "" { target *-*-* } 40 }
// { dg-error "deleted function" "" { target *-*-* } 170 } // { dg-error "deleted function" "" { target *-*-* } 172 }
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
// { dg-require-cstdint "" } // { dg-require-cstdint "" }
// { dg-require-gthreads "" } // { dg-require-gthreads "" }
// Copyright (C) 2008 Free Software Foundation, Inc. // Copyright (C) 2008, 2009 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // 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 // software; you can redistribute it and/or modify it under the
...@@ -40,4 +40,4 @@ void test01() ...@@ -40,4 +40,4 @@ void test01()
} }
// { dg-error "used here" "" { target *-*-* } 39 } // { dg-error "used here" "" { target *-*-* } 39 }
// { dg-error "deleted function" "" { target *-*-* } 169 } // { dg-error "deleted function" "" { target *-*-* } 171 }
// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-solaris* *-*-cygwin *-*-darwin* alpha*-*-osf* mips-sgi-irix6* } }
// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* alpha*-*-osf* mips-sgi-irix6* } }
// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } }
// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } }
// { dg-require-cstdint "" }
// { dg-require-gthreads "" }
// Copyright (C) 2009 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.
#include <thread/all.h>
#include <condition_variable>
int main()
{
typedef std::condition_variable_any test_type;
__gnu_test::compare_type_to_native_type_sizes<test_type>();
return 0;
}
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
// { dg-require-cstdint "" } // { dg-require-cstdint "" }
// { dg-require-gthreads "" } // { dg-require-gthreads "" }
// Copyright (C) 2008 Free Software Foundation, Inc. // Copyright (C) 2008, 2009 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // 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 // software; you can redistribute it and/or modify it under the
...@@ -42,4 +42,4 @@ void test01() ...@@ -42,4 +42,4 @@ void test01()
} }
// { dg-error "used here" "" { target *-*-* } 41 } // { dg-error "used here" "" { target *-*-* } 41 }
// { dg-error "deleted function" "" { target *-*-* } 77 } // { dg-error "deleted function" "" { target *-*-* } 80 }
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
// { dg-require-cstdint "" } // { dg-require-cstdint "" }
// { dg-require-gthreads "" } // { dg-require-gthreads "" }
// Copyright (C) 2008 Free Software Foundation, Inc. // Copyright (C) 2008, 2009 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // 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 // software; you can redistribute it and/or modify it under the
...@@ -41,4 +41,4 @@ void test01() ...@@ -41,4 +41,4 @@ void test01()
} }
// { dg-error "used here" "" { target *-*-* } 40 } // { dg-error "used here" "" { target *-*-* } 40 }
// { dg-error "deleted function" "" { target *-*-* } 76 } // { dg-error "deleted function" "" { target *-*-* } 79 }
// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-solaris* *-*-cygwin *-*-darwin* alpha*-*-osf* mips-sgi-irix6* } }
// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* alpha*-*-osf* mips-sgi-irix6* } }
// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } }
// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } }
// { dg-require-cstdint "" }
// { dg-require-gthreads "" }
// Copyright (C) 2009 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.
#include <thread/all.h>
#include <mutex>
int main()
{
typedef std::mutex test_type;
__gnu_test::compare_type_to_native_type_sizes<test_type>();
return 0;
}
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
// { dg-require-cstdint "" } // { dg-require-cstdint "" }
// { dg-require-gthreads "" } // { dg-require-gthreads "" }
// Copyright (C) 2008 Free Software Foundation, Inc. // Copyright (C) 2008, 2009 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // 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 // software; you can redistribute it and/or modify it under the
...@@ -42,4 +42,4 @@ void test01() ...@@ -42,4 +42,4 @@ void test01()
} }
// { dg-error "used here" "" { target *-*-* } 41 } // { dg-error "used here" "" { target *-*-* } 41 }
// { dg-error "deleted function" "" { target *-*-* } 129 } // { dg-error "deleted function" "" { target *-*-* } 132 }
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
// { dg-require-cstdint "" } // { dg-require-cstdint "" }
// { dg-require-gthreads "" } // { dg-require-gthreads "" }
// Copyright (C) 2008 Free Software Foundation, Inc. // Copyright (C) 2008, 2009 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // 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 // software; you can redistribute it and/or modify it under the
...@@ -41,4 +41,4 @@ void test01() ...@@ -41,4 +41,4 @@ void test01()
} }
// { dg-error "used here" "" { target *-*-* } 40 } // { dg-error "used here" "" { target *-*-* } 40 }
// { dg-error "deleted function" "" { target *-*-* } 128 } // { dg-error "deleted function" "" { target *-*-* } 131 }
// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-solaris* *-*-cygwin *-*-darwin* alpha*-*-osf* mips-sgi-irix6* } }
// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* alpha*-*-osf* mips-sgi-irix6* } }
// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } }
// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } }
// { dg-require-cstdint "" }
// { dg-require-gthreads "" }
// Copyright (C) 2009 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.
#include <thread/all.h>
#include <mutex>
int main()
{
typedef std::recursive_mutex test_type;
__gnu_test::compare_type_to_native_type_sizes<test_type>();
return 0;
}
...@@ -42,4 +42,4 @@ void test01() ...@@ -42,4 +42,4 @@ void test01()
} }
// { dg-error "used here" "" { target *-*-* } 41 } // { dg-error "used here" "" { target *-*-* } 41 }
// { dg-error "deleted function" "" { target *-*-* } 283 } // { dg-error "deleted function" "" { target *-*-* } 295 }
...@@ -41,4 +41,4 @@ void test01() ...@@ -41,4 +41,4 @@ void test01()
} }
// { dg-error "used here" "" { target *-*-* } 40 } // { dg-error "used here" "" { target *-*-* } 40 }
// { dg-error "deleted function" "" { target *-*-* } 282 } // { dg-error "deleted function" "" { target *-*-* } 294 }
// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-solaris* *-*-cygwin *-*-darwin* alpha*-*-osf* mips-sgi-irix6* } }
// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* alpha*-*-osf* mips-sgi-irix6* } }
// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } }
// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } }
// { dg-require-cstdint "" }
// { dg-require-gthreads "" }
// Copyright (C) 2009 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.
#include <mutex>
#include <thread/all.h>
int main()
{
typedef std::recursive_timed_mutex test_type;
__gnu_test::compare_type_to_native_type_sizes<test_type>();
return 0;
}
...@@ -33,4 +33,4 @@ void test01() ...@@ -33,4 +33,4 @@ void test01()
} }
// { dg-error "used here" "" { target *-*-* } 32 } // { dg-error "used here" "" { target *-*-* } 32 }
// { dg-error "deleted function" "" { target *-*-* } 145 } // { dg-error "deleted function" "" { target *-*-* } 144 }
...@@ -28,9 +28,9 @@ void test01() ...@@ -28,9 +28,9 @@ void test01()
// copy // copy
typedef std::thread test_type; typedef std::thread test_type;
test_type t1; test_type t1;
test_type t2(t1); test_type t2(t1); // XXX this is failing for the wrong reason
} }
// { dg-error "here" "" { target *-*-* } 31 } // { dg-error "here" "" { target *-*-* } 31 }
// { dg-error "deleted function" "" { target *-*-* } 124 } // { dg-error "deleted function" "" { target *-*-* } 123 }
// { dg-excess-errors "In file included from" } // { dg-excess-errors "In file included from" }
// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-solaris* *-*-cygwin *-*-darwin* alpha*-*-osf* mips-sgi-irix6* } }
// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* alpha*-*-osf* mips-sgi-irix6* } }
// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } }
// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } }
// { dg-require-cstdint "" }
// { dg-require-gthreads "" }
// Copyright (C) 2009 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.
#include <thread/all.h>
#include <thread>
int main()
{
typedef std::thread test_type;
// XXX disable at the moment
//__gnu_test::compare_type_to_native_type_sizes<test_type>();
return 0;
}
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
// { dg-require-cstdint "" } // { dg-require-cstdint "" }
// { dg-require-gthreads "" } // { dg-require-gthreads "" }
// Copyright (C) 2008 Free Software Foundation, Inc. // Copyright (C) 2008, 2009 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // 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 // software; you can redistribute it and/or modify it under the
...@@ -42,4 +42,4 @@ void test01() ...@@ -42,4 +42,4 @@ void test01()
} }
// { dg-error "used here" "" { target *-*-* } 41 } // { dg-error "used here" "" { target *-*-* } 41 }
// { dg-error "deleted function" "" { target *-*-* } 180 } // { dg-error "deleted function" "" { target *-*-* } 190 }
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
// { dg-require-cstdint "" } // { dg-require-cstdint "" }
// { dg-require-gthreads "" } // { dg-require-gthreads "" }
// Copyright (C) 2008 Free Software Foundation, Inc. // Copyright (C) 2008, 2009 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // 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 // software; you can redistribute it and/or modify it under the
...@@ -41,4 +41,4 @@ void test01() ...@@ -41,4 +41,4 @@ void test01()
} }
// { dg-error "used here" "" { target *-*-* } 40 } // { dg-error "used here" "" { target *-*-* } 40 }
// { dg-error "deleted function" "" { target *-*-* } 179 } // { dg-error "deleted function" "" { target *-*-* } 189 }
// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-solaris* *-*-cygwin *-*-darwin* alpha*-*-osf* mips-sgi-irix6* } }
// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* alpha*-*-osf* mips-sgi-irix6* } }
// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } }
// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } }
// { dg-require-cstdint "" }
// { dg-require-gthreads "" }
// Copyright (C) 2009 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.
#include <thread/all.h>
#include <mutex>
int main()
{
typedef std::timed_mutex test_type;
__gnu_test::compare_type_to_native_type_sizes<test_type>();
return 0;
}
// -*- C++ -*-
// Utilities for testing threads for the C++ library testsuite.
//
// Copyright (C) 2009 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.
//
// As a special exception, you may use this file as part of a free software
// library without restriction. Specifically, if other files instantiate
// templates or use macros or inline functions from this file, or you compile
// this file and link it with other files to produce an executable, this
// file does not by itself cause the resulting executable to be covered by
// the GNU General Public License. This exception does not however
// invalidate any other reasons why the executable file might be covered by
// the GNU General Public License.
#ifndef _GLIBCXX_TESTSUITE_THREAD_H
#define _GLIBCXX_TESTSUITE_THREAD_H
#include <sstream>
#include <stdexcept>
#include <type_traits>
// C++0x only.
namespace __gnu_test
{
// Assume _Tp::native_handle_type.
template<typename _Tp>
void
compare_type_to_native_type_sizes()
{
typedef _Tp test_type;
typedef typename test_type::native_handle_type native_handle_type;
int st = sizeof(test_type);
// Remove possible pointer type.
int snt = sizeof(typename std::remove_pointer<native_handle_type>::type);
if (st != snt)
{
std::ostringstream s;
s << std::endl;
s << "size of _Tp: " << st << std::endl;
s << "size of *(_Tp::native_handle_type): " << snt << std::endl;
throw std::runtime_error(s.str());
}
}
} // namespace __gnu_test
#endif // _GLIBCXX_TESTSUITE_THREAD_H
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment