]> xenbits.xensource.com Git - qemu-xen-4.4-testing.git/commitdiff
div64 fix (aka ssh bug)
authorbellard <bellard>
Thu, 8 Sep 2005 19:26:14 +0000 (19:26 +0000)
committerbellard <bellard>
Thu, 8 Sep 2005 19:26:14 +0000 (19:26 +0000)
target-i386/helper.c

index c7fea9553e56642f9ad8de29a63b2ba904ad63ea..e2f6fba2efb34f11be2d620559cee263a9016e61 100644 (file)
@@ -3261,7 +3261,7 @@ static void imul64(uint64_t *plow, uint64_t *phigh, int64_t a, int64_t b)
 static int div64(uint64_t *plow, uint64_t *phigh, uint64_t b)
 {
     uint64_t q, r, a1, a0;
-    int i, qb;
+    int i, qb, ab;
 
     a0 = *plow;
     a1 = *phigh;
@@ -3275,8 +3275,9 @@ static int div64(uint64_t *plow, uint64_t *phigh, uint64_t b)
             return 1;
         /* XXX: use a better algorithm */
         for(i = 0; i < 64; i++) {
+            ab = a1 >> 63;
             a1 = (a1 << 1) | (a0 >> 63);
-            if (a1 >= b) {
+            if (ab || a1 >= b) {
                 a1 -= b;
                 qb = 1;
             } else {