Use utc_offset() where applicable, and hide the internals of it

as static variables.
This commit is contained in:
Poul-Henning Kamp 2006-10-02 18:23:37 +00:00
parent 948170b7d4
commit e5037a18a9
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=162970
7 changed files with 15 additions and 26 deletions

View File

@ -662,7 +662,7 @@ inittodr(time_t base)
/* sec now contains the number of seconds, since Jan 1 1970,
in the local time zone */
sec += tz_minuteswest * 60 + (wall_cmos_clock ? adjkerntz : 0);
sec += utc_offset();
y = time_second - sec;
if (y <= -2 || y >= 2) {
@ -700,7 +700,7 @@ resettodr()
/* Calculate local time to put in RTC */
tm -= tz_minuteswest * 60 + (wall_cmos_clock ? adjkerntz : 0);
tm -= utc_offset();
writertc(RTC_SEC, bin2bcd(tm%60)); tm /= 60; /* Write back Seconds */
writertc(RTC_MIN, bin2bcd(tm%60)); tm /= 60; /* Write back Minutes */

View File

@ -276,9 +276,7 @@ tw_osl_write_reg_inline(struct tw_cl_ctlr_handle *ctlr_handle,
* Return value: local time
*/
#define tw_osl_get_local_time() \
(time_second - (tz_minuteswest * 60) - \
(wall_cmos_clock ? adjkerntz : 0))
(time_second - utc_offset())
/*

View File

@ -55,7 +55,7 @@
#include <sys/clock.h>
#include <sys/kernel.h> /* defines tz */
#include <sys/systm.h>
#include <machine/clock.h>
#include <sys/clock.h>
#include <sys/dirent.h>
#include <sys/iconv.h>
#include <sys/mount.h>
@ -127,8 +127,7 @@ unix2dostime(tsp, ddp, dtp, dhp)
* If the time from the last conversion is the same as now, then
* skip the computations and use the saved result.
*/
t = tsp->tv_sec - (tz_minuteswest * 60)
- (wall_cmos_clock ? adjkerntz : 0);
t = tsp->tv_sec - utc_offset();
/* - daylight savings time correction */
t &= ~1;
if (lasttime != t) {
@ -239,8 +238,7 @@ dos2unixtime(dd, dt, dh, tsp)
days += ((dd & DD_DAY_MASK) >> DD_DAY_SHIFT) - 1;
lastseconds = (days * 24 * 60 * 60) + SECONDSTO1980;
}
tsp->tv_sec = seconds + lastseconds + (tz_minuteswest * 60)
+ adjkerntz;
tsp->tv_sec = seconds + lastseconds + utc_offset();
/* + daylight savings time correction */
tsp->tv_nsec = (dh % 100) * 10000000;
}

View File

@ -37,7 +37,7 @@
#include <sys/clock.h>
#include <sys/lockmgr.h>
#include <sys/malloc.h>
#include <machine/clock.h>
#include <sys/clock.h>
#include <sys/time.h>
#include <netncp/ncp.h>
@ -598,8 +598,7 @@ ncp_unix2dostime(tsp, tzoff, ddp, dtp, dhp)
* If the time from the last conversion is the same as now, then
* skip the computations and use the saved result.
*/
t = tsp->tv_sec - tzoff * 60 - tz_minuteswest * 60 -
(wall_cmos_clock ? adjkerntz : 0);
t = tsp->tv_sec - tzoff * 60 - utc_offset();
t &= ~1;
if (lasttime != t) {
lasttime = t;
@ -708,7 +707,6 @@ ncp_dos2unixtime(dd, dt, dh, tzoff, tsp)
days += ((dd & DD_DAY_MASK) >> DD_DAY_SHIFT) - 1;
lastseconds = (days * 24 * 60 * 60) + SECONDSTO1980;
}
tsp->tv_sec = seconds + lastseconds + tz_minuteswest * 60 +
tzoff * 60 + (wall_cmos_clock ? adjkerntz : 0);
tsp->tv_sec = seconds + lastseconds + tzoff * 60 + utc_offset();
tsp->tv_nsec = (dh % 100) * 10000000;
}

View File

@ -49,9 +49,9 @@ __FBSDID("$FreeBSD$");
#include <sys/sysctl.h>
#include <sys/timetc.h>
int adjkerntz; /* local offset from GMT in seconds */
int disable_rtc_set; /* disable resettodr() if != 0 */
int wall_cmos_clock; /* wall CMOS clock assumed if != 0 */
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 */
int tz_minuteswest;
int tz_dsttime;

View File

@ -58,9 +58,6 @@ __FBSDID("$FreeBSD$");
#include <sys/sysctl.h>
#include <sys/timetc.h>
/* XXX: for the CPU_* sysctl OID constants. */
#include <machine/cpu.h>
#include "clock_if.h"
static device_t clock_dev = NULL;
@ -132,8 +129,7 @@ inittodr(time_t base)
printf("Check and reset the date immediately!\n");
}
ts.tv_sec += tz_minuteswest * 60 +
(wall_cmos_clock ? adjkerntz : 0);
ts.tv_sec += utc_offset();
if (timespeccmp(&ref, &ts, >)) {
diff = ref;
@ -161,7 +157,7 @@ resettodr()
return;
getnanotime(&ts);
ts.tv_sec -= tz_minuteswest * 60 + (wall_cmos_clock ? adjkerntz : 0);
ts.tv_sec -= utc_offset();
if ((error = CLOCK_SETTIME(clock_dev, &ts)) != 0) {
printf("warning: clock_settime failed (%d), time-of-day clock "
"not adjusted to system time\n", error);

View File

@ -49,8 +49,7 @@
void inittodr(time_t base);
void resettodr(void);
void startrtclock(void);
extern int wall_cmos_clock;
extern int adjkerntz;
extern int disable_rtc_set;
/*