libcxx initial import

llvm-svn: 103490
diff --git a/libcxx/test/thread/thread.threads/thread.thread.class/thread.thread.member/detach.pass.cpp b/libcxx/test/thread/thread.threads/thread.thread.class/thread.thread.member/detach.pass.cpp
new file mode 100644
index 0000000..081a98f
--- /dev/null
+++ b/libcxx/test/thread/thread.threads/thread.thread.class/thread.thread.member/detach.pass.cpp
@@ -0,0 +1,54 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <thread>
+
+// class thread
+
+// void detach();
+
+#include <thread>
+#include <new>
+#include <cstdlib>
+#include <cassert>
+
+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()
+{
+    {
+        std::thread t0((G()));
+        assert(t0.joinable());
+        t0.detach();
+        assert(!t0.joinable());
+        std::this_thread::sleep_for(std::chrono::milliseconds(250));
+        assert(G::op_run);
+        assert(G::n_alive == 0);
+    }
+}
diff --git a/libcxx/test/thread/thread.threads/thread.thread.class/thread.thread.member/get_id.pass.cpp b/libcxx/test/thread/thread.threads/thread.thread.class/thread.thread.member/get_id.pass.cpp
new file mode 100644
index 0000000..c5c7788
--- /dev/null
+++ b/libcxx/test/thread/thread.threads/thread.thread.class/thread.thread.member/get_id.pass.cpp
@@ -0,0 +1,54 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <thread>
+
+// class thread
+
+// id get_id() const;
+
+#include <thread>
+#include <new>
+#include <cstdlib>
+#include <cassert>
+
+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()
+{
+    {
+        std::thread t0((G()));
+        std::thread::id id0 = t0.get_id();
+        std::thread t1;
+        std::thread::id id1 = t1.get_id();
+        assert(t0.get_id() != id1);
+        assert(t1.get_id() == std::thread::id());
+        t0.join();
+    }
+}
diff --git a/libcxx/test/thread/thread.threads/thread.thread.class/thread.thread.member/join.pass.cpp b/libcxx/test/thread/thread.threads/thread.thread.class/thread.thread.member/join.pass.cpp
new file mode 100644
index 0000000..c890f18
--- /dev/null
+++ b/libcxx/test/thread/thread.threads/thread.thread.class/thread.thread.member/join.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <thread>
+
+// class thread
+
+// void join();
+
+#include <thread>
+#include <new>
+#include <cstdlib>
+#include <cassert>
+
+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()
+{
+    {
+        std::thread t0((G()));
+        assert(t0.joinable());
+        t0.join();
+        assert(!t0.joinable());
+    }
+}
diff --git a/libcxx/test/thread/thread.threads/thread.thread.class/thread.thread.member/joinable.pass.cpp b/libcxx/test/thread/thread.threads/thread.thread.class/thread.thread.member/joinable.pass.cpp
new file mode 100644
index 0000000..1b24796
--- /dev/null
+++ b/libcxx/test/thread/thread.threads/thread.thread.class/thread.thread.member/joinable.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <thread>
+
+// class thread
+
+// bool joinable() const;
+
+#include <thread>
+#include <new>
+#include <cstdlib>
+#include <cassert>
+
+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()
+{
+    {
+        std::thread t0((G()));
+        assert(t0.joinable());
+        t0.join();
+        assert(!t0.joinable());
+    }
+}
diff --git a/libcxx/test/thread/thread.threads/thread.thread.class/thread.thread.member/native_handle.pass.cpp b/libcxx/test/thread/thread.threads/thread.thread.class/thread.thread.member/native_handle.pass.cpp
new file mode 100644
index 0000000..63c879b
--- /dev/null
+++ b/libcxx/test/thread/thread.threads/thread.thread.class/thread.thread.member/native_handle.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <thread>
+
+// class thread
+
+// native_handle_type native_handle();
+
+#include <thread>
+#include <new>
+#include <cstdlib>
+#include <cassert>
+
+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()
+{
+    {
+        std::thread t0((G()));
+        pthread_t pid = t0.native_handle();
+        assert(pid != 0);
+        t0.join();
+    }
+}
diff --git a/libcxx/test/thread/thread.threads/thread.thread.class/thread.thread.member/swap.pass.cpp b/libcxx/test/thread/thread.threads/thread.thread.class/thread.thread.member/swap.pass.cpp
new file mode 100644
index 0000000..61aee10
--- /dev/null
+++ b/libcxx/test/thread/thread.threads/thread.thread.class/thread.thread.member/swap.pass.cpp
@@ -0,0 +1,55 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <thread>
+
+// class thread
+
+// void swap(thread& t);
+
+#include <thread>
+#include <new>
+#include <cstdlib>
+#include <cassert>
+
+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()
+{
+    {
+        std::thread t0((G()));
+        std::thread::id id0 = t0.get_id();
+        std::thread t1;
+        std::thread::id id1 = t1.get_id();
+        t0.swap(t1);
+        assert(t0.get_id() == id1);
+        assert(t1.get_id() == id0);
+        t1.join();
+    }
+}