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
llvm-svn: 268734
Cr-Mirrored-From: sso://chromium.googlesource.com/_direct/external/github.com/llvm/llvm-project
Cr-Mirrored-Commit: c7e4239fabf2c876449697caf05a342b01bf0312
diff --git a/src/condition_variable.cpp b/src/condition_variable.cpp
index 5fd5fc8..bfb4bf3 100644
--- a/src/condition_variable.cpp
+++ b/src/condition_variable.cpp
@@ -20,19 +20,19 @@
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 @@
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 @@
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");
}