diff options
| author | Kacper <kacper@mail.openlinux.dev> | 2025-12-15 02:01:33 +0100 |
|---|---|---|
| committer | Kacper <kacper@mail.openlinux.dev> | 2025-12-15 02:01:59 +0100 |
| commit | 3b3325f761b09ebbfef04c44eed546cc4fdeb329 (patch) | |
| tree | aa19ea259bcda2410c2b3dd4512f19fb85aeaf8f /lib/libc/include | |
| parent | 15d2df7811ef3cb79cc3e501d0d5f9b993d42bea (diff) | |
Added aio and eventfd support, along with sleep and yes utilities
Diffstat (limited to 'lib/libc/include')
| -rw-r--r-- | lib/libc/include/__aio.h | 35 | ||||
| -rw-r--r-- | lib/libc/include/io_uring.h | 53 |
2 files changed, 88 insertions, 0 deletions
diff --git a/lib/libc/include/__aio.h b/lib/libc/include/__aio.h new file mode 100644 index 00000000..93cb1f79 --- /dev/null +++ b/lib/libc/include/__aio.h @@ -0,0 +1,35 @@ +#ifndef __LIBC_AIO_H +#define __LIBC_AIO_H + +#include <aio.h> + +#define AIO_REQUEST_STATUS_PENDING 0 +#define AIO_REQUEST_STATUS_COMPLETED 1 + +struct lio_group { + int pending; + int error; + int eventfd; + struct sigevent *sig; +}; + +struct aio_context { + struct aio_request *head; + struct aio_request *tail; +}; + +struct aio_request { + struct aiocb *aiocbp; + int status; + ssize_t result; + struct aio_request *next; + struct lio_group *grp; +}; + +void __aio_poll(void); + +int __aio_request(struct aio_request *, int); +struct aio_request *__aio_lookup(const struct aiocb *); +struct aio_request *__aio_remove(const struct aiocb *); + +#endif diff --git a/lib/libc/include/io_uring.h b/lib/libc/include/io_uring.h new file mode 100644 index 00000000..4dac4583 --- /dev/null +++ b/lib/libc/include/io_uring.h @@ -0,0 +1,53 @@ +#ifndef __LIBC_IO_URING_H +#define __LIBC_IO_URING_H + +#include <linux/io_uring.h> +#include <signal.h> + +#define IO_URING_ENTRIES 256 + +struct io_uring_sq { + void *ring; + size_t ring_size; + struct io_uring_sqe *sqes; + + unsigned *head; + unsigned *tail; + unsigned *ring_mask; + unsigned *ring_entries; + unsigned *flags; + unsigned *dropped; + unsigned *array; +}; + +struct io_uring_cq { + void *ring; + size_t ring_size; + + unsigned *head; + unsigned *tail; + unsigned *ring_mask; + unsigned *ring_entries; + unsigned *overflow; + struct io_uring_cqe *cqes; + unsigned *flags; +}; + +struct io_uring { + int fd; + int eventfd; + + struct io_uring_sq sq; + struct io_uring_cq cq; +}; + +extern struct io_uring __io_uring; + +int io_uring_setup(unsigned int, struct io_uring_params *); + +int io_uring_register(unsigned int, unsigned int, void *, unsigned int); + +int io_uring_enter(unsigned int, unsigned int, unsigned int, unsigned int, + sigset_t *, size_t); + +#endif |
