[PATCH] D20874: [libcxx] Two more threading dependencies

Asiri Rathnayake via cfe-commits cfe-commits at lists.llvm.org
Wed Jun 1 11:49:25 PDT 2016


rmaprath created this revision.
rmaprath added reviewers: EricWF, bcraig, mclow.lists.
rmaprath added a subscriber: cfe-commits.

Bumped into these while working on the externally threaded variant. I think it makes most sense to group these two under the main threading API. This greatly simplifies the presentation of the externally threaded library variant as well.

http://reviews.llvm.org/D20874

Files:
  include/__threading_support
  src/thread.cpp

Index: src/thread.cpp
===================================================================
--- src/thread.cpp
+++ src/thread.cpp
@@ -40,7 +40,7 @@
 thread::~thread()
 {
     if (__t_ != 0)
-        terminate();
+        __libcpp_thread_terminate();
 }
 
 void
@@ -130,7 +130,7 @@
             ts.tv_nsec = giga::num - 1;
         }
 
-        while (nanosleep(&ts, &ts) == -1 && errno == EINTR)
+        while (__libcpp_thread_nanosleep(&ts, &ts) == -1 && errno == EINTR)
             ;
     }
 }
Index: include/__threading_support
===================================================================
--- include/__threading_support
+++ include/__threading_support
@@ -22,6 +22,8 @@
 #if defined(_LIBCPP_HAS_THREAD_API_PTHREAD)
 #include <pthread.h>
 #include <sched.h>
+#include <time.h>
+#include <exception>
 #endif
 
 _LIBCPP_BEGIN_NAMESPACE_STD
@@ -156,6 +158,12 @@
 }
 
 inline _LIBCPP_ALWAYS_INLINE
+int __libcpp_thread_nanosleep(const timespec *req, timespec *rem)
+{
+    return nanosleep(req, rem);
+}
+
+inline _LIBCPP_ALWAYS_INLINE
 int __libcpp_thread_join(__libcpp_thread_t* __t)
 {
     return pthread_join(*__t, 0);
@@ -173,6 +181,12 @@
     sched_yield();
 }
 
+inline _LIBCPP_ALWAYS_INLINE
+void __libcpp_thread_terminate()
+{
+    std::terminate();
+}
+
 // Thread local storage
 typedef pthread_key_t __libcpp_tl_key;
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D20874.59262.patch
Type: text/x-patch
Size: 1338 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160601/62e59062/attachment.bin>


More information about the cfe-commits mailing list