rmaprath updated this revision to Diff 59507. rmaprath added a comment. Added a comment about `~std::thread()` hook.
@EricWF: Gentle ping. http://reviews.llvm.org/D20874 Files: include/__threading_support src/thread.cpp 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) ; } } 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;
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) ; } } 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;
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits