]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
drd/tests/std_thread: Enable this test program
authorBart Van Assche <bvanassche@acm.org>
Sat, 7 Jun 2014 07:31:56 +0000 (07:31 +0000)
committerBart Van Assche <bvanassche@acm.org>
Sat, 7 Jun 2014 07:31:56 +0000 (07:31 +0000)
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@14001

drd/tests/std_thread.cpp
drd/tests/std_thread.vgtest

index e4487d4c6f5c80e5cf97ce99e2ef17bedf39f0f9..4d637a388b26e5280feb8c2ec6cdda91f2718630 100644 (file)
@@ -10,6 +10,7 @@
 #define _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER(addr) \
   ANNOTATE_HAPPENS_AFTER(addr)
 #define _GLIBCXX_EXTERN_TEMPLATE -1
+#define _GLIBCXX_DEBUG 1
 
 #include <iostream>
 #include <thread>
@@ -21,3 +22,48 @@ int main(int argc, char** argv)
   std::cerr << "Done.\n";
   return 0;
 }
+
+//
+// From libstdc++-v3/src/c++11/thread.cc
+//
+
+#include <system_error>
+
+extern "C" void* execute_native_thread_routine(void* __p)
+{
+  std::thread::_Impl_base* __t = static_cast<std::thread::_Impl_base*>(__p);
+  std::thread::__shared_base_type __local;
+  __local.swap(__t->_M_this_ptr);
+
+  __try {
+    __t->_M_run();
+  } __catch(const __cxxabiv1::__forced_unwind&) {
+    __throw_exception_again;
+  } __catch(...) {
+    std::terminate();
+  }
+
+  return 0;
+}
+
+namespace std
+{
+  void thread::_M_start_thread(__shared_base_type __b)
+  {
+    if (!__gthread_active_p())
+#if __EXCEPTIONS
+      throw system_error(make_error_code(errc::operation_not_permitted),
+                         "Enable multithreading to use std::thread");
+#else
+      __throw_system_error(int(errc::operation_not_permitted));
+#endif
+
+    __b->_M_this_ptr = __b;
+    int __e = pthread_create(&_M_id._M_thread, NULL,
+                             &execute_native_thread_routine, __b.get());
+    if (__e) {
+      __b->_M_this_ptr.reset();
+      __throw_system_error(__e);
+    }
+  }
+}
index e6264c2b590f55b2af6fbe3a4c881bb86752fb1a..aa30d15e5590b87496480f874c1ae490daa19d7a 100644 (file)
@@ -1,4 +1,4 @@
-prereq: false && test -e std_thread && ./supported_libpthread
+prereq: test -e std_thread && ./supported_libpthread
 vgopts: --check-stack-var=yes --show-confl-seg=no
 prog: std_thread
 stderr_filter: filter_stderr