- ret = __timedwait(&seq, last, CLOCK_MONOTONIC,
- ts ? &at : 0, 0, 0, 1);
+ switch (nzcnt) {
+ case 0:
+ pfut = &dummy_fut;
+ break;
+ case 1:
+ pfut = (void *)&cb->__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<cnt; i++)
+ if (cbs[i] && aio_error(cbs[i]) != EINPROGRESS)
+ return 0;
+ break;
+ }