Skip to content

Commit 0e9c6f3

Browse files
authored
Merge pull request #3946 from asomers/main-stat32
Fix the definition of struct stat on 32-bit FreeBSD 12+
2 parents 2d221d7 + f9a3404 commit 0e9c6f3

File tree

13 files changed

+151
-263
lines changed

13 files changed

+151
-263
lines changed

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

-30
Original file line numberDiff line numberDiff line change
@@ -8,36 +8,6 @@ pub type register_t = i32;
88
pub type __greg_t = ::c_uint;
99
pub type __gregset_t = [::__greg_t; 17];
1010

11-
s! {
12-
pub struct stat {
13-
pub st_dev: ::dev_t,
14-
pub st_ino: ::ino_t,
15-
pub st_mode: ::mode_t,
16-
pub st_nlink: ::nlink_t,
17-
pub st_uid: ::uid_t,
18-
pub st_gid: ::gid_t,
19-
pub st_rdev: ::dev_t,
20-
pub st_atime: ::time_t,
21-
pub st_atime_nsec: ::c_long,
22-
pub st_atime_pad: ::c_long,
23-
pub st_mtime: ::time_t,
24-
pub st_mtime_nsec: ::c_long,
25-
pub st_mtime_pad: ::c_long,
26-
pub st_ctime: ::time_t,
27-
pub st_ctime_nsec: ::c_long,
28-
pub st_ctime_pad: ::c_long,
29-
pub st_size: ::off_t,
30-
pub st_blocks: ::blkcnt_t,
31-
pub st_blksize: ::blksize_t,
32-
pub st_flags: ::fflags_t,
33-
pub st_gen: u32,
34-
pub st_lspare: i32,
35-
pub st_birthtime: ::time_t,
36-
pub st_birthtime_nsec: ::c_long,
37-
pub st_birthtime_pad: ::c_long,
38-
}
39-
}
40-
4111
s_no_extra_traits! {
4212
pub struct mcontext_t {
4313
pub __gregs: ::__gregset_t,

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

+5-4
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
pub type nlink_t = u16;
55
// Type of `dev_t` changed from `u32` to `u64` in FreeBSD 12:
66
pub type dev_t = u32;
7-
// Type of `ino_t` changed from `unsigned int` to `unsigned long` in FreeBSD 12:
7+
// Type of `ino_t` changed from `__uint32_t` to `__uint64_t` in FreeBSD 12:
88
pub type ino_t = u32;
99

1010
s! {
@@ -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

+35-10
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
pub type nlink_t = u64;
44
pub type dev_t = u64;
5-
pub type ino_t = ::c_ulong;
5+
pub type ino_t = u64;
66
pub type shmatt_t = ::c_uint;
77

88
s! {
@@ -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

+35-10
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
pub type nlink_t = u64;
44
pub type dev_t = u64;
5-
pub type ino_t = ::c_ulong;
5+
pub type ino_t = u64;
66
pub type shmatt_t = ::c_uint;
77
pub type kpaddr_t = u64;
88
pub type kssize_t = i64;
@@ -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

+35-10
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
pub type nlink_t = u64;
44
pub type dev_t = u64;
5-
pub type ino_t = ::c_ulong;
5+
pub type ino_t = u64;
66
pub type shmatt_t = ::c_uint;
77
pub type kpaddr_t = u64;
88
pub type kssize_t = i64;
@@ -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)