ia64/xen-unstable

changeset 7375:9e373ffff3e6

NS_PER_TICK must be a s64 quantity. It is compared with
possibly -ve values which we do not want to 'promote' to
big +ve values.

Signed-off-by: Keir Fraser <keir@xensource.com>
author kaf24@firebug.cl.cam.ac.uk
date Thu Oct 13 08:38:49 2005 +0100 (2005-10-13)
parents 48f542f8d906
children 43677823b395
files linux-2.6-xen-sparse/arch/xen/i386/kernel/time.c
line diff
     1.1 --- a/linux-2.6-xen-sparse/arch/xen/i386/kernel/time.c	Thu Oct 13 08:06:27 2005 +0100
     1.2 +++ b/linux-2.6-xen-sparse/arch/xen/i386/kernel/time.c	Thu Oct 13 08:38:49 2005 +0100
     1.3 @@ -122,7 +122,8 @@ static u32 shadow_tv_version;
     1.4  static u64 processed_system_time;   /* System time (ns) at last processing. */
     1.5  static DEFINE_PER_CPU(u64, processed_system_time);
     1.6  
     1.7 -#define NS_PER_TICK (1000000000ULL/HZ)
     1.8 +/* Must be signed, as it's compared with s64 quantities which can be -ve. */
     1.9 +#define NS_PER_TICK (1000000000LL/HZ)
    1.10  
    1.11  static inline void __normalize_time(time_t *sec, s64 *nsec)
    1.12  {
    1.13 @@ -235,9 +236,9 @@ static void __update_wallclock(time_t se
    1.14  
    1.15  	/* Adjust wall-clock time base based on wall_jiffies ticks. */
    1.16  	wc_nsec = processed_system_time;
    1.17 -	wc_nsec += (u64)sec * 1000000000ULL;
    1.18 -	wc_nsec += (u64)nsec;
    1.19 -	wc_nsec -= (jiffies - wall_jiffies) * (u64)(NSEC_PER_SEC / HZ);
    1.20 +	wc_nsec += sec * (u64)NSEC_PER_SEC;
    1.21 +	wc_nsec += nsec;
    1.22 +	wc_nsec -= (jiffies - wall_jiffies) * (u64)NS_PER_TICK;
    1.23  
    1.24  	/* Split wallclock base into seconds and nanoseconds. */
    1.25  	tmp = wc_nsec;
    1.26 @@ -437,7 +438,7 @@ int do_settimeofday(struct timespec *tv)
    1.27  	 * be stale, so we can retry with fresh ones.
    1.28  	 */
    1.29  	for ( ; ; ) {
    1.30 -		nsec = (s64)tv->tv_nsec - (s64)get_nsec_offset(shadow);
    1.31 +		nsec = tv->tv_nsec - get_nsec_offset(shadow);
    1.32  		if (time_values_up_to_date(cpu))
    1.33  			break;
    1.34  		get_time_values_from_xen();
    1.35 @@ -558,7 +559,7 @@ irqreturn_t timer_interrupt(int irq, voi
    1.36  	}
    1.37  	while (!time_values_up_to_date(cpu));
    1.38  
    1.39 -	if (unlikely(delta < (s64)-1000000) || unlikely(delta_cpu < 0)) {
    1.40 +	if (unlikely(delta < -1000000LL) || unlikely(delta_cpu < 0)) {
    1.41  		printk("Timer ISR/%d: Time went backwards: "
    1.42  		       "delta=%lld cpu_delta=%lld shadow=%lld "
    1.43  		       "off=%lld processed=%lld cpu_processed=%lld\n",
    1.44 @@ -802,7 +803,7 @@ static inline u64 jiffies_to_st(unsigned
    1.45  		 * but that's ok: we'll just end up with a shorter timeout. */
    1.46  		if (delta < 1) 
    1.47  			delta = 1;
    1.48 -		st = processed_system_time + ((u64)delta * NS_PER_TICK);
    1.49 +		st = processed_system_time + (delta * (u64)NS_PER_TICK);
    1.50  	} while (read_seqretry(&xtime_lock, seq));
    1.51  
    1.52  	return st;