diff options
author | Ben Cheng <bccheng@google.com> | 2014-03-25 22:37:19 -0700 |
---|---|---|
committer | Ben Cheng <bccheng@google.com> | 2014-03-25 22:37:19 -0700 |
commit | 1bc5aee63eb72b341f506ad058502cd0361f0d10 (patch) | |
tree | c607e8252f3405424ff15bc2d00aa38dadbb2518 /gcc-4.9/libstdc++-v3/testsuite/30_threads | |
parent | 283a0bf58fcf333c58a2a92c3ebbc41fb9eb1fdb (diff) | |
download | toolchain_gcc-1bc5aee63eb72b341f506ad058502cd0361f0d10.tar.gz toolchain_gcc-1bc5aee63eb72b341f506ad058502cd0361f0d10.tar.bz2 toolchain_gcc-1bc5aee63eb72b341f506ad058502cd0361f0d10.zip |
Initial checkin of GCC 4.9.0 from trunk (r208799).
Change-Id: I48a3c08bb98542aa215912a75f03c0890e497dba
Diffstat (limited to 'gcc-4.9/libstdc++-v3/testsuite/30_threads')
245 files changed, 13234 insertions, 0 deletions
diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/async/42819.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/async/42819.cc new file mode 100644 index 000000000..587403556 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/async/42819.cc @@ -0,0 +1,59 @@ +// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* *-*-solaris* *-*-cygwin *-*-darwin* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } } +// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } } +// { dg-require-cstdint "" } +// { dg-require-gthreads "" } +// { dg-require-atomic-builtins "" } + +// Copyright (C) 2010-2014 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 <future> +#include <testsuite_hooks.h> + +int do_work1(int value) { return value; } +int do_work2(int value) { return value * 2; } + +int work1(int value) +{ + auto handle = std::async([=] { return do_work2(value); }); + int tmp = do_work1(value); + return tmp + handle.get(); +} + +int work2(int value) +{ + auto handle = std::async(do_work2, value); + int tmp = do_work1(value); + return tmp + handle.get(); +} + +// libstdc++/42819 +void test01() +{ + bool test __attribute__((unused)) = true; + + VERIFY( work1(1) == 3 ); + VERIFY( work2(2) == 6 ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/async/49668.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/async/49668.cc new file mode 100644 index 000000000..a13a1a22d --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/async/49668.cc @@ -0,0 +1,62 @@ +// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* *-*-solaris* *-*-cygwin *-*-darwin* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } } +// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } } +// { dg-require-cstdint "" } +// { dg-require-gthreads "" } +// { dg-require-atomic-builtins "" } + +// Copyright (C) 2011-2014 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 <future> +#include <functional> +#include <testsuite_hooks.h> + +struct moveable +{ + moveable() = default; + moveable(moveable&&) = default; + moveable(const moveable&) = delete; +}; + +using std::launch; +namespace ph = std::placeholders; + +typedef decltype(ph::_1) placeholder_type; + +bool f(moveable, placeholder_type) { return true; } + +void test01() +{ + auto fut = std::async(launch::async, f, moveable(), ph::_1); + bool test = fut.get(); + VERIFY( test ); +} + +void test02() +{ + auto fut = std::async(launch::deferred, f, moveable(), ph::_1); + bool test = fut.get(); + VERIFY( test ); +} + +int main() +{ + test01(); + test02(); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/async/54297.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/async/54297.cc new file mode 100644 index 000000000..d760363ae --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/async/54297.cc @@ -0,0 +1,51 @@ +// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* *-*-solaris* *-*-cygwin *-*-darwin* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } } +// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } } +// { dg-require-cstdint "" } +// { dg-require-gthreads "" } +// { dg-require-atomic-builtins "" } +// { dg-require-sleep "" } + +// Copyright (C) 2012-2014 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 <chrono> +#include <thread> +#include <future> +#include <set> +#include <testsuite_hooks.h> + +struct Task; + +std::set<const Task*> dead_tasks; + +struct Task +{ + ~Task() { dead_tasks.insert(this); } + + void operator()() const + { + std::this_thread::sleep_for(std::chrono::seconds(1)); + VERIFY( dead_tasks.count(this) == 0 ); + } +}; + +int main() +{ + std::async(std::launch::async, Task()); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/async/any.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/async/any.cc new file mode 100644 index 000000000..733f345b3 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/async/any.cc @@ -0,0 +1,58 @@ +// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* *-*-solaris* *-*-cygwin *-*-darwin* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } } +// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } } +// { dg-require-cstdint "" } +// { dg-require-gthreads "" } +// { dg-require-atomic-builtins "" } + +// Copyright (C) 2010-2014 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 <future> +#include <testsuite_hooks.h> + +struct sum { + typedef int result_type; + int operator()(int i, int& j, const int& k) { return i + j + k; } +}; + +void test01() +{ + bool test __attribute__((unused)) = true; + + using namespace std; + + int a = 1; + int b = 10; + int c = 100; + future<int> f1 = async(launch::async|launch::deferred, sum(), a, ref(b), cref(c)); + future<int> f2 = async(sum(), a, ref(b), cref(c)); + + VERIFY( f1.valid() ); + VERIFY( f2.valid() ); + int r1 = f1.get(); + int r2 = f2.get(); + VERIFY( r1 == r2 ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/async/async.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/async/async.cc new file mode 100644 index 000000000..3bd3da129 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/async/async.cc @@ -0,0 +1,71 @@ +// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* *-*-solaris* *-*-cygwin *-*-darwin* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } } +// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } } +// { dg-require-cstdint "" } +// { dg-require-gthreads "" } +// { dg-require-atomic-builtins "" } + +// Copyright (C) 2010-2014 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 <future> +#include <testsuite_hooks.h> + +using namespace std; + +void work(mutex& m) +{ + unique_lock<mutex> l(m); +} + +void test01() +{ + mutex m; + unique_lock<mutex> l(m); + future<void> f1 = async(launch::async, &work, ref(m)); + l.unlock(); // allow async thread to proceed + f1.get(); // wait for it to finish +} + +void test02() +{ + bool test __attribute__((unused)) = true; + + mutex m; + unique_lock<mutex> l(m); + future<void> f1 = async(launch::async, &work, ref(m)); + std::future_status status; + status = f1.wait_for(std::chrono::milliseconds(1)); + VERIFY( status == std::future_status::timeout ); + status = f1.wait_until(std::chrono::system_clock::now()); + VERIFY( status == std::future_status::timeout ); + l.unlock(); // allow async thread to proceed + f1.wait(); // wait for it to finish + status = f1.wait_for(std::chrono::milliseconds(0)); + VERIFY( status == std::future_status::ready ); + status = f1.wait_until(std::chrono::system_clock::now()); + VERIFY( status == std::future_status::ready ); +} + +int main() +{ + test01(); + test02(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/async/launch.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/async/launch.cc new file mode 100644 index 000000000..2dfaf571f --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/async/launch.cc @@ -0,0 +1,94 @@ +// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* *-*-solaris* *-*-cygwin *-*-darwin* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } } +// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } } +// { dg-require-cstdint "" } +// { dg-require-gthreads "" } +// { dg-require-atomic-builtins "" } + +// Copyright (C) 2011-2014 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 <future> +#include <testsuite_hooks.h> + +void test01() +{ + bool test __attribute__((unused)) = true; + + using std::launch; + + const launch none{}; + const launch both = launch::async|launch::deferred; + const launch all = ~none; + + VERIFY( (none & both) == none ); + VERIFY( (none | both) == both ); + VERIFY( (none ^ both) == both ); + + VERIFY( (none & all) == none ); + VERIFY( (none | all) == all ); + VERIFY( (none ^ all) == all ); + + VERIFY( (both & all) == both ); + VERIFY( (both | all) == all ); + VERIFY( (both ^ all) == ~both ); + + VERIFY( (none & launch::async) == none ); + VERIFY( (none & launch::deferred) == none ); + + VERIFY( (none | launch::async) == launch::async ); + VERIFY( (none | launch::deferred) == launch::deferred ); + + VERIFY( (none ^ launch::async) == launch::async ); + VERIFY( (none ^ launch::deferred) == launch::deferred ); + + VERIFY( (none & none) == none ); + VERIFY( (none | none) == none ); + VERIFY( (none ^ none) == none ); + + VERIFY( (both & both) == both ); + VERIFY( (both | both) == both ); + VERIFY( (both ^ both) == none ); + + VERIFY( (all & all) == all ); + VERIFY( (all | all) == all ); + VERIFY( (all ^ all) == none ); + + launch l = none; + + l &= none; + VERIFY( l == none ); + l |= none; + VERIFY( l == none ); + l ^= none; + VERIFY( l == none ); + + l &= both; + VERIFY( l == none ); + l |= both; + VERIFY( l == both ); + l ^= both; + VERIFY( l == none ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/async/sync.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/async/sync.cc new file mode 100644 index 000000000..89ae51423 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/async/sync.cc @@ -0,0 +1,74 @@ +// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* *-*-solaris* *-*-cygwin *-*-darwin* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } } +// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } } +// { dg-require-cstdint "" } +// { dg-require-gthreads "" } +// { dg-require-atomic-builtins "" } + +// Copyright (C) 2010-2014 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 <future> +#include <testsuite_hooks.h> + +struct sum { + typedef int result_type; + int operator()(int i, int& j, const int& k) { return i + j + k; } +}; + +void test01() +{ + bool test __attribute__((unused)) = true; + + using namespace std; + + int a = 1; + int b = 1; + int c = 1; + future<int> f1 = async(launch::deferred, sum(), a, ref(b), cref(c)); + a = 0; + b = 10; + c = 100; + + const std::chrono::seconds delay(10); + const auto then = std::chrono::system_clock::now() + delay; + + VERIFY( f1.valid() ); + // timed waiting functions should return 'deferred' immediately + VERIFY( f1.wait_until(then) == std::future_status::deferred ); + VERIFY( f1.wait_for(delay) == std::future_status::deferred ); + VERIFY( std::chrono::system_clock::now() < then ); + + f1.wait(); + + VERIFY( f1.valid() ); + // timed waiting functions should return 'ready' immediately + VERIFY( f1.wait_until(then) == std::future_status::ready ); + VERIFY( f1.wait_for(delay) == std::future_status::ready ); + VERIFY( std::chrono::system_clock::now() < then ); + + VERIFY( f1.get() == 111 ); + VERIFY( !f1.valid() ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/call_once/39909.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/call_once/39909.cc new file mode 100644 index 000000000..ea88d5e47 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/call_once/39909.cc @@ -0,0 +1,56 @@ +// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* *-*-solaris* *-*-cygwin *-*-darwin* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* powerpc-ibm-aix* } } +// { 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-2014 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 <mutex> +#include <thread> +#include <testsuite_hooks.h> + +std::once_flag flag; +int value = 0; + +struct Inc { void operator()() const { ++value; } }; + +struct Func +{ + void operator()() const + { + Inc inc; + for (int i = 0; i < 10000; ++i) + std::call_once(flag, inc); + } +}; + +int main() +{ + Func f; + std::thread t1(f); + std::thread t2(f); + std::thread t3(f); + t1.join(); + t2.join(); + t3.join(); + VERIFY( value == 1 ); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/call_once/49668.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/call_once/49668.cc new file mode 100644 index 000000000..bcedcfc2c --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/call_once/49668.cc @@ -0,0 +1,51 @@ +// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* *-*-solaris* *-*-cygwin *-*-darwin* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } } +// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } } +// { dg-require-cstdint "" } +// { dg-require-gthreads "" } + +// Copyright (C) 2011-2014 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 <mutex> +#include <functional> +#include <testsuite_hooks.h> + +struct moveable +{ + moveable() = default; + moveable(moveable&&) = default; + moveable(const moveable&) = delete; +}; + +typedef decltype(std::placeholders::_1) placeholder_type; + +void f(moveable, placeholder_type, bool& b) { b = true; } + +void test01() +{ + bool test = false; + std::once_flag once; + std::call_once(once, f, moveable(), std::placeholders::_1, std::ref(test)); + VERIFY( test ); +} + +int main() +{ + test01(); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/call_once/call_once1.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/call_once/call_once1.cc new file mode 100644 index 000000000..57f2529e5 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/call_once/call_once1.cc @@ -0,0 +1,59 @@ +// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* *-*-solaris* *-*-cygwin *-*-darwin* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* powerpc-ibm-aix* } } +// { 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-2014 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 <mutex> +#include <system_error> +#include <testsuite_hooks.h> + +std::once_flag value_flag; +int value = 1; + +void add_to_value(int i) +{ + value += i; +} + +int main() +{ + bool test __attribute__((unused)) = true; + + try + { + std::call_once(value_flag, add_to_value, 2); + std::call_once(value_flag, add_to_value, 2); + } + catch (const std::system_error& e) + { + VERIFY( false ); + } + catch (...) + { + VERIFY( false ); + } + + VERIFY( value == 3 ); + + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/call_once/constexpr.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/call_once/constexpr.cc new file mode 100644 index 000000000..8250fc872 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/call_once/constexpr.cc @@ -0,0 +1,31 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } +// { dg-require-cstdint "" } +// { dg-require-gthreads "" } + +// Copyright (C) 2010-2014 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 <mutex> +#include <testsuite_common_types.h> + +int main() +{ + __gnu_test::constexpr_default_constructible test; + test.operator()<std::mutex>(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/call_once/once_flag.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/call_once/once_flag.cc new file mode 100644 index 000000000..6a36a9a7f --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/call_once/once_flag.cc @@ -0,0 +1,29 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } +// { dg-require-cstdint "" } +// { dg-require-gthreads "" } + +// Copyright (C) 2008-2014 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 <mutex> + +void test01() +{ + std::once_flag once_flag; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/condition_variable/54185.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/condition_variable/54185.cc new file mode 100644 index 000000000..3e30d4183 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/condition_variable/54185.cc @@ -0,0 +1,62 @@ +// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* *-*-solaris* *-*-cygwin *-*-darwin* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } } +// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } } +// { dg-require-cstdint "" } +// { dg-require-gthreads "" } + +// Copyright (C) 2012-2014 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 <vector> +#include <mutex> +#include <condition_variable> +#include <thread> + +// PR libstdc++/54185 + +std::condition_variable* cond = nullptr; +std::mutex mx; +int started = 0; +int constexpr NUM_THREADS = 10; + +void do_thread_a() +{ + std::unique_lock<std::mutex> lock(mx); + if(++started >= NUM_THREADS) + { + cond->notify_all(); + delete cond; + cond = nullptr; + } + else + cond->wait(lock); +} + +int main(){ + std::vector<std::thread> vec; + for(int j = 0; j < 1000; ++j) + { + started = 0; + cond = new std::condition_variable; + for (int i = 0; i < NUM_THREADS; ++i) + vec.emplace_back(&do_thread_a); + for (int i = 0; i < NUM_THREADS; ++i) + vec[i].join(); + vec.clear(); + } +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/condition_variable/cons/1.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/condition_variable/cons/1.cc new file mode 100644 index 000000000..197c5f93a --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/condition_variable/cons/1.cc @@ -0,0 +1,48 @@ +// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* *-*-solaris* *-*-cygwin *-*-darwin* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* powerpc-ibm-aix* } } +// { 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-2014 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 <condition_variable> +#include <system_error> +#include <testsuite_hooks.h> + +int main() +{ + bool test __attribute__((unused)) = true; + + try + { + std::condition_variable c1; + } + catch (const std::system_error& e) + { + VERIFY( false ); + } + catch (...) + { + VERIFY( false ); + } + + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/condition_variable/cons/assign_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/condition_variable/cons/assign_neg.cc new file mode 100644 index 000000000..f8499f43b --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/condition_variable/cons/assign_neg.cc @@ -0,0 +1,34 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } +// { dg-require-cstdint "" } +// { dg-require-gthreads "" } + +// Copyright (C) 2008-2014 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 <condition_variable> + +void test01() +{ + // assign + std::condition_variable c1; + std::condition_variable c2; + c1 = c2; // { dg-error "deleted" } +} + +// { dg-prune-output "include" } diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/condition_variable/cons/copy_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/condition_variable/cons/copy_neg.cc new file mode 100644 index 000000000..f59245c67 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/condition_variable/cons/copy_neg.cc @@ -0,0 +1,33 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } +// { dg-require-cstdint "" } +// { dg-require-gthreads "" } + +// Copyright (C) 2008-2014 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 <condition_variable> + +void test01() +{ + // copy + std::condition_variable c1; + std::condition_variable c2(c1); // { dg-error "deleted" } +} + +// { dg-prune-output "include" } diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/condition_variable/members/1.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/condition_variable/members/1.cc new file mode 100644 index 000000000..dcd6f3d2c --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/condition_variable/members/1.cc @@ -0,0 +1,61 @@ +// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* *-*-solaris* *-*-cygwin *-*-darwin* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* powerpc-ibm-aix* } } +// { 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-2014 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 <chrono> +#include <condition_variable> +#include <system_error> +#include <testsuite_hooks.h> + +void test01() +{ + bool test __attribute__((unused)) = true; + + try + { + std::chrono::microseconds ms(500); + std::condition_variable c1; + std::mutex m; + std::unique_lock<std::mutex> l(m); + + auto then = std::chrono::system_clock::now(); + std::cv_status result = c1.wait_for(l, ms); + VERIFY( result == std::cv_status::timeout ); + VERIFY( (std::chrono::system_clock::now() - then) >= ms ); + VERIFY( l.owns_lock() ); + } + catch (const std::system_error& e) + { + VERIFY( false ); + } + catch (...) + { + VERIFY( false ); + } +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/condition_variable/members/2.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/condition_variable/members/2.cc new file mode 100644 index 000000000..1fc906a6c --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/condition_variable/members/2.cc @@ -0,0 +1,61 @@ +// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* *-*-solaris* *-*-cygwin *-*-darwin* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* powerpc-ibm-aix* } } +// { 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-2014 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 <chrono> +#include <condition_variable> +#include <system_error> +#include <testsuite_hooks.h> + +void test01() +{ + bool test __attribute__((unused)) = true; + + try + { + std::chrono::microseconds ms(500); + std::condition_variable c1; + std::mutex m; + std::unique_lock<std::mutex> l(m); + + auto then = std::chrono::steady_clock::now(); + std::cv_status result = c1.wait_until(l, then + ms); + VERIFY( result == std::cv_status::timeout ); + VERIFY( (std::chrono::steady_clock::now() - then) >= ms ); + VERIFY( l.owns_lock() ); + } + catch (const std::system_error& e) + { + VERIFY( false ); + } + catch (...) + { + VERIFY( false ); + } +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/condition_variable/members/53841.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/condition_variable/members/53841.cc new file mode 100644 index 000000000..ee998c17c --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/condition_variable/members/53841.cc @@ -0,0 +1,50 @@ +// { dg-do compile } +// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* powerpc-ibm-aix* hppa*-hp-hpux11* } } +// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } } +// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } } +// { dg-require-cstdint "" } +// { dg-require-gthreads "" } + +// Copyright (C) 2012-2014 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/>. + +// PR libstdc++/53841 + +#include <chrono> +#include <mutex> +#include <condition_variable> + +namespace ch = std::chrono; + +struct FPClock : ch::system_clock +{ + typedef double rep; + typedef std::ratio<1> period; + typedef ch::duration<rep, period> duration; + typedef ch::time_point<FPClock> time_point; + + static time_point now() + { return time_point(duration(system_clock::now().time_since_epoch())); } +}; + +void f() +{ + std::mutex mx; + std::unique_lock<std::mutex> l(mx); + std::condition_variable cv; + cv.wait_until(l, FPClock::now()); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/condition_variable/native_handle/typesizes.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/condition_variable/native_handle/typesizes.cc new file mode 100644 index 000000000..540a54046 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/condition_variable/native_handle/typesizes.cc @@ -0,0 +1,33 @@ +// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* *-*-solaris* *-*-cygwin *-*-darwin* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* powerpc-ibm-aix* } } +// { 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-2014 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 <condition_variable> +#include <thread/all.h> + +int main() +{ + typedef std::condition_variable test_type; + __gnu_test::compare_type_to_native_type<test_type>(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/condition_variable/requirements/standard_layout.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/condition_variable/requirements/standard_layout.cc new file mode 100644 index 000000000..8574889b8 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/condition_variable/requirements/standard_layout.cc @@ -0,0 +1,31 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } +// { dg-require-cstdint "" } +// { dg-require-gthreads "" } + +// Copyright (C) 2009-2014 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 <condition_variable> +#include <testsuite_common_types.h> + +void test01() +{ + __gnu_test::standard_layout test; + test.operator()<std::condition_variable>(); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/condition_variable/requirements/typedefs.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/condition_variable/requirements/typedefs.cc new file mode 100644 index 000000000..0fba56213 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/condition_variable/requirements/typedefs.cc @@ -0,0 +1,32 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } +// { dg-require-cstdint "" } +// { dg-require-gthreads "" } +// 2009-01-28 Benjamin Kosnik <bkoz@redhat.com> + +// Copyright (C) 2009-2014 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 <condition_variable> + +void test01() +{ + // Check for required typedefs + typedef std::condition_variable test_type; + typedef test_type::native_handle_type type; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/condition_variable_any/50862.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/condition_variable_any/50862.cc new file mode 100644 index 000000000..ffb45b56f --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/condition_variable_any/50862.cc @@ -0,0 +1,80 @@ +// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* *-*-solaris* *-*-cygwin *-*-darwin* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } } +// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } } +// { dg-require-cstdint "" } +// { dg-require-gthreads "" } +// { dg-require-sched-yield "" } + +// Copyright (C) 2011-2014 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 <condition_variable> +#include <thread> +#include <mutex> +#include <array> +#include <sstream> + +struct scoped_thread +{ + ~scoped_thread() { if (t.joinable()) t.join(); } + std::thread t; +}; + +int main() +{ + typedef std::unique_lock<std::mutex> Lock; + + std::mutex m; + std::condition_variable_any cond; + unsigned int product = 0; + const unsigned int count = 10; + + // writing to stream causes timing changes which makes deadlock easier + // to reproduce - do not remove + std::ostringstream out; + + // create consumers + std::array<scoped_thread, 2> threads; + for (std::size_t i = 0; i < threads.size(); ++i) + threads[i].t + = std::thread( [&] + { + for (unsigned int i = 0; i < count; ++i) + { + std::this_thread::yield(); + Lock lock(m); + while(product == 0) + cond.wait(lock); + out << "got product " + << std::this_thread::get_id() + << ' ' << product << std::endl; + --product; + } + } ); + + // single producer + for (std::size_t i = 0; i < threads.size() * count; ++i) + { + std::this_thread::yield(); + Lock lock(m); + ++product; + out << "setting product " << std::this_thread::get_id() + << ' ' << product << std::endl; + cond.notify_one(); + } +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/condition_variable_any/53830.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/condition_variable_any/53830.cc new file mode 100644 index 000000000..1350048d7 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/condition_variable_any/53830.cc @@ -0,0 +1,68 @@ +// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* *-*-solaris* *-*-cygwin *-*-darwin* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } } +// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } } +// { dg-require-cstdint "" } +// { dg-require-gthreads "" } +// { dg-require-sched-yield "" } +// { dg-require-sleep "" } + +// Copyright (C) 2012-2014 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/>. + +// PR libstdc++/53830 +// Test for deadlock in condition_variable_any::wait_for + +#include <thread> +#include <mutex> +#include <condition_variable> +#include <chrono> +#include <atomic> + +std::mutex mutex; +std::condition_variable_any cv; + +std::atomic<int> barrier(0); + +// waits for data from another thread +void wait_for_data() +{ + std::unique_lock<std::mutex> lock(mutex); + barrier = 1; + cv.wait_for(lock, std::chrono::milliseconds(100), []{ return false; }); + // read data +} + +// passes data to waiting thread +void provide_data() +{ + while (barrier == 0) + std::this_thread::yield(); + std::unique_lock<std::mutex> lock(mutex); + // pass data + std::this_thread::sleep_for(std::chrono::seconds(1)); + cv.notify_one(); +} + +int main() +{ + std::thread thread1(wait_for_data); + provide_data(); + thread1.join(); + return 0; +} + diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/condition_variable_any/cons/1.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/condition_variable_any/cons/1.cc new file mode 100644 index 000000000..893046946 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/condition_variable_any/cons/1.cc @@ -0,0 +1,48 @@ +// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* *-*-solaris* *-*-cygwin *-*-darwin* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* powerpc-ibm-aix* } } +// { 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-2014 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 <condition_variable> +#include <system_error> +#include <testsuite_hooks.h> + +int main() +{ + bool test __attribute__((unused)) = true; + + try + { + std::condition_variable_any c1; + } + catch (const std::system_error& e) + { + VERIFY( false ); + } + catch (...) + { + VERIFY( false ); + } + + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/condition_variable_any/cons/assign_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/condition_variable_any/cons/assign_neg.cc new file mode 100644 index 000000000..3bf0621e7 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/condition_variable_any/cons/assign_neg.cc @@ -0,0 +1,34 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } +// { dg-require-cstdint "" } +// { dg-require-gthreads "" } + +// Copyright (C) 2008-2014 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 <condition_variable> + +void test01() +{ + // assign + std::condition_variable_any c1; + std::condition_variable_any c2; + c1 = c2; // { dg-error "deleted" } +} + +// { dg-prune-output "include" } diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/condition_variable_any/cons/copy_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/condition_variable_any/cons/copy_neg.cc new file mode 100644 index 000000000..2632ab45b --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/condition_variable_any/cons/copy_neg.cc @@ -0,0 +1,33 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } +// { dg-require-cstdint "" } +// { dg-require-gthreads "" } + +// Copyright (C) 2008-2014 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 <condition_variable> + +void test01() +{ + // copy + std::condition_variable_any c1; + std::condition_variable_any c2(c1); // { dg-error "deleted" } +} + +// { dg-prune-output "include" } diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/condition_variable_any/members/1.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/condition_variable_any/members/1.cc new file mode 100644 index 000000000..fa5b58a86 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/condition_variable_any/members/1.cc @@ -0,0 +1,85 @@ +// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* *-*-solaris* *-*-cygwin *-*-darwin* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } } +// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } } +// { dg-require-cstdint "" } +// { dg-require-gthreads "" } + +// Copyright (C) 2010-2014 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 <chrono> +#include <condition_variable> +#include <system_error> +#include <testsuite_hooks.h> + +struct Mutex +{ + Mutex() : locked(false) { } + + void lock() + { + if (locked) + throw locked; + mtx.lock(); + locked = true; + } + + void unlock() + { + if (!locked) + throw locked; + mtx.unlock(); + locked = false; + } + + std::mutex mtx; + bool locked; +}; + +void test01() +{ + bool test __attribute__((unused)) = true; + + try + { + std::chrono::microseconds ms(500); + std::condition_variable_any c1; + Mutex m; + m.lock(); + + auto then = std::chrono::system_clock::now(); + std::cv_status result = c1.wait_for(m, ms); + VERIFY( result == std::cv_status::timeout ); + VERIFY( (std::chrono::system_clock::now() - then) >= ms ); + VERIFY( m.locked ); + } + catch (const std::system_error& e) + { + VERIFY( false ); + } + catch (...) + { + VERIFY( false ); + } +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/condition_variable_any/members/2.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/condition_variable_any/members/2.cc new file mode 100644 index 000000000..0d2a3f910 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/condition_variable_any/members/2.cc @@ -0,0 +1,86 @@ +// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* *-*-solaris* *-*-cygwin *-*-darwin* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } } +// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } } +// { dg-require-cstdint "" } +// { dg-require-gthreads "" } + +// Copyright (C) 2010-2014 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 <chrono> +#include <condition_variable> +#include <system_error> +#include <testsuite_hooks.h> + +struct Mutex +{ + Mutex() : locked(false) { } + + void lock() + { + if (locked) + throw locked; + mtx.lock(); + locked = true; + } + + void unlock() + { + if (!locked) + throw locked; + mtx.unlock(); + locked = false; + } + + std::mutex mtx; + bool locked; +}; + + +void test01() +{ + bool test __attribute__((unused)) = true; + + try + { + std::chrono::microseconds ms(500); + std::condition_variable_any c1; + Mutex m; + m.lock(); + + auto then = std::chrono::steady_clock::now(); + std::cv_status result = c1.wait_until(m, then + ms); + VERIFY( result == std::cv_status::timeout ); + VERIFY( (std::chrono::steady_clock::now() - then) >= ms ); + VERIFY( m.locked ); + } + catch (const std::system_error& e) + { + VERIFY( false ); + } + catch (...) + { + VERIFY( false ); + } +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/future/cons/assign_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/future/cons/assign_neg.cc new file mode 100644 index 000000000..e24cad1a7 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/future/cons/assign_neg.cc @@ -0,0 +1,37 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } +// { dg-require-cstdint "" } +// { dg-require-gthreads "" } +// { dg-require-atomic-builtins "" } + +// Copyright (C) 2009-2014 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 <future> + +extern std::future<int>& get(); + +void test01() +{ + // assign + std::future<int>& p1 = get(); + std::future<int>& p2 = get(); + p1 = p2; // { dg-error "deleted" } +} + +// { dg-prune-output "include" } diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/future/cons/constexpr.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/future/cons/constexpr.cc new file mode 100644 index 000000000..be31f91bb --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/future/cons/constexpr.cc @@ -0,0 +1,35 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x -fno-inline -save-temps -g0" } +// { dg-require-cstdint "" } +// { dg-require-gthreads "" } +// { dg-require-atomic-builtins "" } +// { dg-final { scan-assembler-not "_ZNSt6futureIvEC2Ev" } } +// { dg-final { scan-assembler-not "_ZNSt6futureIiEC2Ev" } } + +// Copyright (C) 2010-2014 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 <future> +#include <testsuite_common_types.h> + +int main() +{ + __gnu_test::constexpr_default_constructible test; //not literal + test.operator()<std::future<int>>(); + test.operator()<std::future<void>>(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/future/cons/copy_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/future/cons/copy_neg.cc new file mode 100644 index 000000000..03edc22d0 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/future/cons/copy_neg.cc @@ -0,0 +1,36 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } +// { dg-require-cstdint "" } +// { dg-require-gthreads "" } +// { dg-require-atomic-builtins "" } + +// Copyright (C) 2009-2014 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 <future> + +extern std::future<int>& get(); + +void test01() +{ + // copy + std::future<int>& p1 = get(); + std::future<int> p2(p1); // { dg-error "deleted" } +} + +// { dg-prune-output "include" } diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/future/cons/default.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/future/cons/default.cc new file mode 100644 index 000000000..32183bc33 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/future/cons/default.cc @@ -0,0 +1,51 @@ +// { dg-options "-std=gnu++0x" } +// { dg-require-cstdint "" } +// { dg-require-gthreads "" } +// { dg-require-atomic-builtins "" } + +// Copyright (C) 2010-2014 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 <future> +#include <testsuite_hooks.h> +#include <testsuite_tr1.h> + +void test01() +{ + using std::future; + using namespace __gnu_test; + + bool __attribute__((unused)) test = true; + + future<int> p1; + VERIFY( !p1.valid() ); + future<int&> p2; + VERIFY( !p2.valid() ); + future<void> p3; + VERIFY( !p3.valid() ); + future<ClassType> p4; + VERIFY( !p4.valid() ); + future<AbstractClass&> p5; + VERIFY( !p5.valid() ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/future/cons/move.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/future/cons/move.cc new file mode 100644 index 000000000..d8d4f492a --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/future/cons/move.cc @@ -0,0 +1,41 @@ +// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* *-*-solaris* *-*-cygwin *-*-darwin* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } } +// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } } +// { dg-require-cstdint "" } +// { dg-require-gthreads "" } +// { dg-require-atomic-builtins "" } + +// Copyright (C) 2009-2014 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 <future> + +void test01() +{ + // move + std::promise<int> p1; + std::future<int> f1(p1.get_future()); + std::future<int> f2(std::move(f1)); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/future/cons/move_assign.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/future/cons/move_assign.cc new file mode 100644 index 000000000..644cc6c19 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/future/cons/move_assign.cc @@ -0,0 +1,43 @@ +// { dg-options "-std=gnu++0x" } +// { dg-require-cstdint "" } +// { dg-require-gthreads "" } +// { dg-require-atomic-builtins "" } + +// Copyright (C) 2010-2014 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 <future> +#include <testsuite_hooks.h> + +std::future<int> get() { return std::promise<int>().get_future(); } + +void test01() +{ + // assign + std::future<int> p1; + std::future<int> p2 = get(); + p1 = std::move(p2); + VERIFY( p1.valid() ); + VERIFY( !p2.valid() ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/future/members/45133.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/future/members/45133.cc new file mode 100644 index 000000000..a1685f78d --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/future/members/45133.cc @@ -0,0 +1,103 @@ +// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* *-*-solaris* *-*-cygwin *-*-darwin* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } } +// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } } +// { dg-require-cstdint "" } +// { dg-require-gthreads "" } +// { dg-require-atomic-builtins "" } + +// Copyright (C) 2010-2014 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/>. + +// 30.6.6 Class template future [futures.unique_future] + +#include <future> +#include <testsuite_hooks.h> + +// This test verifies behaviour which is encouraged by a non-normative note, +// but not required. + +void +test01() +{ + bool test __attribute__((unused)) = true; + + std::promise<int> p; + std::future<int> f = p.get_future(); + p.set_value(0); + f.get(); + try + { + f.get(); + VERIFY( false ); + } + catch (std::future_error& e) + { + VERIFY( e.code() == std::future_errc::no_state ); + } +} + +void +test02() +{ + bool test __attribute__((unused)) = true; + + std::promise<int&> p; + std::future<int&> f = p.get_future(); + int i = 0; + p.set_value(i); + f.get(); + try + { + f.get(); + VERIFY( false ); + } + catch (std::future_error& e) + { + VERIFY( e.code() == std::future_errc::no_state ); + } +} + +void +test03() +{ + bool test __attribute__((unused)) = true; + + std::promise<void> p; + std::future<void> f = p.get_future(); + p.set_value(); + f.get(); + try + { + f.get(); + VERIFY( false ); + } + catch (std::future_error& e) + { + VERIFY( e.code() == std::future_errc::no_state ); + } +} + +int main() +{ + test01(); + test02(); + test03(); + + return 0; +} + diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/future/members/get.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/future/members/get.cc new file mode 100644 index 000000000..367b00912 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/future/members/get.cc @@ -0,0 +1,73 @@ +// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* *-*-solaris* *-*-cygwin *-*-darwin* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } } +// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } } +// { dg-require-cstdint "" } +// { dg-require-gthreads "" } +// { dg-require-atomic-builtins "" } + +// Copyright (C) 2009-2014 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 <future> +#include <testsuite_hooks.h> + +int value = 99; + +void test01() +{ + bool test __attribute__((unused)) = true; + + std::promise<int> p1; + std::future<int> f1(p1.get_future()); + + p1.set_value(value); + VERIFY( f1.get() == value ); + VERIFY( !f1.valid() ); +} + +void test02() +{ + bool test __attribute__((unused)) = true; + + std::promise<int&> p1; + std::future<int&> f1(p1.get_future()); + + p1.set_value(value); + VERIFY( &f1.get() == &value ); + VERIFY( !f1.valid() ); +} + +void test03() +{ + std::promise<void> p1; + std::future<void> f1(p1.get_future()); + + p1.set_value(); + f1.get(); + VERIFY( !f1.valid() ); +} + +int main() +{ + test01(); + test02(); + test03(); + + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/future/members/get2.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/future/members/get2.cc new file mode 100644 index 000000000..6e54df075 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/future/members/get2.cc @@ -0,0 +1,100 @@ +// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* *-*-solaris* *-*-cygwin *-*-darwin* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } } +// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } } +// { dg-require-cstdint "" } +// { dg-require-gthreads "" } +// { dg-require-atomic-builtins "" } + +// Copyright (C) 2009-2014 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 <future> +#include <exception> +#include <testsuite_hooks.h> + +int value = 99; + +void test01() +{ + bool test __attribute__((unused)) = true; + + std::promise<int> p1; + std::future<int> f1(p1.get_future()); + + p1.set_exception(std::make_exception_ptr(value)); + try + { + (void) f1.get(); + VERIFY( false ); + } + catch (int& e) + { + VERIFY( e == value ); + } + VERIFY( !f1.valid() ); +} + +void test02() +{ + bool test __attribute__((unused)) = true; + + std::promise<int&> p1; + std::future<int&> f1(p1.get_future()); + + p1.set_exception(std::make_exception_ptr(value)); + try + { + (void) f1.get(); + VERIFY( false ); + } + catch (int& e) + { + VERIFY( e == value ); + } + VERIFY( !f1.valid() ); +} + +void test03() +{ + bool test __attribute__((unused)) = true; + + std::promise<void> p1; + std::future<void> f1(p1.get_future()); + + p1.set_exception(std::make_exception_ptr(value)); + try + { + f1.get(); + VERIFY( false ); + } + catch (int& e) + { + VERIFY( e == value ); + } + VERIFY( !f1.valid() ); +} + +int main() +{ + test01(); + test02(); + test03(); + + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/future/members/share.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/future/members/share.cc new file mode 100644 index 000000000..074404a49 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/future/members/share.cc @@ -0,0 +1,73 @@ +// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* *-*-solaris* *-*-cygwin *-*-darwin* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } } +// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } } +// { dg-require-cstdint "" } +// { dg-require-gthreads "" } +// { dg-require-atomic-builtins "" } + +// Copyright (C) 2011-2014 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 <future> +#include <testsuite_hooks.h> + +int value = 99; + +void test01() +{ + bool test __attribute__((unused)) = true; + + std::promise<int> p1; + std::future<int> f1(p1.get_future()); + std::shared_future<int> f2 = f1.share(); + + p1.set_value(value); + VERIFY( f2.get() == value ); +} + +void test02() +{ + bool test __attribute__((unused)) = true; + + std::promise<int&> p1; + std::future<int&> f1(p1.get_future()); + std::shared_future<int&> f2 = f1.share(); + + p1.set_value(value); + VERIFY( &f2.get() == &value ); +} + +void test03() +{ + std::promise<void> p1; + std::future<void> f1(p1.get_future()); + std::shared_future<void> f2 = f1.share(); + + p1.set_value(); + f2.get(); +} + +int main() +{ + test01(); + test02(); + test03(); + + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/future/members/valid.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/future/members/valid.cc new file mode 100644 index 000000000..de1446ad1 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/future/members/valid.cc @@ -0,0 +1,56 @@ +// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* *-*-solaris* *-*-cygwin *-*-darwin* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } } +// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } } +// { dg-require-cstdint "" } +// { dg-require-gthreads "" } +// { dg-require-atomic-builtins "" } + +// Copyright (C) 2010-2014 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 <future> +#include <testsuite_hooks.h> + +void test01() +{ + bool test __attribute__((unused)) = true; + + std::future<int> f0; + VERIFY( !f0.valid() ); + + std::promise<int> p1; + std::future<int> f1(p1.get_future()); + + VERIFY( f1.valid() ); + + p1.set_value(1); + + VERIFY( f1.valid() ); + + f1 = std::move(f0); + + VERIFY( !f1.valid() ); + VERIFY( !f0.valid() ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/future/members/wait.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/future/members/wait.cc new file mode 100644 index 000000000..f2fb97803 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/future/members/wait.cc @@ -0,0 +1,54 @@ +// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* *-*-solaris* *-*-cygwin *-*-darwin* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } } +// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } } +// { dg-require-cstdint "" } +// { dg-require-gthreads "" } +// { dg-require-atomic-builtins "" } + +// Copyright (C) 2009-2014 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 <future> +#include <chrono> +#include <thread> +#include <mutex> +#include <testsuite_hooks.h> + + +void fut_wait(std::future<void>& f) +{ + f.wait(); +} + +void test01() +{ + std::promise<void> p1; + std::future<void> f1(p1.get_future()); + + std::thread t1(fut_wait, std::ref(f1)); + + p1.set_value(); + t1.join(); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/future/members/wait_for.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/future/members/wait_for.cc new file mode 100644 index 000000000..05623c715 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/future/members/wait_for.cc @@ -0,0 +1,53 @@ +// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* *-*-solaris* *-*-cygwin *-*-darwin* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } } +// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } } +// { dg-require-cstdint "" } +// { dg-require-gthreads "" } +// { dg-require-atomic-builtins "" } + +// Copyright (C) 2009-2014 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 <future> +#include <chrono> +#include <testsuite_hooks.h> + +void test01() +{ + bool test __attribute__((unused)) = true; + + std::promise<int> p1; + std::future<int> f1(p1.get_future()); + + std::chrono::milliseconds delay(100); + + VERIFY( f1.wait_for(delay) == std::future_status::timeout ); + + p1.set_value(1); + + auto before = std::chrono::system_clock::now(); + VERIFY( f1.wait_for(delay) == std::future_status::ready ); + VERIFY( std::chrono::system_clock::now() < (before + delay) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/future/members/wait_until.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/future/members/wait_until.cc new file mode 100644 index 000000000..88ff4c48f --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/future/members/wait_until.cc @@ -0,0 +1,58 @@ +// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* *-*-solaris* *-*-cygwin *-*-darwin* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } } +// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } } +// { dg-require-cstdint "" } +// { dg-require-gthreads "" } +// { dg-require-atomic-builtins "" } + +// Copyright (C) 2009-2014 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 <future> +#include <chrono> +#include <testsuite_hooks.h> + +std::chrono::system_clock::time_point make_time(int i) +{ + return std::chrono::system_clock::now() + std::chrono::milliseconds(i); +} + +void test01() +{ + bool test __attribute__((unused)) = true; + + std::promise<int> p1; + std::future<int> f1(p1.get_future()); + + auto when = make_time(10); + VERIFY( f1.wait_until(when) == std::future_status::timeout ); + VERIFY( std::chrono::system_clock::now() >= when ); + + p1.set_value(1); + + when = make_time(100); + VERIFY( f1.wait_until(when) == std::future_status::ready ); + VERIFY( std::chrono::system_clock::now() < when ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/future/requirements/explicit_instantiation.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/future/requirements/explicit_instantiation.cc new file mode 100644 index 000000000..d730a64b1 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/future/requirements/explicit_instantiation.cc @@ -0,0 +1,34 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } +// { dg-require-cstdint "" } +// { dg-require-gthreads "" } +// { dg-require-atomic-builtins "" } + +// Copyright (C) 2009-2014 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 <future> +#include <testsuite_tr1.h> + +using namespace __gnu_test; +using std::future; +template class future<int>; +template class future<int&>; +template class future<void>; +template class future<ClassType>; +template class future<ClassType&>; diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/headers/condition_variable/std_c++0x_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/headers/condition_variable/std_c++0x_neg.cc new file mode 100644 index 000000000..5abce5f9d --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/headers/condition_variable/std_c++0x_neg.cc @@ -0,0 +1,26 @@ +// { dg-do compile } +// { dg-options "-std=gnu++98" } + +// Copyright (C) 2008-2014 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 <condition_variable> + +// { dg-error "ISO C.. 2011" "" { target *-*-* } 32 } + + + diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/headers/condition_variable/types_std_c++0x.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/headers/condition_variable/types_std_c++0x.cc new file mode 100644 index 000000000..5264c6360 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/headers/condition_variable/types_std_c++0x.cc @@ -0,0 +1,29 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } +// { dg-require-cstdint "" } +// { dg-require-gthreads "" } + +// Copyright (C) 2008-2014 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 <condition_variable> + +void test01() +{ + typedef std::condition_variable c_t; + typedef std::condition_variable_any ca_t; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/headers/future/std_c++0x_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/headers/future/std_c++0x_neg.cc new file mode 100644 index 000000000..cbe4554ee --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/headers/future/std_c++0x_neg.cc @@ -0,0 +1,26 @@ +// { dg-do compile } +// { dg-options "-std=gnu++98" } + +// Copyright (C) 2009-2014 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 <future> + +// { dg-error "ISO C.. 2011" "" { target *-*-* } 32 } + + + diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/headers/future/types_std_c++0x.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/headers/future/types_std_c++0x.cc new file mode 100644 index 000000000..4732c44b1 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/headers/future/types_std_c++0x.cc @@ -0,0 +1,51 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } +// { dg-require-cstdint "" } +// { dg-require-gthreads "" } +// { dg-require-atomic-builtins "" } + +// Copyright (C) 2009-2014 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 <future> + +void test01() +{ + typedef std::future_errc errc_t; + + using std::future_category; + + typedef std::future_error error_t; + + typedef std::future<int> uniq_t; + typedef std::future<int&> uniqr_t; + typedef std::future<void> uniqv_t; + + typedef std::shared_future<int> shar_t; + typedef std::shared_future<int&> sharr_t; + typedef std::shared_future<void> sharv_t; + + typedef std::promise<int> promise_t; + typedef std::promise<int&> promiser_t; + typedef std::promise<void> promisev_t; + + typedef std::packaged_task<int> ptask_t; + typedef std::packaged_task<int&> ptaskr_t; + typedef std::packaged_task<void> ptaskv_t; + + using std::async; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/headers/mutex/std_c++0x_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/headers/mutex/std_c++0x_neg.cc new file mode 100644 index 000000000..8e5847e68 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/headers/mutex/std_c++0x_neg.cc @@ -0,0 +1,26 @@ +// { dg-do compile } +// { dg-options "-std=gnu++98" } + +// Copyright (C) 2008-2014 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 <mutex> + +// { dg-error "ISO C.. 2011" "" { target *-*-* } 32 } + + + diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/headers/mutex/types_std_c++0x.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/headers/mutex/types_std_c++0x.cc new file mode 100644 index 000000000..ac3e7d906 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/headers/mutex/types_std_c++0x.cc @@ -0,0 +1,42 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } +// { dg-require-cstdint "" } +// { dg-require-gthreads "" } + +// Copyright (C) 2008-2014 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 <mutex> + +void test01() +{ + typedef std::mutex mutext_t; + typedef std::recursive_mutex rmutext_t; + + typedef std::defer_lock_t dl_t; + typedef std::try_to_lock_t ttl_t; + typedef std::adopt_lock_t al_t; + + using std::defer_lock; + using std::try_to_lock; + using std::adopt_lock; + + typedef std::lock_guard<mutext_t> lock_t; + typedef std::unique_lock<rmutext_t> ulock_t; + + typedef std::once_flag once_t; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/headers/thread/std_c++0x_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/headers/thread/std_c++0x_neg.cc new file mode 100644 index 000000000..7675f7a27 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/headers/thread/std_c++0x_neg.cc @@ -0,0 +1,25 @@ +// { dg-do compile } +// { dg-options "-std=gnu++98" } +// { dg-require-cstdint "" } +// { dg-require-gthreads "" } + +// Copyright (C) 2008-2014 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> + +// { dg-error "ISO C.. 2011" "" { target *-*-* } 32 } diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/headers/thread/types_std_c++0x.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/headers/thread/types_std_c++0x.cc new file mode 100644 index 000000000..d81dcdf3f --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/headers/thread/types_std_c++0x.cc @@ -0,0 +1,30 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } +// { dg-require-cstdint "" } +// { dg-require-gthreads "" } + +// Copyright (C) 2008-2014 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() +{ + typedef std::thread t_t; + + using namespace std::this_thread; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/lock/1.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/lock/1.cc new file mode 100644 index 000000000..4cb6f1548 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/lock/1.cc @@ -0,0 +1,65 @@ +// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* *-*-solaris* *-*-cygwin *-*-darwin* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } } +// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } } +// { dg-require-cstdint "" } +// { dg-require-gthreads "" } + +// Copyright (C) 2010-2014 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 <mutex> +#include <system_error> +#include <testsuite_hooks.h> + +int main() +{ + bool test __attribute__((unused)) = true; + typedef std::mutex mutex_type; + typedef std::unique_lock<mutex_type> lock_type; + + try + { + mutex_type m1, m2, m3; + lock_type l1(m1, std::defer_lock), + l2(m2, std::defer_lock), + l3(m3, std::defer_lock); + + try + { + std::lock(l1, l2, l3); + VERIFY( l1.owns_lock() ); + VERIFY( l2.owns_lock() ); + VERIFY( l3.owns_lock() ); + } + catch (const std::system_error& e) + { + VERIFY( false ); + } + } + catch (const std::system_error& e) + { + VERIFY( false ); + } + catch (...) + { + VERIFY( false ); + } + + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/lock/2.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/lock/2.cc new file mode 100644 index 000000000..acde43420 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/lock/2.cc @@ -0,0 +1,58 @@ +// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* *-*-solaris* *-*-cygwin *-*-darwin* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } } +// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } } +// { dg-require-cstdint "" } +// { dg-require-gthreads "" } + +// Copyright (C) 2010-2014 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 <mutex> +#include <thread> +#include <testsuite_hooks.h> + +void locker(std::mutex& m1, std::mutex& m2, std::mutex& m3) +{ + bool test __attribute__((unused)) = true; + + typedef std::unique_lock<std::mutex> lock_type; + + lock_type l1(m1, std::defer_lock); + lock_type l2(m2, std::defer_lock); + lock_type l3(m3, std::defer_lock); + std::lock(l1, l2, l3); + VERIFY( l1.owns_lock() ); + VERIFY( l2.owns_lock() ); + VERIFY( l3.owns_lock() ); +} + +void test01() +{ + std::mutex m1, m2, m3; + std::thread t1(locker, std::ref(m1), std::ref(m2), std::ref(m3)); + std::thread t2(locker, std::ref(m3), std::ref(m2), std::ref(m1)); + t1.join(); + t2.join(); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/lock/3.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/lock/3.cc new file mode 100644 index 000000000..93b584668 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/lock/3.cc @@ -0,0 +1,90 @@ +// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* *-*-solaris* *-*-cygwin *-*-darwin* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } } +// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } } +// { dg-require-cstdint "" } +// { dg-require-gthreads "" } + +// Copyright (C) 2010-2014 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 <mutex> +#include <system_error> +#include <testsuite_hooks.h> + +struct user_lock +{ + user_lock() : is_locked(false) { } + ~user_lock() = default; + user_lock(const user_lock&) = default; + + void lock() + { + bool test __attribute__((unused)) = true; + VERIFY( !is_locked ); + is_locked = true; + } + + bool try_lock() + { return is_locked ? false : (is_locked = true); } + + void unlock() + { + bool test __attribute__((unused)) = true; + VERIFY( is_locked ); + is_locked = false; + } + +private: + bool is_locked; +}; + +int main() +{ + bool test __attribute__((unused)) = true; + + try + { + std::mutex m1; + std::recursive_mutex m2; + user_lock m3; + + try + { + //heterogeneous types + std::lock(m1, m2, m3); + m1.unlock(); + m2.unlock(); + m3.unlock(); + } + catch (const std::system_error& e) + { + VERIFY( false ); + } + } + catch (const std::system_error& e) + { + VERIFY( false ); + } + catch (...) + { + VERIFY( false ); + } + + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/lock/4.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/lock/4.cc new file mode 100644 index 000000000..d6fa4293d --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/lock/4.cc @@ -0,0 +1,152 @@ +// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* *-*-solaris* *-*-cygwin *-*-darwin* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } } +// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } } +// { dg-require-cstdint "" } +// { dg-require-gthreads "" } + +// Copyright (C) 2010-2014 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 <mutex> +#include <testsuite_hooks.h> + +struct unreliable_lock +{ + std::mutex m; + std::unique_lock<std::mutex> l; + + static int count; + static int throw_on; + static int lock_on; + + unreliable_lock() : l(m, std::defer_lock) { } + + ~unreliable_lock() + { + bool test __attribute__((unused)) = true; + VERIFY( !l.owns_lock() ); + } + + void lock() + { + if (count == throw_on) + throw throw_on; + ++count; + l.lock(); + } + bool try_lock() + { + if (count == throw_on) + throw throw_on; + std::unique_lock<std::mutex> l2(m, std::defer_lock); + if (count == lock_on) + l2.lock(); + ++count; + return l.try_lock(); + } + + void unlock() + { + bool test __attribute__((unused)) = true; + VERIFY( l.owns_lock() ); + l.unlock(); + } + +}; + +int unreliable_lock::count = 0; +int unreliable_lock::throw_on = -1; +int unreliable_lock::lock_on = -1; + +void test01() +{ + bool test __attribute__((unused)) = true; + + unreliable_lock l1, l2, l3; + + try + { + unreliable_lock::count = 0; + std::lock(l1, l2, l3); + VERIFY( unreliable_lock::count == 3 ); + l1.unlock(); + l2.unlock(); + l3.unlock(); + } + catch (...) + { + VERIFY( false ); + } +} + +void test02() +{ + bool test __attribute__((unused)) = true; + + // test behaviour when a lock is already held + try + { + unreliable_lock::lock_on = 1; + while (unreliable_lock::lock_on < 3) + { + unreliable_lock::count = 0; + unreliable_lock l1, l2, l3; + std::lock(l1, l2, l3); + VERIFY( unreliable_lock::count > 3 ); + l1.unlock(); + l2.unlock(); + l3.unlock(); + ++unreliable_lock::lock_on; + } + } + catch (...) + { + VERIFY( false ); + } +} + +void test03() +{ + // test behaviour when an exception is thrown + unreliable_lock::throw_on = 0; + while (unreliable_lock::throw_on < 3) + { + unreliable_lock::count = 0; + unreliable_lock l1, l2, l3; + bool test = false; + try + { + std::lock(l1, l2, l3); + } + catch (...) + { + test = true; + } + VERIFY( test ); + ++unreliable_lock::throw_on; + } +} + +int main() +{ + test01(); + test02(); + test03(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/lock_guard/cons/1.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/lock_guard/cons/1.cc new file mode 100644 index 000000000..008dfe223 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/lock_guard/cons/1.cc @@ -0,0 +1,76 @@ +// { dg-do run } +// { dg-options " -std=gnu++11 " } +// { dg-require-cstdint "" } + +// Copyright (C) 2010-2014 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 <mutex> +#include <testsuite_hooks.h> + +struct Mutex +{ + Mutex() : locked(false) { } + + ~Mutex() + { + if (locked) + throw 0; + } + + void lock() + { + if (locked) + throw 0; + locked = true; + } + + void unlock() + { + if (!locked) + throw 0; + locked = false; + } + + bool locked; +}; + +void test01() +{ + bool test __attribute__((unused)) = true; + + Mutex m; + m.lock(); + + try + { + std::lock_guard<Mutex> l(m, std::adopt_lock); + } + catch (...) + { + VERIFY( false ); + } + + VERIFY( !m.locked ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/lock_guard/requirements/explicit_instantiation.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/lock_guard/requirements/explicit_instantiation.cc new file mode 100644 index 000000000..fedcc2952 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/lock_guard/requirements/explicit_instantiation.cc @@ -0,0 +1,33 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } +// { dg-require-cstdint "" } +// { dg-require-gthreads "" } + +// 2008-03-14 Benjamin Kosnik <bkoz@redhat.com> + +// Copyright (C) 2008-2014 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/>. + + +// NB: This file is for testing with NO OTHER INCLUDES. + +#include <mutex> + +namespace std +{ + template class lock_guard<mutex>; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/lock_guard/requirements/typedefs.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/lock_guard/requirements/typedefs.cc new file mode 100644 index 000000000..3e6b5170b --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/lock_guard/requirements/typedefs.cc @@ -0,0 +1,35 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } +// { dg-require-cstdint "" } +// { dg-require-gthreads "" } + +// 2008-03-14 Benjamin Kosnik <bkoz@redhat.com> + +// Copyright (C) 2008-2014 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/>. + + +// NB: This file is for testing with NO OTHER INCLUDES. + +#include <mutex> + +void test01() +{ + // Check for required typedefs + typedef std::lock_guard<std::mutex> test_type; + typedef test_type::mutex_type mutex_type; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/mutex/cons/1.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/mutex/cons/1.cc new file mode 100644 index 000000000..aab9ff765 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/mutex/cons/1.cc @@ -0,0 +1,49 @@ +// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* *-*-solaris* *-*-cygwin *-*-darwin* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* powerpc-ibm-aix* } } +// { 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-2014 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 <mutex> +#include <system_error> +#include <testsuite_hooks.h> + +int main() +{ + bool test __attribute__((unused)) = true; + typedef std::mutex mutex_type; + + try + { + mutex_type m1; + } + catch (const std::system_error& e) + { + VERIFY( false ); + } + catch (...) + { + VERIFY( false ); + } + + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/mutex/cons/assign_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/mutex/cons/assign_neg.cc new file mode 100644 index 000000000..d64107931 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/mutex/cons/assign_neg.cc @@ -0,0 +1,35 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } +// { dg-require-cstdint "" } +// { dg-require-gthreads "" } + +// Copyright (C) 2008-2014 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 <mutex> + +void test01() +{ + // assign + typedef std::mutex mutex_type; + mutex_type m1; + mutex_type m2; + m1 = m2; // { dg-error "deleted" } +} + +// { dg-prune-output "include" } diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/mutex/cons/constexpr.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/mutex/cons/constexpr.cc new file mode 100644 index 000000000..8250fc872 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/mutex/cons/constexpr.cc @@ -0,0 +1,31 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } +// { dg-require-cstdint "" } +// { dg-require-gthreads "" } + +// Copyright (C) 2010-2014 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 <mutex> +#include <testsuite_common_types.h> + +int main() +{ + __gnu_test::constexpr_default_constructible test; + test.operator()<std::mutex>(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/mutex/cons/copy_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/mutex/cons/copy_neg.cc new file mode 100644 index 000000000..d38e0ae91 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/mutex/cons/copy_neg.cc @@ -0,0 +1,34 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } +// { dg-require-cstdint "" } +// { dg-require-gthreads "" } + +// Copyright (C) 2008-2014 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 <mutex> + +void test01() +{ + // assign + typedef std::mutex mutex_type; + mutex_type m1; + mutex_type m2(m1); // { dg-error "deleted" } +} + +// { dg-prune-output "include" } diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/mutex/dest/destructor_locked.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/mutex/dest/destructor_locked.cc new file mode 100644 index 000000000..6a4f12fb2 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/mutex/dest/destructor_locked.cc @@ -0,0 +1,51 @@ +// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* *-*-solaris* *-*-cygwin *-*-darwin* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* powerpc-ibm-aix* } } +// { 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-2014 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 <mutex> +#include <system_error> +#include <testsuite_hooks.h> + +int main() +{ + bool test __attribute__((unused)) = true; + typedef std::mutex mutex_type; + + try + { + mutex_type m; + m.lock(); + } + catch (const std::system_error& e) + { + // Destroying locked mutex raises system error, or undefined. + // POSIX == may fail with EBUSY. + } + catch (...) + { + VERIFY( false ); + } + + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/mutex/lock/1.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/mutex/lock/1.cc new file mode 100644 index 000000000..4d407f82d --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/mutex/lock/1.cc @@ -0,0 +1,63 @@ +// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* *-*-solaris* *-*-cygwin *-*-darwin* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* powerpc-ibm-aix* } } +// { 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-2014 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 <mutex> +#include <system_error> +#include <testsuite_hooks.h> + +int main() +{ + bool test __attribute__((unused)) = true; + typedef std::mutex mutex_type; + + try + { + mutex_type m; + m.lock(); + + // Lock already locked mutex. + try + { + // XXX Will block. + // m.lock(); + } + catch (const std::system_error& e) + { + VERIFY( false ); + } + + m.unlock(); + } + catch (const std::system_error& e) + { + VERIFY( false ); + } + catch (...) + { + VERIFY( false ); + } + + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/mutex/native_handle/1.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/mutex/native_handle/1.cc new file mode 100644 index 000000000..9c4815542 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/mutex/native_handle/1.cc @@ -0,0 +1,51 @@ +// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* *-*-solaris* *-*-cygwin *-*-darwin* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* powerpc-ibm-aix* } } +// { 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-2014 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 <mutex> +#include <system_error> +#include <testsuite_hooks.h> + +int main() +{ + bool test __attribute__((unused)) = true; + typedef std::mutex mutex_type; + + try + { + mutex_type m; + mutex_type::native_handle_type n = m.native_handle(); + (void)n; + } + catch (const std::system_error& e) + { + VERIFY( false ); + } + catch (...) + { + VERIFY( false ); + } + + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/mutex/native_handle/typesizes.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/mutex/native_handle/typesizes.cc new file mode 100644 index 000000000..a60ea236e --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/mutex/native_handle/typesizes.cc @@ -0,0 +1,33 @@ +// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* *-*-solaris* *-*-cygwin *-*-darwin* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* powerpc-ibm-aix* } } +// { 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-2014 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 <mutex> +#include <thread/all.h> + +int main() +{ + typedef std::mutex test_type; + __gnu_test::compare_type_to_native_type<test_type>(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/mutex/requirements/standard_layout.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/mutex/requirements/standard_layout.cc new file mode 100644 index 000000000..04c970d96 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/mutex/requirements/standard_layout.cc @@ -0,0 +1,31 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } +// { dg-require-cstdint "" } +// { dg-require-gthreads "" } + +// Copyright (C) 2009-2014 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 <mutex> +#include <testsuite_common_types.h> + +void test01() +{ + __gnu_test::standard_layout test; + test.operator()<std::mutex>(); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/mutex/requirements/typedefs.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/mutex/requirements/typedefs.cc new file mode 100644 index 000000000..1ea455717 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/mutex/requirements/typedefs.cc @@ -0,0 +1,32 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } +// { dg-require-cstdint "" } +// { dg-require-gthreads "" } +// 2008-03-18 Benjamin Kosnik <bkoz@redhat.com> + +// Copyright (C) 2008-2014 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 <mutex> + +void test01() +{ + // Check for required typedefs + typedef std::mutex test_type; + typedef test_type::native_handle_type type; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/mutex/try_lock/1.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/mutex/try_lock/1.cc new file mode 100644 index 000000000..7e35c4603 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/mutex/try_lock/1.cc @@ -0,0 +1,52 @@ +// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* *-*-solaris* *-*-cygwin *-*-darwin* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* powerpc-ibm-aix* } } +// { 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-2014 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 <mutex> +#include <system_error> +#include <testsuite_hooks.h> + +int main() +{ + bool test __attribute__((unused)) = true; + typedef std::mutex mutex_type; + + try + { + mutex_type m; + bool b = m.try_lock(); + VERIFY( b ); + m.unlock(); + } + catch (const std::system_error& e) + { + VERIFY( false ); + } + catch (...) + { + VERIFY( false ); + } + + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/mutex/try_lock/2.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/mutex/try_lock/2.cc new file mode 100644 index 000000000..98cc94d75 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/mutex/try_lock/2.cc @@ -0,0 +1,67 @@ +// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* *-*-solaris* *-*-cygwin *-*-darwin* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* powerpc-ibm-aix* } } +// { 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-2014 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 <mutex> +#include <thread> +#include <system_error> +#include <testsuite_hooks.h> + +int main() +{ + bool test __attribute__((unused)) = true; + typedef std::mutex mutex_type; + + try + { + mutex_type m; + m.lock(); + bool b; + + std::thread t([&] { + try + { + b = m.try_lock(); + } + catch (const std::system_error& e) + { + VERIFY( false ); + } + }); + t.join(); + VERIFY( !b ); + + m.unlock(); + } + catch (const std::system_error& e) + { + VERIFY( false ); + } + catch (...) + { + VERIFY( false ); + } + + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/mutex/unlock/1.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/mutex/unlock/1.cc new file mode 100644 index 000000000..402d7ddd0 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/mutex/unlock/1.cc @@ -0,0 +1,52 @@ +// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* *-*-solaris* *-*-cygwin *-*-darwin* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* powerpc-ibm-aix* } } +// { 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-2014 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 <mutex> +#include <system_error> +#include <testsuite_hooks.h> + +int main() +{ + bool test __attribute__((unused)) = true; + typedef std::mutex mutex_type; + + try + { + // Unlock mutex that hasn't been locked. + mutex_type m; + m.unlock(); + } + catch (const std::system_error& e) + { + // POSIX == EPERM + VERIFY( true ); + } + catch (...) + { + VERIFY( false ); + } + + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/once_flag/cons/constexpr.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/once_flag/cons/constexpr.cc new file mode 100644 index 000000000..568f023d5 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/once_flag/cons/constexpr.cc @@ -0,0 +1,31 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } +// { dg-require-cstdint "" } +// { dg-require-gthreads "" } + +// Copyright (C) 2010-2014 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 <mutex> +#include <testsuite_common_types.h> + +int main() +{ + __gnu_test::constexpr_default_constructible test; + test.operator()<std::once_flag>(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/packaged_task/49668.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/packaged_task/49668.cc new file mode 100644 index 000000000..05fac3dce --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/packaged_task/49668.cc @@ -0,0 +1,51 @@ +// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* *-*-solaris* *-*-cygwin *-*-darwin* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } } +// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } } +// { dg-require-cstdint "" } +// { dg-require-gthreads "" } +// { dg-require-atomic-builtins "" } + +// Copyright (C) 2011-2014 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 <future> +#include <testsuite_hooks.h> + +struct moveable +{ + moveable() = default; + moveable(moveable&&) = default; +}; + +typedef decltype(std::placeholders::_1) placeholder_type; + +bool f(moveable, placeholder_type) { return true; } + +void test01() +{ + std::packaged_task<bool(moveable, placeholder_type)> p(f); + p(moveable(), std::placeholders::_1); + bool test = p.get_future().get(); + VERIFY( test ); +} + +int main() +{ + test01(); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/packaged_task/60564.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/packaged_task/60564.cc new file mode 100644 index 000000000..956d506d7 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/packaged_task/60564.cc @@ -0,0 +1,51 @@ +// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* *-*-solaris* *-*-cygwin *-*-darwin* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++11 -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++11 -pthreads" { target *-*-solaris* } } +// { dg-options " -std=gnu++11 " { target *-*-cygwin *-*-darwin* } } +// { dg-require-cstdint "" } +// { dg-require-gthreads "" } +// { dg-require-atomic-builtins "" } + +// Copyright (C) 2014 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 <future> +#include <testsuite_hooks.h> + +struct X +{ + X() = default; + X(const X&) = default; + X(X&& x) { x.moved = true; } + + void operator()() const { } + + bool moved = false; +}; + +void test01() +{ + X x; + std::packaged_task<void()> p(x); + VERIFY( !x.moved ); +} + +int main() +{ + test01(); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/packaged_task/cons/1.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/packaged_task/cons/1.cc new file mode 100644 index 000000000..3128b6356 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/packaged_task/cons/1.cc @@ -0,0 +1,53 @@ +// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* *-*-solaris* *-*-cygwin *-*-darwin* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } } +// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } } +// { dg-require-cstdint "" } +// { dg-require-gthreads "" } +// { dg-require-atomic-builtins "" } + +// Copyright (C) 2009-2014 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 <future> +#include <testsuite_hooks.h> +#include <testsuite_tr1.h> + +void test01() +{ + bool test __attribute__((unused)) = true; + using std::packaged_task; + using namespace __gnu_test; + + packaged_task<int ()> p1; + VERIFY( !p1.valid() ); + packaged_task<int& ()> p2; + VERIFY( !p2.valid() ); + packaged_task<void ()> p3; + VERIFY( !p3.valid() ); + packaged_task<ClassType ()> p4; + VERIFY( !p4.valid() ); + packaged_task<AbstractClass& (int)> p5; + VERIFY( !p5.valid() ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/packaged_task/cons/2.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/packaged_task/cons/2.cc new file mode 100644 index 000000000..62f951e01 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/packaged_task/cons/2.cc @@ -0,0 +1,64 @@ +// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* *-*-solaris* *-*-cygwin *-*-darwin* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } } +// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } } +// { dg-require-cstdint "" } +// { dg-require-gthreads "" } +// { dg-require-atomic-builtins "" } + +// Copyright (C) 2009-2014 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 <future> +#include <testsuite_hooks.h> +#include <testsuite_tr1.h> + +using namespace __gnu_test; + +int f1() { return 0; } +int& f2() { static int i; return i; } +void f3() { } +ClassType f4() { return ClassType(); } + +struct Derived : AbstractClass { + void rotate(int) { } + Derived& operator()(int i) { rotate(i); return *this; } +} f5; + +void test01() +{ + bool test __attribute__((unused)) = true; + using std::packaged_task; + + packaged_task<int ()> p1(f1); + VERIFY( p1.valid() ); + packaged_task<int& ()> p2(f2); + VERIFY( p2.valid() ); + packaged_task<void ()> p3(f3); + VERIFY( p3.valid() ); + packaged_task<ClassType ()> p4(f4); + VERIFY( p4.valid() ); + packaged_task<AbstractClass& (int)> p5(f5); + VERIFY( p5.valid() ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/packaged_task/cons/3.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/packaged_task/cons/3.cc new file mode 100644 index 000000000..9238753e7 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/packaged_task/cons/3.cc @@ -0,0 +1,56 @@ +// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* *-*-solaris* *-*-cygwin *-*-darwin* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } } +// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } } +// { dg-require-cstdint "" } +// { dg-require-gthreads "" } +// { dg-require-atomic-builtins "" } + +// Copyright (C) 2011-2014 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/>. + +// LWG 2067. packaged_task should have deleted copy c'tor with const parameter + +#include <future> +#include <thread> +#include <testsuite_hooks.h> + +template<typename F> +std::future<typename std::result_of<F()>::type> spawn_task(F f) +{ + typedef typename std::result_of<F()>::type result_type; + std::packaged_task<result_type()> task(std::move(f)); + std::future<result_type> res(task.get_future()); + std::thread(std::move(task)).detach(); + return res; +} + +int get_res() +{ + return 42; +} + +void test01() +{ + auto f = spawn_task(get_res); + VERIFY( f.get() == get_res() ); +} + +int main() +{ + test01(); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/packaged_task/cons/56492.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/packaged_task/cons/56492.cc new file mode 100644 index 000000000..c256565fd --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/packaged_task/cons/56492.cc @@ -0,0 +1,35 @@ +// { dg-do compile { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* *-*-solaris* *-*-cygwin *-*-darwin* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++11 -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++11 -pthreads" { target *-*-solaris* } } +// { dg-options " -std=gnu++11 " { target *-*-cygwin *-*-darwin* } } +// { dg-require-cstdint "" } +// { dg-require-gthreads "" } +// { dg-require-atomic-builtins "" } + +// Copyright (C) 2013-2014 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 <future> + +struct S +{ + S() = default; + S(S&&) = default; + void operator()() { } +}; + +std::packaged_task<void ()> pt{ S{} }; diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/packaged_task/cons/alloc.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/packaged_task/cons/alloc.cc new file mode 100644 index 000000000..9de283e9c --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/packaged_task/cons/alloc.cc @@ -0,0 +1,52 @@ +// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* *-*-solaris* *-*-cygwin *-*-darwin* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } } +// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } } +// { dg-require-cstdint "" } +// { dg-require-gthreads "" } +// { dg-require-atomic-builtins "" } + +// Copyright (C) 2010-2014 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 <future> +#include <testsuite_hooks.h> +#include <testsuite_allocator.h> + +int f() { return 5; } + +void test01() +{ + bool test __attribute__((unused)) = true; + + using std::packaged_task; + using std::allocator_arg; + using __gnu_test::uneq_allocator; + + uneq_allocator<char> alloc(99); + + packaged_task<int ()> p1(allocator_arg, alloc, f); + VERIFY( p1.valid() ); + p1(); + VERIFY( p1.get_future().get() == 5 ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/packaged_task/cons/alloc2.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/packaged_task/cons/alloc2.cc new file mode 100644 index 000000000..3c27d6176 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/packaged_task/cons/alloc2.cc @@ -0,0 +1,40 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } +// { dg-require-cstdint "" } +// { dg-require-gthreads "" } +// { dg-require-atomic-builtins "" } + +// Copyright (C) 2011-2014 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/>. + +// Test that packaged_task can be default-constructed or move-constructed +// in a context that does uses-allocator construction. + +#include <future> +#include <memory> +#include <tuple> + +using std::packaged_task; +using std::allocator_arg; +using std::allocator; +using std::tuple; + +typedef packaged_task<void()> task; +allocator<task> a; + +tuple<task> t1{ allocator_arg, a }; +tuple<task> t2{ allocator_arg, a, task{} }; diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/packaged_task/cons/alloc_min.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/packaged_task/cons/alloc_min.cc new file mode 100644 index 000000000..904000bb6 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/packaged_task/cons/alloc_min.cc @@ -0,0 +1,34 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } +// { dg-require-cstdint "" } +// { dg-require-gthreads "" } +// { dg-require-atomic-builtins "" } + +// Copyright (C) 2011-2014 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/>. + +// Test that packaged_task can use a minimal C++11 allocator +// and doesn't rely on C++98 allocator interface. + +#include <future> +#include <testsuite_allocator.h> + +using std::packaged_task; +using std::allocator_arg; + +__gnu_test::SimpleAllocator<int> a; +packaged_task<int()> p(allocator_arg, a, []() { return 1; }); diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/packaged_task/cons/assign_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/packaged_task/cons/assign_neg.cc new file mode 100644 index 000000000..c7a97f5c4 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/packaged_task/cons/assign_neg.cc @@ -0,0 +1,35 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } +// { dg-require-cstdint "" } +// { dg-require-gthreads "" } +// { dg-require-atomic-builtins "" } + +// Copyright (C) 2009-2014 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 <future> + +void test01() +{ + // assign + std::packaged_task<int()> p1; + std::packaged_task<int()> p2; + p1 = p2; // { dg-error "deleted" } +} + +// { dg-prune-output "include" } diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/packaged_task/cons/copy_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/packaged_task/cons/copy_neg.cc new file mode 100644 index 000000000..cb75a3eb0 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/packaged_task/cons/copy_neg.cc @@ -0,0 +1,34 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } +// { dg-require-cstdint "" } +// { dg-require-gthreads "" } +// { dg-require-atomic-builtins "" } + +// Copyright (C) 2009-2014 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 <future> + +void test01() +{ + // copy + std::packaged_task<int()> p1; + std::packaged_task<int()> p2(p1); // { dg-error "deleted" } +} + +// { dg-prune-output "include" } diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/packaged_task/cons/move.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/packaged_task/cons/move.cc new file mode 100644 index 000000000..263e0f050 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/packaged_task/cons/move.cc @@ -0,0 +1,49 @@ +// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* *-*-solaris* *-*-cygwin *-*-darwin* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } } +// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } } +// { dg-require-cstdint "" } +// { dg-require-gthreads "" } +// { dg-require-atomic-builtins "" } + +// Copyright (C) 2009-2014 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 <future> +#include <testsuite_hooks.h> + +int f1() { return 0; } + +void test01() +{ + bool test __attribute__((unused)) = true; + using namespace std; + + // move + packaged_task<int()> p1(f1); + packaged_task<int()> p2(std::move(p1)); + VERIFY( !p1.valid() ); + VERIFY( p2.valid() ); +} + +int main() +{ + test01(); + return 0; +} + diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/packaged_task/cons/move_assign.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/packaged_task/cons/move_assign.cc new file mode 100644 index 000000000..dcde7ef4f --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/packaged_task/cons/move_assign.cc @@ -0,0 +1,49 @@ +// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* *-*-solaris* *-*-cygwin *-*-darwin* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } } +// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } } +// { dg-require-cstdint "" } +// { dg-require-gthreads "" } +// { dg-require-atomic-builtins "" } + +// Copyright (C) 2009-2014 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 <future> +#include <testsuite_hooks.h> + +int gen() { return 0; } + +void test01() +{ + bool test __attribute__((unused)) = true; + + // move assign + std::packaged_task<int()> p1; + std::packaged_task<int()> p2(gen); + p1 = std::move(p2); + VERIFY( p1.valid() ); + VERIFY( !p2.valid() ); +} + +int main() +{ + test01(); + return 0; +} + diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/packaged_task/members/get_future.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/packaged_task/members/get_future.cc new file mode 100644 index 000000000..f12ab2d9d --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/packaged_task/members/get_future.cc @@ -0,0 +1,57 @@ +// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* *-*-solaris* *-*-cygwin *-*-darwin* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } } +// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } } +// { dg-require-cstdint "" } +// { dg-require-gthreads "" } +// { dg-require-atomic-builtins "" } + +// Copyright (C) 2009-2014 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 <future> +#include <testsuite_hooks.h> + +int& inc(int& i) { return ++i; } + +void test01() +{ + bool test __attribute__((unused)) = true; + + std::packaged_task<int&(int&)> p1(inc); + std::future<int&> f1 = p1.get_future(); + + std::chrono::milliseconds delay(1); + VERIFY( f1.valid() ); + VERIFY( f1.wait_for(delay) == std::future_status::timeout ); + + int i1 = 0; + + p1(i1); + + int& i2 = f1.get(); + + VERIFY( &i1 == &i2 ); + VERIFY( i1 == 1 ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/packaged_task/members/get_future2.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/packaged_task/members/get_future2.cc new file mode 100644 index 000000000..544a0c371 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/packaged_task/members/get_future2.cc @@ -0,0 +1,58 @@ +// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* *-*-solaris* *-*-cygwin *-*-darwin* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } } +// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } } +// { dg-require-cstdint "" } +// { dg-require-gthreads "" } +// { dg-require-atomic-builtins "" } + +// Copyright (C) 2009-2014 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 <future> +#include <system_error> +#include <testsuite_hooks.h> + +int& inc(int& i) { return ++i; } + +void test01() +{ + bool test = false; + + std::packaged_task<int&(int&)> p1(inc); + p1.get_future(); + + try + { + p1.get_future(); + VERIFY( false ); + } + catch (const std::future_error& e) + { + VERIFY( e.code() == std::future_errc::future_already_retrieved ); + test = true; + } + + VERIFY( test ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/packaged_task/members/invoke.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/packaged_task/members/invoke.cc new file mode 100644 index 000000000..26d2267df --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/packaged_task/members/invoke.cc @@ -0,0 +1,49 @@ +// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* *-*-solaris* *-*-cygwin *-*-darwin* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } } +// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } } +// { dg-require-cstdint "" } +// { dg-require-gthreads "" } +// { dg-require-atomic-builtins "" } + +// Copyright (C) 2009-2014 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 <future> +#include <testsuite_hooks.h> + +int zero() { return 0; } + +void test01() +{ + bool test __attribute__((unused)) = true; + + std::packaged_task<int()> p1(zero); + std::future<int> f1 = p1.get_future(); + + p1(); + + VERIFY( p1.valid() ); + VERIFY( f1.get() == 0 ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/packaged_task/members/invoke2.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/packaged_task/members/invoke2.cc new file mode 100644 index 000000000..4afe37f1a --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/packaged_task/members/invoke2.cc @@ -0,0 +1,57 @@ +// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* *-*-solaris* *-*-cygwin *-*-darwin* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } } +// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } } +// { dg-require-cstdint "" } +// { dg-require-gthreads "" } +// { dg-require-atomic-builtins "" } + +// Copyright (C) 2009-2014 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 <future> +#include <testsuite_hooks.h> + +bool odd(unsigned i) { return i%2; } + +void test01() +{ + bool test = false; + + std::packaged_task<bool(unsigned)> p1(odd); + + p1(5); + + try + { + p1(4); + } + catch (const std::future_error& e) + { + VERIFY( e.code() == std::future_errc::promise_already_satisfied ); + test = true; + } + + VERIFY( test ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/packaged_task/members/invoke3.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/packaged_task/members/invoke3.cc new file mode 100644 index 000000000..b977b84aa --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/packaged_task/members/invoke3.cc @@ -0,0 +1,61 @@ +// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* *-*-solaris* *-*-cygwin *-*-darwin* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } } +// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } } +// { dg-require-cstdint "" } +// { dg-require-gthreads "" } +// { dg-require-atomic-builtins "" } + +// Copyright (C) 2009-2014 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 <future> +#include <testsuite_hooks.h> + +int& inc(int& i) { ++i; return i; } + +void test01() +{ + bool test = false; + + std::packaged_task<void(int&)> p1(inc); + + int i1 = 0; + p1(i1); + + VERIFY( i1 == 1 ); + + try + { + p1(i1); + } + catch (const std::future_error& e) + { + VERIFY( e.code() == std::future_errc::promise_already_satisfied ); + test = true; + } + + VERIFY( i1 == 1 ); + VERIFY( test ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/packaged_task/members/invoke4.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/packaged_task/members/invoke4.cc new file mode 100644 index 000000000..3b0104301 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/packaged_task/members/invoke4.cc @@ -0,0 +1,53 @@ +// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* *-*-solaris* *-*-cygwin *-*-darwin* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } } +// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } } +// { dg-require-cstdint "" } +// { dg-require-gthreads "" } +// { dg-require-atomic-builtins "" } + +// Copyright (C) 2009-2014 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 <future> +#include <testsuite_hooks.h> + +void thrower() { throw 0; } + +void test01() +{ + bool test = false; + + std::packaged_task<void()> p1(thrower); + std::future<void> f1 = p1.get_future(); + + p1(); + + try { + f1.get(); + } catch (int) { + test = true; + } + VERIFY( test ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/packaged_task/members/invoke5.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/packaged_task/members/invoke5.cc new file mode 100644 index 000000000..bb991f0fe --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/packaged_task/members/invoke5.cc @@ -0,0 +1,51 @@ +// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* *-*-solaris* *-*-cygwin *-*-darwin* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } } +// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } } +// { dg-require-cstdint "" } +// { dg-require-gthreads "" } +// { dg-require-atomic-builtins "" } + +// Copyright (C) 2009-2014 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 <future> +#include <thread> +#include <testsuite_hooks.h> + +void noop() { } +void waiter(std::shared_future<void> f) { f.wait(); } + +void test01() +{ + bool test __attribute__((unused)) = true; + + std::packaged_task<void()> p1(noop); + std::shared_future<void> f1(p1.get_future()); + std::thread t1(waiter, f1); + + p1(); + + t1.join(); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/packaged_task/members/reset.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/packaged_task/members/reset.cc new file mode 100644 index 000000000..331c3a4b0 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/packaged_task/members/reset.cc @@ -0,0 +1,63 @@ +// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* *-*-solaris* *-*-cygwin *-*-darwin* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } } +// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } } +// { dg-require-cstdint "" } +// { dg-require-gthreads "" } +// { dg-require-atomic-builtins "" } + +// Copyright (C) 2009-2014 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 <future> +#include <system_error> +#include <testsuite_hooks.h> + +int zero() { return 0; } + +void test01() +{ + bool test = false; + using namespace std; + + packaged_task<int()> p1(zero); + future<int> f1 = p1.get_future(); + + p1.reset(); + VERIFY( p1.valid() ); + + future<int> f2 = p1.get_future(); + + try + { + f1.get(); + } + catch (future_error& e) + { + VERIFY( e.code() == make_error_code(future_errc::broken_promise) ); + test = true; + } + + VERIFY( test ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/packaged_task/members/reset2.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/packaged_task/members/reset2.cc new file mode 100644 index 000000000..6b418f028 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/packaged_task/members/reset2.cc @@ -0,0 +1,54 @@ +// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* *-*-solaris* *-*-cygwin *-*-darwin* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } } +// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } } +// { dg-require-cstdint "" } +// { dg-require-gthreads "" } +// { dg-require-atomic-builtins "" } + +// Copyright (C) 2009-2014 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 <future> +#include <testsuite_hooks.h> + +int iota() { static int i = 0; return i++; } + +void test01() +{ + bool test __attribute__((unused)) = true; + + std::packaged_task<int()> p1(iota); + std::future<int> f1 = p1.get_future(); + + p1(); + p1.reset(); + + VERIFY( p1.valid() ); + VERIFY( f1.get() == 0 ); + + std::future<int> f2 = p1.get_future(); + p1(); + VERIFY( f2.get() == 1 ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/packaged_task/members/swap.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/packaged_task/members/swap.cc new file mode 100644 index 000000000..d68aa5472 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/packaged_task/members/swap.cc @@ -0,0 +1,49 @@ +// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* *-*-solaris* *-*-cygwin *-*-darwin* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } } +// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } } +// { dg-require-cstdint "" } +// { dg-require-gthreads "" } +// { dg-require-atomic-builtins "" } + +// Copyright (C) 2009-2014 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 <future> +#include <testsuite_hooks.h> + +int zero() { return 0; } + +void test01() +{ + bool test __attribute__((unused)) = true; + + std::packaged_task<int()> p1(zero); + std::packaged_task<int()> p2; + VERIFY( p1.valid() ); + VERIFY( !p2.valid() ); + p1.swap(p2); + VERIFY( !p1.valid() ); + VERIFY( p2.valid() ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/packaged_task/members/valid.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/packaged_task/members/valid.cc new file mode 100644 index 000000000..6515f9b87 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/packaged_task/members/valid.cc @@ -0,0 +1,47 @@ +// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* *-*-solaris* *-*-cygwin *-*-darwin* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } } +// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } } +// { dg-require-cstdint "" } +// { dg-require-gthreads "" } +// { dg-require-atomic-builtins "" } + +// Copyright (C) 2011-2014 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 <future> +#include <testsuite_hooks.h> + +int zero() { return 0; } + +void test01() +{ + bool test __attribute__((unused)) = true; + + std::packaged_task<int()> p1; + VERIFY( !p1.valid() ); + + std::packaged_task<int()> p2(zero); + VERIFY( p2.valid() ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/packaged_task/requirements/explicit_instantiation.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/packaged_task/requirements/explicit_instantiation.cc new file mode 100644 index 000000000..55be22dd6 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/packaged_task/requirements/explicit_instantiation.cc @@ -0,0 +1,34 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } +// { dg-require-cstdint "" } +// { dg-require-gthreads "" } +// { dg-require-atomic-builtins "" } + +// Copyright (C) 2009-2014 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 <future> +#include <testsuite_tr1.h> + +using namespace __gnu_test; +using std::packaged_task; +template class packaged_task<int()>; +template class packaged_task<int&()>; +template class packaged_task<void()>; +template class packaged_task<ClassType(int)>; +template class packaged_task<AbstractClass&(int)>; diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/packaged_task/uses_allocator.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/packaged_task/uses_allocator.cc new file mode 100644 index 000000000..73abd6242 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/packaged_task/uses_allocator.cc @@ -0,0 +1,32 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } +// { dg-require-cstdint "" } +// { dg-require-gthreads "" } +// { dg-require-atomic-builtins "" } + +// Copyright (C) 2011-2014 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 <future> +#include <memory> + +using std::uses_allocator; +using std::allocator; +using std::packaged_task; +static_assert( uses_allocator<packaged_task<int()>, allocator<int>>::value, + "packaged_task supports uses-allocator construction" ); diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/promise/cons/1.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/promise/cons/1.cc new file mode 100644 index 000000000..891306016 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/promise/cons/1.cc @@ -0,0 +1,46 @@ +// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* *-*-solaris* *-*-cygwin *-*-darwin* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } } +// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } } +// { dg-require-cstdint "" } +// { dg-require-gthreads "" } +// { dg-require-atomic-builtins "" } + +// Copyright (C) 2009-2014 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 <future> +#include <testsuite_tr1.h> + +void test01() +{ + using std::promise; + using namespace __gnu_test; + + promise<int> p1; + promise<int&> p2; + promise<void> p3; + promise<ClassType> p4; + promise<AbstractClass&> p5; +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/promise/cons/alloc.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/promise/cons/alloc.cc new file mode 100644 index 000000000..10fa8824c --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/promise/cons/alloc.cc @@ -0,0 +1,47 @@ +// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* *-*-solaris* *-*-cygwin *-*-darwin* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } } +// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } } +// { dg-require-cstdint "" } +// { dg-require-gthreads "" } +// { dg-require-atomic-builtins "" } + +// Copyright (C) 2010-2014 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 <future> +#include <testsuite_hooks.h> +#include <testsuite_allocator.h> + +void test01() +{ + using std::promise; + using std::allocator_arg; + using __gnu_test::uneq_allocator; + + uneq_allocator<char> alloc(99); + + promise<int> p1(allocator_arg, alloc); + p1.set_value(5); + VERIFY( p1.get_future().get() == 5 ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/promise/cons/alloc2.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/promise/cons/alloc2.cc new file mode 100644 index 000000000..178f37c30 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/promise/cons/alloc2.cc @@ -0,0 +1,42 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } +// { dg-require-cstdint "" } +// { dg-require-gthreads "" } +// { dg-require-atomic-builtins "" } + +// Copyright (C) 2011-2014 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/>. + +// Test that promise can be default-constructed or move-constructed +// in a context that does uses-allocator construction. + +#include <future> +#include <memory> +#include <tuple> + +using std::promise; +using std::allocator_arg; +using std::allocator; +using std::tuple; + +typedef promise<int> p; +typedef promise<int&> pr; +typedef promise<void> pv; +allocator<p> a; + +tuple<p, pr, pv> t1{ allocator_arg, a }; +tuple<p, pr, pv> t2{ allocator_arg, a, p{}, pr{}, pv{} }; diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/promise/cons/alloc_min.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/promise/cons/alloc_min.cc new file mode 100644 index 000000000..297d5a8bd --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/promise/cons/alloc_min.cc @@ -0,0 +1,40 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } +// { dg-require-cstdint "" } +// { dg-require-gthreads "" } +// { dg-require-atomic-builtins "" } + +// Copyright (C) 2011-2014 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/>. + +// Test that promise can use a minimal C++11 allocator +// and doesn't rely on C++98 allocator interface. + +#include <future> +#include <testsuite_allocator.h> + +using std::promise; +using std::allocator_arg; +using std::tuple; + +typedef promise<int> p; +typedef promise<int&> pr; +typedef promise<void> pv; +__gnu_test::SimpleAllocator<p> a; + +tuple<p, pr, pv> t1{ allocator_arg, a }; +tuple<p, pr, pv> t2{ allocator_arg, a, p{}, pr{}, pv{} }; diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/promise/cons/assign_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/promise/cons/assign_neg.cc new file mode 100644 index 000000000..2863856ab --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/promise/cons/assign_neg.cc @@ -0,0 +1,35 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } +// { dg-require-cstdint "" } +// { dg-require-gthreads "" } +// { dg-require-atomic-builtins "" } + +// Copyright (C) 2009-2014 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 <future> + +void test01() +{ + // assign + std::promise<int> p1; + std::promise<int> p2; + p1 = p2; // { dg-error "deleted" } +} + +// { dg-prune-output "include" } diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/promise/cons/copy_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/promise/cons/copy_neg.cc new file mode 100644 index 000000000..4a8cce19d --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/promise/cons/copy_neg.cc @@ -0,0 +1,34 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } +// { dg-require-cstdint "" } +// { dg-require-gthreads "" } +// { dg-require-atomic-builtins "" } + +// Copyright (C) 2009-2014 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 <future> + +void test01() +{ + // copy + std::promise<int> p1; + std::promise<int> p2(p1); // { dg-error "deleted" } +} + +// { dg-prune-output "include" } diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/promise/cons/move.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/promise/cons/move.cc new file mode 100644 index 000000000..7196e93e0 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/promise/cons/move.cc @@ -0,0 +1,55 @@ +// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* *-*-solaris* *-*-cygwin *-*-darwin* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } } +// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } } +// { dg-require-cstdint "" } +// { dg-require-gthreads "" } +// { dg-require-atomic-builtins "" } + +// Copyright (C) 2009-2014 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 <future> +#include <testsuite_hooks.h> + +void test01() +{ + bool test __attribute__((unused)) = true; + using namespace std; + + // move assign + promise<int> p1; + p1.set_value(3); + promise<int> p2(std::move(p1)); + VERIFY( p2.get_future().get() == 3 ); + try + { + p1.get_future(); + VERIFY( false ); + } + catch (std::future_error& e) + { + VERIFY(e.code() == make_error_code(future_errc::no_state)); + } +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/promise/cons/move_assign.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/promise/cons/move_assign.cc new file mode 100644 index 000000000..1bfbd3560 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/promise/cons/move_assign.cc @@ -0,0 +1,56 @@ +// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* *-*-solaris* *-*-cygwin *-*-darwin* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } } +// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } } +// { dg-require-cstdint "" } +// { dg-require-gthreads "" } +// { dg-require-atomic-builtins "" } + +// Copyright (C) 2009-2014 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 <future> +#include <testsuite_hooks.h> + +void test01() +{ + bool test __attribute__((unused)) = true; + using namespace std; + + // move assign + promise<int> p1; + p1.set_value(3); + promise<int> p2; + p2 = move(p1); + VERIFY( p2.get_future().get() == 3 ); + try + { + p1.get_future(); + VERIFY( false ); + } + catch (future_error& e) + { + VERIFY(e.code() == make_error_code(future_errc::no_state)); + } +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/promise/members/get_future.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/promise/members/get_future.cc new file mode 100644 index 000000000..3f0e37a0a --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/promise/members/get_future.cc @@ -0,0 +1,52 @@ +// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* *-*-solaris* *-*-cygwin *-*-darwin* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } } +// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } } +// { dg-require-cstdint "" } +// { dg-require-gthreads "" } +// { dg-require-atomic-builtins "" } + +// Copyright (C) 2009-2014 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 <future> +#include <testsuite_hooks.h> + +void test01() +{ + bool test __attribute__((unused)) = true; + + std::promise<int&> p1; + std::future<int&> f1 = p1.get_future(); + + VERIFY( f1.valid() ); + + int i1 = 0; + + p1.set_value(i1); + + int& i2 = f1.get(); + + VERIFY( &i1 == &i2 ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/promise/members/get_future2.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/promise/members/get_future2.cc new file mode 100644 index 000000000..6e0814636 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/promise/members/get_future2.cc @@ -0,0 +1,57 @@ +// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* *-*-solaris* *-*-cygwin *-*-darwin* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } } +// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } } +// { dg-require-cstdint "" } +// { dg-require-gthreads "" } +// { dg-require-atomic-builtins "" } + +// Copyright (C) 2009-2014 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 <future> +#include <system_error> +#include <testsuite_hooks.h> + +void test01() +{ + bool test = false; + using namespace std; + + promise<int&> p1; + p1.get_future(); + + try + { + p1.get_future(); + VERIFY( false ); + } + catch (future_error& e) + { + VERIFY(e.code() == make_error_code(future_errc::future_already_retrieved)); + test = true; + } + + VERIFY( test ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/promise/members/set_exception.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/promise/members/set_exception.cc new file mode 100644 index 000000000..e07893e48 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/promise/members/set_exception.cc @@ -0,0 +1,57 @@ +// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* *-*-solaris* *-*-cygwin *-*-darwin* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } } +// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } } +// { dg-require-cstdint "" } +// { dg-require-gthreads "" } +// { dg-require-atomic-builtins "" } + +// Copyright (C) 2009-2014 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 <future> +#include <testsuite_hooks.h> + +void test01() +{ + bool test = false; + + std::promise<int> p1; + std::future<int> f1 = p1.get_future(); + + VERIFY( f1.valid() ); + + p1.set_exception(std::make_exception_ptr(0)); + + try + { + f1.get(); + } + catch (int) + { + test = true; + } + VERIFY( test ); + VERIFY( !f1.valid() ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/promise/members/set_exception2.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/promise/members/set_exception2.cc new file mode 100644 index 000000000..949702c56 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/promise/members/set_exception2.cc @@ -0,0 +1,93 @@ +// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* *-*-solaris* *-*-cygwin *-*-darwin* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } } +// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } } +// { dg-require-cstdint "" } +// { dg-require-gthreads "" } +// { dg-require-atomic-builtins "" } + +// Copyright (C) 2009-2014 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 <future> +#include <testsuite_hooks.h> + +void test01() +{ + bool test = false; + + std::promise<int> p1; + std::future<int> f1 = p1.get_future(); + + p1.set_exception(std::make_exception_ptr(0)); + + try + { + p1.set_exception(std::make_exception_ptr(1)); + VERIFY( false ); + } + catch (std::future_error& e) + { + VERIFY(e.code() == + std::make_error_code(std::future_errc::promise_already_satisfied)); + test = true; + } + + try + { + f1.get(); + test = false; + } + catch(int i) + { + VERIFY( i == 0 ); + } + + VERIFY( test ); +} + +void test02() +{ + bool test = false; + + std::promise<int> p1; + std::future<int> f1 = p1.get_future(); + + p1.set_value(2); + + try + { + p1.set_exception(std::make_exception_ptr(0)); + VERIFY( false ); + } + catch (std::future_error& e) + { + VERIFY(e.code() == + std::make_error_code(std::future_errc::promise_already_satisfied)); + test = true; + } + + VERIFY( test ); +} + +int main() +{ + test01(); + test02(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/promise/members/set_value.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/promise/members/set_value.cc new file mode 100644 index 000000000..a670ab0d8 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/promise/members/set_value.cc @@ -0,0 +1,106 @@ +// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* *-*-solaris* *-*-cygwin *-*-darwin* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } } +// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } } +// { dg-require-cstdint "" } +// { dg-require-gthreads "" } +// { dg-require-atomic-builtins "" } + +// Copyright (C) 2009-2014 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 <future> +#include <testsuite_hooks.h> +#include <testsuite_rvalref.h> + +void test01() +{ + bool test __attribute__((unused)) = true; + + std::promise<int> p1; + std::future<int> f1 = p1.get_future(); + + VERIFY( f1.valid() ); + + p1.set_value(0); + + int&& i1 = f1.get(); + + VERIFY( i1 == 0 ); +} + +void test02() +{ + bool test __attribute__((unused)) = true; + using __gnu_test::rvalstruct; + + std::promise<rvalstruct> p1; + std::future<rvalstruct> f1 = p1.get_future(); + + VERIFY( f1.valid() ); + + p1.set_value(rvalstruct(1)); + + rvalstruct r1(f1.get()); + + VERIFY( !f1.valid() ); + VERIFY( r1.val == 1 ); +} + + +void test03() +{ + bool test __attribute__((unused)) = true; + + std::promise<int&> p1; + std::future<int&> f1 = p1.get_future(); + + VERIFY( f1.valid() ); + + int i1 = 0; + p1.set_value(i1); + int& i2 = f1.get(); + + VERIFY( !f1.valid() ); + VERIFY( &i1 == &i2 ); +} + +void test04() +{ + bool test __attribute__((unused)) = true; + + std::promise<void> p1; + std::future<void> f1 = p1.get_future(); + + VERIFY( f1.valid() ); + + p1.set_value(); + f1.get(); + + VERIFY( !f1.valid() ); +} + +int main() +{ + test01(); + test02(); + test03(); + test04(); + + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/promise/members/set_value2.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/promise/members/set_value2.cc new file mode 100644 index 000000000..3764d11b2 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/promise/members/set_value2.cc @@ -0,0 +1,89 @@ +// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* *-*-solaris* *-*-cygwin *-*-darwin* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } } +// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } } +// { dg-require-cstdint "" } +// { dg-require-gthreads "" } +// { dg-require-atomic-builtins "" } + +// Copyright (C) 2009-2014 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 <future> +#include <testsuite_hooks.h> + +void test01() +{ + bool test = false; + + std::promise<int> p1; + std::future<int> f1 = p1.get_future(); + + p1.set_value(1); + + try + { + p1.set_value(2); + VERIFY( false ); + } + catch (std::future_error& e) + { + VERIFY(e.code() == + std::make_error_code(std::future_errc::promise_already_satisfied)); + test = true; + } + + std::chrono::milliseconds delay(1); + VERIFY( f1.wait_for(delay) == std::future_status::ready ); + VERIFY( f1.get() == 1 ); + VERIFY( test ); +} + +void test02() +{ + bool test = false; + + std::promise<int> p1; + std::future<int> f1 = p1.get_future(); + + p1.set_value(3); + + try + { + p1.set_exception(std::make_exception_ptr(4)); + VERIFY( false ); + } + catch (std::future_error& e) + { + VERIFY(e.code() == + std::make_error_code(std::future_errc::promise_already_satisfied)); + test = true; + } + + std::chrono::milliseconds delay(1); + VERIFY( f1.wait_for(delay) == std::future_status::ready ); + VERIFY( f1.get() == 3 ); + VERIFY( test ); +} + +int main() +{ + test01(); + test02(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/promise/members/set_value3.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/promise/members/set_value3.cc new file mode 100644 index 000000000..e7bd13f5f --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/promise/members/set_value3.cc @@ -0,0 +1,80 @@ +// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* *-*-solaris* *-*-cygwin *-*-darwin* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } } +// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } } +// { dg-require-cstdint "" } +// { dg-require-gthreads "" } +// { dg-require-atomic-builtins "" } + +// Copyright (C) 2009-2014 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 <future> +#include <testsuite_hooks.h> + + +// Test promise::set_value() for deadlock by checking if the state is ready +// during construction and destruction of the associated state. + +struct tester +{ + tester(int); + tester(const tester&); + tester() = delete; + tester& operator=(const tester&); +}; + +std::promise<tester> pglobal; +std::future<tester> fglobal = pglobal.get_future(); + +auto delay = std::chrono::milliseconds(1); + +tester::tester(int) +{ + bool test __attribute__((unused)) = true; + VERIFY (fglobal.wait_for(delay) == std::future_status::timeout); +} + +tester::tester(const tester&) +{ + bool test __attribute__((unused)) = true; + // if this copy happens while a mutex is locked next line could deadlock: + VERIFY (fglobal.wait_for(delay) == std::future_status::timeout); +} + +tester& tester::operator=(const tester&) +{ + bool test __attribute__((unused)) = true; + // if this copy happens while a mutex is locked next line could deadlock: + VERIFY (fglobal.wait_for(delay) == std::future_status::timeout); + return *this; +} + +void test01() +{ + bool test __attribute__((unused)) = true; + + pglobal.set_value( tester(1) ); + + VERIFY (fglobal.wait_for(delay) == std::future_status::ready); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/promise/members/swap.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/promise/members/swap.cc new file mode 100644 index 000000000..c003a4047 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/promise/members/swap.cc @@ -0,0 +1,47 @@ +// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* *-*-solaris* *-*-cygwin *-*-darwin* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } } +// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } } +// { dg-require-cstdint "" } +// { dg-require-gthreads "" } +// { dg-require-atomic-builtins "" } + +// Copyright (C) 2009-2014 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 <future> +#include <testsuite_hooks.h> + +void test01() +{ + bool test __attribute__((unused)) = true; + + std::promise<int> p1; + std::promise<int> p2; + p1.set_value(1); + p1.swap(p2); + auto delay = std::chrono::milliseconds(1); + VERIFY( p1.get_future().wait_for(delay) == std::future_status::timeout ); + VERIFY( p2.get_future().wait_for(delay) == std::future_status::ready ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/promise/requirements/explicit_instantiation.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/promise/requirements/explicit_instantiation.cc new file mode 100644 index 000000000..033b7b836 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/promise/requirements/explicit_instantiation.cc @@ -0,0 +1,34 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } +// { dg-require-cstdint "" } +// { dg-require-gthreads "" } +// { dg-require-atomic-builtins "" } + +// Copyright (C) 2009-2014 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 <future> +#include <testsuite_tr1.h> + +using namespace __gnu_test; +using std::promise; +template class promise<int>; +template class promise<int&>; +template class promise<void>; +template class promise<ClassType>; +template class promise<ClassType&>; diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/promise/uses_allocator.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/promise/uses_allocator.cc new file mode 100644 index 000000000..4c9c55f0e --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/promise/uses_allocator.cc @@ -0,0 +1,32 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } +// { dg-require-cstdint "" } +// { dg-require-gthreads "" } +// { dg-require-atomic-builtins "" } + +// Copyright (C) 2011-2014 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 <future> +#include <memory> + +using std::uses_allocator; +using std::allocator; +using std::promise; +static_assert( uses_allocator<promise<int>, allocator<int>>::value, + "promise supports uses-allocator construction" ); diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/recursive_mutex/cons/1.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/recursive_mutex/cons/1.cc new file mode 100644 index 000000000..8bef41d6a --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/recursive_mutex/cons/1.cc @@ -0,0 +1,49 @@ +// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* *-*-solaris* *-*-cygwin *-*-darwin* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* powerpc-ibm-aix* } } +// { 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-2014 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 <mutex> +#include <system_error> +#include <testsuite_hooks.h> + +int main() +{ + bool test __attribute__((unused)) = true; + typedef std::recursive_mutex mutex_type; + + try + { + mutex_type m1; + } + catch (const std::system_error& e) + { + VERIFY( false ); + } + catch (...) + { + VERIFY( false ); + } + + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/recursive_mutex/cons/assign_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/recursive_mutex/cons/assign_neg.cc new file mode 100644 index 000000000..90749158d --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/recursive_mutex/cons/assign_neg.cc @@ -0,0 +1,35 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } +// { dg-require-cstdint "" } +// { dg-require-gthreads "" } + +// Copyright (C) 2008-2014 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 <mutex> + +void test01() +{ + // assign + typedef std::recursive_mutex mutex_type; + mutex_type m1; + mutex_type m2; + m1 = m2; // { dg-error "deleted" } +} + +// { dg-prune-output "include" } diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/recursive_mutex/cons/copy_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/recursive_mutex/cons/copy_neg.cc new file mode 100644 index 000000000..1bf0fcaca --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/recursive_mutex/cons/copy_neg.cc @@ -0,0 +1,34 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } +// { dg-require-cstdint "" } +// { dg-require-gthreads "" } + +// Copyright (C) 2008-2014 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 <mutex> + +void test01() +{ + // assign + typedef std::recursive_mutex mutex_type; + mutex_type m1; + mutex_type m2(m1); // { dg-error "deleted" } +} + +// { dg-prune-output "include" } diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/recursive_mutex/dest/destructor_locked.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/recursive_mutex/dest/destructor_locked.cc new file mode 100644 index 000000000..7ced0dabb --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/recursive_mutex/dest/destructor_locked.cc @@ -0,0 +1,51 @@ +// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* *-*-solaris* *-*-cygwin *-*-darwin* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* powerpc-ibm-aix* } } +// { 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-2014 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 <mutex> +#include <system_error> +#include <testsuite_hooks.h> + +int main() +{ + bool test __attribute__((unused)) = true; + typedef std::recursive_mutex mutex_type; + + try + { + mutex_type m; + m.lock(); + } + catch (const std::system_error& e) + { + // Destroying locked mutex raises system error, or undefined. + // POSIX == may fail with EBUSY. + } + catch (...) + { + VERIFY( false ); + } + + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/recursive_mutex/lock/1.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/recursive_mutex/lock/1.cc new file mode 100644 index 000000000..af58e5306 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/recursive_mutex/lock/1.cc @@ -0,0 +1,64 @@ +// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* *-*-solaris* *-*-cygwin *-*-darwin* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* powerpc-ibm-aix* } } +// { 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-2014 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 <mutex> +#include <system_error> +#include <testsuite_hooks.h> + +int main() +{ + bool test __attribute__((unused)) = true; + typedef std::recursive_mutex mutex_type; + + try + { + mutex_type m; + m.lock(); + + // Lock already locked recursive mutex. + try + { + // XXX Will not block. + m.lock(); + } + catch (const std::system_error& e) + { + VERIFY( false ); + } + + m.unlock(); + m.unlock(); + } + catch (const std::system_error& e) + { + VERIFY( false ); + } + catch (...) + { + VERIFY( false ); + } + + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/recursive_mutex/native_handle/1.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/recursive_mutex/native_handle/1.cc new file mode 100644 index 000000000..be25308e2 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/recursive_mutex/native_handle/1.cc @@ -0,0 +1,51 @@ +// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* *-*-solaris* *-*-cygwin *-*-darwin* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* powerpc-ibm-aix* } } +// { 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-2014 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 <mutex> +#include <system_error> +#include <testsuite_hooks.h> + +int main() +{ + bool test __attribute__((unused)) = true; + typedef std::recursive_mutex mutex_type; + + try + { + mutex_type m; + mutex_type::native_handle_type n = m.native_handle(); + (void)n; + } + catch (const std::system_error& e) + { + VERIFY( false ); + } + catch (...) + { + VERIFY( false ); + } + + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/recursive_mutex/native_handle/typesizes.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/recursive_mutex/native_handle/typesizes.cc new file mode 100644 index 000000000..c2bfae22a --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/recursive_mutex/native_handle/typesizes.cc @@ -0,0 +1,33 @@ +// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* *-*-solaris* *-*-cygwin *-*-darwin* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* powerpc-ibm-aix* } } +// { 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-2014 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 <mutex> +#include <thread/all.h> + +int main() +{ + typedef std::recursive_mutex test_type; + __gnu_test::compare_type_to_native_type<test_type>(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/recursive_mutex/requirements/standard_layout.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/recursive_mutex/requirements/standard_layout.cc new file mode 100644 index 000000000..1b531fdfd --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/recursive_mutex/requirements/standard_layout.cc @@ -0,0 +1,31 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } +// { dg-require-cstdint "" } +// { dg-require-gthreads "" } + +// Copyright (C) 2009-2014 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 <mutex> +#include <testsuite_common_types.h> + +void test01() +{ + __gnu_test::standard_layout test; + test.operator()<std::recursive_mutex>(); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/recursive_mutex/requirements/typedefs.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/recursive_mutex/requirements/typedefs.cc new file mode 100644 index 000000000..e331a3473 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/recursive_mutex/requirements/typedefs.cc @@ -0,0 +1,33 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } +// { dg-require-cstdint "" } +// { dg-require-gthreads "" } + +// 2008-03-18 Benjamin Kosnik <bkoz@redhat.com> + +// Copyright (C) 2008-2014 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 <mutex> + +void test01() +{ + // Check for required typedefs + typedef std::recursive_mutex test_type; + typedef test_type::native_handle_type type; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/recursive_mutex/try_lock/1.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/recursive_mutex/try_lock/1.cc new file mode 100644 index 000000000..2c0a7d2d5 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/recursive_mutex/try_lock/1.cc @@ -0,0 +1,52 @@ +// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* *-*-solaris* *-*-cygwin *-*-darwin* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* powerpc-ibm-aix* } } +// { 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-2014 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 <mutex> +#include <system_error> +#include <testsuite_hooks.h> + +int main() +{ + bool test __attribute__((unused)) = true; + typedef std::recursive_mutex mutex_type; + + try + { + mutex_type m; + bool b = m.try_lock(); + VERIFY( b ); + m.unlock(); + } + catch (const std::system_error& e) + { + VERIFY( false ); + } + catch (...) + { + VERIFY( false ); + } + + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/recursive_mutex/try_lock/2.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/recursive_mutex/try_lock/2.cc new file mode 100644 index 000000000..76fa20aa0 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/recursive_mutex/try_lock/2.cc @@ -0,0 +1,68 @@ +// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* *-*-solaris* *-*-cygwin *-*-darwin* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* powerpc-ibm-aix* } } +// { 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-2014 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 <mutex> +#include <system_error> +#include <testsuite_hooks.h> + +int main() +{ + bool test __attribute__((unused)) = true; + typedef std::recursive_mutex mutex_type; + + try + { + mutex_type m; + m.lock(); + bool b; + + try + { + b = m.try_lock(); + VERIFY( b ); + m.unlock(); + } + catch (const std::system_error& e) + { + VERIFY( false ); + } + catch(...) + { + VERIFY( false ); + } + + m.unlock(); + } + catch (const std::system_error& e) + { + VERIFY( false ); + } + catch (...) + { + VERIFY( false ); + } + + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/recursive_mutex/unlock/1.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/recursive_mutex/unlock/1.cc new file mode 100644 index 000000000..2aef2749e --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/recursive_mutex/unlock/1.cc @@ -0,0 +1,52 @@ +// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* *-*-solaris* *-*-cygwin *-*-darwin* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* powerpc-ibm-aix* } } +// { 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-2014 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 <mutex> +#include <system_error> +#include <testsuite_hooks.h> + +int main() +{ + bool test __attribute__((unused)) = true; + typedef std::recursive_mutex mutex_type; + + try + { + // Unlock mutex that hasn't been locked. + mutex_type m; + m.unlock(); + } + catch (const std::system_error& e) + { + // POSIX == EPERM + VERIFY( true ); + } + catch (...) + { + VERIFY( false ); + } + + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/recursive_timed_mutex/cons/1.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/recursive_timed_mutex/cons/1.cc new file mode 100644 index 000000000..a6a9a28ef --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/recursive_timed_mutex/cons/1.cc @@ -0,0 +1,49 @@ +// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* *-*-solaris* *-*-cygwin *-*-darwin* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } } +// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } } +// { dg-require-cstdint "" } +// { dg-require-gthreads-timed "" } + +// Copyright (C) 2008-2014 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 <mutex> +#include <system_error> +#include <testsuite_hooks.h> + +int main() +{ + bool test __attribute__((unused)) = true; + typedef std::recursive_timed_mutex mutex_type; + + try + { + mutex_type m1; + } + catch (const std::system_error& e) + { + VERIFY( false ); + } + catch (...) + { + VERIFY( false ); + } + + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/recursive_timed_mutex/cons/assign_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/recursive_timed_mutex/cons/assign_neg.cc new file mode 100644 index 000000000..23c7c1b5e --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/recursive_timed_mutex/cons/assign_neg.cc @@ -0,0 +1,35 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } +// { dg-require-cstdint "" } +// { dg-require-gthreads-timed "" } + +// Copyright (C) 2008-2014 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 <mutex> + +void test01() +{ + // assign + typedef std::recursive_timed_mutex mutex_type; + mutex_type m1; + mutex_type m2; + m1 = m2; // { dg-error "deleted" } +} + +// { dg-prune-output "include" } diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/recursive_timed_mutex/cons/copy_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/recursive_timed_mutex/cons/copy_neg.cc new file mode 100644 index 000000000..222ed9881 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/recursive_timed_mutex/cons/copy_neg.cc @@ -0,0 +1,34 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } +// { dg-require-cstdint "" } +// { dg-require-gthreads-timed "" } + +// Copyright (C) 2008-2014 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 <mutex> + +void test01() +{ + // assign + typedef std::recursive_timed_mutex mutex_type; + mutex_type m1; + mutex_type m2(m1); // { dg-error "deleted" } +} + +// { dg-prune-output "include" } diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/recursive_timed_mutex/dest/destructor_locked.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/recursive_timed_mutex/dest/destructor_locked.cc new file mode 100644 index 000000000..5cc92b58a --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/recursive_timed_mutex/dest/destructor_locked.cc @@ -0,0 +1,51 @@ +// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* *-*-solaris* *-*-cygwin *-*-darwin* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } } +// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } } +// { dg-require-cstdint "" } +// { dg-require-gthreads-timed "" } + +// Copyright (C) 2008-2014 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 <mutex> +#include <system_error> +#include <testsuite_hooks.h> + +int main() +{ + bool test __attribute__((unused)) = true; + typedef std::recursive_timed_mutex mutex_type; + + try + { + mutex_type m; + m.lock(); + } + catch (const std::system_error& e) + { + // Destroying locked mutex raises system error, or undefined. + // POSIX == may fail with EBUSY. + } + catch (...) + { + VERIFY( false ); + } + + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/recursive_timed_mutex/lock/1.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/recursive_timed_mutex/lock/1.cc new file mode 100644 index 000000000..d90874dc6 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/recursive_timed_mutex/lock/1.cc @@ -0,0 +1,63 @@ +// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* *-*-solaris* *-*-cygwin *-*-darwin* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } } +// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } } +// { dg-require-cstdint "" } +// { dg-require-gthreads-timed "" } + +// Copyright (C) 2008-2014 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 <mutex> +#include <system_error> +#include <testsuite_hooks.h> + +int main() +{ + bool test __attribute__((unused)) = true; + typedef std::recursive_timed_mutex mutex_type; + + try + { + mutex_type m; + m.lock(); + + // Lock already locked mutex. + try + { + // XXX Will block. + // m.lock(); + } + catch (const std::system_error& e) + { + VERIFY( false ); + } + + m.unlock(); + } + catch (const std::system_error& e) + { + VERIFY( false ); + } + catch (...) + { + VERIFY( false ); + } + + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/recursive_timed_mutex/lock/2.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/recursive_timed_mutex/lock/2.cc new file mode 100644 index 000000000..75f01b442 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/recursive_timed_mutex/lock/2.cc @@ -0,0 +1,63 @@ +// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* *-*-solaris* *-*-cygwin *-*-darwin* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } } +// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } } +// { dg-require-cstdint "" } +// { dg-require-gthreads-timed "" } + +// Copyright (C) 2008-2014 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 <mutex> +#include <system_error> +#include <testsuite_hooks.h> + +int main() +{ + bool test __attribute__((unused)) = true; + typedef std::recursive_timed_mutex mutex_type; + + try + { + mutex_type m; + m.lock(); + + // Lock already locked mutex. + try + { + // XXX Will not block. + // m.lock(); + } + catch (const std::system_error& e) + { + VERIFY( false ); + } + + m.unlock(); + } + catch (const std::system_error& e) + { + VERIFY( false ); + } + catch (...) + { + VERIFY( false ); + } + + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/recursive_timed_mutex/native_handle/1.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/recursive_timed_mutex/native_handle/1.cc new file mode 100644 index 000000000..f3f8f1d71 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/recursive_timed_mutex/native_handle/1.cc @@ -0,0 +1,51 @@ +// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* *-*-solaris* *-*-cygwin *-*-darwin* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } } +// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } } +// { dg-require-cstdint "" } +// { dg-require-gthreads-timed "" } + +// Copyright (C) 2008-2014 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 <mutex> +#include <system_error> +#include <testsuite_hooks.h> + +int main() +{ + bool test __attribute__((unused)) = true; + typedef std::recursive_timed_mutex mutex_type; + + try + { + mutex_type m; + mutex_type::native_handle_type n = m.native_handle(); + (void)n; + } + catch (const std::system_error& e) + { + VERIFY( false ); + } + catch (...) + { + VERIFY( false ); + } + + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/recursive_timed_mutex/native_handle/typesizes.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/recursive_timed_mutex/native_handle/typesizes.cc new file mode 100644 index 000000000..71632abb4 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/recursive_timed_mutex/native_handle/typesizes.cc @@ -0,0 +1,33 @@ +// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* *-*-solaris* *-*-cygwin *-*-darwin* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } } +// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } } +// { dg-require-cstdint "" } +// { dg-require-gthreads-timed "" } + +// Copyright (C) 2009-2014 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 <mutex> +#include <thread/all.h> + +int main() +{ + typedef std::recursive_timed_mutex test_type; + __gnu_test::compare_type_to_native_type<test_type>(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/recursive_timed_mutex/requirements/typedefs.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/recursive_timed_mutex/requirements/typedefs.cc new file mode 100644 index 000000000..0f0311539 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/recursive_timed_mutex/requirements/typedefs.cc @@ -0,0 +1,33 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } +// { dg-require-cstdint "" } +// { dg-require-gthreads-timed "" } + +// 2008-03-18 Benjamin Kosnik <bkoz@redhat.com> + +// Copyright (C) 2008-2014 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 <mutex> + +void test01() +{ + // Check for required typedefs + typedef std::recursive_timed_mutex test_type; + typedef test_type::native_handle_type type; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/recursive_timed_mutex/try_lock/1.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/recursive_timed_mutex/try_lock/1.cc new file mode 100644 index 000000000..c6ec13846 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/recursive_timed_mutex/try_lock/1.cc @@ -0,0 +1,52 @@ +// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* *-*-solaris* *-*-cygwin *-*-darwin* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } } +// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } } +// { dg-require-cstdint "" } +// { dg-require-gthreads-timed "" } + +// Copyright (C) 2008-2014 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 <mutex> +#include <system_error> +#include <testsuite_hooks.h> + +int main() +{ + bool test __attribute__((unused)) = true; + typedef std::recursive_timed_mutex mutex_type; + + try + { + mutex_type m; + bool b = m.try_lock(); + VERIFY( b ); + m.unlock(); + } + catch (const std::system_error& e) + { + VERIFY( false ); + } + catch (...) + { + VERIFY( false ); + } + + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/recursive_timed_mutex/try_lock/2.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/recursive_timed_mutex/try_lock/2.cc new file mode 100644 index 000000000..4f02074cc --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/recursive_timed_mutex/try_lock/2.cc @@ -0,0 +1,64 @@ +// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* *-*-solaris* *-*-cygwin *-*-darwin* powerpc-ibm-aix* } } +// { dg-options "-std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* powerpc-ibm-aix* } } +// { dg-options "-std=gnu++0x -pthreads" { target *-*-solaris* } } +// { dg-options "-std=gnu++0x " { target *-*-cygwin *-*-darwin* } } +// { dg-require-cstdint "" } +// { dg-require-gthreads-timed "" } + +// Copyright (C) 2008-2014 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 <mutex> +#include <system_error> +#include <testsuite_hooks.h> + +int main() +{ + bool test __attribute__((unused)) = true; + typedef std::recursive_timed_mutex mutex_type; + + try + { + mutex_type m; + m.lock(); + bool b; + + try + { + b = m.try_lock(); + VERIFY( b ); + } + catch (const std::system_error& e) + { + VERIFY( false ); + } + + m.unlock(); + m.unlock(); + } + catch (const std::system_error& e) + { + VERIFY( false ); + } + catch (...) + { + VERIFY( false ); + } + + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/recursive_timed_mutex/try_lock_for/1.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/recursive_timed_mutex/try_lock_for/1.cc new file mode 100644 index 000000000..41a1a7586 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/recursive_timed_mutex/try_lock_for/1.cc @@ -0,0 +1,53 @@ +// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* *-*-solaris* *-*-cygwin *-*-darwin* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } } +// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } } +// { dg-require-cstdint "" } +// { dg-require-gthreads-timed "" } + +// Copyright (C) 2008-2014 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 <mutex> +#include <chrono> +#include <system_error> +#include <testsuite_hooks.h> + +int main() +{ + bool test __attribute__((unused)) = true; + typedef std::recursive_timed_mutex mutex_type; + + try + { + mutex_type m; + bool b = m.try_lock_for(std::chrono::seconds(1)); + VERIFY( b ); + m.unlock(); + } + catch (const std::system_error& e) + { + VERIFY( false ); + } + catch (...) + { + VERIFY( false ); + } + + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/recursive_timed_mutex/try_lock_for/2.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/recursive_timed_mutex/try_lock_for/2.cc new file mode 100644 index 000000000..ef344a2de --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/recursive_timed_mutex/try_lock_for/2.cc @@ -0,0 +1,54 @@ +// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* *-*-solaris* *-*-cygwin *-*-darwin* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } } +// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } } +// { dg-require-cstdint "" } +// { dg-require-gthreads-timed "" } + +// Copyright (C) 2008-2014 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 <mutex> +#include <chrono> +#include <system_error> +#include <testsuite_hooks.h> + +int main() +{ + bool test __attribute__((unused)) = true; + typedef std::recursive_timed_mutex mutex_type; + typedef std::chrono::duration<int64_t, std::pico> picoseconds; + + try + { + mutex_type m; + bool b = m.try_lock_for(picoseconds(1)); + VERIFY( b ); + m.unlock(); + } + catch (const std::system_error& e) + { + VERIFY( false ); + } + catch (...) + { + VERIFY( false ); + } + + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/recursive_timed_mutex/try_lock_for/3.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/recursive_timed_mutex/try_lock_for/3.cc new file mode 100644 index 000000000..90353a781 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/recursive_timed_mutex/try_lock_for/3.cc @@ -0,0 +1,70 @@ +// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* *-*-solaris* *-*-cygwin *-*-darwin* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } } +// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } } +// { dg-require-cstdint "" } +// { dg-require-gthreads-timed "" } + +// Copyright (C) 2008-2014 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 <mutex> +#include <system_error> +#include <testsuite_hooks.h> + +int main() +{ + bool test __attribute__((unused)) = true; + typedef std::recursive_timed_mutex mutex_type; + + std::chrono::seconds s(1); + + try + { + mutex_type m; + m.lock(); + bool b; + + try + { + b = m.try_lock_for(s); + VERIFY( b ); + m.unlock(); + } + catch (const std::system_error& e) + { + VERIFY( false ); + } + catch(...) + { + VERIFY( false ); + } + + m.unlock(); + } + catch (const std::system_error& e) + { + VERIFY( false ); + } + catch (...) + { + VERIFY( false ); + } + + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/recursive_timed_mutex/try_lock_until/1.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/recursive_timed_mutex/try_lock_until/1.cc new file mode 100644 index 000000000..c6ec13846 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/recursive_timed_mutex/try_lock_until/1.cc @@ -0,0 +1,52 @@ +// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* *-*-solaris* *-*-cygwin *-*-darwin* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } } +// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } } +// { dg-require-cstdint "" } +// { dg-require-gthreads-timed "" } + +// Copyright (C) 2008-2014 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 <mutex> +#include <system_error> +#include <testsuite_hooks.h> + +int main() +{ + bool test __attribute__((unused)) = true; + typedef std::recursive_timed_mutex mutex_type; + + try + { + mutex_type m; + bool b = m.try_lock(); + VERIFY( b ); + m.unlock(); + } + catch (const std::system_error& e) + { + VERIFY( false ); + } + catch (...) + { + VERIFY( false ); + } + + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/recursive_timed_mutex/try_lock_until/2.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/recursive_timed_mutex/try_lock_until/2.cc new file mode 100644 index 000000000..2cfdfb2ea --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/recursive_timed_mutex/try_lock_until/2.cc @@ -0,0 +1,63 @@ +// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* *-*-solaris* *-*-cygwin *-*-darwin* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } } +// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } } +// { dg-require-cstdint "" } +// { dg-require-gthreads-timed "" } + +// Copyright (C) 2008-2014 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 <mutex> +#include <system_error> +#include <testsuite_hooks.h> + +int main() +{ + bool test __attribute__((unused)) = true; + typedef std::recursive_timed_mutex mutex_type; + + try + { + mutex_type m; + m.lock(); + bool b; + + try + { + b = m.try_lock(); + VERIFY( b ); + } + catch (const std::system_error& e) + { + VERIFY( false ); + } + + m.unlock(); + } + catch (const std::system_error& e) + { + VERIFY( false ); + } + catch (...) + { + VERIFY( false ); + } + + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/recursive_timed_mutex/unlock/1.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/recursive_timed_mutex/unlock/1.cc new file mode 100644 index 000000000..18b3f53cb --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/recursive_timed_mutex/unlock/1.cc @@ -0,0 +1,52 @@ +// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* *-*-solaris* *-*-cygwin *-*-darwin* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } } +// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } } +// { dg-require-cstdint "" } +// { dg-require-gthreads-timed "" } + +// Copyright (C) 2008-2014 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 <mutex> +#include <system_error> +#include <testsuite_hooks.h> + +int main() +{ + bool test __attribute__((unused)) = true; + typedef std::recursive_timed_mutex mutex_type; + + try + { + // Unlock mutex that hasn't been locked. + mutex_type m; + m.unlock(); + } + catch (const std::system_error& e) + { + // POSIX == EPERM + VERIFY( true ); + } + catch (...) + { + VERIFY( false ); + } + + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/shared_future/cons/assign.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/shared_future/cons/assign.cc new file mode 100644 index 000000000..7b19aa191 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/shared_future/cons/assign.cc @@ -0,0 +1,44 @@ +// { dg-options "-std=gnu++0x" } +// { dg-require-cstdint "" } +// { dg-require-gthreads "" } +// { dg-require-atomic-builtins "" } + +// Copyright (C) 2010-2014 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 <future> +#include <testsuite_hooks.h> + +std::future<int> get() { return std::promise<int>().get_future(); } + +void test01() +{ + // assign + std::shared_future<int> p1; + std::shared_future<int> p2 = get(); + p1 = p2; + VERIFY( p1.valid() ); + VERIFY( p2.valid() ); +} + +int main() +{ + test01(); + return 0; +} + diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/shared_future/cons/constexpr.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/shared_future/cons/constexpr.cc new file mode 100644 index 000000000..ab7f85c1c --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/shared_future/cons/constexpr.cc @@ -0,0 +1,35 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x -fno-inline -save-temps -g0" } +// { dg-require-cstdint "" } +// { dg-require-gthreads "" } +// { dg-require-atomic-builtins "" } +// { dg-final { scan-assembler-not "_ZNSt13shared_futureIvEC2Ev" } } +// { dg-final { scan-assembler-not "_ZNSt13shared_futureIiEC2Ev" } } + +// Copyright (C) 2010-2014 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 <future> +#include <testsuite_common_types.h> + +int main() +{ + __gnu_test::constexpr_default_constructible test; //not literal + test.operator()<std::shared_future<int>>(); + test.operator()<std::shared_future<void>>(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/shared_future/cons/copy.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/shared_future/cons/copy.cc new file mode 100644 index 000000000..57a0cfdc3 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/shared_future/cons/copy.cc @@ -0,0 +1,42 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } +// { dg-require-cstdint "" } +// { dg-require-gthreads "" } +// { dg-require-atomic-builtins "" } + +// Copyright (C) 2009-2014 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 <future> +#include <testsuite_hooks.h> + +extern std::future<int>&& get(); + +void test01() +{ + using std::shared_future; + + shared_future<int> p1 = get(); + shared_future<int> p2(p1); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/shared_future/cons/default.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/shared_future/cons/default.cc new file mode 100644 index 000000000..2e78590d8 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/shared_future/cons/default.cc @@ -0,0 +1,51 @@ +// { dg-options "-std=gnu++0x" } +// { dg-require-cstdint "" } +// { dg-require-gthreads "" } +// { dg-require-atomic-builtins "" } + +// Copyright (C) 2010-2014 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 <future> +#include <testsuite_hooks.h> +#include <testsuite_tr1.h> + +void test01() +{ + using std::shared_future; + using namespace __gnu_test; + + bool __attribute__((unused)) test = true; + + shared_future<int> p1; + VERIFY( !p1.valid() ); + shared_future<int&> p2; + VERIFY( !p2.valid() ); + shared_future<void> p3; + VERIFY( !p3.valid() ); + shared_future<ClassType> p4; + VERIFY( !p4.valid() ); + shared_future<AbstractClass&> p5; + VERIFY( !p5.valid() ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/shared_future/cons/move.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/shared_future/cons/move.cc new file mode 100644 index 000000000..de67e3a10 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/shared_future/cons/move.cc @@ -0,0 +1,41 @@ +// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* *-*-solaris* *-*-cygwin *-*-darwin* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } } +// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } } +// { dg-require-cstdint "" } +// { dg-require-gthreads "" } +// { dg-require-atomic-builtins "" } + +// Copyright (C) 2009-2014 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 <future> + +void test01() +{ + // construct from rvalue future + std::promise<int> p1; + std::future<int> f1(p1.get_future()); + std::shared_future<int> f2(std::move(f1)); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/shared_future/cons/move_assign.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/shared_future/cons/move_assign.cc new file mode 100644 index 000000000..3b9f867ab --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/shared_future/cons/move_assign.cc @@ -0,0 +1,43 @@ +// { dg-options "-std=gnu++0x" } +// { dg-require-cstdint "" } +// { dg-require-gthreads "" } +// { dg-require-atomic-builtins "" } + +// Copyright (C) 2010-2014 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 <future> +#include <testsuite_hooks.h> + +std::future<int> get() { return std::promise<int>().get_future(); } + +void test01() +{ + // assign + std::shared_future<int> p1; + std::shared_future<int> p2 = get(); + p1 = std::move(p2); + VERIFY( p1.valid() ); + VERIFY( !p2.valid() ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/shared_future/members/45133.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/shared_future/members/45133.cc new file mode 100644 index 000000000..5723d64c0 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/shared_future/members/45133.cc @@ -0,0 +1,93 @@ +// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* *-*-solaris* *-*-cygwin *-*-darwin* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } } +// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } } +// { dg-require-cstdint "" } +// { dg-require-gthreads "" } +// { dg-require-atomic-builtins "" } + +// Copyright (C) 2010-2014 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/>. + +// 30.6.7 Class template shared_future [futures.shared_future] + +#include <future> +#include <testsuite_hooks.h> + +// This test verifies behaviour which is encouraged by a non-normative note, +// but not required. + +void +test01() +{ + bool test __attribute__((unused)) = true; + + std::shared_future<int> f; + try + { + f.get(); + VERIFY( false ); + } + catch (std::future_error& e) + { + VERIFY( e.code() == std::future_errc::no_state ); + } +} + +void +test02() +{ + bool test __attribute__((unused)) = true; + + std::shared_future<int&> f; + try + { + f.get(); + VERIFY( false ); + } + catch (std::future_error& e) + { + VERIFY( e.code() == std::future_errc::no_state ); + } +} + +void +test03() +{ + bool test __attribute__((unused)) = true; + + std::shared_future<void> f; + try + { + f.get(); + VERIFY( false ); + } + catch (std::future_error& e) + { + VERIFY( e.code() == std::future_errc::no_state ); + } +} + +int main() +{ + test01(); + test02(); + test03(); + + return 0; +} + diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/shared_future/members/get.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/shared_future/members/get.cc new file mode 100644 index 000000000..590c7183a --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/shared_future/members/get.cc @@ -0,0 +1,78 @@ +// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* *-*-solaris* *-*-cygwin *-*-darwin* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } } +// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } } +// { dg-require-cstdint "" } +// { dg-require-gthreads "" } +// { dg-require-atomic-builtins "" } + +// Copyright (C) 2009-2014 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 <future> +#include <testsuite_hooks.h> + +int value = 99; + +void test01() +{ + bool test __attribute__((unused)) = true; + + std::promise<int> p1; + const std::shared_future<int> f1(p1.get_future()); + std::shared_future<int> f2(f1); + + p1.set_value(value); + VERIFY( f1.get() == value ); + VERIFY( f2.get() == value ); +} + +void test02() +{ + bool test __attribute__((unused)) = true; + + std::promise<int&> p1; + const std::shared_future<int&> f1(p1.get_future()); + std::shared_future<int&> f2(f1); + + p1.set_value(value); + VERIFY( &f1.get() == &value ); + VERIFY( &f2.get() == &value ); +} + +void test03() +{ + bool test __attribute__((unused)) = true; + + std::promise<void> p1; + const std::shared_future<void> f1(p1.get_future()); + std::shared_future<void> f2(f1); + + p1.set_value(); + f1.get(); + f2.get(); +} + +int main() +{ + test01(); + test02(); + test03(); + + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/shared_future/members/get2.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/shared_future/members/get2.cc new file mode 100644 index 000000000..3c593d8ce --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/shared_future/members/get2.cc @@ -0,0 +1,127 @@ +// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* *-*-solaris* *-*-cygwin *-*-darwin* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } } +// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } } +// { dg-require-cstdint "" } +// { dg-require-gthreads "" } +// { dg-require-atomic-builtins "" } + +// Copyright (C) 2009-2014 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 <future> +#include <exception> +#include <testsuite_hooks.h> + +int value = 99; + +void test01() +{ + bool test __attribute__((unused)) = true; + + std::promise<int> p1; + std::shared_future<int> f1(p1.get_future()); + std::shared_future<int> f2(f1); + + p1.set_exception(std::make_exception_ptr(value)); + try + { + (void) f1.get(); + VERIFY( false ); + } + catch (int& e) + { + VERIFY( e == value ); + } + try + { + (void) f2.get(); + VERIFY( false ); + } + catch (int& e) + { + VERIFY( e == value ); + } +} + +void test02() +{ + bool test __attribute__((unused)) = true; + + std::promise<int&> p1; + std::shared_future<int&> f1(p1.get_future()); + std::shared_future<int&> f2(f1); + + p1.set_exception(std::make_exception_ptr(value)); + try + { + (void) f1.get(); + VERIFY( false ); + } + catch (int& e) + { + VERIFY( e == value ); + } + try + { + (void) f2.get(); + VERIFY( false ); + } + catch (int& e) + { + VERIFY( e == value ); + } +} + +void test03() +{ + bool test __attribute__((unused)) = true; + + std::promise<void> p1; + std::shared_future<void> f1(p1.get_future()); + std::shared_future<void> f2(f1); + + p1.set_exception(std::make_exception_ptr(value)); + try + { + f1.get(); + VERIFY( false ); + } + catch (int& e) + { + VERIFY( e == value ); + } + try + { + f2.get(); + VERIFY( false ); + } + catch (int& e) + { + VERIFY( e == value ); + } +} + +int main() +{ + test01(); + test02(); + test03(); + + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/shared_future/members/valid.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/shared_future/members/valid.cc new file mode 100644 index 000000000..078073ee2 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/shared_future/members/valid.cc @@ -0,0 +1,61 @@ +// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* *-*-solaris* *-*-cygwin *-*-darwin* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } } +// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } } +// { dg-require-cstdint "" } +// { dg-require-gthreads "" } +// { dg-require-atomic-builtins "" } + +// Copyright (C) 2010-2014 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 <future> +#include <testsuite_hooks.h> + +void test01() +{ + bool test __attribute__((unused)) = true; + + std::shared_future<int> f0; + + VERIFY( !f0.valid() ); + + std::promise<int> p1; + std::shared_future<int> f1(p1.get_future()); + std::shared_future<int> f2(f1); + + VERIFY( f1.valid() ); + VERIFY( f2.valid() ); + + p1.set_value(1); + + VERIFY( f1.valid() ); + VERIFY( f2.valid() ); + + f1 = std::move(f0); + + VERIFY( !f0.valid() ); + VERIFY( !f1.valid() ); + VERIFY( f2.valid() ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/shared_future/members/wait.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/shared_future/members/wait.cc new file mode 100644 index 000000000..702b26f0a --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/shared_future/members/wait.cc @@ -0,0 +1,56 @@ +// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* *-*-solaris* *-*-cygwin *-*-darwin* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } } +// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } } +// { dg-require-cstdint "" } +// { dg-require-gthreads "" } +// { dg-require-atomic-builtins "" } + +// Copyright (C) 2009-2014 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 <future> +#include <thread> +#include <mutex> +#include <testsuite_hooks.h> + +void fut_wait(std::shared_future<void> f) +{ + f.wait(); +} + +void test01() +{ + std::promise<void> p1; + std::shared_future<void> f1(p1.get_future()); + + std::thread t1(fut_wait, f1); + std::thread t2(fut_wait, f1); + std::thread t3(fut_wait, f1); + + p1.set_value(); + t1.join(); + t2.join(); + t3.join(); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/shared_future/members/wait_for.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/shared_future/members/wait_for.cc new file mode 100644 index 000000000..a3fae991d --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/shared_future/members/wait_for.cc @@ -0,0 +1,56 @@ +// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* *-*-solaris* *-*-cygwin *-*-darwin* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } } +// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } } +// { dg-require-cstdint "" } +// { dg-require-gthreads "" } +// { dg-require-atomic-builtins "" } + +// Copyright (C) 2009-2014 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 <future> +#include <chrono> +#include <testsuite_hooks.h> + +void test01() +{ + bool test __attribute__((unused)) = true; + + std::promise<int> p1; + std::shared_future<int> f1(p1.get_future()); + std::shared_future<int> f2(f1); + + std::chrono::milliseconds delay(100); + + VERIFY( f1.wait_for(delay) == std::future_status::timeout ); + VERIFY( f2.wait_for(delay) == std::future_status::timeout ); + + p1.set_value(1); + + auto before = std::chrono::system_clock::now(); + VERIFY( f1.wait_for(delay) == std::future_status::ready ); + VERIFY( f2.wait_for(delay) == std::future_status::ready ); + VERIFY( std::chrono::system_clock::now() < (before + 2*delay) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/shared_future/members/wait_until.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/shared_future/members/wait_until.cc new file mode 100644 index 000000000..37384e973 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/shared_future/members/wait_until.cc @@ -0,0 +1,64 @@ +// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* *-*-solaris* *-*-cygwin *-*-darwin* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } } +// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } } +// { dg-require-cstdint "" } +// { dg-require-gthreads "" } +// { dg-require-atomic-builtins "" } + +// Copyright (C) 2009-2014 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 <future> +#include <chrono> +#include <testsuite_hooks.h> + +std::chrono::system_clock::time_point make_time(int i) +{ + return std::chrono::system_clock::now() + std::chrono::milliseconds(i); +} + +void test01() +{ + bool test __attribute__((unused)) = true; + + std::promise<int> p1; + std::shared_future<int> f1(p1.get_future()); + std::shared_future<int> f2(f1); + + auto when = make_time(10); + VERIFY( f1.wait_until(make_time(10)) == std::future_status::timeout ); + VERIFY( std::chrono::system_clock::now() >= when ); + + when = make_time(10); + VERIFY( f2.wait_until(make_time(10)) == std::future_status::timeout ); + VERIFY( std::chrono::system_clock::now() >= when ); + + p1.set_value(1); + + when = make_time(100); + VERIFY( f1.wait_until(when) == std::future_status::ready ); + VERIFY( f2.wait_until(when) == std::future_status::ready ); + VERIFY( std::chrono::system_clock::now() < when ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/shared_future/requirements/explicit_instantiation.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/shared_future/requirements/explicit_instantiation.cc new file mode 100644 index 000000000..06876b0ca --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/shared_future/requirements/explicit_instantiation.cc @@ -0,0 +1,34 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } +// { dg-require-cstdint "" } +// { dg-require-gthreads "" } +// { dg-require-atomic-builtins "" } + +// Copyright (C) 2009-2014 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 <future> +#include <testsuite_tr1.h> + +using namespace __gnu_test; +using std::shared_future; +template class shared_future<int>; +template class shared_future<int&>; +template class shared_future<void>; +template class shared_future<ClassType>; +template class shared_future<ClassType&>; diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/shared_lock/cons/1.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/shared_lock/cons/1.cc new file mode 100644 index 000000000..c271577cf --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/shared_lock/cons/1.cc @@ -0,0 +1,53 @@ +// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-solaris* *-*-cygwin *-*-darwin* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++1y -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++1y -pthreads" { target *-*-solaris* } } +// { dg-options " -std=gnu++1y " { target *-*-cygwin *-*-darwin* } } +// { dg-require-cstdint "" } +// { dg-require-gthreads "" } + +// Copyright (C) 2013-2014 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 <shared_mutex> +#include <system_error> +#include <testsuite_hooks.h> + +int main() +{ + bool test __attribute__((unused)) = true; + typedef std::shared_timed_mutex mutex_type; + typedef std::shared_lock<mutex_type> lock_type; + + try + { + lock_type lock; + + VERIFY( !lock.owns_lock() ); + VERIFY( !(bool)lock ); + } + catch (const std::system_error& e) + { + VERIFY( false ); + } + catch (...) + { + VERIFY( false ); + } + + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/shared_lock/cons/2.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/shared_lock/cons/2.cc new file mode 100644 index 000000000..af01e0e66 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/shared_lock/cons/2.cc @@ -0,0 +1,54 @@ +// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-solaris* *-*-cygwin *-*-darwin* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++1y -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++1y -pthreads" { target *-*-solaris* } } +// { dg-options " -std=gnu++1y " { target *-*-cygwin *-*-darwin* } } +// { dg-require-cstdint "" } +// { dg-require-gthreads "" } + +// Copyright (C) 2013-2014 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 <shared_mutex> +#include <system_error> +#include <testsuite_hooks.h> + +int main() +{ + bool test __attribute__((unused)) = true; + typedef std::shared_timed_mutex mutex_type; + typedef std::shared_lock<mutex_type> lock_type; + + try + { + mutex_type m; + lock_type lock(m); + + VERIFY( lock.owns_lock() ); + VERIFY( (bool)lock ); + } + catch (const std::system_error& e) + { + VERIFY( false ); + } + catch (...) + { + VERIFY( false ); + } + + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/shared_lock/cons/3.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/shared_lock/cons/3.cc new file mode 100644 index 000000000..17023b410 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/shared_lock/cons/3.cc @@ -0,0 +1,54 @@ +// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-solaris* *-*-cygwin *-*-darwin* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++1y -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++1y -pthreads" { target *-*-solaris* } } +// { dg-options " -std=gnu++1y " { target *-*-cygwin *-*-darwin* } } +// { dg-require-cstdint "" } +// { dg-require-gthreads "" } + +// Copyright (C) 2013-2014 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 <shared_mutex> +#include <system_error> +#include <testsuite_hooks.h> + +int main() +{ + bool test __attribute__((unused)) = true; + typedef std::shared_timed_mutex mutex_type; + typedef std::shared_lock<mutex_type> lock_type; + + try + { + mutex_type m; + lock_type lock(m, std::defer_lock); + + VERIFY( !lock.owns_lock() ); + VERIFY( !(bool)lock ); + } + catch (const std::system_error& e) + { + VERIFY( false ); + } + catch (...) + { + VERIFY( false ); + } + + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/shared_lock/cons/4.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/shared_lock/cons/4.cc new file mode 100644 index 000000000..db761e1f5 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/shared_lock/cons/4.cc @@ -0,0 +1,54 @@ +// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-solaris* *-*-cygwin *-*-darwin* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++1y -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++1y -pthreads" { target *-*-solaris* } } +// { dg-options " -std=gnu++1y " { target *-*-cygwin *-*-darwin* } } +// { dg-require-cstdint "" } +// { dg-require-gthreads "" } + +// Copyright (C) 2013-2014 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 <shared_mutex> +#include <system_error> +#include <testsuite_hooks.h> + +int main() +{ + bool test __attribute__((unused)) = true; + typedef std::shared_timed_mutex mutex_type; + typedef std::shared_lock<mutex_type> lock_type; + + try + { + mutex_type m; + lock_type lock(m, std::try_to_lock); + + VERIFY( lock.owns_lock() ); + VERIFY( (bool)lock ); + } + catch (const std::system_error& e) + { + VERIFY( false ); + } + catch (...) + { + VERIFY( false ); + } + + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/shared_lock/cons/5.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/shared_lock/cons/5.cc new file mode 100644 index 000000000..712e68ca6 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/shared_lock/cons/5.cc @@ -0,0 +1,58 @@ +// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-solaris* *-*-cygwin *-*-darwin* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++1y -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++1y -pthreads" { target *-*-solaris* } } +// { dg-options " -std=gnu++1y " { target *-*-cygwin *-*-darwin* } } +// { dg-require-cstdint "" } +// { dg-require-gthreads-timed "" } + +// Copyright (C) 2013-2014 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 <chrono> +#include <shared_mutex> +#include <system_error> +#include <testsuite_hooks.h> + +int main() +{ + bool test __attribute__((unused)) = true; + typedef std::shared_timed_mutex mutex_type; + typedef std::shared_lock<mutex_type> lock_type; + typedef std::chrono::system_clock clock_type; + + try + { + clock_type::time_point t = clock_type::now() + std::chrono::seconds(5); + + mutex_type m; + lock_type lock(m, t); + + VERIFY( lock.owns_lock() ); + VERIFY( (bool)lock ); + } + catch (const std::system_error& e) + { + VERIFY( false ); + } + catch (...) + { + VERIFY( false ); + } + + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/shared_lock/cons/6.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/shared_lock/cons/6.cc new file mode 100644 index 000000000..bb1f902ac --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/shared_lock/cons/6.cc @@ -0,0 +1,58 @@ +// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-solaris* *-*-cygwin *-*-darwin* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++1y -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++1y -pthreads" { target *-*-solaris* } } +// { dg-options " -std=gnu++1y " { target *-*-cygwin *-*-darwin* } } +// { dg-require-cstdint "" } +// { dg-require-gthreads-timed "" } + +// Copyright (C) 2013-2014 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 <chrono> +#include <shared_mutex> +#include <system_error> +#include <testsuite_hooks.h> + +int main() +{ + bool test __attribute__((unused)) = true; + typedef std::shared_timed_mutex mutex_type; + typedef std::shared_lock<mutex_type> lock_type; + typedef std::chrono::system_clock clock_type; + + try + { + clock_type::duration d = std::chrono::seconds(5); + + mutex_type m; + lock_type lock(m, d); + + VERIFY( lock.owns_lock() ); + VERIFY( (bool)lock ); + } + catch (const std::system_error& e) + { + VERIFY( false ); + } + catch (...) + { + VERIFY( false ); + } + + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/shared_lock/locking/1.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/shared_lock/locking/1.cc new file mode 100644 index 000000000..ececeb007 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/shared_lock/locking/1.cc @@ -0,0 +1,61 @@ +// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-solaris* *-*-cygwin *-*-darwin* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++1y -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++1y -pthreads" { target *-*-solaris* } } +// { dg-options " -std=gnu++1y " { target *-*-cygwin *-*-darwin* } } +// { dg-require-cstdint "" } +// { dg-require-gthreads "" } + +// Copyright (C) 2013-2014 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 <shared_mutex> +#include <system_error> +#include <testsuite_hooks.h> + +int main() +{ + bool test __attribute__((unused)) = true; + typedef std::shared_timed_mutex mutex_type; + typedef std::shared_lock<mutex_type> lock_type; + + try + { + mutex_type m; + lock_type l(m, std::defer_lock); + + l.lock(); + + VERIFY( (bool)l ); + VERIFY( l.owns_lock() ); + + l.unlock(); + + VERIFY( !(bool)l ); + VERIFY( !l.owns_lock() ); + } + catch (const std::system_error& e) + { + VERIFY( false ); + } + catch (...) + { + VERIFY( false ); + } + + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/shared_lock/locking/2.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/shared_lock/locking/2.cc new file mode 100644 index 000000000..3f120ad44 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/shared_lock/locking/2.cc @@ -0,0 +1,106 @@ +// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-solaris* *-*-cygwin *-*-darwin* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++1y -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++1y -pthreads" { target *-*-solaris* } } +// { dg-options " -std=gnu++1y " { target *-*-cygwin *-*-darwin* } } +// { dg-require-cstdint "" } +// { dg-require-gthreads "" } + +// Copyright (C) 2013-2014 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 <shared_mutex> +#include <system_error> +#include <testsuite_hooks.h> + +void test01() +{ + bool test __attribute__((unused)) = true; + typedef std::shared_timed_mutex mutex_type; + typedef std::shared_lock<mutex_type> lock_type; + + try + { + lock_type l; + + // Lock shared_lock w/o mutex + try + { + l.lock(); + } + catch (const std::system_error& ex) + { + VERIFY( ex.code() == std::make_error_code + (std::errc::operation_not_permitted) ); + } + catch (...) + { + VERIFY( false ); + } + } + catch (const std::system_error& e) + { + VERIFY( false ); + } + catch (...) + { + VERIFY( false ); + } +} + + +void test02() +{ + bool test __attribute__((unused)) = true; + typedef std::shared_timed_mutex mutex_type; + typedef std::shared_lock<mutex_type> lock_type; + + try + { + mutex_type m; + lock_type l(m); + + // Lock already locked shared_lock. + try + { + l.lock(); + } + catch (const std::system_error& ex) + { + VERIFY( ex.code() == std::make_error_code + (std::errc::resource_deadlock_would_occur) ); + } + catch (...) + { + VERIFY( false ); + } + } + catch (const std::system_error& e) + { + VERIFY( false ); + } + catch (...) + { + VERIFY( false ); + } +} + +int main() +{ + test01(); + test02(); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/shared_lock/locking/3.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/shared_lock/locking/3.cc new file mode 100644 index 000000000..2770a75ed --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/shared_lock/locking/3.cc @@ -0,0 +1,67 @@ +// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-solaris* *-*-cygwin *-*-darwin* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++1y -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++1y -pthreads" { target *-*-solaris* } } +// { dg-options " -std=gnu++1y " { target *-*-cygwin *-*-darwin* } } +// { dg-require-cstdint "" } +// { dg-require-gthreads-timed "" } + +// Copyright (C) 2013-2014 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 <chrono> +#include <shared_mutex> +#include <system_error> +#include <testsuite_hooks.h> + +int main() +{ + bool test __attribute__((unused)) = true; + typedef std::shared_timed_mutex mutex_type; + typedef std::shared_lock<mutex_type> lock_type; + + try + { + mutex_type m; + lock_type l(m, std::defer_lock); + + try + { + l.try_lock_for(std::chrono::milliseconds(100)); + } + catch(const std::system_error&) + { + VERIFY( false ); + } + catch (...) + { + VERIFY( false ); + } + + VERIFY( l.owns_lock() ); + } + catch (const std::system_error&) + { + VERIFY( false ); + } + catch (...) + { + VERIFY( false ); + } + + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/shared_lock/locking/4.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/shared_lock/locking/4.cc new file mode 100644 index 000000000..8d11de9b0 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/shared_lock/locking/4.cc @@ -0,0 +1,69 @@ +// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-solaris* *-*-cygwin *-*-darwin* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++1y -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++1y -pthreads" { target *-*-solaris* } } +// { dg-options " -std=gnu++1y " { target *-*-cygwin *-*-darwin* } } +// { dg-require-cstdint "" } +// { dg-require-gthreads-timed "" } + +// Copyright (C) 2013-2014 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 <chrono> +#include <shared_mutex> +#include <system_error> +#include <testsuite_hooks.h> + +int main() +{ + bool test __attribute__((unused)) = true; + typedef std::shared_timed_mutex mutex_type; + typedef std::shared_lock<mutex_type> lock_type; + typedef std::chrono::system_clock clock_type; + + try + { + mutex_type m; + lock_type l(m, std::defer_lock); + clock_type::time_point t = clock_type::now() + std::chrono::seconds(1); + + try + { + l.try_lock_until(t); + } + catch(const std::system_error&) + { + VERIFY( false ); + } + catch (...) + { + VERIFY( false ); + } + + VERIFY( l.owns_lock() ); + } + catch (const std::system_error& e) + { + VERIFY( false ); + } + catch (...) + { + VERIFY( false ); + } + + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/shared_lock/modifiers/1.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/shared_lock/modifiers/1.cc new file mode 100644 index 000000000..03abcc4c8 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/shared_lock/modifiers/1.cc @@ -0,0 +1,68 @@ +// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-solaris* *-*-cygwin *-*-darwin* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++1y -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++1y -pthreads" { target *-*-solaris* } } +// { dg-options " -std=gnu++1y " { target *-*-cygwin *-*-darwin* } } +// { dg-require-cstdint "" } +// { dg-require-gthreads "" } + +// Copyright (C) 2013-2014 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 <shared_mutex> +#include <system_error> +#include <testsuite_hooks.h> + +int main() +{ + bool test __attribute__((unused)) = true; + typedef std::shared_timed_mutex mutex_type; + typedef std::shared_lock<mutex_type> lock_type; + + try + { + mutex_type m; + lock_type l1(m); + lock_type l2; + + try + { + l1.swap(l2); + } + catch (const std::system_error&) + { + VERIFY( false ); + } + catch(...) + { + VERIFY( false ); + } + + VERIFY( !(bool)l1 ); + VERIFY( (bool)l2 ); + } + catch (const std::system_error& e) + { + VERIFY( false ); + } + catch (...) + { + VERIFY( false ); + } + + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/shared_lock/modifiers/2.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/shared_lock/modifiers/2.cc new file mode 100644 index 000000000..a5e349373 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/shared_lock/modifiers/2.cc @@ -0,0 +1,68 @@ +// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-solaris* *-*-cygwin *-*-darwin* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++1y -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++1y -pthreads" { target *-*-solaris* } } +// { dg-options " -std=gnu++1y " { target *-*-cygwin *-*-darwin* } } +// { dg-require-cstdint "" } +// { dg-require-gthreads "" } + +// Copyright (C) 2013-2014 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 <shared_mutex> +#include <system_error> +#include <testsuite_hooks.h> + +int main() +{ + bool test __attribute__((unused)) = true; + typedef std::shared_timed_mutex mutex_type; + typedef std::shared_lock<mutex_type> lock_type; + + try + { + mutex_type m; + lock_type l1(m); + lock_type l2; + + try + { + l1.swap(l2); + } + catch (const std::system_error&) + { + VERIFY( false ); + } + catch(...) + { + VERIFY( false ); + } + + VERIFY( !(bool)l1 ); + VERIFY( (bool)l2 ); + } + catch (const std::system_error&) + { + VERIFY( false ); + } + catch (...) + { + VERIFY( false ); + } + + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/shared_lock/requirements/explicit_instantiation.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/shared_lock/requirements/explicit_instantiation.cc new file mode 100644 index 000000000..efd61565b --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/shared_lock/requirements/explicit_instantiation.cc @@ -0,0 +1,31 @@ +// { dg-do compile } +// { dg-options "-std=gnu++1y" } +// { dg-require-cstdint "" } +// { dg-require-gthreads "" } + +// Copyright (C) 2013-2014 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/>. + + +// NB: This file is for testing with NO OTHER INCLUDES. + +#include <shared_mutex> + +namespace std +{ + template class shared_lock<shared_timed_mutex>; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/shared_lock/requirements/typedefs.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/shared_lock/requirements/typedefs.cc new file mode 100644 index 000000000..738e7f147 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/shared_lock/requirements/typedefs.cc @@ -0,0 +1,33 @@ +// { dg-do compile } +// { dg-options "-std=gnu++1y" } +// { dg-require-cstdint "" } +// { dg-require-gthreads "" } + +// Copyright (C) 2013-2014 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/>. + + +// NB: This file is for testing with NO OTHER INCLUDES. + +#include <shared_mutex> + +void test01() +{ + // Check for required typedefs + typedef std::shared_lock<std::shared_timed_mutex> test_type; + typedef test_type::mutex_type mutex_type; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/shared_timed_mutex/cons/1.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/shared_timed_mutex/cons/1.cc new file mode 100644 index 000000000..b38cdbbcb --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/shared_timed_mutex/cons/1.cc @@ -0,0 +1,49 @@ +// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-solaris* *-*-cygwin *-*-darwin* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++1y -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++1y -pthreads" { target *-*-solaris* } } +// { dg-options " -std=gnu++1y " { target *-*-cygwin *-*-darwin* } } +// { dg-require-cstdint "" } +// { dg-require-gthreads "" } + +// Copyright (C) 2013-2014 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 <shared_mutex> +#include <system_error> +#include <testsuite_hooks.h> + +int main() +{ + bool test __attribute__((unused)) = true; + typedef std::shared_timed_mutex mutex_type; + + try + { + mutex_type m1; + } + catch (const std::system_error& e) + { + VERIFY( false ); + } + catch (...) + { + VERIFY( false ); + } + + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/shared_timed_mutex/cons/assign_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/shared_timed_mutex/cons/assign_neg.cc new file mode 100644 index 000000000..c8be74101 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/shared_timed_mutex/cons/assign_neg.cc @@ -0,0 +1,35 @@ +// { dg-do compile } +// { dg-options "-std=gnu++1y" } +// { dg-require-cstdint "" } +// { dg-require-gthreads "" } + +// Copyright (C) 2008-2014 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 <shared_mutex> + +void test01() +{ + // assign + typedef std::shared_timed_mutex mutex_type; + mutex_type m1; + mutex_type m2; + m1 = m2; // { dg-error "deleted" } +} + +// { dg-prune-output "include" } diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/shared_timed_mutex/cons/copy_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/shared_timed_mutex/cons/copy_neg.cc new file mode 100644 index 000000000..780c19341 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/shared_timed_mutex/cons/copy_neg.cc @@ -0,0 +1,34 @@ +// { dg-do compile } +// { dg-options "-std=gnu++1y" } +// { dg-require-cstdint "" } +// { dg-require-gthreads "" } + +// Copyright (C) 2013-2014 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 <shared_mutex> + +void test01() +{ + // assign + typedef std::shared_timed_mutex mutex_type; + mutex_type m1; + mutex_type m2(m1); // { dg-error "deleted" } +} + +// { dg-prune-output "include" } diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/shared_timed_mutex/requirements/standard_layout.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/shared_timed_mutex/requirements/standard_layout.cc new file mode 100644 index 000000000..3133b10eb --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/shared_timed_mutex/requirements/standard_layout.cc @@ -0,0 +1,31 @@ +// { dg-do compile } +// { dg-options "-std=gnu++1y" } +// { dg-require-cstdint "" } +// { dg-require-gthreads "" } + +// Copyright (C) 2013-2014 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 <shared_mutex> +#include <testsuite_common_types.h> + +void test01() +{ + __gnu_test::standard_layout test; + test.operator()<std::shared_timed_mutex>(); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/shared_timed_mutex/try_lock/1.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/shared_timed_mutex/try_lock/1.cc new file mode 100644 index 000000000..c13e05b57 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/shared_timed_mutex/try_lock/1.cc @@ -0,0 +1,52 @@ +// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-solaris* *-*-cygwin *-*-darwin* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++1y -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++1y -pthreads" { target *-*-solaris* } } +// { dg-options " -std=gnu++1y " { target *-*-cygwin *-*-darwin* } } +// { dg-require-cstdint "" } +// { dg-require-gthreads "" } + +// Copyright (C) 2013-2014 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 <shared_mutex> +#include <system_error> +#include <testsuite_hooks.h> + +int main() +{ + bool test __attribute__((unused)) = true; + typedef std::shared_timed_mutex mutex_type; + + try + { + mutex_type m; + bool b = m.try_lock(); + VERIFY( b ); + m.unlock(); + } + catch (const std::system_error& e) + { + VERIFY( false ); + } + catch (...) + { + VERIFY( false ); + } + + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/shared_timed_mutex/try_lock/2.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/shared_timed_mutex/try_lock/2.cc new file mode 100644 index 000000000..28f833ba6 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/shared_timed_mutex/try_lock/2.cc @@ -0,0 +1,67 @@ +// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-solaris* *-*-cygwin *-*-darwin* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++1y -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++1y -pthreads" { target *-*-solaris* } } +// { dg-options " -std=gnu++1y " { target *-*-cygwin *-*-darwin* } } +// { dg-require-cstdint "" } +// { dg-require-gthreads "" } + +// Copyright (C) 2013-2014 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 <shared_mutex> +#include <thread> +#include <system_error> +#include <testsuite_hooks.h> + +int main() +{ + bool test __attribute__((unused)) = true; + typedef std::shared_timed_mutex mutex_type; + + try + { + mutex_type m; + m.lock(); + bool b; + + std::thread t([&] { + try + { + b = m.try_lock(); + } + catch (const std::system_error& e) + { + VERIFY( false ); + } + }); + t.join(); + VERIFY( !b ); + + m.unlock(); + } + catch (const std::system_error& e) + { + VERIFY( false ); + } + catch (...) + { + VERIFY( false ); + } + + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/this_thread/1.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/this_thread/1.cc new file mode 100644 index 000000000..8ea38b6a0 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/this_thread/1.cc @@ -0,0 +1,49 @@ +// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* *-*-solaris* *-*-cygwin *-*-darwin* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* powerpc-ibm-aix* } } +// { 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-2014 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> +#include <system_error> +#include <testsuite_hooks.h> + +int main() +{ + bool test __attribute__((unused)) = true; + + try + { + std::thread::id id = std::this_thread::get_id(); + VERIFY( id != std::thread::id() ); + } + catch (const std::system_error&) + { + VERIFY( false ); + } + catch (...) + { + VERIFY( false ); + } + + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/this_thread/2.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/this_thread/2.cc new file mode 100644 index 000000000..8f91094de --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/this_thread/2.cc @@ -0,0 +1,48 @@ +// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* *-*-solaris* *-*-cygwin *-*-darwin* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* powerpc-ibm-aix* } } +// { 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-2014 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> +#include <system_error> +#include <testsuite_hooks.h> + +int main() +{ + bool test __attribute__((unused)) = true; + + try + { + std::this_thread::yield(); + } + catch (const std::system_error&) + { + VERIFY( false ); + } + catch (...) + { + VERIFY( false ); + } + + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/this_thread/3.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/this_thread/3.cc new file mode 100644 index 000000000..88406c5ac --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/this_thread/3.cc @@ -0,0 +1,65 @@ +// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* *-*-solaris* *-*-cygwin *-*-darwin* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } } +// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } } +// { dg-require-cstdint "" } +// { dg-require-gthreads "" } +// { dg-require-sleep "" } + +// Copyright (C) 2008-2014 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 <chrono> +#include <thread> +#include <system_error> +#include <testsuite_hooks.h> + +namespace chr = std::chrono; + +void foo() +{ + bool test __attribute__((unused)) = true; + + chr::system_clock::time_point begin = chr::system_clock::now(); + chr::microseconds ms(500); + + std::this_thread::sleep_for(ms); + + VERIFY( (chr::system_clock::now() - begin) >= ms ); +} + +int main() +{ + bool test __attribute__((unused)) = true; + + try + { + std::thread t(foo); + t.join(); + } + catch (const std::system_error&) + { + VERIFY( false ); + } + catch (...) + { + VERIFY( false ); + } + + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/this_thread/4.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/this_thread/4.cc new file mode 100644 index 000000000..1e585a697 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/this_thread/4.cc @@ -0,0 +1,65 @@ +// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* *-*-solaris* *-*-cygwin *-*-darwin* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } } +// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } } +// { dg-require-cstdint "" } +// { dg-require-gthreads "" } +// { dg-require-sleep "" } + +// Copyright (C) 2008-2014 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 <chrono> +#include <thread> +#include <system_error> +#include <testsuite_hooks.h> + +namespace chr = std::chrono; + +void foo() +{ + bool test __attribute__((unused)) = true; + + chr::system_clock::time_point begin = chr::system_clock::now(); + chr::microseconds ms(500); + + std::this_thread::sleep_until(chr::system_clock::now() + ms); + + VERIFY( (chr::system_clock::now() - begin) >= ms ); +} + +int main() +{ + bool test __attribute__((unused)) = true; + + try + { + std::thread t(foo); + t.join(); + } + catch (const std::system_error&) + { + VERIFY( false ); + } + catch (...) + { + VERIFY( false ); + } + + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/thread/adl.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/thread/adl.cc new file mode 100644 index 000000000..1f9aca146 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/thread/adl.cc @@ -0,0 +1,39 @@ +// { dg-do compile } +// { dg-options "-std=gnu++11" } +// { dg-require-cstdint "" } +// { dg-require-gthreads "" } + +// Copyright (C) 2012-2014 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> +#include <memory> +#include <functional> + +template<typename, typename...P> +void make_shared(P&&...) +{} + +struct C {}; + +void f(C){} + +// PR libstdc++/53872 +int main() +{ + std::thread t(std::bind(&::f, C())); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/thread/cons/1.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/thread/cons/1.cc new file mode 100644 index 000000000..273b34c4a --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/thread/cons/1.cc @@ -0,0 +1,52 @@ +// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* *-*-solaris* *-*-cygwin *-*-darwin* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* powerpc-ibm-aix* } } +// { 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-2014 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> +#include <system_error> +#include <testsuite_hooks.h> + +// thread default cons works +// thread default cons no throw +// thread default cons not joinable +int main() +{ + bool test __attribute__((unused)) = true; + + try + { + std::thread t; + VERIFY( !t.joinable() ); + } + catch (const std::system_error&) + { + VERIFY( false ); + } + catch (...) + { + VERIFY( false ); + } + + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/thread/cons/2.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/thread/cons/2.cc new file mode 100644 index 000000000..2c058fd67 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/thread/cons/2.cc @@ -0,0 +1,73 @@ +// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* *-*-solaris* *-*-cygwin *-*-darwin* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* powerpc-ibm-aix* } } +// { 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-2014 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 <functional> // std::ref +#include <thread> +#include <system_error> +#include <testsuite_hooks.h> + +void +free_function(std::thread::id& id) +{ + id = std::this_thread::get_id(); +} + +// thread::id default cons +// thread::id copy ctor +// thread variadic cons, c++ function +// thread variadic cons joinable +// thread join +// thread join postcondition not joinable +// thread join postcondition function called correctly +// this_thread::get_id +void test02() +{ + bool test __attribute__((unused)) = true; + + try + { + std::thread::id id1; + std::thread t(free_function, std::ref(id1)); + std::thread::id id2 = t.get_id(); + VERIFY( t.joinable() ); + t.join(); + VERIFY( !t.joinable() ); + VERIFY( id1 == id2 ); + } + catch (const std::system_error&) + { + VERIFY( false ); + } + catch (...) + { + VERIFY( false ); + } +} + +int main() +{ + test02(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/thread/cons/3.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/thread/cons/3.cc new file mode 100644 index 000000000..266d7b9b8 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/thread/cons/3.cc @@ -0,0 +1,92 @@ +// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* *-*-solaris* *-*-cygwin *-*-darwin* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* powerpc-ibm-aix* } } +// { 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-2014 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 <functional> // std::unary_function, std::ref +#include <thread> +#include <system_error> +#include <testsuite_hooks.h> + +struct copyable : public std::unary_function<std::thread::id&, void> +{ + copyable() = default; + ~copyable() = default; + copyable(const copyable& c) + { ++copy_count; } + + void operator()(std::thread::id& id) const + { + id = std::this_thread::get_id(); + } + + static int copy_count; +}; + +int copyable::copy_count = 0; + +// same as 2, but function is copyable function object +// thread variadic cons not copied when std::ref +// thread variadic cons copied when not std::ref +// no errors +void test03() +{ + bool test __attribute__((unused)) = true; + + try + { + std::thread::id t1_id1; + copyable c1; + std::thread t1(std::ref(c1), std::ref(t1_id1)); + std::thread::id t1_id2 = t1.get_id(); + VERIFY( t1.joinable() ); + t1.join(); + VERIFY( !t1.joinable() ); + VERIFY( t1_id1 == t1_id2 ); + VERIFY( copyable::copy_count == 0 ); + + std::thread::id t2_id1; + copyable c2; + std::thread t2(c2, std::ref(t2_id1)); + std::thread::id t2_id2 = t2.get_id(); + VERIFY( t2.joinable() ); + t2.join(); + VERIFY( !t2.joinable() ); + VERIFY( t2_id1 == t2_id2 ); + VERIFY( copyable::copy_count > 0 ); + } + catch (const std::system_error&) + { + VERIFY( false ); + } + catch (...) + { + VERIFY( false ); + } +} + +int main() +{ + test03(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/thread/cons/4.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/thread/cons/4.cc new file mode 100644 index 000000000..ae97783fd --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/thread/cons/4.cc @@ -0,0 +1,87 @@ +// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* *-*-solaris* *-*-cygwin *-*-darwin* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* powerpc-ibm-aix* } } +// { 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-2014 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 <functional> // std::unary_function, std::ref, std::cref +#include <thread> +#include <system_error> +#include <testsuite_hooks.h> + +struct noncopyable : std::unary_function<std::thread::id&, void> +{ + noncopyable() = default; + ~noncopyable() = default; + noncopyable(const noncopyable&) = delete; + noncopyable& operator=(const noncopyable&) = delete; + void operator()(std::thread::id& id) const + { + id = std::this_thread::get_id(); + } +}; + +// same as 3, but function is noncopyable function object +// thread variadic cons not copied when std::ref +// thread variadic cons copied when not std::ref +// thread variadic cons not copied when std::cref +// thread variadic cons copied when not std::cref +// no errors +void test03() +{ + bool test __attribute__((unused)) = true; + + try + { + std::thread::id t1_id1; + noncopyable nc1; + std::thread t1(std::ref(nc1), std::ref(t1_id1)); + std::thread::id t1_id2 = t1.get_id(); + VERIFY( t1.joinable() ); + t1.join(); + VERIFY( !t1.joinable() ); + VERIFY( t1_id1 == t1_id2 ); + + std::thread::id t2_id1; + noncopyable nc2; + std::thread t2(std::cref(nc2), std::ref(t2_id1)); + std::thread::id t2_id2 = t2.get_id(); + VERIFY( t2.joinable() ); + t2.join(); + VERIFY( !t2.joinable() ); + VERIFY( t2_id1 == t2_id2 ); + } + catch(const std::system_error&) + { + VERIFY( false ); + } + catch(...) + { + VERIFY( false ); + } +} + +int main() +{ + test03(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/thread/cons/49668.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/thread/cons/49668.cc new file mode 100644 index 000000000..0082259d4 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/thread/cons/49668.cc @@ -0,0 +1,51 @@ +// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* *-*-solaris* *-*-cygwin *-*-darwin* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } } +// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } } +// { dg-require-cstdint "" } +// { dg-require-gthreads "" } + +// Copyright (C) 2011-2014 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> +#include <functional> +#include <testsuite_hooks.h> + +struct moveable +{ + moveable() = default; + moveable(moveable&&) = default; + moveable(const moveable&) = delete; +}; + +typedef decltype(std::placeholders::_1) placeholder_type; + +void f(moveable, placeholder_type, bool& b) { b = true; } + +void test01() +{ + bool test = false; + std::thread t(f, moveable(), std::placeholders::_1, std::ref(test)); + t.join(); + VERIFY( test ); +} + +int main() +{ + test01(); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/thread/cons/5.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/thread/cons/5.cc new file mode 100644 index 000000000..20678b89f --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/thread/cons/5.cc @@ -0,0 +1,77 @@ +// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* *-*-solaris* *-*-cygwin *-*-darwin* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* powerpc-ibm-aix* } } +// { 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-2014 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 <functional> // std::unary_function, std::ref +#include <thread> +#include <system_error> +#include <testsuite_hooks.h> + +struct nonconst : public std::unary_function<std::thread::id&, void> +{ + void operator()(std::thread::id& id) + { + id = std::this_thread::get_id(); + } +}; + +void test01() +{ + bool test __attribute__((unused)) = true; + + try + { + std::thread::id t1_id1; + nonconst c1; + std::thread t1(std::ref(c1), std::ref(t1_id1)); + std::thread::id t1_id2 = t1.get_id(); + VERIFY( t1.joinable() ); + t1.join(); + VERIFY( !t1.joinable() ); + VERIFY( t1_id1 == t1_id2 ); + + std::thread::id t2_id1; + nonconst c2; + std::thread t2(c2, std::ref(t2_id1)); + std::thread::id t2_id2 = t2.get_id(); + VERIFY( t2.joinable() ); + t2.join(); + VERIFY( !t2.joinable() ); + VERIFY( t2_id1 == t2_id2 ); + } + catch (const std::system_error&) + { + VERIFY( false ); + } + catch (...) + { + VERIFY( false ); + } +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/thread/cons/6.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/thread/cons/6.cc new file mode 100644 index 000000000..736119ec9 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/thread/cons/6.cc @@ -0,0 +1,65 @@ +// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* *-*-solaris* *-*-cygwin *-*-darwin* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* powerpc-ibm-aix* } } +// { 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-2014 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> +#include <system_error> +#include <testsuite_hooks.h> + +bool f_was_called = false; + +void f() +{ + f_was_called = true; +} + +// thread non-variadic cons, c++ function +// thread join +// thread join postcondition function called correctly +// no errors +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/gcc-4.9/libstdc++-v3/testsuite/30_threads/thread/cons/7.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/thread/cons/7.cc new file mode 100644 index 000000000..0857ec59a --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/thread/cons/7.cc @@ -0,0 +1,72 @@ +// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* *-*-solaris* *-*-cygwin *-*-darwin* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* powerpc-ibm-aix* } } +// { 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-2014 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> +#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; + } +}; + +// same as 6, but function is copyable function object passed by reference +void test07() +{ + bool test __attribute__((unused)) = true; + + try + { + copyable c; + copyable& rc = c; + std::thread t(rc); + t.join(); + VERIFY( functor_was_called ); + } + catch (const std::system_error&) + { + VERIFY( false ); + } + catch (...) + { + VERIFY( false ); + } +} + +int main() +{ + test07(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/thread/cons/8.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/thread/cons/8.cc new file mode 100644 index 000000000..4feb19f28 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/thread/cons/8.cc @@ -0,0 +1,72 @@ +// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* *-*-solaris* *-*-cygwin *-*-darwin* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* powerpc-ibm-aix* } } +// { 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-2014 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> +#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; + } +}; + +// same as 6, but function object is movable +void test08() +{ + bool test __attribute__((unused)) = true; + + try + { + moveable m; + std::thread t(std::move(m)); + t.join(); + VERIFY( functor_was_called ); + } + catch (const std::system_error&) + { + VERIFY( false ); + } + catch (...) + { + VERIFY( false ); + } +} + +int main() +{ + test08(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/thread/cons/9.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/thread/cons/9.cc new file mode 100644 index 000000000..9331509d4 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/thread/cons/9.cc @@ -0,0 +1,83 @@ +// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* *-*-solaris* *-*-cygwin *-*-darwin* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* powerpc-ibm-aix* } } +// { 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-2014 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> +#include <system_error> +#include <testsuite_hooks.h> + +int total = 0; + +// Functor has internal state. +struct moveable +{ + int i; + + moveable() = default; + ~moveable() = default; + moveable(const moveable& c) = delete; + moveable& operator=(const moveable&) = delete; + + moveable(int j): i(j) { } + moveable(moveable&& m): i(m.i) { } + + void operator()() const { total += i; } +}; + +// Two threads called by same functor type, different functor objects +// that have different state. Make sure each thread calls the correct +// functor. +void test09() +{ + bool test __attribute__((unused)) = true; + + try + { + // first + moveable m1(60); + std::thread t1(std::move(m1)); + t1.join(); + VERIFY( total == 60 ); + + // second + moveable m2(600); + std::thread t2(std::move(m2)); + t2.join(); + VERIFY( total == 660 ); // Not 120... + } + catch (const std::system_error&) + { + VERIFY( false ); + } + catch (...) + { + VERIFY( false ); + } +} + +int main() +{ + test09(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/thread/cons/assign_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/thread/cons/assign_neg.cc new file mode 100644 index 000000000..f288012f0 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/thread/cons/assign_neg.cc @@ -0,0 +1,34 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } +// { dg-require-cstdint "" } +// { dg-require-gthreads "" } + +// Copyright (C) 2009-2014 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() +{ + // assign + typedef std::thread test_type; + test_type t1; + test_type t2; + t1 = t2; // { dg-error "deleted" } +} + +// { dg-prune-output "include" } diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/thread/cons/copy_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/thread/cons/copy_neg.cc new file mode 100644 index 000000000..fd7694f5e --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/thread/cons/copy_neg.cc @@ -0,0 +1,33 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } +// { dg-require-cstdint "" } +// { dg-require-gthreads "" } + +// Copyright (C) 2009-2014 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() +{ + // copy + typedef std::thread test_type; + test_type t1; + test_type t2(t1); // { dg-error "deleted" } +} + +// { dg-prune-output "include" } diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/thread/cons/moveable.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/thread/cons/moveable.cc new file mode 100644 index 000000000..a0fca8830 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/thread/cons/moveable.cc @@ -0,0 +1,77 @@ +// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* *-*-solaris* *-*-cygwin *-*-darwin* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* powerpc-ibm-aix* } } +// { 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-2014 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> +#include <utility> +#include <testsuite_hooks.h> + +struct moveable +{ + moveable() = default; + ~moveable() = default; + moveable(const moveable& c) = delete; + moveable& operator=(const moveable&) = delete; + moveable(moveable&&) { } + + void operator()() const { } +}; + + +void test01() +{ + bool test __attribute__((unused)) = true; + + moveable m; + std::thread b(std::move(m)); + std::thread::id id_initial = b.get_id(); + VERIFY( b.joinable() ); + VERIFY( id_initial != std::thread::id() ); + + // copy move construct + // copied new thread old id, original thread default id + std::thread c(std::move(b)); + VERIFY( c.joinable() ); + VERIFY( c.get_id() == id_initial ); + VERIFY( !b.joinable() ); + VERIFY( b.get_id() == std::thread::id() ); + + // copy move assign + std::thread d; + VERIFY( !d.joinable() ); + VERIFY( d.get_id() == std::thread::id() ); + d = std::move(c); + VERIFY( d.joinable() ); + VERIFY( d.get_id() == id_initial ); + VERIFY( !c.joinable() ); + VERIFY( c.get_id() == std::thread::id() ); + + d.join(); +} + +int main(void) +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/thread/id/hash.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/thread/id/hash.cc new file mode 100644 index 000000000..626f59259 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/thread/id/hash.cc @@ -0,0 +1,26 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } +// { dg-require-cstdint "" } +// { dg-require-gthreads "" } + +// Copyright (C) 2010-2014 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> + +// thread::id hash +std::hash<std::thread::id> h1; diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/thread/id/operators.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/thread/id/operators.cc new file mode 100644 index 000000000..6bd6cf097 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/thread/id/operators.cc @@ -0,0 +1,37 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } +// { dg-require-cstdint "" } +// { dg-require-gthreads "" } + +// Copyright (C) 2009-2014 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() +{ + // thread::id operators + std::thread::id id1; + std::thread::id id2; + + id1 == id2; + id1 != id2; + id1 < id2; + id1 > id2; + id1 >= id2; + id1 <= id2; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/thread/members/1.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/thread/members/1.cc new file mode 100644 index 000000000..6f9d1b5a3 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/thread/members/1.cc @@ -0,0 +1,53 @@ +// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* *-*-solaris* *-*-cygwin *-*-darwin* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* powerpc-ibm-aix* } } +// { 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-2014 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> +#include <system_error> +#include <testsuite_hooks.h> + +void f() { } + +int main() +{ + bool test __attribute__((unused)) = true; + + try + { + std::thread t(f); + VERIFY( t.joinable() ); + t.join(); + VERIFY( !t.joinable() ); + } + catch (const std::system_error&) + { + VERIFY( false ); + } + catch (...) + { + VERIFY( false ); + } + + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/thread/members/2.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/thread/members/2.cc new file mode 100644 index 000000000..d7f9320fb --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/thread/members/2.cc @@ -0,0 +1,53 @@ +// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* *-*-solaris* *-*-cygwin *-*-darwin* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* powerpc-ibm-aix* } } +// { 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-2014 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> +#include <system_error> +#include <testsuite_hooks.h> + +void f() { } + +int main() +{ + bool test __attribute__((unused)) = true; + + try + { + std::thread t(f); + VERIFY( t.joinable() ); + t.detach(); + VERIFY( !t.joinable() ); + } + catch (const std::system_error&) + { + VERIFY( false ); + } + catch (...) + { + VERIFY( false ); + } + + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/thread/members/3.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/thread/members/3.cc new file mode 100644 index 000000000..01c4ea172 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/thread/members/3.cc @@ -0,0 +1,53 @@ +// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* *-*-solaris* *-*-cygwin *-*-darwin* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* powerpc-ibm-aix* } } +// { 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-2014 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> +#include <system_error> +#include <testsuite_hooks.h> + +void f() { } + +int main() +{ + bool test __attribute__((unused)) = true; + + try + { + std::thread t(f); + VERIFY( t.get_id() != std::thread::id() ); + t.join(); + VERIFY( t.get_id() == std::thread::id() ); + } + catch (const std::system_error&) + { + VERIFY( false ); + } + catch (...) + { + VERIFY( false ); + } + + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/thread/members/4.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/thread/members/4.cc new file mode 100644 index 000000000..23e4a8cc8 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/thread/members/4.cc @@ -0,0 +1,48 @@ +// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* *-*-solaris* *-*-cygwin *-*-darwin* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* powerpc-ibm-aix* } } +// { 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-2014 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> +#include <system_error> +#include <testsuite_hooks.h> + +int main() +{ + bool test = false; + + std::thread t; + + try + { + t.join(); + } + catch (const std::system_error&) + { + test = true; + } + + VERIFY( test ); + + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/thread/members/5.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/thread/members/5.cc new file mode 100644 index 000000000..dd141c41e --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/thread/members/5.cc @@ -0,0 +1,48 @@ +// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* *-*-solaris* *-*-cygwin *-*-darwin* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* powerpc-ibm-aix* } } +// { 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-2014 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> +#include <system_error> +#include <testsuite_hooks.h> + +int main() +{ + bool test = false; + + std::thread t; + + try + { + t.detach(); + } + catch (const std::system_error&) + { + test = true; + } + + VERIFY( test ); + + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/thread/members/hardware_concurrency.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/thread/members/hardware_concurrency.cc new file mode 100644 index 000000000..f7f8e3ffa --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/thread/members/hardware_concurrency.cc @@ -0,0 +1,36 @@ +// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* *-*-solaris* *-*-cygwin *-*-darwin* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } } +// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } } +// { dg-require-cstdint "" } +// { dg-require-gthreads "" } +// { dg-require-nprocs "" } + +// Copyright (C) 2009-2014 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> +#include <testsuite_hooks.h> + +int main() +{ + bool test __attribute__((unused)) = true; + + VERIFY( std::thread::hardware_concurrency() >= 1 ); + + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/thread/native_handle/cancel.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/thread/native_handle/cancel.cc new file mode 100644 index 000000000..d2fd5d859 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/thread/native_handle/cancel.cc @@ -0,0 +1,44 @@ +// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* *-*-solaris* *-*-cygwin *-*-darwin* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } } +// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } } +// { dg-require-cstdint "" } +// { dg-require-gthreads "" } + +// Copyright (C) 2012-2014 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 <pthread.h> +#include <thread> +#include <atomic> + +void f(std::atomic<bool>& started) +{ + started = true; + while (true) + std::this_thread::sleep_for(std::chrono::milliseconds(100)); +} + +int main() +{ + std::atomic<bool> started{ false }; + std::thread t(f, std::ref(started)); + while (!started) + std::this_thread::sleep_for(std::chrono::milliseconds(100)); + pthread_cancel(t.native_handle()); + t.join(); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/thread/native_handle/typesizes.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/thread/native_handle/typesizes.cc new file mode 100644 index 000000000..a976dc289 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/thread/native_handle/typesizes.cc @@ -0,0 +1,32 @@ +// { dg-do run { target *-*-linux* *-*-gnu* *-*-solaris* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthread" { target *-*-linux* *-*-gnu* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } } +// { dg-require-cstdint "" } +// { dg-require-gthreads "" } + +// Copyright (C) 2009-2014 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> +#include <thread/all.h> + +int main() +{ + typedef std::thread test_type; + __gnu_test::compare_type_to_native_type<test_type>(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/thread/swap/1.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/thread/swap/1.cc new file mode 100644 index 000000000..271e0b9a3 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/thread/swap/1.cc @@ -0,0 +1,93 @@ +// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* *-*-solaris* *-*-cygwin *-*-darwin* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* powerpc-ibm-aix* } } +// { 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-2014 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> +#include <system_error> +#include <bits/move.h> // std::move +#include <testsuite_hooks.h> + +void f() { } + +void test01() +{ + bool test __attribute__((unused)) = true; + + try + { + std::thread t1(f); + std::thread::id t1_id = t1.get_id(); + + std::thread t2; + + t2.swap(t1); + VERIFY( t1.get_id() == std::thread::id() ); + VERIFY( t2.get_id() == t1_id ); + + t2.join(); + } + catch (const std::system_error&) + { + VERIFY( false ); + } + catch (...) + { + VERIFY( false ); + } +} + +void test02() +{ + bool test __attribute__((unused)) = true; + + try + { + std::thread t1(f); + std::thread::id t1_id = t1.get_id(); + + std::thread t2; + + std::swap(t1, t2); + VERIFY( t1.get_id() == std::thread::id() ); + VERIFY( t2.get_id() == t1_id ); + + t2.join(); + } + catch (const std::system_error&) + { + VERIFY( false ); + } + catch (...) + { + VERIFY( false ); + } +} + +int main() +{ + test01(); + test02(); + + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/timed_mutex/cons/1.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/timed_mutex/cons/1.cc new file mode 100644 index 000000000..6576aafe4 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/timed_mutex/cons/1.cc @@ -0,0 +1,49 @@ +// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* *-*-solaris* *-*-cygwin *-*-darwin* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } } +// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } } +// { dg-require-cstdint "" } +// { dg-require-gthreads-timed "" } + +// Copyright (C) 2008-2014 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 <mutex> +#include <system_error> +#include <testsuite_hooks.h> + +int main() +{ + bool test __attribute__((unused)) = true; + typedef std::timed_mutex mutex_type; + + try + { + mutex_type m1; + } + catch (const std::system_error& e) + { + VERIFY( false ); + } + catch (...) + { + VERIFY( false ); + } + + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/timed_mutex/cons/assign_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/timed_mutex/cons/assign_neg.cc new file mode 100644 index 000000000..9df0b258c --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/timed_mutex/cons/assign_neg.cc @@ -0,0 +1,35 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } +// { dg-require-cstdint "" } +// { dg-require-gthreads-timed "" } + +// Copyright (C) 2008-2014 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 <mutex> + +void test01() +{ + // assign + typedef std::timed_mutex mutex_type; + mutex_type m1; + mutex_type m2; + m1 = m2; // { dg-error "deleted" } +} + +// { dg-prune-output "include" } diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/timed_mutex/cons/copy_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/timed_mutex/cons/copy_neg.cc new file mode 100644 index 000000000..2d43524c5 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/timed_mutex/cons/copy_neg.cc @@ -0,0 +1,34 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } +// { dg-require-cstdint "" } +// { dg-require-gthreads-timed "" } + +// Copyright (C) 2008-2014 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 <mutex> + +void test01() +{ + // assign + typedef std::timed_mutex mutex_type; + mutex_type m1; + mutex_type m2(m1); // { dg-error "deleted" } +} + +// { dg-prune-output "include" } diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/timed_mutex/dest/destructor_locked.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/timed_mutex/dest/destructor_locked.cc new file mode 100644 index 000000000..f871a035d --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/timed_mutex/dest/destructor_locked.cc @@ -0,0 +1,51 @@ +// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* *-*-solaris* *-*-cygwin *-*-darwin* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } } +// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } } +// { dg-require-cstdint "" } +// { dg-require-gthreads-timed "" } + +// Copyright (C) 2008-2014 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 <mutex> +#include <system_error> +#include <testsuite_hooks.h> + +int main() +{ + bool test __attribute__((unused)) = true; + typedef std::timed_mutex mutex_type; + + try + { + mutex_type m; + m.lock(); + } + catch (const std::system_error& e) + { + // Destroying locked mutex raises system error, or undefined. + // POSIX == may fail with EBUSY. + } + catch (...) + { + VERIFY( false ); + } + + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/timed_mutex/lock/1.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/timed_mutex/lock/1.cc new file mode 100644 index 000000000..d5c12bb5c --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/timed_mutex/lock/1.cc @@ -0,0 +1,63 @@ +// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* *-*-solaris* *-*-cygwin *-*-darwin* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } } +// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } } +// { dg-require-cstdint "" } +// { dg-require-gthreads-timed "" } + +// Copyright (C) 2008-2014 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 <mutex> +#include <system_error> +#include <testsuite_hooks.h> + +int main() +{ + bool test __attribute__((unused)) = true; + typedef std::timed_mutex mutex_type; + + try + { + mutex_type m; + m.lock(); + + // Lock already locked mutex. + try + { + // XXX Will block. + // m.lock(); + } + catch (const std::system_error& e) + { + VERIFY( false ); + } + + m.unlock(); + } + catch (const std::system_error& e) + { + VERIFY( false ); + } + catch (...) + { + VERIFY( false ); + } + + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/timed_mutex/native_handle/1.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/timed_mutex/native_handle/1.cc new file mode 100644 index 000000000..9475fcb70 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/timed_mutex/native_handle/1.cc @@ -0,0 +1,51 @@ +// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* *-*-solaris* *-*-cygwin *-*-darwin* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } } +// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } } +// { dg-require-cstdint "" } +// { dg-require-gthreads-timed "" } + +// Copyright (C) 2008-2014 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 <mutex> +#include <system_error> +#include <testsuite_hooks.h> + +int main() +{ + bool test __attribute__((unused)) = true; + typedef std::timed_mutex mutex_type; + + try + { + mutex_type m; + mutex_type::native_handle_type n = m.native_handle(); + (void)n; + } + catch (const std::system_error& e) + { + VERIFY( false ); + } + catch (...) + { + VERIFY( false ); + } + + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/timed_mutex/native_handle/typesizes.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/timed_mutex/native_handle/typesizes.cc new file mode 100644 index 000000000..dc771e568 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/timed_mutex/native_handle/typesizes.cc @@ -0,0 +1,33 @@ +// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* *-*-solaris* *-*-cygwin *-*-darwin* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } } +// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } } +// { dg-require-cstdint "" } +// { dg-require-gthreads-timed "" } + +// Copyright (C) 2009-2014 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 <mutex> +#include <thread/all.h> + +int main() +{ + typedef std::timed_mutex test_type; + __gnu_test::compare_type_to_native_type<test_type>(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/timed_mutex/requirements/standard_layout.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/timed_mutex/requirements/standard_layout.cc new file mode 100644 index 000000000..c0196a538 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/timed_mutex/requirements/standard_layout.cc @@ -0,0 +1,31 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } +// { dg-require-cstdint "" } +// { dg-require-gthreads-timed "" } + +// Copyright (C) 2009-2014 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 <mutex> +#include <testsuite_common_types.h> + +void test01() +{ + __gnu_test::standard_layout test; + test.operator()<std::timed_mutex>(); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/timed_mutex/requirements/typedefs.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/timed_mutex/requirements/typedefs.cc new file mode 100644 index 000000000..e1a2c68fe --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/timed_mutex/requirements/typedefs.cc @@ -0,0 +1,33 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } +// { dg-require-cstdint "" } +// { dg-require-gthreads-timed "" } + +// 2008-07-23 Chris Fairles <chris.fairles@gmail.com> + +// Copyright (C) 2008-2014 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 <mutex> + +void test01() +{ + // Check for required typedefs + typedef std::timed_mutex test_type; + typedef test_type::native_handle_type type; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/timed_mutex/try_lock/1.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/timed_mutex/try_lock/1.cc new file mode 100644 index 000000000..b14d8793a --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/timed_mutex/try_lock/1.cc @@ -0,0 +1,52 @@ +// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* *-*-solaris* *-*-cygwin *-*-darwin* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } } +// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } } +// { dg-require-cstdint "" } +// { dg-require-gthreads-timed "" } + +// Copyright (C) 2008-2014 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 <mutex> +#include <system_error> +#include <testsuite_hooks.h> + +int main() +{ + bool test __attribute__((unused)) = true; + typedef std::timed_mutex mutex_type; + + try + { + mutex_type m; + bool b = m.try_lock(); + VERIFY( b ); + m.unlock(); + } + catch (const std::system_error& e) + { + VERIFY( false ); + } + catch (...) + { + VERIFY( false ); + } + + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/timed_mutex/try_lock/2.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/timed_mutex/try_lock/2.cc new file mode 100644 index 000000000..8ab64bbdb --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/timed_mutex/try_lock/2.cc @@ -0,0 +1,63 @@ +// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* *-*-solaris* *-*-cygwin *-*-darwin* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } } +// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } } +// { dg-require-cstdint "" } +// { dg-require-gthreads-timed "" } + +// Copyright (C) 2008-2014 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 <mutex> +#include <system_error> +#include <testsuite_hooks.h> + +int main() +{ + bool test __attribute__((unused)) = true; + typedef std::timed_mutex mutex_type; + + try + { + mutex_type m; + m.lock(); + bool b; + + try + { + b = m.try_lock(); + VERIFY( !b ); + } + catch (const std::system_error& e) + { + VERIFY( false ); + } + + m.unlock(); + } + catch (const std::system_error& e) + { + VERIFY( false ); + } + catch (...) + { + VERIFY( false ); + } + + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/timed_mutex/try_lock_for/1.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/timed_mutex/try_lock_for/1.cc new file mode 100644 index 000000000..48c55af82 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/timed_mutex/try_lock_for/1.cc @@ -0,0 +1,53 @@ +// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* *-*-solaris* *-*-cygwin *-*-darwin* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } } +// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } } +// { dg-require-cstdint "" } +// { dg-require-gthreads-timed "" } + +// Copyright (C) 2008-2014 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 <mutex> +#include <chrono> +#include <system_error> +#include <testsuite_hooks.h> + +int main() +{ + bool test __attribute__((unused)) = true; + typedef std::timed_mutex mutex_type; + + try + { + mutex_type m; + bool b = m.try_lock_for(std::chrono::seconds(1)); + VERIFY( b ); + m.unlock(); + } + catch (const std::system_error& e) + { + VERIFY( false ); + } + catch (...) + { + VERIFY( false ); + } + + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/timed_mutex/try_lock_for/2.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/timed_mutex/try_lock_for/2.cc new file mode 100644 index 000000000..4a40b3c88 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/timed_mutex/try_lock_for/2.cc @@ -0,0 +1,54 @@ +// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* *-*-solaris* *-*-cygwin *-*-darwin* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } } +// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } } +// { dg-require-cstdint "" } +// { dg-require-gthreads-timed "" } + +// Copyright (C) 2008-2014 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 <mutex> +#include <chrono> +#include <system_error> +#include <testsuite_hooks.h> + +int main() +{ + bool test __attribute__((unused)) = true; + typedef std::timed_mutex mutex_type; + typedef std::chrono::duration<int64_t, std::pico> picoseconds; + + try + { + mutex_type m; + bool b = m.try_lock_for(picoseconds(1)); + VERIFY( b ); + m.unlock(); + } + catch (const std::system_error& e) + { + VERIFY( false ); + } + catch (...) + { + VERIFY( false ); + } + + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/timed_mutex/try_lock_for/3.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/timed_mutex/try_lock_for/3.cc new file mode 100644 index 000000000..82951db24 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/timed_mutex/try_lock_for/3.cc @@ -0,0 +1,65 @@ +// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* *-*-solaris* *-*-cygwin *-*-darwin* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } } +// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } } +// { dg-require-cstdint "" } +// { dg-require-gthreads-timed "" } + +// Copyright (C) 2008-2014 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 <mutex> +#include <system_error> +#include <testsuite_hooks.h> + +int main() +{ + bool test __attribute__((unused)) = true; + typedef std::timed_mutex mutex_type; + + std::chrono::seconds s(1); + + try + { + mutex_type m; + m.lock(); + bool b; + + try + { + b = m.try_lock_for(s); + VERIFY( !b ); + } + catch (const std::system_error& e) + { + VERIFY( false ); + } + + m.unlock(); + } + catch (const std::system_error& e) + { + VERIFY( false ); + } + catch (...) + { + VERIFY( false ); + } + + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/timed_mutex/try_lock_until/1.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/timed_mutex/try_lock_until/1.cc new file mode 100644 index 000000000..b14d8793a --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/timed_mutex/try_lock_until/1.cc @@ -0,0 +1,52 @@ +// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* *-*-solaris* *-*-cygwin *-*-darwin* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } } +// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } } +// { dg-require-cstdint "" } +// { dg-require-gthreads-timed "" } + +// Copyright (C) 2008-2014 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 <mutex> +#include <system_error> +#include <testsuite_hooks.h> + +int main() +{ + bool test __attribute__((unused)) = true; + typedef std::timed_mutex mutex_type; + + try + { + mutex_type m; + bool b = m.try_lock(); + VERIFY( b ); + m.unlock(); + } + catch (const std::system_error& e) + { + VERIFY( false ); + } + catch (...) + { + VERIFY( false ); + } + + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/timed_mutex/try_lock_until/2.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/timed_mutex/try_lock_until/2.cc new file mode 100644 index 000000000..8ab64bbdb --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/timed_mutex/try_lock_until/2.cc @@ -0,0 +1,63 @@ +// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* *-*-solaris* *-*-cygwin *-*-darwin* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } } +// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } } +// { dg-require-cstdint "" } +// { dg-require-gthreads-timed "" } + +// Copyright (C) 2008-2014 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 <mutex> +#include <system_error> +#include <testsuite_hooks.h> + +int main() +{ + bool test __attribute__((unused)) = true; + typedef std::timed_mutex mutex_type; + + try + { + mutex_type m; + m.lock(); + bool b; + + try + { + b = m.try_lock(); + VERIFY( !b ); + } + catch (const std::system_error& e) + { + VERIFY( false ); + } + + m.unlock(); + } + catch (const std::system_error& e) + { + VERIFY( false ); + } + catch (...) + { + VERIFY( false ); + } + + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/timed_mutex/try_lock_until/57641.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/timed_mutex/try_lock_until/57641.cc new file mode 100644 index 000000000..e51cf5fba --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/timed_mutex/try_lock_until/57641.cc @@ -0,0 +1,69 @@ +// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* *-*-solaris* *-*-cygwin *-*-darwin* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } } +// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } } +// { dg-require-cstdint "" } +// { dg-require-gthreads-timed "" } + +// Copyright (C) 2013-2014 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 <mutex> +#include <chrono> +#include <thread> +#include <testsuite_hooks.h> + +// PR libstdc++/57641 + +namespace C = std::chrono; + +// custom clock with epoch 10s before system_clock's +struct clock +{ + typedef C::system_clock::rep rep; + typedef C::system_clock::period period; + typedef C::system_clock::duration duration; + typedef C::time_point<clock> time_point; + static constexpr bool is_steady = C::system_clock::is_steady; + + static time_point + now() + { + auto sys_time = C::system_clock::now().time_since_epoch(); + return time_point(sys_time + C::seconds(10)); + } +}; + +std::timed_mutex mx; +bool test = false; + +void f() +{ + test = mx.try_lock_until(clock::now() + C::milliseconds(1)); +} + +int main() +{ + bool test = false; + std::lock_guard<std::timed_mutex> l(mx); + auto start = C::system_clock::now(); + std::thread t(f); + t.join(); + auto stop = C::system_clock::now(); + VERIFY( (stop - start) < C::seconds(9) ); + VERIFY( !test ); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/timed_mutex/unlock/1.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/timed_mutex/unlock/1.cc new file mode 100644 index 000000000..6c2162ffd --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/timed_mutex/unlock/1.cc @@ -0,0 +1,52 @@ +// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* *-*-solaris* *-*-cygwin *-*-darwin* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } } +// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } } +// { dg-require-cstdint "" } +// { dg-require-gthreads-timed "" } + +// Copyright (C) 2008-2014 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 <mutex> +#include <system_error> +#include <testsuite_hooks.h> + +int main() +{ + bool test __attribute__((unused)) = true; + typedef std::timed_mutex mutex_type; + + try + { + // Unlock mutex that hasn't been locked. + mutex_type m; + m.unlock(); + } + catch (const std::system_error& e) + { + // POSIX == EPERM + VERIFY( true ); + } + catch (...) + { + VERIFY( false ); + } + + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/try_lock/1.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/try_lock/1.cc new file mode 100644 index 000000000..5a2648d75 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/try_lock/1.cc @@ -0,0 +1,63 @@ +// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* *-*-solaris* *-*-cygwin *-*-darwin* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* powerpc-ibm-aix* } } +// { 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-2014 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 <mutex> +#include <system_error> +#include <testsuite_hooks.h> + +int main() +{ + bool test __attribute__((unused)) = true; + typedef std::mutex mutex_type; + typedef std::unique_lock<mutex_type> lock_type; + + try + { + mutex_type m1, m2, m3; + lock_type l1(m1, std::defer_lock), + l2(m2, std::defer_lock), + l3(m3, std::defer_lock); + + try + { + int result = std::try_lock(l1, l2, l3); + VERIFY( result == -1 ); + } + catch (const std::system_error& e) + { + VERIFY( false ); + } + } + catch (const std::system_error& e) + { + VERIFY( false ); + } + catch (...) + { + VERIFY( false ); + } + + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/try_lock/2.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/try_lock/2.cc new file mode 100644 index 000000000..bbf93e2e3 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/try_lock/2.cc @@ -0,0 +1,110 @@ +// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* *-*-solaris* *-*-cygwin *-*-darwin* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* powerpc-ibm-aix* } } +// { 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-2014 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 <mutex> +#include <system_error> +#include <testsuite_hooks.h> + +typedef std::unique_lock<std::mutex> lock_type; + +void test01() +{ + bool test __attribute__((unused)) = true; + + try + { + std::mutex m1, m2, m3; + lock_type l1(m1); + int result = std::try_lock(m1, m2, m3); + VERIFY( result == 0 ); + VERIFY( l1.owns_lock() ); + lock_type l2(m2); + lock_type l3(m3); + } + catch (const std::system_error& e) + { + VERIFY( false ); + } + catch (...) + { + VERIFY( false ); + } +} + +void test02() +{ + bool test __attribute__((unused)) = true; + + try + { + std::mutex m1, m2, m3; + lock_type l2(m2); + int result = std::try_lock(m1, m2, m3); + VERIFY( result == 1 ); + VERIFY( l2.owns_lock() ); + lock_type l1(m1); + lock_type l3(m3); + } + catch (const std::system_error& e) + { + VERIFY( false ); + } + catch (...) + { + VERIFY( false ); + } +} + +void test03() +{ + bool test __attribute__((unused)) = true; + + try + { + std::mutex m1, m2, m3; + lock_type l3(m3); + int result = std::try_lock(m1, m2, m3); + VERIFY( result == 2 ); + VERIFY( l3.owns_lock() ); + lock_type l1(m1); + lock_type l2(m2); + } + catch (const std::system_error& e) + { + VERIFY( false ); + } + catch (...) + { + VERIFY( false ); + } +} + +int main() +{ + test01(); + test02(); + test03(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/try_lock/3.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/try_lock/3.cc new file mode 100644 index 000000000..e91f56385 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/try_lock/3.cc @@ -0,0 +1,91 @@ +// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* *-*-solaris* *-*-cygwin *-*-darwin* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* powerpc-ibm-aix* } } +// { 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-2014 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 <mutex> +#include <system_error> +#include <testsuite_hooks.h> + +struct user_lock +{ + user_lock() : is_locked(false) { } + ~user_lock() = default; + user_lock(const user_lock&) = default; + + void lock() + { + bool test __attribute__((unused)) = true; + VERIFY( !is_locked ); + is_locked = true; + } + + bool try_lock() + { return is_locked ? false : (is_locked = true); } + + void unlock() + { + bool test __attribute__((unused)) = true; + VERIFY( is_locked ); + is_locked = false; + } + +private: + bool is_locked; +}; + +int main() +{ + bool test __attribute__((unused)) = true; + + try + { + std::mutex m1; + std::recursive_mutex m2; + user_lock m3; + + try + { + //heterogeneous types + int result = std::try_lock(m1, m2, m3); + VERIFY( result == -1 ); + m1.unlock(); + m2.unlock(); + m3.unlock(); + } + catch (const std::system_error& e) + { + VERIFY( false ); + } + } + catch (const std::system_error& e) + { + VERIFY( false ); + } + catch (...) + { + VERIFY( false ); + } + + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/try_lock/4.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/try_lock/4.cc new file mode 100644 index 000000000..de9b69eef --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/try_lock/4.cc @@ -0,0 +1,153 @@ +// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* *-*-solaris* *-*-cygwin *-*-darwin* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } } +// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } } +// { dg-require-cstdint "" } +// { dg-require-gthreads "" } + +// Copyright (C) 2010-2014 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 <mutex> +#include <testsuite_hooks.h> + +struct unreliable_lock +{ + std::mutex m; + std::unique_lock<std::mutex> l; + + static int count; + static int throw_on; + static int lock_on; + + unreliable_lock() : l(m, std::defer_lock) { } + + ~unreliable_lock() + { + bool test __attribute__((unused)) = true; + VERIFY( !l.owns_lock() ); + } + + void lock() + { + if (count == throw_on) + throw throw_on; + ++count; + l.lock(); + } + bool try_lock() + { + if (count == throw_on) + throw throw_on; + std::unique_lock<std::mutex> l2(m, std::defer_lock); + if (count == lock_on) + l2.lock(); + ++count; + return l.try_lock(); + } + + void unlock() + { + bool test __attribute__((unused)) = true; + VERIFY( l.owns_lock() ); + l.unlock(); + } + +}; + +int unreliable_lock::count = 0; +int unreliable_lock::throw_on = -1; +int unreliable_lock::lock_on = -1; + +void test01() +{ + bool test __attribute__((unused)) = true; + + unreliable_lock l1, l2, l3; + + try + { + unreliable_lock::count = 0; + int result = std::try_lock(l1, l2, l3); + VERIFY( result == -1 ); + VERIFY( unreliable_lock::count == 3 ); + l1.unlock(); + l2.unlock(); + l3.unlock(); + } + catch (...) + { + VERIFY( false ); + } +} + +void test02() +{ + bool test __attribute__((unused)) = true; + + unreliable_lock l1, l2, l3; + + try + { + // test behaviour when a lock is already held + unreliable_lock::lock_on = 0; + while (unreliable_lock::lock_on < 3) + { + unreliable_lock::count = 0; + int failed = std::try_lock(l1, l2, l3); + VERIFY( failed == unreliable_lock::lock_on ); + ++unreliable_lock::lock_on; + } + } + catch (...) + { + VERIFY( false ); + } +} + +void test03() +{ + bool test __attribute__((unused)) = true; + + unreliable_lock l1, l2, l3; + + try + { + // test behaviour when an exception is thrown + unreliable_lock::throw_on = 0; + while (unreliable_lock::throw_on < 3) + { + unreliable_lock::count = 0; + int failed = std::try_lock(l1, l2, l3); + VERIFY( failed == unreliable_lock::throw_on ); + ++unreliable_lock::throw_on; + } + } + catch (...) + { + VERIFY( false ); + } +} + +int main() +{ + test01(); + test02(); + test03(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/unique_lock/cons/1.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/unique_lock/cons/1.cc new file mode 100644 index 000000000..ca2cad91d --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/unique_lock/cons/1.cc @@ -0,0 +1,53 @@ +// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* *-*-solaris* *-*-cygwin *-*-darwin* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* powerpc-ibm-aix* } } +// { 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-2014 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 <mutex> +#include <system_error> +#include <testsuite_hooks.h> + +int main() +{ + bool test __attribute__((unused)) = true; + typedef std::mutex mutex_type; + typedef std::unique_lock<mutex_type> lock_type; + + try + { + lock_type lock; + + VERIFY( !lock.owns_lock() ); + VERIFY( !(bool)lock ); + } + catch (const std::system_error& e) + { + VERIFY( false ); + } + catch (...) + { + VERIFY( false ); + } + + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/unique_lock/cons/2.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/unique_lock/cons/2.cc new file mode 100644 index 000000000..4085803f9 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/unique_lock/cons/2.cc @@ -0,0 +1,54 @@ +// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* *-*-solaris* *-*-cygwin *-*-darwin* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* powerpc-ibm-aix* } } +// { 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-2014 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 <mutex> +#include <system_error> +#include <testsuite_hooks.h> + +int main() +{ + bool test __attribute__((unused)) = true; + typedef std::mutex mutex_type; + typedef std::unique_lock<mutex_type> lock_type; + + try + { + mutex_type m; + lock_type lock(m); + + VERIFY( lock.owns_lock() ); + VERIFY( (bool)lock ); + } + catch (const std::system_error& e) + { + VERIFY( false ); + } + catch (...) + { + VERIFY( false ); + } + + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/unique_lock/cons/3.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/unique_lock/cons/3.cc new file mode 100644 index 000000000..de38838bb --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/unique_lock/cons/3.cc @@ -0,0 +1,54 @@ +// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* *-*-solaris* *-*-cygwin *-*-darwin* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* powerpc-ibm-aix* } } +// { 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-2014 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 <mutex> +#include <system_error> +#include <testsuite_hooks.h> + +int main() +{ + bool test __attribute__((unused)) = true; + typedef std::mutex mutex_type; + typedef std::unique_lock<mutex_type> lock_type; + + try + { + mutex_type m; + lock_type lock(m, std::defer_lock); + + VERIFY( !lock.owns_lock() ); + VERIFY( !(bool)lock ); + } + catch (const std::system_error& e) + { + VERIFY( false ); + } + catch (...) + { + VERIFY( false ); + } + + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/unique_lock/cons/4.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/unique_lock/cons/4.cc new file mode 100644 index 000000000..f6a4ccaf2 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/unique_lock/cons/4.cc @@ -0,0 +1,54 @@ +// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* *-*-solaris* *-*-cygwin *-*-darwin* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* powerpc-ibm-aix* } } +// { 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-2014 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 <mutex> +#include <system_error> +#include <testsuite_hooks.h> + +int main() +{ + bool test __attribute__((unused)) = true; + typedef std::mutex mutex_type; + typedef std::unique_lock<mutex_type> lock_type; + + try + { + mutex_type m; + lock_type lock(m, std::try_to_lock); + + VERIFY( lock.owns_lock() ); + VERIFY( (bool)lock ); + } + catch (const std::system_error& e) + { + VERIFY( false ); + } + catch (...) + { + VERIFY( false ); + } + + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/unique_lock/cons/5.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/unique_lock/cons/5.cc new file mode 100644 index 000000000..941f65293 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/unique_lock/cons/5.cc @@ -0,0 +1,58 @@ +// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* *-*-solaris* *-*-cygwin *-*-darwin* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } } +// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } } +// { dg-require-cstdint "" } +// { dg-require-gthreads-timed "" } + +// Copyright (C) 2008-2014 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 <chrono> +#include <mutex> +#include <system_error> +#include <testsuite_hooks.h> + +int main() +{ + bool test __attribute__((unused)) = true; + typedef std::timed_mutex mutex_type; + typedef std::unique_lock<mutex_type> lock_type; + typedef std::chrono::system_clock clock_type; + + try + { + clock_type::time_point t = clock_type::now() + std::chrono::seconds(5); + + mutex_type m; + lock_type lock(m, t); + + VERIFY( lock.owns_lock() ); + VERIFY( (bool)lock ); + } + catch (const std::system_error& e) + { + VERIFY( false ); + } + catch (...) + { + VERIFY( false ); + } + + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/unique_lock/cons/6.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/unique_lock/cons/6.cc new file mode 100644 index 000000000..8b94afd32 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/unique_lock/cons/6.cc @@ -0,0 +1,58 @@ +// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* *-*-solaris* *-*-cygwin *-*-darwin* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } } +// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } } +// { dg-require-cstdint "" } +// { dg-require-gthreads-timed "" } + +// Copyright (C) 2008-2014 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 <chrono> +#include <mutex> +#include <system_error> +#include <testsuite_hooks.h> + +int main() +{ + bool test __attribute__((unused)) = true; + typedef std::timed_mutex mutex_type; + typedef std::unique_lock<mutex_type> lock_type; + typedef std::chrono::system_clock clock_type; + + try + { + clock_type::duration d = std::chrono::seconds(5); + + mutex_type m; + lock_type lock(m, d); + + VERIFY( lock.owns_lock() ); + VERIFY( (bool)lock ); + } + catch (const std::system_error& e) + { + VERIFY( false ); + } + catch (...) + { + VERIFY( false ); + } + + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/unique_lock/locking/1.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/unique_lock/locking/1.cc new file mode 100644 index 000000000..efa1aac50 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/unique_lock/locking/1.cc @@ -0,0 +1,61 @@ +// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* *-*-solaris* *-*-cygwin *-*-darwin* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* powerpc-ibm-aix* } } +// { 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-2014 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 <mutex> +#include <system_error> +#include <testsuite_hooks.h> + +int main() +{ + bool test __attribute__((unused)) = true; + typedef std::mutex mutex_type; + typedef std::unique_lock<mutex_type> lock_type; + + try + { + mutex_type m; + lock_type l(m, std::defer_lock); + + l.lock(); + + VERIFY( (bool)l ); + VERIFY( l.owns_lock() ); + + l.unlock(); + + VERIFY( !(bool)l ); + VERIFY( !l.owns_lock() ); + } + catch (const std::system_error& e) + { + VERIFY( false ); + } + catch (...) + { + VERIFY( false ); + } + + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/unique_lock/locking/2.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/unique_lock/locking/2.cc new file mode 100644 index 000000000..e0a302e05 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/unique_lock/locking/2.cc @@ -0,0 +1,106 @@ +// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* *-*-solaris* *-*-cygwin *-*-darwin* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* powerpc-ibm-aix* } } +// { 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-2014 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 <mutex> +#include <system_error> +#include <testsuite_hooks.h> + +void test01() +{ + bool test __attribute__((unused)) = true; + typedef std::mutex mutex_type; + typedef std::unique_lock<mutex_type> lock_type; + + try + { + lock_type l; + + // Lock unique_lock w/o mutex + try + { + l.lock(); + } + catch (const std::system_error& ex) + { + VERIFY( ex.code() == std::make_error_code + (std::errc::operation_not_permitted) ); + } + catch (...) + { + VERIFY( false ); + } + } + catch (const std::system_error& e) + { + VERIFY( false ); + } + catch (...) + { + VERIFY( false ); + } +} + + +void test02() +{ + bool test __attribute__((unused)) = true; + typedef std::mutex mutex_type; + typedef std::unique_lock<mutex_type> lock_type; + + try + { + mutex_type m; + lock_type l(m); + + // Lock already locked unique_lock. + try + { + l.lock(); + } + catch (const std::system_error& ex) + { + VERIFY( ex.code() == std::make_error_code + (std::errc::resource_deadlock_would_occur) ); + } + catch (...) + { + VERIFY( false ); + } + } + catch (const std::system_error& e) + { + VERIFY( false ); + } + catch (...) + { + VERIFY( false ); + } +} + +int main() +{ + test01(); + test02(); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/unique_lock/locking/3.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/unique_lock/locking/3.cc new file mode 100644 index 000000000..01bc682c0 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/unique_lock/locking/3.cc @@ -0,0 +1,67 @@ +// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* *-*-solaris* *-*-cygwin *-*-darwin* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } } +// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } } +// { dg-require-cstdint "" } +// { dg-require-gthreads-timed "" } + +// Copyright (C) 2008-2014 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 <chrono> +#include <mutex> +#include <system_error> +#include <testsuite_hooks.h> + +int main() +{ + bool test __attribute__((unused)) = true; + typedef std::timed_mutex mutex_type; + typedef std::unique_lock<mutex_type> lock_type; + + try + { + mutex_type m; + lock_type l(m, std::defer_lock); + + try + { + l.try_lock_for(std::chrono::milliseconds(100)); + } + catch(const std::system_error&) + { + VERIFY( false ); + } + catch (...) + { + VERIFY( false ); + } + + VERIFY( l.owns_lock() ); + } + catch (const std::system_error&) + { + VERIFY( false ); + } + catch (...) + { + VERIFY( false ); + } + + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/unique_lock/locking/4.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/unique_lock/locking/4.cc new file mode 100644 index 000000000..192f3a823 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/unique_lock/locking/4.cc @@ -0,0 +1,69 @@ +// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* *-*-solaris* *-*-cygwin *-*-darwin* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } } +// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } } +// { dg-require-cstdint "" } +// { dg-require-gthreads-timed "" } + +// Copyright (C) 2008-2014 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 <chrono> +#include <mutex> +#include <system_error> +#include <testsuite_hooks.h> + +int main() +{ + bool test __attribute__((unused)) = true; + typedef std::timed_mutex mutex_type; + typedef std::unique_lock<mutex_type> lock_type; + typedef std::chrono::system_clock clock_type; + + try + { + mutex_type m; + lock_type l(m, std::defer_lock); + clock_type::time_point t = clock_type::now() + std::chrono::seconds(1); + + try + { + l.try_lock_until(t); + } + catch(const std::system_error&) + { + VERIFY( false ); + } + catch (...) + { + VERIFY( false ); + } + + VERIFY( l.owns_lock() ); + } + catch (const std::system_error& e) + { + VERIFY( false ); + } + catch (...) + { + VERIFY( false ); + } + + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/unique_lock/modifiers/1.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/unique_lock/modifiers/1.cc new file mode 100644 index 000000000..0c5408f48 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/unique_lock/modifiers/1.cc @@ -0,0 +1,68 @@ +// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* *-*-solaris* *-*-cygwin *-*-darwin* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* powerpc-ibm-aix* } } +// { 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-2014 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 <mutex> +#include <system_error> +#include <testsuite_hooks.h> + +int main() +{ + bool test __attribute__((unused)) = true; + typedef std::mutex mutex_type; + typedef std::unique_lock<mutex_type> lock_type; + + try + { + mutex_type m; + lock_type l1(m); + lock_type l2; + + try + { + l1.swap(l2); + } + catch (const std::system_error&) + { + VERIFY( false ); + } + catch(...) + { + VERIFY( false ); + } + + VERIFY( !(bool)l1 ); + VERIFY( (bool)l2 ); + } + catch (const std::system_error& e) + { + VERIFY( false ); + } + catch (...) + { + VERIFY( false ); + } + + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/unique_lock/modifiers/2.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/unique_lock/modifiers/2.cc new file mode 100644 index 000000000..28a01b230 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/unique_lock/modifiers/2.cc @@ -0,0 +1,68 @@ +// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* *-*-solaris* *-*-cygwin *-*-darwin* powerpc-ibm-aix* } } +// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* powerpc-ibm-aix* } } +// { 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-2014 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 <mutex> +#include <system_error> +#include <testsuite_hooks.h> + +int main() +{ + bool test __attribute__((unused)) = true; + typedef std::mutex mutex_type; + typedef std::unique_lock<mutex_type> lock_type; + + try + { + mutex_type m; + lock_type l1(m); + lock_type l2; + + try + { + l1.swap(l2); + } + catch (const std::system_error&) + { + VERIFY( false ); + } + catch(...) + { + VERIFY( false ); + } + + VERIFY( !(bool)l1 ); + VERIFY( (bool)l2 ); + } + catch (const std::system_error&) + { + VERIFY( false ); + } + catch (...) + { + VERIFY( false ); + } + + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/unique_lock/requirements/explicit_instantiation.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/unique_lock/requirements/explicit_instantiation.cc new file mode 100644 index 000000000..ed0f6e672 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/unique_lock/requirements/explicit_instantiation.cc @@ -0,0 +1,33 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } +// { dg-require-cstdint "" } +// { dg-require-gthreads "" } + +// 2008-03-14 Benjamin Kosnik <bkoz@redhat.com> + +// Copyright (C) 2008-2014 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/>. + + +// NB: This file is for testing with NO OTHER INCLUDES. + +#include <mutex> + +namespace std +{ + template class unique_lock<mutex>; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/unique_lock/requirements/typedefs.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/unique_lock/requirements/typedefs.cc new file mode 100644 index 000000000..5df6bab0f --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/unique_lock/requirements/typedefs.cc @@ -0,0 +1,35 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } +// { dg-require-cstdint "" } +// { dg-require-gthreads "" } + +// 2008-03-14 Benjamin Kosnik <bkoz@redhat.com> + +// Copyright (C) 2008-2014 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/>. + + +// NB: This file is for testing with NO OTHER INCLUDES. + +#include <mutex> + +void test01() +{ + // Check for required typedefs + typedef std::unique_lock<std::mutex> test_type; + typedef test_type::mutex_type mutex_type; +} |