MCPcopy Create free account
hub / github.com/axboe/liburing / prep

Function prep

test/submit-reuse.c:46–83  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

44static int no_stable;
45
46static int prep(int fd, char *str, int split, int async)
47{
48 struct io_uring_sqe *sqe;
49 struct iovec iovs[16];
50 int ret, i;
51
52 if (split) {
53 int vsize = STR_SIZE / 16;
54 void *ptr = str;
55
56 for (i = 0; i < 16; i++) {
57 iovs[i].iov_base = ptr;
58 iovs[i].iov_len = vsize;
59 ptr += vsize;
60 }
61 } else {
62 iovs[0].iov_base = str;
63 iovs[0].iov_len = STR_SIZE;
64 }
65
66 sqe = io_uring_get_sqe(&ring);
67 io_uring_prep_readv(sqe, fd, iovs, split ? 16 : 1, 0);
68 sqe->user_data = fd;
69 if (async)
70 sqe->flags = IOSQE_ASYNC;
71 ret = io_uring_submit(&ring);
72 if (ret != 1) {
73 fprintf(stderr, "submit got %d\n", ret);
74 return 1;
75 }
76 if (split) {
77 for (i = 0; i < 16; i++)
78 iovs[i].iov_base = NULL;
79 } else {
80 iovs[0].iov_base = NULL;
81 }
82 return 0;
83}
84
85static int wait_nr(int nr)
86{

Callers 1

test_reuseFunction · 0.85

Calls 2

io_uring_submitFunction · 0.85
io_uring_get_sqeFunction · 0.50

Tested by 1

test_reuseFunction · 0.68