diff options
author | Jonathan Wakely <jwakely@redhat.com> | 2019-11-15 14:38:59 +0000 |
---|---|---|
committer | Jonathan Wakely <redi@gcc.gnu.org> | 2019-11-15 14:38:59 +0000 |
commit | a0e1dcd44f9c0ee22f56b73660f36072633adb69 (patch) | |
tree | 299841c9a1488666a529f2af88e0ff24b4bcaaa4 | |
parent | f31e515fd519fe6ec3dc0b5cf5b1388fd1373ba4 (diff) | |
download | gcc-a0e1dcd44f9c0ee22f56b73660f36072633adb69.zip gcc-a0e1dcd44f9c0ee22f56b73660f36072633adb69.tar.gz gcc-a0e1dcd44f9c0ee22f56b73660f36072633adb69.tar.bz2 |
libstdc++: Fix definition of std::nostopstate object
Also add <stop_token> header to PCH and Doxygen config.
* doc/doxygen/user.cfg.in: Add <stop_token>.
* include/precompiled/stdc++.h: Likewise.
* include/std/stop_token: Fix definition of std::nostopstate.
* testsuite/30_threads/headers/stop_token/synopsis.cc: New test.
* testsuite/30_threads/headers/thread/types_std_c++20.cc: New test.
* testsuite/30_threads/stop_token/stop_source.cc: New test.
* testsuite/30_threads/stop_token/stop_token.cc: Remove unnecessary
dg-require directives. Remove I/O and inclusion of <iostream>.
From-SVN: r278296
-rw-r--r-- | libstdc++-v3/ChangeLog | 11 | ||||
-rw-r--r-- | libstdc++-v3/doc/doxygen/user.cfg.in | 1 | ||||
-rw-r--r-- | libstdc++-v3/include/precompiled/stdc++.h | 1 | ||||
-rw-r--r-- | libstdc++-v3/include/std/stop_token | 2 | ||||
-rw-r--r-- | libstdc++-v3/testsuite/30_threads/headers/stop_token/synopsis.cc | 35 | ||||
-rw-r--r-- | libstdc++-v3/testsuite/30_threads/headers/thread/types_std_c++20.cc | 30 | ||||
-rw-r--r-- | libstdc++-v3/testsuite/30_threads/stop_token/stop_source.cc | 75 | ||||
-rw-r--r-- | libstdc++-v3/testsuite/30_threads/stop_token/stop_token.cc | 8 |
8 files changed, 156 insertions, 7 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index b537c95..53f3b29 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,14 @@ +2019-11-15 Jonathan Wakely <jwakely@redhat.com> + + * doc/doxygen/user.cfg.in: Add <stop_token>. + * include/precompiled/stdc++.h: Likewise. + * include/std/stop_token: Fix definition of std::nostopstate. + * testsuite/30_threads/headers/stop_token/synopsis.cc: New test. + * testsuite/30_threads/headers/thread/types_std_c++20.cc: New test. + * testsuite/30_threads/stop_token/stop_source.cc: New test. + * testsuite/30_threads/stop_token/stop_token.cc: Remove unnecessary + dg-require directives. Remove I/O and inclusion of <iostream>. + 2019-11-14 Thomas Rodgers <trodgers@redhat.com> * include/Makefile.am: Add <stop_token> header. diff --git a/libstdc++-v3/doc/doxygen/user.cfg.in b/libstdc++-v3/doc/doxygen/user.cfg.in index 1899470..19f8ffd 100644 --- a/libstdc++-v3/doc/doxygen/user.cfg.in +++ b/libstdc++-v3/doc/doxygen/user.cfg.in @@ -840,6 +840,7 @@ INPUT = @srcdir@/doc/doxygen/doxygroups.cc \ include/sstream \ include/stack \ include/stdexcept \ + include/stop_token \ include/streambuf \ include/string \ include/string_view \ diff --git a/libstdc++-v3/include/precompiled/stdc++.h b/libstdc++-v3/include/precompiled/stdc++.h index 118fc8f..c77136e 100644 --- a/libstdc++-v3/include/precompiled/stdc++.h +++ b/libstdc++-v3/include/precompiled/stdc++.h @@ -140,6 +140,7 @@ #include <numbers> #include <ranges> #include <span> +#include <stop_token> // #include <syncstream> #include <version> #endif diff --git a/libstdc++-v3/include/std/stop_token b/libstdc++-v3/include/std/stop_token index af64018..f96c267 100644 --- a/libstdc++-v3/include/std/stop_token +++ b/libstdc++-v3/include/std/stop_token @@ -47,7 +47,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION class stop_callback; struct nostopstate_t { explicit nostopstate_t() = default; }; - inline constexpr nostopstate_t nostopstate(); + inline constexpr nostopstate_t nostopstate{}; class stop_token { diff --git a/libstdc++-v3/testsuite/30_threads/headers/stop_token/synopsis.cc b/libstdc++-v3/testsuite/30_threads/headers/stop_token/synopsis.cc new file mode 100644 index 0000000..b185bc7 --- /dev/null +++ b/libstdc++-v3/testsuite/30_threads/headers/stop_token/synopsis.cc @@ -0,0 +1,35 @@ +// Copyright (C) 2019 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 3, 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 COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +// { dg-options "-std=gnu++2a" } +// { dg-do compile { target c++2a } } + +#include <stop_token> + +namespace std +{ + class stop_token; + class stop_source; + struct nostopstate_t; + template<class> + class stop_callback; +} + +namespace gnu +{ + constexpr const std::nostopstate_t* tag = &std::nostopstate; +} diff --git a/libstdc++-v3/testsuite/30_threads/headers/thread/types_std_c++20.cc b/libstdc++-v3/testsuite/30_threads/headers/thread/types_std_c++20.cc new file mode 100644 index 0000000..86f29d8 --- /dev/null +++ b/libstdc++-v3/testsuite/30_threads/headers/thread/types_std_c++20.cc @@ -0,0 +1,30 @@ +// { dg-options "-std=gnu++2a" } +// { dg-do compile { target c++2a } } +// { dg-require-gthreads "" } + +// Copyright (C) 2019 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 3, 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 COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +#include <thread> + +void test01() +{ + using t_t = std::thread; + using j_t = std::jthread; + + using namespace std::this_thread; +} diff --git a/libstdc++-v3/testsuite/30_threads/stop_token/stop_source.cc b/libstdc++-v3/testsuite/30_threads/stop_token/stop_source.cc new file mode 100644 index 0000000..9e477b7 --- /dev/null +++ b/libstdc++-v3/testsuite/30_threads/stop_token/stop_source.cc @@ -0,0 +1,75 @@ +// Copyright (C) 2019 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 3, 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 COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +// { dg-options "-std=gnu++2a" } +// { dg-do run { target c++2a } } + +#include <stop_token> +#include <testsuite_hooks.h> + +void +test01() +{ + std::stop_source ssrc; + VERIFY( ssrc.stop_possible() ); + VERIFY( !ssrc.stop_requested() ); + + std::stop_source copy(ssrc); + VERIFY( copy.stop_possible() ); + VERIFY( !copy.stop_requested() ); + VERIFY( ssrc.stop_possible() ); + VERIFY( !ssrc.stop_requested() ); + + std::stop_source move(std::move(ssrc)); + VERIFY( move.stop_possible() ); + VERIFY( !move.stop_requested() ); + VERIFY( copy.stop_possible() ); + VERIFY( !copy.stop_requested() ); + VERIFY( !ssrc.stop_possible() ); + VERIFY( !ssrc.stop_requested() ); +} + +void +test02() +{ + // stop_source(nostopstate_t) constructor is explicit: + static_assert(!std::is_convertible_v<std::nostopstate_t, std::stop_source>); + + std::stop_source ssrc(std::nostopstate); + VERIFY( !ssrc.stop_possible() ); + VERIFY( !ssrc.stop_requested() ); + + std::stop_source copy(ssrc); + VERIFY( !copy.stop_possible() ); + VERIFY( !copy.stop_requested() ); + VERIFY( !ssrc.stop_possible() ); + VERIFY( !ssrc.stop_requested() ); + + std::stop_source move(std::move(ssrc)); + VERIFY( !move.stop_possible() ); + VERIFY( !move.stop_requested() ); + VERIFY( !copy.stop_possible() ); + VERIFY( !copy.stop_requested() ); + VERIFY( !ssrc.stop_possible() ); + VERIFY( !ssrc.stop_requested() ); +} + +int main() +{ + test01(); + test02(); +} diff --git a/libstdc++-v3/testsuite/30_threads/stop_token/stop_token.cc b/libstdc++-v3/testsuite/30_threads/stop_token/stop_token.cc index 37d79e8..f0772c1 100644 --- a/libstdc++-v3/testsuite/30_threads/stop_token/stop_token.cc +++ b/libstdc++-v3/testsuite/30_threads/stop_token/stop_token.cc @@ -15,13 +15,10 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. -// { dg-options "-std=gnu++2a -pthread" } -// { dg-do run } -// { dg-require-effective-target c++2a } -// { dg-require-effective-target pthread } +// { dg-options "-std=gnu++2a" } +// { dg-do run { target c++2a } } #include <stop_token> -#include <iostream> #include <testsuite_hooks.h> int main() @@ -41,7 +38,6 @@ int main() // register callback bool cb1called{false}; auto cb1 = [&]{ - std::cout << "cb1" << std::endl; cb1called = true; }; { |