diff options
| author | Xavier Del Campo Romero <xavi92@disroot.org> | 2025-07-06 22:12:11 +0200 |
|---|---|---|
| committer | Xavier Del Campo Romero <xavi92@disroot.org> | 2025-07-06 22:21:51 +0200 |
| commit | 4d2c6c230d1b2a502c4b58c54195b874860530b3 (patch) | |
| tree | 4ee7b7e045372d0f26630fe30a509c938c776696 /src/aio | |
| parent | 55f32781ea611873a08f195d437fc0123919d685 (diff) | |
| download | wnix-4d2c6c230d1b2a502c4b58c54195b874860530b3.tar.gz | |
Setup aio skeleton
Diffstat (limited to 'src/aio')
| -rw-r--r-- | src/aio/CMakeLists.txt | 6 | ||||
| -rw-r--r-- | src/aio/include/aio.h | 17 | ||||
| -rw-r--r-- | src/aio/private_include/aio/types.h | 16 | ||||
| -rw-r--r-- | src/aio/src/close.c | 16 | ||||
| -rw-r--r-- | src/aio/src/open.c | 15 |
5 files changed, 70 insertions, 0 deletions
diff --git a/src/aio/CMakeLists.txt b/src/aio/CMakeLists.txt new file mode 100644 index 0000000..3f4561a --- /dev/null +++ b/src/aio/CMakeLists.txt @@ -0,0 +1,6 @@ +set(src + "src/close.c" + "src/open.c" +) +add_library(aio ${src}) +target_include_directories(aio PUBLIC "include" PRIVATE "private_include") diff --git a/src/aio/include/aio.h b/src/aio/include/aio.h new file mode 100644 index 0000000..39a53e5 --- /dev/null +++ b/src/aio/include/aio.h @@ -0,0 +1,17 @@ +#ifndef AIO_H +#define AIO_H + +#include <stddef.h> + +enum +{ + AIO_POLLIN = 1, + AIO_POLLOUT = 1 << 1 +}; + +struct aio *aio_open(const char *path, const char *mode); +int aio_poll(struct aio **io, size_t n); +int aio_event(const struct aio *io, int ev); +int aio_close(struct aio *io); + +#endif diff --git a/src/aio/private_include/aio/types.h b/src/aio/private_include/aio/types.h new file mode 100644 index 0000000..31ee414 --- /dev/null +++ b/src/aio/private_include/aio/types.h @@ -0,0 +1,16 @@ +#ifndef AIO_PRV_OPEN_H +#define AIO_PRV_OPEN_H + +enum aio_state +{ + AIO_OK, + AIO_AGAIN, + AIO_FATAL +}; + +struct aio +{ + enum aio_state (*next)(struct aio *); +}; + +#endif diff --git a/src/aio/src/close.c b/src/aio/src/close.c new file mode 100644 index 0000000..a9ec348 --- /dev/null +++ b/src/aio/src/close.c @@ -0,0 +1,16 @@ +#include <aio.h> +#include <errno.h> +#include <stdio.h> +#include <stdlib.h> + +int aio_close(struct aio *const aio) +{ + if (!aio) + { + errno = EINVAL; + return EOF; + } + + free(aio); + return 0; +} diff --git a/src/aio/src/open.c b/src/aio/src/open.c new file mode 100644 index 0000000..6689051 --- /dev/null +++ b/src/aio/src/open.c @@ -0,0 +1,15 @@ +#include <aio/types.h> +#include <stddef.h> +#include <stdlib.h> + +struct aio *aio_open(const char *const path, const char *const mode) +{ + struct aio *const ret = malloc(sizeof *ret); + + if (!ret) + goto failure; + +failure: + free(ret); + return NULL; +} |
