diff options
author | phk <phk@FreeBSD.org> | 2008-04-12 20:35:56 +0000 |
---|---|---|
committer | phk <phk@FreeBSD.org> | 2008-04-12 20:35:56 +0000 |
commit | cee09d51d4e2b359570320e3519918b7dba86ece (patch) | |
tree | c2792e2597c0fbf8ab62bf16fa35c4f0c9d6f5e2 | |
parent | 7aa529a5ec291eab87efd974e366d509f1321bd2 (diff) | |
download | FreeBSD-src-cee09d51d4e2b359570320e3519918b7dba86ece.zip FreeBSD-src-cee09d51d4e2b359570320e3519918b7dba86ece.tar.gz |
Emit summaries of struct c(alender)t(ime) <-> struct timespec conversions
under bootverbose.
Struct ct is used for setting/reading real time clocks and I'm about
to Do Things to some of those, so a bit of preemptive debugging is
in order.
Remove a pointless __inline.
-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 |