Skip to content

Commit 3346526

Browse files
authored
Fix hurd build (#1064)
* hurd: Fix build 6ec74e0 ("Fix handling of negative timestamps in `Stat`. (#999)") broke the hurd build, where we have a st_[acm]tim timespec instead of st_[acm], like on aix and nto. * aix, nto, hurd: Implement impl StatExt
1 parent b26eca9 commit 3346526

File tree

1 file changed

+24
-2
lines changed

1 file changed

+24
-2
lines changed

src/fs/mod.rs

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ pub use std::os::wasi::fs::{DirEntryExt, FileExt, FileTypeExt, MetadataExt, Open
150150
/// the Unix epoch. Until the next semver bump, these unsigned fields are
151151
/// deprecated, and this trait provides accessors which return their values
152152
/// as signed integers.
153-
#[cfg(all(unix, not(any(target_os = "aix", target_os = "nto"))))]
153+
#[cfg(all(unix))]
154154
pub trait StatExt {
155155
/// Return the value of the `st_atime` field, casted to the correct type.
156156
fn atime(&self) -> i64;
@@ -160,7 +160,10 @@ pub trait StatExt {
160160
fn ctime(&self) -> i64;
161161
}
162162

163-
#[cfg(all(unix, not(any(target_os = "aix", target_os = "nto"))))]
163+
#[cfg(all(
164+
unix,
165+
not(any(target_os = "aix", target_os = "hurd", target_os = "nto"))
166+
))]
164167
#[allow(deprecated)]
165168
impl StatExt for Stat {
166169
#[inline]
@@ -178,3 +181,22 @@ impl StatExt for Stat {
178181
self.st_ctime as i64
179182
}
180183
}
184+
185+
#[cfg(any(target_os = "aix", target_os = "hurd", target_os = "nto"))]
186+
#[allow(deprecated)]
187+
impl StatExt for Stat {
188+
#[inline]
189+
fn atime(&self) -> i64 {
190+
self.st_atim.tv_sec as i64
191+
}
192+
193+
#[inline]
194+
fn mtime(&self) -> i64 {
195+
self.st_mtim.tv_sec as i64
196+
}
197+
198+
#[inline]
199+
fn ctime(&self) -> i64 {
200+
self.st_ctim.tv_sec as i64
201+
}
202+
}

0 commit comments

Comments
 (0)