From 4e8199b572f2035b7749cba276ece3a26630d23e Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 17 Apr 2024 14:18:21 +0200 Subject: Adding upstream version 1.67.1+dfsg1. Signed-off-by: Daniel Baumann --- .../src/backend/linux_raw/io_uring/syscalls.rs | 63 ++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 vendor/rustix/src/backend/linux_raw/io_uring/syscalls.rs (limited to 'vendor/rustix/src/backend/linux_raw/io_uring/syscalls.rs') diff --git a/vendor/rustix/src/backend/linux_raw/io_uring/syscalls.rs b/vendor/rustix/src/backend/linux_raw/io_uring/syscalls.rs new file mode 100644 index 000000000..196676985 --- /dev/null +++ b/vendor/rustix/src/backend/linux_raw/io_uring/syscalls.rs @@ -0,0 +1,63 @@ +//! linux_raw syscalls supporting `rustix::io_uring`. +//! +//! # Safety +//! +//! See the `rustix::backend::syscalls` module documentation for details. +#![allow(unsafe_code)] +#![allow(clippy::undocumented_unsafe_blocks)] + +use super::super::conv::{by_mut, c_uint, pass_usize, ret, ret_c_uint, ret_owned_fd}; +use crate::fd::{BorrowedFd, OwnedFd}; +use crate::io; +use crate::io_uring::{io_uring_params, IoringEnterFlags, IoringRegisterOp}; +use core::ffi::c_void; + +#[inline] +pub(crate) fn io_uring_setup(entries: u32, params: &mut io_uring_params) -> io::Result { + unsafe { + ret_owned_fd(syscall!( + __NR_io_uring_setup, + c_uint(entries), + by_mut(params) + )) + } +} + +#[inline] +pub(crate) unsafe fn io_uring_register( + fd: BorrowedFd<'_>, + opcode: IoringRegisterOp, + arg: *const c_void, + nr_args: u32, +) -> io::Result<()> { + ret(syscall_readonly!( + __NR_io_uring_register, + fd, + c_uint(opcode as u32), + arg, + c_uint(nr_args) + )) +} + +#[inline] +pub(crate) unsafe fn io_uring_enter( + fd: BorrowedFd<'_>, + to_submit: u32, + min_complete: u32, + flags: IoringEnterFlags, + arg: *const c_void, + size: usize, +) -> io::Result { + // This is not `_readonly` because `io_uring_enter` waits for I/O to + // complete, and I/O could involve writing to memory buffers, which + // could be a side effect depended on by the caller. + ret_c_uint(syscall!( + __NR_io_uring_enter, + fd, + c_uint(to_submit), + c_uint(min_complete), + flags, + arg, + pass_usize(size) + )) +} -- cgit v1.2.3