Index: include/__threading_support =================================================================== --- include/__threading_support +++ include/__threading_support @@ -22,6 +22,8 @@ #if defined(_LIBCPP_HAS_THREAD_API_PTHREAD) #include #include +#include +#include #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; Index: src/thread.cpp =================================================================== --- src/thread.cpp +++ src/thread.cpp @@ -39,8 +39,10 @@ thread::~thread() { + // custom hook allowing thread implementations to control + // the ~std::tread() behavior. if (__t_ != 0) - terminate(); + __libcpp_thread_terminate(); } void @@ -133,7 +135,7 @@ ts.tv_nsec = giga::num - 1; } - while (nanosleep(&ts, &ts) == -1 && errno == EINTR) + while (__libcpp_thread_nanosleep(&ts, &ts) == -1 && errno == EINTR) ; } }