Skip to content

Commit

Permalink
Fix the definition of "struct stat" on 32-bit FreeBSD 12+
Browse files Browse the repository at this point in the history
The original definitions were never correct.  But nobody noticed because
we don't do CI on 32-bit FreeBSD.  The problem is apparent now due to
 #3723 , which caused the nightly toolchain to switch to a FreeBSD 12
ABI.

Fixes rust-lang/rust#130677
  • Loading branch information
asomers committed Sep 23, 2024
1 parent 9049542 commit 8aca9c0
Show file tree
Hide file tree
Showing 10 changed files with 146 additions and 173 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,26 @@
pub struct stat {
pub st_dev: ::dev_t,
pub st_ino: ::ino_t,
pub st_nlink: ::nlink_t,
pub st_mode: ::mode_t,
st_padding0: i16,
pub st_nlink: ::nlink_t,
pub st_uid: ::uid_t,
pub st_gid: ::gid_t,
st_padding1: i32,
pub st_rdev: ::dev_t,
pub st_atime: ::time_t,
pub st_atime_nsec: ::c_long,
pub st_mtime: ::time_t,
pub st_mtime_nsec: ::c_long,
pub st_ctime: ::time_t,
pub st_ctime_nsec: ::c_long,
pub st_birthtime: ::time_t,
pub st_birthtime_nsec: ::c_long,
pub st_size: ::off_t,
pub st_blocks: ::blkcnt_t,
pub st_blksize: ::blksize_t,
pub st_flags: ::fflags_t,
pub st_gen: u64,
pub st_spare: [u64; 10],
pub st_gen: u32,
pub st_lspare: i32,
pub st_birthtime: ::time_t,
pub st_birthtime_nsec: ::c_long,
__unused: [u8; 8],
}

impl ::Copy for ::stat {}
Expand Down
7 changes: 4 additions & 3 deletions src/unix/bsd/freebsdlike/freebsd/freebsd11/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -479,10 +479,11 @@ extern "C" {
}

cfg_if! {
if #[cfg(any(target_arch = "x86_64",
target_arch = "aarch64",
target_arch = "riscv64"))] {
if #[cfg(target_pointer_width = "64")] {
mod b64;
pub use self::b64::*;
} else {
mod b32;
pub use self::b32::*;
}
}
43 changes: 34 additions & 9 deletions src/unix/bsd/freebsdlike/freebsd/freebsd12/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,40 @@ s! {
/// kthread flag.
pub ki_tdflags: ::c_long,
}

pub struct stat {
pub st_dev: ::dev_t,
pub st_ino: ::ino_t,
pub st_nlink: ::nlink_t,
pub st_mode: ::mode_t,
st_padding0: i16,
pub st_uid: ::uid_t,
pub st_gid: ::gid_t,
st_padding1: i32,
pub st_rdev: ::dev_t,
#[cfg(target_arch = "x86")]
st_atim_ext: i32,
pub st_atime: ::time_t,
pub st_atime_nsec: ::c_long,
#[cfg(target_arch = "x86")]
st_mtim_ext: i32,
pub st_mtime: ::time_t,
pub st_mtime_nsec: ::c_long,
#[cfg(target_arch = "x86")]
st_ctim_ext: i32,
pub st_ctime: ::time_t,
pub st_ctime_nsec: ::c_long,
#[cfg(target_arch = "x86")]
st_btim_ext: i32,
pub st_birthtime: ::time_t,
pub st_birthtime_nsec: ::c_long,
pub st_size: ::off_t,
pub st_blocks: ::blkcnt_t,
pub st_blksize: ::blksize_t,
pub st_flags: ::fflags_t,
pub st_gen: u64,
pub st_spare: [u64; 10],
}
}

s_no_extra_traits! {
Expand Down Expand Up @@ -488,15 +522,6 @@ extern "C" {
pub fn basename(path: *mut ::c_char) -> *mut ::c_char;
}

cfg_if! {
if #[cfg(any(target_arch = "x86_64",
target_arch = "aarch64",
target_arch = "riscv64"))] {
mod b64;
pub use self::b64::*;
}
}

cfg_if! {
if #[cfg(target_arch = "x86_64")] {
mod x86_64;
Expand Down
34 changes: 0 additions & 34 deletions src/unix/bsd/freebsdlike/freebsd/freebsd13/b64.rs

This file was deleted.

43 changes: 34 additions & 9 deletions src/unix/bsd/freebsdlike/freebsd/freebsd13/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,40 @@ s! {
/// kthread flag.
pub ki_tdflags: ::c_long,
}

pub struct stat {
pub st_dev: ::dev_t,
pub st_ino: ::ino_t,
pub st_nlink: ::nlink_t,
pub st_mode: ::mode_t,
st_padding0: i16,
pub st_uid: ::uid_t,
pub st_gid: ::gid_t,
st_padding1: i32,
pub st_rdev: ::dev_t,
#[cfg(target_arch = "x86")]
st_atim_ext: i32,
pub st_atime: ::time_t,
pub st_atime_nsec: ::c_long,
#[cfg(target_arch = "x86")]
st_mtim_ext: i32,
pub st_mtime: ::time_t,
pub st_mtime_nsec: ::c_long,
#[cfg(target_arch = "x86")]
st_ctim_ext: i32,
pub st_ctime: ::time_t,
pub st_ctime_nsec: ::c_long,
#[cfg(target_arch = "x86")]
st_btim_ext: i32,
pub st_birthtime: ::time_t,
pub st_birthtime_nsec: ::c_long,
pub st_size: ::off_t,
pub st_blocks: ::blkcnt_t,
pub st_blksize: ::blksize_t,
pub st_flags: ::fflags_t,
pub st_gen: u64,
pub st_spare: [u64; 10],
}
}

s_no_extra_traits! {
Expand Down Expand Up @@ -529,15 +563,6 @@ extern "C" {
pub fn kvm_kerndisp(kd: *mut ::kvm_t) -> ::kssize_t;
}

cfg_if! {
if #[cfg(any(target_arch = "x86_64",
target_arch = "aarch64",
target_arch = "riscv64"))] {
mod b64;
pub use self::b64::*;
}
}

cfg_if! {
if #[cfg(target_arch = "x86_64")] {
mod x86_64;
Expand Down
34 changes: 0 additions & 34 deletions src/unix/bsd/freebsdlike/freebsd/freebsd14/b64.rs

This file was deleted.

43 changes: 34 additions & 9 deletions src/unix/bsd/freebsdlike/freebsd/freebsd14/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,40 @@ s! {
/// kthread flag.
pub ki_tdflags: ::c_long,
}

pub struct stat {
pub st_dev: ::dev_t,
pub st_ino: ::ino_t,
pub st_nlink: ::nlink_t,
pub st_mode: ::mode_t,
st_padding0: i16,
pub st_uid: ::uid_t,
pub st_gid: ::gid_t,
st_padding1: i32,
pub st_rdev: ::dev_t,
#[cfg(target_arch = "x86")]
st_atim_ext: i32,
pub st_atime: ::time_t,
pub st_atime_nsec: ::c_long,
#[cfg(target_arch = "x86")]
st_mtim_ext: i32,
pub st_mtime: ::time_t,
pub st_mtime_nsec: ::c_long,
#[cfg(target_arch = "x86")]
st_ctim_ext: i32,
pub st_ctime: ::time_t,
pub st_ctime_nsec: ::c_long,
#[cfg(target_arch = "x86")]
st_btim_ext: i32,
pub st_birthtime: ::time_t,
pub st_birthtime_nsec: ::c_long,
pub st_size: ::off_t,
pub st_blocks: ::blkcnt_t,
pub st_blksize: ::blksize_t,
pub st_flags: ::fflags_t,
pub st_gen: u64,
pub st_spare: [u64; 10],
}
}

s_no_extra_traits! {
Expand Down Expand Up @@ -529,15 +563,6 @@ extern "C" {
pub fn kvm_kerndisp(kd: *mut ::kvm_t) -> ::kssize_t;
}

cfg_if! {
if #[cfg(any(target_arch = "x86_64",
target_arch = "aarch64",
target_arch = "riscv64"))] {
mod b64;
pub use self::b64::*;
}
}

cfg_if! {
if #[cfg(target_arch = "x86_64")] {
mod x86_64;
Expand Down
34 changes: 0 additions & 34 deletions src/unix/bsd/freebsdlike/freebsd/freebsd15/b64.rs

This file was deleted.

43 changes: 34 additions & 9 deletions src/unix/bsd/freebsdlike/freebsd/freebsd15/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,40 @@ s! {
/// kthread flag.
pub ki_tdflags: ::c_long,
}

pub struct stat {
pub st_dev: ::dev_t,
pub st_ino: ::ino_t,
pub st_nlink: ::nlink_t,
pub st_mode: ::mode_t,
st_padding0: i16,
pub st_uid: ::uid_t,
pub st_gid: ::gid_t,
st_padding1: i32,
pub st_rdev: ::dev_t,
#[cfg(target_arch = "x86")]
st_atim_ext: i32,
pub st_atime: ::time_t,
pub st_atime_nsec: ::c_long,
#[cfg(target_arch = "x86")]
st_mtim_ext: i32,
pub st_mtime: ::time_t,
pub st_mtime_nsec: ::c_long,
#[cfg(target_arch = "x86")]
st_ctim_ext: i32,
pub st_ctime: ::time_t,
pub st_ctime_nsec: ::c_long,
#[cfg(target_arch = "x86")]
st_btim_ext: i32,
pub st_birthtime: ::time_t,
pub st_birthtime_nsec: ::c_long,
pub st_size: ::off_t,
pub st_blocks: ::blkcnt_t,
pub st_blksize: ::blksize_t,
pub st_flags: ::fflags_t,
pub st_gen: u64,
pub st_spare: [u64; 10],
}
}

s_no_extra_traits! {
Expand Down Expand Up @@ -529,15 +563,6 @@ extern "C" {
pub fn kvm_kerndisp(kd: *mut ::kvm_t) -> ::kssize_t;
}

cfg_if! {
if #[cfg(any(target_arch = "x86_64",
target_arch = "aarch64",
target_arch = "riscv64"))] {
mod b64;
pub use self::b64::*;
}
}

cfg_if! {
if #[cfg(target_arch = "x86_64")] {
mod x86_64;
Expand Down
Loading

0 comments on commit 8aca9c0

Please sign in to comment.