Skip to content

Commit a8df758

Browse files
snoggetgross35
authored andcommitted
gnu: Adapt struct stat for gnu_file_offset_bits64
Change the __padX members in b32/mod.rs from short to uint even though they are actually unsigned short in C. Using unsigned int will give the same alignment, and make the struct equivalent to stat64 when gnu_file_offset_bits64 is set. (backport <rust-lang#4345>) (cherry picked from commit 5a5abc2)
1 parent e620284 commit a8df758

File tree

4 files changed

+45
-7
lines changed

4 files changed

+45
-7
lines changed

src/unix/linux_like/linux/gnu/b32/mips/mod.rs

+14
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,36 @@ s! {
88
pub st_dev: c_ulong,
99

1010
st_pad1: [c_long; 3],
11+
1112
pub st_ino: crate::ino_t,
13+
1214
pub st_mode: crate::mode_t,
1315
pub st_nlink: crate::nlink_t,
1416
pub st_uid: crate::uid_t,
1517
pub st_gid: crate::gid_t,
18+
1619
pub st_rdev: c_ulong,
20+
21+
#[cfg(not(gnu_file_offset_bits64))]
1722
st_pad2: [c_long; 2],
23+
#[cfg(gnu_file_offset_bits64)]
24+
st_pad2: [c_long; 3],
25+
1826
pub st_size: off_t,
27+
28+
#[cfg(not(gnu_file_offset_bits64))]
1929
st_pad3: c_long,
30+
2031
pub st_atime: crate::time_t,
2132
pub st_atime_nsec: c_long,
2233
pub st_mtime: crate::time_t,
2334
pub st_mtime_nsec: c_long,
2435
pub st_ctime: crate::time_t,
2536
pub st_ctime_nsec: c_long,
37+
2638
pub st_blksize: crate::blksize_t,
39+
#[cfg(gnu_file_offset_bits64)]
40+
st_pad4: c_long,
2741
pub st_blocks: crate::blkcnt_t,
2842
st_pad5: [c_long; 14],
2943
}

src/unix/linux_like/linux/gnu/b32/mod.rs

+28-7
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ cfg_if! {
2020
if #[cfg(target_arch = "riscv32")] {
2121
pub type time_t = i64;
2222
pub type suseconds_t = i64;
23-
pub type ino_t = u64;
23+
type __ino_t = c_ulong;
24+
type __ino64_t = u64;
25+
pub type ino_t = __ino64_t;
2426
pub type off_t = i64;
2527
pub type blkcnt_t = i64;
2628
pub type fsblkcnt_t = u64;
@@ -30,7 +32,9 @@ cfg_if! {
3032
} else if #[cfg(gnu_file_offset_bits64)] {
3133
pub type time_t = i32;
3234
pub type suseconds_t = i32;
33-
pub type ino_t = u64;
35+
type __ino_t = c_ulong;
36+
type __ino64_t = u64;
37+
pub type ino_t = __ino64_t;
3438
pub type off_t = i64;
3539
pub type blkcnt_t = i64;
3640
pub type fsblkcnt_t = u64;
@@ -40,7 +44,9 @@ cfg_if! {
4044
} else {
4145
pub type time_t = i32;
4246
pub type suseconds_t = i32;
43-
pub type ino_t = u32;
47+
type __ino_t = c_ulong;
48+
type __ino64_t = u64;
49+
pub type ino_t = __ino_t;
4450
pub type off_t = i32;
4551
pub type blkcnt_t = i32;
4652
pub type fsblkcnt_t = c_ulong;
@@ -61,25 +67,40 @@ cfg_if! {
6167
pub struct stat {
6268
pub st_dev: crate::dev_t,
6369

64-
__pad1: c_short,
70+
__pad1: c_uint,
71+
72+
#[cfg(not(gnu_file_offset_bits64))]
6573
pub st_ino: crate::ino_t,
74+
#[cfg(all(gnu_file_offset_bits64))]
75+
__st_ino: __ino_t,
76+
6677
pub st_mode: crate::mode_t,
6778
pub st_nlink: crate::nlink_t,
6879
pub st_uid: crate::uid_t,
6980
pub st_gid: crate::gid_t,
81+
7082
pub st_rdev: crate::dev_t,
71-
__pad2: c_short,
83+
84+
__pad2: c_uint,
85+
7286
pub st_size: off_t,
87+
7388
pub st_blksize: crate::blksize_t,
7489
pub st_blocks: crate::blkcnt_t,
90+
7591
pub st_atime: crate::time_t,
7692
pub st_atime_nsec: c_long,
7793
pub st_mtime: crate::time_t,
7894
pub st_mtime_nsec: c_long,
7995
pub st_ctime: crate::time_t,
8096
pub st_ctime_nsec: c_long,
81-
__unused4: c_long,
82-
__unused5: c_long,
97+
98+
#[cfg(not(gnu_file_offset_bits64))]
99+
__glibc_reserved4: c_long,
100+
#[cfg(not(gnu_file_offset_bits64))]
101+
__glibc_reserved5: c_long,
102+
#[cfg(gnu_file_offset_bits64)]
103+
pub st_ino: crate::ino_t,
83104
}
84105
}
85106
}

src/unix/linux_like/linux/gnu/b32/powerpc.rs

+2
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ s! {
5959

6060
pub struct stat {
6161
pub st_dev: crate::dev_t,
62+
#[cfg(not(gnu_file_offset_bits64))]
63+
__pad1: c_ushort,
6264
pub st_ino: crate::ino_t,
6365
pub st_mode: crate::mode_t,
6466
pub st_nlink: crate::nlink_t,

src/unix/linux_like/linux/gnu/b32/sparc/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ s! {
6262

6363
pub struct stat {
6464
pub st_dev: crate::dev_t,
65+
#[cfg(not(gnu_file_offset_bits64))]
6566
__pad1: c_ushort,
6667
pub st_ino: crate::ino_t,
6768
pub st_mode: crate::mode_t,

0 commit comments

Comments
 (0)