div64 fix (aka ssh bug)

git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1570 c046a42c-6fe2-441c-8c8c-71466251a162
This commit is contained in:
bellard 2005-09-08 19:26:14 +00:00
parent de75815006
commit c0b24a1dd6

View 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 {