| 23 | } |
| 24 | |
| 25 | int main(void) |
| 26 | { |
| 27 | unsigned long tstop; |
| 28 | unsigned long nr_reqs = 0; |
| 29 | struct io_uring_cqe *cqe; |
| 30 | struct io_uring_sqe *sqe; |
| 31 | struct io_uring ring; |
| 32 | int pipe1[2]; |
| 33 | int ret, i, qd = 32; |
| 34 | |
| 35 | if (pipe(pipe1) != 0) { |
| 36 | perror("pipe"); |
| 37 | return 1; |
| 38 | } |
| 39 | |
| 40 | ret = io_uring_queue_init(1024, &ring, IORING_SETUP_SINGLE_ISSUER); |
| 41 | if (ret == -EINVAL) { |
| 42 | fprintf(stderr, "can't single\n"); |
| 43 | ret = io_uring_queue_init(1024, &ring, 0); |
| 44 | } |
| 45 | if (ret) { |
| 46 | fprintf(stderr, "child: ring setup failed: %d\n", ret); |
| 47 | return 1; |
| 48 | } |
| 49 | |
| 50 | ret = io_uring_register_files(&ring, pipe1, 2); |
| 51 | if (ret < 0) { |
| 52 | fprintf(stderr, "io_uring_register_files failed\n"); |
| 53 | return 1; |
| 54 | } |
| 55 | |
| 56 | ret = io_uring_register_ring_fd(&ring); |
| 57 | if (ret < 0) { |
| 58 | fprintf(stderr, "io_uring_register_ring_fd failed\n"); |
| 59 | return 1; |
| 60 | } |
| 61 | |
| 62 | tstop = gettimeofday_ms() + runtime_ms; |
| 63 | do { |
| 64 | for (i = 0; i < qd; i++) { |
| 65 | sqe = io_uring_get_sqe(&ring); |
| 66 | io_uring_prep_poll_add(sqe, 0, POLLIN); |
| 67 | sqe->flags |= IOSQE_FIXED_FILE; |
| 68 | sqe->user_data = 1; |
| 69 | } |
| 70 | |
| 71 | ret = io_uring_submit(&ring); |
| 72 | if (ret != qd) { |
| 73 | fprintf(stderr, "child: sqe submit failed: %d\n", ret); |
| 74 | return 1; |
| 75 | } |
| 76 | |
| 77 | ret = write(pipe1[1], buf, 1); |
| 78 | if (ret != 1) { |
| 79 | fprintf(stderr, "write failed %i\n", errno); |
| 80 | return 1; |
| 81 | } |
| 82 | ret = read(pipe1[0], buf, 1); |
nothing calls this directly
no test coverage detected