alnyan/yggdrasil: sync with ABI updates
This commit is contained in:
parent
c4ac4dbf69
commit
7754945c27
@ -1,16 +1,32 @@
|
||||
#![unstable(feature = "yggdrasil_os", issue = "none")]
|
||||
|
||||
use yggdrasil_rt::io::FileMode;
|
||||
|
||||
use crate::fs::Metadata;
|
||||
use crate::sys_common::AsInner;
|
||||
use yggdrasil_rt::io::FileMode;
|
||||
|
||||
#[unstable(feature = "yggdrasil_os", issue = "none")]
|
||||
pub trait MetadataExt {
|
||||
fn mode_ext(&self) -> FileMode;
|
||||
fn inode(&self) -> Option<u32>;
|
||||
fn block_count(&self) -> u64;
|
||||
fn block_size(&self) -> u64;
|
||||
}
|
||||
|
||||
impl MetadataExt for Metadata {
|
||||
fn mode_ext(&self) -> FileMode {
|
||||
self.as_inner().mode_ext()
|
||||
}
|
||||
|
||||
fn inode(&self) -> Option<u32> {
|
||||
self.as_inner().inode()
|
||||
}
|
||||
|
||||
fn block_count(&self) -> u64 {
|
||||
self.as_inner().block_count()
|
||||
}
|
||||
|
||||
fn block_size(&self) -> u64 {
|
||||
self.as_inner().block_size()
|
||||
}
|
||||
}
|
||||
|
@ -44,6 +44,18 @@ impl FileAttr {
|
||||
self.0.mode
|
||||
}
|
||||
|
||||
pub fn inode(&self) -> Option<u32> {
|
||||
self.0.inode
|
||||
}
|
||||
|
||||
pub fn block_count(&self) -> u64 {
|
||||
self.0.block_count
|
||||
}
|
||||
|
||||
pub fn block_size(&self) -> u64 {
|
||||
self.0.block_size
|
||||
}
|
||||
|
||||
pub fn modified(&self) -> io::Result<SystemTime> {
|
||||
Err(crate::io::const_io_error!(
|
||||
crate::io::ErrorKind::Unsupported,
|
||||
|
@ -1,26 +1,16 @@
|
||||
#![allow(dead_code)]
|
||||
|
||||
use yggdrasil_rt::time::Timespec as SysTimespec;
|
||||
use yggdrasil_rt::time::{self as rt, SystemTime as SysTimespec};
|
||||
|
||||
use crate::ops::{Add, AddAssign, Sub, SubAssign};
|
||||
use crate::time::Duration;
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord)]
|
||||
#[repr(transparent)]
|
||||
struct Timespec(SysTimespec);
|
||||
|
||||
impl Timespec {
|
||||
pub const fn zero() -> Self {
|
||||
Self(SysTimespec::ZERO)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)]
|
||||
pub struct Instant(Timespec);
|
||||
pub struct Instant(SysTimespec);
|
||||
|
||||
impl Instant {
|
||||
pub fn now() -> Self {
|
||||
todo!()
|
||||
Self(rt::get_monotonic_time().expect("Could not retrieve monotonic time value"))
|
||||
}
|
||||
|
||||
pub fn elapsed(&self) -> Duration {
|
||||
@ -35,8 +25,15 @@ impl Instant {
|
||||
todo!()
|
||||
}
|
||||
|
||||
pub fn checked_sub_instant(&self, _other: &Instant) -> Option<Duration> {
|
||||
todo!()
|
||||
pub fn checked_sub_instant(&self, other: &Instant) -> Option<Duration> {
|
||||
let mut s = u64::checked_sub(self.0.seconds, other.0.seconds)?;
|
||||
let ns = if self.0.nanoseconds >= other.0.nanoseconds {
|
||||
self.0.nanoseconds - other.0.nanoseconds
|
||||
} else {
|
||||
s = u64::checked_sub(s, 1)?;
|
||||
1000000000 + self.0.nanoseconds - other.0.nanoseconds
|
||||
};
|
||||
Some(Duration::new(s, ns as u32))
|
||||
}
|
||||
|
||||
pub fn checked_add_duration(&self, _other: &Duration) -> Option<Instant> {
|
||||
@ -60,41 +57,43 @@ impl Add<Duration> for Instant {
|
||||
type Output = Instant;
|
||||
|
||||
fn add(self, _other: Duration) -> Instant {
|
||||
todo!()
|
||||
todo!("Instant::add(duration)")
|
||||
}
|
||||
}
|
||||
|
||||
impl AddAssign<Duration> for Instant {
|
||||
fn add_assign(&mut self, _other: Duration) {
|
||||
todo!()
|
||||
todo!("Instant::add_assign(duration)")
|
||||
}
|
||||
}
|
||||
impl Sub<Duration> for Instant {
|
||||
type Output = Instant;
|
||||
|
||||
fn sub(self, _other: Duration) -> Instant {
|
||||
todo!()
|
||||
todo!("Instant:sub(duration)")
|
||||
}
|
||||
}
|
||||
|
||||
impl SubAssign<Duration> for Instant {
|
||||
fn sub_assign(&mut self, _other: Duration) {
|
||||
todo!()
|
||||
fn sub_assign(&mut self, other: Duration) {
|
||||
todo!("Instant::sub_assign(duration)")
|
||||
}
|
||||
}
|
||||
|
||||
impl Sub<Instant> for Instant {
|
||||
type Output = Duration;
|
||||
|
||||
fn sub(self, _other: Instant) -> Duration {
|
||||
todo!()
|
||||
fn sub(self, other: Instant) -> Duration {
|
||||
let d0 = Duration::new(self.0.seconds, self.0.nanoseconds as _);
|
||||
let d1 = Duration::new(other.0.seconds, other.0.nanoseconds as _);
|
||||
Duration::saturating_sub(d0, d1)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)]
|
||||
pub struct SystemTime(Timespec);
|
||||
pub struct SystemTime(SysTimespec);
|
||||
|
||||
pub const UNIX_EPOCH: SystemTime = SystemTime(Timespec::zero());
|
||||
pub const UNIX_EPOCH: SystemTime = SystemTime(SysTimespec::ZERO);
|
||||
|
||||
impl SystemTime {
|
||||
pub fn now() -> Self {
|
||||
|
Loading…
x
Reference in New Issue
Block a user