diff options
author | dim <dim@FreeBSD.org> | 2015-01-07 21:08:01 +0000 |
---|---|---|
committer | dim <dim@FreeBSD.org> | 2015-01-07 21:08:01 +0000 |
commit | 083c980732b44eb899ce399cf182dec9b90b9a1d (patch) | |
tree | 41f38760e19d47a9e21d0f64ece2bddaaab8aaf7 /src/thread.cpp | |
parent | c3e10da3dc0f616b78ccf85206fdcf4c92f8ac85 (diff) | |
download | FreeBSD-src-083c980732b44eb899ce399cf182dec9b90b9a1d.zip FreeBSD-src-083c980732b44eb899ce399cf182dec9b90b9a1d.tar.gz |
Vendor import of libc++ trunk r224926:
https://llvm.org/svn/llvm-project/libcxx/trunk@224926
Diffstat (limited to 'src/thread.cpp')
-rw-r--r-- | src/thread.cpp | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/src/thread.cpp b/src/thread.cpp index 338a8a2..6aad558 100644 --- a/src/thread.cpp +++ b/src/thread.cpp @@ -7,6 +7,9 @@ // //===----------------------------------------------------------------------===// +#include "__config" +#ifndef _LIBCPP_HAS_NO_THREADS + #include "thread" #include "exception" #include "vector" @@ -14,10 +17,10 @@ #include "limits" #include <sys/types.h> #if !defined(_WIN32) -#if !defined(__sun__) && !defined(__linux__) && !defined(_AIX) -#include <sys/sysctl.h> -#endif // !__sun__ && !__linux__ && !_AIX -#include <unistd.h> +# if !defined(__sun__) && !defined(__linux__) && !defined(_AIX) && !defined(__native_client__) +# include <sys/sysctl.h> +# endif // !defined(__sun__) && !defined(__linux__) && !defined(_AIX) && !defined(__native_client__) +# include <unistd.h> #endif // !_WIN32 #if defined(__NetBSD__) @@ -121,7 +124,9 @@ sleep_for(const chrono::nanoseconds& ns) ts.tv_sec = ts_sec_max; ts.tv_nsec = giga::num - 1; } - nanosleep(&ts, 0); + + while (nanosleep(&ts, &ts) == -1 && errno == EINTR) + ; } } @@ -144,7 +149,7 @@ public: T* allocate(size_t __n) {return static_cast<T*>(::operator new(__n * sizeof(T)));} - void deallocate(T* __p, size_t) {::operator delete((void*)__p);} + void deallocate(T* __p, size_t) {::operator delete(static_cast<void*>(__p));} size_t max_size() const {return size_t(~0) / sizeof(T);} }; @@ -223,3 +228,5 @@ __thread_struct::__make_ready_at_thread_exit(__assoc_sub_state* __s) } _LIBCPP_END_NAMESPACE_STD + +#endif // !_LIBCPP_HAS_NO_THREADS |