debuggers.hg

changeset 3357:feb29654f4d9

bitkeeper revision 1.1159.1.500 (41c9ced6bi_22nPlm0WqxtYuPUpiTw)

Merge scramble.cl.cam.ac.uk:/local/scratch/kaf24/xen-2.0-testing.bk
into scramble.cl.cam.ac.uk:/local/scratch/kaf24/xen-unstable.bk
author kaf24@scramble.cl.cam.ac.uk
date Wed Dec 22 19:45:26 2004 +0000 (2004-12-22)
parents a2352469313f 90c778996d20
children fb44ce115c8e
files linux-2.4.28-xen-sparse/arch/xen/kernel/time.c
line diff
     1.1 --- a/linux-2.4.28-xen-sparse/arch/xen/kernel/time.c	Wed Dec 22 15:10:05 2004 +0000
     1.2 +++ b/linux-2.4.28-xen-sparse/arch/xen/kernel/time.c	Wed Dec 22 19:45:26 2004 +0000
     1.3 @@ -99,6 +99,10 @@ static u64 processed_system_time;   /* S
     1.4  
     1.5  #define NS_PER_TICK (1000000000ULL/HZ)
     1.6  
     1.7 +#ifndef NSEC_PER_SEC
     1.8 +#define NSEC_PER_SEC (1000000000L)
     1.9 +#endif
    1.10 +
    1.11  #define HANDLE_USEC_UNDERFLOW(_tv)         \
    1.12      do {                                   \
    1.13          while ( (_tv).tv_usec < 0 )        \
    1.14 @@ -115,6 +119,17 @@ static u64 processed_system_time;   /* S
    1.15              (_tv).tv_sec++;                \
    1.16          }                                  \
    1.17      } while ( 0 )
    1.18 +static inline void __normalize_time(time_t *sec, s64 *nsec)
    1.19 +{
    1.20 +	while (*nsec >= NSEC_PER_SEC) {
    1.21 +		(*nsec) -= NSEC_PER_SEC;
    1.22 +		(*sec)++;
    1.23 +	}
    1.24 +	while (*nsec < 0) {
    1.25 +		(*nsec) += NSEC_PER_SEC;
    1.26 +		(*sec)--;
    1.27 +	}
    1.28 +}
    1.29  
    1.30  /* Dynamically-mapped IRQs. */
    1.31  static int time_irq, debug_irq;
    1.32 @@ -256,6 +271,7 @@ void do_gettimeofday(struct timeval *tv)
    1.33  {
    1.34      unsigned long flags, lost;
    1.35      struct timeval _tv;
    1.36 +    s64 nsec;
    1.37  
    1.38   again:
    1.39      read_lock_irqsave(&xtime_lock, flags);
    1.40 @@ -266,8 +282,9 @@ void do_gettimeofday(struct timeval *tv)
    1.41      _tv.tv_sec   = xtime.tv_sec;
    1.42      _tv.tv_usec += xtime.tv_usec;
    1.43  
    1.44 -    _tv.tv_usec += 
    1.45 -        (unsigned long)(shadow_system_time - processed_system_time) / 1000UL;
    1.46 +    nsec = shadow_system_time - processed_system_time;
    1.47 +    __normalize_time(&_tv.tv_sec, &nsec);
    1.48 +    _tv.tv_usec += (long)nsec / 1000L;
    1.49  
    1.50      if ( unlikely(!TIME_VALUES_UP_TO_DATE) )
    1.51      {
    1.52 @@ -304,7 +321,8 @@ void do_gettimeofday(struct timeval *tv)
    1.53  void do_settimeofday(struct timeval *tv)
    1.54  {
    1.55      struct timeval newtv;
    1.56 -    suseconds_t usec;
    1.57 +    s64            nsec;
    1.58 +    suseconds_t    usec;
    1.59      
    1.60      if ( !INDEPENDENT_WALLCLOCK() )
    1.61          return;
    1.62 @@ -318,8 +336,11 @@ void do_settimeofday(struct timeval *tv)
    1.63       */
    1.64   again:
    1.65      usec = tv->tv_usec - __get_time_delta_usecs();
    1.66 -    usec -= 
    1.67 -        (unsigned long)(shadow_system_time - processed_system_time) / 1000UL;
    1.68 +
    1.69 +    nsec = shadow_system_time - processed_system_time;
    1.70 +    __normalize_time(&tv->tv_sec, &nsec);
    1.71 +    usec -= (long)nsec / 1000L;
    1.72 +
    1.73      if ( unlikely(!TIME_VALUES_UP_TO_DATE) )
    1.74      {
    1.75          __get_time_values_from_xen();