Split the global timezone structure into two integer fields to
prevent the compiler from optimizing assignments into byte-copy operations which might make access to the individual fields non-atomic. Use the individual fields throughout, and don't bother locking them with Giant: it is no longer needed. Inspired by: tjr
This commit is contained in:
parent
db5fb5c2b4
commit
91f1c2b3cc
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=110299
@ -908,7 +908,7 @@ inittodr(time_t base)
|
||||
/* sec now contains the number of seconds, since Jan 1 1970,
|
||||
in the local time zone */
|
||||
|
||||
sec += tz.tz_minuteswest * 60 + (wall_cmos_clock ? adjkerntz : 0);
|
||||
sec += tz_minuteswest * 60 + (wall_cmos_clock ? adjkerntz : 0);
|
||||
|
||||
y = time_second - sec;
|
||||
if (y <= -2 || y >= 2) {
|
||||
@ -946,7 +946,7 @@ resettodr()
|
||||
|
||||
/* Calculate local time to put in RTC */
|
||||
|
||||
tm -= tz.tz_minuteswest * 60 + (wall_cmos_clock ? adjkerntz : 0);
|
||||
tm -= tz_minuteswest * 60 + (wall_cmos_clock ? adjkerntz : 0);
|
||||
|
||||
writertc(RTC_SEC, bin2bcd(tm%60)); tm /= 60; /* Write back Seconds */
|
||||
writertc(RTC_MIN, bin2bcd(tm%60)); tm /= 60; /* Write back Minutes */
|
||||
|
@ -908,7 +908,7 @@ inittodr(time_t base)
|
||||
/* sec now contains the number of seconds, since Jan 1 1970,
|
||||
in the local time zone */
|
||||
|
||||
sec += tz.tz_minuteswest * 60 + (wall_cmos_clock ? adjkerntz : 0);
|
||||
sec += tz_minuteswest * 60 + (wall_cmos_clock ? adjkerntz : 0);
|
||||
|
||||
y = time_second - sec;
|
||||
if (y <= -2 || y >= 2) {
|
||||
@ -946,7 +946,7 @@ resettodr()
|
||||
|
||||
/* Calculate local time to put in RTC */
|
||||
|
||||
tm -= tz.tz_minuteswest * 60 + (wall_cmos_clock ? adjkerntz : 0);
|
||||
tm -= tz_minuteswest * 60 + (wall_cmos_clock ? adjkerntz : 0);
|
||||
|
||||
writertc(RTC_SEC, bin2bcd(tm%60)); tm /= 60; /* Write back Seconds */
|
||||
writertc(RTC_MIN, bin2bcd(tm%60)); tm /= 60; /* Write back Minutes */
|
||||
|
@ -112,7 +112,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.tz_minuteswest * 60)
|
||||
t = tsp->tv_sec - (tz_minuteswest * 60)
|
||||
- (wall_cmos_clock ? adjkerntz : 0);
|
||||
/* - daylight savings time correction */
|
||||
t &= ~1;
|
||||
@ -224,7 +224,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.tz_minuteswest * 60)
|
||||
tsp->tv_sec = seconds + lastseconds + (tz_minuteswest * 60)
|
||||
+ adjkerntz;
|
||||
/* + daylight savings time correction */
|
||||
tsp->tv_nsec = (dh % 100) * 10000000;
|
||||
|
@ -596,7 +596,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.tz_minuteswest * 60 -
|
||||
t = tsp->tv_sec - tzoff * 60 - tz_minuteswest * 60 -
|
||||
(wall_cmos_clock ? adjkerntz : 0);
|
||||
t &= ~1;
|
||||
if (lasttime != t) {
|
||||
@ -706,7 +706,7 @@ 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.tz_minuteswest * 60 +
|
||||
tsp->tv_sec = seconds + lastseconds + tz_minuteswest * 60 +
|
||||
tzoff * 60 + (wall_cmos_clock ? adjkerntz : 0);
|
||||
tsp->tv_nsec = (dh % 100) * 10000000;
|
||||
}
|
||||
|
@ -108,7 +108,7 @@ static u_short lastdtime;
|
||||
void
|
||||
smb_time_local2server(struct timespec *tsp, int tzoff, u_long *seconds)
|
||||
{
|
||||
*seconds = tsp->tv_sec - tzoff * 60 /*- tz.tz_minuteswest * 60 -
|
||||
*seconds = tsp->tv_sec - tzoff * 60 /*- tz_minuteswest * 60 -
|
||||
(wall_cmos_clock ? adjkerntz : 0)*/;
|
||||
}
|
||||
|
||||
@ -116,7 +116,7 @@ void
|
||||
smb_time_server2local(u_long seconds, int tzoff, struct timespec *tsp)
|
||||
{
|
||||
tsp->tv_sec = seconds + tzoff * 60;
|
||||
/*+ tz.tz_minuteswest * 60 + (wall_cmos_clock ? adjkerntz : 0)*/;
|
||||
/*+ tz_minuteswest * 60 + (wall_cmos_clock ? adjkerntz : 0)*/;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -908,7 +908,7 @@ inittodr(time_t base)
|
||||
/* sec now contains the number of seconds, since Jan 1 1970,
|
||||
in the local time zone */
|
||||
|
||||
sec += tz.tz_minuteswest * 60 + (wall_cmos_clock ? adjkerntz : 0);
|
||||
sec += tz_minuteswest * 60 + (wall_cmos_clock ? adjkerntz : 0);
|
||||
|
||||
y = time_second - sec;
|
||||
if (y <= -2 || y >= 2) {
|
||||
@ -946,7 +946,7 @@ resettodr()
|
||||
|
||||
/* Calculate local time to put in RTC */
|
||||
|
||||
tm -= tz.tz_minuteswest * 60 + (wall_cmos_clock ? adjkerntz : 0);
|
||||
tm -= tz_minuteswest * 60 + (wall_cmos_clock ? adjkerntz : 0);
|
||||
|
||||
writertc(RTC_SEC, bin2bcd(tm%60)); tm /= 60; /* Write back Seconds */
|
||||
writertc(RTC_MIN, bin2bcd(tm%60)); tm /= 60; /* Write back Minutes */
|
||||
|
@ -120,8 +120,8 @@ xenix_ftime(td, uap)
|
||||
microtime(&tv);
|
||||
itb.time = tv.tv_sec;
|
||||
itb.millitm = (tv.tv_usec / 1000);
|
||||
itb.timezone = tz.tz_minuteswest;
|
||||
itb.dstflag = tz.tz_dsttime != DST_NONE;
|
||||
itb.timezone = tz_minuteswest;
|
||||
itb.dstflag = tz_dsttime != DST_NONE;
|
||||
|
||||
return copyout((caddr_t)&itb, (caddr_t)uap->tp,
|
||||
sizeof(struct ibcs2_timeb));
|
||||
|
@ -908,7 +908,7 @@ inittodr(time_t base)
|
||||
/* sec now contains the number of seconds, since Jan 1 1970,
|
||||
in the local time zone */
|
||||
|
||||
sec += tz.tz_minuteswest * 60 + (wall_cmos_clock ? adjkerntz : 0);
|
||||
sec += tz_minuteswest * 60 + (wall_cmos_clock ? adjkerntz : 0);
|
||||
|
||||
y = time_second - sec;
|
||||
if (y <= -2 || y >= 2) {
|
||||
@ -946,7 +946,7 @@ resettodr()
|
||||
|
||||
/* Calculate local time to put in RTC */
|
||||
|
||||
tm -= tz.tz_minuteswest * 60 + (wall_cmos_clock ? adjkerntz : 0);
|
||||
tm -= tz_minuteswest * 60 + (wall_cmos_clock ? adjkerntz : 0);
|
||||
|
||||
writertc(RTC_SEC, bin2bcd(tm%60)); tm /= 60; /* Write back Seconds */
|
||||
writertc(RTC_MIN, bin2bcd(tm%60)); tm /= 60; /* Write back Minutes */
|
||||
|
@ -908,7 +908,7 @@ inittodr(time_t base)
|
||||
/* sec now contains the number of seconds, since Jan 1 1970,
|
||||
in the local time zone */
|
||||
|
||||
sec += tz.tz_minuteswest * 60 + (wall_cmos_clock ? adjkerntz : 0);
|
||||
sec += tz_minuteswest * 60 + (wall_cmos_clock ? adjkerntz : 0);
|
||||
|
||||
y = time_second - sec;
|
||||
if (y <= -2 || y >= 2) {
|
||||
@ -946,7 +946,7 @@ resettodr()
|
||||
|
||||
/* Calculate local time to put in RTC */
|
||||
|
||||
tm -= tz.tz_minuteswest * 60 + (wall_cmos_clock ? adjkerntz : 0);
|
||||
tm -= tz_minuteswest * 60 + (wall_cmos_clock ? adjkerntz : 0);
|
||||
|
||||
writertc(RTC_SEC, bin2bcd(tm%60)); tm /= 60; /* Write back Seconds */
|
||||
writertc(RTC_MIN, bin2bcd(tm%60)); tm /= 60; /* Write back Minutes */
|
||||
|
@ -55,7 +55,8 @@
|
||||
#include <vm/vm.h>
|
||||
#include <vm/vm_extern.h>
|
||||
|
||||
struct timezone tz;
|
||||
int tz_minuteswest;
|
||||
int tz_dsttime;
|
||||
|
||||
/*
|
||||
* Time of day and interval timer support.
|
||||
@ -327,9 +328,8 @@ gettimeofday(struct thread *td, struct gettimeofday_args *uap)
|
||||
error = copyout(&atv, uap->tp, sizeof (atv));
|
||||
}
|
||||
if (error == 0 && uap->tzp != NULL) {
|
||||
mtx_lock(&Giant);
|
||||
rtz = tz;
|
||||
mtx_unlock(&Giant);
|
||||
rtz.tz_minuteswest = tz_minuteswest;
|
||||
rtz.tz_dsttime = tz_dsttime;
|
||||
error = copyout(&rtz, uap->tzp, sizeof (rtz));
|
||||
}
|
||||
return (error);
|
||||
@ -373,9 +373,8 @@ settimeofday(struct thread *td, struct settimeofday_args *uap)
|
||||
if (uap->tv && (error = settime(td, &atv)))
|
||||
return (error);
|
||||
if (uap->tzp) {
|
||||
mtx_lock(&Giant);
|
||||
tz = atz;
|
||||
mtx_unlock(&Giant);
|
||||
tz_minuteswest = atz.tz_minuteswest;
|
||||
tz_dsttime = atz.tz_dsttime;
|
||||
}
|
||||
return (error);
|
||||
}
|
||||
|
@ -281,7 +281,7 @@ inittodr(time_t base)
|
||||
printf("Check and reset the date immediately!\n");
|
||||
}
|
||||
|
||||
ts.tv_sec += tz.tz_minuteswest * 60 +
|
||||
ts.tv_sec += tz_minuteswest * 60 +
|
||||
(wall_cmos_clock ? adjkerntz : 0);
|
||||
|
||||
if (timespeccmp(&ref, &ts, >)) {
|
||||
@ -310,7 +310,7 @@ resettodr()
|
||||
return;
|
||||
|
||||
getnanotime(&ts);
|
||||
ts.tv_sec -= tz.tz_minuteswest * 60 + (wall_cmos_clock ? adjkerntz : 0);
|
||||
ts.tv_sec -= tz_minuteswest * 60 + (wall_cmos_clock ? adjkerntz : 0);
|
||||
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);
|
||||
|
@ -281,7 +281,7 @@ inittodr(time_t base)
|
||||
printf("Check and reset the date immediately!\n");
|
||||
}
|
||||
|
||||
ts.tv_sec += tz.tz_minuteswest * 60 +
|
||||
ts.tv_sec += tz_minuteswest * 60 +
|
||||
(wall_cmos_clock ? adjkerntz : 0);
|
||||
|
||||
if (timespeccmp(&ref, &ts, >)) {
|
||||
@ -310,7 +310,7 @@ resettodr()
|
||||
return;
|
||||
|
||||
getnanotime(&ts);
|
||||
ts.tv_sec -= tz.tz_minuteswest * 60 + (wall_cmos_clock ? adjkerntz : 0);
|
||||
ts.tv_sec -= tz_minuteswest * 60 + (wall_cmos_clock ? adjkerntz : 0);
|
||||
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);
|
||||
|
@ -1200,7 +1200,7 @@ inittodr(time_t base)
|
||||
in the local time zone */
|
||||
#endif
|
||||
|
||||
sec += tz.tz_minuteswest * 60 + (wall_cmos_clock ? adjkerntz : 0);
|
||||
sec += tz_minuteswest * 60 + (wall_cmos_clock ? adjkerntz : 0);
|
||||
|
||||
y = time_second - sec;
|
||||
if (y <= -2 || y >= 2) {
|
||||
@ -1241,7 +1241,7 @@ resettodr()
|
||||
|
||||
/* Calculate local time to put in RTC */
|
||||
|
||||
tm -= tz.tz_minuteswest * 60 + (wall_cmos_clock ? adjkerntz : 0);
|
||||
tm -= tz_minuteswest * 60 + (wall_cmos_clock ? adjkerntz : 0);
|
||||
|
||||
rtc_outb(bin2bcd(tm%60)); tm /= 60; /* Write back Seconds */
|
||||
rtc_outb(bin2bcd(tm%60)); tm /= 60; /* Write back Minutes */
|
||||
@ -1279,7 +1279,7 @@ resettodr()
|
||||
|
||||
/* Calculate local time to put in RTC */
|
||||
|
||||
tm -= tz.tz_minuteswest * 60 + (wall_cmos_clock ? adjkerntz : 0);
|
||||
tm -= tz_minuteswest * 60 + (wall_cmos_clock ? adjkerntz : 0);
|
||||
|
||||
writertc(RTC_SEC, bin2bcd(tm%60)); tm /= 60; /* Write back Seconds */
|
||||
writertc(RTC_MIN, bin2bcd(tm%60)); tm /= 60; /* Write back Minutes */
|
||||
|
@ -1200,7 +1200,7 @@ inittodr(time_t base)
|
||||
in the local time zone */
|
||||
#endif
|
||||
|
||||
sec += tz.tz_minuteswest * 60 + (wall_cmos_clock ? adjkerntz : 0);
|
||||
sec += tz_minuteswest * 60 + (wall_cmos_clock ? adjkerntz : 0);
|
||||
|
||||
y = time_second - sec;
|
||||
if (y <= -2 || y >= 2) {
|
||||
@ -1241,7 +1241,7 @@ resettodr()
|
||||
|
||||
/* Calculate local time to put in RTC */
|
||||
|
||||
tm -= tz.tz_minuteswest * 60 + (wall_cmos_clock ? adjkerntz : 0);
|
||||
tm -= tz_minuteswest * 60 + (wall_cmos_clock ? adjkerntz : 0);
|
||||
|
||||
rtc_outb(bin2bcd(tm%60)); tm /= 60; /* Write back Seconds */
|
||||
rtc_outb(bin2bcd(tm%60)); tm /= 60; /* Write back Minutes */
|
||||
@ -1279,7 +1279,7 @@ resettodr()
|
||||
|
||||
/* Calculate local time to put in RTC */
|
||||
|
||||
tm -= tz.tz_minuteswest * 60 + (wall_cmos_clock ? adjkerntz : 0);
|
||||
tm -= tz_minuteswest * 60 + (wall_cmos_clock ? adjkerntz : 0);
|
||||
|
||||
writertc(RTC_SEC, bin2bcd(tm%60)); tm /= 60; /* Write back Seconds */
|
||||
writertc(RTC_MIN, bin2bcd(tm%60)); tm /= 60; /* Write back Minutes */
|
||||
|
@ -1200,7 +1200,7 @@ inittodr(time_t base)
|
||||
in the local time zone */
|
||||
#endif
|
||||
|
||||
sec += tz.tz_minuteswest * 60 + (wall_cmos_clock ? adjkerntz : 0);
|
||||
sec += tz_minuteswest * 60 + (wall_cmos_clock ? adjkerntz : 0);
|
||||
|
||||
y = time_second - sec;
|
||||
if (y <= -2 || y >= 2) {
|
||||
@ -1241,7 +1241,7 @@ resettodr()
|
||||
|
||||
/* Calculate local time to put in RTC */
|
||||
|
||||
tm -= tz.tz_minuteswest * 60 + (wall_cmos_clock ? adjkerntz : 0);
|
||||
tm -= tz_minuteswest * 60 + (wall_cmos_clock ? adjkerntz : 0);
|
||||
|
||||
rtc_outb(bin2bcd(tm%60)); tm /= 60; /* Write back Seconds */
|
||||
rtc_outb(bin2bcd(tm%60)); tm /= 60; /* Write back Minutes */
|
||||
@ -1279,7 +1279,7 @@ resettodr()
|
||||
|
||||
/* Calculate local time to put in RTC */
|
||||
|
||||
tm -= tz.tz_minuteswest * 60 + (wall_cmos_clock ? adjkerntz : 0);
|
||||
tm -= tz_minuteswest * 60 + (wall_cmos_clock ? adjkerntz : 0);
|
||||
|
||||
writertc(RTC_SEC, bin2bcd(tm%60)); tm /= 60; /* Write back Seconds */
|
||||
writertc(RTC_MIN, bin2bcd(tm%60)); tm /= 60; /* Write back Minutes */
|
||||
|
@ -68,8 +68,6 @@ extern char kernelname[MAXPATHLEN];
|
||||
/* 1.2 */
|
||||
extern struct timeval boottime;
|
||||
|
||||
extern struct timezone tz; /* XXX */
|
||||
|
||||
extern int tick; /* usec per tick (1000000 / hz) */
|
||||
extern int hz; /* system clock's frequency */
|
||||
extern int psratio; /* ratio: prof / stat */
|
||||
@ -79,6 +77,9 @@ extern int profprocs; /* number of process's profiling */
|
||||
extern int ticks;
|
||||
extern int lbolt; /* once a second sleep address */
|
||||
|
||||
extern int tz_minuteswest;
|
||||
extern int tz_dsttime;
|
||||
|
||||
#endif /* _KERNEL */
|
||||
|
||||
/*
|
||||
|
Loading…
Reference in New Issue
Block a user