glibc/sysdeps/ieee754/ldbl-128
Joseph Myers 8afdb7ac1e Fix lround, llround missing exceptions close to overflow threshold (bug 19088).
The dbl-64, ldbl-96 and ldbl-128 implementations of lround and llround
fail to produce "invalid" exceptions in cases where the rounded result
overflows the target type, but truncating the floating-point argument
to the next integer towards zero does not overflow it (so in
particular casts do not produce such exceptions).  (This issue cannot
arise for float, or for double with 64-bit target type, or for ldbl-96
with 64-bit target type and negative arguments, because of
insufficient precision in the floating-point type for arguments with
the relevant property to exist.)

This patch fixes these problems by inserting checks for the special
cases that can occur in each implementation, and explicitly raising
FE_INVALID (and avoiding the cast if it might raise spurious
FE_INEXACT).

Tested for x86_64, x86 and mips64.

	[BZ #19088]
	* sysdeps/ieee754/dbl-64/s_lround.c: Include <fenv.h> and
	<limits.h>.
	(__lround) [FE_INVALID]: Force FE_INVALID exception when result
	overflows but exception would not result from cast.
	* sysdeps/ieee754/dbl-64/wordsize-64/s_lround.c: Include <fenv.h>
	and <limits.h>.
	(__lround) [FE_INVALID]: Force FE_INVALID exception when result
	overflows but exception would not result from cast.
	* sysdeps/ieee754/ldbl-128/s_llroundl.c: Include <fenv.h> and
	<limits.h>.
	(__llroundl) [FE_INVALID]: Force FE_INVALID exception when result
	overflows but exception would not result from cast.
	* sysdeps/ieee754/ldbl-128/s_lroundl.c: Include <fenv.h> and
	<limits.h>.
	(__lroundl) [FE_INVALID]: Force FE_INVALID exception when result
	overflows but exception would not result from cast.
	* sysdeps/ieee754/ldbl-96/s_llroundl.c: Include <fenv.h> and
	<limits.h>.
	(__llroundl) [FE_INVALID]: Force FE_INVALID exception when result
	overflows but exception would not result from cast.
	* sysdeps/ieee754/ldbl-96/s_lroundl.c: Include <fenv.h> and
	<limits.h>.
	(__lroundl) [FE_INVALID]: Force FE_INVALID exception when result
	overflows but exception would not result from cast.
	* math/libm-test.inc (lround_test_data): Add more tests.
	(llround_test_data): Likewise.
2015-10-07 23:45:29 +00:00
..
Makefile
e_acoshl.c Use <> for math.h and math_private.h everywhere. 2012-03-09 16:09:10 -08:00
e_acosl.c Fix ldbl-128/ldbl-128ibm acosl inaccuracy (bug 18038, bug 18039). 2015-02-26 21:06:34 +00:00
e_asinl.c Refactor code forcing underflow exceptions. 2015-09-23 22:42:30 +00:00
e_atan2l.c Use <> for math.h and math_private.h everywhere. 2012-03-09 16:09:10 -08:00
e_atanhl.c Refactor code forcing underflow exceptions. 2015-09-23 22:42:30 +00:00
e_coshl.c Fix cosh spurious underflows from expm1 (bug 16354), inaccurate results near 0 (bug 17061). 2014-06-23 20:20:10 +00:00
e_exp10l.c This patch renames all uses of __isinf*, __isnan*, __finite* and __signbit* to use standard C99 macros. This has no effect on generated code. 2015-06-03 15:41:36 +01:00
e_expl.c Refactor code forcing underflow exceptions. 2015-09-23 22:42:30 +00:00
e_fmodl.c Use <> for math.h and math_private.h everywhere. 2012-03-09 16:09:10 -08:00
e_gammal_r.c Refactor code forcing underflow exceptions. 2015-09-23 22:42:30 +00:00
e_hypotl.c Fix hypot missing underflows (bug 18803). 2015-09-24 23:43:57 +00:00
e_ilogbl.c Finish ilogb changes 2012-04-18 14:31:43 +02:00
e_j0l.c This patch renames all uses of __isinf*, __isnan*, __finite* and __signbit* to use standard C99 macros. This has no effect on generated code. 2015-06-03 15:41:36 +01:00
e_j1l.c Refactor code forcing underflow exceptions. 2015-09-23 22:42:30 +00:00
e_jnl.c Refactor code forcing underflow exceptions. 2015-09-23 22:42:30 +00:00
e_lgammal_r.c Fix ldbl-128 / ldbl-128ibm lgamma overflow handling (bug 16347, bug 19046). 2015-10-01 17:15:54 +00:00
e_log2l.c Fix log2 (1) in round-downward mode (bug 17042). 2014-06-10 12:07:15 +00:00
e_log10l.c Fix log10 (1) in round-downward mode (bug 16977). 2014-05-23 12:07:50 +00:00
e_logl.c Fix log (1) in round-downward mode (bug 16731). 2014-03-21 18:13:58 +00:00
e_powl.c Fix pow missing underflows (bug 18825). 2015-09-25 22:29:10 +00:00
e_rem_pio2l.c Update copyright dates with scripts/update-copyrights. 2015-01-02 16:29:47 +00:00
e_remainderl.c Use <> for math.h and math_private.h everywhere. 2012-03-09 16:09:10 -08:00
e_sinhl.c Refactor code forcing underflow exceptions. 2015-09-23 22:42:30 +00:00
gamma_productl.c Update copyright dates with scripts/update-copyrights. 2015-01-02 16:29:47 +00:00
ieee754.h Update copyright dates with scripts/update-copyrights. 2015-01-02 16:29:47 +00:00
k_cosl.c Update copyright dates with scripts/update-copyrights. 2015-01-02 16:29:47 +00:00
k_sincosl.c Refactor code forcing underflow exceptions. 2015-09-23 22:42:30 +00:00
k_sinl.c Refactor code forcing underflow exceptions. 2015-09-23 22:42:30 +00:00
k_tanl.c Refactor code forcing underflow exceptions. 2015-09-23 22:42:30 +00:00
ldbl2mpn.c Update copyright dates with scripts/update-copyrights. 2015-01-02 16:29:47 +00:00
lgamma_negl.c Fix lgamma (negative) inaccuracy (bug 2542, bug 2543, bug 2558). 2015-09-10 22:27:58 +00:00
lgamma_productl.c Fix lgamma (negative) inaccuracy (bug 2542, bug 2543, bug 2558). 2015-09-10 22:27:58 +00:00
math_ldbl.h
mpn2ldbl.c Update copyright dates with scripts/update-copyrights. 2015-01-02 16:29:47 +00:00
printf_fphex.c Update copyright dates with scripts/update-copyrights. 2015-01-02 16:29:47 +00:00
s_asinhl.c Refactor code forcing underflow exceptions. 2015-09-23 22:42:30 +00:00
s_atanl.c Refactor code forcing underflow exceptions. 2015-09-23 22:42:30 +00:00
s_cbrtl.c This patch renames all uses of __isinf*, __isnan*, __finite* and __signbit* to use standard C99 macros. This has no effect on generated code. 2015-06-03 15:41:36 +01:00
s_ceill.c Use <> for math.h and math_private.h everywhere. 2012-03-09 16:09:10 -08:00
s_copysignl.c Use <> for math.h and math_private.h everywhere. 2012-03-09 16:09:10 -08:00
s_cosl.c Use <> for math.h and math_private.h everywhere. 2012-03-09 16:09:10 -08:00
s_erfl.c Refactor code forcing underflow exceptions. 2015-09-23 22:42:30 +00:00
s_expm1l.c Refactor code forcing underflow exceptions. 2015-09-23 22:42:30 +00:00
s_fabsl.c Use <> for math.h and math_private.h everywhere. 2012-03-09 16:09:10 -08:00
s_finitel.c Reduce number of constants in __finite* (bug 15384). 2015-09-17 16:47:14 +00:00
s_floorl.c Use <> for math.h and math_private.h everywhere. 2012-03-09 16:09:10 -08:00
s_fma.c Update copyright dates with scripts/update-copyrights. 2015-01-02 16:29:47 +00:00
s_fmal.c Refactor code forcing underflow exceptions. 2015-09-23 22:42:30 +00:00
s_fpclassifyl.c Update copyright dates with scripts/update-copyrights. 2015-01-02 16:29:47 +00:00
s_frexpl.c Use <> for math.h and math_private.h everywhere. 2012-03-09 16:09:10 -08:00
s_isinfl.c Use <> for math.h and math_private.h everywhere. 2012-03-09 16:09:10 -08:00
s_isnanl.c Use <> for math.h and math_private.h everywhere. 2012-03-09 16:09:10 -08:00
s_issignalingl.c Update copyright dates with scripts/update-copyrights. 2015-01-02 16:29:47 +00:00
s_llrintl.c Use math_narrow_eval more consistently. 2015-09-23 18:14:57 +00:00
s_llroundl.c Fix lround, llround missing exceptions close to overflow threshold (bug 19088). 2015-10-07 23:45:29 +00:00
s_log1pl.c Refactor code forcing underflow exceptions. 2015-09-23 22:42:30 +00:00
s_logbl.c Optimize handling of denormals in logb/logbf/logbl 2012-05-26 13:53:22 +02:00
s_lrintl.c Fix ldbl-128 lrintl, lroundl missing exceptions for 32-bit long (bug 19085). 2015-10-07 16:10:59 +00:00
s_lroundl.c Fix lround, llround missing exceptions close to overflow threshold (bug 19088). 2015-10-07 23:45:29 +00:00
s_modfl.c Use <> for math.h and math_private.h everywhere. 2012-03-09 16:09:10 -08:00
s_nearbyintl.c Fix nearbyint scheduling of arithmetic past fesetenv (bug 15490). 2013-05-19 18:40:25 +00:00
s_nextafterl.c Fix nextafter overflow in non-default rounding modes (bug 16677). 2014-03-11 22:24:00 +00:00
s_nexttoward.c Fix nexttoward overflow in non-default rounding modes (bug 19059). 2015-10-02 17:11:13 +00:00
s_nexttowardf.c Fix nexttoward overflow in non-default rounding modes (bug 19059). 2015-10-02 17:11:13 +00:00
s_remquol.c Fix sign of remquo zero remainder in round-downward mode (bug 17987). 2015-02-17 00:41:50 +00:00
s_rintl.c Fix set-but-not-used warnings in ldbl-128 nearbyintl, rintl. 2012-11-20 14:26:07 +00:00
s_roundl.c Fix ldbl-128 roundl for exponents in [31, 47] (bug 18346). 2015-04-28 17:27:02 +00:00
s_scalblnl.c [BZ #6803] Set errno for scalbln, scalbn 2014-06-20 07:48:20 +05:30
s_scalbnl.c Make scalbn set errno (bug 6803). 2015-09-16 21:11:00 +00:00
s_signbitl.c Use the GCC builtin functions for the non-inlined signbit implementations. 2015-09-18 16:39:08 +01:00
s_sincosl.c Since we now inline isinf, isnan and isfinite in math.h, replace uses of __isinf_ns(l/f) 2015-09-18 20:51:52 +01:00
s_sinl.c Use <> for math.h and math_private.h everywhere. 2012-03-09 16:09:10 -08:00
s_tanhl.c Refactor code forcing underflow exceptions. 2015-09-23 22:42:30 +00:00
s_tanl.c Remove trailing whitespace. 2013-06-05 20:44:03 +00:00
s_truncl.c Update copyright dates with scripts/update-copyrights. 2015-01-02 16:29:47 +00:00
strtold_l.c Update copyright dates with scripts/update-copyrights. 2015-01-02 16:29:47 +00:00
t_expl.h Update copyright dates with scripts/update-copyrights. 2015-01-02 16:29:47 +00:00
t_sincosl.c Update copyright dates with scripts/update-copyrights. 2015-01-02 16:29:47 +00:00
w_expl.c This patch renames all uses of __isinf*, __isnan*, __finite* and __signbit* to use standard C99 macros. This has no effect on generated code. 2015-06-03 15:41:36 +01:00
x2y2m1l.c Fix clog, clog10 inaccuracy (bug 19016). 2015-09-28 22:11:22 +00:00