// Force this function using CLOCK_MONOTONIC because it was always using // CLOCK_MONOTONIC in history. extern "C" int pthread_cond_timedwait_relative_np(pthread_cond_t* cond_interface, pthread_mutex_t* mutex, const timespec* rel_timeout) { timespec ts; timespec* abs_timeout = nullptr; if (rel_timeout != nullptr) { absolute_timespec_from_timespec(ts, *rel_timeout, CLOCK_MONOTONIC); abs_timeout = &ts; } return __pthread_cond_timedwait(__get_internal_cond(cond_interface), mutex, false, abs_timeout); }
int pthread_cond_timedwait(pthread_cond_t *cond_interface, pthread_mutex_t * mutex, const timespec *abstime) { pthread_cond_internal_t* cond = __get_internal_cond(cond_interface); return __pthread_cond_timedwait(cond, mutex, cond->use_realtime_clock(), abstime); }
extern "C" int pthread_cond_timedwait_monotonic_np(pthread_cond_t* cond_interface, pthread_mutex_t* mutex, const timespec* abs_timeout) { return __pthread_cond_timedwait(__get_internal_cond(cond_interface), mutex, false, abs_timeout); }
int pthread_cond_wait(pthread_cond_t* cond_interface, pthread_mutex_t* mutex) { pthread_cond_internal_t* cond = __get_internal_cond(cond_interface); return __pthread_cond_timedwait(cond, mutex, false, nullptr); }
int pthread_cond_timedwait_monotonic_np(pthread_cond_t* cond, pthread_mutex_t* mutex, const struct timespec* abstime) { return __pthread_cond_timedwait(cond, mutex, abstime, CLOCK_MONOTONIC); }
int pthread_cond_timedwait(pthread_cond_t *cond, pthread_mutex_t * mutex, const struct timespec *abstime) { return __pthread_cond_timedwait(cond, mutex, abstime, CLOCK_REALTIME); }
int pthread_cond_wait(pthread_cond_t* cond, pthread_mutex_t* mutex) { return __pthread_cond_timedwait(cond, mutex, NULL, CLOCK_REALTIME); }
#include <threads.h> #include <errno.h> int __pthread_cond_timedwait(cnd_t *restrict, mtx_t *restrict, const struct timespec *restrict); int cnd_timedwait(cnd_t *restrict c, mtx_t *restrict m, const struct timespec *restrict ts) { int ret = __pthread_cond_timedwait(c, m, ts); switch (ret) { /* May also return EINVAL or EPERM. */ default: return thrd_error; case 0: return thrd_success; case ETIMEDOUT: return thrd_timedout; } }