diff options
author | Jakub Jelinek <jakub@redhat.com> | 2017-07-19 15:12:58 +0200 |
---|---|---|
committer | Jakub Jelinek <jakub@gcc.gnu.org> | 2017-07-19 15:12:58 +0200 |
commit | 1eba0867060b1643d71d4185fbc23995248092bf (patch) | |
tree | b933cf0474996b72f099f09c134fd321c9590600 /libquadmath/math/llroundq.c | |
parent | 564e405c138dc1891ca92462a585bf89444d7dd1 (diff) | |
download | gcc-1eba0867060b1643d71d4185fbc23995248092bf.zip gcc-1eba0867060b1643d71d4185fbc23995248092bf.tar.gz gcc-1eba0867060b1643d71d4185fbc23995248092bf.tar.bz2 |
re PR libquadmath/65757 (gfortran gives incorrect result for anint with real*16 argument)
PR libquadmath/65757
* quadmath-imp.h (math_opt_barrier, math_force_eval,
math_narrow_eval, math_check_force_underflow,
math_check_force_underflow_nonneg): Define.
* math/ceilq.c: Backport changes from upstream glibc
between 2012-11-01 and 2017-07-13.
* math/remquoq.c: Likewise.
* math/expq.c: Likewise.
* math/llroundq.c: Likewise.
* math/logq.c: Likewise.
* math/atanq.c: Likewise.
* math/nearbyintq.c: Likewise.
* math/scalblnq.c: Likewise.
* math/finiteq.c: Likewise.
* math/atanhq.c: Likewise.
* math/expm1q.c: Likewise.
* math/sinhq.c: Likewise.
* math/log10q.c: Likewise.
* math/rintq.c: Likewise.
* math/roundq.c: Likewise.
* math/fmaq.c: Likewise.
* math/erfq.c: Likewise.
* math/log2q.c: Likewise.
* math/lroundq.c: Likewise.
* math/j1q.c: Likewise.
* math/scalbnq.c: Likewise.
* math/truncq.c: Likewise.
* math/frexpq.c: Likewise.
* math/sincosq.c: Likewise.
* math/tanhq.c: Likewise.
* math/asinq.c: Likewise.
* math/coshq.c: Likewise.
* math/j0q.c: Likewise.
* math/asinhq.c: Likewise.
* math/floorq.c: Likewise.
* math/sinq_kernel.c: Likewise.
* math/powq.c: Likewise.
* math/hypotq.c: Likewise.
* math/sincos_table.c: Likewise.
* math/rem_pio2q.c: Likewise.
* math/nextafterq.c: Likewise.
* math/log1pq.c: Likewise.
* math/sincosq_kernel.c: Likewise.
* math/tanq.c: Likewise.
* math/acosq.c: Likewise.
* math/lrintq.c: Likewise.
* math/llrintq.c: Likewise.
From-SVN: r250343
Diffstat (limited to 'libquadmath/math/llroundq.c')
-rw-r--r-- | libquadmath/math/llroundq.c | 29 |
1 files changed, 24 insertions, 5 deletions
diff --git a/libquadmath/math/llroundq.c b/libquadmath/math/llroundq.c index d22180d..098fb9e 100644 --- a/libquadmath/math/llroundq.c +++ b/libquadmath/math/llroundq.c @@ -1,8 +1,8 @@ /* Round __float128 value to long long int. - Copyright (C) 1997, 1999, 2004 Free Software Foundation, Inc. + Copyright (C) 1997-2017 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997 and - Jakub Jelinek <jj@ultra.linux.cz>, 1999. + Jakub Jelinek <jj@ultra.linux.cz>, 1999. The GNU C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public @@ -59,13 +59,32 @@ llroundq (__float128 x) if (j0 == 48) result = (long long int) i0; else - result = ((long long int) i0 << (j0 - 48)) | (j >> (112 - j0)); + { + result = ((long long int) i0 << (j0 - 48)) | (j >> (112 - j0)); +#if defined FE_INVALID && defined USE_FENV_H + if (sign == 1 && result == LLONG_MIN) + /* Rounding brought the value out of range. */ + feraiseexcept (FE_INVALID); +#endif + } } } else { - /* The number is too large. It is left implementation defined - what happens. */ + /* The number is too large. Unless it rounds to LLONG_MIN, + FE_INVALID must be raised and the return value is + unspecified. */ +#ifdef FE_INVALID + if (x <= (__float128) LLONG_MIN - 0.5Q) + { + /* If truncation produces LLONG_MIN, the cast will not raise + the exception, but may raise "inexact". */ +#ifdef USE_FENV_H + feraiseexcept (FE_INVALID); +#endif + return LLONG_MIN; + } +#endif return (long long int) x; } |