Skip to content

Instantly share code, notes, and snippets.

@kawaii-ghost
Last active September 30, 2023 06:04
Show Gist options
  • Save kawaii-ghost/f7dc48a272865d2b4d5dfaa01e42ffc3 to your computer and use it in GitHub Desktop.
Save kawaii-ghost/f7dc48a272865d2b4d5dfaa01e42ffc3 to your computer and use it in GitHub Desktop.
#include <liburing.h>
#include <stdio.h>
#include <unistd.h>
#include <wchar.h>
int main(void)
{
struct io_uring ring;
io_uring_queue_init(1, &ring, 0);
struct io_uring_sqe *sqe = io_uring_get_sqe(&ring);
const wchar_t wstr[] = L"Hello, world!\n"
io_uring_prep_write(sqe, STDOUT_FILENO, wstr, sizeof(wstr) - sizeof(wstr[0]), 0);
io_uring_submit(&ring);
struct io_uring_cqe *cqe;
int ret = io_uring_wait_cqe(&ring, &cqe);
if (ret < 0) {
perror("io_uring_wait_cqe");
return 1;
}
if (cqe->res < 0) {
fprintf(stderr, "Sync write failed.\n");
return 1;
}
io_uring_cqe_seen(&ring, cqe);
io_uring_queue_exit(&ring);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment