diff options
Diffstat (limited to 'sys/kern/subr_clock.c')
-rw-r--r-- | sys/kern/subr_clock.c | 29 |
1 files changed, 27 insertions, 2 deletions
diff --git a/sys/kern/subr_clock.c b/sys/kern/subr_clock.c index b2f7827..ce9a128 100644 --- a/sys/kern/subr_clock.c +++ b/sys/kern/subr_clock.c @@ -49,6 +49,7 @@ __FBSDID("$FreeBSD$"); #include <sys/sysctl.h> #include <sys/timetc.h> +#define ct_debug bootverbose static int adjkerntz; /* local offset from GMT in seconds */ static int wall_cmos_clock; /* wall CMOS clock assumed if != 0 */ int disable_rtc_set; /* disable resettodr() if != 0 */ @@ -107,7 +108,7 @@ static const int month_days[12] = { * ((year % 400) == 0) ) * It is otherwise equivalent. */ -static __inline int +static int leapyear(int year) { int rv = 0; @@ -123,6 +124,14 @@ leapyear(int year) return (rv); } +static void +print_ct(struct clocktime *ct) +{ + printf("[%04d-%02d-%02d %02d:%02d:%02d]", + ct->year, ct->mon, ct->day, + ct->hour, ct->min, ct->sec); +} + int clock_ct_to_ts(struct clocktime *ct, struct timespec *ts) { @@ -131,12 +140,21 @@ clock_ct_to_ts(struct clocktime *ct, struct timespec *ts) year = ct->year; + if (ct_debug) { + printf("ct_to_ts("); + print_ct(ct); + printf(")"); + } + /* Sanity checks. */ if (ct->mon < 1 || ct->mon > 12 || ct->day < 1 || ct->day > days_in_month(year, ct->mon) || ct->hour > 23 || ct->min > 59 || ct->sec > 59 || - ct->year > 2037) /* time_t overflow */ + ct->year > 2037) { /* time_t overflow */ + if (ct_debug) + printf(" = EINVAL\n"); return (EINVAL); + } /* * Compute days since start of time @@ -160,6 +178,8 @@ clock_ct_to_ts(struct clocktime *ct, struct timespec *ts) ts->tv_sec = secs; ts->tv_nsec = ct->nsec; + if (ct_debug) + printf(" = %d.%09ld\n", ts->tv_sec, (long)ts->tv_nsec); return (0); } @@ -196,6 +216,11 @@ clock_ts_to_ct(struct timespec *ts, struct clocktime *ct) rsec = rsec % 60; ct->sec = rsec; ct->nsec = ts->tv_nsec; + if (ct_debug) { + printf("ts_to_ct(%d.%09ld) = ", ts->tv_sec, (long)ts->tv_nsec); + print_ct(ct); + printf("\n"); + } } int |