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

Function use_buf

test/regbuf-clone.c:56–91  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

54}
55
56static int use_buf(struct io_uring *ring, void *addr, int index)
57{
58 struct io_uring_sqe *sqe;
59 struct io_uring_cqe *cqe;
60 char src_buf[32];
61 int fds[2], ret;
62
63 fdinfo_read(ring);
64
65 if (pipe(fds) < 0)
66 return -errno;
67
68 memset(src_buf, 0xbb, sizeof(src_buf));
69
70 sqe = io_uring_get_sqe(ring);
71 io_uring_prep_read_fixed(sqe, fds[0], addr, sizeof(src_buf), 0, index);
72 io_uring_submit(ring);
73
74 ret = write(fds[1], src_buf, sizeof(src_buf));
75 if (ret < 0)
76 return -errno;
77
78 ret = io_uring_wait_cqe(ring, &cqe);
79 if (ret) {
80 fprintf(stderr, "wait_cqe: %d\n", ret);
81 return ret;
82 }
83
84 ret = cqe->res;
85 io_uring_cqe_seen(ring, cqe);
86 if (ret < 0)
87 return ret;
88 close(fds[0]);
89 close(fds[1]);
90 return 0;
91}
92
93static int test_offsets(void)
94{

Callers 2

test_offsetsFunction · 0.85
testFunction · 0.85

Calls 3

io_uring_submitFunction · 0.85
fdinfo_readFunction · 0.70
io_uring_get_sqeFunction · 0.50

Tested by 1

test_offsetsFunction · 0.68