6 #include "pthread_impl.h"
8 int aio_suspend(const struct aiocb
*const cbs
[], int cnt
, const struct timespec
*ts
)
10 int i
, tid
= 0, ret
, expect
= 0;
12 volatile int dummy_fut
, *pfut
;
14 const struct aiocb
*cb
= 0;
23 for (i
=0; i
<cnt
; i
++) if (cbs
[i
]) {
24 if (aio_error(cbs
[i
]) != EINPROGRESS
) return 0;
30 clock_gettime(CLOCK_MONOTONIC
, &at
);
31 at
.tv_sec
+= ts
->tv_sec
;
32 if ((at
.tv_nsec
+= ts
->tv_nsec
) >= 1000000000) {
33 at
.tv_nsec
-= 1000000000;
40 if (cbs
[i
] && aio_error(cbs
[i
]) != EINPROGRESS
)
48 pfut
= (void *)&cb
->__err
;
49 expect
= EINPROGRESS
| 0x80000000;
50 a_cas(pfut
, EINPROGRESS
, expect
);
54 if (!tid
) tid
= __pthread_self()->tid
;
55 expect
= a_cas(pfut
, 0, tid
);
56 if (!expect
) expect
= tid
;
57 /* Need to recheck the predicate before waiting. */
59 if (cbs
[i
] && aio_error(cbs
[i
]) != EINPROGRESS
)
64 ret
= __timedwait_cp(pfut
, expect
, CLOCK_MONOTONIC
, ts
?&at
:0, 1);