mirror of
https://github.com/asterinas/asterinas.git
synced 2025-06-25 02:13:24 +00:00
Remove the shim kernel crate
This commit is contained in:
committed by
Tate, Hongliang Tian
parent
d76c7a5b1e
commit
dafd16075f
27
kernel/src/syscall/gettimeofday.rs
Normal file
27
kernel/src/syscall/gettimeofday.rs
Normal file
@ -0,0 +1,27 @@
|
||||
// SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
use super::SyscallReturn;
|
||||
use crate::{
|
||||
prelude::*,
|
||||
time::{timeval_t, SystemTime},
|
||||
};
|
||||
|
||||
// The use of the timezone structure is obsolete.
|
||||
// Glibc sets the timezone_addr argument to NULL, so just ignore it.
|
||||
pub fn sys_gettimeofday(
|
||||
timeval_addr: Vaddr,
|
||||
/* timezone_addr: Vaddr, */ ctx: &Context,
|
||||
) -> Result<SyscallReturn> {
|
||||
if timeval_addr == 0 {
|
||||
return Ok(SyscallReturn::Return(0));
|
||||
}
|
||||
|
||||
let time_val = {
|
||||
let now = SystemTime::now();
|
||||
let time_duration = now.duration_since(&SystemTime::UNIX_EPOCH)?;
|
||||
timeval_t::from(time_duration)
|
||||
};
|
||||
ctx.get_user_space().write_val(timeval_addr, &time_val)?;
|
||||
|
||||
Ok(SyscallReturn::Return(0))
|
||||
}
|
Reference in New Issue
Block a user