From 51072bd6bf79ef2bc6a922079bff57c31c1effbc Mon Sep 17 00:00:00 2001 From: Dimitry Andric Date: Sat, 23 Jul 2016 20:47:26 +0000 Subject: Vendor import of libc++ release_39 branch r276489: https://llvm.org/svn/llvm-project/libcxx/branches/release_39@276489 --- .../thread.thread.member/native_handle.pass.cpp | 54 ++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 test/libcxx/thread/thread.threads/thread.thread.class/thread.thread.member/native_handle.pass.cpp (limited to 'test/libcxx/thread/thread.threads/thread.thread.class/thread.thread.member/native_handle.pass.cpp') diff --git a/test/libcxx/thread/thread.threads/thread.thread.class/thread.thread.member/native_handle.pass.cpp b/test/libcxx/thread/thread.threads/thread.thread.class/thread.thread.member/native_handle.pass.cpp new file mode 100644 index 000000000000..c8807a965c44 --- /dev/null +++ b/test/libcxx/thread/thread.threads/thread.thread.class/thread.thread.member/native_handle.pass.cpp @@ -0,0 +1,54 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// UNSUPPORTED: libcpp-has-no-threads + +// + +// class thread + +// native_handle_type native_handle(); + +#include +#include +#include +#include + +class G +{ + int alive_; +public: + static int n_alive; + static bool op_run; + + G() : alive_(1) {++n_alive;} + G(const G& g) : alive_(g.alive_) {++n_alive;} + ~G() {alive_ = 0; --n_alive;} + + void operator()() + { + assert(alive_ == 1); + assert(n_alive >= 1); + op_run = true; + } +}; + +int G::n_alive = 0; +bool G::op_run = false; + +int main() +{ + { + G g; + std::thread t0(g); + pthread_t pid = t0.native_handle(); + assert(pid != 0); + t0.join(); + } +} -- cgit v1.3