]>
git.proxmox.com Git - wasi-libc.git/blob - libc-top-half/musl/src/aio/aio_suspend.c
5 #include "pthread_impl.h"
7 int aio_suspend(const struct aiocb
*const cbs
[], int cnt
, const struct timespec
*ts
)
9 int i
, tid
= 0, ret
, expect
= 0;
11 volatile int dummy_fut
, *pfut
;
13 const struct aiocb
*cb
= 0;
22 for (i
=0; i
<cnt
; i
++) if (cbs
[i
]) {
23 if (aio_error(cbs
[i
]) != EINPROGRESS
) return 0;
29 clock_gettime(CLOCK_MONOTONIC
, &at
);
30 at
.tv_sec
+= ts
->tv_sec
;
31 if ((at
.tv_nsec
+= ts
->tv_nsec
) >= 1000000000) {
32 at
.tv_nsec
-= 1000000000;
39 if (cbs
[i
] && aio_error(cbs
[i
]) != EINPROGRESS
)
47 pfut
= (void *)&cb
->__err
;
48 expect
= EINPROGRESS
| 0x80000000;
49 a_cas(pfut
, EINPROGRESS
, expect
);
53 if (!tid
) tid
= __pthread_self()->tid
;
54 expect
= a_cas(pfut
, 0, tid
);
55 if (!expect
) expect
= tid
;
56 /* Need to recheck the predicate before waiting. */
58 if (cbs
[i
] && aio_error(cbs
[i
]) != EINPROGRESS
)
63 ret
= __timedwait_cp(pfut
, expect
, CLOCK_MONOTONIC
, ts
?&at
:0, 1);
77 weak_alias(aio_suspend
, aio_suspend64
);