summaryrefslogtreecommitdiff
path: root/emulators/qemu/patches/patch-ay
blob: d50ab3d4136735045af3818119a5d26f991d5754 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
$NetBSD: patch-ay,v 1.1 2005/11/04 21:10:42 dbj Exp $

--- target-i386/helper.c.orig	2005-09-04 13:11:31.000000000 -0400
+++ target-i386/helper.c
@@ -3261,7 +3261,7 @@ static void imul64(uint64_t *plow, uint6
 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_
             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 {