| 55 | } |
| 56 | |
| 57 | int main(int argc, char *argv[]) |
| 58 | { |
| 59 | struct io_uring_reg_wait *reg; |
| 60 | struct io_uring_sqe *sqe; |
| 61 | struct io_uring_cqe *cqe[2]; |
| 62 | struct io_uring ring; |
| 63 | char b1[8], b2[8]; |
| 64 | unsigned long msec; |
| 65 | struct timeval tv; |
| 66 | int ret, fds[2]; |
| 67 | int page_size; |
| 68 | |
| 69 | if (argc > 1) { |
| 70 | fprintf(stdout, "%s: takes no arguments\n", argv[0]); |
| 71 | return 0; |
| 72 | } |
| 73 | |
| 74 | page_size = sysconf(_SC_PAGESIZE); |
| 75 | if (page_size < 0) { |
| 76 | fprintf(stderr, "sysconf(_SC_PAGESIZE) failed\n"); |
| 77 | return 1; |
| 78 | } |
| 79 | |
| 80 | if (pipe(fds) < 0) { |
| 81 | perror("pipe"); |
| 82 | return 1; |
| 83 | } |
| 84 | |
| 85 | ret = io_uring_queue_init(8, &ring, IORING_SETUP_R_DISABLED); |
| 86 | if (ret) { |
| 87 | fprintf(stderr, "Queue init: %d\n", ret); |
| 88 | return 1; |
| 89 | } |
| 90 | |
| 91 | /* |
| 92 | * Setup a region we'll use to pass wait arguments. It should be |
| 93 | * page aligned, we're using only first two wait entries here and |
| 94 | * the rest of the memory can be reused for other purposes. |
| 95 | */ |
| 96 | reg = t_aligned_alloc(page_size, page_size); |
| 97 | if (!reg) { |
| 98 | fprintf(stderr, "allocation failed\n"); |
| 99 | return 1; |
| 100 | } |
| 101 | |
| 102 | ret = register_memory(&ring, reg, page_size); |
| 103 | if (ret) { |
| 104 | if (ret == -EINVAL) { |
| 105 | fprintf(stderr, "Kernel doesn't support registered waits\n"); |
| 106 | return 1; |
| 107 | } |
| 108 | fprintf(stderr, "Registered wait: %d\n", ret); |
| 109 | return 1; |
| 110 | } |
| 111 | |
| 112 | ret = io_uring_enable_rings(&ring); |
| 113 | if (ret) { |
| 114 | fprintf(stderr, "io_uring_enable_rings failure %i\n", ret); |
nothing calls this directly
no test coverage detected