merge FreeBSD timecounters from branch simonb-timecounters

- struct timeval time is gone
  time.tv_sec -> time_second
- struct timeval mono_time is gone
  mono_time.tv_sec -> time_uptime
- access to time via
	{get,}{micro,nano,bin}time()
	get* versions are fast but less precise
- support NTP nanokernel implementation (NTP API 4)
- further reading:
  Timecounter Paper: http://phk.freebsd.dk/pubs/timecounter.pdf
  NTP Nanokernel: http://www.eecis.udel.edu/~mills/ntp/html/kern.html
This commit is contained in:
kardel 2006-06-07 22:33:33 +00:00
parent d3390a5a9b
commit de4337ab21
142 changed files with 3270 additions and 1359 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: linux_misc.c,v 1.154 2006/05/14 21:24:50 elad Exp $ */
/* $NetBSD: linux_misc.c,v 1.155 2006/06/07 22:33:33 kardel Exp $ */
/*-
* Copyright (c) 1995, 1998, 1999 The NetBSD Foundation, Inc.
@ -64,7 +64,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: linux_misc.c,v 1.154 2006/05/14 21:24:50 elad Exp $");
__KERNEL_RCSID(0, "$NetBSD: linux_misc.c,v 1.155 2006/06/07 22:33:33 kardel Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -776,7 +776,7 @@ linux_sys_times(l, v, retval)
} */ *uap = v;
struct proc *p = l->l_proc;
struct timeval t;
int error, s;
int error;
if (SCARG(uap, tms)) {
struct linux_tms ltms;
@ -793,9 +793,7 @@ linux_sys_times(l, v, retval)
return error;
}
s = splclock();
timersub(&time, &boottime, &t);
splx(s);
getmicrouptime(&t);
retval[0] = ((linux_clock_t)(CONVTCK(t)));
return 0;
@ -1625,7 +1623,7 @@ linux_sys_sysinfo(l, v, retval)
struct linux_sysinfo si;
struct loadavg *la;
si.uptime = time.tv_sec - boottime.tv_sec;
si.uptime = time_uptime;
la = &averunnable;
si.loads[0] = la->ldavg[0] * LINUX_SYSINFO_LOADS_SCALE / la->fscale;
si.loads[1] = la->ldavg[1] * LINUX_SYSINFO_LOADS_SCALE / la->fscale;

View File

@ -1,4 +1,4 @@
/* $NetBSD: linux_misc_notalpha.c,v 1.79 2006/05/14 21:24:50 elad Exp $ */
/* $NetBSD: linux_misc_notalpha.c,v 1.80 2006/06/07 22:33:33 kardel Exp $ */
/*-
* Copyright (c) 1995, 1998 The NetBSD Foundation, Inc.
@ -38,7 +38,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: linux_misc_notalpha.c,v 1.79 2006/05/14 21:24:50 elad Exp $");
__KERNEL_RCSID(0, "$NetBSD: linux_misc_notalpha.c,v 1.80 2006/06/07 22:33:33 kardel Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -102,9 +102,10 @@ linux_sys_alarm(l, v, retval)
syscallarg(unsigned int) secs;
} */ *uap = v;
struct proc *p = l->l_proc;
int s;
struct timeval now;
struct itimerval *itp, it;
struct ptimer *ptp;
int s;
if (p->p_timers && p->p_timers->pts_timers[ITIMER_REAL])
itp = &p->p_timers->pts_timers[ITIMER_REAL]->pt_time;
@ -117,9 +118,10 @@ linux_sys_alarm(l, v, retval)
if (itp) {
callout_stop(&p->p_timers->pts_timers[ITIMER_REAL]->pt_ch);
timerclear(&itp->it_interval);
getmicrotime(&now);
if (timerisset(&itp->it_value) &&
timercmp(&itp->it_value, &time, >))
timersub(&itp->it_value, &time, &itp->it_value);
timercmp(&itp->it_value, &now, >))
timersub(&itp->it_value, &now, &itp->it_value);
/*
* Return how many seconds were left (rounded up)
*/
@ -171,7 +173,8 @@ linux_sys_alarm(l, v, retval)
* Don't need to check hzto() return value, here.
* callout_reset() does it for us.
*/
timeradd(&it.it_value, &time, &it.it_value);
getmicrotime(&now);
timeradd(&it.it_value, &now, &it.it_value);
callout_reset(&ptp->pt_ch, hzto(&it.it_value),
realtimerexpire, ptp);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: netbsd32_time.c,v 1.21 2006/05/31 09:52:27 drochner Exp $ */
/* $NetBSD: netbsd32_time.c,v 1.22 2006/06/07 22:33:33 kardel Exp $ */
/*
* Copyright (c) 1998, 2001 Matthew R. Green
@ -29,7 +29,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: netbsd32_time.c,v 1.21 2006/05/31 09:52:27 drochner Exp $");
__KERNEL_RCSID(0, "$NetBSD: netbsd32_time.c,v 1.22 2006/06/07 22:33:33 kardel Exp $");
#if defined(_KERNEL_OPT)
#include "opt_ntp.h"
@ -42,6 +42,7 @@ __KERNEL_RCSID(0, "$NetBSD: netbsd32_time.c,v 1.21 2006/05/31 09:52:27 drochner
#include <sys/time.h>
#include <sys/timex.h>
#include <sys/timevar.h>
#include <sys/timetc.h>
#include <sys/proc.h>
#include <sys/pool.h>
#include <sys/resourcevar.h>
@ -54,21 +55,6 @@ __KERNEL_RCSID(0, "$NetBSD: netbsd32_time.c,v 1.21 2006/05/31 09:52:27 drochner
#ifdef NTP
#ifdef PPS_SYNC
/*
* The following variables are used only if the PPS signal discipline
* is configured in the kernel.
*/
extern int pps_shift; /* interval duration (s) (shift) */
extern long pps_freq; /* pps frequency offset (scaled ppm) */
extern long pps_jitter; /* pps jitter (us) */
extern long pps_stabil; /* pps stability (scaled ppm) */
extern long pps_jitcnt; /* jitter limit exceeded */
extern long pps_calcnt; /* calibration intervals */
extern long pps_errcnt; /* calibration errors */
extern long pps_stbcnt; /* stability limit exceeded */
#endif /* PPS_SYNC */
int
netbsd32_ntp_gettime(l, v, retval)
struct lwp *l;
@ -146,21 +132,12 @@ netbsd32_ntp_adjtime(l, v, retval)
struct timex ntv;
int error = 0;
int modes;
int s;
struct proc *p = l->l_proc;
extern long time_freq; /* frequency offset (scaled ppm) */
extern long time_maxerror;
extern long time_esterror;
extern int time_state; /* clock state */
extern int time_status; /* clock status bits */
extern long time_constant; /* pll time constant */
extern long time_offset; /* time offset (us) */
extern long time_tolerance; /* frequency tolerance (scaled ppm) */
extern long time_precision; /* clock precision (us) */
if ((error = copyin((caddr_t)NETBSD32PTR64(SCARG(uap, tp)),
(caddr_t)&ntv32, sizeof(ntv32))))
return (error);
netbsd32_to_timex(&ntv32, &ntv);
/*
@ -172,75 +149,13 @@ netbsd32_ntp_adjtime(l, v, retval)
if (modes != 0 && (error = kauth_authorize_generic(p->p_cred, KAUTH_GENERIC_ISSUSER, &p->p_acflag)))
return (error);
s = splclock();
if (modes & MOD_FREQUENCY)
#ifdef PPS_SYNC
time_freq = ntv.freq - pps_freq;
#else /* PPS_SYNC */
time_freq = ntv.freq;
#endif /* PPS_SYNC */
if (modes & MOD_MAXERROR)
time_maxerror = ntv.maxerror;
if (modes & MOD_ESTERROR)
time_esterror = ntv.esterror;
if (modes & MOD_STATUS) {
time_status &= STA_RONLY;
time_status |= ntv.status & ~STA_RONLY;
}
if (modes & MOD_TIMECONST)
time_constant = ntv.constant;
if (modes & MOD_OFFSET)
hardupdate(ntv.offset);
/*
* Retrieve all clock variables
*/
if (time_offset < 0)
ntv.offset = -(-time_offset >> SHIFT_UPDATE);
else
ntv.offset = time_offset >> SHIFT_UPDATE;
#ifdef PPS_SYNC
ntv.freq = time_freq + pps_freq;
#else /* PPS_SYNC */
ntv.freq = time_freq;
#endif /* PPS_SYNC */
ntv.maxerror = time_maxerror;
ntv.esterror = time_esterror;
ntv.status = time_status;
ntv.constant = time_constant;
ntv.precision = time_precision;
ntv.tolerance = time_tolerance;
#ifdef PPS_SYNC
ntv.shift = pps_shift;
ntv.ppsfreq = pps_freq;
ntv.jitter = pps_jitter >> PPS_AVG;
ntv.stabil = pps_stabil;
ntv.calcnt = pps_calcnt;
ntv.errcnt = pps_errcnt;
ntv.jitcnt = pps_jitcnt;
ntv.stbcnt = pps_stbcnt;
#endif /* PPS_SYNC */
(void)splx(s);
ntp_adjtime1(&ntv);
netbsd32_from_timex(&ntv, &ntv32);
error = copyout((caddr_t)&ntv32, (caddr_t)NETBSD32PTR64(SCARG(uap, tp)),
sizeof(ntv32));
if (!error) {
/*
* Status word error decode. See comments in
* ntp_gettime() routine.
*/
if ((time_status & (STA_UNSYNC | STA_CLOCKERR)) ||
(time_status & (STA_PPSFREQ | STA_PPSTIME) &&
!(time_status & STA_PPSSIGNAL)) ||
(time_status & STA_PPSTIME &&
time_status & STA_PPSJITTER) ||
(time_status & STA_PPSFREQ &&
time_status & (STA_PPSWANDER | STA_PPSERROR)))
*retval = TIME_ERROR;
else
*retval = time_state;
*retval = ntp_timestatus();
}
return error;
}
@ -427,53 +342,89 @@ netbsd32_adjtime(l, v, retval)
syscallarg(netbsd32_timevalp_t) olddelta;
} */ *uap = v;
struct netbsd32_timeval atv;
int32_t ndelta, ntickdelta, odelta;
int s, error;
int error;
struct proc *p = l->l_proc;
extern long bigadj, timedelta;
extern int tickdelta;
if ((error = kauth_authorize_generic(p->p_cred, KAUTH_GENERIC_ISSUSER, &p->p_acflag)) != 0)
return (error);
#ifdef __HAVE_TIMECOUNTER
{
extern int time_adjusted; /* in kern_ntptime.c */
extern int64_t time_adjtime; /* in kern_ntptime.c */
if (SCARG(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--;
}
(void) copyout(&atv,
(caddr_t)NETBSD32PTR64(SCARG(uap, olddelta)),
sizeof(atv));
if (error)
return (error);
}
if (SCARG(uap, delta)) {
error = copyin((caddr_t)NETBSD32PTR64(SCARG(uap, delta)), &atv,
sizeof(struct timeval));
if (error)
return (error);
error = copyin((caddr_t)NETBSD32PTR64(SCARG(uap, delta)), &atv,
sizeof(struct timeval));
if (error)
return (error);
/*
* Compute the total correction and the rate at which to apply it.
* Round the adjustment down to a whole multiple of the per-tick
* delta, so that after some number of incremental changes in
* hardclock(), tickdelta will become zero, lest the correction
* overshoot and start taking us away from the desired final time.
*/
ndelta = atv.tv_sec * 1000000 + atv.tv_usec;
if (ndelta > bigadj)
ntickdelta = 10 * tickadj;
else
ntickdelta = tickadj;
if (ndelta % ntickdelta)
ndelta = ndelta / ntickdelta * ntickdelta;
time_adjtime = (int64_t)atv.tv_sec * 1000000 +
atv.tv_usec;
/*
* To make hardclock()'s job easier, make the per-tick delta negative
* if we want time to run slower; then hardclock can simply compute
* tick + tickdelta, and subtract tickdelta from timedelta.
*/
if (ndelta < 0)
ntickdelta = -ntickdelta;
s = splclock();
odelta = timedelta;
timedelta = ndelta;
tickdelta = ntickdelta;
splx(s);
if (SCARG(uap, olddelta)) {
atv.tv_sec = odelta / 1000000;
atv.tv_usec = odelta % 1000000;
(void) copyout(&atv,
(caddr_t)NETBSD32PTR64(SCARG(uap, olddelta)), sizeof(atv));
if (time_adjtime)
/* We need to save the system time during shutdown */
time_adjusted |= 1;
}
}
#else /* !__HAVE_TIMECOUNTER */
{
int32_t ndelta, ntickdelta, odelta;
extern long bigadj, timedelta;
extern int tickdelta;
int s;
error = copyin((caddr_t)NETBSD32PTR64(SCARG(uap, delta)), &atv,
sizeof(struct timeval));
if (error)
return (error);
/*
* Compute the total correction and the rate at which to apply it.
* Round the adjustment down to a whole multiple of the per-tick
* delta, so that after some number of incremental changes in
* hardclock(), tickdelta will become zero, lest the correction
* overshoot and start taking us away from the desired final time.
*/
ndelta = atv.tv_sec * 1000000 + atv.tv_usec;
if (ndelta > bigadj)
ntickdelta = 10 * tickadj;
else
ntickdelta = tickadj;
if (ndelta % ntickdelta)
ndelta = ndelta / ntickdelta * ntickdelta;
/*
* To make hardclock()'s job easier, make the per-tick delta negative
* if we want time to run slower; then hardclock can simply compute
* tick + tickdelta, and subtract tickdelta from timedelta.
*/
if (ndelta < 0)
ntickdelta = -ntickdelta;
s = splclock();
odelta = timedelta;
timedelta = ndelta;
tickdelta = ntickdelta;
splx(s);
if (SCARG(uap, olddelta)) {
atv.tv_sec = odelta / 1000000;
atv.tv_usec = odelta % 1000000;
(void) copyout(&atv,
(caddr_t)NETBSD32PTR64(SCARG(uap, olddelta)), sizeof(atv));
}
}
#endif /* !__HAVE_TIMECOUNTER */
return (0);
}
@ -578,8 +529,8 @@ netbsd32_nanosleep(l, v, retval)
struct netbsd32_timespec ts32;
struct timespec rqt;
struct timespec rmt;
struct timeval atv, utv;
int error, s, timo;
struct timeval atv, utv, ctime;
int error, timo;
error = copyin((caddr_t)NETBSD32PTR64(SCARG(uap, rqtp)), (caddr_t)&ts32,
sizeof(ts32));
@ -591,15 +542,14 @@ netbsd32_nanosleep(l, v, retval)
if (itimerfix(&atv))
return (EINVAL);
s = splclock();
timeradd(&atv,&time,&atv);
getmicrotime(&ctime);
timeradd(&atv,&ctime,&atv);
timo = hzto(&atv);
/*
* Avoid inadvertantly sleeping forever
*/
if (timo == 0)
timo = 1;
splx(s);
error = tsleep(&nanowait, PWAIT | PCATCH, "nanosleep", timo);
if (error == ERESTART)
@ -610,9 +560,7 @@ netbsd32_nanosleep(l, v, retval)
if (SCARG(uap, rmtp)) {
int error1;
s = splclock();
utv = time;
splx(s);
getmicrotime(&utv);
timersub(&atv, &utv, &utv);
if (utv.tv_sec < 0)

View File

@ -1,4 +1,4 @@
# $NetBSD: files,v 1.780 2006/06/07 15:24:12 rpaulo Exp $
# $NetBSD: files,v 1.781 2006/06/07 22:33:34 kardel Exp $
# @(#)files.newconf 7.5 (Berkeley) 5/10/93
@ -14,15 +14,15 @@ devclass tty
# (note, these are case-sensitive)
#
defflag INSECURE
defflag MBUFTRACE
defflag KMEMSTATS
defflag KCONT
defflag KMEMSTATS
defflag KTRACE
defflag MBUFTRACE
defflag SYSTRACE
defparam DEFCORENAME
defparam HZ
defparam MAXUPRC
defparam RTC_OFFSET
defparam HZ
defparam DEFCORENAME
defflag opt_pipe.h PIPE_SOCKETPAIR PIPE_NODIRECT
defflag BUFQ_DISKSORT
@ -1250,6 +1250,7 @@ file kern/kern_systrace.c systrace
file kern/kern_subr.c
file kern/kern_synch.c
file kern/kern_sysctl.c
file kern/kern_tc.c
file kern/kern_time.c
file kern/kern_timeout.c
file kern/kern_uuid.c

View File

@ -33,7 +33,7 @@
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGES.
*
* $Id: ah_osdep.c,v 1.4 2006/06/05 05:14:38 gdamore Exp $
* $Id: ah_osdep.c,v 1.5 2006/06/07 22:33:34 kardel Exp $
*/
#include "opt_athhal.h"
#include "athhal_options.h"
@ -417,16 +417,10 @@ ath_hal_delay(int n)
u_int32_t
ath_hal_getuptime(struct ath_hal *ah)
{
struct timeval boot, cur, diff;
int s;
s = splclock();
boot = boottime;
cur = time;
splx(s);
timersub(&cur, &boot, &diff);
return diff.tv_sec * 1000 + diff.tv_usec / 1000;
struct bintime bt;
getbinuptime(&bt);
return (bt.sec * 1000) +
(((uint64_t)1000 * (uint32_t)(bt.frac >> 32)) >> 32);
}
void

View File

@ -1,4 +1,4 @@
/* $NetBSD: clockctl.c,v 1.16 2006/03/09 23:44:43 christos Exp $ */
/* $NetBSD: clockctl.c,v 1.17 2006/06/07 22:33:34 kardel Exp $ */
/*-
* Copyright (c) 2001 The NetBSD Foundation, Inc.
@ -31,7 +31,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: clockctl.c,v 1.16 2006/03/09 23:44:43 christos Exp $");
__KERNEL_RCSID(0, "$NetBSD: clockctl.c,v 1.17 2006/06/07 22:33:34 kardel Exp $");
#include "opt_ntp.h"
@ -119,8 +119,12 @@ clockctlioctl(dev, cmd, data, flags, l)
if (error)
return (error);
error = ntp_adjtime1(&ntv, args, &retval);
(void)copyout(&retval, &args->retval, sizeof(retval));
ntp_adjtime1(&ntv);
error = copyout(&ntv, args->tp, sizeof(ntv));
if (error == 0)
(void)copyout(&retval, &args->retval, sizeof(retval));
return (error);
}
#endif /* NTP */

View File

@ -1,4 +1,4 @@
/* $NetBSD: com.c,v 1.243 2006/05/14 21:42:27 elad Exp $ */
/* $NetBSD: com.c,v 1.244 2006/06/07 22:33:34 kardel Exp $ */
/*-
* Copyright (c) 1998, 1999, 2004 The NetBSD Foundation, Inc.
@ -73,7 +73,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: com.c,v 1.243 2006/05/14 21:42:27 elad Exp $");
__KERNEL_RCSID(0, "$NetBSD: com.c,v 1.244 2006/06/07 22:33:34 kardel Exp $");
#include "opt_com.h"
#include "opt_ddb.h"
@ -219,11 +219,13 @@ static int comconsrate;
static tcflag_t comconscflag;
static struct cnm_state com_cnm_state;
#ifndef __HAVE_TIMECOUNTER
static int ppscap =
PPS_TSFMT_TSPEC |
PPS_CAPTUREASSERT |
PPS_CAPTURECLEAR |
PPS_OFFSETASSERT | PPS_OFFSETCLEAR;
#endif /* !__HAVE_TIMECOUNTER */
#ifndef __HAVE_GENERIC_SOFT_INTERRUPTS
#ifdef __NO_SOFT_SERIAL_INTERRUPT
@ -753,9 +755,11 @@ com_shutdown(struct com_softc *sc)
/* Clear any break condition set with TIOCSBRK. */
com_break(sc, 0);
#ifndef __HAVE_TIMECOUNTER
/* Turn off PPS capture on last close. */
sc->sc_ppsmask = 0;
sc->ppsparam.mode = 0;
#endif /* !__HAVE_TIMECOUNTER */
/*
* Hang up if necessary. Wait a bit, so the other side has time to
@ -872,8 +876,14 @@ comopen(dev_t dev, int flag, int mode, struct lwp *l)
sc->sc_msr = bus_space_read_1(sc->sc_iot, sc->sc_ioh, com_msr);
/* Clear PPS capture state on first open. */
#ifdef __HAVE_TIMECOUNTER
memset(&sc->sc_pps_state, 0, sizeof(sc->sc_pps_state));
sc->sc_pps_state.ppscap = PPS_CAPTUREASSERT | PPS_CAPTURECLEAR;
pps_init(&sc->sc_pps_state);
#else /* !__HAVE_TIMECOUNTER */
sc->sc_ppsmask = 0;
sc->ppsparam.mode = 0;
#endif /* !__HAVE_TIMECOUNTER */
COM_UNLOCK(sc);
splx(s2);
@ -1095,6 +1105,19 @@ comioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct lwp *l)
*(int *)data = com_to_tiocm(sc);
break;
#ifdef __HAVE_TIMECOUNTER
case PPS_IOC_CREATE:
case PPS_IOC_DESTROY:
case PPS_IOC_GETPARAMS:
case PPS_IOC_SETPARAMS:
case PPS_IOC_GETCAP:
case PPS_IOC_FETCH:
#ifdef PPS_SYNC
case PPS_IOC_KCBIND:
#endif
error = pps_ioctl(cmd, data, &sc->sc_pps_state);
break;
#else /* !__HAVE_TIMECOUNTER */
case PPS_IOC_CREATE:
break;
@ -1187,8 +1210,18 @@ comioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct lwp *l)
break;
}
#endif /* PPS_SYNC */
#endif /* !__HAVE_TIMECOUNTER */
case TIOCDCDTIMESTAMP: /* XXX old, overloaded API used by xntpd v3 */
#ifdef __HAVE_TIMECOUNTER
#ifndef PPS_TRAILING_EDGE
TIMESPEC_TO_TIMEVAL((struct timeval *)data,
&sc->sc_pps_state.ppsinfo.assert_timestamp);
#else
TIMESPEC_TO_TIMEVAL((struct timeval *)data,
&sc->sc_pps_state.ppsinfo.clear_timestamp);
#endif
#else /* !__HAVE_TIMECOUNTER */
/*
* Some GPS clocks models use the falling rather than
* rising edge as the on-the-second signal.
@ -1206,6 +1239,7 @@ comioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct lwp *l)
TIMESPEC_TO_TIMEVAL((struct timeval *)data,
&sc->ppsinfo.clear_timestamp);
#endif
#endif /* !__HAVE_TIMECOUNTER */
break;
default:
@ -2147,6 +2181,16 @@ again: do {
msr = bus_space_read_1(iot, ioh, com_msr);
delta = msr ^ sc->sc_msr;
sc->sc_msr = msr;
#ifdef __HAVE_TIMECOUNTER
if ((sc->sc_pps_state.ppsparam.mode & PPS_CAPTUREBOTH) &&
(delta & MSR_DCD)) {
pps_capture(&sc->sc_pps_state);
pps_event(&sc->sc_pps_state,
(msr & MSR_DCD) ?
PPS_CAPTUREASSERT :
PPS_CAPTURECLEAR);
}
#else /* !__HAVE_TIMECOUNTER */
/*
* Pulse-per-second (PSS) signals on edge of DCD?
* Process these even if line discipline is ignoring DCD.
@ -2194,6 +2238,7 @@ again: do {
sc->ppsinfo.current_mode = sc->ppsparam.mode;
}
}
#endif /* !__HAVE_TIMECOUNTER */
/*
* Process normal status changes

View File

@ -1,4 +1,4 @@
/* $NetBSD: comvar.h,v 1.51 2006/03/05 17:33:33 christos Exp $ */
/* $NetBSD: comvar.h,v 1.52 2006/06/07 22:33:35 kardel Exp $ */
/*
* Copyright (c) 1996 Christopher G. Demetriou. All rights reserved.
@ -137,12 +137,16 @@ struct com_softc {
void (*disable)(struct com_softc *);
int enabled;
#ifdef __HAVE_TIMECOUNTER
struct pps_state sc_pps_state; /* pps state */
#else /* !__HAVE_TIMECOUNTER */
/* PPS signal on DCD, with or without inkernel clock disciplining */
u_char sc_ppsmask; /* pps signal mask */
u_char sc_ppsassert; /* pps leading edge */
u_char sc_ppsclear; /* pps trailing edge */
pps_info_t ppsinfo;
pps_params_t ppsparam;
#endif /* !__HAVE_TIMECOUNTER */
#if NRND > 0 && defined(RND_COM)
rndsource_element_t rnd_source;

View File

@ -1,4 +1,4 @@
/* $NetBSD: hd64570.c,v 1.31 2006/03/28 17:38:30 thorpej Exp $ */
/* $NetBSD: hd64570.c,v 1.32 2006/06/07 22:33:35 kardel Exp $ */
/*
* Copyright (c) 1999 Christian E. Hopps
@ -65,7 +65,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: hd64570.c,v 1.31 2006/03/28 17:38:30 thorpej Exp $");
__KERNEL_RCSID(0, "$NetBSD: hd64570.c,v 1.32 2006/06/07 22:33:35 kardel Exp $");
#include "bpfilter.h"
#include "opt_inet.h"
@ -413,6 +413,7 @@ sca_init(struct sca_softc *sc)
void
sca_port_attach(struct sca_softc *sc, u_int port)
{
struct timeval now;
sca_port_t *scp = &sc->sc_ports[port];
struct ifnet *ifp;
static u_int ntwo_unit = 0;
@ -475,7 +476,8 @@ sca_port_attach(struct sca_softc *sc, u_int port)
/*
* reset the last seen times on the cisco keepalive protocol
*/
scp->cka_lasttx = time.tv_usec;
getmicrotime(&now);
scp->cka_lasttx = now.tv_usec;
scp->cka_lastrx = 0;
}
@ -1568,7 +1570,7 @@ sca_frame_process(sca_port_t *scp)
u_int16_t len;
u_int32_t t;
t = (time.tv_sec - boottime.tv_sec) * 1000;
t = time_uptime * 1000;
desc = &scp->sp_rxdesc[scp->sp_rxstart];
bufp = scp->sp_rxbuf + SCA_BSIZE * scp->sp_rxstart;
len = sca_desc_read_buflen(scp->sca, desc);
@ -1821,6 +1823,7 @@ static void
sca_port_up(sca_port_t *scp)
{
struct sca_softc *sc = scp->sca;
struct timeval now;
#if 0
u_int8_t ier0, ier1;
#endif
@ -1885,7 +1888,8 @@ sca_port_up(sca_port_t *scp)
*/
scp->sp_txinuse = 0;
scp->sp_txcur = 0;
scp->cka_lasttx = time.tv_usec;
getmicrotime(&now);
scp->cka_lasttx = now.tv_usec;
scp->cka_lastrx = 0;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: icp.c,v 1.19 2006/03/28 17:38:30 thorpej Exp $ */
/* $NetBSD: icp.c,v 1.20 2006/06/07 22:33:35 kardel Exp $ */
/*-
* Copyright (c) 2002, 2003 The NetBSD Foundation, Inc.
@ -83,7 +83,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: icp.c,v 1.19 2006/03/28 17:38:30 thorpej Exp $");
__KERNEL_RCSID(0, "$NetBSD: icp.c,v 1.20 2006/06/07 22:33:35 kardel Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -1323,7 +1323,7 @@ icp_store_event(struct icp_softc *icp, u_int16_t source, u_int16_t idx,
(evt->size == 0 && e->event_data.size == 0 &&
strcmp((char *) e->event_data.event_string,
(char *) evt->event_string) == 0))) {
e->last_stamp = time.tv_sec;
e->last_stamp = time_second;
e->same_count++;
} else {
if (icp_event_buffer[icp_event_lastidx].event_source != 0) {
@ -1339,7 +1339,7 @@ icp_store_event(struct icp_softc *icp, u_int16_t source, u_int16_t idx,
e = &icp_event_buffer[icp_event_lastidx];
e->event_source = source;
e->event_idx = idx;
e->first_stamp = e->last_stamp = time.tv_sec;
e->first_stamp = e->last_stamp = time_second;
e->same_count = 1;
e->event_data = *evt;
e->application = 0;

View File

@ -1,4 +1,4 @@
/* $NetBSD: mlx.c,v 1.42 2006/04/14 21:06:47 christos Exp $ */
/* $NetBSD: mlx.c,v 1.43 2006/06/07 22:33:36 kardel Exp $ */
/*-
* Copyright (c) 2001 The NetBSD Foundation, Inc.
@ -74,7 +74,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: mlx.c,v 1.42 2006/04/14 21:06:47 christos Exp $");
__KERNEL_RCSID(0, "$NetBSD: mlx.c,v 1.43 2006/06/07 22:33:36 kardel Exp $");
#include "ld.h"
@ -135,8 +135,6 @@ static int mlx_rebuild(struct mlx_softc *, int, int);
static void mlx_shutdown(void *);
static int mlx_user_command(struct mlx_softc *, struct mlx_usercommand *);
static inline time_t mlx_curtime(void);
dev_type_open(mlxopen);
dev_type_close(mlxclose);
dev_type_ioctl(mlxioctl);
@ -253,23 +251,6 @@ struct {
{ 0, 14, 0x0104 },
};
/*
* Return the current time in seconds - we're not particularly interested in
* precision here.
*/
static inline time_t
mlx_curtime(void)
{
time_t rt;
int s;
s = splclock();
rt = mono_time.tv_sec;
splx(s);
return (rt);
}
/*
* Initialise the controller and our interface.
*/
@ -810,7 +791,7 @@ mlxioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct lwp *l)
/* Looks ok, go with it. */
mlx->mlx_pause.mp_which = mp->mp_which;
mlx->mlx_pause.mp_when = mlx_curtime() + mp->mp_when;
mlx->mlx_pause.mp_when = time_second + mp->mp_when;
mlx->mlx_pause.mp_howlong =
mlx->mlx_pause.mp_when + mp->mp_howlong;
@ -999,13 +980,10 @@ mlx_periodic(struct mlx_softc *mlx)
{
struct mlx_ccb *mc, *nmc;
int etype, s;
time_t ct;
ct = mlx_curtime();
if ((mlx->mlx_pause.mp_which != 0) &&
(mlx->mlx_pause.mp_when > 0) &&
(ct >= mlx->mlx_pause.mp_when)) {
(time_second >= mlx->mlx_pause.mp_when)) {
/*
* Start bus pause.
*/
@ -1016,15 +994,15 @@ mlx_periodic(struct mlx_softc *mlx)
/*
* Stop pause if required.
*/
if (ct >= mlx->mlx_pause.mp_howlong) {
if (time_second >= mlx->mlx_pause.mp_howlong) {
mlx_pause_action(mlx);
mlx->mlx_pause.mp_which = 0;
}
} else if (ct > (mlx->mlx_lastpoll + 10)) {
} else if (time_second > (mlx->mlx_lastpoll + 10)) {
/*
* Run normal periodic activities...
*/
mlx->mlx_lastpoll = ct;
mlx->mlx_lastpoll = time_second;
/*
* Check controller status.
@ -1068,7 +1046,7 @@ mlx_periodic(struct mlx_softc *mlx)
s = splbio();
for (mc = TAILQ_FIRST(&mlx->mlx_ccb_worklist); mc != NULL; mc = nmc) {
nmc = TAILQ_NEXT(mc, mc_chain.tailq);
if (mc->mc_expiry > ct) {
if (mc->mc_expiry > time_second) {
/*
* The remaining CCBs will expire after this one, so
* there's no point in going further.
@ -1479,9 +1457,6 @@ mlx_pause_action(struct mlx_softc *mlx)
{
struct mlx_ccb *mc;
int failsafe, i, cmd;
time_t ct;
ct = mlx_curtime();
/* What are we doing here? */
if (mlx->mlx_pause.mp_when == 0) {
@ -1495,11 +1470,12 @@ mlx_pause_action(struct mlx_softc *mlx)
* period, which is specified in multiples of 30 seconds.
* This constrains us to a maximum pause of 450 seconds.
*/
failsafe = ((mlx->mlx_pause.mp_howlong - ct) + 5) / 30;
failsafe = ((mlx->mlx_pause.mp_howlong - time_second) + 5) / 30;
if (failsafe > 0xf) {
failsafe = 0xf;
mlx->mlx_pause.mp_howlong = ct + (0xf * 30) - 5;
mlx->mlx_pause.mp_howlong =
time_second + (0xf * 30) - 5;
}
}
@ -1542,7 +1518,7 @@ mlx_pause_done(struct mlx_ccb *mc)
else if (command == MLX_CMD_STOPCHANNEL)
printf("%s: channel %d pausing for %ld seconds\n",
mlx->mlx_dv.dv_xname, channel,
(long)(mlx->mlx_pause.mp_howlong - mlx_curtime()));
(long)(mlx->mlx_pause.mp_howlong - time_second));
else
printf("%s: channel %d resuming\n", mlx->mlx_dv.dv_xname,
channel);
@ -2083,7 +2059,7 @@ mlx_ccb_submit(struct mlx_softc *mlx, struct mlx_ccb *mc)
/* Mark the command as currently being processed. */
mc->mc_status = MLX_STATUS_BUSY;
mc->mc_expiry = mlx_curtime() + MLX_TIMEOUT;
mc->mc_expiry = time_second + MLX_TIMEOUT;
/* Spin waiting for the mailbox. */
for (i = 100; i != 0; i--) {

View File

@ -1,4 +1,4 @@
/* $NetBSD: ncr53c9x.c,v 1.119 2006/03/29 04:16:49 thorpej Exp $ */
/* $NetBSD: ncr53c9x.c,v 1.120 2006/06/07 22:33:36 kardel Exp $ */
/*-
* Copyright (c) 1998, 2002 The NetBSD Foundation, Inc.
@ -77,7 +77,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: ncr53c9x.c,v 1.119 2006/03/29 04:16:49 thorpej Exp $");
__KERNEL_RCSID(0, "$NetBSD: ncr53c9x.c,v 1.120 2006/06/07 22:33:36 kardel Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -1110,7 +1110,7 @@ ncr53c9x_sched(sc)
if (lun < NCR_NLUN)
ti->lun[lun] = li;
}
li->last_used = time.tv_sec;
li->last_used = time_second;
if (tag == 0) {
/* Try to issue this as an un-tagged command */
if (li->untagged == NULL)
@ -2948,7 +2948,7 @@ ncr53c9x_watch(arg)
struct ncr53c9x_linfo *li;
int t, s;
/* Delete any structures that have not been used in 10min. */
time_t old = time.tv_sec - (10 * 60);
time_t old = time_second - (10 * 60);
s = splbio();
simple_lock(&sc->sc_lock);

View File

@ -1,4 +1,4 @@
/* $NetBSD: nslm7x.c,v 1.25 2006/05/13 09:03:21 xtraeme Exp $ */
/* $NetBSD: nslm7x.c,v 1.26 2006/06/07 22:33:36 kardel Exp $ */
/*-
* Copyright (c) 2000 The NetBSD Foundation, Inc.
@ -37,7 +37,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: nslm7x.c,v 1.25 2006/05/13 09:03:21 xtraeme Exp $");
__KERNEL_RCSID(0, "$NetBSD: nslm7x.c,v 1.26 2006/06/07 22:33:36 kardel Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -435,27 +435,20 @@ lm_gtredata(sme, tred)
struct sysmon_envsys *sme;
struct envsys_tre_data *tred;
{
static const struct timeval onepointfive = { 1, 500000 };
struct timeval t;
struct lm_softc *sc = sme->sme_cookie;
int i, s;
static const struct timeval onepointfive = { 1, 500000 };
struct timeval t, utv;
struct lm_softc *sc = sme->sme_cookie;
/* read new values at most once every 1.5 seconds */
timeradd(&sc->lastread, &onepointfive, &t);
s = splclock();
i = timercmp(&mono_time, &t, >);
if (i) {
sc->lastread.tv_sec = mono_time.tv_sec;
sc->lastread.tv_usec = mono_time.tv_usec;
}
splx(s);
/* read new values at most once every 1.5 seconds */
getmicrouptime(&utv);
timeradd(&sc->lastread, &onepointfive, &t);
if (timercmp(&utv, &t, >)) {
sc->lastread = utv;
sc->refresh_sensor_data(sc);
if (i)
sc->refresh_sensor_data(sc);
*tred = sc->sensors[tred->sensor];
*tred = sc->sensors[tred->sensor];
return 0;
return 0;
}
int

View File

@ -1,4 +1,4 @@
/* $NetBSD: z8530tty.c,v 1.107 2006/05/14 21:42:27 elad Exp $ */
/* $NetBSD: z8530tty.c,v 1.108 2006/06/07 22:33:36 kardel Exp $ */
/*-
* Copyright (c) 1993, 1994, 1995, 1996, 1997, 1998, 1999
@ -137,7 +137,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: z8530tty.c,v 1.107 2006/05/14 21:42:27 elad Exp $");
__KERNEL_RCSID(0, "$NetBSD: z8530tty.c,v 1.108 2006/06/07 22:33:36 kardel Exp $");
#include "opt_kgdb.h"
#include "opt_ntp.h"
@ -184,11 +184,13 @@ u_int zstty_rbuf_size = ZSTTY_RING_SIZE;
u_int zstty_rbuf_hiwat = (ZSTTY_RING_SIZE * 1) / 4;
u_int zstty_rbuf_lowat = (ZSTTY_RING_SIZE * 3) / 4;
#ifndef __HAVE_TIMECOUNTER
static int zsppscap =
PPS_TSFMT_TSPEC |
PPS_CAPTUREASSERT |
PPS_CAPTURECLEAR |
PPS_OFFSETASSERT | PPS_OFFSETCLEAR;
#endif /* __HAVE_TIMECOUNTER */
struct zstty_softc {
struct device zst_dev; /* required first: base device */
@ -237,10 +239,14 @@ struct zstty_softc {
/* PPS signal on DCD, with or without inkernel clock disciplining */
u_char zst_ppsmask; /* pps signal mask */
#ifdef __HAVE_TIMECOUNTER
struct pps_state zst_pps_state;
#else /* !__HAVE_TIMECOUNTER */
u_char zst_ppsassert; /* pps leading edge */
u_char zst_ppsclear; /* pps trailing edge */
pps_info_t ppsinfo;
pps_params_t ppsparam;
#endif /* !__HAVE_TIMECOUNTER */
};
/* Definition of the driver for autoconfig. */
@ -507,9 +513,11 @@ zs_shutdown(zst)
/* Clear any break condition set with TIOCSBRK. */
zs_break(cs, 0);
#ifndef __HAVE_TIMECOUNTER
/* Turn off PPS capture on last close. */
zst->zst_ppsmask = 0;
zst->ppsparam.mode = 0;
#endif /* __HAVE_TIMECOUNTER */
/*
* Hang up if necessary. Wait a bit, so the other side has time to
@ -636,7 +644,13 @@ zsopen(dev, flags, mode, l)
/* Clear PPS capture state on first open. */
zst->zst_ppsmask = 0;
#ifdef __HAVE_TIMECOUNTER
memset(&zst->zst_pps_state, 0, sizeof(zst->zst_pps_state));
zst->zst_pps_state.ppscap = PPS_CAPTUREASSERT | PPS_CAPTURECLEAR;
pps_init(&zst->zst_pps_state);
#else /* !__HAVE_TIMECOUNTER */
zst->ppsparam.mode = 0;
#endif /* !__HAVE_TIMECOUNTER */
simple_unlock(&cs->cs_lock);
splx(s2);
@ -853,6 +867,23 @@ zsioctl(dev, cmd, data, flag, l)
*(int *)data = zs_to_tiocm(zst);
break;
#ifdef __HAVE_TIMECOUNTER
case PPS_IOC_CREATE:
case PPS_IOC_DESTROY:
case PPS_IOC_GETPARAMS:
case PPS_IOC_SETPARAMS:
case PPS_IOC_GETCAP:
case PPS_IOC_FETCH:
#ifdef PPS_SYNC
case PPS_IOC_KCBIND:
#endif
error = pps_ioctl(cmd, data, &zst->zst_pps_state);
if (zst->zst_pps_state.ppsparam.mode & PPS_CAPTUREBOTH)
zst->zst_ppsmask = ZSRR0_DCD;
else
zst->zst_ppsmask = 0;
break;
#else /* !__HAVE_TIMECOUNTER */
case PPS_IOC_CREATE:
break;
@ -967,17 +998,22 @@ zsioctl(dev, cmd, data, flag, l)
break;
}
#endif /* PPS_SYNC */
#endif /* !__HAVE_TIMECOUNTER */
case TIOCDCDTIMESTAMP: /* XXX old, overloaded API used by xntpd v3 */
if (cs->cs_rr0_pps == 0) {
error = EINVAL;
break;
}
/*
* Some GPS clocks models use the falling rather than
* rising edge as the on-the-second signal.
* The old API has no way to specify PPS polarity.
*/
#ifdef __HAVE_TIMECOUNTER
#ifndef PPS_TRAILING_EDGE
TIMESPEC_TO_TIMEVAL((struct timeval *)data,
&zst->zst_pps_state.ppsinfo.assert_timestamp);
#else
TIMESPEC_TO_TIMEVAL((struct timeval *)data,
&zst->zst_pps_state.ppsinfo.clear_timestamp);
#endif
#else /* !__HAVE_TIMECOUNTER */
zst->zst_ppsmask = ZSRR0_DCD;
#ifndef PPS_TRAILING_EDGE
zst->zst_ppsassert = ZSRR0_DCD;
@ -990,6 +1026,7 @@ zsioctl(dev, cmd, data, flag, l)
TIMESPEC_TO_TIMEVAL((struct timeval *)data,
&zst->ppsinfo.clear_timestamp);
#endif
#endif /* !__HAVE_TIMECOUNTER */
/*
* Now update interrupts.
*/
@ -1659,6 +1696,15 @@ zstty_stint(cs, force)
* Pulse-per-second clock signal on edge of DCD?
*/
if (ISSET(delta, zst->zst_ppsmask)) {
#ifdef __HAVE_TIMECOUNTER
if (zst->zst_pps_state.ppsparam.mode & PPS_CAPTUREBOTH) {
pps_capture(&zst->zst_pps_state);
pps_event(&zst->zst_pps_state,
(ISSET(cs->cs_rr0, zst->zst_ppsmask))
? PPS_CAPTUREASSERT
: PPS_CAPTURECLEAR);
}
#else /* !__HAVE_TIMECOUNTER */
struct timeval tv;
if (ISSET(rr0, zst->zst_ppsmask) == zst->zst_ppsassert) {
/* XXX nanotime() */
@ -1700,6 +1746,7 @@ zstty_stint(cs, force)
zst->ppsinfo.clear_sequence++;
zst->ppsinfo.current_mode = zst->ppsparam.mode;
}
#endif /* !__HAVE_TIMECOUNTER */
}
/*

View File

@ -1,4 +1,4 @@
/* $NetBSD: amr.c,v 1.34 2006/04/17 13:31:02 elad Exp $ */
/* $NetBSD: amr.c,v 1.35 2006/06/07 22:33:36 kardel Exp $ */
/*-
* Copyright (c) 2002, 2003 The NetBSD Foundation, Inc.
@ -71,7 +71,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: amr.c,v 1.34 2006/04/17 13:31:02 elad Exp $");
__KERNEL_RCSID(0, "$NetBSD: amr.c,v 1.35 2006/06/07 22:33:36 kardel Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -833,7 +833,6 @@ amr_thread(void *cookie)
struct amr_ccb *ac;
struct amr_logdrive *al;
struct amr_enquiry *ae;
time_t curtime;
int rv, i, s;
amr = cookie;
@ -850,10 +849,9 @@ amr_thread(void *cookie)
s = splbio();
amr_intr(cookie);
curtime = (time_t)mono_time.tv_sec;
ac = TAILQ_FIRST(&amr->amr_ccb_active);
while (ac != NULL) {
if (ac->ac_start_time + AMR_TIMEOUT > curtime)
if (ac->ac_start_time + AMR_TIMEOUT > time_uptime)
break;
if ((ac->ac_flags & AC_MOAN) == 0) {
printf("%s: ccb %d timed out; mailbox:\n",
@ -1189,7 +1187,7 @@ amr_quartz_submit(struct amr_softc *amr, struct amr_ccb *ac)
bus_dmamap_sync(amr->amr_dmat, amr->amr_dmamap, 0,
sizeof(struct amr_mailbox), BUS_DMASYNC_PREWRITE);
ac->ac_start_time = (time_t)mono_time.tv_sec;
ac->ac_start_time = time_uptime;
ac->ac_flags |= AC_ACTIVE;
amr_outl(amr, AMR_QREG_IDB,
(amr->amr_mbox_paddr + 16) | AMR_QIDB_SUBMIT);
@ -1223,7 +1221,7 @@ amr_std_submit(struct amr_softc *amr, struct amr_ccb *ac)
bus_dmamap_sync(amr->amr_dmat, amr->amr_dmamap, 0,
sizeof(struct amr_mailbox), BUS_DMASYNC_PREWRITE);
ac->ac_start_time = (time_t)mono_time.tv_sec;
ac->ac_start_time = time_uptime;
ac->ac_flags |= AC_ACTIVE;
amr_outb(amr, AMR_SREG_CMD, AMR_SCMD_POST);
return (0);

View File

@ -1,4 +1,4 @@
/* $NetBSD: viaenv.c,v 1.13 2005/12/11 12:22:51 christos Exp $ */
/* $NetBSD: viaenv.c,v 1.14 2006/06/07 22:33:37 kardel Exp $ */
/*
* Copyright (c) 2000 Johan Danielsson
@ -35,7 +35,7 @@
/* driver for the hardware monitoring part of the VIA VT82C686A */
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: viaenv.c,v 1.13 2005/12/11 12:22:51 christos Exp $");
__KERNEL_RCSID(0, "$NetBSD: viaenv.c,v 1.14 2006/06/07 22:33:37 kardel Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -202,17 +202,16 @@ static void
viaenv_refresh_sensor_data(struct viaenv_softc *sc)
{
static const struct timeval onepointfive = { 1, 500000 };
struct timeval t;
struct timeval t, utv;
u_int8_t v, v2;
int i, s;
int i;
/* Read new values at most once every 1.5 seconds. */
timeradd(&sc->sc_lastread, &onepointfive, &t);
s = splclock();
i = timercmp(&mono_time, &t, >);
getmicrouptime(&utv);
i = timercmp(&utv, &t, >);
if (i)
sc->sc_lastread = mono_time;
splx(s);
sc->sc_lastread = utv;
if (i == 0)
return;

View File

@ -1,4 +1,4 @@
/* $NetBSD: pms.c,v 1.10 2006/03/29 07:11:08 thorpej Exp $ */
/* $NetBSD: pms.c,v 1.11 2006/06/07 22:33:37 kardel Exp $ */
/*-
* Copyright (c) 2004 Kentaro Kurahone.
@ -28,7 +28,7 @@
#include "opt_pms.h"
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: pms.c,v 1.10 2006/03/29 07:11:08 thorpej Exp $");
__KERNEL_RCSID(0, "$NetBSD: pms.c,v 1.11 2006/06/07 22:33:37 kardel Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -493,16 +493,13 @@ pmsinput(void *vsc, int data)
u_int changed;
int dx, dy, dz = 0;
int newbuttons = 0;
int s;
if (!sc->sc_enabled) {
/* Interrupts are not expected. Discard the byte. */
return;
}
s = splclock();
sc->current = mono_time;
splx(s);
getmicrouptime(&sc->current);
if (sc->inputstate > 0) {
struct timeval diff;

View File

@ -1,4 +1,4 @@
/* $NetBSD: synaptics.c,v 1.9 2005/12/24 20:27:52 perry Exp $ */
/* $NetBSD: synaptics.c,v 1.10 2006/06/07 22:33:37 kardel Exp $ */
/*
* Copyright (c) 2005, Steve C. Woodford
@ -650,16 +650,13 @@ pms_synaptics_input(void *vsc, int data)
struct synaptics_softc *sc = &psc->u.synaptics;
struct timeval diff;
struct synaptics_packet sp;
int s;
if (!psc->sc_enabled) {
/* Interrupts are not expected. Discard the byte. */
return;
}
s = splclock();
psc->current = mono_time;
splx(s);
getmicrouptime(&psc->current);
if (psc->inputstate > 0) {
timersub(&psc->current, &psc->last, &diff);

View File

@ -1,6 +1,8 @@
/* $NetBSD: pps_ppbus.c,v 1.6 2006/05/10 10:33:40 drochner Exp $ */
/* $NetBSD: pps_ppbus.c,v 1.7 2006/06/07 22:33:37 kardel Exp $ */
/*
* ported to timecounters by Frank Kardel 2006
*
* Copyright (c) 2004
* Matthias Drochner. All rights reserved.
*
@ -27,7 +29,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: pps_ppbus.c,v 1.6 2006/05/10 10:33:40 drochner Exp $");
__KERNEL_RCSID(0, "$NetBSD: pps_ppbus.c,v 1.7 2006/06/07 22:33:37 kardel Exp $");
#include "opt_ntp.h"
@ -47,11 +49,15 @@ struct pps_softc {
struct ppbus_device_softc pps_dev;
struct device *ppbus;
int busy;
#ifdef __HAVE_TIMECOUNTER
struct pps_state pps_state; /* pps state */
#else /* !__HAVE_TIMECOUNTER */
pps_info_t ppsinfo;
pps_params_t ppsparam;
#ifdef PPS_SYNC
int hardpps;
#endif
#endif /* !__HAVE_TIMECOUNTER */
};
static int pps_probe(struct device *, struct cfdata *, void *);
@ -70,7 +76,9 @@ const struct cdevsw pps_cdevsw = {
static void ppsintr(void *arg);
#ifndef __HAVE_TIMECOUNTER
static int ppscap = PPS_TSFMT_TSPEC | PPS_CAPTUREASSERT | PPS_OFFSETASSERT;
#endif
static int
pps_probe(struct device *parent, struct cfdata *match, void *aux)
@ -125,6 +133,12 @@ ppsopen(dev_t dev, int flags, int fmt, struct lwp *l)
ppbus_set_mode(sc->ppbus, PPBUS_PS2, 0);
ppbus_wctr(sc->ppbus, IRQENABLE | PCD | nINIT | SELECTIN);
#ifdef __HAVE_TIMECOUNTER
memset((void *)&sc->pps_state, 0, sizeof(sc->pps_state));
sc->pps_state.ppscap = PPS_CAPTUREASSERT;
pps_init(&sc->pps_state);
#endif /* __HAVE_TIMECOUNTER */
sc->busy = 1;
return (0);
}
@ -135,11 +149,16 @@ ppsclose(dev_t dev, int flags, int fmt, struct lwp *l)
struct pps_softc *sc = device_lookup(&pps_cd, minor(dev));
struct device *ppbus = sc->ppbus;
sc->ppsparam.mode = 0;
sc->busy = 0;
#ifdef __HAVE_TIMECOUNTER
sc->pps_state.ppsparam.mode = 0;
#else /* !__HAVE_TIMECOUNTER */
sc->ppsparam.mode = 0;
#ifdef PPS_SYNC
sc->hardpps = 0;
#endif
#endif /* __HAVE_TIMECOUNTER */
ppbus_wdtr(ppbus, 0);
ppbus_wctr(ppbus, 0);
@ -154,11 +173,25 @@ ppsintr(void *arg)
{
struct pps_softc *sc = arg;
struct device *ppbus = sc->ppbus;
#ifndef __HAVE_TIMECOUNTER
struct timeval tv;
#else /* __HAVE_TIMECOUNTER */
pps_capture(&sc->pps_state);
#endif /* __HAVE_TIMECOUNTER */
if (!(ppbus_rstr(ppbus) & nACK))
return;
#ifdef __HAVE_TIMECOUNTER
if (sc->pps_state.ppsparam.mode & PPS_ECHOASSERT)
ppbus_wctr(ppbus, IRQENABLE | AUTOFEED);
pps_event(&sc->pps_state, PPS_CAPTUREASSERT);
if (sc->pps_state.ppsparam.mode & PPS_ECHOASSERT)
ppbus_wctr(ppbus, IRQENABLE);
#else /* !__HAVE_TIMECOUNTER */
microtime(&tv);
TIMEVAL_TO_TIMESPEC(&tv, &sc->ppsinfo.assert_timestamp);
if (sc->ppsparam.mode & PPS_OFFSETASSERT) {
@ -172,6 +205,7 @@ ppsintr(void *arg)
#endif
sc->ppsinfo.assert_sequence++;
sc->ppsinfo.current_mode = sc->ppsparam.mode;
#endif /* !__HAVE_TIMECOUNTER */
}
static int
@ -181,6 +215,19 @@ ppsioctl(dev_t dev, u_long cmd, caddr_t data, int flags, struct lwp *l)
int error = 0;
switch (cmd) {
#ifdef __HAVE_TIMECOUNTER
case PPS_IOC_CREATE:
case PPS_IOC_DESTROY:
case PPS_IOC_GETPARAMS:
case PPS_IOC_SETPARAMS:
case PPS_IOC_GETCAP:
case PPS_IOC_FETCH:
#ifdef PPS_SYNC
case PPS_IOC_KCBIND:
#endif
error = pps_ioctl(cmd, data, &sc->pps_state);
break;
#else /* !__HAVE_TIMECOUNTER */
case PPS_IOC_CREATE:
break;
@ -224,6 +271,7 @@ ppsioctl(dev_t dev, u_long cmd, caddr_t data, int flags, struct lwp *l)
sc->hardpps = 0;
break;
#endif
#endif /* !__HAVE_TIMECOUNTER */
default:
error = EPASSTHROUGH;

View File

@ -1,4 +1,4 @@
/* $NetBSD: rf_etimer.h,v 1.10 2005/12/11 12:23:37 christos Exp $ */
/* $NetBSD: rf_etimer.h,v 1.11 2006/06/07 22:33:37 kardel Exp $ */
/*
* Copyright (c) 1995 Carnegie-Mellon University.
* All rights reserved.
@ -42,19 +42,13 @@ struct RF_Etimer_s {
#define RF_ETIMER_START(_t_) \
{ \
int _s; \
memset(&(_t_), 0, sizeof (_t_)); \
_s = splclock(); \
(_t_).st = mono_time; \
splx(_s); \
getmicrouptime(&(_t_).st); \
}
#define RF_ETIMER_STOP(_t_) \
{ \
int _s; \
_s = splclock(); \
(_t_).et = mono_time; \
splx(_s); \
getmicrouptime(&(_t_).et); \
}
#define RF_ETIMER_EVAL(_t_) \

View File

@ -1,4 +1,4 @@
/* $NetBSD: st.c,v 1.190 2006/04/20 12:13:52 blymn Exp $ */
/* $NetBSD: st.c,v 1.191 2006/06/07 22:33:37 kardel Exp $ */
/*-
* Copyright (c) 1998, 2004 The NetBSD Foundation, Inc.
@ -57,7 +57,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: st.c,v 1.190 2006/04/20 12:13:52 blymn Exp $");
__KERNEL_RCSID(0, "$NetBSD: st.c,v 1.191 2006/06/07 22:33:37 kardel Exp $");
#include "opt_scsi.h"
@ -1348,7 +1348,6 @@ stdone(struct scsipi_xfer *xs, int error)
iostat_unbusy(st->stats, bp->b_bcount,
((bp->b_flags & B_READ) == B_READ));
#if NRND > 0
rnd_add_uint32(&st->rnd_source, bp->b_blkno);
#endif

View File

@ -1,4 +1,4 @@
/* $NetBSD: kbd.c,v 1.55 2005/12/14 00:41:17 christos Exp $ */
/* $NetBSD: kbd.c,v 1.56 2006/06/07 22:33:38 kardel Exp $ */
/*
* Copyright (c) 1992, 1993
@ -47,7 +47,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: kbd.c,v 1.55 2005/12/14 00:41:17 christos Exp $");
__KERNEL_RCSID(0, "$NetBSD: kbd.c,v 1.56 2006/06/07 22:33:38 kardel Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -794,7 +794,7 @@ kbd_input_event(struct kbd_softc *k, int code)
fe->id = KEY_CODE(code);
fe->value = KEY_UP(code) ? VKEY_UP : VKEY_DOWN;
fe->time = time;
getmicrotime(&fe->time);
k->k_events.ev_put = put;
EV_WAKEUP(&k->k_events);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: ms.c,v 1.31 2006/03/10 20:25:45 macallan Exp $ */
/* $NetBSD: ms.c,v 1.32 2006/06/07 22:33:38 kardel Exp $ */
/*
* Copyright (c) 1992, 1993
@ -52,7 +52,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: ms.c,v 1.31 2006/03/10 20:25:45 macallan Exp $");
__KERNEL_RCSID(0, "$NetBSD: ms.c,v 1.32 2006/06/07 22:33:38 kardel Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -372,7 +372,7 @@ ms_input(ms, c)
d = to_one[d - 1]; /* from 1..7 to {1,2,4} */
fe->id = to_id[d - 1]; /* from {1,2,4} to ID */
fe->value = mb & d ? VKEY_DOWN : VKEY_UP;
fe->time = time;
getmicrotime(&fe->time);
ADVANCE;
ub ^= d;
}
@ -380,7 +380,7 @@ ms_input(ms, c)
NEXT;
fe->id = LOC_X_DELTA;
fe->value = ms->ms_dx;
fe->time = time;
getmicrotime(&fe->time);
ADVANCE;
ms->ms_dx = 0;
}
@ -388,7 +388,7 @@ ms_input(ms, c)
NEXT;
fe->id = LOC_Y_DELTA;
fe->value = ms->ms_dy;
fe->time = time;
getmicrotime(&fe->time);
ADVANCE;
ms->ms_dy = 0;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: wsevent.c,v 1.18 2006/02/07 09:13:02 jmmv Exp $ */
/* $NetBSD: wsevent.c,v 1.19 2006/06/07 22:33:38 kardel Exp $ */
/*-
* Copyright (c) 2006 The NetBSD Foundation, Inc.
@ -111,7 +111,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: wsevent.c,v 1.18 2006/02/07 09:13:02 jmmv Exp $");
__KERNEL_RCSID(0, "$NetBSD: wsevent.c,v 1.19 2006/06/07 22:33:38 kardel Exp $");
#include <sys/param.h>
#include <sys/kernel.h>
@ -339,7 +339,6 @@ int
wsevent_inject(struct wseventvar *ev, struct wscons_event *events,
size_t nevents)
{
int oldspl;
size_t avail, i;
struct timespec t;
@ -355,9 +354,7 @@ wsevent_inject(struct wseventvar *ev, struct wscons_event *events,
return ENOSPC;
/* Use the current time for all events. */
oldspl = splhigh();
TIMEVAL_TO_TIMESPEC(&time, &t);
splx(oldspl);
getnanotime(&t);
/* Inject the events. */
for (i = 0; i < nevents; i++) {

View File

@ -1,4 +1,4 @@
/* $NetBSD: pfvar.h,v 1.11 2006/01/17 12:24:53 peter Exp $ */
/* $NetBSD: pfvar.h,v 1.12 2006/06/07 22:33:38 kardel Exp $ */
/* $OpenBSD: pfvar.h,v 1.213 2005/03/03 07:13:39 dhartmei Exp $ */
/*
@ -1608,6 +1608,7 @@ int pfil_ifaddr_wrapper(void *, struct mbuf **, struct ifnet *, int);
#define PRIu32 "u" /* XXX */
#endif
#if !defined(__OpenBSD__)
#if !defined(__NetBSD__)
#include <sys/kernel.h> /* mono_time */
static __inline void getmicrouptime(struct timeval *);
static __inline void
@ -1620,9 +1621,10 @@ getmicrouptime(struct timeval *tvp)
splx(s);
}
#define time_second time.tv_sec
#endif /* !__NetBSD__ */
#define m_copym2 m_dup
#define pool_allocator_oldnointr pool_allocator_nointr
#endif
#endif /* !__OpenBSD__ */
#endif /* _KERNEL */
/* The fingerprint functions can be linked into userland programs (tcpdump) */

View File

@ -1,4 +1,4 @@
/* $NetBSD: msdosfs_vnops.c,v 1.28 2006/05/14 21:31:52 elad Exp $ */
/* $NetBSD: msdosfs_vnops.c,v 1.29 2006/06/07 22:33:38 kardel Exp $ */
/*-
* Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank.
@ -48,7 +48,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: msdosfs_vnops.c,v 1.28 2006/05/14 21:31:52 elad Exp $");
__KERNEL_RCSID(0, "$NetBSD: msdosfs_vnops.c,v 1.29 2006/06/07 22:33:38 kardel Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -1871,22 +1871,27 @@ msdosfs_detimes(struct denode *dep, const struct timespec *acc,
struct timespec *ts = NULL, tsb;
KASSERT(dep->de_flag & (DE_UPDATE | DE_CREATE | DE_ACCESS));
/* XXX just call getnanotime early and use result if needed? */
dep->de_flag |= DE_MODIFIED;
if (dep->de_flag & DE_UPDATE) {
if (mod == NULL)
mod = ts = nanotime(&tsb);
if (mod == NULL) {
getnanotime(&tsb);
mod = ts = &tsb;
}
unix2dostime(mod, gmtoff, &dep->de_MDate, &dep->de_MTime, NULL);
dep->de_Attributes |= ATTR_ARCHIVE;
}
if ((dep->de_pmp->pm_flags & MSDOSFSMNT_NOWIN95) == 0) {
if (dep->de_flag & DE_ACCESS) {
if (acc == NULL)
acc = ts == NULL ? (ts = nanotime(&tsb)) : ts;
acc = ts == NULL ?
(getnanotime(&tsb), ts = &tsb) : ts;
unix2dostime(acc, gmtoff, &dep->de_ADate, NULL, NULL);
}
if (dep->de_flag & DE_CREATE) {
if (cre == NULL)
cre = ts == NULL ? (ts = nanotime(&tsb)) : ts;
cre = ts == NULL ?
(getnanotime(&tsb), ts = &tsb) : ts;
unix2dostime(cre, gmtoff, &dep->de_CDate,
&dep->de_CTime, &dep->de_CHun);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: ptyfs_vnops.c,v 1.14 2006/05/14 21:31:52 elad Exp $ */
/* $NetBSD: ptyfs_vnops.c,v 1.15 2006/06/07 22:33:38 kardel Exp $ */
/*
* Copyright (c) 1993, 1995
@ -76,7 +76,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: ptyfs_vnops.c,v 1.14 2006/05/14 21:31:52 elad Exp $");
__KERNEL_RCSID(0, "$NetBSD: ptyfs_vnops.c,v 1.15 2006/06/07 22:33:38 kardel Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -774,10 +774,10 @@ ptyfs_close(void *v)
struct vnode *vp = ap->a_vp;
struct ptyfsnode *ptyfs = VTOPTYFS(vp);
simple_lock(&vp->v_interlock);
if (vp->v_usecount > 1)
simple_lock(&vp->v_interlock);
if (vp->v_usecount > 1)
PTYFS_ITIMES(ptyfs, NULL, NULL, NULL);
simple_unlock(&vp->v_interlock);
simple_unlock(&vp->v_interlock);
switch (ptyfs->ptyfs_type) {
case PTYFSpts:
@ -806,7 +806,7 @@ ptyfs_read(void *v)
ptyfs->ptyfs_flag |= PTYFS_ACCESS;
/* hardclock() resolution is good enough for ptyfs */
TIMEVAL_TO_TIMESPEC(&time, &ts);
getnanotime(&ts);
(void)ptyfs_update(vp, &ts, &ts, 0);
switch (ptyfs->ptyfs_type) {
@ -842,8 +842,7 @@ ptyfs_write(void *v)
int error;
ptyfs->ptyfs_flag |= PTYFS_MODIFY;
/* hardclock() resolution is good enough for ptyfs */
TIMEVAL_TO_TIMESPEC(&time, &ts);
getnanotime(&ts);
(void)ptyfs_update(vp, &ts, &ts, 0);
switch (ptyfs->ptyfs_type) {
@ -948,22 +947,24 @@ void
ptyfs_itimes(struct ptyfsnode *ptyfs, const struct timespec *acc,
const struct timespec *mod, const struct timespec *cre)
{
struct timespec *ts = NULL, tsb;
struct timespec now;
KASSERT(ptyfs->ptyfs_flag & (PTYFS_ACCESS|PTYFS_CHANGE|PTYFS_MODIFY));
getnanotime(&now);
if (ptyfs->ptyfs_flag & (PTYFS_ACCESS|PTYFS_MODIFY)) {
if (acc == NULL)
acc = ts = nanotime(&tsb);
acc = &now;
ptyfs->ptyfs_atime = *acc;
}
if (ptyfs->ptyfs_flag & PTYFS_MODIFY) {
if (mod == NULL)
mod = ts == NULL ? (ts = nanotime(&tsb)) : ts;
mod = &now;
ptyfs->ptyfs_mtime = *mod;
}
if (ptyfs->ptyfs_flag & PTYFS_CHANGE) {
if (cre == NULL)
cre = ts == NULL ? (ts = nanotime(&tsb)) : ts;
cre = &now;
ptyfs->ptyfs_ctime = *cre;
}
ptyfs->ptyfs_flag &= ~(PTYFS_ACCESS|PTYFS_CHANGE|PTYFS_MODIFY);

View File

@ -1,4 +1,4 @@
/* $NetBSD: smbfs_node.c,v 1.27 2006/05/14 21:31:52 elad Exp $ */
/* $NetBSD: smbfs_node.c,v 1.28 2006/06/07 22:33:38 kardel Exp $ */
/*
* Copyright (c) 2000-2001 Boris Popov
@ -35,7 +35,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: smbfs_node.c,v 1.27 2006/05/14 21:31:52 elad Exp $");
__KERNEL_RCSID(0, "$NetBSD: smbfs_node.c,v 1.28 2006/06/07 22:33:38 kardel Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -312,7 +312,6 @@ void
smbfs_attr_cacheenter(struct vnode *vp, struct smbfattr *fap)
{
struct smbnode *np = VTOSMB(vp);
int s;
if (vp->v_type == VREG) {
if (np->n_size != fap->fa_size) {
@ -327,9 +326,7 @@ smbfs_attr_cacheenter(struct vnode *vp, struct smbfattr *fap)
np->n_mtime = fap->fa_mtime;
np->n_dosattr = fap->fa_attr;
s = splclock();
np->n_attrage = mono_time.tv_sec;
splx(s);
np->n_attrage = time_uptime;
}
int
@ -337,12 +334,9 @@ smbfs_attr_cachelookup(struct vnode *vp, struct vattr *va)
{
struct smbnode *np = VTOSMB(vp);
struct smbmount *smp = VTOSMBFS(vp);
int s;
time_t diff;
s = splclock();
diff = mono_time.tv_sec - np->n_attrage;
splx(s);
diff = time_uptime - np->n_attrage;
if (diff > SMBFS_ATTRTIMO) /* XXX should be configurable */
return ENOENT;

View File

@ -1,4 +1,4 @@
/* $NetBSD: smbfs_smb.c,v 1.29 2005/12/11 12:24:29 christos Exp $ */
/* $NetBSD: smbfs_smb.c,v 1.30 2006/06/07 22:33:38 kardel Exp $ */
/*-
* Copyright (c) 2003 The NetBSD Foundation, Inc.
@ -71,7 +71,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: smbfs_smb.c,v 1.29 2005/12/11 12:24:29 christos Exp $");
__KERNEL_RCSID(0, "$NetBSD: smbfs_smb.c,v 1.30 2006/06/07 22:33:38 kardel Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -642,7 +642,7 @@ smbfs_smb_create(struct smbnode *dnp, const char *name, int nmlen,
smb_rq_getrequest(rqp, &mbp);
/* get current time */
(void)nanotime(&ctime);
getnanotime(&ctime);
smb_time_local2server(&ctime, SSTOVC(ssp)->vc_sopt.sv_tz, &tm);
smb_rq_wstart(rqp);

View File

@ -1,4 +1,4 @@
/* $NetBSD: tmpfs_subr.c,v 1.20 2006/05/15 00:05:16 christos Exp $ */
/* $NetBSD: tmpfs_subr.c,v 1.21 2006/06/07 22:33:39 kardel Exp $ */
/*
* Copyright (c) 2005, 2006 The NetBSD Foundation, Inc.
@ -42,7 +42,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: tmpfs_subr.c,v 1.20 2006/05/15 00:05:16 christos Exp $");
__KERNEL_RCSID(0, "$NetBSD: tmpfs_subr.c,v 1.21 2006/06/07 22:33:39 kardel Exp $");
#include <sys/param.h>
#include <sys/dirent.h>
@ -131,7 +131,7 @@ tmpfs_alloc_node(struct tmpfs_mount *tmp, enum vtype type,
nnode->tn_status = 0;
nnode->tn_flags = 0;
nnode->tn_links = 0;
(void)nanotime(&nnode->tn_atime);
getnanotime(&nnode->tn_atime);
nnode->tn_birthtime = nnode->tn_ctime = nnode->tn_mtime =
nnode->tn_atime;
nnode->tn_uid = uid;
@ -1224,9 +1224,8 @@ void
tmpfs_itimes(struct vnode *vp, const struct timespec *acc,
const struct timespec *mod)
{
struct timespec now;
struct tmpfs_node *node;
const struct timespec *ts = NULL;
struct timespec tsb;
node = VP_TO_TMPFS_NODE(vp);
@ -1234,21 +1233,20 @@ tmpfs_itimes(struct vnode *vp, const struct timespec *acc,
TMPFS_NODE_CHANGED)) == 0)
return;
getnanotime(&now);
if (node->tn_status & TMPFS_NODE_ACCESSED) {
if (acc == NULL)
acc = ts == NULL ? (ts = nanotime(&tsb)) : ts;
acc = &now;
node->tn_atime = *acc;
}
if (node->tn_status & TMPFS_NODE_MODIFIED) {
if (mod == NULL)
mod = ts == NULL ? (ts = nanotime(&tsb)) : ts;
mod = &now;
node->tn_mtime = *mod;
}
if (node->tn_status & TMPFS_NODE_CHANGED) {
if (ts == NULL)
ts = nanotime(&tsb);
node->tn_ctime = *ts;
}
if (node->tn_status & TMPFS_NODE_CHANGED)
node->tn_ctime = now;
node->tn_status &=
~(TMPFS_NODE_ACCESSED | TMPFS_NODE_MODIFIED | TMPFS_NODE_CHANGED);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: init_main.c,v 1.266 2006/05/14 21:15:11 elad Exp $ */
/* $NetBSD: init_main.c,v 1.267 2006/06/07 22:33:39 kardel Exp $ */
/*
* Copyright (c) 1982, 1986, 1989, 1991, 1992, 1993
@ -71,15 +71,16 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: init_main.c,v 1.266 2006/05/14 21:15:11 elad Exp $");
__KERNEL_RCSID(0, "$NetBSD: init_main.c,v 1.267 2006/06/07 22:33:39 kardel Exp $");
#include "opt_ipsec.h"
#include "opt_sysv.h"
#include "opt_multiprocessor.h"
#include "opt_pipe.h"
#include "opt_syscall_debug.h"
#include "opt_posix.h"
#include "opt_kcont.h"
#include "opt_multiprocessor.h"
#include "opt_ntp.h"
#include "opt_pipe.h"
#include "opt_posix.h"
#include "opt_syscall_debug.h"
#include "opt_sysv.h"
#include "opt_verified_exec.h"
#include "rnd.h"
@ -174,7 +175,9 @@ struct proc *initproc;
struct vnode *rootvp, *swapdev_vp;
int boothowto;
int cold = 1; /* still working on startup */
struct timeval boottime;
#ifndef __HAVE_TIMECOUNTER
struct timeval boottime;
#endif
time_t rootfstime; /* recorded root fs time, if known */
volatile int start_init_exec; /* semaphore for start_init() */
@ -192,6 +195,9 @@ void main(void);
void
main(void)
{
#ifdef __HAVE_TIMECOUNTER
struct timeval time;
#endif
struct lwp *l;
struct proc *p;
struct pdevinit *pdev;
@ -284,6 +290,13 @@ main(void)
#endif
vfsinit();
#ifdef __HAVE_TIMECOUNTER
#ifdef NTP
ntp_init();
#endif
#endif /* __HAVE_TIMECOUNTER */
/* Configure the system hardware. This will enable interrupts. */
configure();
@ -444,9 +457,15 @@ main(void)
*/
proclist_lock_read();
s = splsched();
#ifdef __HAVE_TIMECOUNTER
getmicrotime(&time);
#else
mono_time = time;
#endif
boottime = time;
LIST_FOREACH(p, &allproc, p_list) {
KASSERT((p->p_flag & P_MARKER) == 0);
p->p_stats->p_start = mono_time = boottime = time;
p->p_stats->p_start = time;
LIST_FOREACH(l, &p->p_lwps, l_sibling) {
if (l->l_cpu != NULL)
l->l_cpu->ci_schedstate.spc_runtime = time;

View File

@ -1,4 +1,4 @@
/* $NetBSD: kern_acct.c,v 1.63 2006/05/14 21:15:11 elad Exp $ */
/* $NetBSD: kern_acct.c,v 1.64 2006/06/07 22:33:39 kardel Exp $ */
/*-
* Copyright (c) 1982, 1986, 1989, 1993
@ -71,7 +71,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: kern_acct.c,v 1.63 2006/05/14 21:15:11 elad Exp $");
__KERNEL_RCSID(0, "$NetBSD: kern_acct.c,v 1.64 2006/06/07 22:33:39 kardel Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -392,9 +392,9 @@ int
acct_process(struct lwp *l)
{
struct acct acct;
struct rusage *r;
struct timeval ut, st, tmp;
int s, t, error = 0;
struct rusage *r;
int t, error = 0;
struct plimit *oplim = NULL;
struct proc *p = l->l_proc;
@ -430,9 +430,8 @@ acct_process(struct lwp *l)
/* (3) The elapsed time the commmand ran (and its starting time) */
acct.ac_btime = p->p_stats->p_start.tv_sec;
s = splclock();
timersub(&time, &p->p_stats->p_start, &tmp);
splx(s);
getmicrotime(&tmp);
timersub(&tmp, &p->p_stats->p_start, &tmp);
acct.ac_etime = encode_comp_t(tmp.tv_sec, tmp.tv_usec);
/* (4) The average amount of memory used */

View File

@ -1,4 +1,4 @@
/* $NetBSD: kern_clock.c,v 1.98 2006/04/15 02:12:49 christos Exp $ */
/* $NetBSD: kern_clock.c,v 1.99 2006/06/07 22:33:39 kardel Exp $ */
/*-
* Copyright (c) 2000, 2004 The NetBSD Foundation, Inc.
@ -76,7 +76,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: kern_clock.c,v 1.98 2006/04/15 02:12:49 christos Exp $");
__KERNEL_RCSID(0, "$NetBSD: kern_clock.c,v 1.99 2006/06/07 22:33:39 kardel Exp $");
#include "opt_ntp.h"
#include "opt_multiprocessor.h"
@ -93,6 +93,9 @@ __KERNEL_RCSID(0, "$NetBSD: kern_clock.c,v 1.98 2006/04/15 02:12:49 christos Exp
#include <sys/timex.h>
#include <sys/sched.h>
#include <sys/time.h>
#ifdef __HAVE_TIMECOUNTER
#include <sys/timetc.h>
#endif
#include <machine/cpu.h>
#ifdef __HAVE_GENERIC_SOFT_INTERRUPTS
@ -127,6 +130,7 @@ __KERNEL_RCSID(0, "$NetBSD: kern_clock.c,v 1.98 2006/04/15 02:12:49 christos Exp
* profhz/stathz for statistics. (For profiling, every tick counts.)
*/
#ifndef __HAVE_TIMECOUNTER
#ifdef NTP /* NTP phase-locked loop in kernel */
/*
* Phase/frequency-lock loop (PLL/FLL) definitions
@ -308,7 +312,6 @@ long clock_cpu = 0; /* CPU clock adjust */
#endif /* EXT_CLOCK */
#endif /* NTP */
/*
* Bump a timeval by a small number of usec's.
*/
@ -322,16 +325,18 @@ long clock_cpu = 0; /* CPU clock adjust */
tp->tv_sec++; \
} \
}
#endif /* !__HAVE_TIMECOUNTER */
int stathz;
int profhz;
int profsrc;
int schedhz;
int profprocs;
int hardclock_ticks;
u_int hardclock_ticks;
static int statscheddiv; /* stat => sched divider (used if schedhz == 0) */
static int psdiv; /* prof => stat divider */
int psratio; /* ratio: prof / stat */
#ifndef __HAVE_TIMECOUNTER
int tickfix, tickfixinterval; /* used if tick not really integral */
#ifndef NTP
static int tickfixcnt; /* accumulated fractional error */
@ -347,8 +352,30 @@ int shifthz;
*/
volatile struct timeval time __attribute__((__aligned__(__alignof__(quad_t))));
volatile struct timeval mono_time;
#endif /* !__HAVE_TIMECOUNTER */
#ifdef __HAVE_GENERIC_SOFT_INTERRUPTS
void *softclock_si;
#endif
#ifdef __HAVE_TIMECOUNTER
static u_int get_intr_timecount(struct timecounter *);
static struct timecounter intr_timecounter = {
get_intr_timecount, /* get_timecount */
0, /* no poll_pps */
~0u, /* counter_mask */
0, /* frequency */
"clockinterrupt", /* name */
0 /* quality - minimum implementation level for a clock */
};
static u_int
get_intr_timecount(struct timecounter *tc)
{
return hardclock_ticks;
}
#endif
/*
* Initialize clock frequencies and start both clocks running.
@ -369,6 +396,15 @@ initclocks(void)
* code do its bit.
*/
psdiv = 1;
#ifdef __HAVE_TIMECOUNTER
inittimecounter();
/*
* provide minimum default time counter
* will only run at interrupt resolution
*/
intr_timecounter.tc_frequency = hz;
tc_init(&intr_timecounter);
#endif
cpu_initclocks();
/*
@ -386,6 +422,7 @@ initclocks(void)
panic("statscheddiv");
}
#ifndef __HAVE_TIMECOUNTER
#ifdef NTP
switch (hz) {
case 1:
@ -455,7 +492,8 @@ initclocks(void)
*/
fixtick = (1000000 - (hz*tick));
}
#endif
#endif /* NTP */
#endif /* !__HAVE_TIMECOUNTER */
}
/*
@ -466,15 +504,17 @@ hardclock(struct clockframe *frame)
{
struct lwp *l;
struct proc *p;
struct cpu_info *ci = curcpu();
struct ptimer *pt;
#ifndef __HAVE_TIMECOUNTER
int delta;
extern int tickdelta;
extern long timedelta;
struct cpu_info *ci = curcpu();
struct ptimer *pt;
#ifdef NTP
int time_update;
int ltemp;
#endif
#endif /* NTP */
#endif /* __HAVE_TIMECOUNTER */
l = curlwp;
if (l) {
@ -509,6 +549,11 @@ hardclock(struct clockframe *frame)
return;
#endif
hardclock_ticks++;
#ifdef __HAVE_TIMECOUNTER
tc_ticktock();
#else /* __HAVE_TIMECOUNTER */
/*
* Increment the time-of-day. The increment is normally just
* ``tick''. If the machine is one which has a clock frequency
@ -517,7 +562,6 @@ hardclock(struct clockframe *frame)
* if we are still adjusting the time (see adjtime()),
* ``tickdelta'' may also be added in.
*/
hardclock_ticks++;
delta = tick;
#ifndef NTP
@ -831,6 +875,7 @@ hardclock(struct clockframe *frame)
}
#endif /* NTP */
#endif /* !__HAVE_TIMECOUNTER */
/*
* Update real-time timeout queue.
@ -858,6 +903,83 @@ hardclock(struct clockframe *frame)
}
}
#ifdef __HAVE_TIMECOUNTER
/*
* Compute number of hz until specified time. Used to compute second
* argument to callout_reset() from an absolute time.
*/
int
hzto(struct timeval *tvp)
{
struct timeval now, tv;
tv = *tvp; /* Don't modify original tvp. */
getmicrotime(&now);
timersub(&tv, &now, &tv);
return tvtohz(&tv);
}
#endif /* __HAVE_TIMECOUNTER */
/*
* Compute number of ticks in the specified amount of time.
*/
int
tvtohz(struct timeval *tv)
{
unsigned long ticks;
long sec, usec;
/*
* If the number of usecs in the whole seconds part of the time
* difference fits in a long, then the total number of usecs will
* fit in an unsigned long. Compute the total and convert it to
* ticks, rounding up and adding 1 to allow for the current tick
* to expire. Rounding also depends on unsigned long arithmetic
* to avoid overflow.
*
* Otherwise, if the number of ticks in the whole seconds part of
* the time difference fits in a long, then convert the parts to
* ticks separately and add, using similar rounding methods and
* overflow avoidance. This method would work in the previous
* case, but it is slightly slower and assumes that hz is integral.
*
* Otherwise, round the time difference down to the maximum
* representable value.
*
* If ints are 32-bit, then the maximum value for any timeout in
* 10ms ticks is 248 days.
*/
sec = tv->tv_sec;
usec = tv->tv_usec;
if (usec < 0) {
sec--;
usec += 1000000;
}
if (sec < 0 || (sec == 0 && usec <= 0)) {
/*
* Would expire now or in the past. Return 0 ticks.
* This is different from the legacy hzto() interface,
* and callers need to check for it.
*/
ticks = 0;
} else if (sec <= (LONG_MAX / 1000000))
ticks = (((sec * 1000000) + (unsigned long)usec + (tick - 1))
/ tick) + 1;
else if (sec <= (LONG_MAX / hz))
ticks = (sec * hz) +
(((unsigned long)usec + (tick - 1)) / tick) + 1;
else
ticks = LONG_MAX;
if (ticks > INT_MAX)
ticks = INT_MAX;
return ((int)ticks);
}
#ifndef __HAVE_TIMECOUNTER
/*
* Compute number of hz until specified time. Used to compute second
* argument to callout_reset() from an absolute time.
@ -920,6 +1042,23 @@ hzto(struct timeval *tv)
return ((int)ticks);
}
#endif /* !__HAVE_TIMECOUNTER */
/*
* Compute number of ticks in the specified amount of time.
*/
int
tstohz(struct timespec *ts)
{
struct timeval tv;
/*
* usec has great enough resolution for hz, so convert to a
* timeval and use tvtohz() above.
*/
TIMESPEC_TO_TIMEVAL(&tv, ts);
return tvtohz(&tv);
}
/*
* Start profiling on a process.
@ -1103,9 +1242,8 @@ statclock(struct clockframe *frame)
}
}
#ifndef __HAVE_TIMECOUNTER
#ifdef NTP /* NTP phase-locked loop in kernel */
/*
* hardupdate() - local clock update
*
@ -1434,15 +1572,72 @@ hardpps(struct timeval *tvp, /* time at PPS */
#endif /* PPS_SYNC */
#endif /* NTP */
/*
* XXX: Until all md code has it.
*/
struct timespec *
/* timecounter compat functions */
void
nanotime(struct timespec *ts)
{
struct timeval tv;
microtime(&tv);
TIMEVAL_TO_TIMESPEC(&tv, ts);
return ts;
}
void
getbinuptime(struct bintime *bt)
{
struct timeval tv;
microtime(&tv);
timeval2bintime(&tv, bt);
}
void
nanouptime(struct timespec *tsp)
{
int s;
s = splclock();
TIMEVAL_TO_TIMESPEC(&mono_time, tsp);
splx(s);
}
void
getnanouptime(struct timespec *tsp)
{
int s;
s = splclock();
TIMEVAL_TO_TIMESPEC(&mono_time, tsp);
splx(s);
}
void
getmicrouptime(struct timeval *tvp)
{
int s;
s = splclock();
*tvp = mono_time;
splx(s);
}
void
getnanotime(struct timespec *tsp)
{
int s;
s = splclock();
TIMEVAL_TO_TIMESPEC(&time, tsp);
splx(s);
}
void
getmicrotime(struct timeval *tvp)
{
int s;
s = splclock();
*tvp = time;
splx(s);
}
#endif /* !__HAVE_TIMECOUNTER */

View File

@ -1,4 +1,5 @@
/* $NetBSD: kern_event.c,v 1.27 2006/05/14 21:15:11 elad Exp $ */
/* $NetBSD: kern_event.c,v 1.28 2006/06/07 22:33:39 kardel Exp $ */
/*-
* Copyright (c) 1999,2000,2001 Jonathan Lemon <jlemon@FreeBSD.org>
* All rights reserved.
@ -28,7 +29,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: kern_event.c,v 1.27 2006/05/14 21:15:11 elad Exp $");
__KERNEL_RCSID(0, "$NetBSD: kern_event.c,v 1.28 2006/06/07 22:33:39 kardel Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -923,10 +924,7 @@ kqueue_scan(struct file *fp, size_t maxevents, struct kevent *ulistp,
error = EINVAL;
goto done;
}
s = splclock();
timeradd(&atv, &time, &atv); /* calc. time to wait until */
splx(s);
timeout = hzto(&atv);
timeout = tvtohz(&atv);
if (timeout <= 0)
timeout = -1; /* do poll */
} else {

View File

@ -1,4 +1,4 @@
/* $NetBSD: kern_fork.c,v 1.124 2006/05/14 21:15:11 elad Exp $ */
/* $NetBSD: kern_fork.c,v 1.125 2006/06/07 22:33:39 kardel Exp $ */
/*-
* Copyright (c) 1999, 2001, 2004 The NetBSD Foundation, Inc.
@ -76,7 +76,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: kern_fork.c,v 1.124 2006/05/14 21:15:11 elad Exp $");
__KERNEL_RCSID(0, "$NetBSD: kern_fork.c,v 1.125 2006/06/07 22:33:39 kardel Exp $");
#include "opt_ktrace.h"
#include "opt_systrace.h"
@ -432,7 +432,7 @@ fork1(struct lwp *l1, int flags, int exitsig, void *stack, size_t stacksize,
* except if the parent requested the child to start in SSTOP state.
*/
SCHED_LOCK(s);
p2->p_stats->p_start = time;
getmicrotime(&p2->p_stats->p_start);
p2->p_acflag = AFORK;
if (p1->p_flag & P_STOPFORK) {
p2->p_nrlwps = 0;

View File

@ -1,4 +1,4 @@
/* $NetBSD: kern_ktrace.c,v 1.103 2006/05/14 21:15:11 elad Exp $ */
/* $NetBSD: kern_ktrace.c,v 1.104 2006/06/07 22:33:39 kardel Exp $ */
/*
* Copyright (c) 1989, 1993
@ -32,7 +32,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: kern_ktrace.c,v 1.103 2006/05/14 21:15:11 elad Exp $");
__KERNEL_RCSID(0, "$NetBSD: kern_ktrace.c,v 1.104 2006/06/07 22:33:39 kardel Exp $");
#include "opt_ktrace.h"
#include "opt_compat_mach.h"
@ -233,8 +233,7 @@ ktraddentry(struct lwp *l, struct ktrace_entry *kte, int flags)
struct proc *p = l->l_proc;
struct ktr_desc *ktd;
#ifdef DEBUG
struct timeval t;
int s;
struct timeval t1, t2;
#endif
if (p->p_traceflag & KTRFAC_TRC_EMUL) {
@ -282,9 +281,7 @@ ktraddentry(struct lwp *l, struct ktrace_entry *kte, int flags)
ktd->ktd_flags |= KTDF_WAIT;
ktd_wakeup(ktd);
#ifdef DEBUG
s = splclock();
t = mono_time;
splx(s);
getmicrouptime(&t1);
#endif
if (ltsleep(&ktd->ktd_flags, PWAIT, "ktrsync",
ktd_timeout * hz, &ktd->ktd_slock) != 0) {
@ -298,13 +295,12 @@ ktraddentry(struct lwp *l, struct ktrace_entry *kte, int flags)
break;
}
#ifdef DEBUG
s = splclock();
timersub(&mono_time, &t, &t);
splx(s);
if (t.tv_sec > 0)
getmicrouptime(&t2);
timersub(&t2, &t1, &t2);
if (t2.tv_sec > 0)
log(LOG_NOTICE,
"ktrace long wait: %ld.%06ld\n",
t.tv_sec, t.tv_usec);
t2.tv_sec, t2.tv_usec);
#endif
} while (p->p_tracep == ktd &&
(ktd->ktd_flags & (KTDF_WAIT | KTDF_DONE)) == KTDF_WAIT);

View File

@ -1,4 +1,4 @@
/* $NetBSD: kern_microtime.c,v 1.15 2005/12/11 12:24:29 christos Exp $ */
/* $NetBSD: kern_microtime.c,v 1.16 2006/06/07 22:33:40 kardel Exp $ */
/*-
* Copyright (c) 2001 The NetBSD Foundation, Inc.
@ -54,7 +54,7 @@
#include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
__KERNEL_RCSID(0, "$NetBSD: kern_microtime.c,v 1.15 2005/12/11 12:24:29 christos Exp $");
__KERNEL_RCSID(0, "$NetBSD: kern_microtime.c,v 1.16 2006/06/07 22:33:40 kardel Exp $");
#include "opt_multiprocessor.h"
@ -126,7 +126,7 @@ cc_microtime(struct timeval *tvp)
*/
/* XXXSMP: not atomic */
simple_lock(&microtime_slock);
t = time;
getmicrotime(&t);
}
/*

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,4 @@
/* $NetBSD: kern_sig.c,v 1.220 2006/05/14 21:15:11 elad Exp $ */
/* $NetBSD: kern_sig.c,v 1.221 2006/06/07 22:33:40 kardel Exp $ */
/*
* Copyright (c) 1982, 1986, 1989, 1991, 1993
@ -37,7 +37,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: kern_sig.c,v 1.220 2006/05/14 21:15:11 elad Exp $");
__KERNEL_RCSID(0, "$NetBSD: kern_sig.c,v 1.221 2006/06/07 22:33:40 kardel Exp $");
#include "opt_ktrace.h"
#include "opt_compat_sunos.h"
@ -2367,13 +2367,12 @@ __sigtimedwait1(struct lwp *l, void *v, register_t *retval,
} */ *uap = v;
sigset_t *waitset, twaitset;
struct proc *p = l->l_proc;
int error, signum, s;
int error, signum;
int timo = 0;
struct timeval tvstart;
struct timespec ts;
struct timespec ts, tsstart;
ksiginfo_t *ksi;
memset(&tvstart, 0, sizeof tvstart); /* XXX gcc */
memset(&tsstart, 0, sizeof tsstart); /* XXX gcc */
MALLOC(waitset, sigset_t *, sizeof(sigset_t), M_TEMP, M_WAITOK);
@ -2427,12 +2426,10 @@ __sigtimedwait1(struct lwp *l, void *v, register_t *retval,
return (EAGAIN);
/*
* Remember current mono_time, it would be used in
* Remember current uptime, it would be used in
* ECANCELED/ERESTART case.
*/
s = splclock();
tvstart = mono_time;
splx(s);
getnanouptime(&tsstart);
}
/*
@ -2479,26 +2476,22 @@ __sigtimedwait1(struct lwp *l, void *v, register_t *retval,
* or called again.
*/
if (timo && (error == ERESTART || error == ECANCELED)) {
struct timeval tvnow, tvtimo;
struct timespec tsnow;
int err;
s = splclock();
tvnow = mono_time;
splx(s);
TIMESPEC_TO_TIMEVAL(&tvtimo, &ts);
/* XXX double check the following change */
getnanouptime(&tsnow);
/* compute how much time has passed since start */
timersub(&tvnow, &tvstart, &tvnow);
timespecsub(&tsnow, &tsstart, &tsnow);
/* substract passed time from timeout */
timersub(&tvtimo, &tvnow, &tvtimo);
timespecsub(&ts, &tsnow, &ts);
if (tvtimo.tv_sec < 0) {
if (ts.tv_sec < 0) {
error = EAGAIN;
goto fail;
}
TIMEVAL_TO_TIMESPEC(&tvtimo, &ts);
/* XXX double check the previous change */
/* copy updated timeout to userland */
if ((err = (*put_timeout)(&ts, SCARG(uap, timeout),

View File

@ -1,25 +1,37 @@
/* $NetBSD: kern_tc.c,v 1.2 2006/06/07 22:33:40 kardel Exp $ */
/*-
* ----------------------------------------------------------------------------
* "THE BEER-WARE LICENSE" (Revision 42):
* <phk@FreeBSD.ORG> wrote this file. As long as you retain this notice you
* can do whatever you want with this stuff. If we meet some day, and you think
* this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp
* ----------------------------------------------------------------------------
* ---------------------------------------------------------------------------
*/
#include <sys/cdefs.h>
__FBSDID("$FreeBSD: src/sys/kern/kern_tc.c,v 1.166 2005/09/19 22:16:31 andre Exp $");
/* __FBSDID("$FreeBSD: src/sys/kern/kern_tc.c,v 1.166 2005/09/19 22:16:31 andre Exp $"); */
__KERNEL_RCSID(0, "$NetBSD: kern_tc.c,v 1.2 2006/06/07 22:33:40 kardel Exp $");
#include "opt_ntp.h"
#include <sys/param.h>
#ifdef __HAVE_TIMECOUNTER /* XXX */
#include <sys/kernel.h>
#include <sys/reboot.h> /* XXX just to get AB_VERBOSE */
#include <sys/sysctl.h>
#include <sys/syslog.h>
#include <sys/systm.h>
#include <sys/timepps.h>
#include <sys/timetc.h>
#include <sys/timex.h>
#include <sys/evcnt.h>
#include <sys/kauth.h>
/*
* maximum name length for TC names in sysctl interface
*/
#define MAX_TCNAMELEN 64
/*
* A large step happens on boot. This constant detects such steps.
@ -92,31 +104,170 @@ time_t time_uptime = 1;
static struct bintime boottimebin;
struct timeval boottime;
#ifdef __FreeBSD__
static int sysctl_kern_boottime(SYSCTL_HANDLER_ARGS);
SYSCTL_PROC(_kern, KERN_BOOTTIME, boottime, CTLTYPE_STRUCT|CTLFLAG_RD,
NULL, 0, sysctl_kern_boottime, "S,timeval", "System boottime");
SYSCTL_NODE(_kern, OID_AUTO, timecounter, CTLFLAG_RW, 0, "");
#endif /* __FreeBSD__ */
static int timestepwarnings;
#ifdef __FreeBSD__
SYSCTL_INT(_kern_timecounter, OID_AUTO, stepwarnings, CTLFLAG_RW,
&timestepwarnings, 0, "");
#endif /* __FreeBSD__ */
#define TC_STATS(foo) \
static u_int foo; \
SYSCTL_UINT(_kern_timecounter, OID_AUTO, foo, CTLFLAG_RD, &foo, 0, "");\
struct __hack
/*
* sysctl helper routine for kern.timercounter.current
*/
static int
sysctl_kern_timecounter_hardware(SYSCTLFN_ARGS)
{
struct sysctlnode node;
int error;
char newname[MAX_TCNAMELEN];
struct timecounter *newtc, *tc;
TC_STATS(nbinuptime); TC_STATS(nnanouptime); TC_STATS(nmicrouptime);
TC_STATS(nbintime); TC_STATS(nnanotime); TC_STATS(nmicrotime);
TC_STATS(ngetbinuptime); TC_STATS(ngetnanouptime); TC_STATS(ngetmicrouptime);
TC_STATS(ngetbintime); TC_STATS(ngetnanotime); TC_STATS(ngetmicrotime);
TC_STATS(nsetclock);
tc = timecounter;
strlcpy(newname, tc->tc_name, sizeof(newname));
node = *rnode;
node.sysctl_data = newname;
node.sysctl_size = sizeof(newname);
error = sysctl_lookup(SYSCTLFN_CALL(&node));
if (error ||
newp == NULL ||
strncmp(newname, tc->tc_name, sizeof(newname)) == 0)
return error;
if (l && (error = kauth_authorize_generic(l->l_proc->p_cred,
KAUTH_GENERIC_ISSUSER, &l->l_proc->p_acflag)) != 0)
return (error);
/* XXX locking */
for (newtc = timecounters; newtc != NULL; newtc = newtc->tc_next) {
if (strcmp(newname, newtc->tc_name) != 0)
continue;
/* Warm up new timecounter. */
(void)newtc->tc_get_timecount(newtc);
(void)newtc->tc_get_timecount(newtc);
timecounter = newtc;
/* XXX unlock */
return (0);
}
/* XXX unlock */
return (EINVAL);
}
static int
sysctl_kern_timecounter_choice(SYSCTLFN_ARGS)
{
char buf[48];
char *where = oldp;
const char *spc;
struct timecounter *tc;
size_t needed, left, slen;
int error;
if (newp != NULL)
return (EPERM);
if (namelen != 0)
return (EINVAL);
spc = "";
error = 0;
needed = 0;
left = *oldlenp;
/* XXX locking */
for (tc = timecounters; error == 0 && tc != NULL; tc = tc->tc_next) {
if (where == NULL) {
needed += sizeof(buf); /* be conservative */
} else {
slen = snprintf(buf, sizeof(buf), "%s%s(q=%d, f=%" PRId64
" Hz)", spc, tc->tc_name, tc->tc_quality,
tc->tc_frequency);
if (left < slen + 1)
break;
/* XXX use sysctl_copyout? (from sysctl_hw_disknames) */
error = copyout(buf, where, slen + 1);
spc = " ";
where += slen;
needed += slen;
left -= slen;
}
}
/* XXX unlock */
*oldlenp = needed;
return (error);
}
SYSCTL_SETUP(sysctl_timecounter_setup, "sysctl timecounter setup")
{
const struct sysctlnode *node;
sysctl_createv(clog, 0, NULL, &node,
CTLFLAG_PERMANENT,
CTLTYPE_NODE, "timecounter",
SYSCTL_DESCR("time counter information"),
NULL, 0, NULL, 0,
CTL_KERN, CTL_CREATE, CTL_EOL);
if (node != NULL) {
sysctl_createv(clog, 0, NULL, NULL,
CTLFLAG_PERMANENT,
CTLTYPE_STRING, "choice",
SYSCTL_DESCR("available counters"),
sysctl_kern_timecounter_choice, 0, NULL, 0,
CTL_KERN, node->sysctl_num, CTL_CREATE, CTL_EOL);
sysctl_createv(clog, 0, NULL, NULL,
CTLFLAG_PERMANENT|CTLFLAG_READWRITE,
CTLTYPE_STRING, "hardware",
SYSCTL_DESCR("currently active time counter"),
sysctl_kern_timecounter_hardware, 0, NULL, MAX_TCNAMELEN,
CTL_KERN, node->sysctl_num, CTL_CREATE, CTL_EOL);
sysctl_createv(clog, 0, NULL, NULL,
CTLFLAG_PERMANENT|CTLFLAG_READWRITE,
CTLTYPE_INT, "timestepwarnings",
SYSCTL_DESCR("log time steps"),
NULL, 0, &timestepwarnings, 0,
CTL_KERN, node->sysctl_num, CTL_CREATE, CTL_EOL);
}
}
#define TC_STATS(name) \
static struct evcnt n##name = \
EVCNT_INITIALIZER(EVCNT_TYPE_MISC, NULL, "timecounter", #name); \
EVCNT_ATTACH_STATIC(n##name)
TC_STATS(binuptime); TC_STATS(nanouptime); TC_STATS(microuptime);
TC_STATS(bintime); TC_STATS(nanotime); TC_STATS(microtime);
TC_STATS(getbinuptime); TC_STATS(getnanouptime); TC_STATS(getmicrouptime);
TC_STATS(getbintime); TC_STATS(getnanotime); TC_STATS(getmicrotime);
TC_STATS(setclock);
#undef TC_STATS
static void tc_windup(void);
#ifdef __FreeBSD__
static int
sysctl_kern_boottime(SYSCTL_HANDLER_ARGS)
{
@ -131,6 +282,8 @@ sysctl_kern_boottime(SYSCTL_HANDLER_ARGS)
#endif
return SYSCTL_OUT(req, &boottime, sizeof(boottime));
}
#endif /* __FreeBSD__ */
/*
* Return the difference between the timehands' counter value now and what
* was when we copied it to the timehands' offset_count.
@ -141,8 +294,8 @@ tc_delta(struct timehands *th)
struct timecounter *tc;
tc = th->th_counter;
return ((tc->tc_get_timecount(tc) - th->th_offset_count) &
tc->tc_counter_mask);
return ((tc->tc_get_timecount(tc) -
th->th_offset_count) & tc->tc_counter_mask);
}
/*
@ -157,7 +310,7 @@ binuptime(struct bintime *bt)
struct timehands *th;
u_int gen;
nbinuptime++;
nbinuptime.ev_count++;
do {
th = timehands;
gen = th->th_generation;
@ -171,7 +324,7 @@ nanouptime(struct timespec *tsp)
{
struct bintime bt;
nnanouptime++;
nnanouptime.ev_count++;
binuptime(&bt);
bintime2timespec(&bt, tsp);
}
@ -181,7 +334,7 @@ microuptime(struct timeval *tvp)
{
struct bintime bt;
nmicrouptime++;
nmicrouptime.ev_count++;
binuptime(&bt);
bintime2timeval(&bt, tvp);
}
@ -190,7 +343,7 @@ void
bintime(struct bintime *bt)
{
nbintime++;
nbintime.ev_count++;
binuptime(bt);
bintime_add(bt, &boottimebin);
}
@ -200,7 +353,7 @@ nanotime(struct timespec *tsp)
{
struct bintime bt;
nnanotime++;
nnanotime.ev_count++;
bintime(&bt);
bintime2timespec(&bt, tsp);
}
@ -210,7 +363,7 @@ microtime(struct timeval *tvp)
{
struct bintime bt;
nmicrotime++;
nmicrotime.ev_count++;
bintime(&bt);
bintime2timeval(&bt, tvp);
}
@ -221,7 +374,7 @@ getbinuptime(struct bintime *bt)
struct timehands *th;
u_int gen;
ngetbinuptime++;
ngetbinuptime.ev_count++;
do {
th = timehands;
gen = th->th_generation;
@ -235,7 +388,7 @@ getnanouptime(struct timespec *tsp)
struct timehands *th;
u_int gen;
ngetnanouptime++;
ngetnanouptime.ev_count++;
do {
th = timehands;
gen = th->th_generation;
@ -249,7 +402,7 @@ getmicrouptime(struct timeval *tvp)
struct timehands *th;
u_int gen;
ngetmicrouptime++;
ngetmicrouptime.ev_count++;
do {
th = timehands;
gen = th->th_generation;
@ -263,7 +416,7 @@ getbintime(struct bintime *bt)
struct timehands *th;
u_int gen;
ngetbintime++;
ngetbintime.ev_count++;
do {
th = timehands;
gen = th->th_generation;
@ -278,7 +431,7 @@ getnanotime(struct timespec *tsp)
struct timehands *th;
u_int gen;
ngetnanotime++;
ngetnanotime.ev_count++;
do {
th = timehands;
gen = th->th_generation;
@ -292,7 +445,7 @@ getmicrotime(struct timeval *tvp)
struct timehands *th;
u_int gen;
ngetmicrotime++;
ngetmicrotime.ev_count++;
do {
th = timehands;
gen = th->th_generation;
@ -315,16 +468,17 @@ tc_init(struct timecounter *tc)
if (u > hz && tc->tc_quality >= 0) {
tc->tc_quality = -2000;
if (bootverbose) {
printf("Timecounter \"%s\" frequency %ju Hz",
printf("timecounter: Timecounter \"%s\" frequency %ju Hz",
tc->tc_name, (uintmax_t)tc->tc_frequency);
printf(" -- Insufficient hz, needs at least %u\n", u);
}
} else if (tc->tc_quality >= 0 || bootverbose) {
printf("Timecounter \"%s\" frequency %ju Hz quality %d\n",
printf("timecounter: Timecounter \"%s\" frequency %ju Hz quality %d\n",
tc->tc_name, (uintmax_t)tc->tc_frequency,
tc->tc_quality);
}
/* XXX locking */
tc->tc_next = timecounters;
timecounters = tc;
/*
@ -363,7 +517,7 @@ tc_setclock(struct timespec *ts)
struct timespec ts2;
struct bintime bt, bt2;
nsetclock++;
nsetclock.ev_count++;
binuptime(&bt2);
timespec2bintime(ts, &bt);
bintime_sub(&bt, &bt2);
@ -440,6 +594,8 @@ tc_windup(void)
* has been read, so on really large steps, we call
* ntp_update_second only twice. We need to call it twice in
* case we missed a leap second.
* If NTP is not compiled in ntp_update_second still calculates
* the adjustment resulting from adjtime() calls.
*/
bt = th->th_offset;
bintime_add(&bt, &boottimebin);
@ -452,6 +608,7 @@ tc_windup(void)
if (bt.sec != t)
boottimebin.sec += bt.sec - t;
}
/* Update the UTC timestamps used by the get*() functions. */
/* XXX shouldn't do this here. Should force non-`get' versions. */
bintime2timeval(&bt, &th->th_microtime);
@ -461,6 +618,10 @@ tc_windup(void)
if (th->th_counter != timecounter) {
th->th_counter = timecounter;
th->th_offset_count = ncount;
printf("timecounter: selected timecounter \"%s\" frequency %ju Hz quality %d\n",
timecounter->tc_name, (uintmax_t)timecounter->tc_frequency,
timecounter->tc_quality);
}
/*-
@ -505,6 +666,7 @@ tc_windup(void)
timehands = th;
}
#ifdef __FreeBSD__
/* Report or change the active timecounter hardware. */
static int
sysctl_kern_timecounter_hardware(SYSCTL_HANDLER_ARGS)
@ -520,6 +682,7 @@ sysctl_kern_timecounter_hardware(SYSCTL_HANDLER_ARGS)
if (error != 0 || req->newptr == NULL ||
strcmp(newname, tc->tc_name) == 0)
return (error);
for (newtc = timecounters; newtc != NULL; newtc = newtc->tc_next) {
if (strcmp(newname, newtc->tc_name) != 0)
continue;
@ -559,6 +722,7 @@ sysctl_kern_timecounter_choice(SYSCTL_HANDLER_ARGS)
SYSCTL_PROC(_kern_timecounter, OID_AUTO, choice, CTLTYPE_STRING | CTLFLAG_RD,
0, 0, sysctl_kern_timecounter_choice, "A", "");
#endif /* __FreeBSD__ */
/*
* RFC 2783 PPS-API implementation.
@ -568,12 +732,12 @@ int
pps_ioctl(u_long cmd, caddr_t data, struct pps_state *pps)
{
pps_params_t *app;
struct pps_fetch_args *fapi;
pps_info_t *pipi;
#ifdef PPS_SYNC
struct pps_kcbind_args *kapi;
int *epi;
#endif
KASSERT(pps != NULL, ("NULL pps pointer in pps_ioctl"));
KASSERT(pps != NULL); /* XXX ("NULL pps pointer in pps_ioctl") */
switch (cmd) {
case PPS_IOC_CREATE:
return (0);
@ -594,31 +758,23 @@ pps_ioctl(u_long cmd, caddr_t data, struct pps_state *pps)
*(int*)data = pps->ppscap;
return (0);
case PPS_IOC_FETCH:
fapi = (struct pps_fetch_args *)data;
if (fapi->tsformat && fapi->tsformat != PPS_TSFMT_TSPEC)
return (EINVAL);
if (fapi->timeout.tv_sec || fapi->timeout.tv_nsec)
return (EOPNOTSUPP);
pipi = (pps_info_t *)data;
pps->ppsinfo.current_mode = pps->ppsparam.mode;
fapi->pps_info_buf = pps->ppsinfo;
*pipi = pps->ppsinfo;
return (0);
case PPS_IOC_KCBIND:
#ifdef PPS_SYNC
kapi = (struct pps_kcbind_args *)data;
epi = (int *)data;
/* XXX Only root should be able to do this */
if (kapi->tsformat && kapi->tsformat != PPS_TSFMT_TSPEC)
if (*epi & ~pps->ppscap)
return (EINVAL);
if (kapi->kernel_consumer != PPS_KC_HARDPPS)
return (EINVAL);
if (kapi->edge & ~pps->ppscap)
return (EINVAL);
pps->kcmode = kapi->edge;
pps->kcmode = *epi;
return (0);
#else
return (EOPNOTSUPP);
#endif
default:
return (ENOIOCTL);
return (EPASSTHROUGH);
}
}
@ -637,7 +793,7 @@ pps_capture(struct pps_state *pps)
{
struct timehands *th;
KASSERT(pps != NULL, ("NULL pps pointer in pps_capture"));
KASSERT(pps != NULL); /* XXX ("NULL pps pointer in pps_capture") */
th = timehands;
pps->capgen = th->th_generation;
pps->capth = th;
@ -655,7 +811,7 @@ pps_event(struct pps_state *pps, int event)
int foff, fhard;
pps_seq_t *pseq;
KASSERT(pps != NULL, ("NULL pps pointer in pps_event"));
KASSERT(pps != NULL); /* XXX ("NULL pps pointer in pps_event") */
/* If the timecounter was wound up underneath us, bail out. */
if (pps->capgen == 0 || pps->capgen != pps->capth->th_generation)
return;
@ -705,7 +861,7 @@ pps_event(struct pps_state *pps, int event)
*tsp = ts;
if (foff) {
timespecadd(tsp, osp);
timespecadd(tsp, osp, tsp);
if (tsp->tv_nsec < 0) {
tsp->tv_nsec += 1000000000;
tsp->tv_sec -= 1;
@ -743,7 +899,9 @@ pps_event(struct pps_state *pps, int event)
*/
static int tc_tick;
#ifdef __FreeBSD__
SYSCTL_INT(_kern_timecounter, OID_AUTO, tick, CTLFLAG_RD, &tc_tick, 0, "");
#endif /* __FreeBSD__ */
void
tc_ticktock(void)
@ -756,8 +914,8 @@ tc_ticktock(void)
tc_windup();
}
static void
inittimecounter(void *dummy)
void
inittimecounter(void)
{
u_int p;
@ -774,11 +932,14 @@ inittimecounter(void *dummy)
else
tc_tick = 1;
p = (tc_tick * 1000000) / hz;
printf("Timecounters tick every %d.%03u msec\n", p / 1000, p % 1000);
printf("timecounter: Timecounters tick every %d.%03u msec\n", p / 1000, p % 1000);
/* warm up new timecounter (again) and get rolling. */
(void)timecounter->tc_get_timecount(timecounter);
(void)timecounter->tc_get_timecount(timecounter);
}
#ifdef __FreeBSD__
SYSINIT(timecounter, SI_SUB_CLOCKS, SI_ORDER_SECOND, inittimecounter, NULL)
#endif /* __FreeBSD__ */
#endif /* __HAVE_TIMECOUNTER */

View File

@ -1,4 +1,4 @@
/* $NetBSD: kern_time.c,v 1.100 2006/05/18 10:09:12 yamt Exp $ */
/* $NetBSD: kern_time.c,v 1.101 2006/06/07 22:33:40 kardel Exp $ */
/*-
* Copyright (c) 2000, 2004, 2005 The NetBSD Foundation, Inc.
@ -68,7 +68,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: kern_time.c,v 1.100 2006/05/18 10:09:12 yamt Exp $");
__KERNEL_RCSID(0, "$NetBSD: kern_time.c,v 1.101 2006/06/07 22:33:40 kardel Exp $");
#include "fs_nfs.h"
#include "opt_nfs.h"
@ -84,7 +84,11 @@ __KERNEL_RCSID(0, "$NetBSD: kern_time.c,v 1.100 2006/05/18 10:09:12 yamt Exp $")
#include <sys/vnode.h>
#include <sys/signalvar.h>
#include <sys/syslog.h>
#ifdef __HAVE_TIMECOUNTER
#include <sys/timetc.h>
#else /* !__HAVE_TIMECOUNTER */
#include <sys/timevar.h>
#endif /* !__HAVE_TIMECOUNTER */
#include <sys/kauth.h>
#include <sys/mount.h>
@ -107,6 +111,9 @@ POOL_INIT(ptimers_pool, sizeof(struct ptimers), 0, 0, 0, "ptimerspl",
&pool_allocator_nointr);
static void timerupcall(struct lwp *, void *);
#ifdef __HAVE_TIMECOUNTER
static int itimespecfix(struct timespec *); /* XXX move itimerfix to timespecs */
#endif /* __HAVE_TIMECOUNTER */
/* Time of day and interval timer support.
*
@ -122,6 +129,10 @@ int
settime(struct proc *p, struct timespec *ts)
{
struct timeval delta, tv;
#ifdef __HAVE_TIMECOUNTER
struct timeval now;
struct timespec ts1;
#endif /* !__HAVE_TIMECOUNTER */
struct cpu_info *ci;
int s;
@ -150,7 +161,12 @@ settime(struct proc *p, struct timespec *ts)
/* WHAT DO WE DO ABOUT PENDING REAL-TIME TIMEOUTS??? */
s = splclock();
#ifdef __HAVE_TIMECOUNTER
microtime(&now);
timersub(&tv, &now, &delta);
#else /* !__HAVE_TIMECOUNTER */
timersub(&tv, &time, &delta);
#endif /* !__HAVE_TIMECOUNTER */
if ((delta.tv_sec < 0 || delta.tv_usec < 0) && securelevel > 1) {
splx(s);
return (EPERM);
@ -161,9 +177,16 @@ settime(struct proc *p, struct timespec *ts)
return (EPERM);
}
#endif
#ifdef __HAVE_TIMECOUNTER
ts1.tv_sec = tv.tv_sec;
ts1.tv_nsec = tv.tv_usec * 1000;
tc_setclock(&ts1);
(void) spllowersoftclock();
#else /* !__HAVE_TIMECOUNTER */
time = tv;
(void) spllowersoftclock();
timeradd(&boottime, &delta, &boottime);
#endif /* !__HAVE_TIMECOUNTER */
/*
* XXXSMP
* This is wrong. We should traverse a list of all
@ -173,9 +196,9 @@ settime(struct proc *p, struct timespec *ts)
ci = curcpu();
timeradd(&ci->ci_schedstate.spc_runtime, &delta,
&ci->ci_schedstate.spc_runtime);
# if (defined(NFS) && !defined (NFS_V2_ONLY)) || defined(NFSSERVER)
nqnfs_lease_updatetime(delta.tv_sec);
# endif
#if (defined(NFS) && !defined (NFS_V2_ONLY)) || defined(NFSSERVER)
nqnfs_lease_updatetime(delta.tv_sec);
#endif
splx(s);
resettodr();
return (0);
@ -190,9 +213,7 @@ sys_clock_gettime(struct lwp *l, void *v, register_t *retval)
syscallarg(struct timespec *) tp;
} */ *uap = v;
clockid_t clock_id;
struct timeval atv;
struct timespec ats;
int s;
clock_id = SCARG(uap, clock_id);
switch (clock_id) {
@ -200,11 +221,18 @@ sys_clock_gettime(struct lwp *l, void *v, register_t *retval)
nanotime(&ats);
break;
case CLOCK_MONOTONIC:
#ifdef __HAVE_TIMECOUNTER
nanouptime(&ats);
#else /* !__HAVE_TIMECOUNTER */
{
int s;
/* XXX "hz" granularity */
s = splclock();
atv = mono_time;
TIMEVAL_TO_TIMESPEC(&mono_time,&ats);
splx(s);
TIMEVAL_TO_TIMESPEC(&atv,&ats);
}
#endif /* !__HAVE_TIMECOUNTER */
break;
default:
return (EINVAL);
@ -287,6 +315,52 @@ sys_clock_getres(struct lwp *l, void *v, register_t *retval)
int
sys_nanosleep(struct lwp *l, void *v, register_t *retval)
{
#ifdef __HAVE_TIMECOUNTER
static int nanowait;
struct sys_nanosleep_args/* {
syscallarg(struct timespec *) rqtp;
syscallarg(struct timespec *) rmtp;
} */ *uap = v;
struct timespec rmt, rqt;
int error, timo;
error = copyin(SCARG(uap, rqtp), &rqt, sizeof(struct timespec));
if (error)
return (error);
if (itimespecfix(&rqt))
return (EINVAL);
timo = tstohz(&rqt);
/*
* Avoid inadvertantly sleeping forever
*/
if (timo == 0)
timo = 1;
error = tsleep(&nanowait, PWAIT | PCATCH, "nanosleep", timo);
if (error == ERESTART)
error = EINTR;
if (error == EWOULDBLOCK)
error = 0;
if (SCARG(uap, rmtp)) {
int error1;
getnanotime(&rmt);
timespecsub(&rqt, &rmt, &rmt);
if (rmt.tv_sec < 0)
timespecclear(&rmt);
error1 = copyout((caddr_t)&rmt, (caddr_t)SCARG(uap,rmtp),
sizeof(rmt));
if (error1)
return (error1);
}
return error;
#else /* !__HAVE_TIMECOUNTER */
static int nanowait;
struct sys_nanosleep_args/* {
syscallarg(struct timespec *) rqtp;
@ -340,6 +414,7 @@ sys_nanosleep(struct lwp *l, void *v, register_t *retval)
}
return error;
#endif /* !__HAVE_TIMECOUNTER */
}
/* ARGSUSED */
@ -416,9 +491,12 @@ settimeofday1(const struct timeval *utv, const struct timezone *utzp,
return settime(p, &ts);
}
#ifndef __HAVE_TIMECOUNTER
int tickdelta; /* current clock skew, us. per tick */
long timedelta; /* unapplied time correction, us. */
long bigadj = 1000000; /* use 10x skew above bigadj us. */
#endif
int time_adjusted; /* set if an adjustment is made */
/* ARGSUSED */
@ -443,10 +521,41 @@ int
adjtime1(const struct timeval *delta, struct timeval *olddelta, struct proc *p)
{
struct timeval atv;
long ndelta, ntickdelta, odelta;
int error;
int s;
int error = 0;
#ifdef __HAVE_TIMECOUNTER
extern int64_t time_adjtime; /* in kern_ntptime.c */
#else /* !__HAVE_TIMECOUNTER */
long ndelta, ntickdelta, odelta;
int s;
#endif /* !__HAVE_TIMECOUNTER */
#ifdef __HAVE_TIMECOUNTER
if (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--;
}
error = copyout(&atv, olddelta, sizeof(struct timeval));
if (error)
return (error);
}
if (delta) {
error = copyin(delta, &atv, sizeof(struct timeval));
if (error)
return (error);
time_adjtime = (int64_t)atv.tv_sec * 1000000 +
atv.tv_usec;
if (time_adjtime)
/* We need to save the system time during shutdown */
time_adjusted |= 1;
}
#else /* !__HAVE_TIMECOUNTER */
error = copyin(delta, &atv, sizeof(struct timeval));
if (error)
return (error);
@ -487,6 +596,8 @@ adjtime1(const struct timeval *delta, struct timeval *olddelta, struct proc *p)
atv.tv_usec = odelta % 1000000;
error = copyout(&atv, olddelta, sizeof(struct timeval));
}
#endif /* __HAVE_TIMECOUNTER */
return error;
}
@ -698,6 +809,9 @@ timer_settime(struct ptimer *pt)
void
timer_gettime(struct ptimer *pt, struct itimerval *aitv)
{
#ifdef __HAVE_TIMECOUNTER
struct timeval now;
#endif
struct ptimer *ptn;
*aitv = pt->pt_time;
@ -710,11 +824,20 @@ timer_gettime(struct ptimer *pt, struct itimerval *aitv)
* off.
*/
if (timerisset(&aitv->it_value)) {
#ifdef __HAVE_TIMECOUNTER
getmicrotime(&now);
if (timercmp(&aitv->it_value, &now, <))
timerclear(&aitv->it_value);
else
timersub(&aitv->it_value, &now,
&aitv->it_value);
#else /* !__HAVE_TIMECOUNTER */
if (timercmp(&aitv->it_value, &time, <))
timerclear(&aitv->it_value);
else
timersub(&aitv->it_value, &time,
&aitv->it_value);
#endif /* !__HAVE_TIMECOUNTER */
}
} else if (pt->pt_active) {
if (pt->pt_type == CLOCK_VIRTUAL)
@ -765,9 +888,12 @@ int
dotimer_settime(int timerid, struct itimerspec *value,
struct itimerspec *ovalue, int flags, struct proc *p)
{
int s;
#ifdef __HAVE_TIMECOUNTER
struct timeval now;
#endif
struct itimerval val, oval;
struct ptimer *pt;
int s;
if ((p->p_timers == NULL) ||
(timerid < 2) || (timerid >= TIMER_MAX) ||
@ -792,13 +918,27 @@ dotimer_settime(int timerid, struct itimerspec *value,
*/
if (timerisset(&pt->pt_time.it_value)) {
if (pt->pt_type == CLOCK_REALTIME) {
#ifdef __HAVE_TIMECOUNTER
if ((flags & TIMER_ABSTIME) == 0) {
getmicrotime(&now);
timeradd(&pt->pt_time.it_value, &now,
&pt->pt_time.it_value);
}
#else /* !__HAVE_TIMECOUNTER */
if ((flags & TIMER_ABSTIME) == 0)
timeradd(&pt->pt_time.it_value, &time,
&pt->pt_time.it_value);
#endif /* !__HAVE_TIMECOUNTER */
} else {
if ((flags & TIMER_ABSTIME) != 0) {
#ifdef __HAVE_TIMECOUNTER
getmicrotime(&now);
timersub(&pt->pt_time.it_value, &now,
&pt->pt_time.it_value);
#else /* !__HAVE_TIMECOUNTER */
timersub(&pt->pt_time.it_value, &time,
&pt->pt_time.it_value);
#endif /* !__HAVE_TIMECOUNTER */
if (!timerisset(&pt->pt_time.it_value) ||
pt->pt_time.it_value.tv_sec < 0) {
pt->pt_time.it_value.tv_sec = 0;
@ -927,7 +1067,6 @@ timerupcall(struct lwp *l, void *arg)
KERNEL_PROC_UNLOCK(l);
}
/*
* Real interval timer expired:
* send process whose timer expired an alarm signal.
@ -939,6 +1078,9 @@ timerupcall(struct lwp *l, void *arg)
void
realtimerexpire(void *arg)
{
#ifdef __HAVE_TIMECOUNTER
struct timeval now;
#endif
struct ptimer *pt;
int s;
@ -950,6 +1092,26 @@ realtimerexpire(void *arg)
timerclear(&pt->pt_time.it_value);
return;
}
#ifdef __HAVE_TIMECOUNTER
for (;;) {
s = splclock(); /* XXX need spl now? */
timeradd(&pt->pt_time.it_value,
&pt->pt_time.it_interval, &pt->pt_time.it_value);
getmicrotime(&now);
if (timercmp(&pt->pt_time.it_value, &now, >)) {
/*
* Don't need to check hzto() return value, here.
* callout_reset() does it for us.
*/
callout_reset(&pt->pt_ch, hzto(&pt->pt_time.it_value),
realtimerexpire, pt);
splx(s);
return;
}
splx(s);
pt->pt_overruns++;
}
#else /* !__HAVE_TIMECOUNTER */
for (;;) {
s = splclock();
timeradd(&pt->pt_time.it_value,
@ -967,6 +1129,7 @@ realtimerexpire(void *arg)
splx(s);
pt->pt_overruns++;
}
#endif /* !__HAVE_TIMECOUNTER */
}
/* BSD routine to get the value of an interval timer. */
@ -1046,6 +1209,9 @@ sys_setitimer(struct lwp *l, void *v, register_t *retval)
int
dosetitimer(struct proc *p, int which, struct itimerval *itvp)
{
#ifdef __HAVE_TIMECOUNTER
struct timeval now;
#endif
struct ptimer *pt;
int s;
@ -1093,7 +1259,13 @@ dosetitimer(struct proc *p, int which, struct itimerval *itvp)
s = splclock();
if ((which == ITIMER_REAL) && timerisset(&pt->pt_time.it_value)) {
/* Convert to absolute time */
#ifdef __HAVE_TIMECOUNTER
/* XXX need to wrap in splclock for timecounters case? */
getmicrotime(&now);
timeradd(&pt->pt_time.it_value, &now, &pt->pt_time.it_value);
#else /* !__HAVE_TIMECOUNTER */
timeradd(&pt->pt_time.it_value, &time, &pt->pt_time.it_value);
#endif /* !__HAVE_TIMECOUNTER */
}
timer_settime(pt);
splx(s);
@ -1199,6 +1371,19 @@ itimerfix(struct timeval *tv)
return (0);
}
#ifdef __HAVE_TIMECOUNTER
int
itimespecfix(struct timespec *ts)
{
if (ts->tv_sec < 0 || ts->tv_nsec < 0 || ts->tv_nsec >= 1000000000)
return (EINVAL);
if (ts->tv_sec == 0 && ts->tv_nsec != 0 && ts->tv_nsec < tick * 1000)
ts->tv_nsec = tick * 1000;
return (0);
}
#endif /* __HAVE_TIMECOUNTER */
/*
* Decrement an interval timer by a specified number
* of microseconds, which must be less than a second,
@ -1323,12 +1508,18 @@ int
ratecheck(struct timeval *lasttime, const struct timeval *mininterval)
{
struct timeval tv, delta;
int s, rv = 0;
int rv = 0;
#ifndef __HAVE_TIMECOUNTER
int s;
#endif
#ifdef __HAVE_TIMECOUNTER
getmicrouptime(&tv);
#else /* !__HAVE_TIMECOUNTER */
s = splclock();
tv = mono_time;
splx(s);
#endif /* !__HAVE_TIMECOUNTER */
timersub(&tv, lasttime, &delta);
/*
@ -1351,12 +1542,18 @@ int
ppsratecheck(struct timeval *lasttime, int *curpps, int maxpps)
{
struct timeval tv, delta;
int s, rv;
int rv;
#ifndef __HAVE_TIMECOUNTER
int s;
#endif
#ifdef __HAVE_TIMECOUNTER
getmicrouptime(&tv);
#else /* !__HAVE_TIMECOUNTER */
s = splclock();
tv = mono_time;
splx(s);
#endif /* !__HAVE_TIMECOUNTER */
timersub(&tv, lasttime, &delta);
/*

View File

@ -1,4 +1,4 @@
/* $NetBSD: subr_disk.c,v 1.78 2006/04/21 13:53:30 yamt Exp $ */
/* $NetBSD: subr_disk.c,v 1.79 2006/06/07 22:33:40 kardel Exp $ */
/*-
* Copyright (c) 1996, 1997, 1999, 2000 The NetBSD Foundation, Inc.
@ -74,7 +74,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: subr_disk.c,v 1.78 2006/04/21 13:53:30 yamt Exp $");
__KERNEL_RCSID(0, "$NetBSD: subr_disk.c,v 1.79 2006/06/07 22:33:40 kardel Exp $");
#include <sys/param.h>
#include <sys/kernel.h>
@ -194,6 +194,7 @@ disk_init0(struct disk *diskp)
static void
disk_attach0(struct disk *diskp)
{
/*
* Allocate and initialize the disklabel structures. Note that
* it's not safe to sleep here, since we're probably going to be

View File

@ -1,4 +1,4 @@
/* $NetBSD: subr_iostat.c,v 1.9 2006/04/21 13:58:10 yamt Exp $ */
/* $NetBSD: subr_iostat.c,v 1.10 2006/06/07 22:33:40 kardel Exp $ */
/* NetBSD: subr_disk.c,v 1.69 2005/05/29 22:24:15 christos Exp */
/*-
@ -75,7 +75,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: subr_iostat.c,v 1.9 2006/04/21 13:58:10 yamt Exp $");
__KERNEL_RCSID(0, "$NetBSD: subr_iostat.c,v 1.10 2006/06/07 22:33:40 kardel Exp $");
#include "opt_compat_netbsd.h"
@ -132,7 +132,6 @@ iostat_find(const char *name)
struct io_stats *
iostat_alloc(int32_t type)
{
int s;
struct io_stats *stats;
stats = malloc(sizeof(struct io_stats), M_DEVBUF, M_WAITOK|M_ZERO);
@ -144,9 +143,7 @@ iostat_alloc(int32_t type)
/*
* Set the attached timestamp.
*/
s = splclock();
stats->io_attachtime = mono_time;
splx(s);
getmicrouptime(&stats->io_attachtime);
/*
* Link into the drivelist.
@ -185,17 +182,9 @@ iostat_free(struct io_stats *stats)
void
iostat_busy(struct io_stats *stats)
{
int s;
/*
* XXX We'd like to use something as accurate as microtime(),
* but that doesn't depend on the system TOD clock.
*/
if (stats->io_busy++ == 0) {
s = splclock();
stats->io_timestamp = mono_time;
splx(s);
}
if (stats->io_busy++ == 0)
getmicrouptime(&stats->io_timestamp);
}
/*
@ -205,7 +194,6 @@ iostat_busy(struct io_stats *stats)
void
iostat_unbusy(struct io_stats *stats, long bcount, int read)
{
int s;
struct timeval dv_time, diff_time;
if (stats->io_busy-- == 0) {
@ -213,9 +201,7 @@ iostat_unbusy(struct io_stats *stats, long bcount, int read)
panic("iostat_unbusy");
}
s = splclock();
dv_time = mono_time;
splx(s);
getmicrouptime(&dv_time);
timersub(&dv_time, &stats->io_timestamp, &diff_time);
timeradd(&stats->io_time, &diff_time, &stats->io_time);

View File

@ -1,4 +1,4 @@
/* $NetBSD: subr_pool.c,v 1.117 2006/05/25 14:27:28 yamt Exp $ */
/* $NetBSD: subr_pool.c,v 1.118 2006/06/07 22:33:40 kardel Exp $ */
/*-
* Copyright (c) 1997, 1999, 2000 The NetBSD Foundation, Inc.
@ -38,7 +38,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: subr_pool.c,v 1.117 2006/05/25 14:27:28 yamt Exp $");
__KERNEL_RCSID(0, "$NetBSD: subr_pool.c,v 1.118 2006/06/07 22:33:40 kardel Exp $");
#include "opt_pool.h"
#include "opt_poollog.h"
@ -1122,7 +1122,6 @@ pool_do_put(struct pool *pp, void *v, struct pool_pagelist *pq)
struct pool_item *pi = v;
struct pool_item_header *ph;
caddr_t page;
int s;
LOCK_ASSERT(simple_lock_held(&pp->pr_slock));
SCHED_ASSERT_UNLOCKED();
@ -1217,9 +1216,7 @@ pool_do_put(struct pool *pp, void *v, struct pool_pagelist *pq)
* be reclaimed by the pagedaemon. This minimizes
* ping-pong'ing for memory.
*/
s = splclock();
ph->ph_time = mono_time;
splx(s);
getmicrotime(&ph->ph_time);
}
pool_update_curpage(pp);
}
@ -1355,7 +1352,6 @@ pool_prime_page(struct pool *pp, caddr_t storage, struct pool_item_header *ph)
unsigned int align = pp->pr_align;
unsigned int ioff = pp->pr_itemoffset;
int n;
int s;
LOCK_ASSERT(simple_lock_held(&pp->pr_slock));
@ -1371,9 +1367,7 @@ pool_prime_page(struct pool *pp, caddr_t storage, struct pool_item_header *ph)
LIST_INIT(&ph->ph_itemlist);
ph->ph_page = storage;
ph->ph_nmissing = 0;
s = splclock();
ph->ph_time = mono_time;
splx(s);
getmicrotime(&ph->ph_time);
if ((pp->pr_roflags & PR_PHINPAGE) == 0)
SPLAY_INSERT(phtree, &pp->pr_phtree, ph);
@ -1539,7 +1533,6 @@ pool_reclaim(struct pool *pp)
struct pool_pagelist pq;
struct pool_cache_grouplist pcgl;
struct timeval curtime, diff;
int s;
if (pp->pr_drain_hook != NULL) {
/*
@ -1561,9 +1554,7 @@ pool_reclaim(struct pool *pp)
LIST_FOREACH(pc, &pp->pr_cachelist, pc_poollist)
pool_cache_reclaim(pc, &pq, &pcgl);
s = splclock();
curtime = mono_time;
splx(s);
getmicrotime(&curtime);
for (ph = LIST_FIRST(&pp->pr_emptypages); ph != NULL; ph = phnext) {
phnext = LIST_NEXT(ph, ph_pagelist);

View File

@ -1,4 +1,4 @@
/* $NetBSD: sys_generic.c,v 1.85 2006/03/01 12:38:21 yamt Exp $ */
/* $NetBSD: sys_generic.c,v 1.86 2006/06/07 22:33:40 kardel Exp $ */
/*
* Copyright (c) 1982, 1986, 1989, 1993
@ -37,7 +37,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: sys_generic.c,v 1.85 2006/03/01 12:38:21 yamt Exp $");
__KERNEL_RCSID(0, "$NetBSD: sys_generic.c,v 1.86 2006/06/07 22:33:40 kardel Exp $");
#include "opt_ktrace.h"
@ -746,10 +746,10 @@ int
selcommon(struct lwp *l, register_t *retval, int nd, fd_set *u_in,
fd_set *u_ou, fd_set *u_ex, struct timeval *tv, sigset_t *mask)
{
struct proc * const p = l->l_proc;
caddr_t bits;
char smallbits[howmany(FD_SETSIZE, NFDBITS) *
sizeof(fd_mask) * 6];
struct proc * const p = l->l_proc;
caddr_t bits;
int s, ncoll, error, timo;
size_t ni;
sigset_t oldmask;
@ -780,14 +780,9 @@ selcommon(struct lwp *l, register_t *retval, int nd, fd_set *u_in,
#undef getbits
timo = 0;
if (tv) {
if (itimerfix(tv)) {
error = EINVAL;
goto done;
}
s = splclock();
timeradd(tv, &time, tv);
splx(s);
if (tv && itimerfix(tv)) {
error = EINVAL;
goto done;
}
if (mask)
(void)sigprocmask1(p, SIG_SETMASK, mask, &oldmask);
@ -803,7 +798,7 @@ selcommon(struct lwp *l, register_t *retval, int nd, fd_set *u_in,
/*
* We have to recalculate the timeout on every retry.
*/
timo = hzto(tv);
timo = tvtohz(tv);
if (timo <= 0)
goto done;
}
@ -946,9 +941,9 @@ pollcommon(struct lwp *l, register_t *retval,
struct pollfd *u_fds, u_int nfds,
struct timeval *tv, sigset_t *mask)
{
char smallbits[32 * sizeof(struct pollfd)];
struct proc * const p = l->l_proc;
caddr_t bits;
char smallbits[32 * sizeof(struct pollfd)];
sigset_t oldmask;
int s, ncoll, error, timo;
size_t ni;
@ -968,14 +963,9 @@ pollcommon(struct lwp *l, register_t *retval,
goto done;
timo = 0;
if (tv) {
if (itimerfix(tv)) {
error = EINVAL;
goto done;
}
s = splclock();
timeradd(tv, &time, tv);
splx(s);
if (tv && itimerfix(tv)) {
error = EINVAL;
goto done;
}
if (mask != NULL)
(void)sigprocmask1(p, SIG_SETMASK, mask, &oldmask);
@ -990,7 +980,7 @@ pollcommon(struct lwp *l, register_t *retval,
/*
* We have to recalculate the timeout on every retry.
*/
timo = hzto(tv);
timo = tvtohz(tv);
if (timo <= 0)
goto done;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: sys_pipe.c,v 1.72 2006/05/14 21:15:11 elad Exp $ */
/* $NetBSD: sys_pipe.c,v 1.73 2006/06/07 22:33:41 kardel Exp $ */
/*-
* Copyright (c) 2003 The NetBSD Foundation, Inc.
@ -83,7 +83,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: sys_pipe.c,v 1.72 2006/05/14 21:15:11 elad Exp $");
__KERNEL_RCSID(0, "$NetBSD: sys_pipe.c,v 1.73 2006/06/07 22:33:41 kardel Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -113,14 +113,6 @@ __KERNEL_RCSID(0, "$NetBSD: sys_pipe.c,v 1.72 2006/05/14 21:15:11 elad Exp $");
#include <sys/pipe.h>
/*
* Avoid microtime(9), it's slow. We don't guard the read from time(9)
* with splclock(9) since we don't actually need to be THAT sure the access
* is atomic.
*/
#define PIPE_TIMESTAMP(tvp) (*(tvp) = time)
/*
* Use this define if you want to disable *fancy* VM things. Expect an
* approx 30% decrease in transfer rate.
@ -314,7 +306,7 @@ pipe_create(struct pipe **pipep, int allockva)
memset(pipe, 0, sizeof(struct pipe));
pipe->pipe_state = PIPE_SIGNALR;
PIPE_TIMESTAMP(&pipe->pipe_ctime);
getmicrotime(&pipe->pipe_ctime);
pipe->pipe_atime = pipe->pipe_ctime;
pipe->pipe_mtime = pipe->pipe_ctime;
simple_lock_init(&pipe->pipe_slock);
@ -556,7 +548,7 @@ again:
}
if (error == 0)
PIPE_TIMESTAMP(&rpipe->pipe_atime);
getmicrotime(&rpipe->pipe_atime);
PIPE_LOCK(rpipe);
pipeunlock(rpipe);
@ -1043,7 +1035,7 @@ retry:
error = 0;
if (error == 0)
PIPE_TIMESTAMP(&wpipe->pipe_mtime);
getmicrotime(&wpipe->pipe_mtime);
/*
* We have something to offer, wake up select/poll.

View File

@ -1,4 +1,4 @@
/* $NetBSD: sysv_msg.c,v 1.42 2006/05/14 21:15:11 elad Exp $ */
/* $NetBSD: sysv_msg.c,v 1.43 2006/06/07 22:33:41 kardel Exp $ */
/*-
* Copyright (c) 1999 The NetBSD Foundation, Inc.
@ -57,7 +57,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: sysv_msg.c,v 1.42 2006/05/14 21:15:11 elad Exp $");
__KERNEL_RCSID(0, "$NetBSD: sysv_msg.c,v 1.43 2006/06/07 22:33:41 kardel Exp $");
#define SYSVMSG
@ -287,7 +287,7 @@ msgctl1(struct proc *p, int msqid, int cmd, struct msqid_ds *msqbuf)
msqptr->msg_perm.mode = (msqptr->msg_perm.mode & ~0777) |
(msqbuf->msg_perm.mode & 0777);
msqptr->msg_qbytes = msqbuf->msg_qbytes;
msqptr->msg_ctime = time.tv_sec;
msqptr->msg_ctime = time_second;
break;
case IPC_STAT:
@ -381,7 +381,7 @@ sys_msgget(struct lwp *l, void *v, register_t *retval)
msqptr->msg_lrpid = 0;
msqptr->msg_stime = 0;
msqptr->msg_rtime = 0;
msqptr->msg_ctime = time.tv_sec;
msqptr->msg_ctime = time_second;
} else {
MSG_PRINTF(("didn't find it and wasn't asked to create it\n"));
return (ENOENT);
@ -664,7 +664,7 @@ msgsnd1(struct proc *p, int msqidr, const char *user_msgp, size_t msgsz,
msqptr->_msg_cbytes += msghdr->msg_ts;
msqptr->msg_qnum++;
msqptr->msg_lspid = p->p_pid;
msqptr->msg_stime = time.tv_sec;
msqptr->msg_stime = time_second;
wakeup(msqptr);
return (0);
@ -866,7 +866,7 @@ msgrcv1(struct proc *p, int msqidr, char *user_msgp, size_t msgsz, long msgtyp,
msqptr->_msg_cbytes -= msghdr->msg_ts;
msqptr->msg_qnum--;
msqptr->msg_lrpid = p->p_pid;
msqptr->msg_rtime = time.tv_sec;
msqptr->msg_rtime = time_second;
/*
* Make msgsz the actual amount that we'll be returning.

View File

@ -1,4 +1,4 @@
/* $NetBSD: sysv_sem.c,v 1.61 2006/05/14 21:15:11 elad Exp $ */
/* $NetBSD: sysv_sem.c,v 1.62 2006/06/07 22:33:41 kardel Exp $ */
/*-
* Copyright (c) 1999 The NetBSD Foundation, Inc.
@ -46,7 +46,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: sysv_sem.c,v 1.61 2006/05/14 21:15:11 elad Exp $");
__KERNEL_RCSID(0, "$NetBSD: sysv_sem.c,v 1.62 2006/06/07 22:33:41 kardel Exp $");
#define SYSVSEM
@ -379,7 +379,7 @@ semctl1(struct proc *p, int semid, int semnum, int cmd, void *v,
semaptr->sem_perm.gid = sembuf->sem_perm.gid;
semaptr->sem_perm.mode = (semaptr->sem_perm.mode & ~0777) |
(sembuf->sem_perm.mode & 0777);
semaptr->sem_ctime = time.tv_sec;
semaptr->sem_ctime = time_second;
break;
case IPC_STAT:
@ -536,7 +536,7 @@ sys_semget(struct lwp *l, void *v, register_t *retval)
(sema[semid].sem_perm._seq + 1) & 0x7fff;
sema[semid].sem_nsems = nsems;
sema[semid].sem_otime = 0;
sema[semid].sem_ctime = time.tv_sec;
sema[semid].sem_ctime = time_second;
sema[semid]._sem_base = &sem[semtot];
semtot += nsems;
memset(sema[semid]._sem_base, 0,
@ -791,7 +791,7 @@ done:
}
/* Update sem_otime */
semaptr->sem_otime = time.tv_sec;
semaptr->sem_otime = time_second;
/* Do a wakeup if any semaphore was up'd. */
if (do_wakeup) {

View File

@ -1,4 +1,4 @@
/* $NetBSD: sysv_shm.c,v 1.87 2006/05/14 21:15:11 elad Exp $ */
/* $NetBSD: sysv_shm.c,v 1.88 2006/06/07 22:33:41 kardel Exp $ */
/*-
* Copyright (c) 1999 The NetBSD Foundation, Inc.
@ -68,7 +68,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: sysv_shm.c,v 1.87 2006/05/14 21:15:11 elad Exp $");
__KERNEL_RCSID(0, "$NetBSD: sysv_shm.c,v 1.88 2006/06/07 22:33:41 kardel Exp $");
#define SYSVSHM
@ -204,7 +204,7 @@ shm_delete_mapping(struct vmspace *vm, struct shmmap_state *shmmap_s,
SLIST_REMOVE(&shmmap_s->entries, shmmap_se, shmmap_entry, next);
shmmap_s->nitems--;
pool_put(&shmmap_entry_pool, shmmap_se);
shmseg->shm_dtime = time.tv_sec;
shmseg->shm_dtime = time_second;
if ((--shmseg->shm_nattch <= 0) &&
(shmseg->shm_perm.mode & SHMSEG_REMOVED)) {
shm_deallocate_segment(shmseg);
@ -367,7 +367,7 @@ sys_shmat(struct lwp *l, void *v, register_t *retval)
SLIST_INSERT_HEAD(&shmmap_s->entries, shmmap_se, next);
shmmap_s->nitems++;
shmseg->shm_lpid = p->p_pid;
shmseg->shm_atime = time.tv_sec;
shmseg->shm_atime = time_second;
shmseg->shm_nattch++;
retval[0] = attach_va;
@ -427,7 +427,7 @@ shmctl1(struct proc *p, int shmid, int cmd, struct shmid_ds *shmbuf)
shmseg->shm_perm.mode =
(shmseg->shm_perm.mode & ~ACCESSPERMS) |
(shmbuf->shm_perm.mode & ACCESSPERMS);
shmseg->shm_ctime = time.tv_sec;
shmseg->shm_ctime = time_second;
break;
case IPC_RMID:
if ((error = ipcperm(cred, &shmseg->shm_perm, IPC_M)) != 0)
@ -527,7 +527,7 @@ shmget_allocate_segment(struct proc *p, struct sys_shmget_args *uap, int mode,
shmseg->shm_cpid = p->p_pid;
shmseg->shm_lpid = shmseg->shm_nattch = 0;
shmseg->shm_atime = shmseg->shm_dtime = 0;
shmseg->shm_ctime = time.tv_sec;
shmseg->shm_ctime = time_second;
shm_committed += btoc(size);
shm_nused++;

View File

@ -1,4 +1,4 @@
/* $NetBSD: tty.c,v 1.184 2006/06/04 16:44:08 christos Exp $ */
/* $NetBSD: tty.c,v 1.185 2006/06/07 22:33:41 kardel Exp $ */
/*-
* Copyright (c) 1982, 1986, 1990, 1991, 1993
@ -37,7 +37,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: tty.c,v 1.184 2006/06/04 16:44:08 christos Exp $");
__KERNEL_RCSID(0, "$NetBSD: tty.c,v 1.185 2006/06/07 22:33:41 kardel Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -1649,7 +1649,7 @@ ttread(struct tty *tp, struct uio *uio, int flag)
struct proc *p;
int c, s, first, error, has_stime, last_cc;
long lflag, slp;
struct timeval stime;
struct timeval now, stime;
stime.tv_usec = 0; /* XXX gcc */
stime.tv_sec = 0; /* XXX gcc */
@ -1723,25 +1723,28 @@ ttread(struct tty *tp, struct uio *uio, int flag)
if (!has_stime) {
/* first character, start timer */
has_stime = 1;
stime = time;
getmicrotime(&stime);
slp = t;
} else if (qp->c_cc > last_cc) {
/* got a character, restart timer */
stime = time;
getmicrotime(&stime);
slp = t;
} else {
/* nothing, check expiration */
slp = t - diff(time, stime);
getmicrotime(&now);
slp = t - diff(now, stime);
}
} else { /* m == 0 */
if (qp->c_cc > 0)
goto read;
if (!has_stime) {
has_stime = 1;
stime = time;
getmicrotime(&stime);
slp = t;
} else
slp = t - diff(time, stime);
} else {
getmicrotime(&now);
slp = t - diff(now, stime);
}
}
last_cc = qp->c_cc;
#undef diff

View File

@ -1,4 +1,4 @@
/* $NetBSD: arc4random.c,v 1.16 2005/12/24 20:45:09 perry Exp $ */
/* $NetBSD: arc4random.c,v 1.17 2006/06/07 22:33:41 kardel Exp $ */
/*-
* Copyright (c) 2002 The NetBSD Foundation, Inc.
@ -72,14 +72,15 @@
#define ARC4_RESEED_SECONDS 300
#define ARC4_KEYBYTES 32 /* 256 bit key */
#ifdef _STANDALONE
#define time_uptime 1 /* XXX ugly! */
#endif /* _STANDALONE */
static u_int8_t arc4_i, arc4_j;
static int arc4_initialized = 0;
static int arc4_numruns = 0;
static u_int8_t arc4_sbox[256];
static struct timeval arc4_tv_nextreseed;
#ifndef _KERNEL
extern struct timeval mono_time;
#endif
static time_t arc4_nextreseed;
static inline u_int8_t arc4_randbyte(void);
@ -123,8 +124,7 @@ arc4_randrekey(void)
RND_EXTRACT_ANY);
} else {
/* don't replace a good key with a bad one! */
arc4_tv_nextreseed = mono_time;
arc4_tv_nextreseed.tv_sec += ARC4_RESEED_SECONDS;
arc4_nextreseed = time_uptime + ARC4_RESEED_SECONDS;
arc4_numruns = 0;
/* we should just ask rnd(4) to rekey us when
it can, but for now, we'll just try later. */
@ -143,8 +143,7 @@ arc4_randrekey(void)
}
/* Reset for next reseed cycle. */
arc4_tv_nextreseed = mono_time;
arc4_tv_nextreseed.tv_sec += ARC4_RESEED_SECONDS;
arc4_nextreseed = time_uptime + ARC4_RESEED_SECONDS;
arc4_numruns = 0;
/*
@ -200,7 +199,7 @@ arc4random(void)
arc4_init();
if ((++arc4_numruns > ARC4_MAXRUNS) ||
(mono_time.tv_sec > arc4_tv_nextreseed.tv_sec)) {
(time_uptime > arc4_nextreseed)) {
arc4_randrekey();
}
@ -221,7 +220,7 @@ arc4randbytes(void *p, size_t len)
;
arc4_numruns += len / sizeof(u_int32_t);
if ((arc4_numruns > ARC4_MAXRUNS) ||
(mono_time.tv_sec > arc4_tv_nextreseed.tv_sec)) {
(time_uptime > arc4_nextreseed)) {
arc4_randrekey();
}
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: kernfs_vnops.c,v 1.120 2006/05/14 21:31:52 elad Exp $ */
/* $NetBSD: kernfs_vnops.c,v 1.121 2006/06/07 22:33:41 kardel Exp $ */
/*
* Copyright (c) 1992, 1993
@ -39,7 +39,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: kernfs_vnops.c,v 1.120 2006/05/14 21:31:52 elad Exp $");
__KERNEL_RCSID(0, "$NetBSD: kernfs_vnops.c,v 1.121 2006/06/07 22:33:41 kardel Exp $");
#ifdef _KERNEL_OPT
#include "opt_ipsec.h"
@ -824,17 +824,12 @@ kernfs_getattr(v)
vap->va_flags = 0;
vap->va_size = 0;
vap->va_blocksize = DEV_BSIZE;
/*
* Make all times be current TOD, except for the "boottime" node.
* Avoid microtime(9), it's slow.
* We don't guard the read from time(9) with splclock(9) since we
* don't actually need to be THAT sure the access is atomic.
*/
/* Make all times be current TOD, except for the "boottime" node. */
if (kfs->kfs_kt && kfs->kfs_kt->kt_namlen == 8 &&
!memcmp(kfs->kfs_kt->kt_name, "boottime", 8)) {
TIMEVAL_TO_TIMESPEC(&boottime, &vap->va_ctime);
} else {
TIMEVAL_TO_TIMESPEC(&time, &vap->va_ctime);
getnanotime(&vap->va_ctime);
}
vap->va_atime = vap->va_mtime = vap->va_ctime;
vap->va_gen = 0;

View File

@ -1,4 +1,4 @@
/* $NetBSD: portal_vnops.c,v 1.65 2006/06/05 13:25:28 rpaulo Exp $ */
/* $NetBSD: portal_vnops.c,v 1.66 2006/06/07 22:33:41 kardel Exp $ */
/*
* Copyright (c) 1992, 1993
@ -40,7 +40,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: portal_vnops.c,v 1.65 2006/06/05 13:25:28 rpaulo Exp $");
__KERNEL_RCSID(0, "$NetBSD: portal_vnops.c,v 1.66 2006/06/07 22:33:41 kardel Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -541,12 +541,8 @@ portal_getattr(v)
vap->va_fsid = vp->v_mount->mnt_stat.f_fsidx.__fsid_val[0];
vap->va_size = DEV_BSIZE;
vap->va_blocksize = DEV_BSIZE;
/*
* Make all times be current TOD. Avoid microtime(9), it's slow.
* We don't guard the read from time(9) with splclock(9) since we
* don't actually need to be THAT sure the access is atomic.
*/
TIMEVAL_TO_TIMESPEC(&time, &vap->va_ctime);
/* Make all times be current TOD. */
getnanotime(&vap->va_ctime);
vap->va_atime = vap->va_mtime = vap->va_ctime;
vap->va_atime = vap->va_mtime = vap->va_ctime;
vap->va_gen = 0;

View File

@ -1,4 +1,4 @@
/* $NetBSD: procfs_vnops.c,v 1.130 2006/05/14 21:31:53 elad Exp $ */
/* $NetBSD: procfs_vnops.c,v 1.131 2006/06/07 22:33:41 kardel Exp $ */
/*
* Copyright (c) 1993, 1995
@ -76,7 +76,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: procfs_vnops.c,v 1.130 2006/05/14 21:31:53 elad Exp $");
__KERNEL_RCSID(0, "$NetBSD: procfs_vnops.c,v 1.131 2006/06/07 22:33:41 kardel Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -586,9 +586,7 @@ procfs_getattr(v)
vap->va_blocksize = PAGE_SIZE;
/*
* Make all times be current TOD. Avoid microtime(9), it's slow.
* We don't guard the read from time(9) with splclock(9) since we
* don't actually need to be THAT sure the access is atomic.
* Make all times be current TOD.
*
* It would be possible to get the process start
* time from the p_stats structure, but there's
@ -596,13 +594,13 @@ procfs_getattr(v)
* p_stats structure is not addressable if u. gets
* swapped out for that process.
*/
TIMEVAL_TO_TIMESPEC(&time, &vap->va_ctime);
getnanotime(&vap->va_ctime);
vap->va_atime = vap->va_mtime = vap->va_ctime;
if (procp)
TIMEVAL_TO_TIMESPEC(&procp->p_stats->p_start,
&vap->va_birthtime);
else
TIMEVAL_TO_TIMESPEC(&boottime, &vap->va_birthtime);
getnanotime(&vap->va_birthtime);
switch (pfs->pfs_type) {
case PFSmem:

View File

@ -1,4 +1,4 @@
/* $NetBSD: sync_subr.c,v 1.21 2006/05/14 21:32:21 elad Exp $ */
/* $NetBSD: sync_subr.c,v 1.22 2006/06/07 22:33:42 kardel Exp $ */
/*
* Copyright 1997 Marshall Kirk McKusick. All Rights Reserved.
@ -32,7 +32,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: sync_subr.c,v 1.21 2006/05/14 21:32:21 elad Exp $");
__KERNEL_RCSID(0, "$NetBSD: sync_subr.c,v 1.22 2006/06/07 22:33:42 kardel Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -170,7 +170,7 @@ sched_sync(v)
updateproc = curlwp;
for (;;) {
starttime = time.tv_sec;
starttime = time_second;
/*
* Push files whose dirty time has expired. Be careful
@ -241,7 +241,7 @@ sched_sync(v)
* matter as we are just trying to generally pace the
* filesystem activity.
*/
if (time.tv_sec == starttime)
if (time_second == starttime)
tsleep(&rushjob, PPAUSE, "syncer", hz);
}
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: if_arcsubr.c,v 1.51 2005/12/11 23:05:24 thorpej Exp $ */
/* $NetBSD: if_arcsubr.c,v 1.52 2006/06/07 22:33:42 kardel Exp $ */
/*
* Copyright (c) 1994, 1995 Ignatios Souvatzis
@ -35,7 +35,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: if_arcsubr.c,v 1.51 2005/12/11 23:05:24 thorpej Exp $");
__KERNEL_RCSID(0, "$NetBSD: if_arcsubr.c,v 1.52 2006/06/07 22:33:42 kardel Exp $");
#include "opt_inet.h"
@ -156,7 +156,7 @@ arc_output(struct ifnet *ifp, struct mbuf *m0, struct sockaddr *dst,
}
if (rt->rt_flags & RTF_REJECT)
if (rt->rt_rmx.rmx_expire == 0 ||
time.tv_sec < rt->rt_rmx.rmx_expire)
time_second < rt->rt_rmx.rmx_expire)
senderr(rt == rt0 ? EHOSTDOWN : EHOSTUNREACH);
}
@ -649,7 +649,7 @@ arc_ifattach(struct ifnet *ifp, uint8_t lla)
ifp->if_output = arc_output;
ifp->if_input = arc_input;
ac = (struct arccom *)ifp;
ac->ac_seqid = (time.tv_sec) & 0xFFFF; /* try to make seqid unique */
ac->ac_seqid = (time_second) & 0xFFFF; /* try to make seqid unique */
if (lla == 0) {
/* XXX this message isn't entirely clear, to me -- cgd */
log(LOG_ERR,"%s: link address 0 reserved for broadcasts. Please change it and ifconfig %s down up\n",

View File

@ -1,4 +1,4 @@
/* $NetBSD: if_bridge.c,v 1.38 2006/05/18 09:05:51 liamjfoy Exp $ */
/* $NetBSD: if_bridge.c,v 1.39 2006/06/07 22:33:42 kardel Exp $ */
/*
* Copyright 2001 Wasabi Systems, Inc.
@ -80,7 +80,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: if_bridge.c,v 1.38 2006/05/18 09:05:51 liamjfoy Exp $");
__KERNEL_RCSID(0, "$NetBSD: if_bridge.c,v 1.39 2006/06/07 22:33:42 kardel Exp $");
#include "opt_bridge_ipf.h"
#include "opt_inet.h"
@ -828,9 +828,9 @@ bridge_ioctl_rts(struct bridge_softc *sc, void *arg)
strlcpy(bareq.ifba_ifsname, brt->brt_ifp->if_xname,
sizeof(bareq.ifba_ifsname));
memcpy(bareq.ifba_dst, brt->brt_addr, sizeof(brt->brt_addr));
if ((brt->brt_flags & IFBAF_TYPEMASK) == IFBAF_DYNAMIC)
bareq.ifba_expire = brt->brt_expire - mono_time.tv_sec;
else
if ((brt->brt_flags & IFBAF_TYPEMASK) == IFBAF_DYNAMIC) {
bareq.ifba_expire = brt->brt_expire - time_uptime;
} else
bareq.ifba_expire = 0;
bareq.ifba_flags = brt->brt_flags;
@ -1665,7 +1665,7 @@ bridge_rtupdate(struct bridge_softc *sc, const uint8_t *dst,
return (ENOMEM);
memset(brt, 0, sizeof(*brt));
brt->brt_expire = mono_time.tv_sec + sc->sc_brttimeout;
brt->brt_expire = time_uptime + sc->sc_brttimeout;
brt->brt_flags = IFBAF_DYNAMIC;
memcpy(brt->brt_addr, dst, ETHER_ADDR_LEN);
@ -1678,8 +1678,10 @@ bridge_rtupdate(struct bridge_softc *sc, const uint8_t *dst,
brt->brt_ifp = dst_if;
if (setflags) {
brt->brt_flags = flags;
brt->brt_expire = (flags & IFBAF_STATIC) ? 0 :
mono_time.tv_sec + sc->sc_brttimeout;
if (flags & IFBAF_STATIC)
brt->brt_expire = 0;
else
brt->brt_expire = time_uptime + sc->sc_brttimeout;
}
return (0);
@ -1765,7 +1767,7 @@ bridge_rtage(struct bridge_softc *sc)
for (brt = LIST_FIRST(&sc->sc_rtlist); brt != NULL; brt = nbrt) {
nbrt = LIST_NEXT(brt, brt_list);
if ((brt->brt_flags & IFBAF_TYPEMASK) == IFBAF_DYNAMIC) {
if (mono_time.tv_sec >= brt->brt_expire)
if (time_uptime >= brt->brt_expire)
bridge_rtnode_destroy(sc, brt);
}
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: if_ecosubr.c,v 1.20 2006/04/22 04:58:49 simonb Exp $ */
/* $NetBSD: if_ecosubr.c,v 1.21 2006/06/07 22:33:42 kardel Exp $ */
/*-
* Copyright (c) 2001 Ben Harris
@ -58,7 +58,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: if_ecosubr.c,v 1.20 2006/04/22 04:58:49 simonb Exp $");
__KERNEL_RCSID(0, "$NetBSD: if_ecosubr.c,v 1.21 2006/06/07 22:33:42 kardel Exp $");
#include "bpfilter.h"
#include "opt_inet.h"
@ -214,7 +214,7 @@ eco_output(struct ifnet *ifp, struct mbuf *m0, struct sockaddr *dst,
}
if (rt->rt_flags & RTF_REJECT)
if (rt->rt_rmx.rmx_expire == 0 ||
time.tv_sec < rt->rt_rmx.rmx_expire)
time_second < rt->rt_rmx.rmx_expire)
senderr(rt == rt0 ? EHOSTDOWN : EHOSTUNREACH);
}
/*

View File

@ -1,4 +1,4 @@
/* $NetBSD: if_ethersubr.c,v 1.133 2006/05/18 09:05:51 liamjfoy Exp $ */
/* $NetBSD: if_ethersubr.c,v 1.134 2006/06/07 22:33:42 kardel Exp $ */
/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@ -61,7 +61,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: if_ethersubr.c,v 1.133 2006/05/18 09:05:51 liamjfoy Exp $");
__KERNEL_RCSID(0, "$NetBSD: if_ethersubr.c,v 1.134 2006/06/07 22:33:42 kardel Exp $");
#include "opt_inet.h"
#include "opt_atalk.h"
@ -284,7 +284,7 @@ ether_output(struct ifnet *ifp0, struct mbuf *m0, struct sockaddr *dst,
}
if (rt->rt_flags & RTF_REJECT)
if (rt->rt_rmx.rmx_expire == 0 ||
(u_long) time.tv_sec < rt->rt_rmx.rmx_expire)
(u_long) time_second < rt->rt_rmx.rmx_expire)
senderr(rt == rt0 ? EHOSTDOWN : EHOSTUNREACH);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: if_fddisubr.c,v 1.61 2006/05/18 09:05:51 liamjfoy Exp $ */
/* $NetBSD: if_fddisubr.c,v 1.62 2006/06/07 22:33:42 kardel Exp $ */
/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@ -96,7 +96,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: if_fddisubr.c,v 1.61 2006/05/18 09:05:51 liamjfoy Exp $");
__KERNEL_RCSID(0, "$NetBSD: if_fddisubr.c,v 1.62 2006/06/07 22:33:42 kardel Exp $");
#include "opt_inet.h"
#include "opt_atalk.h"
@ -274,7 +274,7 @@ fddi_output(struct ifnet *ifp0, struct mbuf *m0, struct sockaddr *dst,
}
if (rt->rt_flags & RTF_REJECT)
if (rt->rt_rmx.rmx_expire == 0 ||
time.tv_sec < rt->rt_rmx.rmx_expire)
time_second < rt->rt_rmx.rmx_expire)
senderr(rt == rt0 ? EHOSTDOWN : EHOSTUNREACH);
}
#endif

View File

@ -1,4 +1,4 @@
/* $NetBSD: if_hippisubr.c,v 1.22 2005/12/11 23:05:25 thorpej Exp $ */
/* $NetBSD: if_hippisubr.c,v 1.23 2006/06/07 22:33:42 kardel Exp $ */
/*
* Copyright (c) 1982, 1989, 1993
@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: if_hippisubr.c,v 1.22 2005/12/11 23:05:25 thorpej Exp $");
__KERNEL_RCSID(0, "$NetBSD: if_hippisubr.c,v 1.23 2006/06/07 22:33:42 kardel Exp $");
#include "opt_inet.h"
@ -137,7 +137,7 @@ hippi_output(struct ifnet *ifp, struct mbuf *m0, struct sockaddr *dst,
}
if (rt->rt_flags & RTF_REJECT)
if (rt->rt_rmx.rmx_expire == 0 || /* XXX: no ARP */
time.tv_sec < rt->rt_rmx.rmx_expire)
time_second < rt->rt_rmx.rmx_expire)
senderr(rt == rt0 ? EHOSTDOWN : EHOSTUNREACH);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: if_ieee1394subr.c,v 1.31 2005/12/11 12:24:51 christos Exp $ */
/* $NetBSD: if_ieee1394subr.c,v 1.32 2006/06/07 22:33:42 kardel Exp $ */
/*
* Copyright (c) 2000 The NetBSD Foundation, Inc.
@ -37,7 +37,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: if_ieee1394subr.c,v 1.31 2005/12/11 12:24:51 christos Exp $");
__KERNEL_RCSID(0, "$NetBSD: if_ieee1394subr.c,v 1.32 2006/06/07 22:33:42 kardel Exp $");
#include "opt_inet.h"
#include "bpfilter.h"
@ -139,7 +139,7 @@ ieee1394_output(struct ifnet *ifp, struct mbuf *m0, struct sockaddr *dst,
}
if (rt->rt_flags & RTF_REJECT)
if (rt->rt_rmx.rmx_expire == 0 ||
time.tv_sec < rt->rt_rmx.rmx_expire)
time_second < rt->rt_rmx.rmx_expire)
senderr(rt == rt0 ? EHOSTDOWN : EHOSTUNREACH);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: if_ppp.c,v 1.106 2006/05/14 21:19:33 elad Exp $ */
/* $NetBSD: if_ppp.c,v 1.107 2006/06/07 22:33:42 kardel Exp $ */
/* Id: if_ppp.c,v 1.6 1997/03/04 03:33:00 paulus Exp */
/*
@ -102,7 +102,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.106 2006/05/14 21:19:33 elad Exp $");
__KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.107 2006/06/07 22:33:42 kardel Exp $");
#include "ppp.h"
@ -146,7 +146,6 @@ __KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.106 2006/05/14 21:19:33 elad Exp $");
#include "bpfilter.h"
#if NBPFILTER > 0
#include <sys/time.h>
#include <net/bpf.h>
#endif
@ -403,7 +402,7 @@ pppalloc(pid_t pid)
sc->sc_npmode[i] = NPMODE_ERROR;
sc->sc_npqueue = NULL;
sc->sc_npqtail = &sc->sc_npqueue;
sc->sc_last_sent = sc->sc_last_recv = time.tv_sec;
sc->sc_last_sent = sc->sc_last_recv = time_second;
return sc;
}
@ -670,7 +669,7 @@ pppioctl(struct ppp_softc *sc, u_long cmd, caddr_t data, int flag,
case PPPIOCGIDLE:
s = splsoftnet();
t = time.tv_sec;
t = time_second;
((struct ppp_idle *)data)->xmit_idle = t - sc->sc_last_sent;
((struct ppp_idle *)data)->recv_idle = t - sc->sc_last_recv;
splx(s);
@ -993,12 +992,12 @@ pppoutput(struct ifnet *ifp, struct mbuf *m0, struct sockaddr *dst,
if (sc->sc_active_filt_out.bf_insns == 0
|| bpf_filter(sc->sc_active_filt_out.bf_insns, (u_char *) m0,
len, 0))
sc->sc_last_sent = time.tv_sec;
sc->sc_last_sent = time_second;
#else
/*
* Update the time we sent the most recent packet.
*/
sc->sc_last_sent = time.tv_sec;
sc->sc_last_sent = time_second;
#endif /* PPP_FILTER */
}
@ -1647,12 +1646,12 @@ ppp_inproc(struct ppp_softc *sc, struct mbuf *m)
if (sc->sc_active_filt_in.bf_insns == 0
|| bpf_filter(sc->sc_active_filt_in.bf_insns, (u_char *) m,
ilen, 0))
sc->sc_last_recv = time.tv_sec;
sc->sc_last_recv = time_second;
#else
/*
* Record the time that we received this packet.
*/
sc->sc_last_recv = time.tv_sec;
sc->sc_last_recv = time_second;
#endif /* PPP_FILTER */
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: if_pppoe.c,v 1.68 2006/05/14 21:19:33 elad Exp $ */
/* $NetBSD: if_pppoe.c,v 1.69 2006/06/07 22:33:42 kardel Exp $ */
/*-
* Copyright (c) 2002 The NetBSD Foundation, Inc.
@ -37,7 +37,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: if_pppoe.c,v 1.68 2006/05/14 21:19:33 elad Exp $");
__KERNEL_RCSID(0, "$NetBSD: if_pppoe.c,v 1.69 2006/06/07 22:33:42 kardel Exp $");
#include "pppoe.h"
#include "bpfilter.h"
@ -1347,6 +1347,7 @@ pppoe_send_pado(struct pppoe_softc *sc)
static int
pppoe_send_pads(struct pppoe_softc *sc)
{
struct bintime bt;
struct mbuf *m0;
u_int8_t *p;
size_t len, l1 = 0; /* XXX: gcc */
@ -1354,7 +1355,8 @@ pppoe_send_pads(struct pppoe_softc *sc)
if (sc->sc_state != PPPOE_STATE_PADO_SENT)
return EIO;
sc->sc_session = mono_time.tv_sec % 0xff + 1;
getbinuptime(&bt);
sc->sc_session = bt.sec % 0xff + 1;
/* calc length */
len = 0;
/* include hunique */

View File

@ -1,4 +1,4 @@
/* $NetBSD: if_sl.c,v 1.97 2006/05/14 21:19:33 elad Exp $ */
/* $NetBSD: if_sl.c,v 1.98 2006/06/07 22:33:43 kardel Exp $ */
/*
* Copyright (c) 1987, 1989, 1992, 1993
@ -60,7 +60,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: if_sl.c,v 1.97 2006/05/14 21:19:33 elad Exp $");
__KERNEL_RCSID(0, "$NetBSD: if_sl.c,v 1.98 2006/06/07 22:33:43 kardel Exp $");
#include "opt_inet.h"
#include "bpfilter.h"
@ -492,11 +492,12 @@ sloutput(struct ifnet *ifp, struct mbuf *m, struct sockaddr *dst,
s = spltty();
if (sc->sc_oqlen && sc->sc_ttyp->t_outq.c_cc == sc->sc_oqlen) {
struct timeval tv;
struct bintime bt;
/* if output's been stalled for too long, and restart */
timersub(&time, &sc->sc_lastpacket, &tv);
if (tv.tv_sec > 0) {
getbinuptime(&bt);
bintime_sub(&bt, &sc->sc_lastpacket);
if (bt.sec > 0) {
sc->sc_otimeout++;
slstart(sc->sc_ttyp);
}
@ -513,7 +514,7 @@ sloutput(struct ifnet *ifp, struct mbuf *m, struct sockaddr *dst,
splx(s);
return error;
}
sc->sc_lastpacket = time;
getbinuptime(&sc->sc_lastpacket);
splx(s);
s = spltty();
@ -625,15 +626,15 @@ slinput(int c, struct tty *tp)
* this one is within the time limit.
*/
if (sc->sc_abortcount &&
time.tv_sec >= sc->sc_starttime + ABT_WINDOW)
time_second >= sc->sc_starttime + ABT_WINDOW)
sc->sc_abortcount = 0;
/*
* If we see an abort after "idle" time, count it;
* record when the first abort escape arrived.
*/
if (time.tv_sec >= sc->sc_lasttime + ABT_IDLE) {
if (time_second >= sc->sc_lasttime + ABT_IDLE) {
if (++sc->sc_abortcount == 1)
sc->sc_starttime = time.tv_sec;
sc->sc_starttime = time_second;
if (sc->sc_abortcount >= ABT_COUNT) {
slclose(tp, 0);
return (0);
@ -641,7 +642,7 @@ slinput(int c, struct tty *tp)
}
} else
sc->sc_abortcount = 0;
sc->sc_lasttime = time.tv_sec;
sc->sc_lasttime = time_second;
}
switch (c) {
@ -810,7 +811,7 @@ slintr(void *arg)
bpf_mtap_sl_out(sc->sc_if.if_bpf, mtod(m, u_char *),
bpf_m);
#endif
sc->sc_lastpacket = time;
getbinuptime(&sc->sc_lastpacket);
s = spltty();
@ -995,7 +996,7 @@ slintr(void *arg)
}
sc->sc_if.if_ipackets++;
sc->sc_lastpacket = time;
getbinuptime(&sc->sc_lastpacket);
#ifdef INET
s = splnet();

View File

@ -1,4 +1,4 @@
/* $NetBSD: if_slvar.h,v 1.31 2005/12/11 23:05:25 thorpej Exp $ */
/* $NetBSD: if_slvar.h,v 1.32 2006/06/07 22:33:43 kardel Exp $ */
/*-
* Copyright (c) 1991, 1993
@ -67,7 +67,7 @@ struct sl_softc {
#ifdef INET /* XXX */
struct slcompress sc_comp; /* tcp compression data */
#endif
struct timeval sc_lastpacket; /* for watchdog */
struct bintime sc_lastpacket; /* for watchdog */
LIST_ENTRY(sl_softc) sc_iflist;
};

View File

@ -1,4 +1,4 @@
/* $NetBSD: if_spppsubr.c,v 1.91 2006/05/21 05:09:13 christos Exp $ */
/* $NetBSD: if_spppsubr.c,v 1.92 2006/06/07 22:33:43 kardel Exp $ */
/*
* Synchronous PPP/Cisco link level subroutines.
@ -41,7 +41,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: if_spppsubr.c,v 1.91 2006/05/21 05:09:13 christos Exp $");
__KERNEL_RCSID(0, "$NetBSD: if_spppsubr.c,v 1.92 2006/06/07 22:33:43 kardel Exp $");
#include "opt_inet.h"
#include "opt_ipx.h"
@ -487,7 +487,7 @@ sppp_input(struct ifnet *ifp, struct mbuf *m)
/* Count received bytes, add hardware framing */
ifp->if_ibytes += m->m_pkthdr.len + sp->pp_framebytes;
/* Note time of last receive */
sp->pp_last_receive = mono_time.tv_sec;
sp->pp_last_receive = time_uptime;
}
if (m->m_pkthdr.len <= PPP_HEADER_LEN) {
@ -624,7 +624,7 @@ sppp_input(struct ifnet *ifp, struct mbuf *m)
if (sp->state[IDX_IPCP] == STATE_OPENED) {
schednetisr(NETISR_IP);
inq = &ipintrq;
sp->pp_last_activity = mono_time.tv_sec;
sp->pp_last_activity = time_uptime;
}
break;
#endif
@ -639,7 +639,7 @@ sppp_input(struct ifnet *ifp, struct mbuf *m)
if (sp->state[IDX_IPV6CP] == STATE_OPENED) {
schednetisr(NETISR_IPV6);
inq = &ip6intrq;
sp->pp_last_activity = mono_time.tv_sec;
sp->pp_last_activity = time_uptime;
}
break;
#endif
@ -707,7 +707,7 @@ sppp_output(struct ifnet *ifp, struct mbuf *m,
s = splnet();
sp->pp_last_activity = mono_time.tv_sec;
sp->pp_last_activity = time_uptime;
if ((ifp->if_flags & IFF_UP) == 0 ||
(ifp->if_flags & (IFF_RUNNING | IFF_AUTO)) == 0) {
@ -1256,8 +1256,9 @@ sppp_cisco_send(struct sppp *sp, int type, int32_t par1, int32_t par2)
struct ppp_header *h;
struct cisco_packet *ch;
struct mbuf *m;
u_int32_t t = (time.tv_sec - boottime.tv_sec) * 1000;
u_int32_t t;
t = time_uptime * 1000;
MGETHDR(m, M_DONTWAIT, MT_DATA);
if (! m)
return;
@ -2036,7 +2037,7 @@ sppp_lcp_up(struct sppp *sp)
STDDCL;
/* Initialize activity timestamp: opening a connection is an activity */
sp->pp_last_receive = sp->pp_last_activity = mono_time.tv_sec;
sp->pp_last_receive = sp->pp_last_activity = time_uptime;
/*
* If this interface is passive or dial-on-demand, and we are
@ -4649,7 +4650,7 @@ sppp_keepalive(void *dummy)
time_t now;
s = splnet();
now = mono_time.tv_sec;
now = time_uptime;
for (sp=spppq; sp; sp=sp->pp_next) {
struct ifnet *ifp = &sp->pp_if;

View File

@ -1,4 +1,4 @@
/* $NetBSD: if_strip.c,v 1.65 2006/05/14 21:19:33 elad Exp $ */
/* $NetBSD: if_strip.c,v 1.66 2006/06/07 22:33:43 kardel Exp $ */
/* from: NetBSD: if_sl.c,v 1.38 1996/02/13 22:00:23 christos Exp $ */
/*
@ -87,7 +87,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: if_strip.c,v 1.65 2006/05/14 21:19:33 elad Exp $");
__KERNEL_RCSID(0, "$NetBSD: if_strip.c,v 1.66 2006/06/07 22:33:43 kardel Exp $");
#include "opt_inet.h"
#include "bpfilter.h"
@ -314,7 +314,7 @@ void strip_timeout(void *x);
#define CLEAR_RESET_TIMER(sc) \
do {\
(sc)->sc_state = ST_ALIVE; \
(sc)->sc_statetimo = time.tv_sec + ST_PROBE_INTERVAL; \
(sc)->sc_statetimo = time_second + ST_PROBE_INTERVAL; \
} while (/*CONSTCOND*/ 0)
/*
@ -323,13 +323,13 @@ void strip_timeout(void *x);
*/
#define FORCE_RESET(sc) \
do {\
(sc)->sc_statetimo = time.tv_sec - 1; \
(sc)->sc_statetimo = time_second - 1; \
(sc)->sc_state = ST_DEAD; \
/*(sc)->sc_if.if_timer = 0;*/ \
} while (/*CONSTCOND*/ 0)
#define RADIO_PROBE_TIMEOUT(sc) \
((sc)-> sc_statetimo > time.tv_sec)
((sc)-> sc_statetimo > time_second)
static int stripclose(struct tty *, int);
static int stripinput(int, struct tty *);
@ -462,7 +462,7 @@ stripinit(struct strip_softc *sc)
/* Initialize radio probe/reset state machine */
sc->sc_state = ST_DEAD; /* assumet the worst. */
sc->sc_statetimo = time.tv_sec; /* do reset immediately */
sc->sc_statetimo = time_second; /* do reset immediately */
return (1);
}
@ -729,7 +729,7 @@ strip_send(struct strip_softc *sc, struct mbuf *m0)
* If a radio probe is due now, append it to this packet rather
* than waiting until the watchdog routine next runs.
*/
if (time.tv_sec >= sc->sc_statetimo && sc->sc_state == ST_ALIVE)
if (time_second >= sc->sc_statetimo && sc->sc_state == ST_ALIVE)
strip_proberadio(sc, tp);
}
@ -867,11 +867,12 @@ stripoutput(struct ifnet *ifp, struct mbuf *m, struct sockaddr *dst,
s = spltty();
if (sc->sc_oqlen && sc->sc_ttyp->t_outq.c_cc == sc->sc_oqlen) {
struct timeval tv;
struct bintime bt;
/* if output's been stalled for too long, and restart */
timersub(&time, &sc->sc_lastpacket, &tv);
if (tv.tv_sec > 0) {
getbinuptime(&bt);
bintime_sub(&bt, &sc->sc_lastpacket);
if (bt.sec > 0) {
DPRINTF(("stripoutput: stalled, resetting\n"));
sc->sc_otimeout++;
stripstart(sc->sc_ttyp);
@ -885,7 +886,7 @@ stripoutput(struct ifnet *ifp, struct mbuf *m, struct sockaddr *dst,
splx(s);
return error;
}
sc->sc_lastpacket = time;
getbinuptime(&sc->sc_lastpacket);
splx(s);
s = spltty();
@ -1189,7 +1190,7 @@ stripintr(void *arg)
bpf_mtap_sl_out(sc->sc_if.if_bpf, mtod(m, u_char *),
bpf_m);
#endif
sc->sc_lastpacket = time;
getbinuptime(&sc->sc_lastpacket);
s = spltty();
strip_send(sc, m);
@ -1292,7 +1293,7 @@ stripintr(void *arg)
}
sc->sc_if.if_ipackets++;
sc->sc_lastpacket = time;
getbinuptime(&sc->sc_lastpacket);
#ifdef INET
s = splnet();
@ -1400,8 +1401,8 @@ strip_resetradio(struct strip_softc *sc, struct tty *tp)
* is so badlyhung it needs powercycling.
*/
sc->sc_state = ST_DEAD;
sc->sc_lastpacket = time;
sc->sc_statetimo = time.tv_sec + STRIP_RESET_INTERVAL;
getbinuptime(&sc->sc_lastpacket);
sc->sc_statetimo = time_second + STRIP_RESET_INTERVAL;
/*
* XXX Does calling the tty output routine now help resets?
@ -1437,7 +1438,7 @@ strip_proberadio(struct strip_softc *sc, struct tty *tp)
sc->sc_if.if_xname);
/* Go to probe-sent state, set timeout accordingly. */
sc->sc_state = ST_PROBE_SENT;
sc->sc_statetimo = time.tv_sec + ST_PROBERESPONSE_INTERVAL;
sc->sc_statetimo = time_second + ST_PROBERESPONSE_INTERVAL;
} else {
addlog("%s: incomplete probe, tty queue %d bytes overfull\n",
sc->sc_if.if_xname, overflow);
@ -1511,13 +1512,13 @@ strip_watchdog(struct ifnet *ifp)
ifp->if_xname,
((unsigned) sc->sc_state < 3) ?
strip_statenames[sc->sc_state] : "<<illegal state>>",
sc->sc_statetimo - time.tv_sec);
sc->sc_statetimo - time_second);
#endif
/*
* If time in this state hasn't yet expired, return.
*/
if ((ifp->if_flags & IFF_UP) == 0 || sc->sc_statetimo > time.tv_sec) {
if ((ifp->if_flags & IFF_UP) == 0 || sc->sc_statetimo > time_second) {
goto done;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: if_stripvar.h,v 1.17 2005/12/11 23:05:25 thorpej Exp $ */
/* $NetBSD: if_stripvar.h,v 1.18 2006/06/07 22:33:43 kardel Exp $ */
#ifndef _NET_IF_STRIPVAR_H_
#define _NET_IF_STRIPVAR_H_
@ -40,7 +40,7 @@ struct strip_softc {
long sc_statetimo; /* When (secs) current state ends */
struct timeval sc_lastpacket; /* for watchdog */
struct bintime sc_lastpacket; /* for watchdog */
LIST_ENTRY(strip_softc) sc_iflist;
};

View File

@ -1,4 +1,4 @@
/* $NetBSD: if_tap.c,v 1.17 2006/05/14 21:19:33 elad Exp $ */
/* $NetBSD: if_tap.c,v 1.18 2006/06/07 22:33:43 kardel Exp $ */
/*
* Copyright (c) 2003, 2004 The NetBSD Foundation.
@ -43,7 +43,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: if_tap.c,v 1.17 2006/05/14 21:19:33 elad Exp $");
__KERNEL_RCSID(0, "$NetBSD: if_tap.c,v 1.18 2006/06/07 22:33:43 kardel Exp $");
#if defined(_KERNEL_OPT)
#include "bpfilter.h"
@ -252,22 +252,24 @@ tap_attach(struct device *parent, struct device *self, void *aux)
{
struct tap_softc *sc = (struct tap_softc *)self;
struct ifnet *ifp;
const struct sysctlnode *node;
u_int8_t enaddr[ETHER_ADDR_LEN] =
{ 0xf2, 0x0b, 0xa4, 0xff, 0xff, 0xff };
char enaddrstr[3 * ETHER_ADDR_LEN];
struct timeval tv;
uint32_t ui;
int error;
const struct sysctlnode *node;
aprint_normal("%s: faking Ethernet device\n",
self->dv_xname);
/*
* In order to obtain unique initial Ethernet address on a host,
* do some randomisation using mono_time. It's not meant for anything
* but avoiding hard-coding an address.
* do some randomisation using the current uptime. It's not meant
* for anything but avoiding hard-coding an address.
*/
ui = (mono_time.tv_sec ^ mono_time.tv_usec) & 0xffffff;
getmicrouptime(&tv);
ui = (tv.tv_sec ^ tv.tv_usec) & 0xffffff;
memcpy(enaddr+3, (u_int8_t *)&ui, 3);
aprint_normal("%s: Ethernet address %s\n", sc->sc_dev.dv_xname,

View File

@ -1,4 +1,4 @@
/* $NetBSD: if_tokensubr.c,v 1.37 2006/05/18 09:05:51 liamjfoy Exp $ */
/* $NetBSD: if_tokensubr.c,v 1.38 2006/06/07 22:33:43 kardel Exp $ */
/*
* Copyright (c) 1982, 1989, 1993
@ -99,7 +99,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: if_tokensubr.c,v 1.37 2006/05/18 09:05:51 liamjfoy Exp $");
__KERNEL_RCSID(0, "$NetBSD: if_tokensubr.c,v 1.38 2006/06/07 22:33:43 kardel Exp $");
#include "opt_inet.h"
#include "opt_atalk.h"
@ -270,7 +270,7 @@ token_output(struct ifnet *ifp0, struct mbuf *m0, struct sockaddr *dst,
}
if (rt->rt_flags & RTF_REJECT)
if (rt->rt_rmx.rmx_expire == 0 ||
time.tv_sec < rt->rt_rmx.rmx_expire)
time_second < rt->rt_rmx.rmx_expire)
senderr(rt == rt0 ? EHOSTDOWN : EHOSTUNREACH);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: route.c,v 1.69 2006/04/15 02:19:00 christos Exp $ */
/* $NetBSD: route.c,v 1.70 2006/06/07 22:33:43 kardel Exp $ */
/*-
* Copyright (c) 1998 The NetBSD Foundation, Inc.
@ -98,7 +98,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: route.c,v 1.69 2006/04/15 02:19:00 christos Exp $");
__KERNEL_RCSID(0, "$NetBSD: route.c,v 1.70 2006/06/07 22:33:43 kardel Exp $");
#include "opt_ns.h"
@ -936,12 +936,6 @@ rt_timer_add(struct rtentry *rt,
struct rttimer_queue *queue)
{
struct rttimer *r;
long current_time;
int s;
s = splclock();
current_time = mono_time.tv_sec;
splx(s);
/*
* If there's already a timer with this action, destroy it before
@ -967,7 +961,7 @@ rt_timer_add(struct rtentry *rt,
Bzero(r, sizeof(*r));
r->rtt_rt = rt;
r->rtt_time = current_time;
r->rtt_time = time_uptime;
r->rtt_func = func;
r->rtt_queue = queue;
LIST_INSERT_HEAD(&rt->rt_timer, r, rtt_link);
@ -983,18 +977,13 @@ rt_timer_timer(void *arg)
{
struct rttimer_queue *rtq;
struct rttimer *r;
long current_time;
int s;
s = splclock();
current_time = mono_time.tv_sec;
splx(s);
s = splsoftnet();
for (rtq = LIST_FIRST(&rttimer_queue_head); rtq != NULL;
rtq = LIST_NEXT(rtq, rtq_link)) {
while ((r = TAILQ_FIRST(&rtq->rtq_head)) != NULL &&
(r->rtt_time + rtq->rtq_timeout) < current_time) {
(r->rtt_time + rtq->rtq_timeout) < time_uptime) {
LIST_REMOVE(r, rtt_link);
TAILQ_REMOVE(&rtq->rtq_head, r, rtt_next);
RTTIMER_CALLOUT(r);

View File

@ -1,4 +1,4 @@
/* $NetBSD: at_control.c,v 1.13 2006/05/14 21:19:33 elad Exp $ */
/* $NetBSD: at_control.c,v 1.14 2006/06/07 22:34:00 kardel Exp $ */
/*
* Copyright (c) 1990,1994 Regents of The University of Michigan.
@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: at_control.c,v 1.13 2006/05/14 21:19:33 elad Exp $");
__KERNEL_RCSID(0, "$NetBSD: at_control.c,v 1.14 2006/06/07 22:34:00 kardel Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -470,7 +470,7 @@ at_ifinit(ifp, aa, sat)
*/
if (nnets != 1) {
net = ntohs(nr.nr_firstnet) +
time.tv_sec % (nnets - 1);
time_second % (nnets - 1);
} else {
net = ntohs(nr.nr_firstnet);
}
@ -509,7 +509,7 @@ at_ifinit(ifp, aa, sat)
* not specified, be random about it... XXX use /dev/random?
*/
if (sat->sat_addr.s_node == ATADDR_ANYNODE) {
AA_SAT(aa)->sat_addr.s_node = time.tv_sec;
AA_SAT(aa)->sat_addr.s_node = time_second;
} else {
AA_SAT(aa)->sat_addr.s_node = sat->sat_addr.s_node;
}
@ -528,7 +528,7 @@ at_ifinit(ifp, aa, sat)
* Once again, starting at the (possibly random)
* initial node address.
*/
for (j = 0, nodeinc = time.tv_sec | 1; j < 256;
for (j = 0, nodeinc = time_second | 1; j < 256;
j++, AA_SAT(aa)->sat_addr.s_node += nodeinc) {
if (AA_SAT(aa)->sat_addr.s_node > 253 ||
AA_SAT(aa)->sat_addr.s_node < 1) {
@ -572,7 +572,7 @@ at_ifinit(ifp, aa, sat)
break;
/* reset node for next network */
AA_SAT(aa)->sat_addr.s_node = time.tv_sec;
AA_SAT(aa)->sat_addr.s_node = time_second;
}
/*

View File

@ -1,4 +1,4 @@
/* $NetBSD: pk_acct.c,v 1.22 2006/05/14 21:19:34 elad Exp $ */
/* $NetBSD: pk_acct.c,v 1.23 2006/06/07 22:34:00 kardel Exp $ */
/*
* Copyright (c) 1990, 1993
@ -74,7 +74,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: pk_acct.c,v 1.22 2006/05/14 21:19:34 elad Exp $");
__KERNEL_RCSID(0, "$NetBSD: pk_acct.c,v 1.23 2006/06/07 22:34:00 kardel Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -159,7 +159,7 @@ pk_acct(lcp)
if (sa -> x25_opts.op_flags & X25_REVERSE_CHARGE)
acbuf.x25acct_revcharge = 1;
acbuf.x25acct_stime = lcp -> lcd_stime;
acbuf.x25acct_etime = time.tv_sec - acbuf.x25acct_stime;
acbuf.x25acct_etime = time_second - acbuf.x25acct_stime;
acbuf.x25acct_uid = kauth_cred_getuid(curproc->p_cred);
acbuf.x25acct_psize = sa -> x25_opts.op_psize;
acbuf.x25acct_net = sa -> x25_net;

View File

@ -1,4 +1,4 @@
/* $NetBSD: pk_subr.c,v 1.31 2005/12/11 12:24:54 christos Exp $ */
/* $NetBSD: pk_subr.c,v 1.32 2006/06/07 22:34:00 kardel Exp $ */
/*
* Copyright (c) 1991, 1992, 1993
@ -78,7 +78,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: pk_subr.c,v 1.31 2005/12/11 12:24:54 christos Exp $");
__KERNEL_RCSID(0, "$NetBSD: pk_subr.c,v 1.32 2006/06/07 22:34:00 kardel Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -504,7 +504,7 @@ pk_assoc(pkp, lcp, sa)
sa->x25_opts.op_wsize = lcp->lcd_windowsize;
sa->x25_net = pkp->pk_xcp->xc_addr.x25_net;
lcp->lcd_flags |= sa->x25_opts.op_flags;
lcp->lcd_stime = time.tv_sec;
lcp->lcd_stime = time_second;
}
int

View File

@ -1,4 +1,4 @@
/* $NetBSD: if_arp.c,v 1.111 2006/05/25 21:33:12 bouyer Exp $ */
/* $NetBSD: if_arp.c,v 1.112 2006/06/07 22:34:00 kardel Exp $ */
/*-
* Copyright (c) 1998, 2000 The NetBSD Foundation, Inc.
@ -75,7 +75,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: if_arp.c,v 1.111 2006/05/25 21:33:12 bouyer Exp $");
__KERNEL_RCSID(0, "$NetBSD: if_arp.c,v 1.112 2006/06/07 22:34:00 kardel Exp $");
#include "opt_ddb.h"
#include "opt_inet.h"
@ -91,6 +91,7 @@ __KERNEL_RCSID(0, "$NetBSD: if_arp.c,v 1.111 2006/05/25 21:33:12 bouyer Exp $");
#include <sys/mbuf.h>
#include <sys/socket.h>
#include <sys/time.h>
#include <sys/timetc.h>
#include <sys/kernel.h>
#include <sys/errno.h>
#include <sys/ioctl.h>
@ -353,8 +354,8 @@ arptimer(void *arg)
nla = LIST_NEXT(la, la_list);
if (rt->rt_expire == 0)
continue;
if ((rt->rt_expire - time.tv_sec) < arpt_refresh &&
rt->rt_pksent > (time.tv_sec - arpt_keep)) {
if ((rt->rt_expire - time_second) < arpt_refresh &&
rt->rt_pksent > (time_second - arpt_keep)) {
/*
* If the entry has been used during since last
* refresh, try to renew it before deleting.
@ -363,7 +364,7 @@ arptimer(void *arg)
&SIN(rt->rt_ifa->ifa_addr)->sin_addr,
&SIN(rt_key(rt))->sin_addr,
LLADDR(rt->rt_ifp->if_sadl));
} else if (rt->rt_expire <= time.tv_sec)
} else if (rt->rt_expire <= time_second)
arptfree(la); /* timer has expired; clear */
}
@ -390,11 +391,18 @@ arp_rtrequest(int req, struct rtentry *rt, struct rt_addrinfo *info)
if (!arpinit_done) {
arpinit_done = 1;
/*
* We generate expiration times from time.tv_sec
* We generate expiration times from time_second
* so avoid accidently creating permanent routes.
*/
if (time.tv_sec == 0) {
if (time_second == 0) {
#ifdef __HAVE_TIMECOUNTER
struct timespec ts;
ts.tv_sec = 1;
ts.tv_nsec = 0;
tc_setclock(&ts);
#else /* !__HAVE_TIMECOUNTER */
time.tv_sec++;
#endif /* !__HAVE_TIMECOUNTER */
}
callout_init(&arptimer_ch);
callout_reset(&arptimer_ch, hz, arptimer, NULL);
@ -459,7 +467,7 @@ arp_rtrequest(int req, struct rtentry *rt, struct rt_addrinfo *info)
* it's a "permanent" route, so that routes cloned
* from it do not need their expiration time set.
*/
rt->rt_expire = time.tv_sec;
rt->rt_expire = time_second;
/*
* linklayers with particular link MTU limitation.
*/
@ -690,11 +698,11 @@ arpresolve(struct ifnet *ifp, struct rtentry *rt, struct mbuf *m,
* Check the address family and length is valid, the address
* is resolved; otherwise, try to resolve.
*/
if ((rt->rt_expire == 0 || rt->rt_expire > time.tv_sec) &&
if ((rt->rt_expire == 0 || rt->rt_expire > time_second) &&
sdl->sdl_family == AF_LINK && sdl->sdl_alen != 0) {
bcopy(LLADDR(sdl), desten,
min(sdl->sdl_alen, ifp->if_addrlen));
rt->rt_pksent = time.tv_sec; /* Time for last pkt sent */
rt->rt_pksent = time_second; /* Time for last pkt sent */
return 1;
}
/*
@ -722,13 +730,13 @@ arpresolve(struct ifnet *ifp, struct rtentry *rt, struct mbuf *m,
/* This should never happen. (Should it? -gwr) */
printf("arpresolve: unresolved and rt_expire == 0\n");
/* Set expiration time to now (expired). */
rt->rt_expire = time.tv_sec;
rt->rt_expire = time_second;
}
#endif
if (rt->rt_expire) {
rt->rt_flags &= ~RTF_REJECT;
if (la->la_asked == 0 || rt->rt_expire != time.tv_sec) {
rt->rt_expire = time.tv_sec;
if (la->la_asked == 0 || rt->rt_expire != time_second) {
rt->rt_expire = time_second;
if (la->la_asked++ < arp_maxtries)
arprequest(ifp,
&SIN(rt->rt_ifa->ifa_addr)->sin_addr,
@ -1056,7 +1064,7 @@ in_arpinput(struct mbuf *m)
bcopy((caddr_t)ar_sha(ah), LLADDR(sdl),
sdl->sdl_alen = ah->ar_hln);
if (rt->rt_expire)
rt->rt_expire = time.tv_sec + arpt_keep;
rt->rt_expire = time_second + arpt_keep;
rt->rt_flags &= ~RTF_REJECT;
la->la_asked = 0;

View File

@ -1,4 +1,4 @@
/* $NetBSD: in_gif.c,v 1.46 2005/12/11 12:24:57 christos Exp $ */
/* $NetBSD: in_gif.c,v 1.47 2006/06/07 22:34:00 kardel Exp $ */
/* $KAME: in_gif.c,v 1.66 2001/07/29 04:46:09 itojun Exp $ */
/*
@ -31,7 +31,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: in_gif.c,v 1.46 2005/12/11 12:24:57 christos Exp $");
__KERNEL_RCSID(0, "$NetBSD: in_gif.c,v 1.47 2006/06/07 22:34:00 kardel Exp $");
#include "opt_inet.h"
#include "opt_iso.h"
@ -197,7 +197,7 @@ in_gif_output(struct ifnet *ifp, int family, struct mbuf *m)
return ENOBUFS;
bcopy(&iphdr, mtod(m, struct ip *), sizeof(struct ip));
if (sc->gif_route_expire - time.tv_sec <= 0 ||
if (sc->gif_route_expire - time_second <= 0 ||
dst->sin_family != sin_dst->sin_family ||
!in_hosteq(dst->sin_addr, sin_dst->sin_addr)) {
/* cache route doesn't match */
@ -224,7 +224,7 @@ in_gif_output(struct ifnet *ifp, int family, struct mbuf *m)
return ENETUNREACH; /*XXX*/
}
sc->gif_route_expire = time.tv_sec + GIF_ROUTE_TTL;
sc->gif_route_expire = time_second + GIF_ROUTE_TTL;
}
error = ip_output(m, NULL, &sc->gif_ro, 0, NULL, NULL);

View File

@ -1,4 +1,4 @@
/* $NetBSD: ip_flow.c,v 1.32 2005/12/24 23:43:17 perry Exp $ */
/* $NetBSD: ip_flow.c,v 1.33 2006/06/07 22:34:01 kardel Exp $ */
/*-
* Copyright (c) 1998 The NetBSD Foundation, Inc.
@ -37,7 +37,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: ip_flow.c,v 1.32 2005/12/24 23:43:17 perry Exp $");
__KERNEL_RCSID(0, "$NetBSD: ip_flow.c,v 1.33 2006/06/07 22:34:01 kardel Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -406,7 +406,7 @@ ipflow_create(const struct route *ro, struct mbuf *m)
ipf->ipf_src = ip->ip_src;
ipf->ipf_tos = ip->ip_tos;
PRT_SLOW_ARM(ipf->ipf_timer, IPFLOW_TIMER);
ipf->ipf_start = time.tv_sec;
ipf->ipf_start = time_uptime;
/*
* Insert into the approriate bucket of the flow table.
*/

View File

@ -1,4 +1,4 @@
/* $NetBSD: ip_id.c,v 1.9 2005/12/11 12:24:57 christos Exp $ */
/* $NetBSD: ip_id.c,v 1.10 2006/06/07 22:34:01 kardel Exp $ */
/* $OpenBSD: ip_id.c,v 1.6 2002/03/15 18:19:52 millert Exp $ */
/*
@ -52,13 +52,11 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: ip_id.c,v 1.9 2005/12/11 12:24:57 christos Exp $");
__KERNEL_RCSID(0, "$NetBSD: ip_id.c,v 1.10 2006/06/07 22:34:01 kardel Exp $");
#include "opt_inet.h"
#include <sys/types.h>
#include <sys/param.h>
#include <sys/kernel.h>
#include <lib/libkern/libkern.h>
#include <net/if.h>
@ -163,7 +161,7 @@ ip_initid(void)
ru_g = pmod(RU_GEN, j, RU_N);
ru_counter = 0;
ru_reseed = time.tv_sec + RU_OUT;
ru_reseed = time_second + RU_OUT;
ru_msb = ru_msb == 0x8000 ? 0 : 0x8000;
}
@ -172,7 +170,7 @@ ip_randomid(void)
{
int i, n;
if (ru_counter >= RU_MAX || time.tv_sec > ru_reseed)
if (ru_counter >= RU_MAX || time_second > ru_reseed)
ip_initid();
#if 0

View File

@ -1,4 +1,4 @@
/* $NetBSD: ip_input.c,v 1.226 2006/05/08 18:50:12 liamjfoy Exp $ */
/* $NetBSD: ip_input.c,v 1.227 2006/06/07 22:34:01 kardel Exp $ */
/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@ -98,7 +98,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: ip_input.c,v 1.226 2006/05/08 18:50:12 liamjfoy Exp $");
__KERNEL_RCSID(0, "$NetBSD: ip_input.c,v 1.227 2006/06/07 22:34:01 kardel Exp $");
#include "opt_inet.h"
#include "opt_gateway.h"
@ -414,7 +414,7 @@ ip_init(void)
for (i = 0; i < IPREASS_NHASH; i++)
LIST_INIT(&ipq[i]);
ip_id = time.tv_sec & 0xfffff;
ip_id = time_second & 0xfffff;
ipintrq.ifq_maxlen = ipqmaxlen;
ip_nmbclusters_changed();

View File

@ -1,4 +1,4 @@
/* $NetBSD: tcp_input.c,v 1.242 2006/05/27 13:35:20 bouyer Exp $ */
/* $NetBSD: tcp_input.c,v 1.243 2006/06/07 22:34:01 kardel Exp $ */
/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@ -150,7 +150,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: tcp_input.c,v 1.242 2006/05/27 13:35:20 bouyer Exp $");
__KERNEL_RCSID(0, "$NetBSD: tcp_input.c,v 1.243 2006/06/07 22:34:01 kardel Exp $");
#include "opt_inet.h"
#include "opt_ipsec.h"
@ -970,7 +970,6 @@ tcp_input(struct mbuf *m, ...)
#ifdef TCP_DEBUG
short ostate = 0;
#endif
int iss = 0;
u_long tiwin;
struct tcp_opt_info opti;
int off, iphlen;
@ -2026,7 +2025,6 @@ after_listen:
if (tiflags & TH_SYN &&
tp->t_state == TCPS_TIME_WAIT &&
SEQ_GT(th->th_seq, tp->rcv_nxt)) {
iss = tcp_new_iss(tp, tp->snd_nxt);
tp = tcp_close(tp);
TCP_FIELDS_TO_NET(th);
goto findpcb;

View File

@ -1,4 +1,4 @@
/* $NetBSD: icmp6.c,v 1.116 2006/04/15 00:24:12 christos Exp $ */
/* $NetBSD: icmp6.c,v 1.117 2006/06/07 22:34:02 kardel Exp $ */
/* $KAME: icmp6.c,v 1.217 2001/06/20 15:03:29 jinmei Exp $ */
/*
@ -62,7 +62,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: icmp6.c,v 1.116 2006/04/15 00:24:12 christos Exp $");
__KERNEL_RCSID(0, "$NetBSD: icmp6.c,v 1.117 2006/06/07 22:34:02 kardel Exp $");
#include "opt_inet.h"
#include "opt_ipsec.h"
@ -1850,8 +1850,9 @@ ni6_store_addrs(ni6, nni6, ifp0, resid)
ltime = ND6_INFINITE_LIFETIME;
else {
if (ifa6->ia6_lifetime.ia6t_expire >
time.tv_sec)
ltime = ifa6->ia6_lifetime.ia6t_expire - time.tv_sec;
time_second)
ltime = ifa6->ia6_lifetime.ia6t_expire -
time_second;
else
ltime = 0;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: in6.c,v 1.107 2006/06/03 06:56:43 dogcow Exp $ */
/* $NetBSD: in6.c,v 1.108 2006/06/07 22:34:03 kardel Exp $ */
/* $KAME: in6.c,v 1.198 2001/07/18 09:12:38 itojun Exp $ */
/*
@ -62,7 +62,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: in6.c,v 1.107 2006/06/03 06:56:43 dogcow Exp $");
__KERNEL_RCSID(0, "$NetBSD: in6.c,v 1.108 2006/06/07 22:34:03 kardel Exp $");
#include "opt_inet.h"
#include "opt_pfil_hooks.h"
@ -506,11 +506,11 @@ in6_control(so, cmd, data, ifp, p)
/* sanity for overflow - beware unsigned */
lt = &ifr->ifr_ifru.ifru_lifetime;
if (lt->ia6t_vltime != ND6_INFINITE_LIFETIME
&& lt->ia6t_vltime + time.tv_sec < time.tv_sec) {
&& lt->ia6t_vltime + time_second < time_second) {
return EINVAL;
}
if (lt->ia6t_pltime != ND6_INFINITE_LIFETIME
&& lt->ia6t_pltime + time.tv_sec < time.tv_sec) {
&& lt->ia6t_pltime + time_second < time_second) {
return EINVAL;
}
break;
@ -574,8 +574,8 @@ in6_control(so, cmd, data, ifp, p)
* XXX: adjust expiration time assuming time_t is
* signed.
*/
maxexpire = (-1) &
~(1 << ((sizeof(maxexpire) * 8) - 1));
maxexpire = ((time_t)~0) &
~((time_t)1 << ((sizeof(maxexpire) * 8) - 1));
if (ia->ia6_lifetime.ia6t_vltime <
maxexpire - ia->ia6_updatetime) {
retlt->ia6t_expire = ia->ia6_updatetime +
@ -592,8 +592,8 @@ in6_control(so, cmd, data, ifp, p)
* XXX: adjust expiration time assuming time_t is
* signed.
*/
maxexpire = (-1) &
~(1 << ((sizeof(maxexpire) * 8) - 1));
maxexpire = ((time_t)~0) &
~((time_t)1 << ((sizeof(maxexpire) * 8) - 1));
if (ia->ia6_lifetime.ia6t_pltime <
maxexpire - ia->ia6_updatetime) {
retlt->ia6t_preferred = ia->ia6_updatetime +
@ -608,12 +608,12 @@ in6_control(so, cmd, data, ifp, p)
/* for sanity */
if (ia->ia6_lifetime.ia6t_vltime != ND6_INFINITE_LIFETIME) {
ia->ia6_lifetime.ia6t_expire =
time.tv_sec + ia->ia6_lifetime.ia6t_vltime;
time_second + ia->ia6_lifetime.ia6t_vltime;
} else
ia->ia6_lifetime.ia6t_expire = 0;
if (ia->ia6_lifetime.ia6t_pltime != ND6_INFINITE_LIFETIME) {
ia->ia6_lifetime.ia6t_preferred =
time.tv_sec + ia->ia6_lifetime.ia6t_pltime;
time_second + ia->ia6_lifetime.ia6t_pltime;
} else
ia->ia6_lifetime.ia6t_preferred = 0;
break;
@ -931,7 +931,7 @@ in6_update_ifa(ifp, ifra, ia, flags)
ia->ia_ifa.ifa_addr = (struct sockaddr *)&ia->ia_addr;
ia->ia_addr.sin6_family = AF_INET6;
ia->ia_addr.sin6_len = sizeof(ia->ia_addr);
ia->ia6_createtime = time.tv_sec;
ia->ia6_createtime = time_second;
if ((ifp->if_flags & (IFF_POINTOPOINT | IFF_LOOPBACK)) != 0) {
/*
* XXX: some functions expect that ifa_dstaddr is not
@ -962,7 +962,7 @@ in6_update_ifa(ifp, ifra, ia, flags)
}
/* update timestamp */
ia->ia6_updatetime = time.tv_sec;
ia->ia6_updatetime = time_second;
/* set prefix mask */
if (ifra->ifra_prefixmask.sin6_len) {
@ -1009,12 +1009,12 @@ in6_update_ifa(ifp, ifra, ia, flags)
ia->ia6_lifetime = ifra->ifra_lifetime;
if (ia->ia6_lifetime.ia6t_vltime != ND6_INFINITE_LIFETIME) {
ia->ia6_lifetime.ia6t_expire =
time.tv_sec + ia->ia6_lifetime.ia6t_vltime;
time_second + ia->ia6_lifetime.ia6t_vltime;
} else
ia->ia6_lifetime.ia6t_expire = 0;
if (ia->ia6_lifetime.ia6t_pltime != ND6_INFINITE_LIFETIME) {
ia->ia6_lifetime.ia6t_preferred =
time.tv_sec + ia->ia6_lifetime.ia6t_pltime;
time_second + ia->ia6_lifetime.ia6t_pltime;
} else
ia->ia6_lifetime.ia6t_preferred = 0;
@ -1032,7 +1032,7 @@ in6_update_ifa(ifp, ifra, ia, flags)
*/
if ((ifra->ifra_flags & IN6_IFF_DEPRECATED) != 0) {
ia->ia6_lifetime.ia6t_pltime = 0;
ia->ia6_lifetime.ia6t_preferred = time.tv_sec;
ia->ia6_lifetime.ia6t_preferred = time_second;
}
/*

View File

@ -1,4 +1,4 @@
/* $NetBSD: in6.h,v 1.55 2006/05/07 23:41:17 rpaulo Exp $ */
/* $NetBSD: in6.h,v 1.56 2006/06/07 22:34:03 kardel Exp $ */
/* $KAME: in6.h,v 1.83 2001/03/29 02:55:07 jinmei Exp $ */
/*
@ -366,11 +366,11 @@ extern const struct in6_addr in6addr_linklocal_allrouters;
#define IFA6_IS_DEPRECATED(a) \
((a)->ia6_lifetime.ia6t_pltime != ND6_INFINITE_LIFETIME && \
(u_int32_t)((time.tv_sec - (a)->ia6_updatetime)) > \
(u_int32_t)((time_second - (a)->ia6_updatetime)) > \
(a)->ia6_lifetime.ia6t_pltime)
#define IFA6_IS_INVALID(a) \
((a)->ia6_lifetime.ia6t_vltime != ND6_INFINITE_LIFETIME && \
(u_int32_t)((time.tv_sec - (a)->ia6_updatetime)) > \
(u_int32_t)((time_second - (a)->ia6_updatetime)) > \
(a)->ia6_lifetime.ia6t_vltime)
#endif

View File

@ -1,4 +1,4 @@
/* $NetBSD: in6_gif.c,v 1.44 2005/12/11 12:25:02 christos Exp $ */
/* $NetBSD: in6_gif.c,v 1.45 2006/06/07 22:34:03 kardel Exp $ */
/* $KAME: in6_gif.c,v 1.62 2001/07/29 04:27:25 itojun Exp $ */
/*
@ -31,7 +31,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: in6_gif.c,v 1.44 2005/12/11 12:25:02 christos Exp $");
__KERNEL_RCSID(0, "$NetBSD: in6_gif.c,v 1.45 2006/06/07 22:34:03 kardel Exp $");
#include "opt_inet.h"
#include "opt_iso.h"
@ -183,7 +183,7 @@ in6_gif_output(ifp, family, m)
ip6->ip6_flow &= ~ntohl(0xff00000);
ip6->ip6_flow |= htonl((u_int32_t)otos << 20);
if (sc->gif_route_expire - time.tv_sec <= 0 ||
if (sc->gif_route_expire - time_second <= 0 ||
dst->sin6_family != sin6_dst->sin6_family ||
!IN6_ARE_ADDR_EQUAL(&dst->sin6_addr, &sin6_dst->sin6_addr)) {
/* cache route doesn't match */
@ -210,7 +210,7 @@ in6_gif_output(ifp, family, m)
return ENETUNREACH; /* XXX */
}
sc->gif_route_expire = time.tv_sec + GIF_ROUTE_TTL;
sc->gif_route_expire = time_second + GIF_ROUTE_TTL;
}
#ifdef IPV6_MINMTU

View File

@ -1,4 +1,4 @@
/* $NetBSD: ip6_forward.c,v 1.47 2006/01/21 00:15:36 rpaulo Exp $ */
/* $NetBSD: ip6_forward.c,v 1.48 2006/06/07 22:34:03 kardel Exp $ */
/* $KAME: ip6_forward.c,v 1.109 2002/09/11 08:10:17 sakane Exp $ */
/*
@ -31,7 +31,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: ip6_forward.c,v 1.47 2006/01/21 00:15:36 rpaulo Exp $");
__KERNEL_RCSID(0, "$NetBSD: ip6_forward.c,v 1.48 2006/06/07 22:34:03 kardel Exp $");
#include "opt_ipsec.h"
#include "opt_pfil_hooks.h"
@ -134,8 +134,8 @@ ip6_forward(m, srcrt)
IN6_IS_ADDR_UNSPECIFIED(&ip6->ip6_src)) {
ip6stat.ip6s_cantforward++;
/* XXX in6_ifstat_inc(rt->rt_ifp, ifs6_in_discard) */
if (ip6_log_time + ip6_log_interval < time.tv_sec) {
ip6_log_time = time.tv_sec;
if (ip6_log_time + ip6_log_interval < time_second) {
ip6_log_time = time_second;
log(LOG_DEBUG,
"cannot forward "
"from %s to %s nxt %d received on %s\n",
@ -418,8 +418,8 @@ ip6_forward(m, srcrt)
ip6stat.ip6s_badscope++;
in6_ifstat_inc(rt->rt_ifp, ifs6_in_discard);
if (ip6_log_time + ip6_log_interval < time.tv_sec) {
ip6_log_time = time.tv_sec;
if (ip6_log_time + ip6_log_interval < time_second) {
ip6_log_time = time_second;
log(LOG_DEBUG,
"cannot forward "
"src %s, dst %s, nxt %d, rcvif %s, outif %s\n",

View File

@ -1,4 +1,4 @@
/* $NetBSD: ip6_id.c,v 1.14 2005/12/11 12:25:02 christos Exp $ */
/* $NetBSD: ip6_id.c,v 1.15 2006/06/07 22:34:03 kardel Exp $ */
/* $KAME: ip6_id.c,v 1.8 2003/09/06 13:41:06 itojun Exp $ */
/* $OpenBSD: ip_id.c,v 1.6 2002/03/15 18:19:52 millert Exp $ */
@ -82,11 +82,9 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: ip6_id.c,v 1.14 2005/12/11 12:25:02 christos Exp $");
__KERNEL_RCSID(0, "$NetBSD: ip6_id.c,v 1.15 2006/06/07 22:34:03 kardel Exp $");
#include <sys/types.h>
#include <sys/param.h>
#include <sys/kernel.h>
#include <lib/libkern/libkern.h>
#include <net/if.h>
@ -211,7 +209,7 @@ initid(struct randomtab *p)
p->ru_g = pmod(p->ru_gen, j, p->ru_n);
p->ru_counter = 0;
p->ru_reseed = time.tv_sec + p->ru_out;
p->ru_reseed = time_second + p->ru_out;
p->ru_msb = p->ru_msb ? 0 : (1U << (p->ru_bits - 1));
}
@ -220,7 +218,7 @@ randomid(struct randomtab *p)
{
int i, n;
if (p->ru_counter >= p->ru_max || time.tv_sec > p->ru_reseed)
if (p->ru_counter >= p->ru_max || time_second > p->ru_reseed)
initid(p);
/* Skip a random number of ids */

View File

@ -1,4 +1,4 @@
/* $NetBSD: ip6_mroute.c,v 1.71 2006/03/05 23:47:08 rpaulo Exp $ */
/* $NetBSD: ip6_mroute.c,v 1.72 2006/06/07 22:34:03 kardel Exp $ */
/* $KAME: ip6_mroute.c,v 1.49 2001/07/25 09:21:18 jinmei Exp $ */
/*
@ -117,7 +117,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: ip6_mroute.c,v 1.71 2006/03/05 23:47:08 rpaulo Exp $");
__KERNEL_RCSID(0, "$NetBSD: ip6_mroute.c,v 1.72 2006/06/07 22:34:03 kardel Exp $");
#include "opt_inet.h"
#include "opt_mrouting.h"
@ -1086,8 +1086,8 @@ ip6_mforward(ip6, ifp, m)
*/
if (IN6_IS_ADDR_UNSPECIFIED(&ip6->ip6_src)) {
ip6stat.ip6s_cantforward++;
if (ip6_log_time + ip6_log_interval < time.tv_sec) {
ip6_log_time = time.tv_sec;
if (ip6_log_time + ip6_log_interval < time_second) {
ip6_log_time = time_second;
log(LOG_DEBUG,
"cannot forward "
"from %s to %s nxt %d received on %s\n",

View File

@ -1,4 +1,4 @@
/* $NetBSD: ipsec.c,v 1.107 2006/02/25 02:28:58 wiz Exp $ */
/* $NetBSD: ipsec.c,v 1.108 2006/06/07 22:34:03 kardel Exp $ */
/* $KAME: ipsec.c,v 1.136 2002/05/19 00:36:39 itojun Exp $ */
/*
@ -35,7 +35,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: ipsec.c,v 1.107 2006/02/25 02:28:58 wiz Exp $");
__KERNEL_RCSID(0, "$NetBSD: ipsec.c,v 1.108 2006/06/07 22:34:03 kardel Exp $");
#include "opt_inet.h"
#include "opt_ipsec.h"
@ -183,6 +183,7 @@ ipsec_checkpcbcache(m, pcbsp, dir)
int dir;
{
struct secpolicyindex spidx;
struct bintime bt;
switch (dir) {
case IPSEC_DIR_INBOUND:
@ -233,7 +234,8 @@ ipsec_checkpcbcache(m, pcbsp, dir)
*/
}
pcbsp->sp_cache[dir].cachesp->lastused = mono_time.tv_sec;
getbinuptime(&bt);
pcbsp->sp_cache[dir].cachesp->lastused = bt.sec;
pcbsp->sp_cache[dir].cachesp->refcnt++;
KEYDEBUG(KEYDEBUG_IPSEC_STAMP,
printf("DP ipsec_checkpcbcache cause refcnt++:%d SP:%p\n",

View File

@ -1,4 +1,4 @@
/* $NetBSD: nd6.c,v 1.102 2006/05/18 09:05:51 liamjfoy Exp $ */
/* $NetBSD: nd6.c,v 1.103 2006/06/07 22:34:04 kardel Exp $ */
/* $KAME: nd6.c,v 1.279 2002/06/08 11:16:51 itojun Exp $ */
/*
@ -31,7 +31,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: nd6.c,v 1.102 2006/05/18 09:05:51 liamjfoy Exp $");
__KERNEL_RCSID(0, "$NetBSD: nd6.c,v 1.103 2006/06/07 22:34:04 kardel Exp $");
#include "opt_ipsec.h"
@ -399,7 +399,7 @@ nd6_llinfo_settimer(ln, xtick)
ln->ln_ntick = 0;
callout_stop(&ln->ln_timer_ch);
} else {
ln->ln_expire = time.tv_sec + xtick / hz;
ln->ln_expire = time_second + xtick / hz;
if (xtick > INT_MAX) {
ln->ln_ntick = xtick - INT_MAX;
callout_reset(&ln->ln_timer_ch, INT_MAX,
@ -540,7 +540,7 @@ nd6_timer(ignored_arg)
/* expire default router list */
dr = TAILQ_FIRST(&nd_defrouter);
while (dr) {
if (dr->expire && dr->expire < time.tv_sec) {
if (dr->expire && dr->expire < time_second) {
struct nd_defrouter *t;
t = TAILQ_NEXT(dr, dr_entry);
defrtrlist_del(dr);
@ -631,7 +631,7 @@ nd6_timer(ignored_arg)
* prefix is not necessary.
*/
if (pr->ndpr_vltime != ND6_INFINITE_LIFETIME &&
time.tv_sec - pr->ndpr_lastupdate > pr->ndpr_vltime) {
time_second - pr->ndpr_lastupdate > pr->ndpr_vltime) {
struct nd_prefix *t;
t = pr->ndpr_next;
@ -1020,9 +1020,9 @@ nd6_free(rt, gc)
* XXX: the check for ln_state would be redundant,
* but we intentionally keep it just in case.
*/
if (dr->expire > time.tv_sec)
if (dr->expire > time_second)
nd6_llinfo_settimer(ln,
(dr->expire - time.tv_sec) * hz);
(dr->expire - time_second) * hz);
else
nd6_llinfo_settimer(ln, (long)nd6_gctimer * hz);
splx(s);

View File

@ -1,4 +1,4 @@
/* $NetBSD: nd6_rtr.c,v 1.58 2006/03/20 12:13:05 rpaulo Exp $ */
/* $NetBSD: nd6_rtr.c,v 1.59 2006/06/07 22:34:04 kardel Exp $ */
/* $KAME: nd6_rtr.c,v 1.95 2001/02/07 08:09:47 itojun Exp $ */
/*
@ -31,7 +31,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: nd6_rtr.c,v 1.58 2006/03/20 12:13:05 rpaulo Exp $");
__KERNEL_RCSID(0, "$NetBSD: nd6_rtr.c,v 1.59 2006/06/07 22:34:04 kardel Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -270,7 +270,7 @@ nd6_ra_input(m, off, icmp6len)
drtr.rtaddr = saddr6;
drtr.flags = nd_ra->nd_ra_flags_reserved;
drtr.rtlifetime = ntohs(nd_ra->nd_ra_router_lifetime);
drtr.expire = time.tv_sec + drtr.rtlifetime;
drtr.expire = time_second + drtr.rtlifetime;
drtr.ifp = ifp;
/* unspecified or not? (RFC 2461 6.3.4) */
if (advreachable) {
@ -913,7 +913,7 @@ nd6_prelist_add(pr, dr, newp)
free(new, M_IP6NDP);
return(error);
}
new->ndpr_lastupdate = time.tv_sec;
new->ndpr_lastupdate = time_second;
if (newp != NULL)
*newp = new;
@ -1044,7 +1044,7 @@ prelist_update(new, dr, m, mcast)
pr->ndpr_vltime = new->ndpr_vltime;
pr->ndpr_pltime = new->ndpr_pltime;
(void)in6_init_prefix_ltimes(pr); /* XXX error case? */
pr->ndpr_lastupdate = time.tv_sec;
pr->ndpr_lastupdate = time_second;
}
if (new->ndpr_raf_onlink &&
@ -1135,7 +1135,6 @@ prelist_update(new, dr, m, mcast)
{
struct in6_ifaddr *ifa6;
u_int32_t remaininglifetime;
long time_second = time.tv_sec;
if (ifa->ifa_addr->sa_family != AF_INET6)
continue;
@ -1252,7 +1251,7 @@ prelist_update(new, dr, m, mcast)
}
ifa6->ia6_lifetime = lt6_tmp;
ifa6->ia6_updatetime = time.tv_sec;
ifa6->ia6_updatetime = time_second;
}
if (ia6_match == NULL && new->ndpr_vltime) {
int ifidlen;
@ -1900,7 +1899,6 @@ in6_tmpifadd(ia0, forcegen, dad_delay)
int updateflags;
u_int32_t randid[2];
u_int32_t vltime0, pltime0;
time_t time_second = (time_t)time.tv_sec;
memset(&ifra, 0, sizeof(ifra));
strncpy(ifra.ifra_name, if_name(ifp), sizeof(ifra.ifra_name));
@ -2031,11 +2029,11 @@ in6_init_prefix_ltimes(struct nd_prefix *ndpr)
if (ndpr->ndpr_pltime == ND6_INFINITE_LIFETIME)
ndpr->ndpr_preferred = 0;
else
ndpr->ndpr_preferred = time.tv_sec + ndpr->ndpr_pltime;
ndpr->ndpr_preferred = time_second + ndpr->ndpr_pltime;
if (ndpr->ndpr_vltime == ND6_INFINITE_LIFETIME)
ndpr->ndpr_expire = 0;
else
ndpr->ndpr_expire = time.tv_sec + ndpr->ndpr_vltime;
ndpr->ndpr_expire = time_second + ndpr->ndpr_vltime;
return 0;
}
@ -2049,7 +2047,7 @@ in6_init_address_ltimes(struct nd_prefix *new, struct in6_addrlifetime *lt6)
if (lt6->ia6t_vltime == ND6_INFINITE_LIFETIME)
lt6->ia6t_expire = 0;
else {
lt6->ia6t_expire = time.tv_sec;
lt6->ia6t_expire = time_second;
lt6->ia6t_expire += lt6->ia6t_vltime;
}
@ -2057,7 +2055,7 @@ in6_init_address_ltimes(struct nd_prefix *new, struct in6_addrlifetime *lt6)
if (lt6->ia6t_pltime == ND6_INFINITE_LIFETIME)
lt6->ia6t_preferred = 0;
else {
lt6->ia6t_preferred = time.tv_sec;
lt6->ia6t_preferred = time_second;
lt6->ia6t_preferred += lt6->ia6t_pltime;
}
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: ipsec_osdep.h,v 1.17 2006/02/16 20:17:20 perry Exp $ */
/* $NetBSD: ipsec_osdep.h,v 1.18 2006/06/07 22:34:04 kardel Exp $ */
/* $FreeBSD: /repoman/r/ncvs/src/sys/netipsec/ipsec_osdep.h,v 1.1 2003/09/29 22:47:45 sam Exp $ */
/*
@ -166,9 +166,10 @@ if_handoff(struct ifqueue *ifq, struct mbuf *m, struct ifnet *ifp, int adjust)
/*
* 7. Elapsed Time: time_second as time in seconds.
* Original FreeBSD fast-ipsec code references a FreeBSD kernel global,
* time_second(). NetBSD: kludge #define to use time_mono_time.tv_sec.
* time_second().
* (Non-timecounter) NetBSD: kludge #define to use time_mono_time.tv_sec.
*/
#ifdef __NetBSD__
#if defined(__NetBSD__) && !defined(__HAVE_TIMECOUNTER)
#include <sys/kernel.h>
#define time_second mono_time.tv_sec
#endif /* __NetBSD__ */

View File

@ -27,7 +27,7 @@
* i4b_global.h - i4b global include file
* --------------------------------------
*
* $Id: i4b_global.h,v 1.6 2005/12/10 23:51:50 elad Exp $
* $Id: i4b_global.h,v 1.7 2006/06/07 22:34:04 kardel Exp $
*
* $FreeBSD$
*
@ -69,13 +69,21 @@
#endif /* >= 3 */
#endif /* __FreeBSD__ */
#if defined(__NetBSD__) || defined (__OpenBSD__) || defined(__bsdi__)
#if defined(__NetBSD__) /* after timecounter merge */
#define TIMEOUT_FUNC_T void *
#define SECOND time_second
#define MICROTIME(x) getmicrotime(&(x))
#endif /* __NetBSD__ */
#if defined (__OpenBSD__) || defined(__bsdi__)
#define TIMEOUT_FUNC_T void *
#define SECOND time.tv_sec
#define MICROTIME(x) microtime(&(x))
#endif /* __NetBSD__ */
#endif /* __OpenBSD__ */
/*----------------*/
/* timer handling */

View File

@ -1,4 +1,4 @@
/* $NetBSD: i4b_l4mgmt.c,v 1.15 2005/12/11 12:25:06 christos Exp $ */
/* $NetBSD: i4b_l4mgmt.c,v 1.16 2006/06/07 22:34:04 kardel Exp $ */
/*
* Copyright (c) 1997, 2000 Hellmuth Michaelis. All rights reserved.
@ -29,7 +29,7 @@
* i4b_l4mgmt.c - layer 4 calldescriptor management utilites
* -----------------------------------------------------------
*
* $Id: i4b_l4mgmt.c,v 1.15 2005/12/11 12:25:06 christos Exp $
* $Id: i4b_l4mgmt.c,v 1.16 2006/06/07 22:34:04 kardel Exp $
*
* $FreeBSD$
*
@ -38,7 +38,7 @@
*---------------------------------------------------------------------------*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: i4b_l4mgmt.c,v 1.15 2005/12/11 12:25:06 christos Exp $");
__KERNEL_RCSID(0, "$NetBSD: i4b_l4mgmt.c,v 1.16 2006/06/07 22:34:04 kardel Exp $");
#include "isdn.h"
@ -295,6 +295,7 @@ get_rand_cr(int unit)
register int i, j;
static u_char val, retval;
static int called = 42;
struct timeval t;
val += ++called;
@ -311,11 +312,12 @@ get_rand_cr(int unit)
#endif /* RANDOMDEV */
#else
getmicrotime(&t);
val |= unit+i;
val <<= i;
val ^= (time.tv_sec >> 8) ^ time.tv_usec;
val ^= (t.tv_sec >> 8) ^ t.tv_usec;
val <<= i;
val ^= time.tv_sec ^ (time.tv_usec >> 8);
val ^= t.tv_sec ^ (t.tv_usec >> 8);
#endif
retval = val & 0x7f;

View File

@ -27,7 +27,7 @@
* i4b_tei.c - tei handling procedures
* -----------------------------------
*
* $Id: i4b_tei.c,v 1.8 2005/12/11 12:25:06 christos Exp $
* $Id: i4b_tei.c,v 1.9 2006/06/07 22:34:04 kardel Exp $
*
* $FreeBSD$
*
@ -36,7 +36,7 @@
*---------------------------------------------------------------------------*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: i4b_tei.c,v 1.8 2005/12/11 12:25:06 christos Exp $");
__KERNEL_RCSID(0, "$NetBSD: i4b_tei.c,v 1.9 2006/06/07 22:34:04 kardel Exp $");
#ifdef __FreeBSD__
#include "i4bq921.h"
@ -312,6 +312,7 @@ i4b_make_rand_ri(l2_softc_t *l2sc)
register u_short val;
register int i;
static int called = 42;
struct timeval t;
val = (l2sc->last_rih << 8) | l2sc->last_ril;
@ -319,11 +320,12 @@ i4b_make_rand_ri(l2_softc_t *l2sc)
for(i=0; i < 50 ; i++, val++)
{
getmicrotime(&t);
val |= l2sc->drv->isdnif+i;
val <<= i;
val ^= (time.tv_sec >> 16) ^ time.tv_usec;
val ^= (t.tv_sec >> 16) ^ t.tv_usec;
val <<= i;
val ^= time.tv_sec ^ (time.tv_usec >> 16);
val ^= t.tv_sec ^ (t.tv_usec >> 16);
if(val != 0 && val != 0xffff)
break;

View File

@ -1,4 +1,4 @@
/* $NetBSD: if_eon.c,v 1.48 2005/12/11 12:25:12 christos Exp $ */
/* $NetBSD: if_eon.c,v 1.49 2006/06/07 22:34:04 kardel Exp $ */
/*-
* Copyright (c) 1991, 1993
@ -67,7 +67,7 @@ SOFTWARE.
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: if_eon.c,v 1.48 2005/12/11 12:25:12 christos Exp $");
__KERNEL_RCSID(0, "$NetBSD: if_eon.c,v 1.49 2006/06/07 22:34:04 kardel Exp $");
#include "opt_eon.h"
@ -109,8 +109,6 @@ __KERNEL_RCSID(0, "$NetBSD: if_eon.c,v 1.48 2005/12/11 12:25:12 christos Exp $")
#include <machine/stdarg.h>
extern struct timeval time;
#define EOK 0
struct ifnet eonif[1];

View File

@ -1,4 +1,4 @@
/* $NetBSD: iso_snpac.c,v 1.35 2006/05/14 21:19:34 elad Exp $ */
/* $NetBSD: iso_snpac.c,v 1.36 2006/06/07 22:34:04 kardel Exp $ */
/*-
* Copyright (c) 1991, 1993
@ -59,7 +59,7 @@ SOFTWARE.
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: iso_snpac.c,v 1.35 2006/05/14 21:19:34 elad Exp $");
__KERNEL_RCSID(0, "$NetBSD: iso_snpac.c,v 1.36 2006/06/07 22:34:04 kardel Exp $");
#include "opt_iso.h"
#ifdef ISO
@ -474,7 +474,7 @@ add:
}
if ((lc = (struct llinfo_llc *) rt->rt_llinfo) == 0)
panic("snpac_rtrequest");
rt->rt_rmx.rmx_expire = ht + time.tv_sec;
rt->rt_rmx.rmx_expire = ht + time_second;
lc->lc_flags = SNPA_VALID | type;
if ((type & SNPA_IS) && !(iso_systype & SNPA_IS))
snpac_logdefis(rt);
@ -627,7 +627,8 @@ snpac_age(void *v)
nlc = lc->lc_list.le_next;
if (lc->lc_flags & SNPA_VALID) {
rt = lc->lc_rt;
if (rt->rt_rmx.rmx_expire && rt->rt_rmx.rmx_expire < time.tv_sec)
if (rt->rt_rmx.rmx_expire &&
rt->rt_rmx.rmx_expire < time_second)
snpac_free(lc);
}
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: tp_input.c,v 1.23 2005/12/11 12:25:12 christos Exp $ */
/* $NetBSD: tp_input.c,v 1.24 2006/06/07 22:34:04 kardel Exp $ */
/*-
* Copyright (c) 1991, 1993
@ -79,7 +79,7 @@ SOFTWARE.
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: tp_input.c,v 1.23 2005/12/11 12:25:12 christos Exp $");
__KERNEL_RCSID(0, "$NetBSD: tp_input.c,v 1.24 2006/06/07 22:34:04 kardel Exp $");
#include "opt_iso.h"
@ -1443,7 +1443,7 @@ again:
#ifdef ARGO_DEBUG
if (argo_debug[D_DROP]) {
if (time.tv_usec & 0x4 &&
if (time_second & 0x4 &&
hdr->tpdu_DTseq & 0x1) {
IncStat(ts_ydebug);
goto discard;

View File

@ -1,4 +1,4 @@
/* $NetBSD: tp_iso.c,v 1.20 2005/12/11 12:25:12 christos Exp $ */
/* $NetBSD: tp_iso.c,v 1.21 2006/06/07 22:34:04 kardel Exp $ */
/*-
* Copyright (c) 1991, 1993
@ -75,7 +75,7 @@ SOFTWARE.
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: tp_iso.c,v 1.20 2005/12/11 12:25:12 christos Exp $");
__KERNEL_RCSID(0, "$NetBSD: tp_iso.c,v 1.21 2006/06/07 22:34:04 kardel Exp $");
#include "opt_iso.h"
#ifdef ISO
@ -548,7 +548,10 @@ tpclnp_input(struct mbuf *m, ...)
#ifdef ARGO_DEBUG
if (argo_debug[D_QUENCH]) {{
if (time.tv_usec & 0x4 && time.tv_usec & 0x40) {
struct timeval now;
getmicrotime(&now);
if (now.tv_usec & 0x4 && now.tv_usec & 0x40) {
printf("tpclnp_input: FAKING %s\n",
tp_stat.ts_pkt_rcvd & 0x1 ? "QUENCH" : "QUENCH2");
if (tp_stat.ts_pkt_rcvd & 0x1)

View File

@ -1,4 +1,4 @@
/* $NetBSD: tp_meas.c,v 1.12 2005/12/11 12:25:12 christos Exp $ */
/* $NetBSD: tp_meas.c,v 1.13 2006/06/07 22:34:04 kardel Exp $ */
/*-
* Copyright (c) 1991, 1993
@ -63,7 +63,7 @@ SOFTWARE.
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: tp_meas.c,v 1.12 2005/12/11 12:25:12 christos Exp $");
__KERNEL_RCSID(0, "$NetBSD: tp_meas.c,v 1.13 2006/06/07 22:34:04 kardel Exp $");
#include <sys/types.h>
#include <sys/time.h>
@ -71,8 +71,6 @@ __KERNEL_RCSID(0, "$NetBSD: tp_meas.c,v 1.12 2005/12/11 12:25:12 christos Exp $"
#include <netiso/argo_debug.h>
#include <netiso/tp_meas.h>
extern struct timeval time;
#ifdef TP_PERF_MEAS
int tp_Measn = 0;
struct tp_Meas tp_Meas[TPMEASN];
@ -112,8 +110,7 @@ Tpmeas(u_int ref, u_int kind, struct timeval *timev, u_int seq, u_int win,
if (kind == TPtime_from_ll)
bcopy((caddr_t) timev, (caddr_t) & tpm->tpm_time, sizeof(struct timeval));
else
bcopy((caddr_t) & time,
(caddr_t) & tpm->tpm_time, sizeof(struct timeval));
getmicrotime(& tpm->tpm_time);
tpm->tpm_seq = seq;
tpm->tpm_window = win;
tpm->tpm_size = size;

Some files were not shown because too many files have changed in this diff Show More