diff options
29 files changed, 29 insertions, 414 deletions
diff --git a/sys/altq/altq_subr.c b/sys/altq/altq_subr.c index fefd45d5158..5fa744837ff 100644 --- a/sys/altq/altq_subr.c +++ b/sys/altq/altq_subr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: altq_subr.c,v 1.28 2011/10/07 17:10:08 henning Exp $ */ +/* $OpenBSD: altq_subr.c,v 1.29 2012/11/05 19:39:34 miod Exp $ */ /* $KAME: altq_subr.c,v 1.11 2002/01/11 08:11:49 kjc Exp $ */ /* @@ -582,14 +582,12 @@ u_int32_t machclk_per_tick = 0; void init_machclk(void) { -#if defined(__HAVE_TIMECOUNTER) /* * If we have timecounters, microtime is good enough and we can * avoid problems on machines with variable cycle counter * frequencies. */ machclk_tc = 1; -#endif if (machclk_tc == 1) { /* emulate 256MHz using microtime() */ diff --git a/sys/arch/alpha/include/_types.h b/sys/arch/alpha/include/_types.h index 55f1fa0e8be..d2a1d64d440 100644 --- a/sys/arch/alpha/include/_types.h +++ b/sys/arch/alpha/include/_types.h @@ -1,4 +1,4 @@ -/* $OpenBSD: _types.h,v 1.15 2011/09/08 03:40:32 guenther Exp $ */ +/* $OpenBSD: _types.h,v 1.16 2012/11/05 19:39:34 miod Exp $ */ /*- * Copyright (c) 1990, 1993 @@ -146,7 +146,4 @@ typedef int __rune_t; typedef void * __wctrans_t; typedef void * __wctype_t; -/* Feature test macros */ -#define __HAVE_TIMECOUNTER - #endif /* _MACHINE__TYPES_H_ */ diff --git a/sys/arch/amd64/include/_types.h b/sys/arch/amd64/include/_types.h index ed5ce0d4990..ef5c5f09a1d 100644 --- a/sys/arch/amd64/include/_types.h +++ b/sys/arch/amd64/include/_types.h @@ -1,4 +1,4 @@ -/* $OpenBSD: _types.h,v 1.9 2011/09/08 03:40:32 guenther Exp $ */ +/* $OpenBSD: _types.h,v 1.10 2012/11/05 19:39:34 miod Exp $ */ /*- * Copyright (c) 1990, 1993 @@ -142,7 +142,4 @@ typedef int __rune_t; typedef void * __wctrans_t; typedef void * __wctype_t; -/* Feature test macros */ -#define __HAVE_TIMECOUNTER - #endif /* _MACHINE__TYPES_H_ */ diff --git a/sys/arch/armish/include/_types.h b/sys/arch/armish/include/_types.h index 0f071a85499..e422568e053 100644 --- a/sys/arch/armish/include/_types.h +++ b/sys/arch/armish/include/_types.h @@ -1,4 +1,4 @@ -/* $OpenBSD: _types.h,v 1.6 2011/03/23 16:54:34 pirofti Exp $ */ +/* $OpenBSD: _types.h,v 1.7 2012/11/05 19:39:34 miod Exp $ */ /* $NetBSD: types.h,v 1.4 2002/02/28 03:17:26 simonb Exp $ */ #ifndef _MACHINE__TYPES_H_ @@ -6,7 +6,4 @@ #include <arm/_types.h> -/* Feature test macros */ -#define __HAVE_TIMECOUNTER - #endif /* _MACHINE__TYPES_H_ */ diff --git a/sys/arch/aviion/include/_types.h b/sys/arch/aviion/include/_types.h index f532a0ac698..a0d494de320 100644 --- a/sys/arch/aviion/include/_types.h +++ b/sys/arch/aviion/include/_types.h @@ -1,7 +1,4 @@ -/* $OpenBSD: _types.h,v 1.3 2010/04/21 19:33:47 miod Exp $ */ +/* $OpenBSD: _types.h,v 1.4 2012/11/05 19:39:34 miod Exp $ */ /* public domain */ #include <m88k/_types.h> - -/* Feature test macros */ -#define __HAVE_TIMECOUNTER diff --git a/sys/arch/beagle/include/_types.h b/sys/arch/beagle/include/_types.h index d2455188651..10dca61f0f7 100644 --- a/sys/arch/beagle/include/_types.h +++ b/sys/arch/beagle/include/_types.h @@ -1,4 +1,4 @@ -/* $OpenBSD: _types.h,v 1.3 2011/03/23 16:54:34 pirofti Exp $ */ +/* $OpenBSD: _types.h,v 1.4 2012/11/05 19:39:34 miod Exp $ */ /* $NetBSD: types.h,v 1.4 2002/02/28 03:17:26 simonb Exp $ */ #ifndef _MACHINE__TYPES_H_ @@ -6,7 +6,4 @@ #include <arm/_types.h> -/* Feature test macros */ -#define __HAVE_TIMECOUNTER - #endif /* _MACHINE__TYPES_H_ */ diff --git a/sys/arch/gumstix/include/_types.h b/sys/arch/gumstix/include/_types.h index 77d95f7e006..34dc9b23b19 100644 --- a/sys/arch/gumstix/include/_types.h +++ b/sys/arch/gumstix/include/_types.h @@ -1,11 +1,8 @@ -/* $OpenBSD: _types.h,v 1.4 2011/03/23 16:54:34 pirofti Exp $ */ +/* $OpenBSD: _types.h,v 1.5 2012/11/05 19:39:34 miod Exp $ */ #ifndef _MACHINE__TYPES_H_ #define _MACHINE__TYPES_H_ #include <arm/_types.h> -/* Feature test macros */ -#define __HAVE_TIMECOUNTER - #endif diff --git a/sys/arch/hp300/include/_types.h b/sys/arch/hp300/include/_types.h index bb22f089bda..1cc7c32cc55 100644 --- a/sys/arch/hp300/include/_types.h +++ b/sys/arch/hp300/include/_types.h @@ -1,4 +1,4 @@ -/* $OpenBSD: _types.h,v 1.4 2012/09/08 19:24:28 miod Exp $ */ +/* $OpenBSD: _types.h,v 1.5 2012/11/05 19:39:34 miod Exp $ */ /* public domain */ @@ -7,7 +7,4 @@ #include <m68k/_types.h> -/* Feature test macros */ -#define __HAVE_TIMECOUNTER - #endif /* _MACHINE__TYPES_H_ */ diff --git a/sys/arch/hppa/include/_types.h b/sys/arch/hppa/include/_types.h index 02794f2e72b..94b55d3ede1 100644 --- a/sys/arch/hppa/include/_types.h +++ b/sys/arch/hppa/include/_types.h @@ -1,4 +1,4 @@ -/* $OpenBSD: _types.h,v 1.17 2011/11/15 17:12:14 deraadt Exp $ */ +/* $OpenBSD: _types.h,v 1.18 2012/11/05 19:39:34 miod Exp $ */ /*- * Copyright (c) 1990, 1993 @@ -146,7 +146,4 @@ typedef int __rune_t; typedef void * __wctrans_t; typedef void * __wctype_t; -/* Feature test macros */ -#define __HAVE_TIMECOUNTER - #endif /* _MACHINE__TYPES_H_ */ diff --git a/sys/arch/hppa64/include/_types.h b/sys/arch/hppa64/include/_types.h index 8ea6f55a3ee..ed996b595b9 100644 --- a/sys/arch/hppa64/include/_types.h +++ b/sys/arch/hppa64/include/_types.h @@ -1,4 +1,4 @@ -/* $OpenBSD: _types.h,v 1.10 2011/11/15 17:12:14 deraadt Exp $ */ +/* $OpenBSD: _types.h,v 1.11 2012/11/05 19:39:34 miod Exp $ */ /*- * Copyright (c) 1990, 1993 @@ -142,7 +142,4 @@ typedef int __rune_t; typedef void * __wctrans_t; typedef void * __wctype_t; -/* Feature test macros */ -#define __HAVE_TIMECOUNTER - #endif /* _MACHINE__TYPES_H_ */ diff --git a/sys/arch/i386/include/_types.h b/sys/arch/i386/include/_types.h index 1f507392cb0..7afa2e77751 100644 --- a/sys/arch/i386/include/_types.h +++ b/sys/arch/i386/include/_types.h @@ -1,4 +1,4 @@ -/* $OpenBSD: _types.h,v 1.14 2011/11/15 17:12:14 deraadt Exp $ */ +/* $OpenBSD: _types.h,v 1.15 2012/11/05 19:39:34 miod Exp $ */ /*- * Copyright (c) 1990, 1993 @@ -142,7 +142,4 @@ typedef int __rune_t; typedef void * __wctrans_t; typedef void * __wctype_t; -/* Feature test macros */ -#define __HAVE_TIMECOUNTER - #endif /* _MACHINE__TYPES_H_ */ diff --git a/sys/arch/ia64/include/_types.h b/sys/arch/ia64/include/_types.h index c0ac6e5ec6a..9024774d731 100644 --- a/sys/arch/ia64/include/_types.h +++ b/sys/arch/ia64/include/_types.h @@ -1,4 +1,4 @@ -/* $OpenBSD: _types.h,v 1.3 2011/09/08 03:40:32 guenther Exp $ */ +/* $OpenBSD: _types.h,v 1.4 2012/11/05 19:39:34 miod Exp $ */ /*- * Copyright (c) 1990, 1993 @@ -143,7 +143,4 @@ typedef int __rune_t; typedef void * __wctrans_t; typedef void * __wctype_t; -/* Feature test macros */ -#define __HAVE_TIMECOUNTER - #endif /* _MACHINE__TYPES_H_ */ diff --git a/sys/arch/luna88k/include/_types.h b/sys/arch/luna88k/include/_types.h index d7d45b463f4..196e5d6c031 100644 --- a/sys/arch/luna88k/include/_types.h +++ b/sys/arch/luna88k/include/_types.h @@ -1,7 +1,4 @@ -/* $OpenBSD: _types.h,v 1.4 2012/10/18 17:45:08 miod Exp $ */ +/* $OpenBSD: _types.h,v 1.5 2012/11/05 19:39:34 miod Exp $ */ /* public domain */ #include <m88k/_types.h> - -/* Feature test macros */ -#define __HAVE_TIMECOUNTER diff --git a/sys/arch/mips64/include/_types.h b/sys/arch/mips64/include/_types.h index 42107996609..3c657d9203e 100644 --- a/sys/arch/mips64/include/_types.h +++ b/sys/arch/mips64/include/_types.h @@ -1,4 +1,4 @@ -/* $OpenBSD: _types.h,v 1.11 2011/11/15 17:12:14 deraadt Exp $ */ +/* $OpenBSD: _types.h,v 1.12 2012/11/05 19:39:34 miod Exp $ */ /*- * Copyright (c) 1990, 1993 @@ -160,7 +160,6 @@ typedef struct label_t { #define __SWAP_BROKEN /* Feature test macros */ -#define __HAVE_TIMECOUNTER #define __HAVE_EXEC_MD_MAP #endif /* _MIPS64__TYPES_H_ */ diff --git a/sys/arch/mvme68k/include/_types.h b/sys/arch/mvme68k/include/_types.h index b2e5bdb7c48..b68f0e855c1 100644 --- a/sys/arch/mvme68k/include/_types.h +++ b/sys/arch/mvme68k/include/_types.h @@ -1,7 +1,4 @@ -/* $OpenBSD: _types.h,v 1.4 2012/11/04 13:33:32 miod Exp $ */ +/* $OpenBSD: _types.h,v 1.5 2012/11/05 19:39:34 miod Exp $ */ /* public domain */ #include <m68k/_types.h> - -/* Feature test macros */ -#define __HAVE_TIMECOUNTER diff --git a/sys/arch/mvme88k/include/_types.h b/sys/arch/mvme88k/include/_types.h index d2e8f646f53..196e5d6c031 100644 --- a/sys/arch/mvme88k/include/_types.h +++ b/sys/arch/mvme88k/include/_types.h @@ -1,7 +1,4 @@ -/* $OpenBSD: _types.h,v 1.4 2009/03/09 19:51:18 miod Exp $ */ +/* $OpenBSD: _types.h,v 1.5 2012/11/05 19:39:34 miod Exp $ */ /* public domain */ #include <m88k/_types.h> - -/* Feature test macros */ -#define __HAVE_TIMECOUNTER diff --git a/sys/arch/palm/include/_types.h b/sys/arch/palm/include/_types.h index 9727bc818aa..b778141b95f 100644 --- a/sys/arch/palm/include/_types.h +++ b/sys/arch/palm/include/_types.h @@ -1,11 +1,8 @@ -/* $OpenBSD: _types.h,v 1.3 2011/03/23 16:54:36 pirofti Exp $ */ +/* $OpenBSD: _types.h,v 1.4 2012/11/05 19:39:34 miod Exp $ */ #ifndef _MACHINE__TYPES_H_ #define _MACHINE__TYPES_H_ #include <arm/_types.h> -/* Feature test macros */ -#define __HAVE_TIMECOUNTER - #endif diff --git a/sys/arch/powerpc/include/_types.h b/sys/arch/powerpc/include/_types.h index 2aa265e491b..002b8e6e237 100644 --- a/sys/arch/powerpc/include/_types.h +++ b/sys/arch/powerpc/include/_types.h @@ -1,4 +1,4 @@ -/* $OpenBSD: _types.h,v 1.13 2011/11/15 17:12:14 deraadt Exp $ */ +/* $OpenBSD: _types.h,v 1.14 2012/11/05 19:39:34 miod Exp $ */ /*- * Copyright (c) 1990, 1993 @@ -143,7 +143,4 @@ typedef int __rune_t; typedef void * __wctrans_t; typedef void * __wctype_t; -/* Feature test macros */ -#define __HAVE_TIMECOUNTER - #endif /* _POWERPC__TYPES_H_ */ diff --git a/sys/arch/sh/include/_types.h b/sys/arch/sh/include/_types.h index ce577a7e8f2..68b59f12cf2 100644 --- a/sys/arch/sh/include/_types.h +++ b/sys/arch/sh/include/_types.h @@ -1,4 +1,4 @@ -/* $OpenBSD: _types.h,v 1.11 2012/09/08 22:01:25 miod Exp $ */ +/* $OpenBSD: _types.h,v 1.12 2012/11/05 19:39:34 miod Exp $ */ /*- * Copyright (c) 1990, 1993 @@ -143,7 +143,4 @@ typedef int __rune_t; typedef void * __wctrans_t; typedef void * __wctype_t; -/* Feature test macros */ -#define __HAVE_TIMECOUNTER - #endif /* _SH__TYPES_H_ */ diff --git a/sys/arch/sparc/include/_types.h b/sys/arch/sparc/include/_types.h index 71ae9ae0623..fe82e73f8a3 100644 --- a/sys/arch/sparc/include/_types.h +++ b/sys/arch/sparc/include/_types.h @@ -1,4 +1,4 @@ -/* $OpenBSD: _types.h,v 1.18 2012/11/05 13:20:16 miod Exp $ */ +/* $OpenBSD: _types.h,v 1.19 2012/11/05 19:39:34 miod Exp $ */ /*- * Copyright (c) 1990, 1993 @@ -143,7 +143,4 @@ typedef int __rune_t; typedef void * __wctrans_t; typedef void * __wctype_t; -/* Feature test macros */ -#define __HAVE_TIMECOUNTER - #endif /* _MACHINE__TYPES_H_ */ diff --git a/sys/arch/sparc64/include/_types.h b/sys/arch/sparc64/include/_types.h index 332bf6bd4bf..c9a51819050 100644 --- a/sys/arch/sparc64/include/_types.h +++ b/sys/arch/sparc64/include/_types.h @@ -1,4 +1,4 @@ -/* $OpenBSD: _types.h,v 1.14 2011/09/27 20:44:50 miod Exp $ */ +/* $OpenBSD: _types.h,v 1.15 2012/11/05 19:39:34 miod Exp $ */ /*- * Copyright (c) 1990, 1993 @@ -142,7 +142,4 @@ typedef int __rune_t; typedef void * __wctrans_t; typedef void * __wctype_t; -/* Feature test macros */ -#define __HAVE_TIMECOUNTER - #endif /* _MACHINE__TYPES_H_ */ diff --git a/sys/arch/vax/include/_types.h b/sys/arch/vax/include/_types.h index 51e03bb7961..09b99aa2473 100644 --- a/sys/arch/vax/include/_types.h +++ b/sys/arch/vax/include/_types.h @@ -1,4 +1,4 @@ -/* $OpenBSD: _types.h,v 1.14 2011/11/15 17:12:14 deraadt Exp $ */ +/* $OpenBSD: _types.h,v 1.15 2012/11/05 19:39:34 miod Exp $ */ /*- * Copyright (c) 1990, 1993 @@ -142,7 +142,4 @@ typedef int __rune_t; typedef void * __wctrans_t; typedef void * __wctype_t; -/* Feature test macros */ -#define __HAVE_TIMECOUNTER - #endif /* _MACHINE__TYPES_H_ */ diff --git a/sys/arch/zaurus/include/_types.h b/sys/arch/zaurus/include/_types.h index 7d1985392fb..62c4840fe0b 100644 --- a/sys/arch/zaurus/include/_types.h +++ b/sys/arch/zaurus/include/_types.h @@ -1,11 +1,8 @@ -/* $OpenBSD: _types.h,v 1.6 2011/03/23 16:54:37 pirofti Exp $ */ +/* $OpenBSD: _types.h,v 1.7 2012/11/05 19:39:34 miod Exp $ */ #ifndef _MACHINE__TYPES_H_ #define _MACHINE__TYPES_H_ #include <arm/_types.h> -/* Feature test macros */ -#define __HAVE_TIMECOUNTER - #endif diff --git a/sys/kern/init_main.c b/sys/kern/init_main.c index eb36c4c46ed..2c43b25ffc6 100644 --- a/sys/kern/init_main.c +++ b/sys/kern/init_main.c @@ -1,4 +1,4 @@ -/* $OpenBSD: init_main.c,v 1.184 2012/08/28 16:39:09 matthew Exp $ */ +/* $OpenBSD: init_main.c,v 1.185 2012/11/05 19:39:34 miod Exp $ */ /* $NetBSD: init_main.c,v 1.84.4.1 1996/06/02 09:08:06 mrg Exp $ */ /* @@ -495,11 +495,7 @@ main(void *framep) * from the file system. Reset p->p_rtime as it may have been * munched in mi_switch() after the time got set. */ -#ifdef __HAVE_TIMECOUNTER microtime(&boottime); -#else - boottime = mono_time = time; -#endif LIST_FOREACH(p, &allproc, p_list) { p->p_p->ps_start = boottime; microuptime(&p->p_cpu->ci_schedstate.spc_runtime); diff --git a/sys/kern/kern_clock.c b/sys/kern/kern_clock.c index 843965b74c4..26ad86213c0 100644 --- a/sys/kern/kern_clock.c +++ b/sys/kern/kern_clock.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_clock.c,v 1.75 2012/08/02 03:18:48 guenther Exp $ */ +/* $OpenBSD: kern_clock.c,v 1.76 2012/11/05 19:39:34 miod Exp $ */ /* $NetBSD: kern_clock.c,v 1.34 1996/06/09 04:51:03 briggs Exp $ */ /*- @@ -50,9 +50,7 @@ #include <uvm/uvm_extern.h> #include <sys/sysctl.h> #include <sys/sched.h> -#ifdef __HAVE_TIMECOUNTER #include <sys/timetc.h> -#endif #include <machine/cpu.h> @@ -108,18 +106,6 @@ int psratio; /* ratio: prof / stat */ long cp_time[CPUSTATES]; -#ifndef __HAVE_TIMECOUNTER -int tickfix, tickfixinterval; /* used if tick not really integral */ -static int tickfixcnt; /* accumulated fractional error */ - -volatile time_t time_second; -volatile time_t time_uptime; - -volatile struct timeval time - __attribute__((__aligned__(__alignof__(quad_t)))); -volatile struct timeval mono_time; -#endif - void *softclock_si; /* @@ -153,9 +139,7 @@ initclocks(void) if (tickadj == 0) tickadj = 1; -#ifdef __HAVE_TIMECOUNTER inittimecounter(); -#endif } /* @@ -202,13 +186,6 @@ void hardclock(struct clockframe *frame) { struct proc *p; -#ifndef __HAVE_TIMECOUNTER - int delta; - extern int tickdelta; - extern long timedelta; - extern int64_t ntp_tick_permanent; - extern int64_t ntp_tick_acc; -#endif struct cpu_info *ci = curcpu(); p = curproc; @@ -243,57 +220,7 @@ hardclock(struct clockframe *frame) if (CPU_IS_PRIMARY(ci) == 0) return; -#ifndef __HAVE_TIMECOUNTER - /* - * Increment the time-of-day. The increment is normally just - * ``tick''. If the machine is one which has a clock frequency - * such that ``hz'' would not divide the second evenly into - * milliseconds, a periodic adjustment must be applied. Finally, - * if we are still adjusting the time (see adjtime()), - * ``tickdelta'' may also be added in. - */ - - delta = tick; - - if (tickfix) { - tickfixcnt += tickfix; - if (tickfixcnt >= tickfixinterval) { - delta++; - tickfixcnt -= tickfixinterval; - } - } - /* Imprecise 4bsd adjtime() handling */ - if (timedelta != 0) { - delta += tickdelta; - timedelta -= tickdelta; - } - - /* - * ntp_tick_permanent accumulates the clock correction each - * tick. The unit is ns per tick shifted left 32 bits. If we have - * accumulated more than 1us, we bump delta in the right - * direction. Use a loop to avoid long long div; typically - * the loops will be executed 0 or 1 iteration. - */ - if (ntp_tick_permanent != 0) { - ntp_tick_acc += ntp_tick_permanent; - while (ntp_tick_acc >= (1000LL << 32)) { - delta++; - ntp_tick_acc -= (1000LL << 32); - } - while (ntp_tick_acc <= -(1000LL << 32)) { - delta--; - ntp_tick_acc += (1000LL << 32); - } - } - - BUMPTIME(&time, delta); - BUMPTIME(&mono_time, delta); - time_second = time.tv_sec; - time_uptime = mono_time.tv_sec; -#else tc_ticktock(); -#endif /* * Update real-time timeout queue. @@ -565,76 +492,3 @@ sysctl_clockrate(char *where, size_t *sizep, void *newp) clkinfo.stathz = stathz ? stathz : hz; return (sysctl_rdstruct(where, sizep, newp, &clkinfo, sizeof(clkinfo))); } - -#ifndef __HAVE_TIMECOUNTER -/* - * Placeholders until everyone uses the timecounters code. - * Won't improve anything except maybe removing a bunch of bugs in fixed code. - */ - -void -getmicrotime(struct timeval *tvp) -{ - int s; - - s = splhigh(); - *tvp = time; - splx(s); -} - -void -nanotime(struct timespec *tsp) -{ - struct timeval tv; - - microtime(&tv); - TIMEVAL_TO_TIMESPEC(&tv, tsp); -} - -void -getnanotime(struct timespec *tsp) -{ - struct timeval tv; - - getmicrotime(&tv); - TIMEVAL_TO_TIMESPEC(&tv, tsp); -} - -void -nanouptime(struct timespec *tsp) -{ - struct timeval tv; - - microuptime(&tv); - TIMEVAL_TO_TIMESPEC(&tv, tsp); -} - - -void -getnanouptime(struct timespec *tsp) -{ - struct timeval tv; - - getmicrouptime(&tv); - TIMEVAL_TO_TIMESPEC(&tv, tsp); -} - -void -microuptime(struct timeval *tvp) -{ - struct timeval tv; - - microtime(&tv); - timersub(&tv, &boottime, tvp); -} - -void -getmicrouptime(struct timeval *tvp) -{ - int s; - - s = splhigh(); - *tvp = mono_time; - splx(s); -} -#endif /* __HAVE_TIMECOUNTER */ diff --git a/sys/kern/kern_sysctl.c b/sys/kern/kern_sysctl.c index c9d14db068a..49f2dfcc8e5 100644 --- a/sys/kern/kern_sysctl.c +++ b/sys/kern/kern_sysctl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_sysctl.c,v 1.227 2012/08/30 20:11:32 matthew Exp $ */ +/* $OpenBSD: kern_sysctl.c,v 1.228 2012/11/05 19:39:35 miod Exp $ */ /* $NetBSD: kern_sysctl.c,v 1.17 1996/05/20 17:49:05 mrg Exp $ */ /*- @@ -70,9 +70,7 @@ #include <sys/socket.h> #include <sys/domain.h> #include <sys/protosw.h> -#ifdef __HAVE_TIMECOUNTER #include <sys/timetc.h> -#endif #include <sys/evcount.h> #include <sys/unpcb.h> @@ -291,9 +289,7 @@ kern_sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp, void *newp, case KERN_WATCHDOG: case KERN_EMUL: case KERN_EVCOUNT: -#ifdef __HAVE_TIMECOUNTER case KERN_TIMECOUNTER: -#endif case KERN_CPTIME2: case KERN_FILE2: break; @@ -557,11 +553,9 @@ kern_sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp, void *newp, return (evcount_sysctl(name + 1, namelen - 1, oldp, oldlenp, newp, newlen)); #endif -#ifdef __HAVE_TIMECOUNTER case KERN_TIMECOUNTER: return (sysctl_tc(name + 1, namelen - 1, oldp, oldlenp, newp, newlen)); -#endif case KERN_MAXLOCKSPERUID: return (sysctl_int(oldp, oldlenp, newp, newlen, &maxlocksperuid)); case KERN_CPTIME2: diff --git a/sys/kern/kern_tc.c b/sys/kern/kern_tc.c index b6c7875e546..17ce4128f3e 100644 --- a/sys/kern/kern_tc.c +++ b/sys/kern/kern_tc.c @@ -6,7 +6,7 @@ * this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp * ---------------------------------------------------------------------------- * - * $OpenBSD: kern_tc.c,v 1.17 2012/05/24 07:17:42 guenther Exp $ + * $OpenBSD: kern_tc.c,v 1.18 2012/11/05 19:39:35 miod Exp $ * $FreeBSD: src/sys/kern/kern_tc.c,v 1.148 2003/03/18 08:45:23 phk Exp $ */ @@ -20,7 +20,6 @@ #include <sys/malloc.h> #include <dev/rndvar.h> -#ifdef __HAVE_TIMECOUNTER /* * A large step happens on boot. This constant detects such steps. * It is relatively small so that ntp_update_second gets called enough @@ -639,4 +638,3 @@ tc_adjfreq(int64_t *old, int64_t *new) } return 0; } -#endif /* __HAVE_TIMECOUNTER */ diff --git a/sys/kern/kern_time.c b/sys/kern/kern_time.c index 2e83b07ffb1..e677212a987 100644 --- a/sys/kern/kern_time.c +++ b/sys/kern/kern_time.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_time.c,v 1.75 2012/05/24 07:17:42 guenther Exp $ */ +/* $OpenBSD: kern_time.c,v 1.76 2012/11/05 19:39:35 miod Exp $ */ /* $NetBSD: kern_time.c,v 1.20 1996/02/18 11:57:06 fvdl Exp $ */ /* @@ -40,24 +40,14 @@ #include <sys/ktrace.h> #include <sys/vnode.h> #include <sys/signalvar.h> -#ifdef __HAVE_TIMECOUNTER #include <sys/timetc.h> -#endif #include <sys/mount.h> #include <sys/syscallargs.h> #include <machine/cpu.h> -#ifdef __HAVE_TIMECOUNTER struct timeval adjtimedelta; /* unapplied time correction */ -#else -int tickdelta; /* current clock skew, us. per tick */ -long timedelta; /* unapplied time correction, us. */ -long bigadj = 1000000; /* use 10x skew above bigadj us. */ -int64_t ntp_tick_permanent; -int64_t ntp_tick_acc; -#endif void itimerround(struct timeval *); @@ -72,7 +62,6 @@ void itimerround(struct timeval *); */ /* This function is used by clock_settime and settimeofday */ -#ifdef __HAVE_TIMECOUNTER int settime(struct timespec *ts) { @@ -120,66 +109,6 @@ settime(struct timespec *ts) return (0); } -#else -int -settime(struct timespec *ts) -{ - struct timeval delta, tvv, *tv; - int s; - - /* XXX - Ugh. */ - tv = &tvv; - tvv.tv_sec = ts->tv_sec; - tvv.tv_usec = ts->tv_nsec / 1000; - - /* - * Don't allow the time to be set forward so far it will wrap - * and become negative, thus allowing an attacker to bypass - * the next check below. The cutoff is 1 year before rollover - * occurs, so even if the attacker uses adjtime(2) to move - * the time past the cutoff, it will take a very long time - * to get to the wrap point. - * - * XXX: we check against INT_MAX since on 64-bit - * platforms, sizeof(int) != sizeof(long) and - * time_t is 32 bits even when atv.tv_sec is 64 bits. - */ - if (tv->tv_sec > INT_MAX - 365*24*60*60) { - printf("denied attempt to set clock forward to %ld\n", - tv->tv_sec); - return (EPERM); - } - /* - * If the system is secure, we do not allow the time to be - * set to an earlier value (it may be slowed using adjtime, - * but not set back). This feature prevent interlopers from - * setting arbitrary time stamps on files. - */ - if (securelevel > 1 && timercmp(tv, &time, <)) { - printf("denied attempt to set clock back %ld seconds\n", - time_second - tv->tv_sec); - return (EPERM); - } - - /* WHAT DO WE DO ABOUT PENDING REAL-TIME TIMEOUTS??? */ - s = splclock(); - timersub(tv, &time, &delta); - time = *tv; - timeradd(&boottime, &delta, &boottime); - - /* - * Adjtime in progress is meaningless or harmful after - * setting the clock. - */ - tickdelta = 0; - timedelta = 0; - - splx(s); - resettodr(); - - return (0); -} -#endif int clock_gettime(struct proc *p, clockid_t clock_id, struct timespec *tp) @@ -444,24 +373,6 @@ sys_adjfreq(struct proc *p, void *v, register_t *retval) int64_t f; const int64_t *freq = SCARG(uap, freq); int64_t *oldfreq = SCARG(uap, oldfreq); -#ifndef __HAVE_TIMECOUNTER - int s; - - if (oldfreq) { - f = ntp_tick_permanent * hz; - if ((error = copyout(&f, oldfreq, sizeof(int64_t)))) - return (error); - } - if (freq) { - if ((error = suser(p, 0))) - return (error); - if ((error = copyin(freq, &f, sizeof(int64_t)))) - return (error); - s = splclock(); - ntp_tick_permanent = f / hz; - splx(s); - } -#else if (oldfreq) { if ((error = tc_adjfreq(&f, NULL))) return (error); @@ -476,7 +387,6 @@ sys_adjfreq(struct proc *p, void *v, register_t *retval) if ((error = tc_adjfreq(NULL, &f))) return (error); } -#endif return (0); } @@ -490,7 +400,6 @@ sys_adjtime(struct proc *p, void *v, register_t *retval) } */ *uap = v; const struct timeval *delta = SCARG(uap, delta); struct timeval *olddelta = SCARG(uap, olddelta); -#ifdef __HAVE_TIMECOUNTER int error; if (olddelta) @@ -517,72 +426,6 @@ sys_adjtime(struct proc *p, void *v, register_t *retval) adjtimedelta.tv_sec -= 1; } return (0); -#else - struct timeval atv; - long ndelta, ntickdelta, odelta; - int s, error; - - if (!delta) { - s = splclock(); - odelta = timedelta; - splx(s); - goto out; - } - if ((error = suser(p, 0))) - return (error); - if ((error = copyin(delta, &atv, sizeof(struct timeval)))) - 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. - */ - if (atv.tv_sec > LONG_MAX / 1000000L) - ndelta = LONG_MAX; - else if (atv.tv_sec < LONG_MIN / 1000000L) - ndelta = LONG_MIN; - else { - ndelta = atv.tv_sec * 1000000L; - odelta = ndelta; - ndelta += atv.tv_usec; - if (atv.tv_usec > 0 && ndelta <= odelta) - ndelta = LONG_MAX; - else if (atv.tv_usec < 0 && ndelta >= odelta) - ndelta = LONG_MIN; - } - - if (ndelta > bigadj || 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); - -out: - if (olddelta) { - atv.tv_sec = odelta / 1000000; - atv.tv_usec = odelta % 1000000; - if ((error = copyout(&atv, olddelta, sizeof(struct timeval)))) - return (error); - } - return (0); -#endif } diff --git a/sys/sys/kernel.h b/sys/sys/kernel.h index f0615ea2007..3e8141a3362 100644 --- a/sys/sys/kernel.h +++ b/sys/sys/kernel.h @@ -1,4 +1,4 @@ -/* $OpenBSD: kernel.h,v 1.12 2007/05/16 17:27:30 art Exp $ */ +/* $OpenBSD: kernel.h,v 1.13 2012/11/05 19:39:35 miod Exp $ */ /* $NetBSD: kernel.h,v 1.11 1995/03/03 01:24:16 cgd Exp $ */ /*- @@ -48,10 +48,6 @@ extern int domainnamelen; /* 1.2 */ extern struct timeval boottime; -#ifndef __HAVE_TIMECOUNTER -extern volatile struct timeval mono_time; -extern volatile struct timeval time; -#endif extern struct timezone tz; /* XXX */ extern int tick; /* usec per tick (1000000 / hz) */ |