NetBSD-Bugs archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: kern/49207
The following reply was made to PR kern/49207; it has been noted by GNATS.
From: "Kamil Rytarowski" <n54%gmx.com@localhost>
To: gnats-bugs%gnats.netbsd.org@localhost
Cc:
Subject: Re: kern/49207
Date: Sat, 27 Sep 2014 21:11:03 +0200
Hello,
I've cleaned the patch according to the discussion at tech-kern.
There are two patches:
1. src/tools
2. src/sys
I'm looking forward for review and inclusion to NetBSD-current.
commit 4fa3ad68002f0b94c8eb516c7a2cf7daa3cda66a
Author: Kamil Rytarowski <n54%gmx.com@localhost>
Date: Tue Sep 16 21:28:13 2014 +0200
sys: Go for <sys/clock.h>
diff --git a/compat/dev/clock_subr.h b/compat/dev/clock_subr.h
index eb8a7d7..46387a5 100644
--- a/compat/dev/clock_subr.h
+++ b/compat/dev/clock_subr.h
@@ -36,6 +36,8 @@
* This is a slightly stripped down version of src/sys/dev/clock_subr.h
*/
+#include "../../../sys/sys/clock.h"
+
/*
* "POSIX time" to/from "YY/MM/DD/hh/mm/ss"
*/
@@ -52,11 +54,4 @@ struct clock_ymdhms {
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_ */
commit f34146553de33acb8d1d93900b7e89f243c5087e
Author: Kamil Rytarowski <n54%gmx.com@localhost>
Date: Sat Sep 27 20:49:08 2014 +0200
NETBSD: Extract part of sys/dev/clock_subr.h to sys/sys/clock.h
Preserve compatibility with code depending on clock_subr.h.
Use explicit values for sec-of-day, sec-of-month etc, to catch
quickly problems with ports that define int as 16 bit value.
Currently there are no ports with 16 bit (a candidate is PDP-11).
diff --git a/dev/clock_subr.h b/dev/clock_subr.h
index 74be860..2492725 100644
--- a/dev/clock_subr.h
+++ b/dev/clock_subr.h
@@ -32,6 +32,8 @@
#ifndef _DEV_CLOCK_SUBR_H_
#define _DEV_CLOCK_SUBR_H_
+#include <sys/clock.h>
+
/*
* "POSIX time" to/from "YY/MM/DD/hh/mm/ss"
*/
@@ -54,13 +56,6 @@ int clock_secs_to_ymdhms(time_t, struct clock_ymdhms *);
#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.
*
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..38d79b4
--- /dev/null
+++ b/sys/clock.h
@@ -0,0 +1,49 @@
+/* $NetBSD: $ */
+
+/*-
+ * 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 _SYS_CLOCK_H_
+#define _SYS_CLOCK_H_
+
+#define IS_LEAP_YEAR(year) ((((year) % 4) == 0 && ((year) % 100) != 0) || ((year%400)) == 0)
+
+/* Some handy constants. */
+#define SECMIN 60
+#define SECHOUR 3600
+#define SECDAY 86400
+#define DAYSYR(year) (IS_LEAP_YEAR(year) ? 366 : 365)
+#define SECYR 31536000 /* common year */
+#define SECLYR 31622400 /* leap year */
+#define SECYEAR(year) (DAYSYR(year) * SECDAY)
+
+/* Traditional POSIX base year */
+#define POSIX_BASE_YEAR 1970
+
+#endif /* _SYS_CLOCK_H_ */
Home |
Main Index |
Thread Index |
Old Index