diff options
Diffstat (limited to 'libstdc++-v3')
-rw-r--r-- | libstdc++-v3/ChangeLog | 8 | ||||
-rw-r--r-- | libstdc++-v3/include/std/thread | 2 | ||||
-rw-r--r-- | libstdc++-v3/testsuite/30_threads/thread/cons/6.cc | 70 | ||||
-rw-r--r-- | libstdc++-v3/testsuite/30_threads/thread/cons/7.cc | 80 | ||||
-rw-r--r-- | libstdc++-v3/testsuite/30_threads/thread/cons/8.cc | 80 |
5 files changed, 239 insertions, 1 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 8c1ceb8..d80ab82 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,11 @@ +2009-02-08 Chris Fairles <cfairles@gcc.gnu.org> + + * include/std/thread (thread<>::thread(_Callable)): Explicitly use + _Callable as template argument for _M_make_shared_data. + * testsuite/30_threads/thread/cons/6.cc: New. + * testsuite/30_threads/thread/cons/7.cc: New. + * testsuite/30_threads/thread/cons/8.cc: New. + 2009-02-07 Benjamin Kosnik <bkoz@redhat.com> * testsuite/30_threads/thread/member: To.. diff --git a/libstdc++-v3/include/std/thread b/libstdc++-v3/include/std/thread index 9ce5fdd..3704192 100644 --- a/libstdc++-v3/include/std/thread +++ b/libstdc++-v3/include/std/thread @@ -128,7 +128,7 @@ namespace std template<typename _Callable> explicit thread(_Callable __f) - : _M_data(_M_make_shared_data(__f)) + : _M_data(_M_make_shared_data<_Callable>(__f)) { _M_start_thread(); } template<typename _Callable, typename... _Args> diff --git a/libstdc++-v3/testsuite/30_threads/thread/cons/6.cc b/libstdc++-v3/testsuite/30_threads/thread/cons/6.cc new file mode 100644 index 0000000..0a6d747 --- /dev/null +++ b/libstdc++-v3/testsuite/30_threads/thread/cons/6.cc @@ -0,0 +1,70 @@ +// { 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. + +// 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. + +#include <thread> +#include <system_error> +#include <testsuite_hooks.h> + +bool f_was_called = false; + +void f() +{ + f_was_called = true; +} + +void test06() +{ + bool test __attribute__((unused)) = true; + + try + { + std::thread t(f); + t.join(); + VERIFY( f_was_called ); + } + catch (const std::system_error&) + { + VERIFY( false ); + } + catch (...) + { + VERIFY( false ); + } +} + +int main() +{ + test06(); + return 0; +} diff --git a/libstdc++-v3/testsuite/30_threads/thread/cons/7.cc b/libstdc++-v3/testsuite/30_threads/thread/cons/7.cc new file mode 100644 index 0000000..fafa72a --- /dev/null +++ b/libstdc++-v3/testsuite/30_threads/thread/cons/7.cc @@ -0,0 +1,80 @@ +// { 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) 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. + +// 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. + +#include <thread> +#include <system_error> +#include <testsuite_hooks.h> + +bool functor_was_called = false; + +struct copyable +{ + copyable() = default; + ~copyable() = default; + copyable(const copyable& c) = default; + copyable& operator=(const copyable&) = default; + + void operator()() const + { + functor_was_called = true; + } +}; + +void test07() +{ + bool test __attribute__((unused)) = true; + + try + { + copyable c; + copyable& rc = c; + std::thread t1(rc); + t1.join(); + VERIFY( functor_was_called ); + } + catch (const std::system_error&) + { + VERIFY( false ); + } + catch (...) + { + VERIFY( false ); + } +} + +int main() +{ + test07(); + return 0; +} diff --git a/libstdc++-v3/testsuite/30_threads/thread/cons/8.cc b/libstdc++-v3/testsuite/30_threads/thread/cons/8.cc new file mode 100644 index 0000000..8c6b2e1 --- /dev/null +++ b/libstdc++-v3/testsuite/30_threads/thread/cons/8.cc @@ -0,0 +1,80 @@ +// { 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) 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. + +// 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. + +#include <thread> +#include <system_error> +#include <testsuite_hooks.h> + +bool functor_was_called = false; + +struct moveable +{ + moveable() = default; + ~moveable() = default; + moveable(const moveable& c) = delete; + moveable& operator=(const moveable&) = delete; + moveable(moveable&&) { } + + void operator()() const + { + functor_was_called = true; + } +}; + +void test08() +{ + bool test __attribute__((unused)) = true; + + try + { + moveable m; + std::thread t1(std::move(m)); + t1.join(); + VERIFY( functor_was_called ); + } + catch (const std::system_error&) + { + VERIFY( false ); + } + catch (...) + { + VERIFY( false ); + } +} + +int main() +{ + test08(); + return 0; +} |