diff options
Diffstat (limited to 'lib/libc/aio/aio_error.c')
| -rw-r--r-- | lib/libc/aio/aio_error.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/lib/libc/aio/aio_error.c b/lib/libc/aio/aio_error.c new file mode 100644 index 00000000..27c7f134 --- /dev/null +++ b/lib/libc/aio/aio_error.c @@ -0,0 +1,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; +} |
