Skip to content

Commit

Permalink
Revert "Fix nightly compiler complaints about size_of"
Browse files Browse the repository at this point in the history
This reverts commit 50b41c7.
  • Loading branch information
SUPERCILEX committed Jul 1, 2024
1 parent 50b41c7 commit 72ba1f1
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 16 deletions.
9 changes: 4 additions & 5 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,9 @@ mod sys;
pub mod types;

use std::marker::PhantomData;
use std::mem::size_of;
use std::mem::ManuallyDrop;
use std::os::unix::io::{AsRawFd, FromRawFd, RawFd};
use std::{cmp, io};
use std::{cmp, io, mem};

#[cfg(feature = "io_safety")]
use std::os::unix::io::{AsFd, BorrowedFd};
Expand Down Expand Up @@ -136,9 +135,9 @@ impl<S: squeue::EntryMarker, C: cqueue::EntryMarker> IoUring<S, C> {
fd: &OwnedFd,
p: &sys::io_uring_params,
) -> io::Result<(MemoryMap, squeue::Inner<S>, cqueue::Inner<C>)> {
let sq_len = p.sq_off.array as usize + p.sq_entries as usize * size_of::<u32>();
let cq_len = p.cq_off.cqes as usize + p.cq_entries as usize * size_of::<C>();
let sqe_len = p.sq_entries as usize * size_of::<S>();
let sq_len = p.sq_off.array as usize + p.sq_entries as usize * mem::size_of::<u32>();
let cq_len = p.cq_off.cqes as usize + p.cq_entries as usize * mem::size_of::<C>();
let sqe_len = p.sq_entries as usize * mem::size_of::<S>();
let sqe_mmap = Mmap::new(fd, sys::IORING_OFF_SQES as _, sqe_len)?;

if p.features & sys::IORING_FEAT_SINGLE_MMAP != 0 {
Expand Down
3 changes: 1 addition & 2 deletions src/opcode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

use std::convert::TryInto;
use std::mem;
use std::mem::size_of;
use std::os::unix::io::RawFd;

use crate::squeue::Entry;
Expand Down Expand Up @@ -1107,7 +1106,7 @@ opcode! {
sqe.opcode = Self::CODE;
sqe.fd = dirfd;
sqe.__bindgen_anon_2.addr = pathname as _;
sqe.len = size_of::<sys::open_how>() as _;
sqe.len = mem::size_of::<sys::open_how>() as _;
sqe.__bindgen_anon_1.off = how as _;
if let Some(dest) = file_index {
sqe.__bindgen_anon_5.file_index = dest.kernel_index_arg();
Expand Down
9 changes: 4 additions & 5 deletions src/submit.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use std::mem::size_of;
use std::os::unix::io::{AsRawFd, RawFd};
use std::sync::atomic;
use std::{io, ptr};
use std::{io, mem, ptr};

use crate::register::{execute, Probe};
use crate::sys;
Expand Down Expand Up @@ -92,7 +91,7 @@ impl<'a> Submitter<'a> {
let arg = arg
.map(|arg| cast_ptr(arg).cast())
.unwrap_or_else(ptr::null);
let size = size_of::<T>();
let size = mem::size_of::<T>();
sys::io_uring_enter(
self.fd.as_raw_fd(),
to_submit,
Expand Down Expand Up @@ -211,7 +210,7 @@ impl<'a> Submitter<'a> {
self.fd.as_raw_fd(),
sys::IORING_REGISTER_FILES2,
cast_ptr::<sys::io_uring_rsrc_register>(&rr).cast(),
size_of::<sys::io_uring_rsrc_register>() as _,
mem::size_of::<sys::io_uring_rsrc_register>() as _,
)
.map(drop)
}
Expand Down Expand Up @@ -412,7 +411,7 @@ impl<'a> Submitter<'a> {
self.fd.as_raw_fd(),
sys::IORING_REGISTER_IOWQ_AFF,
cpu_set as *const _ as *const libc::c_void,
size_of::<libc::cpu_set_t>() as u32,
mem::size_of::<libc::cpu_set_t>() as u32,
)
.map(drop)
}
Expand Down
6 changes: 2 additions & 4 deletions src/types.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
//! Common Linux types not provided by libc.

use std::mem::size_of;

pub(crate) mod sealed {
use super::{Fd, Fixed};
use std::os::unix::io::RawFd;
Expand Down Expand Up @@ -252,7 +250,7 @@ impl<'prev, 'now> SubmitArgs<'prev, 'now> {
#[inline]
pub fn sigmask<'new>(mut self, sigmask: &'new libc::sigset_t) -> SubmitArgs<'now, 'new> {
self.args.sigmask = cast_ptr(sigmask) as _;
self.args.sigmask_sz = size_of::<libc::sigset_t>() as _;
self.args.sigmask_sz = std::mem::size_of::<libc::sigset_t>() as _;

SubmitArgs {
args: self.args,
Expand Down Expand Up @@ -387,7 +385,7 @@ pub struct RecvMsgOut<'buf> {
}

impl<'buf> RecvMsgOut<'buf> {
const DATA_START: usize = size_of::<sys::io_uring_recvmsg_out>();
const DATA_START: usize = std::mem::size_of::<sys::io_uring_recvmsg_out>();

/// Parse the data buffered upon completion of a `RecvMsg` multishot operation.
///
Expand Down

0 comments on commit 72ba1f1

Please sign in to comment.