Skip to content

Commit

Permalink
Add support for fixed buffers
Browse files Browse the repository at this point in the history
  • Loading branch information
ollie-etl committed Nov 29, 2023
1 parent 4a11db4 commit a76d0e9
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/opcode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1482,20 +1482,25 @@ opcode! {
fd: { impl sealed::UseFixed },
cmd_op: { u32 },
;;
buf_index: Option<u16> = None,
/// Arbitrary command data.
cmd: [u8; 16] = [0u8; 16]
}

pub const CODE = sys::IORING_OP_URING_CMD;

pub fn build(self) -> Entry {
let UringCmd16 { fd, cmd_op, cmd } = self;
let UringCmd16 { fd, cmd_op, cmd, buf_index } = self;

let mut sqe = sqe_zeroed();
sqe.opcode = Self::CODE;
assign_fd!(sqe.fd = fd);
sqe.__bindgen_anon_1.__bindgen_anon_1.cmd_op = cmd_op;
unsafe { *sqe.__bindgen_anon_6.cmd.as_mut().as_mut_ptr().cast::<[u8; 16]>() = cmd };
if let Some(buf_index) = buf_index {
sqe.__bindgen_anon_4.buf_index = buf_index;
unsafe { sqe.__bindgen_anon_3.uring_cmd_flags |= 1}; // IORING_URING_CMD_FIXED
}
Entry(sqe)
}
}
Expand All @@ -1506,14 +1511,15 @@ opcode! {
fd: { impl sealed::UseFixed },
cmd_op: { u32 },
;;
buf_index: Option<u16> = None,
/// Arbitrary command data.
cmd: [u8; 80] = [0u8; 80]
}

pub const CODE = sys::IORING_OP_URING_CMD;

pub fn build(self) -> Entry128 {
let UringCmd80 { fd, cmd_op, cmd } = self;
let UringCmd80 { fd, cmd_op, cmd, buf_index } = self;

let cmd1 = cmd[..16].try_into().unwrap();
let cmd2 = cmd[16..].try_into().unwrap();
Expand All @@ -1523,6 +1529,10 @@ opcode! {
assign_fd!(sqe.fd = fd);
sqe.__bindgen_anon_1.__bindgen_anon_1.cmd_op = cmd_op;
unsafe { *sqe.__bindgen_anon_6.cmd.as_mut().as_mut_ptr().cast::<[u8; 16]>() = cmd1 };
if let Some(buf_index) = buf_index {
sqe.__bindgen_anon_4.buf_index = buf_index;
unsafe { sqe.__bindgen_anon_3.uring_cmd_flags |= 1}; // IORING_URING_CMD_FIXED
}
Entry128(Entry(sqe), cmd2)
}
}
Expand Down

0 comments on commit a76d0e9

Please sign in to comment.