summaryrefslogtreecommitdiffstats
path: root/contrib/libc++/src/thread.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/libc++/src/thread.cpp')
-rw-r--r--contrib/libc++/src/thread.cpp19
1 files changed, 13 insertions, 6 deletions
diff --git a/contrib/libc++/src/thread.cpp b/contrib/libc++/src/thread.cpp
index 338a8a2..6aad558 100644
--- a/contrib/libc++/src/thread.cpp
+++ b/contrib/libc++/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
OpenPOWER on IntegriCloud