2 #include "pthread_impl.h"
4 static void cleanup(void *p)
9 int sem_timedwait(sem_t *sem, const struct timespec *at)
13 if (a_fetch_add(sem->__val, -1) > 0) return 0;
16 if (at && at->tv_nsec >= 1000000000UL) {
22 pthread_cleanup_push(cleanup, sem->__val+1)
26 if (!sem_trywait(sem)) break;
27 r = __timedwait_cp(sem->__val, 0, CLOCK_REALTIME, at, 0);
35 pthread_cleanup_pop(1);