Deleted Added
full compact
31c31
< * $FreeBSD: head/sys/kern/kern_ntptime.c 94740 2002-04-15 08:58:24Z phk $
---
> * $FreeBSD: head/sys/kern/kern_ntptime.c 94754 2002-04-15 12:23:11Z phk $
154a155,156
> static int64_t time_adjtime; /* correction from adjtime(2) (usec) */
>
439a442
> int tickrate;
534a538,560
>
> /*
> * Apply any correction from adjtime(2). If more than one second
> * off we slew at a rate of 5ms/s (5000 PPM) else 500us/s (500PPM)
> * until the last second is slewed the final < 500 usecs.
> */
> if (time_adjtime != 0) {
> if (time_adjtime > 1000000)
> tickrate = 5000;
> else if (time_adjtime < -1000000)
> tickrate = -5000;
> else if (time_adjtime > 500)
> tickrate = 500;
> else if (time_adjtime < -500)
> tickrate = -500;
> else if (time_adjtime != 0)
> tickrate = time_adjtime;
> else
> tickrate = 0; /* GCC sucks! */
> time_adjtime -= tickrate;
> L_LINT(ftemp, tickrate * 1000);
> L_ADD(time_adj, ftemp);
> }
535a562
>
867a895,941
>
> #ifndef _SYS_SYSPROTO_H_
> struct adjtime_args {
> struct timeval *delta;
> struct timeval *olddelta;
> };
> #endif
> /*
> * MPSAFE
> */
> /* ARGSUSED */
> int
> adjtime(struct thread *td, struct adjtime_args *uap)
> {
> struct timeval atv;
> int error;
>
> mtx_lock(&Giant);
>
> if ((error = suser(td)))
> goto done2;
> if (uap->olddelta) {
> atv.tv_sec = time_adjtime / 1000000;
> atv.tv_usec = time_adjtime % 1000000;
> if (atv.tv_usec < 0) {
> atv.tv_usec += 1000000;
> atv.tv_sec--;
> }
> printf("Old: time_adjtime = %ld.%06ld %lld\n",
> atv.tv_sec, atv.tv_usec, time_adjtime);
> error = copyout(&atv, uap->olddelta, sizeof(atv));
> if (error)
> goto done2;
> }
> if (uap->delta) {
> error = copyin(uap->delta, &atv, sizeof(atv));
> if (error)
> goto done2;
> time_adjtime = (int64_t)atv.tv_sec * 1000000 + atv.tv_usec;
> printf("New: time_adjtime = %ld.%06ld %lld\n",
> atv.tv_sec, atv.tv_usec, time_adjtime);
> }
> done2:
> mtx_unlock(&Giant);
> return (error);
> }
>