diff --git a/library/std/src/sys/fs/hermit.rs b/library/std/src/sys/fs/hermit.rs index 0d3732a83a9e9..180dc08b4b04a 100644 --- a/library/std/src/sys/fs/hermit.rs +++ b/library/std/src/sys/fs/hermit.rs @@ -1,6 +1,6 @@ use crate::ffi::{CStr, OsStr, OsString}; use crate::fs::TryLockError; -use crate::io::{self, BorrowedCursor, Error, ErrorKind, IoSlice, IoSliceMut, SeekFrom}; +use crate::io::{self, BorrowedCursor, ErrorKind, IoSlice, IoSliceMut, SeekFrom}; use crate::mem::MaybeUninit; use crate::os::hermit::ffi::OsStringExt; use crate::os::hermit::hermit_abi::{ diff --git a/library/std/src/sys/time/hermit.rs b/library/std/src/sys/time/hermit.rs deleted file mode 100644 index 461319b162cc1..0000000000000 --- a/library/std/src/sys/time/hermit.rs +++ /dev/null @@ -1,64 +0,0 @@ -use hermit_abi::{self, CLOCK_MONOTONIC, CLOCK_REALTIME}; - -use crate::io; -use crate::sys::cvt; -use crate::sys::pal::time::Timespec; -use crate::time::Duration; - -fn clock_gettime(clock: hermit_abi::clockid_t) -> Timespec { - let mut t = hermit_abi::timespec { tv_sec: 0, tv_nsec: 0 }; - cvt(unsafe { hermit_abi::clock_gettime(clock, &raw mut t) }).unwrap(); - Timespec::new(t.tv_sec, t.tv_nsec.into()).unwrap() -} - -#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Debug, Hash)] -pub struct Instant(Timespec); - -impl Instant { - pub fn now() -> Instant { - Instant(clock_gettime(CLOCK_MONOTONIC)) - } - - pub fn checked_sub_instant(&self, other: &Instant) -> Option { - self.0.sub_timespec(&other.0).ok() - } - - pub fn checked_add_duration(&self, other: &Duration) -> Option { - Some(Instant(self.0.checked_add_duration(other)?)) - } - - pub fn checked_sub_duration(&self, other: &Duration) -> Option { - Some(Instant(self.0.checked_sub_duration(other)?)) - } -} - -#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)] -pub struct SystemTime(Timespec); - -pub const UNIX_EPOCH: SystemTime = SystemTime(Timespec::zero()); - -impl SystemTime { - pub const MAX: SystemTime = SystemTime(Timespec::MAX); - - pub const MIN: SystemTime = SystemTime(Timespec::MIN); - - pub fn new(tv_sec: i64, tv_nsec: i64) -> Result { - Ok(SystemTime(Timespec::new(tv_sec, tv_nsec)?)) - } - - pub fn now() -> SystemTime { - SystemTime(clock_gettime(CLOCK_REALTIME)) - } - - pub fn sub_time(&self, other: &SystemTime) -> Result { - self.0.sub_timespec(&other.0) - } - - pub fn checked_add_duration(&self, other: &Duration) -> Option { - Some(SystemTime(self.0.checked_add_duration(other)?)) - } - - pub fn checked_sub_duration(&self, other: &Duration) -> Option { - Some(SystemTime(self.0.checked_sub_duration(other)?)) - } -} diff --git a/library/std/src/sys/time/mod.rs b/library/std/src/sys/time/mod.rs index 6cd1850e7cca1..cf29a5a5ab700 100644 --- a/library/std/src/sys/time/mod.rs +++ b/library/std/src/sys/time/mod.rs @@ -1,8 +1,4 @@ cfg_select! { - target_os = "hermit" => { - mod hermit; - use hermit as imp; - } target_os = "motor" => { use moto_rt::time as imp; } @@ -19,6 +15,7 @@ cfg_select! { use uefi as imp; } any( + target_os = "hermit", target_os = "teeos", target_family = "unix", target_os = "wasi",