diff options
author | 2016-09-12 04:28:41 +0000 | |
---|---|---|
committer | 2016-09-12 04:28:41 +0000 | |
commit | e65fc0a080c66825439d0a478ae6ab826dabeb53 (patch) | |
tree | 7cbed39b0fb130dc366ba2ab68477a6d1e67a02e /lib/libm/src | |
parent | Spaces->tabs. (diff) | |
download | wireguard-openbsd-e65fc0a080c66825439d0a478ae6ab826dabeb53.tar.xz wireguard-openbsd-e65fc0a080c66825439d0a478ae6ab826dabeb53.zip |
Use fe*() routines from <fenv.h> instead of fp*() routines from <ieeefp.h>
ok tb@ martynas@
Diffstat (limited to 'lib/libm/src')
-rw-r--r-- | lib/libm/src/e_sqrtl.c | 21 |
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); } |