summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilip Guenther <guenther@cvs.openbsd.org>2016-09-12 04:28:42 +0000
committerPhilip Guenther <guenther@cvs.openbsd.org>2016-09-12 04:28:42 +0000
commite5188618ac5c222627ac16815336898801afbef2 (patch)
tree26c1b28889a8c5fd14bca62caa7c685f616af34d
parentadde5af96f81fe801392d8ac9dd45a1b4de7c618 (diff)
Use fe*() routines from <fenv.h> instead of fp*() routines from <ieeefp.h>
ok tb@ martynas@
-rw-r--r--lib/libm/src/e_sqrtl.c21
1 files changed, 11 insertions, 10 deletions
diff --git a/lib/libm/src/e_sqrtl.c b/lib/libm/src/e_sqrtl.c
index 7ecc83381d7..9bbeec88db0 100644
--- a/lib/libm/src/e_sqrtl.c
+++ b/lib/libm/src/e_sqrtl.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: e_sqrtl.c,v 1.1 2008/12/09 20:00:35 martynas Exp $ */
+/* $OpenBSD: e_sqrtl.c,v 1.2 2016/09/12 04:28:41 guenther Exp $ */
/*-
* Copyright (c) 2007 Steven G. Kargl
* All rights reserved.
@@ -26,9 +26,9 @@
*/
#include <sys/types.h>
-#include <machine/ieee.h>
+#include <machine/ieee.h> /* for struct ieee_ext */
+#include <fenv.h>
#include <float.h>
-#include <ieeefp.h>
#include <math.h>
#ifdef EXT_IMPLICIT_NBIT
@@ -204,27 +204,28 @@ sqrtl(long double x)
u.e = xn + lo; /* Combine everything. */
u.bits.ext_exp += (k >> 1) - 1;
- fpsetsticky(fpgetsticky() & ~FP_X_IMP);
- r = fpsetround(FP_RZ); /* Set to round-toward-zero. */
+ feclearexcept(FE_INEXACT);
+ r = fegetround();
+ fesetround(FE_TOWARDZERO); /* Set to round-toward-zero. */
xn = x / u.e; /* Chopped quotient (inexact?). */
- if (!(fpgetsticky() & FP_X_IMP)) { /* Quotient is exact. */
+ if (!fetestexcept(FE_INEXACT)) { /* Quotient is exact. */
if (xn == u.e) {
- fpsetround(r);
+ fesetround(r);
return (u.e);
}
/* Round correctly for inputs like x = y**2 - ulp. */
xn = dec(xn); /* xn = xn - ulp. */
}
- if (r == FP_RN) {
+ if (r == FE_TONEAREST) {
xn = inc(xn); /* xn = xn + ulp. */
- } else if (r == FP_RP) {
+ } else if (r == FE_UPWARD) {
u.e = inc(u.e); /* u.e = u.e + ulp. */
xn = inc(xn); /* xn = xn + ulp. */
}
u.e = u.e + xn; /* Chopped sum. */
- fpsetround(r); /* Restore env and raise inexact */
+ fesetround(r); /* Restore env and raise inexact */
u.bits.ext_exp--;
return (u.e);
}