Skip to content

Commit 0d418d3

Browse files
committed
Fix the definition of "struct stat" on 32-bit FreeBSD 12+
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
1 parent c1d1f34 commit 0d418d3

File tree

13 files changed

+146
-256
lines changed

13 files changed

+146
-256
lines changed

src/unix/bsd/freebsdlike/freebsd/arm.rs

-30
Original file line numberDiff line numberDiff line change
@@ -6,36 +6,6 @@ pub type time_t = i64;
66
pub type suseconds_t = i32;
77
pub type register_t = i32;
88

9-
s! {
10-
pub struct stat {
11-
pub st_dev: ::dev_t,
12-
pub st_ino: ::ino_t,
13-
pub st_mode: ::mode_t,
14-
pub st_nlink: ::nlink_t,
15-
pub st_uid: ::uid_t,
16-
pub st_gid: ::gid_t,
17-
pub st_rdev: ::dev_t,
18-
pub st_atime: ::time_t,
19-
pub st_atime_nsec: ::c_long,
20-
pub st_atime_pad: ::c_long,
21-
pub st_mtime: ::time_t,
22-
pub st_mtime_nsec: ::c_long,
23-
pub st_mtime_pad: ::c_long,
24-
pub st_ctime: ::time_t,
25-
pub st_ctime_nsec: ::c_long,
26-
pub st_ctime_pad: ::c_long,
27-
pub st_size: ::off_t,
28-
pub st_blocks: ::blkcnt_t,
29-
pub st_blksize: ::blksize_t,
30-
pub st_flags: ::fflags_t,
31-
pub st_gen: u32,
32-
pub st_lspare: i32,
33-
pub st_birthtime: ::time_t,
34-
pub st_birthtime_nsec: ::c_long,
35-
pub st_birthtime_pad: ::c_long,
36-
}
37-
}
38-
399
pub(crate) const _ALIGNBYTES: usize = ::mem::size_of::<::c_int>() - 1;
4010
pub const MAP_32BIT: ::c_int = 0x00080000;
4111
pub const MINSIGSTKSZ: ::size_t = 4096; // 1024 * 4

src/unix/bsd/freebsdlike/freebsd/freebsd12/b64.rs renamed to src/unix/bsd/freebsdlike/freebsd/freebsd11/b32.rs

+6-7
Original file line numberDiff line numberDiff line change
@@ -3,27 +3,26 @@
33
pub struct stat {
44
pub st_dev: ::dev_t,
55
pub st_ino: ::ino_t,
6-
pub st_nlink: ::nlink_t,
76
pub st_mode: ::mode_t,
8-
st_padding0: i16,
7+
pub st_nlink: ::nlink_t,
98
pub st_uid: ::uid_t,
109
pub st_gid: ::gid_t,
11-
st_padding1: i32,
1210
pub st_rdev: ::dev_t,
1311
pub st_atime: ::time_t,
1412
pub st_atime_nsec: ::c_long,
1513
pub st_mtime: ::time_t,
1614
pub st_mtime_nsec: ::c_long,
1715
pub st_ctime: ::time_t,
1816
pub st_ctime_nsec: ::c_long,
19-
pub st_birthtime: ::time_t,
20-
pub st_birthtime_nsec: ::c_long,
2117
pub st_size: ::off_t,
2218
pub st_blocks: ::blkcnt_t,
2319
pub st_blksize: ::blksize_t,
2420
pub st_flags: ::fflags_t,
25-
pub st_gen: u64,
26-
pub st_spare: [u64; 10],
21+
pub st_gen: u32,
22+
pub st_lspare: i32,
23+
pub st_birthtime: ::time_t,
24+
pub st_birthtime_nsec: ::c_long,
25+
__unused: [u8; 8],
2726
}
2827

2928
impl ::Copy for ::stat {}

src/unix/bsd/freebsdlike/freebsd/freebsd11/mod.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -479,10 +479,11 @@ extern "C" {
479479
}
480480

481481
cfg_if! {
482-
if #[cfg(any(target_arch = "x86_64",
483-
target_arch = "aarch64",
484-
target_arch = "riscv64"))] {
482+
if #[cfg(target_pointer_width = "64")] {
485483
mod b64;
486484
pub use self::b64::*;
485+
} else {
486+
mod b32;
487+
pub use self::b32::*;
487488
}
488489
}

src/unix/bsd/freebsdlike/freebsd/freebsd12/mod.rs

+34-9
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,40 @@ s! {
218218
/// kthread flag.
219219
pub ki_tdflags: ::c_long,
220220
}
221+
222+
pub struct stat {
223+
pub st_dev: ::dev_t,
224+
pub st_ino: ::ino_t,
225+
pub st_nlink: ::nlink_t,
226+
pub st_mode: ::mode_t,
227+
st_padding0: i16,
228+
pub st_uid: ::uid_t,
229+
pub st_gid: ::gid_t,
230+
st_padding1: i32,
231+
pub st_rdev: ::dev_t,
232+
#[cfg(target_arch = "x86")]
233+
st_atim_ext: i32,
234+
pub st_atime: ::time_t,
235+
pub st_atime_nsec: ::c_long,
236+
#[cfg(target_arch = "x86")]
237+
st_mtim_ext: i32,
238+
pub st_mtime: ::time_t,
239+
pub st_mtime_nsec: ::c_long,
240+
#[cfg(target_arch = "x86")]
241+
st_ctim_ext: i32,
242+
pub st_ctime: ::time_t,
243+
pub st_ctime_nsec: ::c_long,
244+
#[cfg(target_arch = "x86")]
245+
st_btim_ext: i32,
246+
pub st_birthtime: ::time_t,
247+
pub st_birthtime_nsec: ::c_long,
248+
pub st_size: ::off_t,
249+
pub st_blocks: ::blkcnt_t,
250+
pub st_blksize: ::blksize_t,
251+
pub st_flags: ::fflags_t,
252+
pub st_gen: u64,
253+
pub st_spare: [u64; 10],
254+
}
221255
}
222256

223257
s_no_extra_traits! {
@@ -488,15 +522,6 @@ extern "C" {
488522
pub fn basename(path: *mut ::c_char) -> *mut ::c_char;
489523
}
490524

491-
cfg_if! {
492-
if #[cfg(any(target_arch = "x86_64",
493-
target_arch = "aarch64",
494-
target_arch = "riscv64"))] {
495-
mod b64;
496-
pub use self::b64::*;
497-
}
498-
}
499-
500525
cfg_if! {
501526
if #[cfg(target_arch = "x86_64")] {
502527
mod x86_64;

src/unix/bsd/freebsdlike/freebsd/freebsd13/b64.rs

-34
This file was deleted.

src/unix/bsd/freebsdlike/freebsd/freebsd13/mod.rs

+34-9
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,40 @@ s! {
228228
/// kthread flag.
229229
pub ki_tdflags: ::c_long,
230230
}
231+
232+
pub struct stat {
233+
pub st_dev: ::dev_t,
234+
pub st_ino: ::ino_t,
235+
pub st_nlink: ::nlink_t,
236+
pub st_mode: ::mode_t,
237+
st_padding0: i16,
238+
pub st_uid: ::uid_t,
239+
pub st_gid: ::gid_t,
240+
st_padding1: i32,
241+
pub st_rdev: ::dev_t,
242+
#[cfg(target_arch = "x86")]
243+
st_atim_ext: i32,
244+
pub st_atime: ::time_t,
245+
pub st_atime_nsec: ::c_long,
246+
#[cfg(target_arch = "x86")]
247+
st_mtim_ext: i32,
248+
pub st_mtime: ::time_t,
249+
pub st_mtime_nsec: ::c_long,
250+
#[cfg(target_arch = "x86")]
251+
st_ctim_ext: i32,
252+
pub st_ctime: ::time_t,
253+
pub st_ctime_nsec: ::c_long,
254+
#[cfg(target_arch = "x86")]
255+
st_btim_ext: i32,
256+
pub st_birthtime: ::time_t,
257+
pub st_birthtime_nsec: ::c_long,
258+
pub st_size: ::off_t,
259+
pub st_blocks: ::blkcnt_t,
260+
pub st_blksize: ::blksize_t,
261+
pub st_flags: ::fflags_t,
262+
pub st_gen: u64,
263+
pub st_spare: [u64; 10],
264+
}
231265
}
232266

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

532-
cfg_if! {
533-
if #[cfg(any(target_arch = "x86_64",
534-
target_arch = "aarch64",
535-
target_arch = "riscv64"))] {
536-
mod b64;
537-
pub use self::b64::*;
538-
}
539-
}
540-
541566
cfg_if! {
542567
if #[cfg(target_arch = "x86_64")] {
543568
mod x86_64;

src/unix/bsd/freebsdlike/freebsd/freebsd14/b64.rs

-34
This file was deleted.

src/unix/bsd/freebsdlike/freebsd/freebsd14/mod.rs

+34-9
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,40 @@ s! {
228228
/// kthread flag.
229229
pub ki_tdflags: ::c_long,
230230
}
231+
232+
pub struct stat {
233+
pub st_dev: ::dev_t,
234+
pub st_ino: ::ino_t,
235+
pub st_nlink: ::nlink_t,
236+
pub st_mode: ::mode_t,
237+
st_padding0: i16,
238+
pub st_uid: ::uid_t,
239+
pub st_gid: ::gid_t,
240+
st_padding1: i32,
241+
pub st_rdev: ::dev_t,
242+
#[cfg(target_arch = "x86")]
243+
st_atim_ext: i32,
244+
pub st_atime: ::time_t,
245+
pub st_atime_nsec: ::c_long,
246+
#[cfg(target_arch = "x86")]
247+
st_mtim_ext: i32,
248+
pub st_mtime: ::time_t,
249+
pub st_mtime_nsec: ::c_long,
250+
#[cfg(target_arch = "x86")]
251+
st_ctim_ext: i32,
252+
pub st_ctime: ::time_t,
253+
pub st_ctime_nsec: ::c_long,
254+
#[cfg(target_arch = "x86")]
255+
st_btim_ext: i32,
256+
pub st_birthtime: ::time_t,
257+
pub st_birthtime_nsec: ::c_long,
258+
pub st_size: ::off_t,
259+
pub st_blocks: ::blkcnt_t,
260+
pub st_blksize: ::blksize_t,
261+
pub st_flags: ::fflags_t,
262+
pub st_gen: u64,
263+
pub st_spare: [u64; 10],
264+
}
231265
}
232266

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

532-
cfg_if! {
533-
if #[cfg(any(target_arch = "x86_64",
534-
target_arch = "aarch64",
535-
target_arch = "riscv64"))] {
536-
mod b64;
537-
pub use self::b64::*;
538-
}
539-
}
540-
541566
cfg_if! {
542567
if #[cfg(target_arch = "x86_64")] {
543568
mod x86_64;

src/unix/bsd/freebsdlike/freebsd/freebsd15/b64.rs

-34
This file was deleted.

0 commit comments

Comments
 (0)