summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_time.c
diff options
context:
space:
mode:
authorphk <phk@FreeBSD.org>2003-02-03 19:49:35 +0000
committerphk <phk@FreeBSD.org>2003-02-03 19:49:35 +0000
commit3692879cc82e12c56c011d2bf97d1c02bd3d66c5 (patch)
tree7251be2a86087b08495da120d84f24f25ed673c8 /sys/kern/kern_time.c
parentdb8a973d3ddfc686520b7766d7464f5140726cd9 (diff)
downloadFreeBSD-src-3692879cc82e12c56c011d2bf97d1c02bd3d66c5.zip
FreeBSD-src-3692879cc82e12c56c011d2bf97d1c02bd3d66c5.tar.gz
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
Diffstat (limited to 'sys/kern/kern_time.c')
-rw-r--r--sys/kern/kern_time.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/sys/kern/kern_time.c b/sys/kern/kern_time.c
index 325ecec..405e930 100644
--- a/sys/kern/kern_time.c
+++ b/sys/kern/kern_time.c
@@ -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);
}
OpenPOWER on IntegriCloud