Refactor pthread usage of libcxx.
This patch extracts out all the pthread dependencies of libcxx into the new header __threading_support. The motivation is to make it easy to re-target libcxx into platforms that do not support pthread. Original patch from Fulvio Esposito (fulvio.esposito@outlook.com) - D11781 Applied with tweaks - D19412 Change-Id: I301111f0075de93dd8129416e06babc195aa936b git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@268734 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -20,19 +20,19 @@ _LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
condition_variable::~condition_variable()
|
||||
{
|
||||
pthread_cond_destroy(&__cv_);
|
||||
__libcpp_condvar_destroy(&__cv_);
|
||||
}
|
||||
|
||||
void
|
||||
condition_variable::notify_one() _NOEXCEPT
|
||||
{
|
||||
pthread_cond_signal(&__cv_);
|
||||
__libcpp_condvar_signal(&__cv_);
|
||||
}
|
||||
|
||||
void
|
||||
condition_variable::notify_all() _NOEXCEPT
|
||||
{
|
||||
pthread_cond_broadcast(&__cv_);
|
||||
__libcpp_condvar_broadcast(&__cv_);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -41,7 +41,7 @@ condition_variable::wait(unique_lock<mutex>& lk) _NOEXCEPT
|
||||
if (!lk.owns_lock())
|
||||
__throw_system_error(EPERM,
|
||||
"condition_variable::wait: mutex not locked");
|
||||
int ec = pthread_cond_wait(&__cv_, lk.mutex()->native_handle());
|
||||
int ec = __libcpp_condvar_wait(&__cv_, lk.mutex()->native_handle());
|
||||
if (ec)
|
||||
__throw_system_error(ec, "condition_variable wait failed");
|
||||
}
|
||||
@@ -71,7 +71,7 @@ condition_variable::__do_timed_wait(unique_lock<mutex>& lk,
|
||||
ts.tv_sec = ts_sec_max;
|
||||
ts.tv_nsec = giga::num - 1;
|
||||
}
|
||||
int ec = pthread_cond_timedwait(&__cv_, lk.mutex()->native_handle(), &ts);
|
||||
int ec = __libcpp_condvar_timedwait(&__cv_, lk.mutex()->native_handle(), &ts);
|
||||
if (ec != 0 && ec != ETIMEDOUT)
|
||||
__throw_system_error(ec, "condition_variable timed_wait failed");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user