summaryrefslogtreecommitdiffstats
path: root/sys/lib/libkern/divdi3.c
diff options
context:
space:
mode:
authormickey <mickey@openbsd.org>2004-11-28 07:23:41 +0000
committermickey <mickey@openbsd.org>2004-11-28 07:23:41 +0000
commitf6a3c9b1fa71b1a71957242d0da17e5e1f46240e (patch)
tree923ecdd7af5dbaae56d4af536e50c2c9c2c46dba /sys/lib/libkern/divdi3.c
parenta tiny hppa64 bit (diff)
downloadwireguard-openbsd-f6a3c9b1fa71b1a71957242d0da17e5e1f46240e.tar.xz
wireguard-openbsd-f6a3c9b1fa71b1a71957242d0da17e5e1f46240e.zip
sync from libc
Diffstat (limited to 'sys/lib/libkern/divdi3.c')
-rw-r--r--sys/lib/libkern/divdi3.c27
1 files changed, 11 insertions, 16 deletions
diff --git a/sys/lib/libkern/divdi3.c b/sys/lib/libkern/divdi3.c
index 70008be0fa1..c77959ed469 100644
--- a/sys/lib/libkern/divdi3.c
+++ b/sys/lib/libkern/divdi3.c
@@ -1,6 +1,3 @@
-/* $OpenBSD: divdi3.c,v 1.4 2004/08/07 00:38:32 deraadt Exp $ */
-/* $NetBSD: divdi3.c,v 1.5 1995/10/07 09:26:24 mycroft Exp $ */
-
/*-
* Copyright (c) 1992, 1993
* The Regents of the University of California. All rights reserved.
@@ -35,11 +32,7 @@
*/
#if defined(LIBC_SCCS) && !defined(lint)
-#if 0
-static char sccsid[] = "@(#)divdi3.c 8.1 (Berkeley) 6/4/93";
-#else
-static char rcsid[] = "$OpenBSD: divdi3.c,v 1.4 2004/08/07 00:38:32 deraadt Exp $";
-#endif
+static char rcsid[] = "$OpenBSD: divdi3.c,v 1.5 2004/11/28 07:23:41 mickey Exp $";
#endif /* LIBC_SCCS and not lint */
#include "quad.h"
@@ -52,16 +45,18 @@ quad_t
__divdi3(quad_t a, quad_t 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;
}