This commit removes the `wasm_syscall` feature from the wasm32-unknown-unknown build of the standard library. This feature was originally intended to allow an opt-in way to interact with the operating system in a posix-like way but it was never stabilized. Nowadays with the advent of the `wasm32-wasi` target that should entirely replace the intentions of the `wasm_syscall` feature.
55 lines
1.5 KiB
Rust
55 lines
1.5 KiB
Rust
use crate::time::Duration;
|
|
|
|
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Debug, Hash)]
|
|
pub struct Instant(Duration);
|
|
|
|
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Debug, Hash)]
|
|
pub struct SystemTime(Duration);
|
|
|
|
pub const UNIX_EPOCH: SystemTime = SystemTime(Duration::from_secs(0));
|
|
|
|
impl Instant {
|
|
pub fn now() -> Instant {
|
|
panic!("time not implemented on wasm32-unknown-unknown")
|
|
}
|
|
|
|
pub const fn zero() -> Instant {
|
|
Instant(Duration::from_secs(0))
|
|
}
|
|
|
|
pub fn actually_monotonic() -> bool {
|
|
false
|
|
}
|
|
|
|
pub fn checked_sub_instant(&self, other: &Instant) -> Option<Duration> {
|
|
self.0.checked_sub(other.0)
|
|
}
|
|
|
|
pub fn checked_add_duration(&self, other: &Duration) -> Option<Instant> {
|
|
Some(Instant(self.0.checked_add(*other)?))
|
|
}
|
|
|
|
pub fn checked_sub_duration(&self, other: &Duration) -> Option<Instant> {
|
|
Some(Instant(self.0.checked_sub(*other)?))
|
|
}
|
|
}
|
|
|
|
impl SystemTime {
|
|
pub fn now() -> SystemTime {
|
|
panic!("time not implemented on wasm32-unknown-unknown")
|
|
}
|
|
|
|
pub fn sub_time(&self, other: &SystemTime)
|
|
-> Result<Duration, Duration> {
|
|
self.0.checked_sub(other.0).ok_or_else(|| other.0 - self.0)
|
|
}
|
|
|
|
pub fn checked_add_duration(&self, other: &Duration) -> Option<SystemTime> {
|
|
Some(SystemTime(self.0.checked_add(*other)?))
|
|
}
|
|
|
|
pub fn checked_sub_duration(&self, other: &Duration) -> Option<SystemTime> {
|
|
Some(SystemTime(self.0.checked_sub(*other)?))
|
|
}
|
|
}
|