Add normalize for timeval_t and const value for time

This commit is contained in:
Marsman1996
2024-09-19 11:09:36 +08:00
committed by Tate, Hongliang Tian
parent 4fa4e5ef2a
commit b4003b8aeb
2 changed files with 27 additions and 7 deletions

View File

@ -19,9 +19,10 @@ pub fn sys_select(
let timeout = if timeval_addr == 0 {
None
} else {
let mut timeval = ctx.get_user_space().read_val::<timeval_t>(timeval_addr)?;
timeval.sec += timeval.usec / 1_000_000;
timeval.usec %= 1_000_000;
let timeval = ctx
.get_user_space()
.read_val::<timeval_t>(timeval_addr)?
.normalize();
Some(Duration::try_from(timeval)?)
};