X-Git-Url: https://git.subgeniuskitty.com/unix-history/.git/blobdiff_plain/a8d3bf7f08061516a44629fbaf4c7bb727122742..c45fcba6a906e084a9abafbd25ccf5b06f436041:/usr/src/sys/kern/kern_time.c diff --git a/usr/src/sys/kern/kern_time.c b/usr/src/sys/kern/kern_time.c index cbee186953..53b5f17b4a 100644 --- a/usr/src/sys/kern/kern_time.c +++ b/usr/src/sys/kern/kern_time.c @@ -1,10 +1,11 @@ -/* kern_time.c 5.9 82/10/17 */ +/* kern_time.c 5.16 83/06/10 */ + +#include "../machine/reg.h" #include "../h/param.h" #include "../h/dir.h" /* XXX */ #include "../h/user.h" #include "../h/kernel.h" -#include "../h/reg.h" #include "../h/inode.h" #include "../h/proc.h" @@ -28,17 +29,13 @@ gettimeofday() int s; s = spl7(); atv = time; splx(s); - if (copyout((caddr_t)&atv, (caddr_t)uap->tp, sizeof (atv))) { - u.u_error = EFAULT; + u.u_error = copyout((caddr_t)&atv, (caddr_t)uap->tp, sizeof (atv)); + if (u.u_error) return; - } if (uap->tzp == 0) return; /* SHOULD HAVE PER-PROCESS TIMEZONE */ - if (copyout((caddr_t)&tz, uap->tzp, sizeof (tz))) { - u.u_error = EFAULT; - return; - } + u.u_error = copyout((caddr_t)&tz, (caddr_t)uap->tzp, sizeof (tz)); } settimeofday() @@ -50,16 +47,16 @@ settimeofday() struct timeval atv; struct timezone atz; - if (copyin((caddr_t)uap->tv, (caddr_t)&atv, sizeof (struct timeval))) { - u.u_error = EFAULT; + u.u_error = copyin((caddr_t)uap->tv, (caddr_t)&atv, + sizeof (struct timeval)); + if (u.u_error) return; - } setthetime(&atv); if (uap->tzp && suser()) { - if (copyin((caddr_t)uap->tzp, (caddr_t)&atz, sizeof (atz))) { - u.u_error = EFAULT; + u.u_error = copyin((caddr_t)uap->tzp, (caddr_t)&atz, + sizeof (atz)); + if (u.u_error) return; - } } } @@ -73,7 +70,7 @@ setthetime(tv) /* WHAT DO WE DO ABOUT PENDING REAL-TIME TIMEOUTS??? */ boottime.tv_sec += tv->tv_sec - time.tv_sec; s = spl7(); time = *tv; splx(s); - clockset(); + resettodr(); } /* @@ -127,8 +124,8 @@ getitimer() } else aitv = u.u_timer[uap->which]; splx(s); - if (copyout((caddr_t)&aitv, uap->itv, sizeof (struct itimerval))) - u.u_error = EFAULT; + u.u_error = copyout((caddr_t)&aitv, (caddr_t)uap->itv, + sizeof (struct itimerval)); splx(s); } @@ -146,11 +143,10 @@ setitimer() u.u_error = EINVAL; return; } - if (copyin((caddr_t)uap->itv, (caddr_t)&aitv, - sizeof (struct itimerval))) { - u.u_error = EFAULT; + u.u_error = copyin((caddr_t)uap->itv, (caddr_t)&aitv, + sizeof (struct itimerval)); + if (u.u_error) return; - } if (uap->oitv) { uap->itv = uap->oitv; getitimer(); @@ -161,10 +157,10 @@ setitimer() } s = spl7(); if (uap->which == ITIMER_REAL) { - untimeout(realitexpire, p); + untimeout(realitexpire, (caddr_t)p); if (timerisset(&aitv.it_value)) { timevaladd(&aitv.it_value, &time); - timeout(realitexpire, p, hzto(&aitv.it_value)); + timeout(realitexpire, (caddr_t)p, hzto(&aitv.it_value)); } p->p_realtimer = aitv; } else @@ -195,8 +191,8 @@ realitexpire(p) timevaladd(&p->p_realtimer.it_value, &p->p_realtimer.it_interval); if (timercmp(&p->p_realtimer.it_value, &time, >)) { - timeout(realitexpire, - p, hzto(&p->p_realtimer.it_value)); + timeout(realitexpire, (caddr_t)p, + hzto(&p->p_realtimer.it_value)); splx(s); return; } @@ -217,7 +213,7 @@ itimerfix(tv) if (tv->tv_sec < 0 || tv->tv_sec > 100000000 || tv->tv_usec < 0 || tv->tv_usec >= 1000000) return (EINVAL); - if (tv->tv_sec == 0 && tv->tv_usec < tick) + if (tv->tv_sec == 0 && tv->tv_usec != 0 && tv->tv_usec < tick) tv->tv_usec = tick; return (0); } @@ -302,73 +298,3 @@ timevalfix(t1) t1->tv_usec -= 1000000; } } - -#ifndef NOCOMPAT -otime() -{ - - u.u_r.r_time = time.tv_sec; -} - -ostime() -{ - register struct a { - int time; - } *uap = (struct a *)u.u_ap; - struct timeval tv; - - tv.tv_sec = uap->time; - tv.tv_usec = 0; - setthetime(&tv); -} - -/* from old timeb.h */ -struct timeb { - time_t time; - u_short millitm; - short timezone; - short dstflag; -}; - -oftime() -{ - register struct a { - struct timeb *tp; - } *uap; - struct timeb tb; - - uap = (struct a *)u.u_ap; - (void) spl7(); - tb.time = time.tv_sec; - tb.millitm = time.tv_usec / 1000; - (void) spl0(); - tb.timezone = tz.tz_minuteswest; - tb.dstflag = tz.tz_dsttime; - if (copyout((caddr_t)&tb, (caddr_t)uap->tp, sizeof (tb)) < 0) - u.u_error = EFAULT; -} - -oalarm() -{ - register struct a { - int deltat; - } *uap = (struct a *)u.u_ap; - register struct proc *p = u.u_procp; - int s = spl7(); - - untimeout(realitexpire, p); - timerclear(&p->p_realtimer.it_interval); - u.u_r.r_val1 = 0; - if (timerisset(&p->p_realtimer.it_value) && - timercmp(&p->p_realtimer.it_value, &time, >)) - u.u_r.r_val1 = p->p_realtimer.it_value.tv_sec - time.tv_sec; - if (uap->deltat == 0) { - splx(s); - return; - } - p->p_realtimer.it_value = time; - p->p_realtimer.it_value.tv_sec += uap->deltat; - timeout(realitexpire, p, hzto(&p->p_realtimer.it_value)); - splx(s); -} -#endif