1 #include "pthread_impl.h"
8 static void cleanup(void *p)
11 a_dec(&cm->c->_c_waiters);
12 pthread_mutex_lock(cm->m);
15 int pthread_cond_timedwait(pthread_cond_t *c, pthread_mutex_t *m, const struct timespec *ts)
17 struct cm cm = { .c=c, .m=m };
20 if (ts && ts->tv_nsec >= 1000000000UL)
26 if ((r=pthread_mutex_unlock(m))) return r;
28 a_inc(&c->_c_waiters);
29 do e = __timedwait(&c->_c_block, 1, c->_c_clock, ts, cleanup, &cm, 0);
31 a_dec(&c->_c_waiters);
33 if ((r=pthread_mutex_lock(m))) return r;