1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-16 10:20:30 +00:00

Use kern_setitimer() to implement linux_alarm() instead of fondling the

real interval timer directly.
This commit is contained in:
John Baldwin 2005-02-07 18:36:21 +00:00
parent 777a3021d3
commit 12dd959a7d
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=141467

View File

@ -184,8 +184,7 @@ int
linux_alarm(struct thread *td, struct linux_alarm_args *args)
{
struct itimerval it, old_it;
struct timeval tv;
struct proc *p;
int error;
#ifdef DEBUG
if (ldebug(alarm))
@ -193,32 +192,21 @@ linux_alarm(struct thread *td, struct linux_alarm_args *args)
#endif
if (args->secs > 100000000)
return EINVAL;
return (EINVAL);
it.it_value.tv_sec = (long)args->secs;
it.it_value.tv_usec = 0;
it.it_interval.tv_sec = 0;
it.it_interval.tv_usec = 0;
p = td->td_proc;
PROC_LOCK(p);
old_it = p->p_realtimer;
getmicrouptime(&tv);
if (timevalisset(&old_it.it_value))
callout_stop(&p->p_itcallout);
if (it.it_value.tv_sec != 0) {
callout_reset(&p->p_itcallout, tvtohz(&it.it_value),
realitexpire, p);
timevaladd(&it.it_value, &tv);
}
p->p_realtimer = it;
PROC_UNLOCK(p);
if (timevalcmp(&old_it.it_value, &tv, >)) {
timevalsub(&old_it.it_value, &tv);
error = kern_setitimer(td, ITIMER_REAL, &it, &old_it);
if (error)
return (error);
if (timevalisset(&old_it.it_value)) {
if (old_it.it_value.tv_usec != 0)
old_it.it_value.tv_sec++;
td->td_retval[0] = old_it.it_value.tv_sec;
}
return 0;
return (0);
}
#endif /*!__alpha__*/