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)
25 a_inc(&c->_c_waiters);
26 c->_c_block = tid = pthread_self()->tid;
28 if ((r=pthread_mutex_unlock(m))) return r;
30 do e = __timedwait(&c->_c_block, tid, c->_c_clock, ts, cleanup, &cm, 0);
31 while (c->_c_block == tid && (!e || e==EINTR));
32 if (e == EINTR) e = 0;
34 a_dec(&c->_c_waiters);
36 if ((r=pthread_mutex_lock(m))) return r;