summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkettenis <kettenis@openbsd.org>2014-09-14 18:40:49 +0000
committerkettenis <kettenis@openbsd.org>2014-09-14 18:40:49 +0000
commitdc5d6ebd198a996af78432366480950fe1e2cccd (patch)
tree57f70f6eb03fce0f26a394e8be2e2d5ecfe61761
parentDo not claim that empty numbers set EINVAL, our implementation doesn't. (diff)
downloadwireguard-openbsd-dc5d6ebd198a996af78432366480950fe1e2cccd.tar.xz
wireguard-openbsd-dc5d6ebd198a996af78432366480950fe1e2cccd.zip
Fix some bugs in the fpu_sqrt implementation that would limit the accuracy
of the result in many cases. From FreeBSD allbeit with some changes to keep the coding style consistent.
-rw-r--r--sys/arch/sparc64/fpu/fpu_sqrt.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/sys/arch/sparc64/fpu/fpu_sqrt.c b/sys/arch/sparc64/fpu/fpu_sqrt.c
index 720759b78de..f8c6cbbbca1 100644
--- a/sys/arch/sparc64/fpu/fpu_sqrt.c
+++ b/sys/arch/sparc64/fpu/fpu_sqrt.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: fpu_sqrt.c,v 1.3 2013/11/26 20:33:15 deraadt Exp $ */
+/* $OpenBSD: fpu_sqrt.c,v 1.4 2014/09/14 18:40:49 kettenis Exp $ */
/* $NetBSD: fpu_sqrt.c,v 1.2 1994/11/20 20:52:46 deraadt Exp $ */
/*
@@ -363,12 +363,12 @@ fpu_sqrt(fe)
FPU_SUBCS(d2, x2, t2);
FPU_SUBCS(d1, x1, t1);
FPU_SUBC(d0, x0, t0);
- ODD_DOUBLE;
if ((int)d0 >= 0) {
- x0 = d0, x1 = d1, x2 = d2;
+ x0 = d0, x1 = d1, x2 = d2, x3 = d3;
q |= bit;
y2 |= 1;
}
+ ODD_DOUBLE;
while ((bit >>= 1) != 0) {
EVEN_DOUBLE;
t3 = y3 | bit;
@@ -377,7 +377,7 @@ fpu_sqrt(fe)
FPU_SUBCS(d1, x1, t1);
FPU_SUBC(d0, x0, t0);
if ((int)d0 >= 0) {
- x0 = d0, x1 = d1, x2 = d2;
+ x0 = d0, x1 = d1, x2 = d2, x3 = d3;
q |= bit;
y3 |= bit << 1;
}