ia64/xen-unstable

changeset 18885:c520af4bde59

x86, time: Fix scale_reciprocal().
Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
author Keir Fraser <keir.fraser@citrix.com>
date Fri Dec 05 14:46:38 2008 +0000 (2008-12-05)
parents 4ffd935c08a3
children e34f3e314ecf
files xen/arch/x86/time.c
line diff
     1.1 --- a/xen/arch/x86/time.c	Fri Dec 05 13:06:57 2008 +0000
     1.2 +++ b/xen/arch/x86/time.c	Fri Dec 05 14:46:38 2008 +0000
     1.3 @@ -152,14 +152,23 @@ static inline u64 scale_delta(u64 delta,
     1.4  /* Compute the reciprocal of the given time_scale. */
     1.5  static inline struct time_scale scale_reciprocal(struct time_scale scale)
     1.6  {
     1.7 -    u32 q, r;
     1.8 +    struct time_scale reciprocal;
     1.9 +    u32 dividend;
    1.10 +
    1.11 +    dividend = 0x80000000u;
    1.12 +    reciprocal.shift = 1 - scale.shift;
    1.13 +    while ( unlikely(dividend >= scale.mul_frac) )
    1.14 +    {
    1.15 +        dividend >>= 1;
    1.16 +        reciprocal.shift++;
    1.17 +    }
    1.18  
    1.19      asm (
    1.20          "divl %4"
    1.21 -        : "=a" (q), "=d" (r)
    1.22 -        : "0" (1), "1" (0), "r" (scale.mul_frac) );
    1.23 +        : "=a" (reciprocal.mul_frac), "=d" (dividend)
    1.24 +        : "0" (0), "1" (dividend), "r" (scale.mul_frac) );
    1.25  
    1.26 -    return (struct time_scale) { .shift = -scale.shift, .mul_frac = q };
    1.27 +    return reciprocal;
    1.28  }
    1.29  
    1.30  /*