[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [PATCH v3 04/25] xen: implement an signed 64 bit division helper function



On Thu, 15 Dec 2011, Jan Beulich wrote:
> >>> On 15.12.11 at 17:30, <stefano.stabellini@xxxxxxxxxxxxx> wrote:
> > From: Stefano Stabellini <stefano.stabellini@xxxxxxxxxxxxx>
> > 
> > Implement a C function to perform 64 bit signed division and return both
> > quotient and remainder.
> > Useful as an helper function to implement __aeabi_ldivmod.
> > 
> > Signed-off-by: Stefano Stabellini <stefano.stabellini@xxxxxxxxxxxxx>
> > ---
> >  xen/common/lib.c |   19 +++++++++++++++++++
> >  1 files changed, 19 insertions(+), 0 deletions(-)
> > 
> > diff --git a/xen/common/lib.c b/xen/common/lib.c
> > index 4ae637c..fe831a3 100644
> > --- a/xen/common/lib.c
> > +++ b/xen/common/lib.c
> > @@ -399,6 +399,25 @@ s64 __moddi3(s64 a, s64 b)
> >      return (neg ? -urem : urem);
> >  }
> >  
> > +/*
> > + * Quotient and remainder of unsigned long long division
> > + */
> > +s64 __ldivmod_helper(s64 a, s64 b, s64 *r)
> > +{
> > +    u64 ua, ub, rem, quot;
> > +
> > +    ua = (a < 0) ? -(u64)a : a;
> > +    ub = (b < 0) ? -(u64)b : b;
> 
> ABS() in both cases?

Yep, good idea.

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.