Skip to content

Commit 6b076c2

Browse files
committed
Auto merge of #31734 - aliclark:bsd-stat-fixes, r=alexcrichton
In #25155 the os::freebsd::raw stat was split for the x86 vs. x86-64 cases, which appears to have been done to implement the padding on the end of struct stat for the x86 case (the struct is otherwise the same notwistanding the size of long). This PR de-duplicates the struct using #[cfg(target_arch = "x86")] for the __unused field, which also fixes the definitions which had sinced changed with the LFS work d088b67. Also changed definitions to c_long for dragonfly and freebsd where appropriate. Also removes some unused imports that the compiler was complaining about. dragonfly's long time_t: https://gitweb.dragonflybsd.org/dragonfly.git/blob/a2a57c243ff8016578bc559f8603fb25bbcf1768:/lib/libstand/machine/stdint.h freebsd's long time_t: https://svnweb.freebsd.org/base/release/10.1.0/sys/x86/include/_types.h?view=markup https://github.com/rust-lang/rust/blob/d088b671872f1df6993ccca6fa6139ebed0a8cf3/src/liblibc/lib.rs#L980 freebsd's padding for i686 stat: https://svnweb.freebsd.org/base/release/10.1.0/sys/sys/stat.h?view=markup#l139 https://github.com/rust-lang/rust/blob/d088b671872f1df6993ccca6fa6139ebed0a8cf3/src/liblibc/lib.rs#L1038
2 parents 8e2a577 + 90afb85 commit 6b076c2

File tree

2 files changed

+63
-131
lines changed

2 files changed

+63
-131
lines changed

src/libstd/os/dragonfly/raw.rs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
#![allow(deprecated)]
2020

2121
use os::raw::c_long;
22-
use os::unix::raw::{uid_t, gid_t};
2322

2423
#[stable(feature = "raw_ext", since = "1.1.0")] pub type blkcnt_t = u64;
2524
#[stable(feature = "raw_ext", since = "1.1.0")] pub type blksize_t = u64;
@@ -52,17 +51,17 @@ pub struct stat {
5251
#[stable(feature = "raw_ext", since = "1.1.0")]
5352
pub st_rdev: u32,
5453
#[stable(feature = "raw_ext", since = "1.1.0")]
55-
pub st_atime: i64,
54+
pub st_atime: c_long,
5655
#[stable(feature = "raw_ext", since = "1.1.0")]
57-
pub st_atime_nsec: i64,
56+
pub st_atime_nsec: c_long,
5857
#[stable(feature = "raw_ext", since = "1.1.0")]
59-
pub st_mtime: i64,
58+
pub st_mtime: c_long,
6059
#[stable(feature = "raw_ext", since = "1.1.0")]
61-
pub st_mtime_nsec: i64,
60+
pub st_mtime_nsec: c_long,
6261
#[stable(feature = "raw_ext", since = "1.1.0")]
63-
pub st_ctime: i64,
62+
pub st_ctime: c_long,
6463
#[stable(feature = "raw_ext", since = "1.1.0")]
65-
pub st_ctime_nsec: i64,
64+
pub st_ctime_nsec: c_long,
6665
#[stable(feature = "raw_ext", since = "1.1.0")]
6766
pub st_size: i64,
6867
#[stable(feature = "raw_ext", since = "1.1.0")]
@@ -76,7 +75,7 @@ pub struct stat {
7675
#[stable(feature = "raw_ext", since = "1.1.0")]
7776
pub st_lspare: i32,
7877
#[stable(feature = "raw_ext", since = "1.1.0")]
79-
pub st_birthtime: i64,
78+
pub st_birthtime: c_long,
8079
#[stable(feature = "raw_ext", since = "1.1.0")]
81-
pub st_birthtime_nsec: i64,
80+
pub st_birthtime_nsec: c_long,
8281
}

src/libstd/os/freebsd/raw.rs

Lines changed: 55 additions & 122 deletions
Original file line numberDiff line numberDiff line change
@@ -18,134 +18,67 @@
1818
definitions")]
1919
#![allow(deprecated)]
2020

21-
#[stable(feature = "raw_ext", since = "1.1.0")] pub type off_t = u64;
21+
use os::raw::c_long;
22+
23+
#[stable(feature = "raw_ext", since = "1.1.0")] pub type blkcnt_t = u64;
24+
#[stable(feature = "raw_ext", since = "1.1.0")] pub type blksize_t = u64;
2225
#[stable(feature = "raw_ext", since = "1.1.0")] pub type dev_t = u64;
26+
#[stable(feature = "raw_ext", since = "1.1.0")] pub type fflags_t = u32;
2327
#[stable(feature = "raw_ext", since = "1.1.0")] pub type ino_t = u64;
2428
#[stable(feature = "raw_ext", since = "1.1.0")] pub type mode_t = u32;
2529
#[stable(feature = "raw_ext", since = "1.1.0")] pub type nlink_t = u64;
26-
#[stable(feature = "raw_ext", since = "1.1.0")] pub type blksize_t = u64;
27-
#[stable(feature = "raw_ext", since = "1.1.0")] pub type blkcnt_t = u64;
28-
#[stable(feature = "raw_ext", since = "1.1.0")] pub type fflags_t = u32;
30+
#[stable(feature = "raw_ext", since = "1.1.0")] pub type off_t = u64;
31+
#[stable(feature = "raw_ext", since = "1.1.0")] pub type time_t = i64;
2932

3033
#[unstable(feature = "pthread_t", issue = "29791")] pub type pthread_t = usize;
3134

32-
#[doc(inline)]
35+
#[repr(C)]
36+
#[derive(Clone)]
3337
#[stable(feature = "raw_ext", since = "1.1.0")]
34-
pub use self::arch::{stat, time_t};
35-
36-
#[cfg(target_arch = "x86")]
37-
mod arch {
38-
use super::{off_t, dev_t, ino_t, mode_t, nlink_t, blksize_t, blkcnt_t, fflags_t};
39-
use os::raw::c_long;
40-
use os::unix::raw::{uid_t, gid_t};
41-
42-
#[stable(feature = "raw_ext", since = "1.1.0")] pub type time_t = i64;
43-
44-
#[repr(C)]
45-
#[derive(Clone)]
46-
#[stable(feature = "raw_ext", since = "1.1.0")]
47-
pub struct stat {
48-
#[stable(feature = "raw_ext", since = "1.1.0")]
49-
pub st_dev: dev_t,
50-
#[stable(feature = "raw_ext", since = "1.1.0")]
51-
pub st_ino: ino_t,
52-
#[stable(feature = "raw_ext", since = "1.1.0")]
53-
pub st_mode: mode_t,
54-
#[stable(feature = "raw_ext", since = "1.1.0")]
55-
pub st_nlink: nlink_t,
56-
#[stable(feature = "raw_ext", since = "1.1.0")]
57-
pub st_uid: uid_t,
58-
#[stable(feature = "raw_ext", since = "1.1.0")]
59-
pub st_gid: gid_t,
60-
#[stable(feature = "raw_ext", since = "1.1.0")]
61-
pub st_rdev: dev_t,
62-
#[stable(feature = "raw_ext", since = "1.1.0")]
63-
pub st_atime: time_t,
64-
#[stable(feature = "raw_ext", since = "1.1.0")]
65-
pub st_atime_nsec: c_long,
66-
#[stable(feature = "raw_ext", since = "1.1.0")]
67-
pub st_mtime: time_t,
68-
#[stable(feature = "raw_ext", since = "1.1.0")]
69-
pub st_mtime_nsec: c_long,
70-
#[stable(feature = "raw_ext", since = "1.1.0")]
71-
pub st_ctime: time_t,
72-
#[stable(feature = "raw_ext", since = "1.1.0")]
73-
pub st_ctime_nsec: c_long,
74-
#[stable(feature = "raw_ext", since = "1.1.0")]
75-
pub st_size: off_t,
76-
#[stable(feature = "raw_ext", since = "1.1.0")]
77-
pub st_blocks: blkcnt_t,
78-
#[stable(feature = "raw_ext", since = "1.1.0")]
79-
pub st_blksize: blksize_t,
80-
#[stable(feature = "raw_ext", since = "1.1.0")]
81-
pub st_flags: fflags_t,
82-
#[stable(feature = "raw_ext", since = "1.1.0")]
83-
pub st_gen: u32,
84-
#[stable(feature = "raw_ext", since = "1.1.0")]
85-
pub st_lspare: i32,
86-
#[stable(feature = "raw_ext", since = "1.1.0")]
87-
pub st_birthtime: time_t,
88-
#[stable(feature = "raw_ext", since = "1.1.0")]
89-
pub st_birthtime_nsec: c_long,
90-
#[stable(feature = "raw_ext", since = "1.1.0")]
91-
pub __unused: [u8; 8],
92-
}
93-
}
94-
95-
#[cfg(target_arch = "x86_64")]
96-
mod arch {
97-
use super::{off_t, dev_t, ino_t, mode_t, nlink_t, blksize_t, blkcnt_t, fflags_t};
98-
use os::raw::c_long;
99-
use os::unix::raw::{uid_t, gid_t};
100-
101-
#[stable(feature = "raw_ext", since = "1.1.0")] pub type time_t = i64;
102-
103-
#[repr(C)]
104-
#[derive(Clone)]
105-
#[stable(feature = "raw_ext", since = "1.1.0")]
106-
pub struct stat {
107-
#[stable(feature = "raw_ext", since = "1.1.0")]
108-
pub st_dev: u32,
109-
#[stable(feature = "raw_ext", since = "1.1.0")]
110-
pub st_ino: u32,
111-
#[stable(feature = "raw_ext", since = "1.1.0")]
112-
pub st_mode: u16,
113-
#[stable(feature = "raw_ext", since = "1.1.0")]
114-
pub st_nlink: u16,
115-
#[stable(feature = "raw_ext", since = "1.1.0")]
116-
pub st_uid: u32,
117-
#[stable(feature = "raw_ext", since = "1.1.0")]
118-
pub st_gid: u32,
119-
#[stable(feature = "raw_ext", since = "1.1.0")]
120-
pub st_rdev: u32,
121-
#[stable(feature = "raw_ext", since = "1.1.0")]
122-
pub st_atime: i64,
123-
#[stable(feature = "raw_ext", since = "1.1.0")]
124-
pub st_atime_nsec: i64,
125-
#[stable(feature = "raw_ext", since = "1.1.0")]
126-
pub st_mtime: i64,
127-
#[stable(feature = "raw_ext", since = "1.1.0")]
128-
pub st_mtime_nsec: i64,
129-
#[stable(feature = "raw_ext", since = "1.1.0")]
130-
pub st_ctime: i64,
131-
#[stable(feature = "raw_ext", since = "1.1.0")]
132-
pub st_ctime_nsec: i64,
133-
#[stable(feature = "raw_ext", since = "1.1.0")]
134-
pub st_size: i64,
135-
#[stable(feature = "raw_ext", since = "1.1.0")]
136-
pub st_blocks: i64,
137-
#[stable(feature = "raw_ext", since = "1.1.0")]
138-
pub st_blksize: u32,
139-
#[stable(feature = "raw_ext", since = "1.1.0")]
140-
pub st_flags: u32,
141-
#[stable(feature = "raw_ext", since = "1.1.0")]
142-
pub st_gen: u32,
143-
#[stable(feature = "raw_ext", since = "1.1.0")]
144-
pub st_lspare: i32,
145-
#[stable(feature = "raw_ext", since = "1.1.0")]
146-
pub st_birthtime: i64,
147-
#[stable(feature = "raw_ext", since = "1.1.0")]
148-
pub st_birthtime_nsec: i64,
149-
}
38+
pub struct stat {
39+
#[stable(feature = "raw_ext", since = "1.1.0")]
40+
pub st_dev: u32,
41+
#[stable(feature = "raw_ext", since = "1.1.0")]
42+
pub st_ino: u32,
43+
#[stable(feature = "raw_ext", since = "1.1.0")]
44+
pub st_mode: u16,
45+
#[stable(feature = "raw_ext", since = "1.1.0")]
46+
pub st_nlink: u16,
47+
#[stable(feature = "raw_ext", since = "1.1.0")]
48+
pub st_uid: u32,
49+
#[stable(feature = "raw_ext", since = "1.1.0")]
50+
pub st_gid: u32,
51+
#[stable(feature = "raw_ext", since = "1.1.0")]
52+
pub st_rdev: u32,
53+
#[stable(feature = "raw_ext", since = "1.1.0")]
54+
pub st_atime: c_long,
55+
#[stable(feature = "raw_ext", since = "1.1.0")]
56+
pub st_atime_nsec: c_long,
57+
#[stable(feature = "raw_ext", since = "1.1.0")]
58+
pub st_mtime: c_long,
59+
#[stable(feature = "raw_ext", since = "1.1.0")]
60+
pub st_mtime_nsec: c_long,
61+
#[stable(feature = "raw_ext", since = "1.1.0")]
62+
pub st_ctime: c_long,
63+
#[stable(feature = "raw_ext", since = "1.1.0")]
64+
pub st_ctime_nsec: c_long,
65+
#[stable(feature = "raw_ext", since = "1.1.0")]
66+
pub st_size: i64,
67+
#[stable(feature = "raw_ext", since = "1.1.0")]
68+
pub st_blocks: i64,
69+
#[stable(feature = "raw_ext", since = "1.1.0")]
70+
pub st_blksize: u32,
71+
#[stable(feature = "raw_ext", since = "1.1.0")]
72+
pub st_flags: u32,
73+
#[stable(feature = "raw_ext", since = "1.1.0")]
74+
pub st_gen: u32,
75+
#[stable(feature = "raw_ext", since = "1.1.0")]
76+
pub st_lspare: i32,
77+
#[stable(feature = "raw_ext", since = "1.1.0")]
78+
pub st_birthtime: c_long,
79+
#[stable(feature = "raw_ext", since = "1.1.0")]
80+
pub st_birthtime_nsec: c_long,
81+
#[cfg(target_arch = "x86")]
82+
#[stable(feature = "raw_ext", since = "1.1.0")]
83+
pub __unused: [u8; 8],
15084
}
151-

0 commit comments

Comments
 (0)