From 5e3b14069e3fe25ec2595124e6e0103c7be4f813 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Wed, 6 Jan 2010 22:43:39 +0100 Subject: hwclock: make it report system/rtc clock difference function old new delta rtc_tm2time - 89 +89 read_rtc 23 86 +63 rtc_read_tm - 49 +49 hwclock_main 428 466 +38 rtcwake_main 453 477 +24 rtc_read_time 142 - -142 ------------------------------------------------------------------------------ (add/remove: 2/1 grow/shrink: 3/0 up/down: 263/-142) Total: 121 bytes Signed-off-by: Denys Vlasenko --- libbb/rtc.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'libbb/rtc.c') diff --git a/libbb/rtc.c b/libbb/rtc.c index 2f38b8a7e..9807e1cf9 100644 --- a/libbb/rtc.c +++ b/libbb/rtc.c @@ -59,15 +59,17 @@ int FAST_FUNC rtc_xopen(const char **default_rtc, int flags) return xopen(*default_rtc, flags); } -time_t FAST_FUNC rtc_read_time(int fd, int utc) +void FAST_FUNC rtc_read_tm(struct tm *tm, int fd) { - struct tm tm; - char *oldtz = 0; - time_t t = 0; + memset(tm, 0, sizeof(*tm)); + xioctl(fd, RTC_RD_TIME, tm); + tm->tm_isdst = -1; /* "not known" */ +} - memset(&tm, 0, sizeof(struct tm)); - xioctl(fd, RTC_RD_TIME, &tm); - tm.tm_isdst = -1; /* not known */ +time_t FAST_FUNC rtc_tm2time(struct tm *tm, int utc) +{ + char *oldtz = oldtz; /* for compiler */ + time_t t; if (utc) { oldtz = getenv("TZ"); @@ -75,7 +77,7 @@ time_t FAST_FUNC rtc_read_time(int fd, int utc) tzset(); } - t = mktime(&tm); + t = mktime(tm); if (utc) { unsetenv("TZ"); -- cgit v1.2.3