lkml.org 
[lkml]   [2008]   [Mar]   [14]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 1/4] introduce explicit signed/unsigned 64bit divide
Hi,

On Thu, 13 Mar 2008, Andrew Morton wrote:

> I think what happened was that [patch 3/4] fixed this up. Of course,
> that patch doesn't apply on this updated [1/4]. I _could_ just take the
> old [1/4] (I think), but I don't know if that wouild be bisection-friendly.
>
> Anyway, please redo&resend? Thanks.

Done.

> Please have a think about that code in arch/x86/kvm/i8254.c too. It is
> painful to see remote subsystems (re)implementing generic infrastructure.
> Can KVM use existing code? Should we hoist what KVM has done there into
> generic code? Did it have to use a(nother bleeding) macro?

Looker closer at it, div64_u64() seems to be a bit overkill, as the
divisor is a 32bit value, so the following should do the same job (only
compile tested):

u64 muldiv64(u64 a, u32 b, u32 c)
{
union {
u64 ll;
struct {
u32 low, high;
};
} u, res, rl, rh;

u.ll = a;
rl.ll = (u64)b * u.low;
rh.ll = (u64)b * u.high;
rh.ll += rl.high;
res.high = div_u64_rem(rh.ll, c, &rl.high);
res.low = div_u64(rl.ll, c);
return res.ll;
}

Moving it to a more generic location shouldn't be a big problem.

bye, Roman


\
 
 \ /
  Last update: 2008-03-14 18:49    [W:0.030 / U:7.912 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site