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

[Xen-changelog] [xen-unstable] xen: implement an signed 64 bit division helper function



# HG changeset patch
# User Stefano Stabellini <stefano.stabellini@xxxxxxxxxxxxx>
# Date 1327311635 0
# Node ID 37eefb79503cc36a5e3ca324744b06dffb4fb912
# Parent  96e071fbefd7fb1331a04b0bc11c1518605d3c02
xen: implement an signed 64 bit division helper function

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>
Committed-by: Keir Fraser <keir@xxxxxxx>
---


diff -r 96e071fbefd7 -r 37eefb79503c xen/common/lib.c
--- a/xen/common/lib.c  Mon Jan 23 09:39:58 2012 +0000
+++ b/xen/common/lib.c  Mon Jan 23 09:40:35 2012 +0000
@@ -399,6 +399,25 @@
     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 = ABS(a);
+    ub = ABS(b);
+    quot = __qdivrem(ua, ub, &rem);
+    if ( a < 0 )
+        *r = -rem;
+    else
+        *r = rem;
+    if ( (a < 0) ^ (b < 0) )
+        return -quot;
+    else
+        return quot;
+}
 #endif /* BITS_PER_LONG == 32 */
 
 /* Compute with 96 bit intermediate result: (a*b)/c */

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


 


Rackspace

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