3 #include "pthread_impl.h"
5 /* Due to the requirement that aio_suspend be async-signal-safe, we cannot
6 * use any locks, wait queues, etc. that would make it more efficient. The
7 * only obviously-correct algorithm is to generate a wakeup every time any
8 * aio operation finishes and have aio_suspend re-evaluate the completion
9 * status of each aiocb it was waiting on. */
11 static volatile int seq;
19 int aio_suspend(const struct aiocb *const cbs[], int cnt, const struct timespec *ts)
21 int i, last, first=1, ret=0;
32 for (i=0; i<cnt; i++) {
33 if (cbs[i] && cbs[i]->__err != EINPROGRESS)
38 clock_gettime(CLOCK_MONOTONIC, &at);
39 at.tv_sec += ts->tv_sec;
40 if ((at.tv_nsec += ts->tv_nsec) >= 1000000000) {
41 at.tv_nsec -= 1000000000;
47 ret = __timedwait(&seq, last, CLOCK_MONOTONIC,
48 ts ? &at : 0, 0, 0, 1);
50 if (ret == ETIMEDOUT) ret = EAGAIN;