From 8b6fd0f6bb584b88fc5856719d0903ab9ecf106c Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Mon, 17 May 2021 18:37:18 -0400 Subject: [PATCH] linux::io_uring: add fixed read/write Signed-off-by: Drew DeVault --- io_uring/sqe.ha | 44 ++++++++++++++++++++++++++++++++++++++++---- diff --git a/io_uring/sqe.ha b/io_uring/sqe.ha index 0977b54ffc3b867828f649acabfa1cf2bad1f183..70e3dfaa4f899a234b74d2ac992ba2542b400e30 100644 --- a/io_uring/sqe.ha +++ b/io_uring/sqe.ha @@ -36,8 +36,10 @@ sqe: *sqe, 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 @@ sqe: *sqe, 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 @@ sqe: *sqe, 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 @@ sqe: *sqe, 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; +}; -- 2.48.1