#include #include #include #include "atomic.h" #include "pthread_impl.h" int aio_suspend(const struct aiocb *const cbs[], int cnt, const struct timespec *ts) { int i, tid = 0, ret, expect = 0; struct timespec at; volatile int dummy_fut, *pfut; int nzcnt = 0; const struct aiocb *cb = 0; pthread_testcancel(); if (cnt<0) { errno = EINVAL; return -1; } for (i=0; itv_sec; if ((at.tv_nsec += ts->tv_nsec) >= 1000000000) { at.tv_nsec -= 1000000000; at.tv_sec++; } } for (;;) { for (i=0; i__err; expect = EINPROGRESS | 0x80000000; a_cas(pfut, EINPROGRESS, expect); break; default: pfut = &__aio_fut; if (!tid) tid = __pthread_self()->tid; expect = a_cas(pfut, 0, tid); if (!expect) expect = tid; /* Need to recheck the predicate before waiting. */ for (i=0; i