Skip to content

Commit

Permalink
add io_uring_sqe_set_buf group
Browse files Browse the repository at this point in the history
Adds the free function io_uring_sqe_set_buf_group so that users of liburing-ffi don't have to navigate the complex io_uring_sqe structure.

Signed-off-by: Christian Mazakas <christian.mazakas@gmail.com>
  • Loading branch information
cmazakas committed Dec 9, 2024
1 parent c3d5d62 commit 1dd8059
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 2 deletions.
32 changes: 32 additions & 0 deletions man/io_uring_sqe_set_buf_group.3
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
.\" Copyright (C) 2024 Christian Mazakas <christian.mazakas@gmail.com>
.\"
.\" SPDX-License-Identifier: LGPL-2.0-or-later
.\"
.TH io_uring_sqe_set_buf_group 3 "December 9, 2024" "liburing-2.9" "liburing Manual"
.SH NAME
io_uring_sqe_set_buf_group \- set buf group for submission queue event
.SH SYNOPSIS
.nf
.B #include <liburing.h>
.PP
.BI "void io_uring_sqe_set_buf_group(struct io_uring_sqe *" sqe ","
.BI " int " bgid ");"
.fi
.SH DESCRIPTION
.PP
The
.BR io_uring_sqe_set_buf_group (3)
function sets the associated buf_group of the
.I sqe
to
.IR bgid .

After the caller has requested a submission queue entry (SQE) with
.BR io_uring_get_sqe (3) ,
they can associate a buf_group with the SQE used for multishot operations.

.SH RETURN VALUE
None
.SH SEE ALSO
.BR io_uring_get_sqe (3),
.BR io_uring_cqe_set_data (3)
6 changes: 6 additions & 0 deletions src/include/liburing.h
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,12 @@ IOURINGINLINE void io_uring_sqe_set_flags(struct io_uring_sqe *sqe,
sqe->flags = (__u8) flags;
}

IOURINGINLINE void io_uring_sqe_set_buf_group(struct io_uring_sqe *sqe,
int bgid)
{
sqe->buf_group = (__u16) bgid;
}

IOURINGINLINE void __io_uring_set_target_fixed_file(struct io_uring_sqe *sqe,
unsigned int file_index)
{
Expand Down
1 change: 1 addition & 0 deletions src/liburing-ffi.map
Original file line number Diff line number Diff line change
Expand Up @@ -223,4 +223,5 @@ LIBURING_2.9 {
io_uring_submit_and_wait_reg;
io_uring_clone_buffers_offset;
io_uring_register_region;
io_uring_sqe_set_buf_group;
} LIBURING_2.8;
4 changes: 2 additions & 2 deletions test/recv-multishot.c
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ static int test(struct args *args)
io_uring_prep_recv_multishot(sqe, fds[0], NULL, 0, 0);
}
sqe->flags |= IOSQE_BUFFER_SELECT;
sqe->buf_group = 7;
io_uring_sqe_set_buf_group(sqe, 7);
io_uring_sqe_set_data64(sqe, 1234);
io_uring_submit(&ring);

Expand Down Expand Up @@ -503,7 +503,7 @@ static int test_enobuf(void)
assert(sqe);
io_uring_prep_recv_multishot(sqe, fds[0], NULL, 0, 0);
io_uring_sqe_set_data64(sqe, 1);
sqe->buf_group = 0;
io_uring_sqe_set_buf_group(sqe, 0);
sqe->flags |= IOSQE_BUFFER_SELECT;

ret = io_uring_submit(&ring);
Expand Down

0 comments on commit 1dd8059

Please sign in to comment.