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