Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions src/fuchsia/aarch64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,18 @@ s! {
pub st_uid: crate::uid_t,
pub st_gid: crate::gid_t,
pub st_rdev: crate::dev_t,
__pad0: c_ulong,
__pad0: Padding<c_ulong>,
pub st_size: off_t,
pub st_blksize: crate::blksize_t,
__pad1: c_int,
__pad1: Padding<c_int>,
pub st_blocks: crate::blkcnt_t,
pub st_atime: crate::time_t,
pub st_atime_nsec: c_long,
pub st_mtime: crate::time_t,
pub st_mtime_nsec: c_long,
pub st_ctime: crate::time_t,
pub st_ctime_nsec: c_long,
__unused: [c_uint; 2],
__unused: Padding<[c_uint; 2]>,
}

pub struct stat64 {
Expand All @@ -37,18 +37,18 @@ s! {
pub st_uid: crate::uid_t,
pub st_gid: crate::gid_t,
pub st_rdev: crate::dev_t,
__pad0: c_ulong,
__pad0: Padding<c_ulong>,
pub st_size: off_t,
pub st_blksize: crate::blksize_t,
__pad1: c_int,
__pad1: Padding<c_int>,
pub st_blocks: crate::blkcnt_t,
pub st_atime: crate::time_t,
pub st_atime_nsec: c_long,
pub st_mtime: crate::time_t,
pub st_mtime_nsec: c_long,
pub st_ctime: crate::time_t,
pub st_ctime_nsec: c_long,
__unused: [c_uint; 2],
__unused: Padding<[c_uint; 2]>,
}

pub struct ipc_perm {
Expand All @@ -59,8 +59,8 @@ s! {
pub cgid: crate::gid_t,
pub mode: crate::mode_t,
pub __seq: c_ushort,
__unused1: c_ulong,
__unused2: c_ulong,
__unused1: Padding<c_ulong>,
__unused2: Padding<c_ulong>,
}
}

Expand Down
56 changes: 28 additions & 28 deletions src/fuchsia/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,46 +121,46 @@ s! {
pub ru_stime: timeval,
pub ru_maxrss: c_long,
#[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
__pad1: u32,
__pad1: Padding<u32>,
pub ru_ixrss: c_long,
#[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
__pad2: u32,
__pad2: Padding<u32>,
pub ru_idrss: c_long,
#[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
__pad3: u32,
__pad3: Padding<u32>,
pub ru_isrss: c_long,
#[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
__pad4: u32,
__pad4: Padding<u32>,
pub ru_minflt: c_long,
#[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
__pad5: u32,
__pad5: Padding<u32>,
pub ru_majflt: c_long,
#[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
__pad6: u32,
__pad6: Padding<u32>,
pub ru_nswap: c_long,
#[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
__pad7: u32,
__pad7: Padding<u32>,
pub ru_inblock: c_long,
#[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
__pad8: u32,
__pad8: Padding<u32>,
pub ru_oublock: c_long,
#[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
__pad9: u32,
__pad9: Padding<u32>,
pub ru_msgsnd: c_long,
#[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
__pad10: u32,
__pad10: Padding<u32>,
pub ru_msgrcv: c_long,
#[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
__pad11: u32,
__pad11: Padding<u32>,
pub ru_nsignals: c_long,
#[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
__pad12: u32,
__pad12: Padding<u32>,
pub ru_nvcsw: c_long,
#[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
__pad13: u32,
__pad13: Padding<u32>,
pub ru_nivcsw: c_long,
#[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
__pad14: u32,
__pad14: Padding<u32>,
}

pub struct in_addr {
Expand Down Expand Up @@ -427,11 +427,11 @@ s! {
pub gl_offs: size_t,
pub gl_flags: c_int,

__unused1: *mut c_void,
__unused2: *mut c_void,
__unused3: *mut c_void,
__unused4: *mut c_void,
__unused5: *mut c_void,
__unused1: Padding<*mut c_void>,
__unused2: Padding<*mut c_void>,
__unused3: Padding<*mut c_void>,
__unused4: Padding<*mut c_void>,
__unused5: Padding<*mut c_void>,
}

pub struct ifaddrs {
Expand Down Expand Up @@ -516,7 +516,7 @@ s! {
pub ssi_stime: u64,
pub ssi_addr: u64,
pub ssi_addr_lsb: u16,
_pad2: u16,
_pad2: Padding<u16>,
pub ssi_syscall: i32,
pub ssi_call_addr: u64,
pub ssi_arch: u32,
Expand Down Expand Up @@ -773,8 +773,8 @@ s! {
pub shm_cpid: crate::pid_t,
pub shm_lpid: crate::pid_t,
pub shm_nattch: c_ulong,
__pad1: c_ulong,
__pad2: c_ulong,
__pad1: Padding<c_ulong>,
__pad2: Padding<c_ulong>,
}

pub struct msqid_ds {
Expand All @@ -787,8 +787,8 @@ s! {
pub msg_qbytes: crate::msglen_t,
pub msg_lspid: crate::pid_t,
pub msg_lrpid: crate::pid_t,
__pad1: c_ulong,
__pad2: c_ulong,
__pad1: Padding<c_ulong>,
__pad2: Padding<c_ulong>,
}

pub struct statfs {
Expand All @@ -811,10 +811,10 @@ s! {
pub msg_namelen: crate::socklen_t,
pub msg_iov: *mut crate::iovec,
pub msg_iovlen: c_int,
__pad1: c_int,
__pad1: Padding<c_int>,
pub msg_control: *mut c_void,
pub msg_controllen: crate::socklen_t,
__pad2: crate::socklen_t,
__pad2: Padding<crate::socklen_t>,
pub msg_flags: c_int,
}

Expand Down Expand Up @@ -900,7 +900,7 @@ s! {

pub struct sockaddr_storage {
pub ss_family: sa_family_t,
__ss_pad2: [u8; 128 - 2 - 8],
__ss_pad2: Padding<[u8; 128 - 2 - 8]>,
__ss_align: size_t,
}

Expand Down Expand Up @@ -957,7 +957,7 @@ s! {

pub struct sockaddr_nl {
pub nl_family: crate::sa_family_t,
nl_pad: c_ushort,
nl_pad: Padding<c_ushort>,
pub nl_pid: u32,
pub nl_groups: u32,
}
Expand Down
8 changes: 4 additions & 4 deletions src/fuchsia/riscv64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ s! {
pub st_mode: crate::mode_t,
pub st_uid: crate::uid_t,
pub st_gid: crate::gid_t,
__pad0: c_int,
__pad0: Padding<c_int>,
pub st_rdev: crate::dev_t,
pub st_size: off_t,
pub st_blksize: crate::blksize_t,
Expand All @@ -28,7 +28,7 @@ s! {
pub st_mtime_nsec: c_long,
pub st_ctime: crate::time_t,
pub st_ctime_nsec: c_long,
__unused: [c_long; 3],
__unused: Padding<[c_long; 3]>,
}

// Not actually used, IPC calls just return ENOSYS
Expand All @@ -40,7 +40,7 @@ s! {
pub cgid: crate::gid_t,
pub mode: crate::mode_t,
pub __seq: c_ushort,
__unused1: c_ulong,
__unused2: c_ulong,
__unused1: Padding<c_ulong>,
__unused2: Padding<c_ulong>,
}
}
12 changes: 6 additions & 6 deletions src/fuchsia/x86_64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ s! {
pub st_mode: crate::mode_t,
pub st_uid: crate::uid_t,
pub st_gid: crate::gid_t,
__pad0: c_int,
__pad0: Padding<c_int>,
pub st_rdev: crate::dev_t,
pub st_size: off_t,
pub st_blksize: crate::blksize_t,
Expand All @@ -25,7 +25,7 @@ s! {
pub st_mtime_nsec: c_long,
pub st_ctime: crate::time_t,
pub st_ctime_nsec: c_long,
__unused: [c_long; 3],
__unused: Padding<[c_long; 3]>,
}

pub struct stat64 {
Expand All @@ -35,7 +35,7 @@ s! {
pub st_mode: crate::mode_t,
pub st_uid: crate::uid_t,
pub st_gid: crate::gid_t,
__pad0: c_int,
__pad0: Padding<c_int>,
pub st_rdev: crate::dev_t,
pub st_size: off_t,
pub st_blksize: crate::blksize_t,
Expand All @@ -46,7 +46,7 @@ s! {
pub st_mtime_nsec: c_long,
pub st_ctime: crate::time_t,
pub st_ctime_nsec: c_long,
__reserved: [c_long; 3],
__reserved: Padding<[c_long; 3]>,
}

pub struct mcontext_t {
Expand All @@ -61,8 +61,8 @@ s! {
pub cgid: crate::gid_t,
pub mode: crate::mode_t,
pub __seq: c_int,
__unused1: c_long,
__unused2: c_long,
__unused1: Padding<c_long>,
__unused2: Padding<c_long>,
}

pub struct ucontext_t {
Expand Down
4 changes: 2 additions & 2 deletions src/hermit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,9 @@ s! {
pub struct sockaddr_storage {
pub ss_len: u8,
pub ss_family: sa_family_t,
__ss_pad1: [u8; 6],
__ss_pad1: Padding<[u8; 6]>,
__ss_align: i64,
__ss_pad2: [u8; 112],
__ss_pad2: Padding<[u8; 112]>,
}

pub struct stat {
Expand Down
2 changes: 1 addition & 1 deletion src/new/linux_uapi/linux/can.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ s! {
pub can_id: canid_t,
// FIXME(1.0): this field was renamed to `len` in Linux 5.11
pub can_dlc: u8,
__pad: u8,
__pad: Padding<u8>,
__res0: u8,
pub len8_dlc: u8,
pub data: [u8; CAN_MAX_DLEN],
Expand Down
20 changes: 20 additions & 0 deletions src/types.rs
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you split the changes to this file to a separate commit? It's distinct from the rest of the mechanical changes in this PR.

Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
//! Platform-agnostic support types.

#[cfg(feature = "extra_traits")]
use core::hash::Hash;
use core::mem::MaybeUninit;

use crate::prelude::*;
Expand Down Expand Up @@ -30,6 +32,24 @@ impl<T: Copy> fmt::Debug for Padding<T> {
}
}

/// Do nothing when hashing to ignore the existence of padding fields.
#[cfg(feature = "extra_traits")]
impl<T: Copy> Hash for Padding<T> {
fn hash<H: hash::Hasher>(&self, _state: &mut H) {}
}

/// Padding fields are all equal, regardless of what is inside them, so they do not affect anything.
#[cfg(feature = "extra_traits")]
impl<T: Copy> PartialEq for Padding<T> {
fn eq(&self, _other: &Self) -> bool {
true
}
}

/// Mark that `Padding` implements `Eq` so that it can be used in types that implement it.
#[cfg(feature = "extra_traits")]
impl<T: Copy> Eq for Padding<T> {}

/// The default repr type used for C style enums in Rust.
#[cfg(target_env = "msvc")]
#[allow(unused)]
Expand Down
4 changes: 2 additions & 2 deletions src/unix/aix/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -251,9 +251,9 @@ s! {
pub struct sockaddr_storage {
pub __ss_len: c_uchar,
pub ss_family: sa_family_t,
__ss_pad1: [c_char; 6],
__ss_pad1: Padding<[c_char; 6]>,
__ss_align: crate::int64_t,
__ss_pad2: [c_char; 1265],
__ss_pad2: Padding<[c_char; 1265]>,
}

pub struct sockaddr_un {
Expand Down
Loading
Loading