NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: kern/49207



Hello,
 
I've cleaned the patches and tested (cross-built tools and kernel) over all ports affected with the changes, those I was able to test.
 
List of ports under tests:
algor(P4032) OK
alpha(GENERIC) OK
amiga(GENERIC) OK
arc(GENERIC) OK
atari(FALCON) OK
bebox(GENERIC) OK
cobalt(GENERIC) OK
dreamcast(GENERIC) OK
emips(GENERIC) OK
epoc32(GENERIC) OK
evbarm(RPI) OK
evbppc(OPENBLOCKS200) OK
ews4800mips(GENERIC) OK
hp300(GENERIC) OK
hpcmips(GENERIC) OK
hppa(GENERIC) OK
landisk(GENERIC) OK
luna68k(GENERIC) OK
mac68k(GENERIC) OK
macppc(GENERIC) OK
mipsco(GENERIC) OK
mvme68k(GENERIC) OK
mvmeppc(GENERIC) OK
news68k(GENERIC) OK
newsmips(GENERIC) OK
next68k(GENERIC) OK
playstation2 cross-toolchain missing
pmax(GENERIC) OK
prep(GENERIC) OK
sandpoint(GENERIC) OK
sgimips(GENERIC32_IP3x) OK
sparc(GENERIC) OK
sparc64(GENERIC) OK
sun2(GENERIC) OK
sun3(GENERIC) OK
vax(GENERIC) OK
x68k(GENERIC) OK
 
General idea of the change:
Move src/sys/dev/clock_subr.h to src/sys/sys/clock.h and reuse its code kernel-wide. Sanity time constants and utilities.
 
List of patches:

Directory: src/distrib
0001-NETBSD-Add-usr-include-sys-clock.h.patch
 
Directory: src/tools
0001-NETBSD-Import-sys-clock.h-to-libnbcompat.patch
0002-NETBSD-Remove-obsoleted-dev-clock_subr.h-by-sys-cloc.patch
 
Directory: src/share
0001-NETBSD-Rename-dev-clock_subr.h-sys-clock.h.patch
 
Directory: src/sys
0001-NETBSD-Clone-verbatim-dev-clock_subr.h-sys-clock.h.patch
0002-NETBSD-Adapt-sys-clock.h-for-its-new-place-and-needs.patch
0003-NETBSD-Reusage-of-sys-clock.h-drop-dev-clock_subr.h-.patch
0004-NETBSD-Switch-dev-clock_subr.c-from-dev-clock_subr.h.patch
0005-NETBSD-Remove-dev-clock_subr.h-obsoleted-by-sys-cloc.patch
 
Please sponsor these changes, review and apply.
Your comments are appreciated.
 
Delayed for next set of commits, before freeze of sys/clock.h in a stable release: bcd functions. This will be proposed after applying the current changes.
 
PS. Comments about my doubts from the last mail are still in force.
From 7f528abc2d9ac0445776b988fbfd03ad83dfcba2 Mon Sep 17 00:00:00 2001
From: Kamil Rytarowski <n54%gmx.com@localhost>
Date: Thu, 2 Oct 2014 00:56:03 +0200
Subject: [PATCH] NETBSD: Add /usr/include/sys/clock.h

---
 sets/lists/comp/mi | 1 +
 1 file changed, 1 insertion(+)

diff --git a/sets/lists/comp/mi b/sets/lists/comp/mi
index a37fd43..8193b4d 100644
--- a/sets/lists/comp/mi
+++ b/sets/lists/comp/mi
@@ -3130,6 +3130,7 @@
 ./usr/include/sys/cdio.h			comp-c-include
 ./usr/include/sys/chio.h			comp-c-include
 ./usr/include/sys/clist.h			comp-obsolete		obsolete
+./usr/include/sys/clock.h			comp-c-include
 ./usr/include/sys/clockctl.h			comp-c-include
 ./usr/include/sys/common_ansi.h			comp-c-include
 ./usr/include/sys/common_int_const.h		comp-c-include
-- 
1.9.4

From 25c0b0ecc8c4197ad474f0ad0af81292210a02e3 Mon Sep 17 00:00:00 2001
From: Kamil Rytarowski <n54%gmx.com@localhost>
Date: Wed, 1 Oct 2014 23:17:39 +0200
Subject: [PATCH 1/5] NETBSD: Clone verbatim dev/clock_subr.h -> sys/clock.h

---
 sys/Makefile |   2 +-
 sys/clock.h  | 106 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 107 insertions(+), 1 deletion(-)
 create mode 100644 sys/clock.h

diff --git a/sys/Makefile b/sys/Makefile
index 06f7d7e..c8c9ee4 100644
--- a/sys/Makefile
+++ b/sys/Makefile
@@ -7,7 +7,7 @@ INCSDIR= /usr/include/sys
 INCS=	acct.h agpio.h aio.h ansi.h aout_mids.h ataio.h atomic.h audioio.h \
 	bitops.h bootblock.h bswap.h buf.h \
 	callback.h callout.h cdbr.h cdefs.h cdefs_aout.h \
-	cdefs_elf.h cdio.h chio.h clockctl.h \
+	cdefs_elf.h cdio.h chio.h clock.h clockctl.h \
 	common_ansi.h common_int_const.h common_int_fmtio.h \
 	common_int_limits.h common_int_mwgwtypes.h common_int_types.h \
 	common_limits.h common_wchar_limits.h \
diff --git a/sys/clock.h b/sys/clock.h
new file mode 100644
index 0000000..74be860
--- /dev/null
+++ b/sys/clock.h
@@ -0,0 +1,106 @@
+/*	$NetBSD: clock_subr.h,v 1.22 2014/09/07 11:50:23 martin Exp $	*/
+
+/*-
+ * Copyright (c) 1996 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Gordon W. Ross
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _DEV_CLOCK_SUBR_H_
+#define _DEV_CLOCK_SUBR_H_
+
+/*
+ * "POSIX time" to/from "YY/MM/DD/hh/mm/ss"
+ */
+struct clock_ymdhms {
+	uint64_t dt_year;
+	u_char dt_mon;
+	u_char dt_day;
+	u_char dt_wday;	/* Day of week */
+	u_char dt_hour;
+	u_char dt_min;
+	u_char dt_sec;
+};
+
+time_t	clock_ymdhms_to_secs(struct clock_ymdhms *);
+int	clock_secs_to_ymdhms(time_t, struct clock_ymdhms *);
+
+/*
+ * BCD to binary and binary to BCD.
+ */
+#define	FROMBCD(x)	bcdtobin((x))
+#define	TOBCD(x)	bintobcd((x))
+
+/* Some handy constants. */
+#define SECDAY		(24 * 60 * 60)
+#define SECYR		(SECDAY * 365)
+
+/* Traditional POSIX base year */
+#define	POSIX_BASE_YEAR	1970
+
+/*
+ * Interface to time-of-day clock devices.
+ *
+ * todr_gettime: convert time-of-day clock into a `struct timeval'
+ * todr_settime: set time-of-day clock from a `struct timeval'
+ *
+ * (this is probably not so useful:)
+ * todr_setwen: provide a machine-dependent TOD clock write-enable callback
+ *		function which takes one boolean argument:
+ *			1 to enable writes; 0 to disable writes.
+ */
+struct todr_chip_handle {
+	void	*cookie;	/* Device specific data */
+	void	*bus_cookie;	/* Bus specific data */
+	time_t	base_time;	/* Base time (e.g. rootfs time) */
+
+	int	(*todr_gettime)(struct todr_chip_handle *, struct timeval *);
+	int	(*todr_settime)(struct todr_chip_handle *, struct timeval *);
+	int	(*todr_gettime_ymdhms)(struct todr_chip_handle *,
+	    			struct clock_ymdhms *);
+	int	(*todr_settime_ymdhms)(struct todr_chip_handle *,
+	    			struct clock_ymdhms *);
+	int	(*todr_setwen)(struct todr_chip_handle *, int);
+
+};
+typedef struct todr_chip_handle *todr_chip_handle_t;
+
+#define todr_wenable(ct, v)	if ((ct)->todr_setwen) \
+					((*(ct)->todr_setwen)(ct, v))
+
+/*
+ * Probably these should evolve into internal routines in kern_todr.c.
+ */
+extern int todr_gettime(todr_chip_handle_t tch, struct timeval *);
+extern int todr_settime(todr_chip_handle_t tch, struct timeval *);
+
+/*
+ * Machine-dependent function that machine-independent RTC drivers can
+ * use to register their todr_chip_handle_t with inittodr()/resettodr().
+ */
+void	todr_attach(todr_chip_handle_t);
+
+#endif /* _DEV_CLOCK_SUBR_H_ */
-- 
1.9.4

From 86edf6fa56e358b1b483d7d14940e5258d07c695 Mon Sep 17 00:00:00 2001
From: Kamil Rytarowski <n54%gmx.com@localhost>
Date: Wed, 8 Oct 2014 00:25:07 +0200
Subject: [PATCH 1/2] NETBSD: Import sys/clock.h to libnbcompat

---
 compat/sys/clock.h | 4 ++++
 1 file changed, 4 insertions(+)
 create mode 100644 compat/sys/clock.h

diff --git a/compat/sys/clock.h b/compat/sys/clock.h
new file mode 100644
index 0000000..65ed398
--- /dev/null
+++ b/compat/sys/clock.h
@@ -0,0 +1,4 @@
+/*	$NetBSD: $	*/
+
+/* We unconditionally use the NetBSD clock_subr in libnbcompat. */
+#include "../../sys/sys/clock.h"
-- 
1.9.4

From 06e694a19ba75cfe383fc9cd83dfba45609d9bb0 Mon Sep 17 00:00:00 2001
From: Kamil Rytarowski <n54%gmx.com@localhost>
Date: Thu, 2 Oct 2014 00:56:50 +0200
Subject: [PATCH] NETBSD: Rename dev/clock_subr.h -> sys/clock.h

---
 man/man9/todr.9 | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/man/man9/todr.9 b/man/man9/todr.9
index 39d1a00..9ce6a42 100644
--- a/man/man9/todr.9
+++ b/man/man9/todr.9
@@ -38,7 +38,7 @@
 .Nm clock_secs_to_ymdhms
 .Nd time-of-day clock support
 .Sh SYNOPSIS
-.In dev/clock_subr.h
+.In sys/clock_subr.h
 .Ft void
 .Fn todr_attach "todr_chip_handle_t"
 .Ft int
-- 
1.9.4

From 8b3216e846cb6b266aef8effc04f3e4884fbd37b Mon Sep 17 00:00:00 2001
From: Kamil Rytarowski <n54%gmx.com@localhost>
Date: Wed, 1 Oct 2014 23:46:30 +0200
Subject: [PATCH 2/5] NETBSD: Adapt sys/clock.h for its new place and needs

Changes regarding the original work:
- rename compact macros to more meaningful names
- add secs per minute and hour
- two separated macros for secs per leap and common year
- add statically inlined days_in_month(), is_leap_year() and days_per_year()
- define secs / day as 86400 to catch easier a 16-bit int usage
---
 sys/clock.h | 63 +++++++++++++++++++++++++++++++++++++++++++++++++++++++------
 1 file changed, 57 insertions(+), 6 deletions(-)

diff --git a/sys/clock.h b/sys/clock.h
index 74be860..661879b 100644
--- a/sys/clock.h
+++ b/sys/clock.h
@@ -1,4 +1,4 @@
-/*	$NetBSD: clock_subr.h,v 1.22 2014/09/07 11:50:23 martin Exp $	*/
+/*	$NetBSD: $	*/
 
 /*-
  * Copyright (c) 1996 The NetBSD Foundation, Inc.
@@ -29,8 +29,10 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef _DEV_CLOCK_SUBR_H_
-#define _DEV_CLOCK_SUBR_H_
+#ifndef _SYS_CLOCK_H_
+#define _SYS_CLOCK_H_
+
+/* This file was originally at sys/dev/clock_subr.h */
 
 /*
  * "POSIX time" to/from "YY/MM/DD/hh/mm/ss"
@@ -55,12 +57,61 @@ int	clock_secs_to_ymdhms(time_t, struct clock_ymdhms *);
 #define	TOBCD(x)	bintobcd((x))
 
 /* Some handy constants. */
-#define SECDAY		(24 * 60 * 60)
-#define SECYR		(SECDAY * 365)
+#define SECS_PER_MINUTE		60
+#define SECS_PER_HOUR		3600
+#define SECS_PER_DAY		86400
+#define DAYS_PER_COMMON_YEAR    365
+#define DAYS_PER_LEAP_YEAR      366
+#define SECS_PER_COMMON_YEAR	(SECS_PER_DAY * DAYS_PER_COMMON_YEAR)
+#define SECS_PER_LEAP_YEAR	(SECS_PER_DAY * DAYS_PER_LEAP_YEAR)
 
 /* Traditional POSIX base year */
 #define	POSIX_BASE_YEAR	1970
 
+/* Some handy functions */
+static inline int
+days_in_month(int m)
+{
+	static const int month_days[12] = {
+        	31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31
+	};
+
+	if (__predict_false(m < 1 || m > 12))
+		return EINVAL;
+
+	return month_days[m - 1];
+}
+
+/*
+ * This inline avoids some unnecessary modulo operations
+ * as compared with the usual macro:
+ *   ( ((year % 4) == 0 &&
+ *      (year % 100) != 0) ||
+ *     ((year % 400) == 0) )
+ * It is otherwise equivalent.
+ */
+static inline int
+is_leap_year(uint64_t year)
+{
+	int rv = 0;
+
+	if ((year & 3) == 0) {
+		rv = 1;
+		if (__predict_false((year % 100) == 0)) {
+			rv = 0;
+			if (__predict_false((year % 400) == 0))
+				rv = 1;
+		}
+	}
+	return rv;
+}
+
+static inline int
+days_per_year(uint64_t year)
+{
+	return is_leap_year(year) ? DAYS_PER_LEAP_YEAR : DAYS_PER_COMMON_YEAR;
+}
+
 /*
  * Interface to time-of-day clock devices.
  *
@@ -103,4 +154,4 @@ extern int todr_settime(todr_chip_handle_t tch, struct timeval *);
  */
 void	todr_attach(todr_chip_handle_t);
 
-#endif /* _DEV_CLOCK_SUBR_H_ */
+#endif /* _SYS_CLOCK_H_ */
-- 
1.9.4

From 038cdb894e53d4d832cd84d9920b8a37bf84e055 Mon Sep 17 00:00:00 2001
From: Kamil Rytarowski <n54%gmx.com@localhost>
Date: Wed, 8 Oct 2014 23:56:26 +0200
Subject: [PATCH 2/2] NETBSD: Remove obsoleted dev/clock_subr.h by sys/clock.h

---
 compat/dev/clock_subr.h | 62 -------------------------------------------------
 1 file changed, 62 deletions(-)
 delete mode 100644 compat/dev/clock_subr.h

diff --git a/compat/dev/clock_subr.h b/compat/dev/clock_subr.h
deleted file mode 100644
index eb8a7d7..0000000
--- a/compat/dev/clock_subr.h
+++ /dev/null
@@ -1,62 +0,0 @@
-/*	$NetBSD: clock_subr.h,v 1.2 2014/09/07 11:50:23 martin Exp $	*/
-
-/*-
- * Copyright (c) 1996 The NetBSD Foundation, Inc.
- * All rights reserved.
- *
- * This code is derived from software contributed to The NetBSD Foundation
- * by Gordon W. Ross
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
- * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef _DEV_CLOCK_SUBR_H_
-#define _DEV_CLOCK_SUBR_H_
-
-/*
- * This is a slightly stripped down version of src/sys/dev/clock_subr.h
- */
-
-/*
- * "POSIX time" to/from "YY/MM/DD/hh/mm/ss"
- */
-struct clock_ymdhms {
-	uint64_t dt_year;
-	u_char dt_mon;
-	u_char dt_day;
-	u_char dt_wday;	/* Day of week */
-	u_char dt_hour;
-	u_char dt_min;
-	u_char dt_sec;
-};
-
-time_t	clock_ymdhms_to_secs(struct clock_ymdhms *);
-int	clock_secs_to_ymdhms(time_t, struct clock_ymdhms *);
-
-/* Some handy constants. */
-#define SECDAY		(24 * 60 * 60)
-#define SECYR		(SECDAY * 365)
-
-/* Traditional POSIX base year */
-#define	POSIX_BASE_YEAR	1970
-
-#endif /* _DEV_CLOCK_SUBR_H_ */
-- 
1.9.4

From 49c36c8daad749ba27bc56094c6a9362eb492af5 Mon Sep 17 00:00:00 2001
From: Kamil Rytarowski <n54%gmx.com@localhost>
Date: Thu, 2 Oct 2014 00:59:46 +0200
Subject: [PATCH 3/5] NETBSD: Reusage of sys/clock.h, drop dev/clock_subr.h
 dependency

---
 arch/algor/dev/mcclock_mainbus.c                      |  2 +-
 arch/alpha/alpha/mcclock.c                            |  2 +-
 arch/alpha/isa/mcclock_isa.c                          |  2 +-
 arch/alpha/jensenio/mcclock_jensenio.c                |  2 +-
 arch/alpha/tc/mcclock_ioasic.c                        |  2 +-
 arch/alpha/tlsb/mcclock_tlsb.c                        |  2 +-
 arch/amiga/dev/a2kbbc.c                               |  2 +-
 arch/amiga/dev/a34kbbc.c                              |  2 +-
 arch/amiga/dev/drbbc.c                                |  2 +-
 arch/arc/arc/c_jazz_eisa.c                            |  2 +-
 arch/arc/arc/c_nec_pci.c                              |  2 +-
 arch/arc/isa/mcclock_isa.c                            |  2 +-
 arch/arc/jazz/mcclock_jazzio.c                        |  2 +-
 arch/arm/allwinner/awin_rtc.c                         |  2 +-
 arch/arm/arm32/arm11_pmc.c                            |  2 +-
 arch/arm/arm32/cortex_pmc.c                           |  2 +-
 arch/arm/at91/at91st.c                                |  2 +-
 arch/arm/at91/at91tctmr.c                             |  2 +-
 arch/arm/clps711x/clpsrtc.c                           |  2 +-
 arch/arm/ep93xx/epclk.c                               |  2 +-
 arch/arm/ep93xx/eprtc.c                               |  2 +-
 arch/arm/footbridge/isa/dsrtc.c                       |  2 +-
 arch/arm/gemini/gemini_timer.c                        |  2 +-
 arch/arm/gemini/obio_timer.c                          |  2 +-
 arch/arm/imx/imx51_clock.c                            |  2 +-
 arch/arm/iomd/iomd_clock.c                            |  2 +-
 arch/arm/marvell/mvsocrtc.c                           |  2 +-
 arch/arm/mpcore/mpcore_clock.c                        |  2 +-
 arch/arm/omap/obio_mputmr.c                           |  2 +-
 arch/arm/omap/omap2_mputmr.c                          |  2 +-
 arch/arm/omap/omap3_sdmavar.h                         |  2 +-
 arch/arm/omap/omap_mputmr.c                           |  2 +-
 arch/arm/omap/omap_rtc.c                              |  2 +-
 arch/arm/omap/omapl1x_timer.c                         |  2 +-
 arch/arm/s3c2xx0/s3c2440_rtc.c                        |  2 +-
 arch/arm/xscale/becc_timer.c                          |  2 +-
 arch/arm/xscale/i80321_timer.c                        |  2 +-
 arch/arm/xscale/ixp425_timer.c                        |  2 +-
 arch/arm/xscale/ixp425_wdog.c                         |  2 +-
 arch/arm/xscale/pxa2x0_rtc.c                          |  2 +-
 arch/atari/dev/clock.c                                |  2 +-
 arch/atari/dev/clockreg.h                             |  4 ----
 arch/bebox/isa/mcclock_isa.c                          |  2 +-
 arch/cobalt/dev/mcclock.c                             |  2 +-
 arch/dreamcast/dev/g2/g2rtc.c                         |  4 ++--
 arch/emips/ebus/clock_ebus.c                          |  2 +-
 arch/epoc32/windermere/wmrtc.c                        |  2 +-
 arch/evbarm/ifpga/pl030_rtc.c                         |  2 +-
 arch/evbarm/iq80310/iq80310_timer.c                   |  2 +-
 arch/evbarm/tsarm/tsrtc.c                             |  2 +-
 arch/evbmips/isa/mcclock_isa.c                        |  2 +-
 arch/evbppc/mpc85xx/ds1553rtc.c                       |  2 +-
 arch/evbppc/pmppc/dev/ds17485.c                       |  2 +-
 arch/evbppc/walnut/dev/ds1743.c                       |  2 +-
 arch/evbsh3/ap_ms104_sh4/rs5c316_mainbus.c            |  2 +-
 arch/ews4800mips/sbd/mkclock_sbdio.c                  |  2 +-
 arch/hp300/dev/mcclock_frodo.c                        |  2 +-
 arch/hp300/dev/rtc.c                                  |  2 +-
 arch/hp300/stand/common/clock.c                       | 19 +++++--------------
 arch/hpcmips/hpcmips/clock.c                          |  2 +-
 arch/hpcmips/tx/tx39clock.c                           |  2 +-
 arch/hpcmips/vr/rtc.c                                 |  6 +++---
 arch/hpcmips/vr/rtcreg.h                              |  3 ---
 arch/hppa/dev/pdc.c                                   |  2 +-
 arch/landisk/dev/rs5c313_landisk.c                    |  2 +-
 arch/luna68k/dev/timekeeper.c                         |  2 +-
 arch/luna68k/luna68k/clock.c                          |  2 +-
 arch/mac68k/mac68k/clock.c                            |  2 +-
 arch/macppc/dev/adb.c                                 |  2 +-
 arch/macppc/dev/cuda.c                                |  2 +-
 arch/macppc/dev/pmu.c                                 |  2 +-
 arch/mips/alchemy/dev/aurtc.c                         |  2 +-
 arch/mips/mips/mips_mcclock.c                         |  2 +-
 arch/mipsco/mipsco/clock.c                            |  2 +-
 arch/mipsco/mipsco/machdep.c                          |  2 +-
 arch/mipsco/obio/mkclock.c                            |  2 +-
 arch/mvme68k/stand/libsa/chiptotime.c                 | 10 ++++------
 arch/mvme68k/stand/libsa/clock.c                      | 11 +++++------
 arch/mvmeppc/isa/mkclock_isa.c                        |  2 +-
 arch/mvmeppc/stand/libsa/clock.c                      | 10 ++++------
 arch/news68k/dev/mkclock_hb.c                         |  2 +-
 arch/news68k/dev/timer_hb.c                           |  2 +-
 arch/newsmips/apbus/mkclock_ap.c                      |  2 +-
 arch/newsmips/dev/mkclock_hb.c                        |  2 +-
 arch/next68k/next68k/rtc.c                            |  2 +-
 arch/playstation2/playstation2/clock.c                |  2 +-
 arch/pmax/ibus/mcclock_ibus.c                         |  2 +-
 arch/pmax/pmax/clock.c                                |  2 +-
 arch/pmax/tc/mcclock_ioasic.c                         |  2 +-
 arch/powerpc/powerpc/rtas.c                           |  2 +-
 arch/prep/pnpbus/mcclock_pnpbus.c                     |  2 +-
 arch/prep/pnpbus/nvram_pnpbus.c                       |  2 +-
 arch/sandpoint/isa/mcclock_isa.c                      |  2 +-
 arch/sbmips/sbmips/rtc.c                              |  2 +-
 arch/sgimips/dev/dpclock.c                            |  2 +-
 arch/sgimips/dev/dsclock.c                            |  2 +-
 arch/sgimips/mace/mcclock_mace.c                      |  2 +-
 arch/sgimips/sgimips/clock.c                          |  2 +-
 arch/sh3/dev/rtc.c                                    |  2 +-
 arch/sh3/sh3/clock.c                                  |  2 +-
 arch/sparc/dev/rtc.c                                  |  2 +-
 arch/sparc/sparc/clock.c                              |  2 +-
 arch/sparc/sparc/eeprom.c                             |  2 +-
 arch/sparc/sparc/mkclock.c                            |  2 +-
 arch/sparc/sparc/oclock.c                             |  2 +-
 arch/sparc64/dev/mkclock.c                            |  2 +-
 arch/sparc64/dev/rtc.c                                |  2 +-
 arch/sun2/sun2/clock.c                                |  2 +-
 arch/sun2/sun2/tod.c                                  |  2 +-
 arch/sun3/sun3/clock.c                                |  2 +-
 arch/sun3/sun3x/clock.c                               |  2 +-
 arch/usermode/dev/clock.c                             |  2 +-
 arch/vax/include/clock.h                              | 10 +---------
 arch/vax/vax/clock.c                                  |  5 +++--
 arch/x68k/dev/rtclock.c                               |  2 +-
 arch/x68k/stand/libsa/clock.c                         |  9 +++------
 arch/x68k/x68k/clock.c                                |  2 +-
 arch/x86/include/rtc.h                                |  2 +-
 arch/xen/xen/clock.c                                  |  2 +-
 dev/dec/mcclock.c                                     | 10 +++++-----
 dev/dec/mcclock_pad32.c                               |  2 +-
 dev/i2c/ds1307.c                                      |  2 +-
 dev/i2c/m41st84.c                                     |  2 +-
 dev/i2c/m41t00.c                                      |  2 +-
 dev/i2c/max6900.c                                     |  2 +-
 dev/i2c/pcf8563.c                                     |  2 +-
 dev/i2c/pcf8583.c                                     |  2 +-
 dev/i2c/r2025.c                                       |  2 +-
 dev/i2c/rs5c372.c                                     |  2 +-
 dev/i2c/s390.c                                        |  2 +-
 dev/i2c/tps65950.c                                    |  2 +-
 dev/i2c/x1226.c                                       |  2 +-
 dev/ic/intersil7170.c                                 |  2 +-
 dev/ic/mc146818.c                                     |  2 +-
 dev/ic/mk48txx.c                                      |  2 +-
 dev/ic/mm58167.c                                      |  2 +-
 dev/ic/msm6242b.c                                     |  2 +-
 dev/ic/rs5c313.c                                      |  2 +-
 dev/mvme/clockvar.h                                   |  2 +-
 dev/ofw/ofrtc.c                                       |  2 +-
 dev/pci/voyagervar.h                                  |  2 +-
 .../bsd/compiler_rt/dist/test/Unit/ppc/fixtfdi_test.c |  2 +-
 .../dist/test/builtins/Unit/ppc/fixtfdi_test.c        |  2 +-
 fs/msdosfs/msdosfs_conv.c                             |  2 +-
 fs/smbfs/smbfs_subr.c                                 |  5 +++--
 fs/udf/udf_allocation.c                               |  2 +-
 fs/udf/udf_readwrite.c                                |  2 +-
 fs/udf/udf_strat_bootstrap.c                          |  2 +-
 fs/udf/udf_strat_direct.c                             |  2 +-
 fs/udf/udf_strat_rmw.c                                |  2 +-
 fs/udf/udf_strat_sequential.c                         |  2 +-
 fs/udf/udf_subr.c                                     |  2 +-
 kern/kern_todr.c                                      | 16 ++++++++--------
 153 files changed, 185 insertions(+), 215 deletions(-)

diff --git a/arch/algor/dev/mcclock_mainbus.c b/arch/algor/dev/mcclock_mainbus.c
index 18674ed..7ee109b 100644
--- a/arch/algor/dev/mcclock_mainbus.c
+++ b/arch/algor/dev/mcclock_mainbus.c
@@ -39,7 +39,7 @@ __KERNEL_RCSID(0, "$NetBSD: mcclock_mainbus.c,v 1.12 2011/07/09 16:03:01 matt Ex
 
 #include <algor/autoconf.h>
 
-#include <dev/clock_subr.h>
+#include <sys/clock.h>
 
 #include <dev/ic/mc146818reg.h>
 #include <dev/ic/mc146818var.h>
diff --git a/arch/alpha/alpha/mcclock.c b/arch/alpha/alpha/mcclock.c
index c36447f..0bd3aee 100644
--- a/arch/alpha/alpha/mcclock.c
+++ b/arch/alpha/alpha/mcclock.c
@@ -41,7 +41,7 @@ __KERNEL_RCSID(0, "$NetBSD: mcclock.c,v 1.18 2011/11/21 19:50:37 christos Exp $"
 #include <sys/bus.h>
 #include <machine/cpu_counter.h>
 
-#include <dev/clock_subr.h>
+#include <sys/clock.h>
 
 #include <dev/ic/mc146818reg.h>
 #include <dev/ic/mc146818var.h>
diff --git a/arch/alpha/isa/mcclock_isa.c b/arch/alpha/isa/mcclock_isa.c
index 97d324d..11c3f92 100644
--- a/arch/alpha/isa/mcclock_isa.c
+++ b/arch/alpha/isa/mcclock_isa.c
@@ -38,7 +38,7 @@ __KERNEL_RCSID(0, "$NetBSD: mcclock_isa.c,v 1.20 2011/07/01 19:22:35 dyoung Exp
 
 #include <sys/bus.h>
 
-#include <dev/clock_subr.h>
+#include <sys/clock.h>
 
 #include <dev/ic/mc146818reg.h>
 #include <dev/ic/mc146818var.h>
diff --git a/arch/alpha/jensenio/mcclock_jensenio.c b/arch/alpha/jensenio/mcclock_jensenio.c
index 2e0941d..924a95b 100644
--- a/arch/alpha/jensenio/mcclock_jensenio.c
+++ b/arch/alpha/jensenio/mcclock_jensenio.c
@@ -67,7 +67,7 @@ __KERNEL_RCSID(0, "$NetBSD: mcclock_jensenio.c,v 1.10 2011/07/01 19:22:35 dyoung
 
 #include <sys/bus.h>
 
-#include <dev/clock_subr.h>
+#include <sys/clock.h>
 
 #include <dev/ic/mc146818reg.h>
 #include <dev/ic/mc146818var.h>
diff --git a/arch/alpha/tc/mcclock_ioasic.c b/arch/alpha/tc/mcclock_ioasic.c
index a718bf7..59d1d68 100644
--- a/arch/alpha/tc/mcclock_ioasic.c
+++ b/arch/alpha/tc/mcclock_ioasic.c
@@ -38,7 +38,7 @@ __KERNEL_RCSID(0, "$NetBSD: mcclock_ioasic.c,v 1.17 2012/02/06 02:14:16 matt Exp
 
 #include <sys/bus.h>
 
-#include <dev/clock_subr.h>
+#include <sys/clock.h>
 
 #include <dev/ic/mc146818reg.h>
 #include <dev/ic/mc146818var.h>
diff --git a/arch/alpha/tlsb/mcclock_tlsb.c b/arch/alpha/tlsb/mcclock_tlsb.c
index 5f2d324..668cc91 100644
--- a/arch/alpha/tlsb/mcclock_tlsb.c
+++ b/arch/alpha/tlsb/mcclock_tlsb.c
@@ -45,7 +45,7 @@ __KERNEL_RCSID(0, "$NetBSD: mcclock_tlsb.c,v 1.17 2011/07/01 19:19:51 dyoung Exp
 
 #include <alpha/tlsb/tlsbreg.h>		/* XXX */
 
-#include <dev/clock_subr.h>
+#include <sys/clock.h>
 
 #include <dev/ic/mc146818reg.h>
 #include <dev/ic/mc146818var.h>
diff --git a/arch/amiga/dev/a2kbbc.c b/arch/amiga/dev/a2kbbc.c
index 9af9fde..c9c9754 100644
--- a/arch/amiga/dev/a2kbbc.c
+++ b/arch/amiga/dev/a2kbbc.c
@@ -53,7 +53,7 @@ __KERNEL_RCSID(0, "$NetBSD: a2kbbc.c,v 1.26 2013/01/27 19:58:04 rkujawa Exp $");
 #include <amiga/amiga/cia.h>
 #include <amiga/dev/zbusvar.h>
 
-#include <dev/clock_subr.h>
+#include <sys/clock.h>
 
 #include <dev/ic/msm6242bvar.h>
 #include <dev/ic/msm6242breg.h>
diff --git a/arch/amiga/dev/a34kbbc.c b/arch/amiga/dev/a34kbbc.c
index 14bd9d2..f48661f 100644
--- a/arch/amiga/dev/a34kbbc.c
+++ b/arch/amiga/dev/a34kbbc.c
@@ -53,7 +53,7 @@ __KERNEL_RCSID(0, "$NetBSD: a34kbbc.c,v 1.23 2012/10/27 17:17:26 chs Exp $");
 #include <amiga/dev/rtc.h>
 #include <amiga/dev/zbusvar.h>
 
-#include <dev/clock_subr.h>
+#include <sys/clock.h>
 
 int a34kbbc_match(device_t, cfdata_t, void *);
 void a34kbbc_attach(device_t, device_t, void *);
diff --git a/arch/amiga/dev/drbbc.c b/arch/amiga/dev/drbbc.c
index 4bc7b70..0128294 100644
--- a/arch/amiga/dev/drbbc.c
+++ b/arch/amiga/dev/drbbc.c
@@ -47,7 +47,7 @@ __KERNEL_RCSID(0, "$NetBSD: drbbc.c,v 1.20 2012/10/27 17:17:28 chs Exp $");
 #include <amiga/amiga/drcustom.h>
 #include <amiga/dev/rtc.h>
 
-#include <dev/clock_subr.h>
+#include <sys/clock.h>
 #include <dev/ic/ds.h>
 
 int draco_ds_read_bit(void *);
diff --git a/arch/arc/arc/c_jazz_eisa.c b/arch/arc/arc/c_jazz_eisa.c
index 80f249c..9d17121 100644
--- a/arch/arc/arc/c_jazz_eisa.c
+++ b/arch/arc/arc/c_jazz_eisa.c
@@ -44,7 +44,7 @@ __KERNEL_RCSID(0, "$NetBSD: c_jazz_eisa.c,v 1.14 2012/10/13 17:58:53 jdc Exp $")
 #include <machine/pio.h>
 #include <machine/platform.h>
 
-#include <dev/clock_subr.h>
+#include <sys/clock.h>
 #include <dev/ic/mc146818var.h>
 
 #include <arc/arc/arcbios.h>
diff --git a/arch/arc/arc/c_nec_pci.c b/arch/arc/arc/c_nec_pci.c
index 44ac818..89adb86 100644
--- a/arch/arc/arc/c_nec_pci.c
+++ b/arch/arc/arc/c_nec_pci.c
@@ -49,7 +49,7 @@ __KERNEL_RCSID(0, "$NetBSD: c_nec_pci.c,v 1.20 2012/10/13 17:58:53 jdc Exp $");
 #include <machine/wired_map.h>
 #include <mips/pte.h>
 
-#include <dev/clock_subr.h>
+#include <sys/clock.h>
 #include <dev/ic/mc146818var.h>
 
 #include <dev/pci/pcivar.h>
diff --git a/arch/arc/isa/mcclock_isa.c b/arch/arc/isa/mcclock_isa.c
index 3591a11..eb87194 100644
--- a/arch/arc/isa/mcclock_isa.c
+++ b/arch/arc/isa/mcclock_isa.c
@@ -52,7 +52,7 @@ __KERNEL_RCSID(0, "$NetBSD: mcclock_isa.c,v 1.15 2011/07/01 19:25:41 dyoung Exp
 #include <dev/isa/isareg.h>
 #include <dev/isa/isavar.h>
 
-#include <dev/clock_subr.h>
+#include <sys/clock.h>
 
 #include <dev/ic/mc146818reg.h>
 #include <dev/ic/mc146818var.h>
diff --git a/arch/arc/jazz/mcclock_jazzio.c b/arch/arc/jazz/mcclock_jazzio.c
index b83ac65..1408f6f 100644
--- a/arch/arc/jazz/mcclock_jazzio.c
+++ b/arch/arc/jazz/mcclock_jazzio.c
@@ -50,7 +50,7 @@ __KERNEL_RCSID(0, "$NetBSD: mcclock_jazzio.c,v 1.13 2011/07/01 19:25:42 dyoung E
 #include <machine/autoconf.h>
 #include <sys/bus.h>
 
-#include <dev/clock_subr.h>
+#include <sys/clock.h>
 
 #include <dev/ic/mc146818reg.h>
 #include <dev/ic/mc146818var.h>
diff --git a/arch/arm/allwinner/awin_rtc.c b/arch/arm/allwinner/awin_rtc.c
index 51e6abc..baddc48 100644
--- a/arch/arm/allwinner/awin_rtc.c
+++ b/arch/arm/allwinner/awin_rtc.c
@@ -39,7 +39,7 @@ __KERNEL_RCSID(0, "$NetBSD: awin_rtc.c,v 1.1 2014/09/07 17:49:39 jmcneill Exp $"
 #include <arm/allwinner/awin_reg.h>
 #include <arm/allwinner/awin_var.h>
 
-#include <dev/clock_subr.h>
+#include <sys/clock.h>
 
 struct awin_rtc_softc {
 	device_t sc_dev;
diff --git a/arch/arm/arm32/arm11_pmc.c b/arch/arm/arm32/arm11_pmc.c
index 0d04dec..603066e 100644
--- a/arch/arm/arm32/arm11_pmc.c
+++ b/arch/arm/arm32/arm11_pmc.c
@@ -42,7 +42,7 @@ __KERNEL_RCSID(0, "$NetBSD: arm11_pmc.c,v 1.4 2013/12/01 02:53:46 joerg Exp $");
 #include <sys/kernel.h>  
 #include <sys/time.h>
 #include <sys/timetc.h>
-#include <dev/clock_subr.h>
+#include <sys/clock.h>
 #include <arm/armreg.h>
 #include <arm/cpufunc.h>
 
diff --git a/arch/arm/arm32/cortex_pmc.c b/arch/arm/arm32/cortex_pmc.c
index 3c8c401..bb0e550 100644
--- a/arch/arm/arm32/cortex_pmc.c
+++ b/arch/arm/arm32/cortex_pmc.c
@@ -42,7 +42,7 @@
 #include <sys/time.h>
 #include <sys/timetc.h>
 
-#include <dev/clock_subr.h>
+#include <sys/clock.h>
 
 #include <uvm/uvm_extern.h>
 
diff --git a/arch/arm/at91/at91st.c b/arch/arm/at91/at91st.c
index d021179..fa4b8fa 100644
--- a/arch/arm/at91/at91st.c
+++ b/arch/arm/at91/at91st.c
@@ -49,7 +49,7 @@ __KERNEL_RCSID(0, "$NetBSD: at91st.c,v 1.6 2012/11/12 18:00:36 skrll Exp $");
 #include <sys/time.h>
 #include <sys/device.h>
 
-#include <dev/clock_subr.h>
+#include <sys/clock.h>
 
 #include <sys/bus.h>
 #include <machine/intr.h>
diff --git a/arch/arm/at91/at91tctmr.c b/arch/arm/at91/at91tctmr.c
index a58998f..cbfca0e 100644
--- a/arch/arm/at91/at91tctmr.c
+++ b/arch/arm/at91/at91tctmr.c
@@ -50,7 +50,7 @@ __KERNEL_RCSID(0, "$NetBSD: at91tctmr.c,v 1.7 2012/11/12 18:00:36 skrll Exp $");
 #include <sys/timetc.h>
 #include <sys/device.h>
 
-#include <dev/clock_subr.h>
+#include <sys/clock.h>
 
 #include <sys/bus.h>
 #include <machine/intr.h>
diff --git a/arch/arm/clps711x/clpsrtc.c b/arch/arm/clps711x/clpsrtc.c
index c6fb546..ce3c0c3 100644
--- a/arch/arm/clps711x/clpsrtc.c
+++ b/arch/arm/clps711x/clpsrtc.c
@@ -32,7 +32,7 @@ __KERNEL_RCSID(0, "$NetBSD: clpsrtc.c,v 1.1 2013/04/28 11:57:13 kiyohara Exp $")
 #include <sys/device.h>
 #include <sys/errno.h>
 
-#include <dev/clock_subr.h>
+#include <sys/clock.h>
 
 #include <arm/clps711x/clps711xreg.h>
 #include <arm/clps711x/clpssocvar.h>
diff --git a/arch/arm/ep93xx/epclk.c b/arch/arm/ep93xx/epclk.c
index a2e2737..0fb592e 100644
--- a/arch/arm/ep93xx/epclk.c
+++ b/arch/arm/ep93xx/epclk.c
@@ -59,7 +59,7 @@ __KERNEL_RCSID(0, "$NetBSD: epclk.c,v 1.21 2014/03/06 19:46:27 maxv Exp $");
 #include <arm/ep93xx/epclkreg.h> 
 #include <arm/ep93xx/ep93xxreg.h> 
 #include <arm/ep93xx/ep93xxvar.h>
-#include <dev/clock_subr.h>
+#include <sys/clock.h>
 
 #include "opt_hz.h"
 
diff --git a/arch/arm/ep93xx/eprtc.c b/arch/arm/ep93xx/eprtc.c
index c77b721..c8e53d9 100644
--- a/arch/arm/ep93xx/eprtc.c
+++ b/arch/arm/ep93xx/eprtc.c
@@ -32,7 +32,7 @@ __KERNEL_RCSID(0, "$NetBSD: eprtc.c,v 1.6 2012/10/27 17:17:37 chs Exp $");
 #include <sys/systm.h>
 #include <sys/kernel.h>
 #include <sys/device.h>
-#include <dev/clock_subr.h>
+#include <sys/clock.h>
 #include <sys/bus.h>
 #include <arm/ep93xx/ep93xxvar.h> 
 #include <arm/ep93xx/epsocvar.h> 
diff --git a/arch/arm/footbridge/isa/dsrtc.c b/arch/arm/footbridge/isa/dsrtc.c
index 4b58a48..a2f8679 100644
--- a/arch/arm/footbridge/isa/dsrtc.c
+++ b/arch/arm/footbridge/isa/dsrtc.c
@@ -45,7 +45,7 @@ __KERNEL_RCSID(0, "$NetBSD: dsrtc.c,v 1.12 2012/10/11 08:53:27 skrll Exp $");
 #include <sys/conf.h>
 #include <sys/device.h>
 
-#include <dev/clock_subr.h>
+#include <sys/clock.h>
 #include <arm/footbridge/isa/ds1687reg.h>
 
 #include <dev/isa/isavar.h>
diff --git a/arch/arm/gemini/gemini_timer.c b/arch/arm/gemini/gemini_timer.c
index 33296f4..7affde3 100644
--- a/arch/arm/gemini/gemini_timer.c
+++ b/arch/arm/gemini/gemini_timer.c
@@ -94,7 +94,7 @@ __KERNEL_RCSID(0, "$NetBSD: gemini_timer.c,v 1.7 2014/03/18 12:54:29 martin Exp
 #include <sys/timetc.h>
 #include <sys/device.h>
 
-#include <dev/clock_subr.h>
+#include <sys/clock.h>
 
 #include <sys/bus.h>
 #include <machine/intr.h>
diff --git a/arch/arm/gemini/obio_timer.c b/arch/arm/gemini/obio_timer.c
index 0a5ee4b..7392aa2 100644
--- a/arch/arm/gemini/obio_timer.c
+++ b/arch/arm/gemini/obio_timer.c
@@ -118,7 +118,7 @@ __KERNEL_RCSID(0, "$NetBSD: obio_timer.c,v 1.5 2011/07/01 19:32:28 dyoung Exp $"
 #include <sys/time.h>
 #include <sys/device.h>
 
-#include <dev/clock_subr.h>
+#include <sys/clock.h>
 
 #include <sys/bus.h>
 #include <machine/intr.h>
diff --git a/arch/arm/imx/imx51_clock.c b/arch/arm/imx/imx51_clock.c
index 1c21d4d..4b4f35c 100644
--- a/arch/arm/imx/imx51_clock.c
+++ b/arch/arm/imx/imx51_clock.c
@@ -41,7 +41,7 @@ __KERNEL_RCSID(0, "$NetBSD: imx51_clock.c,v 1.5 2014/07/25 07:49:56 hkenken Exp
 #include <sys/types.h>
 #include <sys/device.h>
 
-#include <dev/clock_subr.h>
+#include <sys/clock.h>
 
 #include <machine/intr.h>
 #include <sys/bus.h>
diff --git a/arch/arm/iomd/iomd_clock.c b/arch/arm/iomd/iomd_clock.c
index a372c30..08f1263 100644
--- a/arch/arm/iomd/iomd_clock.c
+++ b/arch/arm/iomd/iomd_clock.c
@@ -57,7 +57,7 @@ __KERNEL_RCSID(0, "$NetBSD: iomd_clock.c,v 1.29 2012/05/18 21:09:50 skrll Exp $"
 #include <sys/device.h>
 #include <sys/intr.h>
 
-#include <dev/clock_subr.h>
+#include <sys/clock.h>
 
 #include <arm/cpufunc.h>
 
diff --git a/arch/arm/marvell/mvsocrtc.c b/arch/arm/marvell/mvsocrtc.c
index 9137344..fc9c5b2 100644
--- a/arch/arm/marvell/mvsocrtc.c
+++ b/arch/arm/marvell/mvsocrtc.c
@@ -43,7 +43,7 @@ __KERNEL_RCSID(0, "$NetBSD: mvsocrtc.c,v 1.2 2011/07/01 20:30:21 dyoung Exp $");
 #include <sys/device.h>
 #include <sys/kernel.h>
 
-#include <dev/clock_subr.h>
+#include <sys/clock.h>
 
 #include <sys/bus.h>
 
diff --git a/arch/arm/mpcore/mpcore_clock.c b/arch/arm/mpcore/mpcore_clock.c
index d22e0ff..c937ee9 100644
--- a/arch/arm/mpcore/mpcore_clock.c
+++ b/arch/arm/mpcore/mpcore_clock.c
@@ -38,7 +38,7 @@ __KERNEL_RCSID(0, "$NetBSD: mpcore_clock.c,v 1.2 2011/07/01 20:30:21 dyoung Exp
 #include <sys/types.h>
 #include <sys/device.h>
 
-#include <dev/clock_subr.h>
+#include <sys/clock.h>
 
 #include <machine/intr.h>
 #include <sys/bus.h>
diff --git a/arch/arm/omap/obio_mputmr.c b/arch/arm/omap/obio_mputmr.c
index 2abe749..293adf6 100644
--- a/arch/arm/omap/obio_mputmr.c
+++ b/arch/arm/omap/obio_mputmr.c
@@ -113,7 +113,7 @@ __KERNEL_RCSID(0, "$NetBSD: obio_mputmr.c,v 1.8 2013/06/16 17:47:54 matt Exp $")
 #include <sys/time.h>
 #include <sys/device.h>
 
-#include <dev/clock_subr.h>
+#include <sys/clock.h>
 
 #include <sys/bus.h>
 #include <machine/intr.h>
diff --git a/arch/arm/omap/omap2_mputmr.c b/arch/arm/omap/omap2_mputmr.c
index 60095e2..75cf779 100644
--- a/arch/arm/omap/omap2_mputmr.c
+++ b/arch/arm/omap/omap2_mputmr.c
@@ -92,7 +92,7 @@ __KERNEL_RCSID(0, "$NetBSD: omap2_mputmr.c,v 1.8 2013/12/01 02:53:46 joerg Exp $
 #include <sys/bus.h>
 #include <sys/intr.h>
 
-#include <dev/clock_subr.h>
+#include <sys/clock.h>
 
 #include <arm/omap/omap_var.h>
 #include <arm/omap/omap_gptmrreg.h>
diff --git a/arch/arm/omap/omap3_sdmavar.h b/arch/arm/omap/omap3_sdmavar.h
index edd766c..1395f83 100644
--- a/arch/arm/omap/omap3_sdmavar.h
+++ b/arch/arm/omap/omap3_sdmavar.h
@@ -38,4 +38,4 @@ void omapdma_write_ch_reg(int, int, uint32_t);
 uint32_t omapdma_read_ch_reg(int, int);
 
 
-#endif /* OMAPDMA_VAR_H */
\ No newline at end of file
+#endif /* OMAPDMA_VAR_H */
diff --git a/arch/arm/omap/omap_mputmr.c b/arch/arm/omap/omap_mputmr.c
index 4464255..313eadd 100644
--- a/arch/arm/omap/omap_mputmr.c
+++ b/arch/arm/omap/omap_mputmr.c
@@ -83,7 +83,7 @@ __KERNEL_RCSID(0, "$NetBSD: omap_mputmr.c,v 1.6 2011/07/01 20:30:21 dyoung Exp $
 #include <sys/timetc.h>
 #include <sys/device.h>
 
-#include <dev/clock_subr.h>
+#include <sys/clock.h>
 
 #include <sys/bus.h>
 #include <machine/intr.h>
diff --git a/arch/arm/omap/omap_rtc.c b/arch/arm/omap/omap_rtc.c
index 539ff88..092abed 100644
--- a/arch/arm/omap/omap_rtc.c
+++ b/arch/arm/omap/omap_rtc.c
@@ -40,7 +40,7 @@ __KERNEL_RCSID(0, "$NetBSD: omap_rtc.c,v 1.5 2011/07/01 20:30:21 dyoung Exp $");
 #include <sys/kernel.h>
 #include <sys/time.h>
 #include <sys/device.h>
-#include <dev/clock_subr.h>
+#include <sys/clock.h>
 
 #include <sys/bus.h>
 #include <machine/intr.h>
diff --git a/arch/arm/omap/omapl1x_timer.c b/arch/arm/omap/omapl1x_timer.c
index 7810412..945190b 100644
--- a/arch/arm/omap/omapl1x_timer.c
+++ b/arch/arm/omap/omapl1x_timer.c
@@ -38,7 +38,7 @@ __KERNEL_RCSID(0, "$NetBSD: omapl1x_timer.c,v 1.1 2013/10/02 16:48:26 matt Exp $
 #include <sys/device.h>
 #include <sys/bus.h>
 
-#include <dev/clock_subr.h>
+#include <sys/clock.h>
 
 #include <machine/intr.h>
 
diff --git a/arch/arm/s3c2xx0/s3c2440_rtc.c b/arch/arm/s3c2xx0/s3c2440_rtc.c
index 87ef455..13f0870 100644
--- a/arch/arm/s3c2xx0/s3c2440_rtc.c
+++ b/arch/arm/s3c2xx0/s3c2440_rtc.c
@@ -33,7 +33,7 @@
 #include <sys/bus.h>
 #include <sys/time.h>
 
-#include <dev/clock_subr.h>
+#include <sys/clock.h>
 
 #include <arm/s3c2xx0/s3c24x0var.h>
 #include <arm/s3c2xx0/s3c2440var.h>
diff --git a/arch/arm/xscale/becc_timer.c b/arch/arm/xscale/becc_timer.c
index b553201..efd4ef5 100644
--- a/arch/arm/xscale/becc_timer.c
+++ b/arch/arm/xscale/becc_timer.c
@@ -49,7 +49,7 @@ __KERNEL_RCSID(0, "$NetBSD: becc_timer.c,v 1.15 2011/07/01 20:32:51 dyoung Exp $
 #include <sys/time.h>
 #include <sys/timetc.h>
 
-#include <dev/clock_subr.h>
+#include <sys/clock.h>
 
 #include <sys/bus.h>
 #include <arm/cpufunc.h>
diff --git a/arch/arm/xscale/i80321_timer.c b/arch/arm/xscale/i80321_timer.c
index 22c3a55..0b4c8cb 100644
--- a/arch/arm/xscale/i80321_timer.c
+++ b/arch/arm/xscale/i80321_timer.c
@@ -51,7 +51,7 @@ __KERNEL_RCSID(0, "$NetBSD: i80321_timer.c,v 1.21 2013/12/17 01:28:56 joerg Exp
 #include <sys/time.h>
 #include <sys/timetc.h>
 
-#include <dev/clock_subr.h>
+#include <sys/clock.h>
 
 #include <sys/bus.h>
 #include <arm/cpufunc.h>
diff --git a/arch/arm/xscale/ixp425_timer.c b/arch/arm/xscale/ixp425_timer.c
index 4fda194..1a51722 100644
--- a/arch/arm/xscale/ixp425_timer.c
+++ b/arch/arm/xscale/ixp425_timer.c
@@ -42,7 +42,7 @@ __KERNEL_RCSID(0, "$NetBSD: ixp425_timer.c,v 1.18 2012/11/12 18:00:38 skrll Exp
 #include <sys/timetc.h>
 #include <sys/device.h>
 
-#include <dev/clock_subr.h>
+#include <sys/clock.h>
 
 #include <sys/bus.h>
 #include <machine/intr.h>
diff --git a/arch/arm/xscale/ixp425_wdog.c b/arch/arm/xscale/ixp425_wdog.c
index 69b02e2..0997a08 100644
--- a/arch/arm/xscale/ixp425_wdog.c
+++ b/arch/arm/xscale/ixp425_wdog.c
@@ -40,7 +40,7 @@ __KERNEL_RCSID(0, "$NetBSD: ixp425_wdog.c,v 1.4 2012/10/14 14:20:58 msaitoh Exp
 #include <sys/device.h>
 #include <sys/wdog.h>
 
-#include <dev/clock_subr.h>
+#include <sys/clock.h>
 #include <dev/sysmon/sysmonvar.h>
 
 #include <machine/intr.h>
diff --git a/arch/arm/xscale/pxa2x0_rtc.c b/arch/arm/xscale/pxa2x0_rtc.c
index 542fc45..0a52a97 100644
--- a/arch/arm/xscale/pxa2x0_rtc.c
+++ b/arch/arm/xscale/pxa2x0_rtc.c
@@ -29,7 +29,7 @@ __KERNEL_RCSID(0, "$NetBSD: pxa2x0_rtc.c,v 1.6 2012/10/27 17:17:42 chs Exp $");
 #include <sys/device.h>
 #include <sys/kernel.h>
 
-#include <dev/clock_subr.h>
+#include <sys/clock.h>
 
 #include <sys/bus.h>
 
diff --git a/arch/atari/dev/clock.c b/arch/atari/dev/clock.c
index 70d5a05..aae64cc 100644
--- a/arch/atari/dev/clock.c
+++ b/arch/atari/dev/clock.c
@@ -51,7 +51,7 @@ __KERNEL_RCSID(0, "$NetBSD: clock.c,v 1.59 2014/07/25 08:10:32 dholland Exp $");
 #include <sys/event.h>
 #include <sys/timetc.h>
 
-#include <dev/clock_subr.h>
+#include <sys/clock.h>
 
 #include <machine/psl.h>
 #include <machine/cpu.h>
diff --git a/arch/atari/dev/clockreg.h b/arch/atari/dev/clockreg.h
index 83fdb09..79b808e 100644
--- a/arch/atari/dev/clockreg.h
+++ b/arch/atari/dev/clockreg.h
@@ -56,10 +56,6 @@ struct rtc {
 /*
  * Some useful constants/macros
  */
-#define	is_leap(x)		(!(x % 4) && ((x % 100) || !(x % 1000)))
 #define	range_test(n, l, h)	((n) < (l) || (n) > (h))
-#define	SECS_DAY		86400L
-#define	SECS_HOUR		3600L
 #define	GEMSTARTOFTIME		((machineid & ATARI_CLKBROKEN) ? 1970 : 1968)
-#define	BSDSTARTOFTIME		1970
 #endif /* _CLOCKREG_H */
diff --git a/arch/bebox/isa/mcclock_isa.c b/arch/bebox/isa/mcclock_isa.c
index 656ee81..49c4b87 100644
--- a/arch/bebox/isa/mcclock_isa.c
+++ b/arch/bebox/isa/mcclock_isa.c
@@ -127,7 +127,7 @@ __KERNEL_RCSID(0, "$NetBSD: mcclock_isa.c,v 1.6 2014/06/20 09:47:15 phx Exp $");
 
 #include <sys/bus.h>
 
-#include <dev/clock_subr.h>
+#include <sys/clock.h>
 #include <dev/isa/isareg.h>
 #include <dev/isa/isavar.h>
 #include <dev/ic/mc146818reg.h>
diff --git a/arch/cobalt/dev/mcclock.c b/arch/cobalt/dev/mcclock.c
index b3dced6..9e484ff 100644
--- a/arch/cobalt/dev/mcclock.c
+++ b/arch/cobalt/dev/mcclock.c
@@ -40,7 +40,7 @@ __KERNEL_RCSID(0, "$NetBSD: mcclock.c,v 1.5 2011/07/01 20:36:42 dyoung Exp $");
 #include <machine/autoconf.h>
 #include <sys/bus.h>
 
-#include <dev/clock_subr.h>
+#include <sys/clock.h>
 #include <dev/ic/mc146818reg.h>
 #include <dev/ic/mc146818var.h>
 
diff --git a/arch/dreamcast/dev/g2/g2rtc.c b/arch/dreamcast/dev/g2/g2rtc.c
index a59fee0..99c6f7e 100644
--- a/arch/dreamcast/dev/g2/g2rtc.c
+++ b/arch/dreamcast/dev/g2/g2rtc.c
@@ -34,7 +34,7 @@ __KERNEL_RCSID(0, "$NetBSD: g2rtc.c,v 1.6 2011/07/19 15:52:29 dyoung Exp $");
 #include <sys/device.h>
 #include <sys/bus.h>
 
-#include <dev/clock_subr.h>
+#include <sys/clock.h>
 
 #include <dreamcast/dev/g2/g2busvar.h>
 
@@ -43,7 +43,7 @@ __KERNEL_RCSID(0, "$NetBSD: g2rtc.c,v 1.6 2011/07/19 15:52:29 dyoung Exp $");
 #define G2RTC_REG_SIZE	12
 
 /* Offset by 20 years, 5 of them are leap */
-#define G2RTC_OFFSET	(20 * SECYR + 5 * SECDAY)
+#define G2RTC_OFFSET	(20 * SECS_PER_COMMON_YEAR + 5 * SECS_PER_DAY)
 
 struct g2rtc_softc {
 	device_t sc_dev;
diff --git a/arch/emips/ebus/clock_ebus.c b/arch/emips/ebus/clock_ebus.c
index 86f4e78..d032c64 100644
--- a/arch/emips/ebus/clock_ebus.c
+++ b/arch/emips/ebus/clock_ebus.c
@@ -39,7 +39,7 @@ __KERNEL_RCSID(0, "$NetBSD: clock_ebus.c,v 1.8 2014/02/24 14:26:11 martin Exp $"
 #include <sys/systm.h>
 #include <sys/timetc.h>
 
-#include <dev/clock_subr.h>
+#include <sys/clock.h>
 
 #include <emips/ebus/ebusvar.h>
 #include <emips/emips/machdep.h>
diff --git a/arch/epoc32/windermere/wmrtc.c b/arch/epoc32/windermere/wmrtc.c
index c10d47a..d5670cf 100644
--- a/arch/epoc32/windermere/wmrtc.c
+++ b/arch/epoc32/windermere/wmrtc.c
@@ -32,7 +32,7 @@ __KERNEL_RCSID(0, "$NetBSD: wmrtc.c,v 1.1 2013/04/28 12:11:26 kiyohara Exp $");
 #include <sys/device.h>
 #include <sys/errno.h>
 
-#include <dev/clock_subr.h>
+#include <sys/clock.h>
 
 #include <epoc32/windermere/windermerereg.h>
 #include <epoc32/windermere/windermerevar.h>
diff --git a/arch/evbarm/ifpga/pl030_rtc.c b/arch/evbarm/ifpga/pl030_rtc.c
index ec07df2..c66f071 100644
--- a/arch/evbarm/ifpga/pl030_rtc.c
+++ b/arch/evbarm/ifpga/pl030_rtc.c
@@ -41,7 +41,7 @@ __KERNEL_RCSID(0, "$NetBSD: pl030_rtc.c,v 1.10 2009/12/12 14:44:09 tsutsui Exp $
 #include <sys/time.h>
 #include <sys/device.h>
 
-#include <dev/clock_subr.h>
+#include <sys/clock.h>
 
 #include <arm/cpufunc.h>
 #include <machine/intr.h>
diff --git a/arch/evbarm/iq80310/iq80310_timer.c b/arch/evbarm/iq80310/iq80310_timer.c
index 8e72d13..735582f 100644
--- a/arch/evbarm/iq80310/iq80310_timer.c
+++ b/arch/evbarm/iq80310/iq80310_timer.c
@@ -56,7 +56,7 @@ __KERNEL_RCSID(0, "$NetBSD: iq80310_timer.c,v 1.22 2011/07/01 20:41:16 dyoung Ex
 #include <sys/time.h>
 #include <sys/timetc.h>
 
-#include <dev/clock_subr.h>
+#include <sys/clock.h>
 
 #include <sys/bus.h>
 #include <arm/cpufunc.h>
diff --git a/arch/evbarm/tsarm/tsrtc.c b/arch/evbarm/tsarm/tsrtc.c
index e74f4a6..d7c1c83 100644
--- a/arch/evbarm/tsarm/tsrtc.c
+++ b/arch/evbarm/tsarm/tsrtc.c
@@ -39,7 +39,7 @@ __KERNEL_RCSID(0, "$NetBSD: tsrtc.c,v 1.7 2011/07/01 19:11:34 dyoung Exp $");
 
 #include <sys/bus.h>
 
-#include <dev/clock_subr.h>
+#include <sys/clock.h>
 #include <dev/ic/mc146818reg.h>
 #include <dev/ic/mc146818var.h>
 
diff --git a/arch/evbmips/isa/mcclock_isa.c b/arch/evbmips/isa/mcclock_isa.c
index 86293a2..e62b9fc 100644
--- a/arch/evbmips/isa/mcclock_isa.c
+++ b/arch/evbmips/isa/mcclock_isa.c
@@ -38,7 +38,7 @@ __KERNEL_RCSID(0, "$NetBSD: mcclock_isa.c,v 1.14 2011/07/08 18:49:48 matt Exp $"
 
 #include <sys/bus.h>
 
-#include <dev/clock_subr.h>
+#include <sys/clock.h>
 #include <dev/ic/mc146818reg.h>
 #include <dev/ic/mc146818var.h>
 
diff --git a/arch/evbppc/mpc85xx/ds1553rtc.c b/arch/evbppc/mpc85xx/ds1553rtc.c
index 0a76878..d1143a2 100644
--- a/arch/evbppc/mpc85xx/ds1553rtc.c
+++ b/arch/evbppc/mpc85xx/ds1553rtc.c
@@ -50,7 +50,7 @@ __KERNEL_RCSID(0, "$NetBSD: ds1553rtc.c,v 1.2 2011/01/18 01:10:25 matt Exp $");
 #include <sys/intr.h>
 #include <sys/bus.h>
 
-#include <dev/clock_subr.h>
+#include <sys/clock.h>
 #include <dev/ic/mk48txxvar.h>
 
 #include <powerpc/booke/cpuvar.h>
diff --git a/arch/evbppc/pmppc/dev/ds17485.c b/arch/evbppc/pmppc/dev/ds17485.c
index d0f169e..37d77cd 100644
--- a/arch/evbppc/pmppc/dev/ds17485.c
+++ b/arch/evbppc/pmppc/dev/ds17485.c
@@ -161,7 +161,7 @@ __KERNEL_RCSID(0, "$NetBSD: ds17485.c,v 1.8 2011/07/01 19:03:09 dyoung Exp $");
 #include <machine/intr.h>
 #include <sys/bus.h>
 
-#include <dev/clock_subr.h>
+#include <sys/clock.h>
 #include <dev/ic/mc146818reg.h>
 #include <dev/ic/mc146818var.h>
 
diff --git a/arch/evbppc/walnut/dev/ds1743.c b/arch/evbppc/walnut/dev/ds1743.c
index 04de70c..fcedd42 100644
--- a/arch/evbppc/walnut/dev/ds1743.c
+++ b/arch/evbppc/walnut/dev/ds1743.c
@@ -43,7 +43,7 @@ __KERNEL_RCSID(0, "$NetBSD: ds1743.c,v 1.9 2011/07/01 19:03:50 dyoung Exp $");
 #include <sys/param.h>
 #include <sys/systm.h>
 #include <sys/device.h>
-#include <dev/clock_subr.h>
+#include <sys/clock.h>
 
 #include <machine/rtc.h>
 #include <sys/bus.h>
diff --git a/arch/evbsh3/ap_ms104_sh4/rs5c316_mainbus.c b/arch/evbsh3/ap_ms104_sh4/rs5c316_mainbus.c
index 1719dd2..8e026c9 100644
--- a/arch/evbsh3/ap_ms104_sh4/rs5c316_mainbus.c
+++ b/arch/evbsh3/ap_ms104_sh4/rs5c316_mainbus.c
@@ -33,7 +33,7 @@ __KERNEL_RCSID(0, "$NetBSD: rs5c316_mainbus.c,v 1.2 2012/01/21 19:44:29 nonaka E
 #include <sys/device.h>
 #include <sys/kernel.h>
 
-#include <dev/clock_subr.h>
+#include <sys/clock.h>
 #include <dev/ic/rs5c313var.h>
 
 #include <machine/autoconf.h>
diff --git a/arch/ews4800mips/sbd/mkclock_sbdio.c b/arch/ews4800mips/sbd/mkclock_sbdio.c
index 4d7b555..a77225d 100644
--- a/arch/ews4800mips/sbd/mkclock_sbdio.c
+++ b/arch/ews4800mips/sbd/mkclock_sbdio.c
@@ -41,7 +41,7 @@ __KERNEL_RCSID(0, "$NetBSD: mkclock_sbdio.c,v 1.7 2008/04/28 20:23:18 martin Exp
 #include <machine/bus.h>
 #include <machine/sbdiovar.h>
 
-#include <dev/clock_subr.h>
+#include <sys/clock.h>
 
 #include <dev/ic/mk48txxreg.h>
 #include <dev/ic/mk48txxvar.h>
diff --git a/arch/hp300/dev/mcclock_frodo.c b/arch/hp300/dev/mcclock_frodo.c
index 8b1b205..fef0006 100644
--- a/arch/hp300/dev/mcclock_frodo.c
+++ b/arch/hp300/dev/mcclock_frodo.c
@@ -32,7 +32,7 @@ __KERNEL_RCSID(0, "$NetBSD: mcclock_frodo.c,v 1.1 2014/04/19 05:37:54 tsutsui Ex
 
 #include <machine/cpu.h>
 
-#include <dev/clock_subr.h>
+#include <sys/clock.h>
 #include <dev/ic/mc146818reg.h>
 #include <dev/ic/mc146818var.h>
 
diff --git a/arch/hp300/dev/rtc.c b/arch/hp300/dev/rtc.c
index 25d0bec..7adbb73 100644
--- a/arch/hp300/dev/rtc.c
+++ b/arch/hp300/dev/rtc.c
@@ -53,7 +53,7 @@ __KERNEL_RCSID(0, "$NetBSD: rtc.c,v 1.21 2014/04/19 05:37:54 tsutsui Exp $");
 #include <hp300/dev/intiovar.h>
 #include <hp300/dev/rtcreg.h>
 
-#include <dev/clock_subr.h>
+#include <sys/clock.h>
 
 struct rtc_softc {
 	device_t sc_dev;
diff --git a/arch/hp300/stand/common/clock.c b/arch/hp300/stand/common/clock.c
index 6b464c4..a6ec221 100644
--- a/arch/hp300/stand/common/clock.c
+++ b/arch/hp300/stand/common/clock.c
@@ -39,6 +39,7 @@
  */
 
 #include <sys/param.h>
+#include <sys/clock.h>
 
 #include <net/if_ether.h>
 #include <netinet/in.h>
@@ -55,25 +56,15 @@
 #include <hp300/stand/common/samachdep.h>
 
 #define FEBRUARY        2
-#define STARTOFTIME     1970
-#define SECDAY          (60L * 60L * 24L)
-#define SECYR           (SECDAY * 365)
 
 #define BBC_SET_REG     0xe0
 #define BBC_WRITE_REG   0xc2
 #define BBC_READ_REG    0xc3
 #define NUM_BBC_REGS    12
 
-#define leapyear(year)		((year) % 4 == 0)
 #define range_test(n, l, h)	if ((n) < (l) || (n) > (h)) return false
-#define days_in_year(a)		(leapyear(a) ? 366 : 365)
-#define days_in_month(a)	(month_days[(a) - 1])
 #define bbc_to_decimal(a,b)	(bbc_registers[a] * 10 + bbc_registers[b])
 
-static const int month_days[12] = {
-	31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31
-};
-
 static uint8_t bbc_registers[13];
 static struct hil_dev *bbcaddr = BBCADDR;
 
@@ -133,7 +124,7 @@ clock_to_gmt(satime_t *timbuf)
 		year  = bbc_to_decimal(12, 11) + 1900;
 	}
 
-	if (year < STARTOFTIME)
+	if (year < POSIX_BASE_YEAR)
 		year += 100;
 
 #ifdef CLOCK_DEBUG
@@ -147,9 +138,9 @@ clock_to_gmt(satime_t *timbuf)
 
 	tmp = 0;
 
-	for (i = STARTOFTIME; i < year; i++)
-		tmp += days_in_year(i);
-	if (leapyear(year) && month > FEBRUARY)
+	for (i = POSIX_BASE_YEAR; i < year; i++)
+		tmp += days_per_year(i);
+	if (is_leap_year(year) && month > FEBRUARY)
 		tmp++;
 
 	for (i = 1; i < month; i++)
diff --git a/arch/hpcmips/hpcmips/clock.c b/arch/hpcmips/hpcmips/clock.c
index a886a14..252d700 100644
--- a/arch/hpcmips/hpcmips/clock.c
+++ b/arch/hpcmips/hpcmips/clock.c
@@ -74,7 +74,7 @@ __KERNEL_RCSID(0, "$NetBSD: clock.c,v 1.22 2011/03/16 14:43:36 tsutsui Exp $");
 #include <sys/systm.h>
 #include <sys/kernel.h>			/* hz */
 
-#include <dev/clock_subr.h>
+#include <sys/clock.h>
 #include <machine/sysconf.h>		/* platform */
 
 /* 
diff --git a/arch/hpcmips/tx/tx39clock.c b/arch/hpcmips/tx/tx39clock.c
index 396e757..a5329dc 100644
--- a/arch/hpcmips/tx/tx39clock.c
+++ b/arch/hpcmips/tx/tx39clock.c
@@ -40,7 +40,7 @@ __KERNEL_RCSID(0, "$NetBSD: tx39clock.c,v 1.27 2012/10/27 17:17:54 chs Exp $");
 #include <sys/device.h>
 #include <sys/bus.h>
 
-#include <dev/clock_subr.h>
+#include <sys/clock.h>
 
 #include <machine/sysconf.h>
 
diff --git a/arch/hpcmips/vr/rtc.c b/arch/hpcmips/vr/rtc.c
index 710f7fd..e642246 100644
--- a/arch/hpcmips/vr/rtc.c
+++ b/arch/hpcmips/vr/rtc.c
@@ -49,7 +49,7 @@ __KERNEL_RCSID(0, "$NetBSD: rtc.c,v 1.32 2011/03/18 15:31:38 tsutsui Exp $");
 #include <machine/sysconf.h>
 #include <machine/bus.h>
 
-#include <dev/clock_subr.h>
+#include <sys/clock.h>
 
 #include <hpcmips/vr/vr.h>
 #include <hpcmips/vr/vrcpudef.h>
@@ -203,10 +203,10 @@ vrrtc_attach(device_t parent, device_t self, void *aux)
 	 * be on Jan 1.
 	 */
 	for (year = EPOCHYEAR; year < POSIX_BASE_YEAR; year++) {
-		sc->sc_epoch += LEAPYEAR4(year) ? SECYR + SECDAY : SECYR;
+		sc->sc_epoch += days_per_year(year);
 	}
 	for (year = POSIX_BASE_YEAR; year < EPOCHYEAR; year++) {
-		sc->sc_epoch -= LEAPYEAR4(year) ? SECYR + SECDAY : SECYR;
+		sc->sc_epoch -= days_per_year(year);
 	}
 
 	/*
diff --git a/arch/hpcmips/vr/rtcreg.h b/arch/hpcmips/vr/rtcreg.h
index 920854a..dbc2dd6 100644
--- a/arch/hpcmips/vr/rtcreg.h
+++ b/arch/hpcmips/vr/rtcreg.h
@@ -42,9 +42,6 @@
 #define EPOCHMONTH	1			/* WINCE epoch month of year */
 #define EPOCHDATE	1			/* WINCE epoch date of month */
 
-#define	LEAPYEAR4(year)	((((year) % 4) == 0 && ((year) % 100) != 0) || ((year%400)) == 0)
-#define	LEAPYEAR2(year)	(((year) % 4) == 0)
-
 /*
  *	RTC (Real Time Clock Unit) Registers definitions.
  *		start 0x0B0000C0 (Vr4102-4121)
diff --git a/arch/hppa/dev/pdc.c b/arch/hppa/dev/pdc.c
index ec122f3..bc5a147 100644
--- a/arch/hppa/dev/pdc.c
+++ b/arch/hppa/dev/pdc.c
@@ -41,7 +41,7 @@ __KERNEL_RCSID(0, "$NetBSD: pdc.c,v 1.3 2014/07/27 02:56:09 dholland Exp $");
 #include <sys/kauth.h>
 
 #include <dev/cons.h>
-#include <dev/clock_subr.h>
+#include <sys/clock.h>
 
 #include <machine/pdc.h>
 #include <machine/iomod.h>
diff --git a/arch/landisk/dev/rs5c313_landisk.c b/arch/landisk/dev/rs5c313_landisk.c
index 028ca69..a0cdaa7 100644
--- a/arch/landisk/dev/rs5c313_landisk.c
+++ b/arch/landisk/dev/rs5c313_landisk.c
@@ -34,7 +34,7 @@ __KERNEL_RCSID(0, "$NetBSD: rs5c313_landisk.c,v 1.5 2010/04/06 15:29:19 nonaka E
 #include <sys/device.h>
 #include <sys/kernel.h>
 
-#include <dev/clock_subr.h>
+#include <sys/clock.h>
 #include <dev/ic/rs5c313var.h>
 
 #include <sh3/devreg.h>
diff --git a/arch/luna68k/dev/timekeeper.c b/arch/luna68k/dev/timekeeper.c
index 67159fa..45a944a 100644
--- a/arch/luna68k/dev/timekeeper.c
+++ b/arch/luna68k/dev/timekeeper.c
@@ -40,7 +40,7 @@ __KERNEL_RCSID(0, "$NetBSD: timekeeper.c,v 1.14 2014/03/18 18:20:41 riastradh Ex
 
 #include <machine/cpu.h>
 
-#include <dev/clock_subr.h>
+#include <sys/clock.h>
 #include <luna68k/dev/timekeeper.h>
 #include <machine/autoconf.h>
 
diff --git a/arch/luna68k/luna68k/clock.c b/arch/luna68k/luna68k/clock.c
index 8ce472d..1f01e1b 100644
--- a/arch/luna68k/luna68k/clock.c
+++ b/arch/luna68k/luna68k/clock.c
@@ -48,7 +48,7 @@ __KERNEL_RCSID(0, "$NetBSD: clock.c,v 1.9 2013/01/26 15:46:24 tsutsui Exp $");
 
 #include <machine/cpu.h>
 
-#include <dev/clock_subr.h>
+#include <sys/clock.h>
 
 /*
  * Machine-dependent clock routines.
diff --git a/arch/mac68k/mac68k/clock.c b/arch/mac68k/mac68k/clock.c
index d4bfeae..250c975 100644
--- a/arch/mac68k/mac68k/clock.c
+++ b/arch/mac68k/mac68k/clock.c
@@ -84,7 +84,7 @@ __KERNEL_RCSID(0, "$NetBSD: clock.c,v 1.49 2011/02/08 20:20:18 rmind Exp $");
 #include <sys/systm.h>
 #include <sys/timetc.h>
 
-#include <dev/clock_subr.h>
+#include <sys/clock.h>
 
 #include <machine/autoconf.h>
 #include <machine/psl.h>
diff --git a/arch/macppc/dev/adb.c b/arch/macppc/dev/adb.c
index 8cc3337..88fd6d1 100644
--- a/arch/macppc/dev/adb.c
+++ b/arch/macppc/dev/adb.c
@@ -46,7 +46,7 @@ __KERNEL_RCSID(0, "$NetBSD: adb.c,v 1.34 2012/10/27 17:18:00 chs Exp $");
 #include <macppc/dev/pm_direct.h>
 #include <macppc/dev/viareg.h>
 
-#include <dev/clock_subr.h>
+#include <sys/clock.h>
 #include <dev/ofw/openfirm.h>
 
 #include "aed.h"
diff --git a/arch/macppc/dev/cuda.c b/arch/macppc/dev/cuda.c
index 720d7d3..743d84c 100644
--- a/arch/macppc/dev/cuda.c
+++ b/arch/macppc/dev/cuda.c
@@ -39,7 +39,7 @@ __KERNEL_RCSID(0, "$NetBSD: cuda.c,v 1.20 2014/08/13 10:56:35 macallan Exp $");
 #include <sys/bus.h>
 #include <machine/autoconf.h>
 #include <machine/pio.h>
-#include <dev/clock_subr.h>
+#include <sys/clock.h>
 #include <dev/i2c/i2cvar.h>
 
 #include <macppc/dev/viareg.h>
diff --git a/arch/macppc/dev/pmu.c b/arch/macppc/dev/pmu.c
index 2011d45..1895f6a 100644
--- a/arch/macppc/dev/pmu.c
+++ b/arch/macppc/dev/pmu.c
@@ -39,7 +39,7 @@ __KERNEL_RCSID(0, "$NetBSD: pmu.c,v 1.23 2014/03/14 21:59:41 mrg Exp $");
 #include <sys/bus.h>
 #include <machine/pio.h>
 #include <machine/autoconf.h>
-#include <dev/clock_subr.h>
+#include <sys/clock.h>
 #include <dev/i2c/i2cvar.h>
 
 #include <dev/sysmon/sysmonvar.h>
diff --git a/arch/mips/alchemy/dev/aurtc.c b/arch/mips/alchemy/dev/aurtc.c
index d192769..b83c147 100644
--- a/arch/mips/alchemy/dev/aurtc.c
+++ b/arch/mips/alchemy/dev/aurtc.c
@@ -76,7 +76,7 @@ __KERNEL_RCSID(0, "$NetBSD: aurtc.c,v 1.14 2012/01/03 07:36:02 kiyohara Exp $");
 #include <sys/device.h>
 #include <sys/proc.h>
 
-#include <dev/clock_subr.h>
+#include <sys/clock.h>
 
 #include <sys/bus.h>
 
diff --git a/arch/mips/mips/mips_mcclock.c b/arch/mips/mips/mips_mcclock.c
index 403038e..97b4a9b 100644
--- a/arch/mips/mips/mips_mcclock.c
+++ b/arch/mips/mips/mips_mcclock.c
@@ -40,7 +40,7 @@ __KERNEL_RCSID(0, "$NetBSD: mips_mcclock.c,v 1.19 2011/02/20 07:45:48 matt Exp $
 #include <sys/systm.h>
 #include <sys/device.h>
 
-#include <dev/clock_subr.h>
+#include <sys/clock.h>
 #include <dev/ic/mc146818reg.h>
 #include <dev/dec/mcclockvar.h>
 #include <dev/dec/mcclock_pad32.h>
diff --git a/arch/mipsco/mipsco/clock.c b/arch/mipsco/mipsco/clock.c
index 23345f6..030246b 100644
--- a/arch/mipsco/mipsco/clock.c
+++ b/arch/mipsco/mipsco/clock.c
@@ -46,7 +46,7 @@ __KERNEL_RCSID(0, "$NetBSD: clock.c,v 1.10 2011/02/08 20:20:19 rmind Exp $");
 #include <sys/kernel.h>
 #include <sys/device.h>
 #include <sys/systm.h>
-#include <dev/clock_subr.h>
+#include <sys/clock.h>
 
 #include <machine/cpu.h>
 #include <machine/autoconf.h>
diff --git a/arch/mipsco/mipsco/machdep.c b/arch/mipsco/mipsco/machdep.c
index f2c2f05..ff6180f 100644
--- a/arch/mipsco/mipsco/machdep.c
+++ b/arch/mipsco/mipsco/machdep.c
@@ -89,7 +89,7 @@ __KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.78 2014/06/08 07:01:30 he Exp $");
 #include <machine/autoconf.h>
 #include <machine/bootinfo.h>
 #include <machine/prom.h>
-#include <dev/clock_subr.h>
+#include <sys/clock.h>
 #include <dev/cons.h>
 
 #include <sys/boot_flag.h>
diff --git a/arch/mipsco/obio/mkclock.c b/arch/mipsco/obio/mkclock.c
index f885264..2108db2 100644
--- a/arch/mipsco/obio/mkclock.c
+++ b/arch/mipsco/obio/mkclock.c
@@ -37,7 +37,7 @@ __KERNEL_RCSID(0, "$NetBSD: mkclock.c,v 1.11 2012/10/27 17:18:03 chs Exp $");
 #include <sys/device.h>
 #include <sys/systm.h>
 
-#include <dev/clock_subr.h>
+#include <sys/clock.h>
 
 #include <machine/cpu.h>
 #include <machine/mainboard.h>
diff --git a/arch/mvme68k/stand/libsa/chiptotime.c b/arch/mvme68k/stand/libsa/chiptotime.c
index 51e5107..f3c391e 100644
--- a/arch/mvme68k/stand/libsa/chiptotime.c
+++ b/arch/mvme68k/stand/libsa/chiptotime.c
@@ -1,6 +1,7 @@
 /*	$NetBSD: chiptotime.c,v 1.4 2008/01/12 09:54:32 tsutsui Exp $ */
 
 #include <sys/types.h>
+#include <sys/clock.h>
 
 #include <machine/prom.h>
 
@@ -15,9 +16,6 @@
 #define TOBCD(x)        (int)((((unsigned int)(x)) / 10 * 16) +\
 				(((unsigned int)(x)) % 10))
 
-#define SECDAY          (24 * 60 * 60)
-#define SECYR           (SECDAY * 365)
-#define LEAPYEAR(y)     (((y) & 3) == 0)
 #define YEAR0		68
 
 /*
@@ -46,10 +44,10 @@ chiptotime(int sec, int min, int hour, int day, int mon, int year)
 		return (0);
 	days = 0;
 	for (yr = 70; yr < year; yr++)
-		days += LEAPYEAR(yr) ? 366 : 365;
+		days += days_per_year(yr);
 	days += dayyr[mon - 1] + day - 1;
-	if (LEAPYEAR(yr) && mon > 2)
+	if (is_leap_year(yr) && mon > 2)
 		days++;
 	/* now have days since Jan 1, 1970; the rest is easy... */
-	return days * SECDAY + hour * 3600 + min * 60 + sec;
+	return days * SECS_PER_DAY + hour * SECS_PER_HOUR + min * SECS_PER_MINUTE + sec;
 }
diff --git a/arch/mvme68k/stand/libsa/clock.c b/arch/mvme68k/stand/libsa/clock.c
index 3945710..8dd261b 100644
--- a/arch/mvme68k/stand/libsa/clock.c
+++ b/arch/mvme68k/stand/libsa/clock.c
@@ -1,6 +1,8 @@
 /*	$NetBSD: clock.c,v 1.9 2009/01/12 11:32:44 tsutsui Exp $ */
 
 #include <sys/types.h>
+#include <sys/clock.h>
+
 #include <machine/prom.h>
 
 #include <lib/libsa/stand.h>
@@ -15,9 +17,6 @@
 #define TOBCD(x)        (int)((((unsigned int)(x)) / 10 * 16) +\
 				(((unsigned int)(x)) % 10))
 
-#define SECDAY          (24 * 60 * 60)
-#define SECYR           (SECDAY * 365)
-#define LEAPYEAR(y)     (((y) & 3) == 0)
 #define YEAR0		68
 
 /*
@@ -46,12 +45,12 @@ chiptotime(int sec, int min, int hour, int day, int mon, int year)
 		return (0);
 	days = 0;
 	for (yr = 70; yr < year; yr++)
-		days += LEAPYEAR(yr) ? 366 : 365;
+		days += days_per_year(yr);
 	days += dayyr[mon - 1] + day - 1;
-	if (LEAPYEAR(yr) && mon > 2)
+	if (is_leap_year(yr) && mon > 2)
 		days++;
 	/* now have days since Jan 1, 1970; the rest is easy... */
-	return days * SECDAY + hour * 3600 + min * 60 + sec;
+	return days * SECS_PER_DAY + hour * SECS_PER_HOUR + min * SECS_PER_MINUTE + sec;
 }
 
 satime_t
diff --git a/arch/mvmeppc/isa/mkclock_isa.c b/arch/mvmeppc/isa/mkclock_isa.c
index 222221e..ea10e46 100644
--- a/arch/mvmeppc/isa/mkclock_isa.c
+++ b/arch/mvmeppc/isa/mkclock_isa.c
@@ -44,7 +44,7 @@ __KERNEL_RCSID(0, "$NetBSD: mkclock_isa.c,v 1.14 2011/07/01 20:50:00 dyoung Exp
 
 #include <sys/bus.h>
 
-#include <dev/clock_subr.h>
+#include <sys/clock.h>
 #include <dev/ic/mk48txxreg.h>
 #include <dev/ic/mk48txxvar.h>
 
diff --git a/arch/mvmeppc/stand/libsa/clock.c b/arch/mvmeppc/stand/libsa/clock.c
index 247453c..4699399 100644
--- a/arch/mvmeppc/stand/libsa/clock.c
+++ b/arch/mvmeppc/stand/libsa/clock.c
@@ -7,6 +7,7 @@
  */
 
 #include <sys/types.h>
+#include <sys/clock.h>
 
 #include "stand.h"
 #include "net.h"
@@ -16,9 +17,6 @@
 #define FROMBCD(x)      (int)((((unsigned int)(x)) >> 4) * 10 +\
 			      (((unsigned int)(x)) & 0xf))
 
-#define SECDAY          (24 * 60 * 60)
-#define SECYR           (SECDAY * 365)
-#define LEAPYEAR(y)     (((y) & 3) == 0)
 #define YEAR0		68
 
 /*
@@ -47,12 +45,12 @@ chiptotime(int sec, int min, int hour, int day, int mon, int year)
 		return (0);
 	days = 0;
 	for (yr = 70; yr < year; yr++)
-		days += LEAPYEAR(yr) ? 366 : 365;
+		days += days_per_year(yr);
 	days += dayyr[mon - 1] + day - 1;
-	if (LEAPYEAR(yr) && mon > 2)
+	if (is_leap_year(yr) && mon > 2)
 		days++;
 	/* now have days since Jan 1, 1970; the rest is easy... */
-	return (days * SECDAY + hour * 3600 + min * 60 + sec);
+	return (days * SECS_PER_DAY + hour * SECS_PER_HOUR + min * SECS_PER_MINUTE + sec);
 }
 
 satime_t
diff --git a/arch/news68k/dev/mkclock_hb.c b/arch/news68k/dev/mkclock_hb.c
index 31b3d05..fd1c363 100644
--- a/arch/news68k/dev/mkclock_hb.c
+++ b/arch/news68k/dev/mkclock_hb.c
@@ -40,7 +40,7 @@ __KERNEL_RCSID(0, "$NetBSD: mkclock_hb.c,v 1.15 2008/04/28 20:23:30 martin Exp $
 #include <machine/cpu.h>
 #include <machine/bus.h>
 
-#include <dev/clock_subr.h>
+#include <sys/clock.h>
 #include <dev/ic/mk48txxreg.h>
 #include <dev/ic/mk48txxvar.h>
 
diff --git a/arch/news68k/dev/timer_hb.c b/arch/news68k/dev/timer_hb.c
index 5f30053..ae51135 100644
--- a/arch/news68k/dev/timer_hb.c
+++ b/arch/news68k/dev/timer_hb.c
@@ -43,7 +43,7 @@ __KERNEL_RCSID(0, "$NetBSD: timer_hb.c,v 1.19 2011/11/22 14:31:02 tsutsui Exp $"
 #include <machine/cpu.h>
 #include <machine/bus.h>
 
-#include <dev/clock_subr.h>
+#include <sys/clock.h>
 
 #include <news68k/news68k/isr.h>
 #include <news68k/news68k/clockvar.h>
diff --git a/arch/newsmips/apbus/mkclock_ap.c b/arch/newsmips/apbus/mkclock_ap.c
index cb8a581..08bc7f4 100644
--- a/arch/newsmips/apbus/mkclock_ap.c
+++ b/arch/newsmips/apbus/mkclock_ap.c
@@ -40,7 +40,7 @@ __KERNEL_RCSID(0, "$NetBSD: mkclock_ap.c,v 1.9 2008/04/28 20:23:30 martin Exp $"
 #include <machine/cpu.h>
 #include <machine/bus.h>
 
-#include <dev/clock_subr.h>
+#include <sys/clock.h>
 #include <dev/ic/mk48txxreg.h>
 #include <dev/ic/mk48txxvar.h>
 
diff --git a/arch/newsmips/dev/mkclock_hb.c b/arch/newsmips/dev/mkclock_hb.c
index 4648e43..589919e 100644
--- a/arch/newsmips/dev/mkclock_hb.c
+++ b/arch/newsmips/dev/mkclock_hb.c
@@ -40,7 +40,7 @@ __KERNEL_RCSID(0, "$NetBSD: mkclock_hb.c,v 1.8 2008/04/28 20:23:30 martin Exp $"
 #include <machine/cpu.h>
 #include <machine/bus.h>
 
-#include <dev/clock_subr.h>
+#include <sys/clock.h>
 #include <dev/ic/mk48txxreg.h>
 #include <dev/ic/mk48txxvar.h>
 
diff --git a/arch/next68k/next68k/rtc.c b/arch/next68k/next68k/rtc.c
index 5ec8dd1..81e18a5 100644
--- a/arch/next68k/next68k/rtc.c
+++ b/arch/next68k/next68k/rtc.c
@@ -47,7 +47,7 @@ __KERNEL_RCSID(0, "$NetBSD: rtc.c,v 1.17 2014/03/24 20:01:03 christos Exp $");
 #include <machine/bus.h>
 #include <machine/cpu.h>
 
-#include <dev/clock_subr.h>
+#include <sys/clock.h>
 
 #include <next68k/next68k/rtc.h>
 
diff --git a/arch/playstation2/playstation2/clock.c b/arch/playstation2/playstation2/clock.c
index 313e33b..cafce70 100644
--- a/arch/playstation2/playstation2/clock.c
+++ b/arch/playstation2/playstation2/clock.c
@@ -39,7 +39,7 @@ __KERNEL_RCSID(0, "$NetBSD: clock.c,v 1.10 2014/07/04 08:09:47 martin Exp $");
 #include <mips/locore.h>
 #include <mips/mips3_clock.h>
 
-#include <dev/clock_subr.h>
+#include <sys/clock.h>
 #include <machine/bootinfo.h>
 
 #include <playstation2/ee/timervar.h>
diff --git a/arch/pmax/ibus/mcclock_ibus.c b/arch/pmax/ibus/mcclock_ibus.c
index 492ec6a..07663c6 100644
--- a/arch/pmax/ibus/mcclock_ibus.c
+++ b/arch/pmax/ibus/mcclock_ibus.c
@@ -34,7 +34,7 @@ __KERNEL_RCSID(0, "$NetBSD: mcclock_ibus.c,v 1.18 2011/06/04 01:43:56 tsutsui Ex
 #include <sys/kernel.h>
 #include <sys/device.h>
 #include <sys/systm.h>
-#include <dev/clock_subr.h>
+#include <sys/clock.h>
 
 #include <dev/dec/mcclockvar.h>
 #include <dev/dec/mcclock_pad32.h>
diff --git a/arch/pmax/pmax/clock.c b/arch/pmax/pmax/clock.c
index 64a634f..934a38e 100644
--- a/arch/pmax/pmax/clock.c
+++ b/arch/pmax/pmax/clock.c
@@ -45,7 +45,7 @@ __KERNEL_RCSID(0, "$NetBSD: clock.c,v 1.40 2011/07/09 17:32:30 matt Exp $");
 #include <sys/kernel.h>
 #include <sys/systm.h>
 
-#include <dev/clock_subr.h>
+#include <sys/clock.h>
 
 #include <dev/dec/clockvar.h>
 
diff --git a/arch/pmax/tc/mcclock_ioasic.c b/arch/pmax/tc/mcclock_ioasic.c
index 81dbc05..77accea 100644
--- a/arch/pmax/tc/mcclock_ioasic.c
+++ b/arch/pmax/tc/mcclock_ioasic.c
@@ -33,7 +33,7 @@ __KERNEL_RCSID(0, "$NetBSD: mcclock_ioasic.c,v 1.23 2011/06/04 01:43:56 tsutsui
 #include <sys/param.h>
 #include <sys/device.h>
 #include <sys/systm.h>
-#include <dev/clock_subr.h>
+#include <sys/clock.h>
 
 #include <dev/dec/mcclockvar.h>
 #include <dev/dec/mcclock_pad32.h>
diff --git a/arch/powerpc/powerpc/rtas.c b/arch/powerpc/powerpc/rtas.c
index b538d95..694f89e 100644
--- a/arch/powerpc/powerpc/rtas.c
+++ b/arch/powerpc/powerpc/rtas.c
@@ -17,7 +17,7 @@ __KERNEL_RCSID(0, "$NetBSD: rtas.c,v 1.14 2014/02/28 05:41:21 matt Exp $");
 #include <sys/errno.h>
 #include <uvm/uvm.h>
 
-#include <dev/clock_subr.h>
+#include <sys/clock.h>
 #include <dev/ofw/openfirm.h>
 
 #include <powerpc/rtas.h>
diff --git a/arch/prep/pnpbus/mcclock_pnpbus.c b/arch/prep/pnpbus/mcclock_pnpbus.c
index de367c7..74bdfac 100644
--- a/arch/prep/pnpbus/mcclock_pnpbus.c
+++ b/arch/prep/pnpbus/mcclock_pnpbus.c
@@ -55,7 +55,7 @@ __KERNEL_RCSID(0, "$NetBSD: mcclock_pnpbus.c,v 1.10 2011/07/01 16:55:42 dyoung E
 /* XXX */
 #include <machine/pio.h>
 
-#include <dev/clock_subr.h>
+#include <sys/clock.h>
 #include <dev/ic/mc146818reg.h>
 #include <dev/ic/mc146818var.h>
 #include <dev/ic/ds1687reg.h>
diff --git a/arch/prep/pnpbus/nvram_pnpbus.c b/arch/prep/pnpbus/nvram_pnpbus.c
index 1022f45..b825271 100644
--- a/arch/prep/pnpbus/nvram_pnpbus.c
+++ b/arch/prep/pnpbus/nvram_pnpbus.c
@@ -45,7 +45,7 @@ __KERNEL_RCSID(0, "$NetBSD: nvram_pnpbus.c,v 1.20 2014/07/25 08:10:34 dholland E
 
 #include <machine/isa_machdep.h>
 /* clock stuff for motorolla machines */
-#include <dev/clock_subr.h>
+#include <sys/clock.h>
 #include <dev/ic/mk48txxreg.h>
 
 #include <uvm/uvm_extern.h>
diff --git a/arch/sandpoint/isa/mcclock_isa.c b/arch/sandpoint/isa/mcclock_isa.c
index 656ee81..49c4b87 100644
--- a/arch/sandpoint/isa/mcclock_isa.c
+++ b/arch/sandpoint/isa/mcclock_isa.c
@@ -127,7 +127,7 @@ __KERNEL_RCSID(0, "$NetBSD: mcclock_isa.c,v 1.6 2014/06/20 09:47:15 phx Exp $");
 
 #include <sys/bus.h>
 
-#include <dev/clock_subr.h>
+#include <sys/clock.h>
 #include <dev/isa/isareg.h>
 #include <dev/isa/isavar.h>
 #include <dev/ic/mc146818reg.h>
diff --git a/arch/sbmips/sbmips/rtc.c b/arch/sbmips/sbmips/rtc.c
index 5f8e1c6..cf1e221 100644
--- a/arch/sbmips/sbmips/rtc.c
+++ b/arch/sbmips/sbmips/rtc.c
@@ -44,7 +44,7 @@ __KERNEL_RCSID(0, "$NetBSD: rtc.c,v 1.19 2011/07/09 16:59:40 matt Exp $");
 #include <sys/systm.h>
 #include <sys/cpu.h>
 
-#include <dev/clock_subr.h>
+#include <sys/clock.h>
 
 #include <sbmips/swarm.h>
 #include <sbmips/systemsw.h>
diff --git a/arch/sgimips/dev/dpclock.c b/arch/sgimips/dev/dpclock.c
index 2055da6..f3e1302 100644
--- a/arch/sgimips/dev/dpclock.c
+++ b/arch/sgimips/dev/dpclock.c
@@ -44,7 +44,7 @@
 #include <machine/sysconf.h>
 #include <machine/machtype.h>
 
-#include <dev/clock_subr.h>
+#include <sys/clock.h>
 #include <sgimips/dev/dp8573areg.h>
 
 #include <sgimips/sgimips/clockvar.h>
diff --git a/arch/sgimips/dev/dsclock.c b/arch/sgimips/dev/dsclock.c
index e2e3c70..181f021 100644
--- a/arch/sgimips/dev/dsclock.c
+++ b/arch/sgimips/dev/dsclock.c
@@ -46,7 +46,7 @@ __KERNEL_RCSID(0, "$NetBSD: dsclock.c,v 1.5 2011/07/01 18:53:46 dyoung Exp $");
 #include <machine/sysconf.h>
 #include <machine/machtype.h>
 
-#include <dev/clock_subr.h>
+#include <sys/clock.h>
 #include <dev/ic/ds1286reg.h>
 
 #include <sgimips/sgimips/clockvar.h>
diff --git a/arch/sgimips/mace/mcclock_mace.c b/arch/sgimips/mace/mcclock_mace.c
index e9973ee..1fb6ea5 100644
--- a/arch/sgimips/mace/mcclock_mace.c
+++ b/arch/sgimips/mace/mcclock_mace.c
@@ -76,7 +76,7 @@ __KERNEL_RCSID(0, "$NetBSD: mcclock_mace.c,v 1.15 2013/12/16 15:45:29 mrg Exp $"
 #include <sys/bus.h>
 #include <machine/machtype.h>
 
-#include <dev/clock_subr.h>
+#include <sys/clock.h>
 #include <dev/ic/ds1687reg.h>
 
 #include <sgimips/mace/macevar.h>
diff --git a/arch/sgimips/sgimips/clock.c b/arch/sgimips/sgimips/clock.c
index e96b1d7..b173cc0 100644
--- a/arch/sgimips/sgimips/clock.c
+++ b/arch/sgimips/sgimips/clock.c
@@ -51,7 +51,7 @@ __KERNEL_RCSID(0, "$NetBSD: clock.c,v 1.24 2011/02/20 07:59:51 matt Exp $");
 
 #include <mips/locore.h>
 #include <mips/mips3_clock.h>
-#include <dev/clock_subr.h>
+#include <sys/clock.h>
 #include <dev/ic/i8253reg.h>
 
 #include <machine/machtype.h>
diff --git a/arch/sh3/dev/rtc.c b/arch/sh3/dev/rtc.c
index 910e5ad..4153e1a 100644
--- a/arch/sh3/dev/rtc.c
+++ b/arch/sh3/dev/rtc.c
@@ -41,7 +41,7 @@ __KERNEL_RCSID(0, "$NetBSD: rtc.c,v 1.9 2014/09/08 10:00:18 martin Exp $");
 #include <sys/gmon.h>
 #endif
 
-#include <dev/clock_subr.h>
+#include <sys/clock.h>
 
 #include <sh3/rtcreg.h>
 
diff --git a/arch/sh3/sh3/clock.c b/arch/sh3/sh3/clock.c
index 09b92ca..608f585 100644
--- a/arch/sh3/sh3/clock.c
+++ b/arch/sh3/sh3/clock.c
@@ -42,7 +42,7 @@ __KERNEL_RCSID(0, "$NetBSD: clock.c,v 1.40 2009/03/18 10:22:36 cegger Exp $");
 #include <sys/device.h>
 #include <sys/timetc.h>
 
-#include <dev/clock_subr.h>
+#include <sys/clock.h>
 
 #include <sh3/clock.h>
 #include <sh3/exception.h>
diff --git a/arch/sparc/dev/rtc.c b/arch/sparc/dev/rtc.c
index 0afec57..7cf2c33 100644
--- a/arch/sparc/dev/rtc.c
+++ b/arch/sparc/dev/rtc.c
@@ -48,7 +48,7 @@ __KERNEL_RCSID(0, "$NetBSD: rtc.c,v 1.18 2011/07/18 00:31:13 mrg Exp $");
 #include <sys/bus.h>
 #include <machine/autoconf.h>
 
-#include <dev/clock_subr.h>
+#include <sys/clock.h>
 #include <dev/ic/mc146818reg.h>
 
 #include <dev/ebus/ebusreg.h>
diff --git a/arch/sparc/sparc/clock.c b/arch/sparc/sparc/clock.c
index 9de005e..862d2a6 100644
--- a/arch/sparc/sparc/clock.c
+++ b/arch/sparc/sparc/clock.c
@@ -105,7 +105,7 @@ __KERNEL_RCSID(0, "$NetBSD: clock.c,v 1.103 2011/07/01 18:51:51 dyoung Exp $");
 #include <machine/eeprom.h>
 #include <machine/cpu.h>
 
-#include <dev/clock_subr.h>
+#include <sys/clock.h>
 
 /* Variables shared with timer.c, mkclock.c, oclock.c */
 int timerblurb = 10;	/* Guess a value; used before clock is attached */
diff --git a/arch/sparc/sparc/eeprom.c b/arch/sparc/sparc/eeprom.c
index cb5c824..4d892e3 100644
--- a/arch/sparc/sparc/eeprom.c
+++ b/arch/sparc/sparc/eeprom.c
@@ -53,7 +53,7 @@ __KERNEL_RCSID(0, "$NetBSD: eeprom.c,v 1.9 2011/07/17 23:32:37 mrg Exp $");
 #include <machine/autoconf.h>
 #include <machine/eeprom.h>
 
-#include <dev/clock_subr.h>
+#include <sys/clock.h>
 
 /* Imported from clock.c: */
 extern char	*eeprom_va;
diff --git a/arch/sparc/sparc/mkclock.c b/arch/sparc/sparc/mkclock.c
index 91782eb..b429b0a 100644
--- a/arch/sparc/sparc/mkclock.c
+++ b/arch/sparc/sparc/mkclock.c
@@ -53,7 +53,7 @@ __KERNEL_RCSID(0, "$NetBSD: mkclock.c,v 1.19 2011/07/01 18:51:51 dyoung Exp $");
 
 #include <sparc/dev/bootbusvar.h>
 
-#include <dev/clock_subr.h>
+#include <sys/clock.h>
 #include <dev/ic/mk48txxreg.h>
 #include <dev/ic/mk48txxvar.h>
 
diff --git a/arch/sparc/sparc/oclock.c b/arch/sparc/sparc/oclock.c
index a21acb1..3749b6a 100644
--- a/arch/sparc/sparc/oclock.c
+++ b/arch/sparc/sparc/oclock.c
@@ -50,7 +50,7 @@ __KERNEL_RCSID(0, "$NetBSD: oclock.c,v 1.20 2011/07/01 18:51:51 dyoung Exp $");
 #include <machine/promlib.h>
 #include <machine/autoconf.h>
 
-#include <dev/clock_subr.h>
+#include <sys/clock.h>
 #include <dev/ic/intersil7170reg.h>
 #include <dev/ic/intersil7170var.h>
 
diff --git a/arch/sparc64/dev/mkclock.c b/arch/sparc64/dev/mkclock.c
index 33a3eb5..8867f3d 100644
--- a/arch/sparc64/dev/mkclock.c
+++ b/arch/sparc64/dev/mkclock.c
@@ -76,7 +76,7 @@ __KERNEL_RCSID(0, "$NetBSD: mkclock.c,v 1.12 2012/10/27 17:18:12 chs Exp $");
 #include <machine/eeprom.h>
 #include <machine/cpu.h>
 
-#include <dev/clock_subr.h>
+#include <sys/clock.h>
 #include <dev/ic/mk48txxreg.h>
 #include <dev/ic/mk48txxvar.h>
 
diff --git a/arch/sparc64/dev/rtc.c b/arch/sparc64/dev/rtc.c
index 04f62dc..f3a406f 100644
--- a/arch/sparc64/dev/rtc.c
+++ b/arch/sparc64/dev/rtc.c
@@ -70,7 +70,7 @@ __KERNEL_RCSID(0, "$NetBSD: rtc.c,v 1.8 2011/07/01 18:48:37 dyoung Exp $");
 #include <sys/bus.h>
 #include <machine/autoconf.h>
 
-#include <dev/clock_subr.h>
+#include <sys/clock.h>
 #include <dev/ic/mc146818reg.h>
 #include <dev/ic/mc146818var.h>
 
diff --git a/arch/sun2/sun2/clock.c b/arch/sun2/sun2/clock.c
index 2f73307..839898f 100644
--- a/arch/sun2/sun2/clock.c
+++ b/arch/sun2/sun2/clock.c
@@ -102,7 +102,7 @@ __KERNEL_RCSID(0, "$NetBSD: clock.c,v 1.16 2010/01/28 14:10:54 mbalmer Exp $");
 #include <sun2/sun2/enable.h>
 #include <sun2/sun2/machdep.h>
 
-#include <dev/clock_subr.h>
+#include <sys/clock.h>
 #include <dev/ic/am9513reg.h>
 
 /*
diff --git a/arch/sun2/sun2/tod.c b/arch/sun2/sun2/tod.c
index 1ed525d..a5e36fe 100644
--- a/arch/sun2/sun2/tod.c
+++ b/arch/sun2/sun2/tod.c
@@ -105,7 +105,7 @@ __KERNEL_RCSID(0, "$NetBSD: tod.c,v 1.14 2008/07/06 13:29:50 tsutsui Exp $");
 #include <dev/vme/vmereg.h>
 #include <dev/vme/vmevar.h>
 
-#include <dev/clock_subr.h>
+#include <sys/clock.h>
 #include <dev/ic/mm58167var.h>
 
 static int  tod_obio_match(device_t, cfdata_t, void *args);
diff --git a/arch/sun3/sun3/clock.c b/arch/sun3/sun3/clock.c
index 500a581..f24f618 100644
--- a/arch/sun3/sun3/clock.c
+++ b/arch/sun3/sun3/clock.c
@@ -104,7 +104,7 @@ __KERNEL_RCSID(0, "$NetBSD: clock.c,v 1.64 2013/09/07 15:56:11 tsutsui Exp $");
 #include <sun3/sun3/interreg.h>
 #include <sun3/sun3/machdep.h>
 
-#include <dev/clock_subr.h>
+#include <sys/clock.h>
 #include <dev/ic/intersil7170reg.h>
 #include <dev/ic/intersil7170var.h>
 
diff --git a/arch/sun3/sun3x/clock.c b/arch/sun3/sun3x/clock.c
index b862063..a1c7473 100644
--- a/arch/sun3/sun3x/clock.c
+++ b/arch/sun3/sun3x/clock.c
@@ -113,7 +113,7 @@ __KERNEL_RCSID(0, "$NetBSD: clock.c,v 1.40 2013/09/06 17:43:19 tsutsui Exp $");
 #include <machine/idprom.h>
 #include <machine/leds.h>
 
-#include <dev/clock_subr.h>
+#include <sys/clock.h>
 #include <dev/ic/intersil7170reg.h>
 #include <dev/ic/intersil7170var.h>
 #include <dev/ic/mk48txxreg.h>
diff --git a/arch/usermode/dev/clock.c b/arch/usermode/dev/clock.c
index 2da2d85..99226d7 100644
--- a/arch/usermode/dev/clock.c
+++ b/arch/usermode/dev/clock.c
@@ -45,7 +45,7 @@ __KERNEL_RCSID(0, "$NetBSD: clock.c,v 1.26 2012/01/21 22:09:56 reinoud Exp $");
 #include <machine/mainbus.h>
 #include <machine/thunk.h>
 
-#include <dev/clock_subr.h>
+#include <sys/clock.h>
 
 static int	clock_match(device_t, cfdata_t, void *);
 static void	clock_attach(device_t, device_t, void *);
diff --git a/arch/vax/include/clock.h b/arch/vax/include/clock.h
index dad4111..2950837 100644
--- a/arch/vax/include/clock.h
+++ b/arch/vax/include/clock.h
@@ -32,19 +32,11 @@
 #ifndef _VAX_CLOCK_H_
 #define	_VAX_CLOCK_H_
 
-#include <dev/clock_subr.h>
+#include <sys/clock.h>
 
 /*
  * Time constants. These are unlikely to change.
  */
-#define IS_LEAPYEAR(y) ((((y % 4) == 0) && ((y % 100) != 0)) || ((y % 400) == 0))
-
-#define SEC_PER_MIN	(60)
-#define SEC_PER_HOUR	(SEC_PER_MIN * 60)
-#define SEC_PER_DAY	(SEC_PER_HOUR * 24)
-#define DAYSPERYEAR(y)	(IS_LEAPYEAR(y) ? 366 : 365)
-#define SECPERYEAR(y)	(DAYSPERYEAR(y) * SEC_PER_DAY)
-
 #define TODRBASE	(1 << 28) /* Rumours says it comes from VMS */
 
 #define	SEC_OFF		0
diff --git a/arch/vax/vax/clock.c b/arch/vax/vax/clock.c
index f3d46d4..cbc52de 100644
--- a/arch/vax/vax/clock.c
+++ b/arch/vax/vax/clock.c
@@ -34,6 +34,7 @@ __KERNEL_RCSID(0, "$NetBSD: clock.c,v 1.56 2012/03/06 22:50:24 jklos Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
+#include <sys/clock.h>
 #include <sys/cpu.h>
 #include <sys/device.h>
 #include <sys/timetc.h>
@@ -198,7 +199,7 @@ yeartonum(int y)
 	int n;
 
 	for (n = 0, y -= 1; y > 1969; y--)
-		n += SECPERYEAR(y);
+		n += days_per_year(y) * SECS_PER_DAY;
 	return n;
 }
 
@@ -209,7 +210,7 @@ int
 numtoyear(int num)
 {
 	int y = 1970, j;
-	while(num >= (j = SECPERYEAR(y))) {
+	while(num >= (j = days_per_year(y) * SECS_PER_DAY)) {
 		y++;
 		num -= j;
 	}
diff --git a/arch/x68k/dev/rtclock.c b/arch/x68k/dev/rtclock.c
index 3873545..5392399 100644
--- a/arch/x68k/dev/rtclock.c
+++ b/arch/x68k/dev/rtclock.c
@@ -50,7 +50,7 @@ __KERNEL_RCSID(0, "$NetBSD: rtclock.c,v 1.24 2014/03/26 08:17:59 christos Exp $"
 
 #include <machine/bus.h>
 
-#include <dev/clock_subr.h>
+#include <sys/clock.h>
 
 #include <arch/x68k/dev/rtclock_var.h>
 #include <arch/x68k/dev/intiovar.h>
diff --git a/arch/x68k/stand/libsa/clock.c b/arch/x68k/stand/libsa/clock.c
index db9c791..3229f1e 100644
--- a/arch/x68k/stand/libsa/clock.c
+++ b/arch/x68k/stand/libsa/clock.c
@@ -33,9 +33,6 @@
 #include "consio.h"	/* XXX: for MFP_TIMERC */
 
 /* x68k's RTC is defunct 2079, so there is no y2100 problem. */
-#define LEAPYEAR(y)	(((y) % 4) == 0)
-#define SECDAY	(24 * 60 * 60)
-
 int rtc_offset;
 
 const int yday[] = {
@@ -68,13 +65,13 @@ getsecs(void)
 
 	days = 0;
 	for (y = 1970; y < year; y++)
-		days += 365 + LEAPYEAR(y);
+		days += days_per_year(y);
 	days += yday[mon - 1] + day - 1;
-	if (LEAPYEAR(y) && mon > 2)
+	if (is_leap_year(y) && mon > 2)
 		days++;
 
 	/* now we have days since Jan 1, 1970. the rest is easy... */
-	return (days * SECDAY) + (hour * 3600) + (min * 60) + sec
+	return (days * SECS_PER_DAY) + (hour * SECS_PER_HOUR) + (min * SECS_PER_MINUTE) + sec
 		+ (rtc_offset * 60);
 }
 
diff --git a/arch/x68k/x68k/clock.c b/arch/x68k/x68k/clock.c
index 17ac630..a9964b9 100644
--- a/arch/x68k/x68k/clock.c
+++ b/arch/x68k/x68k/clock.c
@@ -55,7 +55,7 @@ __KERNEL_RCSID(0, "$NetBSD: clock.c,v 1.34 2012/05/22 04:03:03 isaki Exp $");
 #include <machine/cpu.h>
 #include <machine/bus.h>
 
-#include <dev/clock_subr.h>
+#include <sys/clock.h>
 
 #include <arch/x68k/dev/mfp.h>
 
diff --git a/arch/x86/include/rtc.h b/arch/x86/include/rtc.h
index ec2875c..f5a9583 100644
--- a/arch/x86/include/rtc.h
+++ b/arch/x86/include/rtc.h
@@ -1,6 +1,6 @@
 /*      $NetBSD: rtc.h,v 1.1 2009/06/16 21:05:34 bouyer Exp $    */
 
-#include <dev/clock_subr.h>
+#include <sys/clock.h>
 
 void rtc_register(void);
 int  rtc_get_ymdhms(todr_chip_handle_t, struct clock_ymdhms *);
diff --git a/arch/xen/xen/clock.c b/arch/xen/xen/clock.c
index c8565f4..46c82ed 100644
--- a/arch/xen/xen/clock.c
+++ b/arch/xen/xen/clock.c
@@ -46,7 +46,7 @@ __KERNEL_RCSID(0, "$NetBSD: clock.c,v 1.62 2012/02/17 19:00:45 bouyer Exp $");
 #include <xen/xen-public/vcpu.h>
 #include <machine/cpu_counter.h>
 
-#include <dev/clock_subr.h>
+#include <sys/clock.h>
 #include <x86/rtc.h>
 
 static int xen_timer_handler(void *, struct intrframe *);
diff --git a/dev/dec/mcclock.c b/dev/dec/mcclock.c
index 8a23f83..ee2d231 100644
--- a/dev/dec/mcclock.c
+++ b/dev/dec/mcclock.c
@@ -34,7 +34,7 @@ __KERNEL_RCSID(0, "$NetBSD: mcclock.c,v 1.27 2011/06/04 01:43:56 tsutsui Exp $")
 #include <sys/kernel.h>
 #include <sys/systm.h>
 #include <sys/device.h>
-#include <dev/clock_subr.h>
+#include <sys/clock.h>
 
 #include <dev/dec/clockvar.h>
 #include <dev/dec/mcclockvar.h>
@@ -168,13 +168,13 @@ mcclock_get(todr_chip_handle_t tch, struct timeval *tvp)
 	dt.dt_mon = regs[MC_MONTH];
 	dt.dt_year = 1972;
 
-	yearsecs = clock_ymdhms_to_secs(&dt) - (72 - 70) * SECYR;
+	yearsecs = clock_ymdhms_to_secs(&dt) - (72 - 70) * SECS_PER_COMMON_YEAR;
 
 	/*
 	 * Take the actual year from the filesystem if possible;
 	 * allow for 2 days of clock loss and 363 days of clock gain.
 	 */
-	dt.dt_year = 1972; /* or MINYEAR or base/SECYR+1970 ... */
+	dt.dt_year = 1972; /* or MINYEAR or base/SECS_PER_COMMON_YEAR+1970 ... */
 	dt.dt_mon = 1;
 	dt.dt_day = 1;
 	dt.dt_hour = 0;
@@ -182,7 +182,7 @@ mcclock_get(todr_chip_handle_t tch, struct timeval *tvp)
 	dt.dt_sec = 0;
 	for(;;) {
 		tvp->tv_sec = yearsecs + clock_ymdhms_to_secs(&dt);
-		if (tvp->tv_sec > tch->base_time - 2 * SECDAY)
+		if (tvp->tv_sec > tch->base_time - 2 * SECS_PER_DAY)
 			break;
 		dt.dt_year++;
 	}
@@ -214,7 +214,7 @@ mcclock_set(todr_chip_handle_t tch, struct timeval *tvp)
 	dt.dt_sec = 0;
 	yearsecs = tvp->tv_sec - clock_ymdhms_to_secs(&dt);
 
-#define first72 ((72 - 70) * SECYR)
+#define first72 ((72 - 70) * SECS_PER_COMMON_YEAR)
 	clock_secs_to_ymdhms(first72 + yearsecs, &dt);
 
 #ifdef DEBUG
diff --git a/dev/dec/mcclock_pad32.c b/dev/dec/mcclock_pad32.c
index f980398..aabd882 100644
--- a/dev/dec/mcclock_pad32.c
+++ b/dev/dec/mcclock_pad32.c
@@ -49,7 +49,7 @@ __KERNEL_RCSID(0, "$NetBSD: mcclock_pad32.c,v 1.16 2009/03/14 21:04:19 dsl Exp $
 #include <sys/kernel.h>
 #include <sys/systm.h>
 #include <sys/device.h>
-#include <dev/clock_subr.h>
+#include <sys/clock.h>
 
 #include <machine/autoconf.h>
 #include <dev/dec/clockvar.h>
diff --git a/dev/i2c/ds1307.c b/dev/i2c/ds1307.c
index a444965..7da0b1a 100644
--- a/dev/i2c/ds1307.c
+++ b/dev/i2c/ds1307.c
@@ -47,7 +47,7 @@ __KERNEL_RCSID(0, "$NetBSD: ds1307.c,v 1.18 2014/07/25 08:10:37 dholland Exp $")
 #include <sys/conf.h>
 #include <sys/event.h>
 
-#include <dev/clock_subr.h>
+#include <sys/clock.h>
 
 #include <dev/i2c/i2cvar.h>
 #include <dev/i2c/ds1307reg.h>
diff --git a/dev/i2c/m41st84.c b/dev/i2c/m41st84.c
index 9530390..8410755 100644
--- a/dev/i2c/m41st84.c
+++ b/dev/i2c/m41st84.c
@@ -49,7 +49,7 @@ __KERNEL_RCSID(0, "$NetBSD: m41st84.c,v 1.21 2014/07/25 08:10:37 dholland Exp $"
 #include <sys/conf.h>
 #include <sys/event.h>
 
-#include <dev/clock_subr.h>
+#include <sys/clock.h>
 
 #include <dev/i2c/i2cvar.h>
 #include <dev/i2c/m41st84reg.h>
diff --git a/dev/i2c/m41t00.c b/dev/i2c/m41t00.c
index de78d8a..d2d6fc6 100644
--- a/dev/i2c/m41t00.c
+++ b/dev/i2c/m41t00.c
@@ -50,7 +50,7 @@ __KERNEL_RCSID(0, "$NetBSD: m41t00.c,v 1.18 2014/07/25 08:10:37 dholland Exp $")
 
 #include <sys/bus.h>
 
-#include <dev/clock_subr.h>
+#include <sys/clock.h>
 
 #include <dev/i2c/i2cvar.h>
 #include <dev/i2c/m41t00reg.h>
diff --git a/dev/i2c/max6900.c b/dev/i2c/max6900.c
index f1ab51d..ef50af1 100644
--- a/dev/i2c/max6900.c
+++ b/dev/i2c/max6900.c
@@ -47,7 +47,7 @@ __KERNEL_RCSID(0, "$NetBSD: max6900.c,v 1.14 2014/07/25 08:10:37 dholland Exp $"
 #include <sys/conf.h>
 #include <sys/event.h>
 
-#include <dev/clock_subr.h>
+#include <sys/clock.h>
 
 #include <dev/i2c/i2cvar.h>
 #include <dev/i2c/max6900reg.h>
diff --git a/dev/i2c/pcf8563.c b/dev/i2c/pcf8563.c
index 99d0b04..74aaf5b 100644
--- a/dev/i2c/pcf8563.c
+++ b/dev/i2c/pcf8563.c
@@ -34,7 +34,7 @@ __KERNEL_RCSID(0, "$NetBSD: pcf8563.c,v 1.3 2012/01/07 21:02:15 phx Exp $");
 #include <sys/device.h>
 #include <sys/kernel.h>
 
-#include <dev/clock_subr.h>
+#include <sys/clock.h>
 
 #include <dev/i2c/i2cvar.h>
 #include <dev/i2c/pcf8563reg.h>
diff --git a/dev/i2c/pcf8583.c b/dev/i2c/pcf8583.c
index 599fa93..59678c6 100644
--- a/dev/i2c/pcf8583.c
+++ b/dev/i2c/pcf8583.c
@@ -54,7 +54,7 @@ __KERNEL_RCSID(0, "$NetBSD: pcf8583.c,v 1.15 2014/07/25 08:10:37 dholland Exp $"
 #include <sys/conf.h>
 #include <sys/event.h>
 
-#include <dev/clock_subr.h>
+#include <sys/clock.h>
 
 #include <dev/i2c/i2cvar.h>
 #include <dev/i2c/pcf8583reg.h>
diff --git a/dev/i2c/r2025.c b/dev/i2c/r2025.c
index cdc9e1a..ff4be13 100644
--- a/dev/i2c/r2025.c
+++ b/dev/i2c/r2025.c
@@ -44,7 +44,7 @@ __KERNEL_RCSID(0, "$NetBSD: r2025.c,v 1.6 2009/12/12 14:44:10 tsutsui Exp $");
 #include <sys/conf.h>
 #include <sys/event.h>
 
-#include <dev/clock_subr.h>
+#include <sys/clock.h>
 
 #include <dev/i2c/i2cvar.h>
 #include <dev/i2c/r2025reg.h>
diff --git a/dev/i2c/rs5c372.c b/dev/i2c/rs5c372.c
index 3dcb43d..1fc7ea9 100644
--- a/dev/i2c/rs5c372.c
+++ b/dev/i2c/rs5c372.c
@@ -37,7 +37,7 @@ __KERNEL_RCSID(0, "$NetBSD: rs5c372.c,v 1.13 2014/06/29 04:04:02 tsutsui Exp $")
 #include <sys/conf.h>
 #include <sys/event.h>
 
-#include <dev/clock_subr.h>
+#include <sys/clock.h>
 
 #include <dev/i2c/i2cvar.h>
 #include <dev/i2c/rs5c372reg.h>
diff --git a/dev/i2c/s390.c b/dev/i2c/s390.c
index 0c85337..aa323ef 100644
--- a/dev/i2c/s390.c
+++ b/dev/i2c/s390.c
@@ -36,7 +36,7 @@ __KERNEL_RCSID(0, "$NetBSD: s390.c,v 1.2 2011/05/28 13:59:31 phx Exp $");
 #include <sys/device.h>
 #include <sys/conf.h>
 
-#include <dev/clock_subr.h>
+#include <sys/clock.h>
 
 #include <dev/i2c/i2cvar.h>
 #include <dev/i2c/s390reg.h>
diff --git a/dev/i2c/tps65950.c b/dev/i2c/tps65950.c
index 61be12e..af968d3 100644
--- a/dev/i2c/tps65950.c
+++ b/dev/i2c/tps65950.c
@@ -44,7 +44,7 @@ __KERNEL_RCSID(0, "$NetBSD: tps65950.c,v 1.4 2014/02/25 18:30:09 pooka Exp $");
 
 #include <dev/i2c/i2cvar.h>
 
-#include <dev/clock_subr.h>
+#include <sys/clock.h>
 #include <dev/sysmon/sysmonvar.h>
 
 /* Default watchdog period, in seconds */
diff --git a/dev/i2c/x1226.c b/dev/i2c/x1226.c
index f83d85d..ecc66c2 100644
--- a/dev/i2c/x1226.c
+++ b/dev/i2c/x1226.c
@@ -47,7 +47,7 @@ __KERNEL_RCSID(0, "$NetBSD: x1226.c,v 1.18 2014/08/04 23:28:19 joerg Exp $");
 #include <sys/conf.h>
 #include <sys/event.h>
 
-#include <dev/clock_subr.h>
+#include <sys/clock.h>
 
 #include <dev/i2c/i2cvar.h>
 #include <dev/i2c/x1226reg.h>
diff --git a/dev/ic/intersil7170.c b/dev/ic/intersil7170.c
index 5d7f99a..e62534c 100644
--- a/dev/ic/intersil7170.c
+++ b/dev/ic/intersil7170.c
@@ -42,7 +42,7 @@ __KERNEL_RCSID(0, "$NetBSD: intersil7170.c,v 1.12 2008/04/28 20:23:50 martin Exp
 #include <sys/errno.h>
 
 #include <sys/bus.h>
-#include <dev/clock_subr.h>
+#include <sys/clock.h>
 #include <dev/ic/intersil7170reg.h>
 #include <dev/ic/intersil7170var.h>
 
diff --git a/dev/ic/mc146818.c b/dev/ic/mc146818.c
index 8ee39ee..b05e9ba 100644
--- a/dev/ic/mc146818.c
+++ b/dev/ic/mc146818.c
@@ -38,7 +38,7 @@ __KERNEL_RCSID(0, "$NetBSD: mc146818.c,v 1.18 2008/12/13 17:32:53 tsutsui Exp $"
 
 #include <sys/bus.h>
 
-#include <dev/clock_subr.h>
+#include <sys/clock.h>
 
 #include <dev/ic/mc146818reg.h>
 #include <dev/ic/mc146818var.h>
diff --git a/dev/ic/mk48txx.c b/dev/ic/mk48txx.c
index 2200ab5..7ae0442 100644
--- a/dev/ic/mk48txx.c
+++ b/dev/ic/mk48txx.c
@@ -41,7 +41,7 @@ __KERNEL_RCSID(0, "$NetBSD: mk48txx.c,v 1.26 2011/01/04 01:28:15 matt Exp $");
 #include <sys/errno.h>
 
 #include <sys/bus.h>
-#include <dev/clock_subr.h>
+#include <sys/clock.h>
 #include <dev/ic/mk48txxreg.h>
 #include <dev/ic/mk48txxvar.h>
 
diff --git a/dev/ic/mm58167.c b/dev/ic/mm58167.c
index bcb6d61..6c45c2b 100644
--- a/dev/ic/mm58167.c
+++ b/dev/ic/mm58167.c
@@ -43,7 +43,7 @@ __KERNEL_RCSID(0, "$NetBSD: mm58167.c,v 1.15 2013/07/25 04:21:47 msaitoh Exp $")
 #include <sys/device.h>
 
 #include <sys/bus.h>
-#include <dev/clock_subr.h>
+#include <sys/clock.h>
 #include <dev/ic/mm58167var.h>
 
 static int mm58167_gettime_ymdhms(todr_chip_handle_t, struct clock_ymdhms *);
diff --git a/dev/ic/msm6242b.c b/dev/ic/msm6242b.c
index f8a6328..15cd180 100644
--- a/dev/ic/msm6242b.c
+++ b/dev/ic/msm6242b.c
@@ -41,7 +41,7 @@ __KERNEL_RCSID(0, "$NetBSD: msm6242b.c,v 1.3 2013/12/04 07:48:59 rkujawa Exp $")
 #include <sys/device.h>
 #include <sys/bus.h>
 
-#include <dev/clock_subr.h>
+#include <sys/clock.h>
 
 #include <dev/ic/msm6242bvar.h>
 #include <dev/ic/msm6242breg.h>
diff --git a/dev/ic/rs5c313.c b/dev/ic/rs5c313.c
index 1a5c0ee..c42368f 100644
--- a/dev/ic/rs5c313.c
+++ b/dev/ic/rs5c313.c
@@ -34,7 +34,7 @@ __KERNEL_RCSID(0, "$NetBSD: rs5c313.c,v 1.9 2010/04/06 15:29:19 nonaka Exp $");
 #include <sys/device.h>
 #include <sys/kernel.h>
 
-#include <dev/clock_subr.h>
+#include <sys/clock.h>
 
 #include <dev/ic/rs5c313reg.h>
 #include <dev/ic/rs5c313var.h>
diff --git a/dev/mvme/clockvar.h b/dev/mvme/clockvar.h
index 9535f8b..0f50677 100644
--- a/dev/mvme/clockvar.h
+++ b/dev/mvme/clockvar.h
@@ -32,7 +32,7 @@
 #ifndef _MVME_CLOCKVAR_H
 #define _MVME_CLOCKVAR_H
 
-#include <dev/clock_subr.h>
+#include <sys/clock.h>
 
 /*
  * Definitions exported to ASIC-specific clock attachment.
diff --git a/dev/ofw/ofrtc.c b/dev/ofw/ofrtc.c
index fd372fd..c2851af 100644
--- a/dev/ofw/ofrtc.c
+++ b/dev/ofw/ofrtc.c
@@ -72,7 +72,7 @@ __KERNEL_RCSID(0, "$NetBSD: ofrtc.c,v 1.23 2011/07/26 08:59:38 mrg Exp $");
 #include <sys/conf.h>
 #include <sys/event.h>
 
-#include <dev/clock_subr.h>
+#include <sys/clock.h>
 #include <dev/ofw/openfirm.h>
 
 #define OFRTC_SEC 0
diff --git a/dev/pci/voyagervar.h b/dev/pci/voyagervar.h
index a94a22b..7aab55c 100644
--- a/dev/pci/voyagervar.h
+++ b/dev/pci/voyagervar.h
@@ -65,4 +65,4 @@ void  voyager_disestablish_intr(device_t, void *);
 /* frequency in Hz, duty cycle in 1000ths */
 uint32_t voyager_set_pwm(int, int);
 
-#endif
\ No newline at end of file
+#endif
diff --git a/external/bsd/compiler_rt/dist/test/Unit/ppc/fixtfdi_test.c b/external/bsd/compiler_rt/dist/test/Unit/ppc/fixtfdi_test.c
index b4865fb..ba42b67 100644
--- a/external/bsd/compiler_rt/dist/test/Unit/ppc/fixtfdi_test.c
+++ b/external/bsd/compiler_rt/dist/test/Unit/ppc/fixtfdi_test.c
@@ -474,4 +474,4 @@ int main(int argc, char *argv[]) {
 	}
 	
 	return 0;
-}
\ No newline at end of file
+}
diff --git a/external/bsd/compiler_rt/dist/test/builtins/Unit/ppc/fixtfdi_test.c b/external/bsd/compiler_rt/dist/test/builtins/Unit/ppc/fixtfdi_test.c
index b4865fb..ba42b67 100644
--- a/external/bsd/compiler_rt/dist/test/builtins/Unit/ppc/fixtfdi_test.c
+++ b/external/bsd/compiler_rt/dist/test/builtins/Unit/ppc/fixtfdi_test.c
@@ -474,4 +474,4 @@ int main(int argc, char *argv[]) {
 	}
 	
 	return 0;
-}
\ No newline at end of file
+}
diff --git a/fs/msdosfs/msdosfs_conv.c b/fs/msdosfs/msdosfs_conv.c
index ba3ca91..0125e28 100644
--- a/fs/msdosfs/msdosfs_conv.c
+++ b/fs/msdosfs/msdosfs_conv.c
@@ -70,7 +70,7 @@ __KERNEL_RCSID(0, "$NetBSD: msdosfs_conv.c,v 1.10 2014/09/01 09:09:47 martin Exp
 #include <dirent.h>
 #include <sys/queue.h>
 #endif
-#include <dev/clock_subr.h>
+#include <sys/clock.h>
 
 /*
  * MSDOSFS include files.
diff --git a/fs/smbfs/smbfs_subr.c b/fs/smbfs/smbfs_subr.c
index 79ae666..5e97b21 100644
--- a/fs/smbfs/smbfs_subr.c
+++ b/fs/smbfs/smbfs_subr.c
@@ -39,6 +39,7 @@ __KERNEL_RCSID(0, "$NetBSD: smbfs_subr.c,v 1.16 2012/11/30 23:24:21 nakayama Exp
 
 #include <sys/param.h>
 #include <sys/systm.h>
+#include <sys/clock.h>
 #include <sys/kernel.h>
 #include <sys/malloc.h>
 #include <sys/mount.h>
@@ -176,12 +177,12 @@ smb_time_unix2dos(struct timespec *tsp, int tzoff, u_int16_t *ddp,
 		if (days != lastday) {
 			lastday = days;
 			for (year = 1970;; year++) {
-				inc = year & 0x03 ? 365 : 366;
+				inc = days_per_year(year);
 				if (days < inc)
 					break;
 				days -= inc;
 			}
-			months = year & 0x03 ? regyear : leapyear;
+			months = is_leap_year(year) ? leapyear : regyear;
 			for (month = 0; days >= months[month]; month++)
 				;
 			if (month > 0)
diff --git a/fs/udf/udf_allocation.c b/fs/udf/udf_allocation.c
index 0021169..7c3c571 100644
--- a/fs/udf/udf_allocation.c
+++ b/fs/udf/udf_allocation.c
@@ -57,7 +57,7 @@ __KERNEL_RCSID(0, "$NetBSD: udf_allocation.c,v 1.36 2013/10/30 08:41:38 mrg Exp
 #include <sys/conf.h>
 #include <sys/kauth.h>
 #include <sys/kthread.h>
-#include <dev/clock_subr.h>
+#include <sys/clock.h>
 
 #include <fs/udf/ecma167-udf.h>
 #include <fs/udf/udf_mount.h>
diff --git a/fs/udf/udf_readwrite.c b/fs/udf/udf_readwrite.c
index 57c4ee2..52bcdef 100644
--- a/fs/udf/udf_readwrite.c
+++ b/fs/udf/udf_readwrite.c
@@ -56,7 +56,7 @@ __KERNEL_RCSID(0, "$NetBSD: udf_readwrite.c,v 1.11 2011/06/12 03:35:55 rmind Exp
 #include <sys/conf.h>
 #include <sys/kauth.h>
 #include <sys/kthread.h>
-#include <dev/clock_subr.h>
+#include <sys/clock.h>
 
 #include <fs/udf/ecma167-udf.h>
 #include <fs/udf/udf_mount.h>
diff --git a/fs/udf/udf_strat_bootstrap.c b/fs/udf/udf_strat_bootstrap.c
index 74567ad..01ced05 100644
--- a/fs/udf/udf_strat_bootstrap.c
+++ b/fs/udf/udf_strat_bootstrap.c
@@ -56,7 +56,7 @@ __KERNEL_RCSID(0, "$NetBSD: udf_strat_bootstrap.c,v 1.3 2008/12/16 16:18:25 pook
 #include <sys/conf.h>
 #include <sys/kauth.h>
 #include <sys/kthread.h>
-#include <dev/clock_subr.h>
+#include <sys/clock.h>
 
 #include <fs/udf/ecma167-udf.h>
 #include <fs/udf/udf_mount.h>
diff --git a/fs/udf/udf_strat_direct.c b/fs/udf/udf_strat_direct.c
index c6cd591..fec511f 100644
--- a/fs/udf/udf_strat_direct.c
+++ b/fs/udf/udf_strat_direct.c
@@ -56,7 +56,7 @@ __KERNEL_RCSID(0, "$NetBSD: udf_strat_direct.c,v 1.12 2013/10/30 08:41:38 mrg Ex
 #include <sys/conf.h>
 #include <sys/kauth.h>
 #include <sys/kthread.h>
-#include <dev/clock_subr.h>
+#include <sys/clock.h>
 
 #include <fs/udf/ecma167-udf.h>
 #include <fs/udf/udf_mount.h>
diff --git a/fs/udf/udf_strat_rmw.c b/fs/udf/udf_strat_rmw.c
index cf04d81..9b21203 100644
--- a/fs/udf/udf_strat_rmw.c
+++ b/fs/udf/udf_strat_rmw.c
@@ -56,7 +56,7 @@ __KERNEL_RCSID(0, "$NetBSD: udf_strat_rmw.c,v 1.24 2013/10/30 08:41:38 mrg Exp $
 #include <sys/conf.h>
 #include <sys/kauth.h>
 #include <sys/kthread.h>
-#include <dev/clock_subr.h>
+#include <sys/clock.h>
 
 #include <fs/udf/ecma167-udf.h>
 #include <fs/udf/udf_mount.h>
diff --git a/fs/udf/udf_strat_sequential.c b/fs/udf/udf_strat_sequential.c
index 8432589..e2525f1 100644
--- a/fs/udf/udf_strat_sequential.c
+++ b/fs/udf/udf_strat_sequential.c
@@ -56,7 +56,7 @@ __KERNEL_RCSID(0, "$NetBSD: udf_strat_sequential.c,v 1.13 2014/03/23 09:34:42 ch
 #include <sys/conf.h>
 #include <sys/kauth.h>
 #include <sys/kthread.h>
-#include <dev/clock_subr.h>
+#include <sys/clock.h>
 
 #include <fs/udf/ecma167-udf.h>
 #include <fs/udf/udf_mount.h>
diff --git a/fs/udf/udf_subr.c b/fs/udf/udf_subr.c
index 112d904..c3528a8 100644
--- a/fs/udf/udf_subr.c
+++ b/fs/udf/udf_subr.c
@@ -57,7 +57,7 @@ __KERNEL_RCSID(0, "$NetBSD: udf_subr.c,v 1.125 2014/07/29 15:36:43 reinoud Exp $
 #include <sys/conf.h>
 #include <sys/kauth.h>
 #include <fs/unicode.h>
-#include <dev/clock_subr.h>
+#include <sys/clock.h>
 
 #include <fs/udf/ecma167-udf.h>
 #include <fs/udf/udf_mount.h>
diff --git a/kern/kern_todr.c b/kern/kern_todr.c
index e2a6103..2c734f1 100644
--- a/kern/kern_todr.c
+++ b/kern/kern_todr.c
@@ -49,7 +49,7 @@ __KERNEL_RCSID(0, "$NetBSD: kern_todr.c,v 1.35 2013/08/29 01:05:29 tls Exp $");
 #include <sys/intr.h>
 #include <sys/rnd.h>
 
-#include <dev/clock_subr.h>	/* hmm.. this should probably move to sys */
+#include <sys/clock.h>
 
 static todr_chip_handle_t todr_handle = NULL;
 
@@ -85,7 +85,7 @@ inittodr(time_t base)
 
 	rnd_add_data(NULL, &base, sizeof(base), 0);
 
-	if (base < 5 * SECYR) {
+	if (base < 5 * SECS_PER_COMMON_YEAR) {
 		struct clock_ymdhms basedate;
 
 		/*
@@ -113,7 +113,7 @@ inittodr(time_t base)
 
 	if ((todr_handle == NULL) ||
 	    (todr_gettime(todr_handle, &tv) != 0) ||
-	    (tv.tv_sec < (25 * SECYR))) {
+	    (tv.tv_sec < (25 * SECS_PER_COMMON_YEAR))) {
 
 		if (todr_handle != NULL)
 			printf("WARNING: preposterous TOD clock time\n");
@@ -126,7 +126,7 @@ inittodr(time_t base)
 		if (deltat < 0)
 			deltat = -deltat;
 
-		if (!badbase && deltat >= 2 * SECDAY) {
+		if (!badbase && deltat >= 2 * SECS_PER_DAY) {
 			
 			if (tv.tv_sec < base) {
 				/*
@@ -136,11 +136,11 @@ inittodr(time_t base)
 				 * believe the filesystem.
 				 */
 				printf("WARNING: clock lost %" PRId64 " days\n",
-				    deltat / SECDAY);
+				    deltat / SECS_PER_DAY);
 				badrtc = true;
 			} else {
 				aprint_verbose("WARNING: clock gained %" PRId64
-				    " days\n", deltat / SECDAY);
+				    " days\n", deltat / SECS_PER_DAY);
 				goodtime = true;
 			}
 		} else {
@@ -179,8 +179,8 @@ inittodr(time_t base)
  * Reset the TODR based on the time value; used when the TODR
  * has a preposterous value and also when the time is reset
  * by the stime system call.  Also called when the TODR goes past
- * TODRZERO + 100*(SECYEAR+2*SECDAY) (e.g. on Jan 2 just after midnight)
- * to wrap the TODR around.
+ * TODRZERO + 100*(SECS_PER_COMMON_YEAR+2*SECS_PER_DAY)
+ * (e.g. on Jan 2 just after midnight) to wrap the TODR around.
  */
 void
 resettodr(void)
-- 
1.9.4

From 87a321dd45536cf79eeb685104894f1872dde033 Mon Sep 17 00:00:00 2001
From: Kamil Rytarowski <n54%gmx.com@localhost>
Date: Wed, 8 Oct 2014 00:59:30 +0200
Subject: [PATCH 4/5] NETBSD: Switch dev/clock_subr.c from dev/clock_subr.h to
 sys/clock.h

---
 dev/clock_subr.c | 56 +++++++++++---------------------------------------------
 1 file changed, 11 insertions(+), 45 deletions(-)

diff --git a/dev/clock_subr.c b/dev/clock_subr.c
index ac3f340..08d1453 100644
--- a/dev/clock_subr.c
+++ b/dev/clock_subr.c
@@ -61,12 +61,9 @@ __KERNEL_RCSID(0, "$NetBSD: clock_subr.c,v 1.22 2014/09/07 11:50:23 martin Exp $
 #include <errno.h>
 #endif /* ! _KERNEL */
 
-#include <dev/clock_subr.h>
+#include <sys/clock.h>
 
-static inline int leapyear(uint64_t year);
 #define FEBRUARY	2
-#define	days_in_year(a) 	(leapyear(a) ? 366 : 365)
-#define	days_in_month(a) 	(month_days[(a) - 1])
 
 /* for easier alignment:
  * time from the epoch to 2000 (there were 7 leap years): */
@@ -81,37 +78,6 @@ static inline int leapyear(uint64_t year);
 /* 400 year intervals include 97 leap years */
 #define	DAYS400YEARS	(365*400+97)
 
-static const int month_days[12] = {
-	31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31
-};
-
-/*
- * This inline avoids some unnecessary modulo operations
- * as compared with the usual macro:
- *   ( ((year % 4) == 0 &&
- *      (year % 100) != 0) ||
- *     ((year % 400) == 0) )
- * It is otherwise equivalent.
- */
-static inline int
-leapyear(uint64_t year)
-{
-	int rv = 0;
-
-	if (year < 1969)
-		return EINVAL;
-
-	if ((year & 3) == 0) {
-		rv = 1;
-		if ((year % 100) == 0) {
-			rv = 0;
-			if ((year % 400) == 0)
-				rv = 1;
-		}
-	}
-	return rv;
-}
-
 time_t
 clock_ymdhms_to_secs(struct clock_ymdhms *dt)
 {
@@ -126,13 +92,13 @@ clock_ymdhms_to_secs(struct clock_ymdhms *dt)
 	if (year < POSIX_BASE_YEAR)
 		return -1;
 	days = 0;
-	if (leapyear(year) && dt->dt_mon > FEBRUARY)
+	if (is_leap_year(year) && dt->dt_mon > FEBRUARY)
 		days++;
 
 	if (year < 2000) {
 		/* simple way for early years */
 		for (i = POSIX_BASE_YEAR; i < year; i++)
-			days += days_in_year(i);
+			days += days_per_year(i);
 	} else {
 		/* years are properly aligned */
 		days += DAYSTO2000;
@@ -151,7 +117,7 @@ clock_ymdhms_to_secs(struct clock_ymdhms *dt)
 		year -= i * 4;
 
 		for (i = dt->dt_year-year; i < dt->dt_year; i++)
-			days += days_in_year(i);
+			days += days_per_year(i);
 	}
 
 
@@ -182,8 +148,8 @@ clock_secs_to_ymdhms(time_t secs, struct clock_ymdhms *dt)
 	if (secs < 0)
 		return EINVAL;
 
-	days = secs / SECDAY;
-	rsec = secs % SECDAY;
+	days = secs / SECS_PER_DAY;
+	rsec = secs % SECS_PER_DAY;
 
 	/* Day of week (Note: 1/1/1970 was a Thursday) */
 	dt->dt_wday = (days + 4) % 7;
@@ -204,20 +170,20 @@ clock_secs_to_ymdhms(time_t secs, struct clock_ymdhms *dt)
 		days -= i*DAYS4YEARS;
 		dt->dt_year += i*4;
 
-		for (i = dt->dt_year; days >= days_in_year(i); i++)
-			days -= days_in_year(i);
+		for (i = dt->dt_year; days >= days_per_year(i); i++)
+			days -= days_per_year(i);
 		dt->dt_year = i;
 	} else {
 		/* Subtract out whole years, counting them in i. */
-		for (i = POSIX_BASE_YEAR; days >= days_in_year(i); i++)
-			days -= days_in_year(i);
+		for (i = POSIX_BASE_YEAR; days >= days_per_year(i); i++)
+			days -= days_per_year(i);
 		dt->dt_year = i;
 	}
 
 	/* Subtract out whole months, counting them in i. */
 	for (leap = 0, i = 1; days >= days_in_month(i)+leap; i++) {
 		days -= days_in_month(i)+leap;
-		if (i == 1 && leapyear(dt->dt_year))
+		if (i == 1 && is_leap_year(dt->dt_year))
 			leap = 1;
 		else
 			leap = 0;
-- 
1.9.4

From 6443c018b23f6ca3d14577deeb80d3bf9a13a612 Mon Sep 17 00:00:00 2001
From: Kamil Rytarowski <n54%gmx.com@localhost>
Date: Wed, 8 Oct 2014 01:00:35 +0200
Subject: [PATCH 5/5] NETBSD: Remove dev/clock_subr.h, obsoleted by sys/clock.h

---
 dev/clock_subr.h | 106 -------------------------------------------------------
 1 file changed, 106 deletions(-)
 delete mode 100644 dev/clock_subr.h

diff --git a/dev/clock_subr.h b/dev/clock_subr.h
deleted file mode 100644
index 74be860..0000000
--- a/dev/clock_subr.h
+++ /dev/null
@@ -1,106 +0,0 @@
-/*	$NetBSD: clock_subr.h,v 1.22 2014/09/07 11:50:23 martin Exp $	*/
-
-/*-
- * Copyright (c) 1996 The NetBSD Foundation, Inc.
- * All rights reserved.
- *
- * This code is derived from software contributed to The NetBSD Foundation
- * by Gordon W. Ross
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
- * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef _DEV_CLOCK_SUBR_H_
-#define _DEV_CLOCK_SUBR_H_
-
-/*
- * "POSIX time" to/from "YY/MM/DD/hh/mm/ss"
- */
-struct clock_ymdhms {
-	uint64_t dt_year;
-	u_char dt_mon;
-	u_char dt_day;
-	u_char dt_wday;	/* Day of week */
-	u_char dt_hour;
-	u_char dt_min;
-	u_char dt_sec;
-};
-
-time_t	clock_ymdhms_to_secs(struct clock_ymdhms *);
-int	clock_secs_to_ymdhms(time_t, struct clock_ymdhms *);
-
-/*
- * BCD to binary and binary to BCD.
- */
-#define	FROMBCD(x)	bcdtobin((x))
-#define	TOBCD(x)	bintobcd((x))
-
-/* Some handy constants. */
-#define SECDAY		(24 * 60 * 60)
-#define SECYR		(SECDAY * 365)
-
-/* Traditional POSIX base year */
-#define	POSIX_BASE_YEAR	1970
-
-/*
- * Interface to time-of-day clock devices.
- *
- * todr_gettime: convert time-of-day clock into a `struct timeval'
- * todr_settime: set time-of-day clock from a `struct timeval'
- *
- * (this is probably not so useful:)
- * todr_setwen: provide a machine-dependent TOD clock write-enable callback
- *		function which takes one boolean argument:
- *			1 to enable writes; 0 to disable writes.
- */
-struct todr_chip_handle {
-	void	*cookie;	/* Device specific data */
-	void	*bus_cookie;	/* Bus specific data */
-	time_t	base_time;	/* Base time (e.g. rootfs time) */
-
-	int	(*todr_gettime)(struct todr_chip_handle *, struct timeval *);
-	int	(*todr_settime)(struct todr_chip_handle *, struct timeval *);
-	int	(*todr_gettime_ymdhms)(struct todr_chip_handle *,
-	    			struct clock_ymdhms *);
-	int	(*todr_settime_ymdhms)(struct todr_chip_handle *,
-	    			struct clock_ymdhms *);
-	int	(*todr_setwen)(struct todr_chip_handle *, int);
-
-};
-typedef struct todr_chip_handle *todr_chip_handle_t;
-
-#define todr_wenable(ct, v)	if ((ct)->todr_setwen) \
-					((*(ct)->todr_setwen)(ct, v))
-
-/*
- * Probably these should evolve into internal routines in kern_todr.c.
- */
-extern int todr_gettime(todr_chip_handle_t tch, struct timeval *);
-extern int todr_settime(todr_chip_handle_t tch, struct timeval *);
-
-/*
- * Machine-dependent function that machine-independent RTC drivers can
- * use to register their todr_chip_handle_t with inittodr()/resettodr().
- */
-void	todr_attach(todr_chip_handle_t);
-
-#endif /* _DEV_CLOCK_SUBR_H_ */
-- 
1.9.4



Home | Main Index | Thread Index | Old Index