glibc/math
Joseph Myers be25493251 Fix yn overflow handling in non-default rounding modes (bug 16561, bug 16562).
This patch fixes bugs 16561 and 16562, bad results of yn in overflow
cases in non-default rounding modes, both because an intermediate
overflow in the recurrence does not get detected if the result is not
an infinity and because an overflowing result may occur in the wrong
sign.  The fix is to set FE_TONEAREST mode internally for the parts of
the function where such overflows can occur (which includes the call
to y1 - where yn is used to compute a Bessel function of order -1,
negating the result of y1 isn't correct for overflowing results in
directed rounding modes) and then compute an overflowing value in the
original rounding mode if the to-nearest result was an infinity.

Tested x86_64 and x86 and ulps updated accordingly.  Also tested for
mips64 and powerpc32 to test the ldbl-128 and ldbl-128ibm changes.

(The tests for these bugs were added in my previous y1 patch, so the
only thing this patch has to do with the testsuite is enable yn
testing in all rounding modes.)

	[BZ #16561]
	[BZ #16562]
	* sysdeps/ieee754/dbl-64/e_jn.c: Include <float.h>.
	(__ieee754_yn): Set FE_TONEAREST mode internally and then
	recompute overflowing results in original rounding mode.
	* sysdeps/ieee754/flt-32/e_jnf.c: Include <float.h>.
	(__ieee754_ynf): Set FE_TONEAREST mode internally and then
	recompute overflowing results in original rounding mode.
	* sysdeps/ieee754/ldbl-128/e_jnl.c: Include <float.h>.
	(__ieee754_ynl): Set FE_TONEAREST mode internally and then
	recompute overflowing results in original rounding mode.
	* sysdeps/ieee754/ldbl-128ibm/e_jnl.c: Include <float.h>.
	(__ieee754_ynl): Set FE_TONEAREST mode internally and then
	recompute overflowing results in original rounding mode.
	* sysdeps/ieee754/ldbl-96/e_jnl.c: Include <float.h>.
	(__ieee754_ynl): Set FE_TONEAREST mode internally and then
	recompute overflowing results in original rounding mode.
	* sysdeps/i386/fpu/fenv_private.h [!__SSE2_MATH__]
	(libc_feholdsetround_ctx): New macro.
	* math/libm-test.inc (yn_test): Use ALL_RM_TEST.
	* sysdeps/i386/fpu/libm-test-ulps: Update.
	* sysdeps/x86_64/fpu/libm-test-ulps : Likewise.
2014-06-27 14:52:13 +00:00
..
bits Complete _BSD_SOURCE / _SVID_source followup cleanup. 2014-02-21 21:45:26 +00:00
machine
atest-exp2.c
atest-exp.c
atest-sincos.c
auto-libm-test-in Fix exp10 spurious underflows (bug 16560). 2014-06-25 11:33:22 +00:00
auto-libm-test-out Fix exp10 spurious underflows (bug 16560). 2014-06-25 11:33:22 +00:00
basic-test.c
bug-nextafter.c
bug-nexttoward.c
bug-tgmath1.c
cabs.c
cabsf.c
cabsl.c
carg.c
cargf.c
cargl.c
cimag.c
cimagf.c
cimagl.c
complex.h
conj.c
conjf.c
conjl.c
creal.c
crealf.c
creall.c
divtc3.c
e_acoshl.c
e_acosl.c
e_asinl.c
e_atan2l.c
e_atanhl.c
e_coshl.c
e_exp2l.c Use glibc_likely instead __builtin_expect. 2014-02-10 15:07:12 +01:00
e_exp10.c
e_exp10f.c
e_exp10l.c
e_expl.c
e_fmodl.c
e_gammal_r.c
e_hypotl.c
e_j0l.c
e_j1l.c
e_jnl.c
e_lgammal_r.c
e_log2l.c
e_log10l.c
e_logl.c
e_powl.c
e_rem_pio2l.c
e_scalb.c Fix scalb spurious "invalid" exceptions (bug 16770). 2014-03-29 17:22:14 +00:00
e_scalbf.c Fix scalb spurious "invalid" exceptions (bug 16770). 2014-03-29 17:22:14 +00:00
e_scalbl.c Fix scalb spurious "invalid" exceptions (bug 16770). 2014-03-29 17:22:14 +00:00
e_sinhl.c
e_sqrtl.c
fclrexcpt.c
fedisblxcpt.c
feenablxcpt.c
fegetenv.c
fegetexcept.c
fegetround.c
feholdexcpt.c
fenv.h
fesetenv.c
fesetround.c
feupdateenv.c
fgetexcptflg.c
fpu_control.c
fraiseexcpt.c
fsetexcptflg.c
ftestexcept.c
gen-auto-libm-tests.c Test cpow in all rounding modes. 2014-06-23 20:15:14 +00:00
gen-libm-test.pl Test cpow in all rounding modes. 2014-06-23 20:15:14 +00:00
ieee-math.c
k_casinh.c
k_casinhf.c
k_casinhl.c
k_cosl.c
k_rem_pio2l.c
k_sincosl.c
k_sinl.c
k_tanl.c
libm-test.inc Fix yn overflow handling in non-default rounding modes (bug 16561, bug 16562). 2014-06-27 14:52:13 +00:00
Makefile [BZ #6803] Set errno for scalbln, scalbn 2014-06-20 07:48:20 +05:30
math.h Complete _BSD_SOURCE / _SVID_source followup cleanup. 2014-02-21 21:45:26 +00:00
multc3.c
README.libm-test Don't include individual test ulps in libm-test-ulps. 2014-03-05 15:02:38 +00:00
s_asinhl.c
s_atanl.c
s_cacos.c Fix cacos (+Inf + finite*i) in round-downward mode (bug 16928). 2014-05-14 12:37:24 +00:00
s_cacosf.c Fix cacos (+Inf + finite*i) in round-downward mode (bug 16928). 2014-05-14 12:37:24 +00:00
s_cacosh.c
s_cacoshf.c
s_cacoshl.c
s_cacosl.c Fix cacos (+Inf + finite*i) in round-downward mode (bug 16928). 2014-05-14 12:37:24 +00:00
s_casin.c
s_casinf.c
s_casinh.c
s_casinhf.c
s_casinhl.c
s_casinl.c
s_catan.c Fix catan, catanh, __ieee754_logf in round-downward mode (bug 16799, bug 16800). 2014-04-02 17:41:02 +00:00
s_catanf.c Fix catan, catanh, __ieee754_logf in round-downward mode (bug 16799, bug 16800). 2014-04-02 17:41:02 +00:00
s_catanh.c Fix catan, catanh, __ieee754_logf in round-downward mode (bug 16799, bug 16800). 2014-04-02 17:41:02 +00:00
s_catanhf.c Fix catan, catanh, __ieee754_logf in round-downward mode (bug 16799, bug 16800). 2014-04-02 17:41:02 +00:00
s_catanhl.c Fix catan, catanh, __ieee754_logf in round-downward mode (bug 16799, bug 16800). 2014-04-02 17:41:02 +00:00
s_catanl.c Fix catan, catanh, __ieee754_logf in round-downward mode (bug 16799, bug 16800). 2014-04-02 17:41:02 +00:00
s_cbrtl.c
s_ccos.c
s_ccosf.c
s_ccosh.c Use glibc_likely instead __builtin_expect. 2014-02-10 15:07:12 +01:00
s_ccoshf.c Use glibc_likely instead __builtin_expect. 2014-02-10 15:07:12 +01:00
s_ccoshl.c Use glibc_likely instead __builtin_expect. 2014-02-10 15:07:12 +01:00
s_ccosl.c
s_cexp.c Use glibc_likely instead __builtin_expect. 2014-02-10 15:07:12 +01:00
s_cexpf.c Use glibc_likely instead __builtin_expect. 2014-02-10 15:07:12 +01:00
s_cexpl.c Use glibc_likely instead __builtin_expect. 2014-02-10 15:07:12 +01:00
s_clog10.c Fix clog / clog10 sign of zero result in round-downward mode (bug 16789). 2014-04-02 13:10:19 +00:00
s_clog10f.c Fix clog / clog10 sign of zero result in round-downward mode (bug 16789). 2014-04-02 13:10:19 +00:00
s_clog10l.c Fix clog / clog10 sign of zero result in round-downward mode (bug 16789). 2014-04-02 13:10:19 +00:00
s_clog.c Fix clog / clog10 sign of zero result in round-downward mode (bug 16789). 2014-04-02 13:10:19 +00:00
s_clogf.c Fix clog / clog10 sign of zero result in round-downward mode (bug 16789). 2014-04-02 13:10:19 +00:00
s_clogl.c Fix clog / clog10 sign of zero result in round-downward mode (bug 16789). 2014-04-02 13:10:19 +00:00
s_cpow.c
s_cpowf.c
s_cpowl.c
s_cproj.c
s_cprojf.c
s_cprojl.c
s_csin.c Use glibc_likely instead __builtin_expect. 2014-02-10 15:07:12 +01:00
s_csinf.c Use glibc_likely instead __builtin_expect. 2014-02-10 15:07:12 +01:00
s_csinh.c Use glibc_likely instead __builtin_expect. 2014-02-10 15:07:12 +01:00
s_csinhf.c Use glibc_likely instead __builtin_expect. 2014-02-10 15:07:12 +01:00
s_csinhl.c Use glibc_likely instead __builtin_expect. 2014-02-10 15:07:12 +01:00
s_csinl.c Use glibc_likely instead __builtin_expect. 2014-02-10 15:07:12 +01:00
s_csqrt.c Use glibc_likely instead __builtin_expect. 2014-02-10 15:07:12 +01:00
s_csqrtf.c Use glibc_likely instead __builtin_expect. 2014-02-10 15:07:12 +01:00
s_csqrtl.c Use glibc_likely instead __builtin_expect. 2014-02-10 15:07:12 +01:00
s_ctan.c Use glibc_likely instead __builtin_expect. 2014-02-10 15:07:12 +01:00
s_ctanf.c Use glibc_likely instead __builtin_expect. 2014-02-10 15:07:12 +01:00
s_ctanh.c Use glibc_likely instead __builtin_expect. 2014-02-10 15:07:12 +01:00
s_ctanhf.c Use glibc_likely instead __builtin_expect. 2014-02-10 15:07:12 +01:00
s_ctanhl.c Use glibc_likely instead __builtin_expect. 2014-02-10 15:07:12 +01:00
s_ctanl.c Use glibc_likely instead __builtin_expect. 2014-02-10 15:07:12 +01:00
s_erfl.c
s_expm1l.c
s_fdim.c
s_fdimf.c
s_fdiml.c
s_fma.c
s_fmaf.c
s_fmal.c
s_fmax.c
s_fmaxf.c
s_fmaxl.c
s_fmin.c
s_fminf.c
s_fminl.c
s_ldexp.c
s_ldexpf.c
s_ldexpl.c
s_log1pl.c
s_nan.c
s_nanf.c
s_nanl.c
s_nextafter.c Fix nextafter overflow in non-default rounding modes (bug 16677). 2014-03-11 22:24:00 +00:00
s_nexttowardf.c
s_nexttowardl.c
s_significand.c
s_significandf.c
s_significandl.c
s_tanhl.c
setfpucw.c
t_sincosl.c
test-double.c
test-fenv-preserve.c math: make test-fenv-preserve.c a no-op if FE_ALL_EXCEPT == 0. 2014-04-11 15:13:42 -04:00
test-fenv-return.c Add FE_NOMASK_ENV return value test. 2014-06-10 15:50:25 +01:00
test-fenv-tls.c
test-fenv.c Add fenv test support for targets which don't have FP traps. 2014-04-17 09:39:27 +01:00
test-float.c
test-fpucw-ieee-static.c
test-fpucw-ieee.c Fix math/test-fpucw-*.c for sysdeps test-fpucw.c overrides. 2014-01-16 05:30:52 +00:00
test-fpucw-static.c Fix math/test-fpucw-*.c for sysdeps test-fpucw.c overrides. 2014-01-16 05:30:52 +00:00
test-fpucw.c
test-idouble.c
test-ifloat.c
test-ildoubl.c
test-ldouble.c
test-matherr.c Remove _BSD_SOURCE and _SVID_SOURCE. 2014-02-11 23:40:07 +00:00
test-misc.c
test-powl.c
test-snan.c
test-tgmath2.c
test-tgmath-int.c
test-tgmath-ret.c
test-tgmath.c
tgmath.h
tst-CMPLX2.c
tst-CMPLX.c
tst-definitions.c
Versions
w_acos.c
w_acosf.c
w_acosh.c
w_acoshf.c
w_acoshl.c
w_acosl.c
w_asin.c
w_asinf.c
w_asinl.c
w_atan2.c Set errno for atan2 underflow (bug 16349). 2014-03-31 14:56:37 +00:00
w_atan2f.c Set errno for atan2 underflow (bug 16349). 2014-03-31 14:56:37 +00:00
w_atan2l.c Set errno for atan2 underflow (bug 16349). 2014-03-31 14:56:37 +00:00
w_atanh.c
w_atanhf.c
w_atanhl.c
w_cosh.c
w_coshf.c
w_coshl.c
w_drem.c
w_dremf.c
w_dreml.c
w_exp2.c
w_exp2f.c
w_exp2l.c
w_exp10.c
w_exp10f.c
w_exp10l.c
w_expl.c
w_fmod.c
w_fmodf.c
w_fmodl.c
w_hypot.c
w_hypotf.c
w_hypotl.c
w_ilogb.c
w_ilogbf.c
w_ilogbl.c
w_j0.c
w_j0f.c
w_j0l.c
w_j1.c
w_j1f.c
w_j1l.c
w_jn.c
w_jnf.c
w_jnl.c
w_lgamma_r.c
w_lgamma.c
w_lgammaf_r.c
w_lgammaf.c
w_lgammal_r.c
w_lgammal.c
w_log2.c
w_log2f.c
w_log2l.c
w_log10.c
w_log10f.c
w_log10l.c
w_log.c
w_logf.c
w_logl.c
w_pow.c Use glibc_likely instead __builtin_expect. 2014-02-10 15:07:12 +01:00
w_powf.c Use glibc_likely instead __builtin_expect. 2014-02-10 15:07:12 +01:00
w_powl.c Use glibc_likely instead __builtin_expect. 2014-02-10 15:07:12 +01:00
w_remainder.c
w_remainderf.c
w_remainderl.c
w_scalb.c Set errno for scalb errors (bug 6803, bug 6804). 2014-03-31 14:57:53 +00:00
w_scalbf.c Set errno for scalb errors (bug 6803, bug 6804). 2014-03-31 14:57:53 +00:00
w_scalbl.c Set errno for scalb errors (bug 6803, bug 6804). 2014-03-31 14:57:53 +00:00
w_scalbln.c [BZ #6803] Set errno for scalbln, scalbn 2014-06-20 07:48:20 +05:30
w_scalblnf.c [BZ #6803] Set errno for scalbln, scalbn 2014-06-20 07:48:20 +05:30
w_scalblnl.c [BZ #6803] Set errno for scalbln, scalbn 2014-06-20 07:48:20 +05:30
w_sinh.c
w_sinhf.c
w_sinhl.c
w_sqrt.c
w_sqrtf.c
w_sqrtl.c
w_tgamma.c
w_tgammaf.c
w_tgammal.c

README for libm-test math test suite
====================================

The libm-test math test suite tests a number of function points of
math functions in the GNU C library.  The following sections contain a
brief overview.  Please note that the test drivers and the Perl script
"gen-libm-test.pl" have some options.  A full list of options is
available with --help (for the test drivers) and -h for
"gen-libm-test.pl".


What is tested?
===============
The tests just evaluate the functions at specified points and compare
the results with precomputed values and the requirements of the ISO
C99 standard.

Besides testing the special values mandated by IEEE 754 (infinities,
NaNs and minus zero), some more or less random values are tested.

Files that are part of libm-test
================================

The main file is "libm-test.inc".  It is platform and floating point
format independent.  The file must be preprocessed by the Perl script
"gen-libm-test.pl".  The results are "libm-test.c" and a file
"libm-test-ulps.h" with platform specific deltas.

The test drivers test-double.c, test-float.c, test-ldouble.c test the
normal double, float and long double implementation of libm.  The test
drivers with an i in it (test-idouble.c, test-ifloat.c,
test-ildoubl.c) test the corresponding inline functions (where
available - otherwise they also test the real functions in libm).

"gen-libm-test.pl" needs a platform specific files with ULPs (Units of
Last Precision).  The file is called "libm-test-ulps" and lives in
platform specific sysdep directory.

How can I generate "libm-test-ulps"?
====================================

To automatically generate a new "libm-test-ulps" run "make regen-ulps".
This generates the file "math/NewUlps" in the build directory.  The file
contains the sorted results of all the tests.  You can use the "NewUlps"
file as the machine's updated "libm-test-ulps" file.  Copy "NewUlps" to
"libm-test-ulps" in the appropriate machine sysdep directory.  Verify
the changes, post your patch, and check it in after review.

To manually generate a new "libm-test-ulps" file, first remove "ULPs"
file in the current directory, then you can execute for example:
    ./testrun.sh math/test-double -u --ignore-max-ulp=yes
This generates a file "ULPs" with all double ULPs in it, ignoring any
previously calculated ULPs, and running with the newly built dynamic
loader and math library (assumes you didn't install your build).  Now
generate the ULPs for all other formats, the tests will be appending the
data to the "ULPs" file.  As final step run "gen-libm-test.pl" with the
file as input and ask to generate a pretty printed output in the file
"NewUlps":
  gen-libm-test.pl -u ULPs -n
Copy "NewUlps" to "libm-test-ulps" in the appropriate machine sysdep
directory.

Note that the test drivers have an option "-u" to output an unsorted
list of all epsilons that the functions have.  The output can be read
in directly but it's better to pretty print it first.
"gen-libm-test.pl" has an option to generate a pretty-printed and
sorted new ULPs file from the output of the test drivers.

Contents of libm-test-ulps
==========================

Since libm-test-ulps can be generated automatically, just a few notes.
The file contains lines for maximal errors of single functions, like:

Function "yn":
idouble: 6

The keywords are float, ifloat, double, idouble, ldouble and ildouble
(the prefix i stands for inline).

Adding tests to libm-test.inc
=============================

The tests are evaluated by a set of special test macros.  The macros
start with "TEST_" followed by a specification the input values, an
underscore and a specification of the output values.  As an example,
the test macro for a function with input of type FLOAT (FLOAT is
either float, double, long double) and output of type FLOAT is
"TEST_f_f".  The macro's parameter are the name of the function, the
input parameter, output parameter and optionally one exception
parameter.

The accepted parameter types are:
- "f" for FLOAT
- "b" for boolean - just tests if the output parameter evaluates to 0
  or 1 (only for output).
- "c" for complex.  This parameter needs two values, first the real,
  then the imaginary part.
- "i" for int.
- "l" for long int.
- "L" for long long int.
- "F" for the address of a FLOAT (only as input parameter)
- "I" for the address of an int (only as input parameter)