Last active
September 30, 2023 06:04
-
-
Save kawaii-ghost/f7dc48a272865d2b4d5dfaa01e42ffc3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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