Skip to content

Commit d9a25a7

Browse files
committed
gnu: Update the stat* structs for 64-bit time
Move the stat struct from gnu/b32/mod.rs to gnu/b32/time*.rs For arm, mips, powerpc, riscv32, and x86, move stat64 to time32.rs and add an stat64 = stat alias to time64.rs. For sparc, do the same for statfs64 and statvfs64.
1 parent fefc83c commit d9a25a7

File tree

19 files changed

+257
-167
lines changed

19 files changed

+257
-167
lines changed

libc-test/build.rs

+2
Original file line numberDiff line numberDiff line change
@@ -3530,6 +3530,8 @@ fn test_linux(target: &str) {
35303530

35313531
// LFS64 types have been removed in musl 1.2.4+
35323532
"off64_t" if musl => "off_t".to_string(),
3533+
// In some gnu targets `stat64` is a typedef to `stat`
3534+
"stat64" if gnu => format!("struct {}", ty),
35333535

35343536
// typedefs don't need any keywords
35353537
t if t.ends_with("_t") => t.to_string(),

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

+10-22
Original file line numberDiff line numberDiff line change
@@ -56,28 +56,6 @@ s! {
5656
__unused2: ::c_ulong
5757
}
5858

59-
pub struct stat64 {
60-
pub st_dev: ::dev_t,
61-
__pad1: ::c_uint,
62-
__st_ino: ::ino_t,
63-
pub st_mode: ::mode_t,
64-
pub st_nlink: ::nlink_t,
65-
pub st_uid: ::uid_t,
66-
pub st_gid: ::gid_t,
67-
pub st_rdev: ::dev_t,
68-
__pad2: ::c_uint,
69-
pub st_size: ::off64_t,
70-
pub st_blksize: ::blksize_t,
71-
pub st_blocks: ::blkcnt64_t,
72-
pub st_atime: ::time_t,
73-
pub st_atime_nsec: ::c_long,
74-
pub st_mtime: ::time_t,
75-
pub st_mtime_nsec: ::c_long,
76-
pub st_ctime: ::time_t,
77-
pub st_ctime_nsec: ::c_long,
78-
pub st_ino: ::ino64_t,
79-
}
80-
8159
pub struct statfs64 {
8260
pub f_type: ::__fsword_t,
8361
pub f_bsize: ::__fsword_t,
@@ -871,3 +849,13 @@ pub const SYS_set_mempolicy_home_node: ::c_long = 450;
871849

872850
mod align;
873851
pub use self::align::*;
852+
853+
cfg_if! {
854+
if #[cfg(gnu_time64_abi)] {
855+
mod time64;
856+
pub use self::time64::*;
857+
} else {
858+
mod time32;
859+
pub use self::time32::*;
860+
}
861+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
s! {
2+
pub struct stat64 {
3+
pub st_dev: ::dev_t,
4+
__pad1: ::c_uint,
5+
__st_ino: ::ino_t,
6+
pub st_mode: ::mode_t,
7+
pub st_nlink: ::nlink_t,
8+
pub st_uid: ::uid_t,
9+
pub st_gid: ::gid_t,
10+
pub st_rdev: ::dev_t,
11+
__pad2: ::c_uint,
12+
pub st_size: ::off64_t,
13+
pub st_blksize: ::blksize_t,
14+
pub st_blocks: ::blkcnt64_t,
15+
pub st_atime: ::time_t,
16+
pub st_atime_nsec: ::c_long,
17+
pub st_mtime: ::time_t,
18+
pub st_mtime_nsec: ::c_long,
19+
pub st_ctime: ::time_t,
20+
pub st_ctime_nsec: ::c_long,
21+
pub st_ino: ::ino64_t,
22+
}
23+
24+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
use stat;
2+
pub type stat64 = stat;

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

+10-22
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,6 @@ pub type c_char = i8;
22
pub type wchar_t = i32;
33

44
s! {
5-
pub struct stat64 {
6-
pub st_dev: ::c_ulong,
7-
st_pad1: [::c_long; 3],
8-
pub st_ino: ::ino64_t,
9-
pub st_mode: ::mode_t,
10-
pub st_nlink: ::nlink_t,
11-
pub st_uid: ::uid_t,
12-
pub st_gid: ::gid_t,
13-
pub st_rdev: ::c_ulong,
14-
st_pad2: [::c_long; 2],
15-
pub st_size: ::off64_t,
16-
pub st_atime: ::time_t,
17-
pub st_atime_nsec: ::c_long,
18-
pub st_mtime: ::time_t,
19-
pub st_mtime_nsec: ::c_long,
20-
pub st_ctime: ::time_t,
21-
pub st_ctime_nsec: ::c_long,
22-
pub st_blksize: ::blksize_t,
23-
st_pad3: ::c_long,
24-
pub st_blocks: ::blkcnt64_t,
25-
st_pad5: [::c_long; 14],
26-
}
275

286
pub struct statfs {
297
pub f_type: ::c_long,
@@ -808,3 +786,13 @@ pub const EHWPOISON: ::c_int = 168;
808786

809787
mod align;
810788
pub use self::align::*;
789+
790+
cfg_if! {
791+
if #[cfg(gnu_time64_abi)] {
792+
mod time64;
793+
pub use self::time64::*;
794+
} else {
795+
mod time32;
796+
pub use self::time32::*;
797+
}
798+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
s! {
2+
pub struct stat64 {
3+
pub st_dev: ::c_ulong,
4+
st_pad1: [::c_long; 3],
5+
pub st_ino: ::ino64_t,
6+
pub st_mode: ::mode_t,
7+
pub st_nlink: ::nlink_t,
8+
pub st_uid: ::uid_t,
9+
pub st_gid: ::gid_t,
10+
pub st_rdev: ::c_ulong,
11+
st_pad2: [::c_long; 2],
12+
pub st_size: ::off64_t,
13+
pub st_atime: ::time_t,
14+
pub st_atime_nsec: ::c_long,
15+
pub st_mtime: ::time_t,
16+
pub st_mtime_nsec: ::c_long,
17+
pub st_ctime: ::time_t,
18+
pub st_ctime_nsec: ::c_long,
19+
pub st_blksize: ::blksize_t,
20+
st_pad3: ::c_long,
21+
pub st_blocks: ::blkcnt64_t,
22+
st_pad5: [::c_long; 14],
23+
}
24+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
use stat;
2+
pub type stat64 = stat;

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

-48
Original file line numberDiff line numberDiff line change
@@ -53,54 +53,6 @@ cfg_if! {
5353
}
5454

5555
s! {
56-
pub struct stat {
57-
#[cfg(not(any(target_arch = "mips", target_arch = "mips32r6")))]
58-
pub st_dev: ::dev_t,
59-
#[cfg(any(target_arch = "mips", target_arch = "mips32r6"))]
60-
pub st_dev: ::c_ulong,
61-
62-
#[cfg(not(any(target_arch = "mips", target_arch = "mips32r6")))]
63-
__pad1: ::c_short,
64-
#[cfg(any(target_arch = "mips", target_arch = "mips32r6"))]
65-
st_pad1: [::c_long; 3],
66-
pub st_ino: ::ino_t,
67-
pub st_mode: ::mode_t,
68-
pub st_nlink: ::nlink_t,
69-
pub st_uid: ::uid_t,
70-
pub st_gid: ::gid_t,
71-
#[cfg(not(any(target_arch = "mips", target_arch = "mips32r6")))]
72-
pub st_rdev: ::dev_t,
73-
#[cfg(any(target_arch = "mips", target_arch = "mips32r6"))]
74-
pub st_rdev: ::c_ulong,
75-
#[cfg(not(any(target_arch = "mips", target_arch = "mips32r6")))]
76-
__pad2: ::c_short,
77-
#[cfg(any(target_arch = "mips", target_arch = "mips32r6"))]
78-
st_pad2: [::c_long; 2],
79-
pub st_size: ::off_t,
80-
#[cfg(any(target_arch = "mips", target_arch = "mips32r6"))]
81-
st_pad3: ::c_long,
82-
#[cfg(not(any(target_arch = "mips", target_arch = "mips32r6")))]
83-
pub st_blksize: ::blksize_t,
84-
#[cfg(not(any(target_arch = "mips", target_arch = "mips32r6")))]
85-
pub st_blocks: ::blkcnt_t,
86-
pub st_atime: ::time_t,
87-
pub st_atime_nsec: ::c_long,
88-
pub st_mtime: ::time_t,
89-
pub st_mtime_nsec: ::c_long,
90-
pub st_ctime: ::time_t,
91-
pub st_ctime_nsec: ::c_long,
92-
#[cfg(not(any(target_arch = "mips", target_arch = "mips32r6")))]
93-
__unused4: ::c_long,
94-
#[cfg(not(any(target_arch = "mips", target_arch = "mips32r6")))]
95-
__unused5: ::c_long,
96-
#[cfg(any(target_arch = "mips", target_arch = "mips32r6"))]
97-
pub st_blksize: ::blksize_t,
98-
#[cfg(any(target_arch = "mips", target_arch = "mips32r6"))]
99-
pub st_blocks: ::blkcnt_t,
100-
#[cfg(any(target_arch = "mips", target_arch = "mips32r6"))]
101-
st_pad5: [::c_long; 14],
102-
}
103-
10456
pub struct statvfs {
10557
pub f_bsize: ::c_ulong,
10658
pub f_frsize: ::c_ulong,

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

-22
Original file line numberDiff line numberDiff line change
@@ -55,28 +55,6 @@ s! {
5555
__glibc_reserved2: u64,
5656
}
5757

58-
pub struct stat64 {
59-
pub st_dev: ::dev_t,
60-
pub st_ino: ::ino64_t,
61-
pub st_mode: ::mode_t,
62-
pub st_nlink: ::nlink_t,
63-
pub st_uid: ::uid_t,
64-
pub st_gid: ::gid_t,
65-
pub st_rdev: ::dev_t,
66-
__pad2: ::c_ushort,
67-
pub st_size: ::off64_t,
68-
pub st_blksize: ::blksize_t,
69-
pub st_blocks: ::blkcnt64_t,
70-
pub st_atime: ::time_t,
71-
pub st_atime_nsec: ::c_long,
72-
pub st_mtime: ::time_t,
73-
pub st_mtime_nsec: ::c_long,
74-
pub st_ctime: ::time_t,
75-
pub st_ctime_nsec: ::c_long,
76-
__glibc_reserved4: ::c_ulong,
77-
__glibc_reserved5: ::c_ulong,
78-
}
79-
8058
pub struct statfs64 {
8159
pub f_type: ::__fsword_t,
8260
pub f_bsize: ::__fsword_t,

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

+22-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,26 @@
11
s! {
2+
pub struct stat64 {
3+
pub st_dev: ::dev_t,
4+
pub st_ino: ::ino64_t,
5+
pub st_mode: ::mode_t,
6+
pub st_nlink: ::nlink_t,
7+
pub st_uid: ::uid_t,
8+
pub st_gid: ::gid_t,
9+
pub st_rdev: ::dev_t,
10+
__pad2: ::c_ushort,
11+
pub st_size: ::off64_t,
12+
pub st_blksize: ::blksize_t,
13+
pub st_blocks: ::blkcnt64_t,
14+
pub st_atime: ::time_t,
15+
pub st_atime_nsec: ::c_long,
16+
pub st_mtime: ::time_t,
17+
pub st_mtime_nsec: ::c_long,
18+
pub st_ctime: ::time_t,
19+
pub st_ctime_nsec: ::c_long,
20+
__glibc_reserved4: ::c_ulong,
21+
__glibc_reserved5: ::c_ulong,
22+
}
23+
224
pub struct shmid_ds {
325
pub shm_perm: ::ipc_perm,
426
__glibc_reserved1: ::c_uint,
@@ -15,5 +37,4 @@ s! {
1537
__glibc_reserved5: ::c_ulong,
1638
__glibc_reserved6: ::c_ulong,
1739
}
18-
1940
}

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

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
use stat;
2+
pub type stat64 = stat;
3+
14
s! {
25
pub struct shmid_ds {
36
pub shm_perm: ::ipc_perm,

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

+9-30
Original file line numberDiff line numberDiff line change
@@ -100,21 +100,6 @@ s! {
100100
__reserved: [::c_long; 2],
101101
}
102102

103-
pub struct statfs64 {
104-
pub f_type: ::__fsword_t,
105-
pub f_bsize: ::__fsword_t,
106-
pub f_blocks: u64,
107-
pub f_bfree: u64,
108-
pub f_bavail: u64,
109-
pub f_files: u64,
110-
pub f_ffree: u64,
111-
pub f_fsid: ::fsid_t,
112-
pub f_namelen: ::__fsword_t,
113-
pub f_frsize: ::__fsword_t,
114-
pub f_flags: ::__fsword_t,
115-
pub f_spare: [::__fsword_t; 4],
116-
}
117-
118103
pub struct statvfs {
119104
pub f_bsize: ::c_ulong,
120105
pub f_frsize: ::c_ulong,
@@ -130,21 +115,6 @@ s! {
130115
__f_spare: [::c_int; 6],
131116
}
132117

133-
pub struct statvfs64 {
134-
pub f_bsize: ::c_ulong,
135-
pub f_frsize: ::c_ulong,
136-
pub f_blocks: u64,
137-
pub f_bfree: u64,
138-
pub f_bavail: u64,
139-
pub f_files: u64,
140-
pub f_ffree: u64,
141-
pub f_favail: u64,
142-
pub f_fsid: ::c_ulong,
143-
pub f_flag: ::c_ulong,
144-
pub f_namemax: ::c_ulong,
145-
__f_spare: [::c_int; 6],
146-
}
147-
148118
pub struct timex {
149119
pub modes: ::c_uint,
150120
pub offset: ::c_long,
@@ -885,3 +855,12 @@ pub const SYS_set_mempolicy_home_node: ::c_long = 450;
885855

886856
mod align;
887857
pub use self::align::*;
858+
cfg_if! {
859+
if #[cfg(gnu_time64_abi)] {
860+
mod time64;
861+
pub use self::time64::*;
862+
} else {
863+
mod time32;
864+
pub use self::time32::*;
865+
}
866+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
s! {
2+
pub struct statfs64 {
3+
pub f_type: ::__fsword_t,
4+
pub f_bsize: ::__fsword_t,
5+
pub f_blocks: u64,
6+
pub f_bfree: u64,
7+
pub f_bavail: u64,
8+
pub f_files: u64,
9+
pub f_ffree: u64,
10+
pub f_fsid: ::fsid_t,
11+
pub f_namelen: ::__fsword_t,
12+
pub f_frsize: ::__fsword_t,
13+
pub f_flags: ::__fsword_t,
14+
pub f_spare: [::__fsword_t; 4],
15+
}
16+
17+
pub struct statvfs64 {
18+
pub f_bsize: ::c_ulong,
19+
pub f_frsize: ::c_ulong,
20+
pub f_blocks: u64,
21+
pub f_bfree: u64,
22+
pub f_bavail: u64,
23+
pub f_files: u64,
24+
pub f_ffree: u64,
25+
pub f_favail: u64,
26+
pub f_fsid: ::c_ulong,
27+
pub f_flag: ::c_ulong,
28+
pub f_namemax: ::c_ulong,
29+
__f_spare: [::c_int; 6],
30+
}
31+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
use statfs;
2+
use statvfs;
3+
pub type statfs64 = statfs;
4+
pub type statvfs64 = statvfs;

0 commit comments

Comments
 (0)