diff options
author | kaf24@scramble.cl.cam.ac.uk <kaf24@scramble.cl.cam.ac.uk> | 2004-12-22 19:44:39 +0000 |
---|---|---|
committer | kaf24@scramble.cl.cam.ac.uk <kaf24@scramble.cl.cam.ac.uk> | 2004-12-22 19:44:39 +0000 |
commit | 84bb38f7b0840e66e08572ed9c3cd9caf5bd4a45 (patch) | |
tree | 6e9951c6e2e5354344dd8eac1249dae3c62bd9f0 | |
parent | 80d936c1406b087ebf99871a650db0d2b6faa00c (diff) | |
download | xen-84bb38f7b0840e66e08572ed9c3cd9caf5bd4a45.tar.gz xen-84bb38f7b0840e66e08572ed9c3cd9caf5bd4a45.tar.bz2 xen-84bb38f7b0840e66e08572ed9c3cd9caf5bd4a45.zip |
bitkeeper revision 1.1159.187.77 (41c9cea7oEBJLap-n-eFcbORZkWXOQ)
More 2.4 time fixes.
-rw-r--r-- | linux-2.4.28-xen-sparse/arch/xen/kernel/time.c | 31 |
1 files changed, 26 insertions, 5 deletions
diff --git a/linux-2.4.28-xen-sparse/arch/xen/kernel/time.c b/linux-2.4.28-xen-sparse/arch/xen/kernel/time.c index 04ceb5e0d4..9b3d40a08c 100644 --- a/linux-2.4.28-xen-sparse/arch/xen/kernel/time.c +++ b/linux-2.4.28-xen-sparse/arch/xen/kernel/time.c @@ -99,6 +99,10 @@ static u64 processed_system_time; /* System time (ns) at last processing. */ #define NS_PER_TICK (1000000000ULL/HZ) +#ifndef NSEC_PER_SEC +#define NSEC_PER_SEC (1000000000L) +#endif + #define HANDLE_USEC_UNDERFLOW(_tv) \ do { \ while ( (_tv).tv_usec < 0 ) \ @@ -115,6 +119,17 @@ static u64 processed_system_time; /* System time (ns) at last processing. */ (_tv).tv_sec++; \ } \ } while ( 0 ) +static inline void __normalize_time(time_t *sec, s64 *nsec) +{ + while (*nsec >= NSEC_PER_SEC) { + (*nsec) -= NSEC_PER_SEC; + (*sec)++; + } + while (*nsec < 0) { + (*nsec) += NSEC_PER_SEC; + (*sec)--; + } +} /* Dynamically-mapped IRQs. */ static int time_irq, debug_irq; @@ -256,6 +271,7 @@ void do_gettimeofday(struct timeval *tv) { unsigned long flags, lost; struct timeval _tv; + s64 nsec; again: read_lock_irqsave(&xtime_lock, flags); @@ -266,8 +282,9 @@ void do_gettimeofday(struct timeval *tv) _tv.tv_sec = xtime.tv_sec; _tv.tv_usec += xtime.tv_usec; - _tv.tv_usec += - (unsigned long)(shadow_system_time - processed_system_time) / 1000UL; + nsec = shadow_system_time - processed_system_time; + __normalize_time(&_tv.tv_sec, &nsec); + _tv.tv_usec += (long)nsec / 1000L; if ( unlikely(!TIME_VALUES_UP_TO_DATE) ) { @@ -304,7 +321,8 @@ void do_gettimeofday(struct timeval *tv) void do_settimeofday(struct timeval *tv) { struct timeval newtv; - suseconds_t usec; + s64 nsec; + suseconds_t usec; if ( !INDEPENDENT_WALLCLOCK() ) return; @@ -318,8 +336,11 @@ void do_settimeofday(struct timeval *tv) */ again: usec = tv->tv_usec - __get_time_delta_usecs(); - usec -= - (unsigned long)(shadow_system_time - processed_system_time) / 1000UL; + + nsec = shadow_system_time - processed_system_time; + __normalize_time(&tv->tv_sec, &nsec); + usec -= (long)nsec / 1000L; + if ( unlikely(!TIME_VALUES_UP_TO_DATE) ) { __get_time_values_from_xen(); |