summaryrefslogtreecommitdiff
path: root/lib/libc/aio/aio_error.c
blob: 27c7f1340ba0c76da4df4d21b327e8ab5e4e4ff8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#include <__aio.h>
#include <errno.h>
#include <stddef.h>

int aio_error(const struct aiocb *aiocbp)
{
	struct aio_request *req;

	if (aiocbp == NULL) {
		errno = EINVAL;
		return -1;
	}

	req = __aio_lookup(aiocbp);

	if (req == NULL) {
		errno = EINVAL;
		return -1;
	}

	if (req->status == AIO_REQUEST_STATUS_PENDING) {
		return EINPROGRESS;
	}

	return req->result < 0 ? -req->result : 0;
}