commit d061d1b8f04e9b1554c7dd85ceb9358fbc6f4bff
parent ad0e2cef986d0df1ce241945147b846deb11f349
Author: Drew DeVault <sir@cmpwn.com>
Date: Mon, 17 May 2021 18:37:18 -0400
linux::io_uring: add fixed read/write
Signed-off-by: Drew DeVault <sir@cmpwn.com>
Diffstat:
1 file changed, 40 insertions(+), 4 deletions(-)
diff --git a/linux/io_uring/sqe.ha b/linux/io_uring/sqe.ha
@@ -36,8 +36,10 @@ export fn readv(
fd: int,
iov: []rt::iovec,
offs: size,
+ flags: sqe_flags...
) void = {
- preprw(sqe, op::READV, fd, iov: *[*]rt::iovec, len(iov): uint, offs);
+ preprw(sqe, op::READV, fd,
+ iov: *[*]rt::iovec, len(iov): uint, offs, flags...);
};
// Prepares a vectored write operation for an [[sqe]].
@@ -46,8 +48,10 @@ export fn writev(
fd: int,
iov: []rt::iovec,
offs: size,
+ flags: sqe_flags...
) void = {
- preprw(sqe, op::WRITEV, fd, iov: *[*]rt::iovec, len(iov): uint, offs);
+ preprw(sqe, op::WRITEV, fd,
+ iov: *[*]rt::iovec, len(iov): uint, offs, flags...);
};
// Prepares a read operation for an [[sqe]].
@@ -56,7 +60,7 @@ export fn read(
fd: int,
buf: *void,
count: size,
- flags: sqe_flags...,
+ flags: sqe_flags...
) void = {
assert(count <= types::U32_MAX);
preprw(sqe, op::READ, fd, buf, count: u32, 0, flags...);
@@ -68,8 +72,40 @@ export fn write(
fd: int,
buf: *void,
count: size,
- flags: sqe_flags...,
+ flags: sqe_flags...
) void = {
assert(count <= types::U32_MAX);
preprw(sqe, op::WRITE, fd, buf, count: u32, 0, flags...);
};
+
+// Prepares a read for a fixed buffer previously registered with
+// [[register_buffers]]. The buf and count parameters must refer to an address
+// which falls within the buffer referenced by the index parameter.
+export fn read_fixed(
+ sqe: *sqe,
+ fd: int,
+ buf: *void,
+ count: size,
+ index: u16,
+ flags: sqe_flags...
+) void = {
+ assert(count <= types::U32_MAX);
+ preprw(sqe, op::READ_FIXED, fd, buf, count: u32, 0, flags...);
+ sqe.buf_index = index;
+};
+
+// Prepares a write for a fixed buffer previously registered with
+// [[register_buffers]]. The buf and count parameters must refer to an address
+// which falls within the buffer referenced by the index parameter.
+export fn write_fixed(
+ sqe: *sqe,
+ fd: int,
+ buf: *void,
+ count: size,
+ index: u16,
+ flags: sqe_flags...
+) void = {
+ assert(count <= types::U32_MAX);
+ preprw(sqe, op::WRITE_FIXED, fd, buf, count: u32, 0, flags...);
+ sqe.buf_index = index;
+};