diff options
Diffstat (limited to 'lib/libc/quad/divdi3.c')
-rw-r--r-- | lib/libc/quad/divdi3.c | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/lib/libc/quad/divdi3.c b/lib/libc/quad/divdi3.c index 99041e67f3f..b8b5eba4733 100644 --- a/lib/libc/quad/divdi3.c +++ b/lib/libc/quad/divdi3.c @@ -32,7 +32,7 @@ */ #if defined(LIBC_SCCS) && !defined(lint) -static char rcsid[] = "$OpenBSD: divdi3.c,v 1.3 2003/06/02 20:18:36 millert Exp $"; +static char rcsid[] = "$OpenBSD: divdi3.c,v 1.4 2004/04/27 17:46:46 otto Exp $"; #endif /* LIBC_SCCS and not lint */ #include "quad.h" @@ -46,16 +46,18 @@ __divdi3(a, b) quad_t a, b; { u_quad_t ua, ub, uq; - int neg; + int neg = 0; + + ua = a; + ub = b; if (a < 0) - ua = -(u_quad_t)a, neg = 1; - else - ua = a, neg = 0; + ua = -ua, neg ^= 1; if (b < 0) - ub = -(u_quad_t)b, neg ^= 1; - else - ub = b; + ub = -ub, neg ^= 1; + uq = __qdivrem(ua, ub, (u_quad_t *)0); - return (neg ? -uq : uq); + if (neg) + uq = - uq; + return uq; } |