1
0
mirror of https://github.com/rcore-os/rCore.git synced 2024-11-27 02:03:29 +04:00
rCore/kernel/src/syscall/time.rs

22 lines
465 B
Rust
Raw Normal View History

2019-02-22 10:10:24 +04:00
//! Syscalls for time
use super::*;
pub fn sys_get_time() -> SysResult {
unsafe { Ok(crate::trap::TICK as isize) }
}
pub fn sys_time(time: *mut u64) -> SysResult {
let t = unsafe { crate::trap::TICK };
if time as usize != 0 {
let mut proc = process();
if !proc.memory_set.check_mut_ptr(time) {
return Err(SysError::EFAULT);
}
unsafe {
time.write(t as u64);
}
}
Ok(t as isize)
}