Commit Graph

1009 Commits

Author SHA1 Message Date
Rajalakshmi Srinivasaraghavan 754c5a08aa PowerPC: Fix nearbyintl failure for few inputs
This patch fixes few failures in nearbyintl() where the fraction part is
close to 0.5.i  The new tests added report few extra failures in
nearbyint_downward and nearbyint_towardzero which is a known issue.

Fixes #17031.
2014-06-17 08:46:25 -05:00
Wilco 0570cfed7f Add FE_NOMASK_ENV return value test. 2014-06-10 15:50:25 +01:00
Joseph Myers f8ba1b5654 Fix log2 (1) in round-downward mode (bug 17042).
As with other issues of this kind, bug 17042 is log2 (1) wrongly
returning -0 instead of +0 in round-downward mode because of
implementations effectively in terms of log1p (x - 1).  This patch
fixes the issue in the same way used for log and log10.

Tested x86_64 and x86 and ulps updated accordingly.  Also tested for
mips64 to confirm a fix was needed for ldbl-128 and to validate that
fix (also applied to ldbl-128ibm since that version of log2l is
essentially the same as the ldbl-128 one).

	[BZ #17042]
	* sysdeps/i386/fpu/e_log2.S (__ieee754_log2): Take absolete value
	when x - 1 is zero.
	* sysdeps/i386/fpu/e_log2f.S (__ieee754_log2f): Likewise.
	* sysdeps/i386/fpu/e_log2l.S (__ieee754_log2l): Likewise.
	* sysdeps/ieee754/ldbl-128/e_log2l.c (__ieee754_log2l): Return
	0.0L for an argument of 1.0L.
	* sysdeps/ieee754/ldbl-128ibm/e_log2l.c (__ieee754_log2l):
	Likewise.
	* sysdeps/x86_64/fpu/e_log2l.S (__ieee754_log2l): Take absolute
	value when x - 1 is zero.
	* math/libm-test.inc (log2_test): Use ALL_RM_TEST.
	* sysdeps/i386/fpu/libm-test-ulps: Update.
	* sysdeps/x86_64/fpu/libm-test-ulps: Likewise.
2014-06-10 12:07:15 +00:00
Joseph Myers 8540f6d2a7 Don't require test wrappers to preserve environment variables, use more consistent environment.
One wart in the original support for test wrappers for cross testing,
as noted in
<https://sourceware.org/ml/libc-alpha/2012-10/msg00722.html>, is the
requirement for test wrappers to pass a poorly-defined set of
environment variables from the build system to the system running the
glibc under test.  Although some variables are passed explicitly via
$(test-wrapper-env), including LD_* variables that simply can't be
passed implicitly because of the side effects they'd have on the build
system's dynamic linker, others are passed implicitly, including
variables such as GCONV_PATH and LOCPATH that could potentially affect
the build system's libc (so effectively relying on any such effects
not breaking the wrappers).  In addition, the code in
cross-test-ssh.sh for preserving environment variables is fragile (it
depends on how bash formats a list of exported variables, and could
well break for multi-line variable definitions where the contents
contain things looking like other variable definitions).

This patch moves to explicitly passing environment variables via
$(test-wrapper-env).  Makefile variables that previously used
$(test-wrapper) are split up into -before-env and -after-env parts
that can be passed separately to the various .sh files used in
testing, so those files can then insert environment settings between
the two parts.

The common default environment settings in make-test-out are made into
a separate makefile variable that can also be passed to scripts,
rather than many scripts duplicating those settings (for testing an
installed glibc, it is desirable to have the GCONV_PATH setting on
just one place, so just that one place needs to support it pointing to
an installed sysroot instead of the build tree).  The default settings
are included in the variables such as $(test-program-prefix), so that
if tests do not need any non-default settings they can continue to use
single variables rather than the split-up variables.

Although this patch cleans up LC_ALL=C settings (that being part of
the common defaults), various LANG=C and LANGUAGE=C settings remain.
Those are generally unnecessary and I propose a subsequent cleanup to
remove them.  LC_ALL takes precedence over LANG, and while LANGUAGE
takes precedence over LC_ALL, it only does so for settings other than
LC_ALL=C.  So LC_ALL=C on its own is sufficient to ensure the C
locale, and anything that gets LC_ALL=C does not need the other
settings.

While preparing this patch I noticed some tests with .sh files that
appeared to do nothing beyond what the generic makefile support for
tests can do (localedata/tst-wctype.sh - the makefiles support -ENV
variables and .input files - and localedata/tst-mbswcs.sh - just runs
five tests that could be run individually from the makefile).  So I
propose another subsequent cleanup to move those to using the generic
support instead of special .sh files.

Tested x86_64 (native) and powerpc32 (cross).

	* Makeconfig (run-program-env): New variable.
	(run-program-prefix-before-env): Likewise.
	(run-program-prefix-after-env): Likewise.
	(run-program-prefix): Define in terms of new variables.
	(built-program-cmd-before-env): New variable.
	(built-program-cmd-after-env): Likewise.
	(built-program-cmd): Define in terms of new variables.
	(test-program-prefix-before-env): New variable.
	(test-program-prefix-after-env): Likewise.
	(test-program-prefix): Define in terms of new variables.
	(test-program-cmd-before-env): New variable.
	(test-program-cmd-after-env): Likewise.
	(test-program-cmd): Define in terms of new variables.
	* Rules (make-test-out): Use $(run-program-env).
	* scripts/cross-test-ssh.sh (env_blacklist): Remove variable.
	(help): Do not mention environment variables.  Mention
	--timeoutfactor option.
	(timeoutfactor): New variable.
	(blacklist_exports): Remove function.
	(exports): Remove variable.
	(command): Do not include ${exports}.
	* manual/install.texi (Configuring and compiling): Do not mention
	test wrappers preserving environment variables.  Mention that last
	assignment to a variable must take precedence.
	* INSTALL: Regenerated.
	* benchtests/Makefile (run-bench): Use $(run-program-env).
	* catgets/Makefile ($(objpfx)test1.cat): Use
	$(built-program-cmd-before-env), $(run-program-env) and
	$(built-program-cmd-after-env).
	($(objpfx)test2.cat): Do not specify environment variables
	explicitly.
	($(objpfx)de/libc.cat): Use $(built-program-cmd-before-env),
	$(run-program-env) and $(built-program-cmd-after-env).
	($(objpfx)test-gencat.out): Use $(test-program-cmd-before-env),
	$(run-program-env) and $(test-program-cmd-after-env).
	($(objpfx)sample.SJIS.cat): Do not specify environment variables
	explicitly.
	* catgets/test-gencat.sh: Use test_program_cmd_before_env,
	run_program_env and test_program_cmd_after_env arguments.
	* elf/Makefile ($(objpfx)tst-pathopt.out): Use $(run-program-env).
	* elf/tst-pathopt.sh: Use run_program_env argument.
	* iconvdata/Makefile ($(objpfx)iconv-test.out): Use
	$(test-wrapper-env) and $(run-program-env).
	* iconvdata/run-iconv-test.sh: Use test_wrapper_env and
	run_program_env arguments.
	* iconvdata/tst-table.sh: Do not set GCONV_PATH explicitly.
	* intl/Makefile ($(objpfx)tst-gettext.out): Use
	$(test-program-prefix-before-env), $(run-program-env) and
	$(test-program-prefix-after-env).
	($(objpfx)tst-gettext2.out): Likewise.
	* intl/tst-gettext.sh: Use test_program_prefix_before_env,
	run_program_env and test_program_prefix_after_env arguments.
	* intl/tst-gettext2.sh: Likewise.
	* intl/tst-gettext4.sh: Do not set environment variables
	explicitly.
	* intl/tst-gettext6.sh: Likewise.
	* intl/tst-translit.sh: Likewise.
	* malloc/Makefile ($(objpfx)tst-mtrace.out): Use
	$(test-program-prefix-before-env), $(run-program-env) and
	$(test-program-prefix-after-env).
	* malloc/tst-mtrace.sh: Use test_program_prefix_before_env,
	run_program_env and test_program_prefix_after_env arguments.
	* math/Makefile (run-regen-ulps): Use $(run-program-env).
	* nptl/Makefile ($(objpfx)tst-tls6.out): Use $(run-program-env).
	* nptl/tst-tls6.sh: Use run_program_env argument.  Set LANG=C
	explicitly with each use of ${test_wrapper_env}.
	* posix/Makefile ($(objpfx)wordexp-tst.out): Use
	$(test-program-prefix-before-env), $(run-program-env) and
	$(test-program-prefix-after-env).
	* posix/tst-getconf.sh: Do not set environment variables
	explicitly.
	* posix/wordexp-tst.sh: Use test_program_prefix_before_env,
	run_program_env and test_program_prefix_after_env arguments.
	* stdio-common/tst-printf.sh: Do not set environment variables
	explicitly.
	* stdlib/Makefile ($(objpfx)tst-fmtmsg.out): Use
	$(test-program-prefix-before-env), $(run-program-env) and
	$(test-program-prefix-after-env).
	* stdlib/tst-fmtmsg.sh: Use test_program_prefix_before_env,
	run_program_env and test_program_prefix_after_env arguments.
	Split $test calls into $test_pre and $test.
	* timezone/Makefile (build-testdata): Use
	$(built-program-cmd-before-env), $(run-program-env) and
	$(built-program-cmd-after-env).

localedata/ChangeLog:
	* Makefile ($(addprefix $(objpfx),$(CTYPE_FILES))): Use
	$(built-program-cmd-before-env), $(run-program-env) and
	$(built-program-cmd-after-env).
	($(objpfx)sort-test.out): Use $(test-program-prefix-before-env),
	$(run-program-env) and $(test-program-prefix-after-env).
	($(objpfx)tst-fmon.out): Use $(run-program-prefix-before-env),
	$(run-program-env) and $(run-program-prefix-after-env).
	($(objpfx)tst-locale.out): Use $(built-program-cmd-before-env),
	$(run-program-env) and $(built-program-cmd-after-env).
	($(objpfx)tst-trans.out): Use $(run-program-prefix-before-env),
	$(run-program-env), $(run-program-prefix-after-env),
	$(test-program-prefix-before-env) and
	$(test-program-prefix-after-env).
	($(objpfx)tst-ctype.out): Use $(test-program-cmd-before-env),
	$(run-program-env) and $(test-program-cmd-after-env).
	($(objpfx)tst-wctype.out): Likewise.
	($(objpfx)tst-langinfo.out): Likewise.
	($(objpfx)tst-langinfo-static.out): Likewise.
	* gen-locale.sh: Use localedef_before_env, run_program_env and
	localedef_after_env arguments.
	* sort-test.sh: Use test_program_prefix_before_env,
	run_program_env and test_program_prefix_after_env arguments.
	* tst-ctype.sh: Use tst_ctype_before_env, run_program_env and
	tst_ctype_after_env arguments.
	* tst-fmon.sh: Use run_program_prefix_before_env, run_program_env
	and run_program_prefix_after_env arguments.
	* tst-langinfo.sh: Use tst_langinfo_before_env, run_program_env
	and tst_langinfo_after_env arguments.
	* tst-locale.sh: Use localedef_before_env, run_program_env and
	localedef_after_env arguments.
	* tst-mbswcs.sh: Do not set environment variables explicitly.
	* tst-numeric.sh: Likewise.
	* tst-rpmatch.sh: Likewise.
	* tst-trans.sh: Use run_program_prefix_before_env,
	run_program_env, run_program_prefix_after_env,
	test_program_prefix_before_env and test_program_prefix_after_env
	arguments.
	* tst-wctype.sh: Use tst_wctype_before_env, run_program_env and
	tst_wctype_after_env arguments.
2014-06-06 22:19:27 +00:00
Joseph Myers b72592e75f Fix log10 (1) in round-downward mode (bug 16977).
As with various other issues of this kind, bug 16977 is log10 (1)
wrongly returning -0 rather than +0 in round-downward mode because of
an implementation effectively in terms of log1p (x - 1).  This patch
fixes the issue in the same way used for log.

Tested x86_64 and x86 and ulps updated accordingly.  Also tested for
mips64 to confirm a fix was needed for ldbl-128 and to validate that
fix (also applied to ldbl-128ibm since that version of logl is
essentially the same as the ldbl-128 one).

	[BZ #16977]
	* sysdeps/i386/fpu/e_log10.S (__ieee754_log10): Take absolute
	value when x - 1 is zero.
	* sysdeps/i386/fpu/e_log10f.S (__ieee754_log10f): Likewise.
	* sysdeps/i386/fpu/e_log10l.S (__ieee754_log10l): Likewise.
	* sysdeps/ieee754/ldbl-128/e_log10l.c (__ieee754_log10l): Return
	0.0L for an argument of 1.0L.
	* sysdeps/ieee754/ldbl-128ibm/e_log10l.c (__ieee754_log10l):
	Likewise.
	* sysdeps/x86_64/fpu/e_log10l.S (__ieee754_log10l): Take absolute
	value when x - 1 is zero.
	* math/libm-test.inc (log10_test): Use ALL_RM_TEST.
	* sysdeps/i386/fpu/libm-test-ulps: Update.
	* sysdeps/x86_64/fpu/libm-test-ulps: Likewise.
2014-05-23 12:07:50 +00:00
Joseph Myers 79520f4bd6 Use existing makefile variables for dependencies on glibc libraries.
glibc's Makeconfig defines some variables such as $(libm) and $(libdl)
for linking with libraries built by glibc, and nptl/Makeconfig
(included by the toplevel Makeconfig) defines others such as
$(shared-thread-library).

In some places glibc's Makefiles use those variables when linking
against the relevant libraries, but in other places they hardcode the
location of the libraries in the build tree.  This patch cleans up
various places to use the variables that already exist (in the case of
libm, replacing several duplicate definitions of a $(link-libm)
variable in subdirectory Makefiles).  (It's not necessarily exactly
equivalent to what the existing code does - in particular,
$(shared-thread-library) includes libpthread_nonshared, but is
replacing places that just referred to libpthread.so.  But I think
that change is desirable on the general principle of linking things as
close as possible to the way in which they would be linked with an
installed library, unless there is a clear reason not to do so.)

To support running tests with an installed copy of glibc without
needing the full build tree from when that copy was built, I think it
will be useful to use such variables more generally and systematically
- every time the rules for building a test refer to some file from the
build tree that's also installed by glibc, use a makefile variable so
that the installed-testing case can point those variables to installed
copies of the files.  This patch just deals with straightforward cases
where such variables already exist.

It's quite possible some uses of $(shared-thread-library) should
actually be a new $(thread-library) variable that's set appropriately
in the --disable-shared case, if those uses would in fact work without
shared libraries.  I didn't change the status quo that those cases
hardcode use of a shared library whether or not it's actually needed
(but other uses such as $(libm) and $(libdl) would now get the static
library if the shared library isn't built, when some previously
hardcoded use of the shared library - if they actually need shared
libraries, the test itself needs an enable-shared conditional anyway).

Tested x86_64.

	* benchtests/Makefile
	($(addprefix $(objpfx)bench-,$(bench-math))): Depend on $(libm),
	not $(common-objpfx)math/libm.so.
	($(addprefix $(objpfx)bench-,$(bench-pthread))): Depend on
	$(shared-thread-library), not $(common-objpfx)nptl/libpthread.so.
	* elf/Makefile ($(objpfx)noload): Depend on $(libdl), not
	$(common-objpfx)dlfcn/libdl.so.
	($(objpfx)tst-audit8): Depend on $(libm), not
	$(common-objpfx)math/libm.so.
	* malloc/Makefile ($(objpfx)libmemusage.so): Depend on $(libdl),
	not $(common-objpfx)dlfcn/libdl.so.
	* math/Makefile
	($(addprefix $(objpfx),$(filter-out $(tests-static),$(tests)))):
	Depend on $(libm), not $(objpfx)libm.so.  Do not condition on
	[$(build-shared) = yes].
	($(objpfx)test-fenv-tls): Depend on $(shared-thread-library), not
	$(common-objpfx)nptl/libpthread.so.
	* misc/Makefile ($(objpfx)tst-tsearch): Depend on $(libm), not
	$(common-objpfx)math/libm.so$(libm.so-version) or
	$(common-objpfx)math/libm.a depending on [$(build-shared) = yes].
	* nptl/Makefile ($(objpfx)tst-unload): Depend on $(libdl), not
	$(common-objpfx)dlfcn/libdl.so.
	* setjmp/Makefile (link-libm): Remove variable.
	($(objpfx)tst-setjmp-fp): Depend on $(libm), not $(link-libm).
	* stdio-common/Makefile (link-libm): Remove variable.
	($(objpfx)tst-printf-round): Depend on $(libm), not $(link-libm).
	* stdlib/Makefile (link-libm): Remove variable.
	($(objpfx)bug-getcontext): Depend on $(libm), not $(link-libm).
	($(objpfx)tst-strtod-round): Likewise.
	($(objpfx)tst-tininess): Likewise.
	($(objpfx)tst-strtod-underflow): Likewise.
	($(objpfx)tst-strtod6): Likewise.
	($(objpfx)tst-tls-atexit): Depend on $(shared-thread-library) and
	$(libdl), not $(common-objpfx)nptl/libpthread.so and
	$(common-objpfx)dlfcn/libdl.so.
2014-05-16 21:38:08 +00:00
Joseph Myers 1a84c3d6d4 Fix log1pl (LDBL_MAX) in FE_UPWARD mode (bug 16564).
Bug 16564 is spurious overflow of log1pl (LDBL_MAX) in FE_UPWARD mode,
resulting from log1pl adding 1 to its argument (for arguments not
close to 0), which overflows in that mode.  This patch fixes this by
avoiding adding 1 to large arguments (precisely what counts as large
depends on the floating-point format).

Tested x86_64 and x86, and spot-checked log1pl tests on mips64 and
powerpc64.

	[BZ #16564]
	* sysdeps/i386/fpu/s_log1pl.S (__log1pl): Do not add 1 to positive
	arguments with exponent 65 or above.
	* sysdeps/ieee754/ldbl-128/s_log1pl.c (__log1pl): Do not add 1 to
	arguments 0x1p113L or above.
	* sysdeps/ieee754/ldbl-128ibm/s_log1pl.c (__log1pl): Do not add 1
	to arguments 0x1p107L or above.
	* sysdeps/x86_64/fpu/s_log1pl.S (__log1pl): Do not add 1 to
	positive arguments with exponent 65 or above.
	* math/auto-libm-test-in: Add more tests of log1p.
	* math/auto-libm-test-out: Regenerated.
2014-05-14 12:38:56 +00:00
Joseph Myers 01dbacd22a Fix cacos (+Inf + finite*i) in round-downward mode (bug 16928).
According to C99/C11 Annex G, cacos applied to a value with real part
+Inf and finite imaginary part should produce a result with real part
+0.  glibc wrongly produces a result with real part -0 in FE_DOWNWARD
mode.  This patch fixes this by checking for zero results in the
relevant case of non-finite arguments (where there should never be a
result with -0 real part), and converts the tests of cacos to
ALL_RM_TEST.

Tested x86_64 and x86 and ulps updated accordingly.

	[BZ #16928]
	* math/s_cacos.c (__cacos): Ensure zero real part of result from
	non-finite arguments is +0.
	* math/s_cacosf.c (__cacosf): Likewise.
	* math/s_cacosl.c (__cacosl): Likewise.
	* math/libm-test.inc (cacos_test): Use ALL_RM_TEST.
	* sysdeps/i386/fpu/libm-test-ulps: Update.
	* sysdeps/x86_64/fpu/libm-test-ulps: Likewise.
2014-05-14 12:37:24 +00:00
Joseph Myers 913d03c864 Fix acosh (1) in round-downward mode (bug 16927).
According to C99 and C11 Annex F, acosh (1) should be +0 in all
rounding modes.  However, some implementations in glibc wrongly return
-0 in round-downward mode (which is what you get if you end up
computing log1p (-0), via 1 - 1 being -0 in round-downward mode).
This patch fixes the problem implementations, by correcting the test
for an exact 1 value in the ldbl-96 implementation to allow for the
explicit high bit of the mantissa, and by inserting fabs instructions
in the i386 implementations; tests of acosh are duly converted to
ALL_RM_TEST.  I believe all the other sysdeps/ieee754 implementations
are already OK (I haven't checked the ia64 versions, but if buggy then
that will be obvious from the results of test runs after this patch is
in).

Tested x86_64 and x86 and ulps updated accordingly.

	[BZ #16927]
	* sysdeps/i386/fpu/e_acosh.S (__ieee754_acosh): Use fabs on x-1
	value.
	* sysdeps/i386/fpu/e_acoshf.S (__ieee754_acoshf): Likewise.
	* sysdeps/i386/fpu/e_acoshl.S (__ieee754_acoshl): Likewise.
	* sysdeps/ieee754/ldbl-96/e_acoshl.c (__ieee754_acoshl): Correct
	for explicit high bit of mantissa when testing for argument equal
	to 1.
	* math/libm-test.inc (acosh_test): Use ALL_RM_TEST.
	* sysdeps/i386/fpu/libm-test-ulps: Update.
	* sysdeps/x86_64/fpu/libm-test-ulps: Likewise.
2014-05-14 12:35:40 +00:00
Joseph Myers 0bf061d3e3 Fix erf underflow handling near 0 (bug 16516).
Bug 16516 reports spurious underflows from erf (for all floating-point
types), when the result is close to underflowing but does not actually
underflow.

erf (x) is about (2/sqrt(pi))*x for x close to 0, so there are
subnormal arguments for which it does not underflow.  The various
implementations do (x + efx*x) (for efx = 2/sqrt(pi) - 1), for greater
accuracy than if just using a single multiplication by an
approximation to 2/sqrt(pi) (effectively, this way there are a few
more bits in the approximation to 2/sqrt(pi)).  This can introduce
underflows when efx*x underflows even though the final result does
not, so a scaled calculation with 8*efx is done in these cases - but 8
is not a big enough scale factor to avoid all such underflows.  16 is
(any underflows with a scale factor of 16 would only occur when the
final result underflows), so this patch changes the code to use that
factor.  Rather than recomputing all the values of the efx8 variable,
it is removed, leaving it to the compiler's constant folding to
compute 16*efx.  As such scaling can also lose underflows when the
final scaling down happens to be exact, appropriate checks are added
to ensure underflow exceptions occur when required in such cases.

Tested x86_64 and x86; no ulps updates needed.  Also spot-checked for
powerpc32 and mips64 to verify the changes to the ldbl-128ibm and
ldbl-128 implementations.

	[BZ #16516]
	* sysdeps/ieee754/dbl-64/s_erf.c (efx8): Remove variable.
	(__erf): Scale by 16 instead of 8 in potentially underflowing
	case.  Ensure exception if result actually underflows.
	* sysdeps/ieee754/flt-32/s_erff.c (efx8): Remove variable.
	(__erff): Scale by 16 instead of 8 in potentially underflowing
	case.  Ensure exception if result actually underflows.
	* sysdeps/ieee754/ldbl-128/s_erfl.c: Include <float.h>.
	(efx8): Remove variable.
	(__erfl): Scale by 16 instead of 8 in potentially underflowing
	case.  Ensure exception if result actually underflows.
	* sysdeps/ieee754/ldbl-128ibm/s_erfl.c: Include <float.h>.
	(efx8): Remove variable.
	(__erfl): Scale by 16 instead of 8 in potentially underflowing
	case.  Ensure exception if result actually underflows.
	* sysdeps/ieee754/ldbl-96/s_erfl.c: Include <float.h>.
	(efx8): Remove variable.
	(__erfl): Scale by 16 instead of 8 in potentially underflowing
	case.  Ensure exception if result actually underflows.
	* math/auto-libm-test-in: Add more tests of erf.
	* math/auto-libm-test-out: Regenerated.
2014-05-14 12:34:03 +00:00
Wilco 423a7160af Add fenv test support for targets which don't have FP traps. 2014-04-17 09:39:27 +01:00
Alan Modra aa5f0ff11a Correct IBM long double frexpl.
Besides fixing the bugzilla, this also fixes corner-cases where the high
and low double differ greatly in magnitude, and handles a denormal
input without resorting to a fp rescale.

	[BZ #16740]
	[BZ #16619]
	* sysdeps/ieee754/ldbl-128ibm/s_frexpl.c (__frexpl): Rewrite.
	* math/libm-test.inc (frexp_test_data): Add tests.
2014-04-16 19:33:32 +09:30
Chris Metcalf 9c9daaeb83 math: make test-fenv-preserve.c a no-op if FE_ALL_EXCEPT == 0.
This fixes a testsuite failure for tile (and possibly microblaze).
2014-04-11 15:13:42 -04:00
Joseph Myers a84e78c8b3 Fix catan, catanh, __ieee754_logf in round-downward mode (bug 16799, bug 16800).
This patch fixes incorrect results from catan and catanh of certain
special inputs in round-downward mode (bug 16799), and incorrect
results of __ieee754_logf (+/-0) in round-downward mode (bug 16800)
that show up through catan/catanh when tested in all rounding modes,
but not directly in the testing for logf because the bug gets hidden
by the wrappers.

Both bugs involve a zero that should be +0 being -0 instead: one
computed as (1-x)*(1+x) in the catan/catanh case, and one as (x-x) in
the logf case.  The fixes ensure positive zero is used.  Testing of
catan and catanh in all rounding modes is duly enabled.

I expect there are various other bugs in special cases in __ieee754_*
functions that are normally hidden by the wrappers but would show up
for testing with -lieee (or in future with -fno-math-errno if we
replace -lieee and _LIB_VERSION with compile-time redirection to new
*_noerrno symbol names).

Tested x86_64 and x86 and ulps updated accordingly.

	[BZ #16799]
	[BZ #16800]
	* math/s_catan.c (__catan): Avoid passing -0 denominator to atan2
	with 0 numerator.
	* math/s_catanf.c (__catanf): Likewise.
	* math/s_catanh.c (__catanh): Likewise.
	* math/s_catanhf.c (__catanhf): Likewise.
	* math/s_catanhl.c (__catanhl): Likewise.
	* math/s_catanl.c (__catanl): Likewise.
	* sysdeps/ieee754/flt-32/e_logf.c (__ieee754_logf): Always divide
	by positive zero when computing -Inf result.
	* math/libm-test.inc (catan_test): Use ALL_RM_TEST.
	(catanh_test): Likewise.
	* sysdeps/i386/fpu/libm-test-ulps: Update.
	* sysdeps/x86_64/fpu/libm-test-ulps: Likewise.
2014-04-02 17:41:02 +00:00
Joseph Myers 6f05bafeba Fix clog / clog10 sign of zero result in round-downward mode (bug 16789).
This patch fixes bug 16789, incorrect sign of (real part) zero result
from clog and clog10 in round-downward mode, arising from that real
part being computed as 0 - 0.  To ensure that an underflow exception
occurred, the code used an underflowing value (the next term in the
series for log1p) in arithmetic computing the real part of the result,
yielding the problematic 0 - 0 computation in some cases even when the
mathematical result would be small but positive.  The patch changes
this code to use the math_force_eval approach to ensuring that an
underflowing computation actually occurs.  Tests of clog and clog10
are enabled in all rounding modes.

Tested x86_64 and x86 and ulps updated accordingly.

	[BZ #16789]
	* math/s_clog.c (__clog): Use math_force_eval to ensure underflow
	instead of using underflowing value in computing result.
	* math/s_clog10.c (__clog10): Likewise.
	* math/s_clog10f.c (__clog10f): Likewise.
	* math/s_clog10l.c (__clog10l): Likewise.
	* math/s_clogf.c (__clogf): Likewise.
	* math/s_clogl.c (__clogl): Likewise.
	* math/libm-test.inc (clog_test): Use ALL_RM_TEST.
	(clog10_test): Likewise.
	* sysdeps/i386/fpu/libm-test-ulps: Update.
	* sysdeps/x86_64/fpu/libm-test-ulps: Likewise.
2014-04-02 13:10:19 +00:00
Alan Modra b0abbc2103 Correct IBM long double nextafterl.
Fix for values near a power of two, and some tidies.

	[BZ #16739]
	* sysdeps/ieee754/ldbl-128ibm/s_nextafterl.c (__nextafterl): Correct
	output when value is near a power of two.  Use int64_t for lx and
	remove casts.  Use decimal rather than hex exponent constants.
	Don't use long double multiplication when double will suffice.
	* math/libm-test.inc (nextafter_test_data): Add tests.
	* NEWS: Add 16739 and 16786 to bug list.
2014-04-02 13:46:19 +10:30
Joseph Myers 8795b4a443 Set errno for scalb errors (bug 6803, bug 6804).
This patch fixes the default mode of scalb to set errno (bugs 6803 and
6804).

Previously, the _LIB_VERSION == _SVID_ mode would set errno but only
in some relevant cases, and with various peculiarities (such as errno
setting when an exact infinity or zero result arises with an argument
to scalb being an infinity).  This patch leaves this mode
bug-compatible, while making the default mode set errno in accordance
with normal practice (so an exact infinity from an infinite argument
is not an error, and nor is an exact zero result).  gen-libm-test.pl
is taught new notation such as ERRNO_PLUS_OFLOW to facilitate writing
the tests of errno setting for underflow / overflow in libm-test.inc.

Note that bug 6803 also covers scalbn and scalbln, but this patch only
addresses the scalb parts of that bug (along with the whole of bug
6804).

Tested x86_64 and x86.

	[BZ #6803]
	[BZ #6804]
	* math/w_scalb.c (__scalb): For non-SVID mode, check result and
	set errno as appropriate.
	* math/w_scalbf.c (__scalbf): Likewise.
	* math/w_scalbl.c (__scalbl): Likewise.
	* math/gen-libm-test.pl (parse_args): Handle ERRNO_PLUS_OFLOW,
	ERRNO_MINUS_OFLOW, ERRNO_PLUS_UFLOW and ERRNO_MINUS_UFLOW.
	* math/libm-test.inc (scalb_test_data): Add errno expectations.
	Add more NaN tests.
2014-03-31 14:57:53 +00:00
Joseph Myers 54fa2475d3 Set errno for atan2 underflow (bug 16349).
This patch fixes bug 16349, missing errno setting for atan2 underflow,
by adding appropriate checks to the existing wrappers.  (As in other
cases, the __kernel_standard support for calling matherr is considered
to be for existing code expecting existing rules for what's considered
an error, even if those don't correspond to a general logical scheme
for what counts as what kind of error, so __set_errno calls are added
directly without any changes to __kernel_standard.)

Tested x86_64 and x86.

	[BZ #16349]
	* math/w_atan2.c: Include <errno.h>.
	(__atan2): Set errno for result underflowing to zero.
	* math/w_atan2f.c: Include <errno.h>.
	(__atan2f): Set errno for result underflowing to zero.
	* math/w_atan2l.c: Include <errno.h>.
	(__atan2l): Set errno for result underflowing to zero.
	* math/auto-libm-test-in: Don't allow missing errno for some atan2
	tests.
	* math/auto-libm-test-out: Regenerated.
2014-03-31 14:56:37 +00:00
Joseph Myers ea6029b19c Fix scalb spurious "invalid" exceptions (bug 16770).
This patch fixes bug 16770, spurious "invalid" exceptions from scalb
when testing whether the second argument is an integer, by inserting
appropriate range checks to determine whether a cast to int is safe.
(Note that invalid_fn is a function that handles both nonintegers and
large integers, distinguishing them reliably using functions such as
__rint; note also that there are no issues with scalb needing to avoid
spurious "inexact" exceptions - it's an old-POSIX XSI function, not a
standard C function bound to an IEEE 754 operation - although the
return value is still fully determined.)

Tested x86_64 and x86.

	[BZ #16770]
	* math/e_scalb.c (__ieee754_scalb): Check second argument is not
	too large before casting to int.
	* math/e_scalbf.c (__ieee754_scalbf): Likewise.
	* math/e_scalbl.c (__ieee754_scalbl): Likewise.
	* math/libm-test.inc (scalb_test_data): Add more tests.
2014-03-29 17:22:14 +00:00
Joseph Myers 289e077957 Fix clog10 (-0 +/- 0i) (bug 16362).
This patch fixes the imaginary part of clog10 (-0 +/- 0i), which
should be +/-pi / log(10) by analogy with clog (the functions were
wrongly returning a result with imaginary part +/-pi, same as for
clog, and the tests matched the incorrect result, though both
functions and tests were correct for the similar case of clog10 (-inf
+/- 0i)).  Tested x86_64 and x86.

	[BZ #16362]
	* math/s_clog10.c (M_PI_LOG10E): New macro.
	(__clog10): Use M_PI_LOG10E instead of M_PI when real and
	imaginary parts are 0.
	* math/s_clog10f.c (M_PI_LOG10Ef): New macro.
	(__clog10f): Use M_PI_LOG10Ef instead of M_PI when real and
	imaginary parts are 0.
	* math/s_clog10l.c (M_PI_LOG10El): New macro.
	(__clog10l): Use M_PI_LOG10El instead of M_PIl when real and
	imaginary parts are 0.
	* math/libm-test.inc (clog10_test_data): Update expected results
	for when real and imaginary parts are 0.
2014-03-28 20:53:32 +00:00
Joseph Myers 03a7091fa2 Fix x86/x86_64 expl/exp10l spurious underflows (bug 16348).
This patch fixes bug 16348, spurious underflows from x86/x86_64 expl
on arguments close to 0.  These implementations effectively use expm1
(on the fractional part of the argument) internally, so resulting in
spurious underflows when the result is very close to 1.  For arguments
small enough that the round-to-nearest correct result is 1, this patch
uses 1+x instead.

These implementations are also used for exp10l and so the patch fixes
similar issues there (the 0x1p-67 threshold being small enough to be
correct for exp10l as well as expl).  But because of spurious
underflows in other exp10 implementations (bug 16560), the tests
aren't added for exp10 at this point - they can be added when the
other exp10 parts of that bug are fixed.

Tested x86_64 and x86; no ulps updates needed.

	[BZ #16348]
	* sysdeps/i386/fpu/e_expl.S (IEEE754_EXPL) [!USE_AS_EXPM1L]: Use
	1+x for argument with exponent below -67.
	* sysdeps/x86_64/fpu/e_expl.S (IEEE754_EXPL) [!USE_AS_EXPM1L]:
	Likewise.
	* math/auto-libm-test-in: Add more tests of exp.
	* math/auto-libm-test-out: Regenerated.
2014-03-27 18:41:14 +00:00
Joseph Myers 9be36fb8cb Make x86_64 fegetenv preserve exception mask (bug 16198).
Bug 16198 is x86_64 fegetenv wrongly masking exceptions for which
traps are enabled, because that's a side-effect of the fnstenv
instruction.  This patch fixes it to use fldenv immediately after
fnstenv, like the i386 version.  Tested x86_64 and x86.

	[BZ #16198]
	* sysdeps/x86_64/fpu/fegetenv.c (fegetenv): Use fldenv after
	fnstenv.
	* math/test-fenv-preserve.c: New file.
	* math/Makefile (tests): Add test-fenv-preserve.
2014-03-26 18:59:08 +00:00
Joseph Myers 046651c168 Relax gen-auto-libm-tests may-underflow rules, test log1p in all rounding modes.
gen-auto-libm-tests presently allows but does not require underflow
exceptions for results with magnitude in the range (greatest
subnormal, least normal].

In some cases, the magnitude of the exact result is very slightly
above the least normal, but rounding in the implementation results in
it effectively computing an infinite-precision result that is slightly
below the least normal, so raising an underflow exception.  This is in
accordance with the documented accuracy goals, but results in
testsuite failures.

This patch changes the logic to allow underflows when the mathematical
result is up to 0.5ulp above the least normal (so in any case where
the round-to-nearest result is the least normal).  Ideally underflows
in all these cases would be accepted only when an underflow with the
actual result is consistent with the rounding mode (in FE_TOWARDZERO
mode, a return value of the least normal implies that the
infinite-precision result did not underflow so there should be no
underflow exception, for example), so as to match the documented goals
more precisely - whereas at present the tests for exceptions are
completely independent of the tests of the returned values.  (The same
applies to overflow exceptions as well - they too should be checked
for consistency with the result, as in FE_TOWARDZERO mode a result
1ulp below the largest finite value should be inconsistent with an
overflow exception and cause a failure with overflow rather than
simply being considered a 1ulp error when overflow is expected.)  But
the present patch at least deals with the cases causing spurious
failures so that (a) certain existing tests no longer need to be
marked as having spurious exceptions (such markings in
auto-libm-test-in end up applying to more cases than just those they
are needed for) and (b) log1p can be tested in all rounding modes
without introducing more such failures.  This patch duly moves tests
of log1p to ALL_RM_TEST.

Tested x86_64 and x86 and ulps updated accordingly.

	[BZ #16357]
	[BZ #16599]
	* math/gen-auto-libm-tests.c (fp_format_desc): Add field
	min_plus_half.
	(fp_formats): Update initializers.
	(init_fp_formats): Initialize new field.
	(output_for_one_input_case): Allow underflow for results up to
	min_plus_half.
	* math/libm-test.inc (log1p_test): Use ALL_RM_TEST.
	* math/auto-libm-test-in: Don't mark some underflows from asin and
	atanh as spurious.
	* math/auto-libm-test-out: Regenerated.
	* sysdeps/i386/fpu/libm-test-ulps: Update.
	* sysdeps/x86_64/fpu/libm-test-ulps: Likewise.
2014-03-25 12:26:06 +00:00
Joseph Myers b376a11a19 Fix dbl-64 exp overflow/underflow in non-default rounding modes (bug 16284).
The dbl-64 version of exp needs round-to-nearest mode for its internal
computations, but that has the consequence of inappropriate
overflowing and underflowing results in other rounding modes.  This
patch fixes this by recomputing the relevant results in cases where
the round-to-nearest result overflows to infinity or underflows to
zero (most of the diffs are actually just consequent reindentation).
Tests are enabled in all rounding modes for complex functions using
exp - but not for cexp because it turns out there are bugs causing
spurious underflows for cexp for some tests, which will need to be
fixed separately (I suspect ccos ccosh csin csinh ctan ctanh have
similar bugs, just not shown by the present set of test inputs).

Tested x86_64 and x86 and ulps updated accordingly.

	[BZ #16284]
	* sysdeps/ieee754/dbl-64/e_exp.c (__ieee754_exp): Use original
	rounding mode to recompute results that overflow to infinity or
	underflow to zero.
	* math/auto-libm-test-in: Don't mark tests as expected to fail for
	bug 16284.
	* math/auto-libm-test-out: Regenerated.
	* math/libm-test.inc (ccos_test): Use ALL_RM_TEST.
	(ccosh_test): Likewise.
	(csin_test_data): Use plus_oflow.
	(csin_test): Use ALL_RM_TEST.
	(csinh_test_data): Use plus_oflow.
	(csinh_test): Use ALL_RM_TEST.
	* sysdeps/i386/fpu/libm-test-ulps: Update.
	* sysdeps/x86_64/fpu/libm-test-ulps: Likewise.
2014-03-24 12:18:45 +00:00
Joseph Myers f7be737659 Fix log (1) in round-downward mode (bug 16731).
According to ISO C Annex F, log (1) should be +0 in all rounding
modes, but some implementations in glibc wrongly return -0 in
round-downward mode (mapping to log1p (x - 1) is problematic because 1
- 1 is -0 in round-downward mode, and log1p (-0) is -0).  This patch
fixes this.  (It helps with some implementations of other functions
such as acosh, log2 and log10 that call out to log, but not enough to
enable all-rounding-modes testing for those functions without further
fixes to other implementations of them.)

Tested x86_64 and x86 and ulps updated accordingly, and did spot tests
for mips64 for the ldbl-128 fix, and i586 for the sysdeps/i386/fpu
implementations shadowed by those in sysdeps/i386/i686/fpu.

	[BZ #16731]
	* sysdeps/i386/fpu/e_log.S (__ieee754_log): Take absolute value
	when x - 1 is zero.
	* sysdeps/i386/fpu/e_logf.S (__ieee754_logf): Likewise.
	* sysdeps/i386/fpu/e_logl.S (__ieee754_logl): Likewise.
	* sysdeps/i386/i686/fpu/e_logl.S (__ieee754_logl): Likewise.
	* sysdeps/ieee754/dbl-64/e_log.c (__ieee754_log): Return +0 when
	argument is 1.
	* sysdeps/ieee754/ldbl-128/e_logl.c (__ieee754_logl): Likewise.
	* sysdeps/x86_64/fpu/e_logl.S: Take absolute value when x - 1 is
	zero.
	* math/libm-test.inc (log_test): Use ALL_RM_TEST.
	* sysdeps/i386/fpu/libm-test-ulps: Update.
	* sysdeps/x86_64/fpu/libm-test-ulps: Likewise.
2014-03-21 18:13:58 +00:00
Joseph Myers 8c92dfff41 Test most libm functions in all rounding modes.
This patch makes libm-test.inc tests of most functions use ALL_RM_TEST
unless there was some reason to defer that change for a particular
function.

I started out planning to defer the change for pow (bug 16315), cexp /
ccos / ccosh / csin / csinh (likely fallout from exp, bug 16284) and
cpow (exact expectations for signs of exact zero results not wanted).
Testing on x86_64 and x86 showed additional failures for acosh, cacos,
catan, catanh, clog, clog10, jn, log, log10, log1p, log2, tgamma, yn,
so making the change for those functions was deferred as well, pending
investigation to show which of these represent distinct bugs (some
such bugs may already be filed) and appropriate fixing / XFAILing.
Failures include wrong signs of zero results, errors slightly above
the 9ulp bound (in such cases it may make sense for functions to set
round-to-nearest internally to reduce error accumulation), large
errors and incorrect overflow/underflow for the rounding mode (with
consequent missing errno settings in some cases).  It's possible some
could be issues with test expectations, though I didn't notice any
that were obviously like that (I added NO_TEST_INLINE for cases that
were failing for ildoubl on x86 and where it seemed reasonable for
them to fail for the fast-math inlines).

There may of course be failures on other architectures for functions
that didn't fail on x86_64 or x86, in which case the usual rule
applies: file a bug (preferably identifying the underlying problem
function, in cases where function A calls function B and a problem
with function B may present in the test results for function A) if not
already in Bugzilla then fix or XFAIL.

Tested x86_64 and x86 and ulps updated accordingly.

	* math/libm-test.inc (asinh_test): Use ALL_RM_TEST.
	(atan_test): Likewise.
	(atanh_test_data): Use NO_TEST_INLINE for two tests.
	(atanh_test): Use ALL_RM_TEST.
	(atan2_test_data): Likewise.
	(cabs_test): Likewise.
	(cacosh_test): Likewise.
	(carg_test): Likewise.
	(casin_test): Likewise.
	(casinh_test): Likewise.
	(cbrt_test): Likewise.
	(csqrt_test): Likewise.
	(erf_test): Likewise.
	(erfc_test): Likewise.
	(pow10_test): Likewise.
	(exp2_test): Likewise.
	(hypot_test): Likewise.
	(j0_test): Likewise.
	(j1_test): Likewise.
	(lgamma_test): Likewise.
	(gamma_test): Likewise.
	(sincos_test): Likewise.
	(tanh_test): Likewise.
	(y0_test): Likewise.
	(y1_test): Likewise.
	* sysdeps/i386/fpu/libm-test-ulps: Update.
	* sysdeps/x86_64/fpu/libm-test-ulps: Likewise.
2014-03-21 00:03:38 +00:00
Joseph Myers ae3a5dff0f Make libm-test support ALL_RM_TEST with AUTO_TESTS_*.
This patch continues improvements to all-rounding-mode libm testing by
making testing with ALL_RM_TEST support test results from
auto-libm-test-out.  gen-libm-test.pl is adapted to generate
appropriate output with results for each rounding mode, with
AUTO_TESTS_* calls no longer specifying a rounding mode.  Where there
were separate functions in libm-test.inc to test a function in each
rounding mode, using AUTO_TESTS_* to list the tests for each rounding
mode, those are converted to using ALL_RM_TEST (so generally this
patch doesn't change the sets of tests run in each rounding mode,
except that in various cases special-case tests given directly in
libm-test.inc were previously run only for round-to-nearest, and now
are run for all rounding modes).

Tested x86_64 and x86.

	* math/gen-libm-test.pl (generate_testfile): Expect only function
	name as argument to AUTO_TESTS_* and pass results for all rounding
	modes to parse_args.
	(parse_auto_input): Separate inputs of automatic tests from
	outputs before storing in %auto_tests.
	* math/libm-test.inc (acos_test_data): Update call to
	AUTO_TESTS_f_f.
	(acos_test): Use ALL_RM_TEST.
	(acos_tonearest_test_data): Remove.
	(acos_test_tonearest): Likewise.
	(acos_towardzero_test_data): Likewise.
	(acos_test_towardzero): Likewise.
	(acos_downward_test_data): Likewise.
	(acos_test_downward): Likewise.
	(acos_upward_test_data): Likewise.
	(acos_test_upward): Likewise.
	(acosh_test_data): Update call to AUTO_TESTS_f_f.
	(asin_test_data): Likewise.
	(asin_test): Use ALL_RM_TEST.
	(asin_tonearest_test_data): Remove.
	(asin_test_tonearest): Likewise.
	(asin_towardzero_test_data): Likewise.
	(asin_test_towardzero): Likewise.
	(asin_downward_test_data): Likewise.
	(asin_test_downward): Likewise.
	(asin_upward_test_data): Likewise.
	(asin_test_upward): Likewise.
	(asinh_test_data): Update call to AUTO_TESTS_f_f.
	(atan_test_data): Likewise.
	(atanh_test_data): Likewise.
	(atan2_test_data): Update call to AUTO_TESTS_ff_f.
	(cabs_test_data): Update call to AUTO_TESTS_c_f.
	(carg_test_data): Likewise.
	(cbrt_test_data): Update call to AUTO_TESTS_f_f.
	(ccos_test_data): Update call to AUTO_TESTS_c_c.
	(ccosh_test_data): Likewise.
	(cexp_test_data): Likewise.
	(clog_test_data): Likewise.
	(clog10_test_data): Likewise.
	(cos_test_data): Update call to AUTO_TESTS_f_f.
	(cos_test): Use ALL_RM_TEST.
	(cos_tonearest_test_data): Remove.
	(cos_test_tonearest): Likewise.
	(cos_towardzero_test_data): Likewise.
	(cos_test_towardzero): Likewise.
	(cos_downward_test_data): Likewise.
	(cos_test_downward): Likewise.
	(cos_upward_test_data): Likewise.
	(cos_test_upward): Likewise.
	(cosh_test_data): Update call to AUTO_TESTS_f_f.
	(cosh_test): Use ALL_RM_TEST.
	(cosh_tonearest_test_data): Remove.
	(cosh_test_tonearest): Likewise.
	(cosh_towardzero_test_data): Likewise.
	(cosh_test_towardzero): Likewise.
	(cosh_downward_test_data): Likewise.
	(cosh_test_downward): Likewise.
	(cosh_upward_test_data): Likewise.
	(cosh_test_upward): Likewise.
	(cpow_test_data): Update call to AUTO_TESTS_cc_c.
	(csqrt_test_data): Update call to AUTO_TESTS_c_c.
	(ctan_test_data): Likewise.
	(ctan_test): Use ALL_RM_TEST.
	(ctan_tonearest_test_data): Remove.
	(ctan_test_tonearest): Likewise.
	(ctan_towardzero_test_data): Likewise.
	(ctan_test_towardzero): Likewise.
	(ctan_downward_test_data): Likewise.
	(ctan_test_downward): Likewise.
	(ctan_upward_test_data): Likewise.
	(ctan_test_upward): Likewise.
	(ctanh_test_data): Update call to AUTO_TESTS_c_c.
	(ctanh_test): Use ALL_RM_TEST.
	(ctanh_tonearest_test_data): Remove.
	(ctanh_test_tonearest): Likewise.
	(ctanh_towardzero_test_data): Likewise.
	(ctanh_test_towardzero): Likewise.
	(ctanh_downward_test_data): Likewise.
	(ctanh_test_downward): Likewise.
	(ctanh_upward_test_data): Likewise.
	(ctanh_test_upward): Likewise.
	(erf_test_data): Update call to AUTO_TESTS_f_f.
	(erfc_test_data): Likewise.
	(exp_test_data): Likewise.
	(exp_test): Use ALL_RM_TEST.
	(exp_tonearest_test_data): Remove.
	(exp_test_tonearest): Likewise.
	(exp_towardzero_test_data): Likewise.
	(exp_test_towardzero): Likewise.
	(exp_downward_test_data): Likewise.
	(exp_test_downward): Likewise.
	(exp_upward_test_data): Likewise.
	(exp_test_upward): Likewise.
	(exp10_test_data): Update call to AUTO_TESTS_f_f.
	(exp10_test): Use ALL_RM_TEST.
	(exp10_tonearest_test_data): Remove.
	(exp10_test_tonearest): Likewise.
	(exp10_towardzero_test_data): Likewise.
	(exp10_test_towardzero): Likewise.
	(exp10_downward_test_data): Likewise.
	(exp10_test_downward): Likewise.
	(exp10_upward_test_data): Likewise.
	(exp10_test_upward): Likewise.
	(exp2_test_data): Update call to AUTO_TESTS_f_f.
	(expm1_test_data): Likewise.
	(expm1_test): Use ALL_RM_TEST.
	(expm1_tonearest_test_data): Remove.
	(expm1_test_tonearest): Likewise.
	(expm1_towardzero_test_data): Likewise.
	(expm1_test_towardzero): Likewise.
	(expm1_downward_test_data): Likewise.
	(expm1_test_downward): Likewise.
	(expm1_upward_test_data): Likewise.
	(expm1_test_upward): Likewise.
	(fma_test_data): Update call to AUTO_TESTS_fff_f.
	(fma_test): Use ALL_RM_TEST.
	(fma_towardzero_test_data): Remove.
	(fma_test_towardzero): Likewise.
	(fma_downward_test_data): Likewise.
	(fma_test_downward): Likewise.
	(fma_upward_test_data): Likewise.
	(fma_test_upward): Likewise.
	(hypot_test_data): Update call to AUTO_TESTS_ff_f.
	(j0_test_data): Update call to AUTO_TESTS_f_f.
	(j1_test_data): Likewise.
	(jn_test_data): Update call to AUTO_TESTS_if_f.
	(lgamma_test_data): Update call to AUTO_TESTS_f_f1.
	(log_test_data): Update call to AUTO_TESTS_f_f.
	(log10_test_data): Likewise.
	(log1p_test_data): Likewise.
	(log2_test_data): Likewise.
	(pow_test_data): Update call to AUTO_TESTS_ff_f.
	(pow_tonearest_test_data): Likewise.
	(sin_test_data): Update call to AUTO_TESTS_f_f.
	(sin_test): Use ALL_RM_TEST.
	(sin_tonearest_test_data): Remove.
	(sin_test_tonearest): Likewise.
	(sin_towardzero_test_data): Likewise.
	(sin_test_towardzero): Likewise.
	(sin_downward_test_data): Likewise.
	(sin_test_downward): Likewise.
	(sin_upward_test_data): Likewise.
	(sin_test_upward): Likewise.
	(sincos_test_data): Update call to AUTO_TESTS_fFF_11.
	(sinh_test_data): Update call to AUTO_TESTS_f_f.
	(sinh_test): Use ALL_RM_TEST.
	(sinh_tonearest_test_data): Remove.
	(sinh_test_tonearest): Likewise.
	(sinh_towardzero_test_data): Likewise.
	(sinh_test_towardzero): Likewise.
	(sinh_downward_test_data): Likewise.
	(sinh_test_downward): Likewise.
	(sinh_upward_test_data): Likewise.
	(sinh_test_upward): Likewise.
	(sqrt_test_data): Update call to AUTO_TESTS_f_f.
	(sqrt_test): Use ALL_RM_TEST.
	(sqrt_tonearest_test_data): Remove.
	(sqrt_test_tonearest): Likewise.
	(sqrt_towardzero_test_data): Likewise.
	(sqrt_test_towardzero): Likewise.
	(sqrt_downward_test_data): Likewise.
	(sqrt_test_downward): Likewise.
	(sqrt_upward_test_data): Likewise.
	(sqrt_test_upward): Likewise.
	(tan_test_data): Update call to AUTO_TESTS_f_f.
	(tan_test): Use ALL_RM_TEST.
	(tan_tonearest_test_data): Remove.
	(tan_test_tonearest): Likewise.
	(tan_towardzero_test_data): Likewise.
	(tan_test_towardzero): Likewise.
	(tan_downward_test_data): Likewise.
	(tan_test_downward): Likewise.
	(tan_upward_test_data): Likewise.
	(tan_test_upward): Likewise.
	(tanh_test_data): Update call to AUTO_TESTS_f_f.
	(tgamma_test_data): Likewise.
	(y0_test_data): Likewise.
	(y1_test_data): Likewise.
	(yn_test_data): Update call to AUTO_TESTS_if_f.
	(main): Do not call removed functions.
2014-03-20 11:48:07 +00:00
Joseph Myers d71aeee886 Use ALL_RM_TEST for more libm tests.
Continuing the move to using ALL_RM_TEST for tests in libm-test.inc,
this patch converts the tests of fdim, ldexp and scalb.  fdim and
scalb are cases where tests could depend on the rounding mode though
none of the present test inputs do; ldexp is such a case where the
function is equivalent to scalbn (for binary floating point) and the
tests used were a subset of those for scalbn, so this patch makes
ldexp testing use the scalbn tests, as done for other cases of libm
function aliases.

Tested x86_64 and x86.

	* math/libm-test.inc (fdim_test): Use ALL_RM_TEST.
	(ldexp_test_data): Remove.
	(ldexp_test): Move to after scalbn_test.  Use ALL_RM_TEST with
	scalbn_test_data.
	(scalb_test): Use ALL_RM_TEST.
2014-03-19 16:17:22 +00:00
Joseph Myers b29b6bb8fe Test scalbn and scalbln in all rounding modes, add more tests of negative arguments.
Continuing the move to systematically testing libm functions in all
rounding modes with ALL_RM_TEST, this patch converts the tests of
scalbn and scalbln to use that macro.

Those tests include cases of underflow and overflow, meaning the
expected results depend on the rounding mode.  For convenience in
writing such tests manually, the patch adds the notation plus_oflow,
minus_oflow, plus_uflow and minus_uflow for overflowing / underflowing
results of each sign appropriate to the rounding mode being used, and
gen-libm-test.pl is made to substitute in the appropriate values.  The
tests of underflow and overflow are extended to include negative
arguments to provide better coverage (otherwise minus_oflow and
minus_uflow wouldn't have been used at all).

(A subsequent patch will make ldexp use the scalbn tests, as those
functions are equivalent for binary floating point.)

Tested x86_64 and x86.

	* math/gen-libm-test.pl (parse_args): Handle plus_oflow,
	minus_oflow, plus_uflow and minus_uflow in expected results.
	* math/libm-test.inc (scalbn_test_data): Add more tests of
	negative arguments.  Use plus_oflow, minus_oflow, plus_uflow and
	minus_uflow.
	(scalbn_test): Use ALL_RM_TEST.
	(scalbln_test_data): Add more tests of negative arguments.  Use
	plus_oflow, minus_oflow, plus_uflow and minus_uflow.
	(scalbln_test): Use ALL_RM_TEST.
2014-03-18 18:47:46 +00:00
Joseph Myers b36208627c Test rint and nearbyint with same inputs, in all rounding modes.
This patch arranges for rint and nearbyint to be tested by
libm-test.inc with the same inputs (previously each had some test
inputs the other didn't, although there was a lot of overlap as well),
and for nearbyint to be tested in all rounding modes where previously
it was only tested in round-to-nearest mode.  The expected results are
the same for each function, except that rint is expected to have
"inexact" exceptions for non-integer input and nearbyint is expected
not to have those exceptions.

Tested x86_64 and x86.

	* math/libm-test.inc (nearbyint_test_data): Include all tests used
	for rint.  Include results for all rounding modes.
	(nearbyint_test): Use ALL_RM_TEST.
	(rint_test_data): Include all tests used for nearbyint.
2014-03-17 21:18:18 +00:00
Joseph Myers 9962a2d34e Add libm-test support for per-rounding-mode manually specified results.
This patch continues the libm-test move towards automatic testing of
all test inputs in all rounding modes by adding gen-libm-test.pl
support for tests specifying results in each rounding mode manually.

Previously a TEST_* line could specify arguments and results, or
arguments, results and flags.  Now there is the option of (arguments,
results-rd, flags-rd, results-rn, flags-rn, results-rz, flags-rz,
results-ru, flags-ru).  This is used to replace the separate arrays of
results in each rounding mode for lrint, llrint and rint.  (In the
case of rint, some tests were only in rint_test_data and needed to
have expectations for non-default rounding modes added, which I did
manually.  In various cases there were slight differences in things
such as the ordering of tests in the arrays for each mode.)

Tested x86_64 and x86.

	* math/gen-libm-test.pl (parse_args): Handle results specified for
	each rounding mode separately.
	* math/libm-test.inc (lrint_test_data): Merge in per-rounding-mode
	tests and results from lrint_tonearest_test_data,
	lrint_towardzero_test_data, lrint_downward_test_data and
	lrint_upward_test_data.
	(lrint_test): Use ALL_RM_TEST.
	(lrint_tonearest_test_data): Remove.
	(lrint_test_tonearest): Likewise.
	(lrint_towardzero_test_data): Likewise.
	(lrint_test_towardzero): Likewise.
	(lrint_downward_test_data): Likewise.
	(lrint_test_downward): Likewise.
	(lrint_upward_test_data): Likewise.
	(lrint_test_upward): Likewise.
	(llrint_test_data): Merge in per-rounding-mode tests and results
	from llrint_tonearest_test_data, llrint_towardzero_test_data,
	llrint_downward_test_data and llrint_upward_test_data.
	(llrint_test): Use ALL_RM_TEST.
	(llrint_tonearest_test_data): Remove.
	(llrint_test_tonearest): Likewise.
	(llrint_towardzero_test_data): Likewise.
	(llrint_test_towardzero): Likewise.
	(llrint_downward_test_data): Likewise.
	(llrint_test_downward): Likewise.
	(llrint_upward_test_data): Likewise.
	(llrint_test_upward): Likewise.
	(rint_test_data): Merge in per-rounding-mode tests and results
	from rint_tonearest_test_data, rint_towardzero_test_data,
	rint_downward_test_data and rint_upward_test_data.  Add
	per-rounding-mode results for tests not in those arrays.
	(rint_test): Use ALL_RM_TEST.
	(rint_tonearest_test_data): Remove.
	(rint_test_tonearest): Likewise.
	(rint_towardzero_test_data): Likewise.
	(rint_test_towardzero): Likewise.
	(rint_downward_test_data): Likewise.
	(rint_test_downward): Likewise.
	(rint_upward_test_data): Likewise.
	(rint_test_upward): Likewise.
	(main): Don't call removed functions.
2014-03-17 12:29:26 +00:00
Adhemerval Zanella c7de502503 PowerPC: remove wrong roundl implementation for PowerPC64
The roundl assembly implementation
(sysdeps/powerpc/powerpc64/fpu/s_roundl.S)
returns wrong results for some inputs where first double is a exact
integer and the precision is determined by second long double.

Checking on implementation comments and history, I am very confident the
assembly implementation was based on a version before commit
5c68d40169 that fixes BZ#2423 (Errors in
long double (ldbl-128ibm) rounding functions in glibc-2.4).

By just removing the implementation and make the build select
sysdeps/ieee754/ldbl-128ibm/s_roundl.c instead fixes the failing math.

This fixes 16707.
2014-03-14 12:54:47 -05:00
Adhemerval Zanella 98fb27a373 PowerPC: remove wrong nearbyintl implementation for PPC64
The nearbyintl assembly implementation
(sysdeps/powerpc/powerpc64/fpu/s_nearbyintl.S)
returns wrong results for some inputs where first double is a exact
integer and the precision is determined by second long double.

Checking on implementation comments and history, I am very confident the
assembly implementation was based on a version before commit
5c68d40169 that fixes BZ#2423 (Errors in
long double (ldbl-128ibm) rounding functions in glibc-2.4).

By just removing the implementation and make the build select
sysdeps/ieee754/ldbl-128ibm/s_nearbyintl.c instead fixes the failing
math.

Fixes BZ#16706.
2014-03-14 12:54:47 -05:00
Adhemerval Zanella 374f7f6121 PowerPC: remove wrong ceill implementation for PowerPC64
The ceill assembly implementation (sysdeps/powerpc/powerpc64/fpu/s_ceill.S)
returns wrong results for some inputs where first double is a exact
integer and the precision is determined by second long double.

Checking on implementation comments and history, I am very confident the
assembly implementation was based on a version before commit
5c68d40169 that fixes BZ#2423 (Errors in
long double (ldbl-128ibm) rounding functions in glibc-2.4).

By just removing the implementation and make the build select
sysdeps/ieee754/ldbl-128ibm/s_ceill.c instead fixes the failing math.

Fixes BZ#16701.
2014-03-14 12:54:47 -05:00
Adhemerval Zanella 4655c291d1 Add truncl tests related to BZ#16414 2014-03-14 12:54:47 -05:00
Joseph Myers 600fa36158 Fix nextafter overflow in non-default rounding modes (bug 16677).
ISO C requires the result of nextafter to be independent of the
rounding mode, even when underflow or overflow occurs.  This patch
fixes the bug in various nextafter implementations that, having done
an overflowing computation to force an overflow exception (correct),
they then return the result of that computation rather than an
infinity computed some other way (incorrect, when the overflowing
result of arithmetic with that sign and rounding mode is finite but
the correct result is infinite) - generally by falling through to
existing code to return a value that in fact is correct for this case
(but was computed by an integer increment and so without generating
the exceptions required).  Having fixed the bug, the previously
deferred conversion of nextafter testing in libm-test.inc to
ALL_RM_TEST is also included.

Tested x86_64 and x86; also spot-checked results of nextafter tests
for powerpc32 and mips64 to test the ldbl-128ibm and ldbl-128
changes.  (The m68k change is untested.)

	[BZ #16677]
	* math/s_nextafter.c (__nextafter): Do not return value from
	overflowing computation.
	* sysdeps/i386/fpu/s_nextafterl.c (__nextafterl): Likewise.
	* sysdeps/ieee754/flt-32/s_nextafterf.c (__nextafterf): Likewise.
	* sysdeps/ieee754/ldbl-128/s_nextafterl.c (__nextafterl):
	Likewise.
	* sysdeps/ieee754/ldbl-128ibm/s_nextafterl.c (__nextafterl):
	Likewise.
	* sysdeps/m68k/m680x0/fpu/s_nextafterl.c (__nextafterl): Likewise.
	* math/libm-test.inc (nextafter_test): Use ALL_RM_TEST.
2014-03-11 22:24:00 +00:00
Joseph Myers e9996ef750 Add libm-test.inc macro for all-rounding-modes testing.
This patch adds support in libm-test.inc for automatically running
tests of a function in all rounding modes, in the form of a macro
ALL_RM_TEST to loop over all rounding modes when running tests of a
function, and uses it for functions whose results should always be
independent of the rounding mode.

Conversion of tests of nextafter to ALL_RM_TEST was deferred because
trying that conversion showed up bug 16677.  (Finding such a bug of
course illustrates the point of testing more systematically in all
rounding modes rather than only reactively when bugs get reported in a
particular function in a non-default mode.)  Conversion of tests where
results can depend on the rounding mode will follow once I add
gen-libm-test.pl support for using different initializers for the
expected results for different rounding modes (again, some conversions
may need deferring until bugs are fixed, depending on how
straightforward they are to XFAIL in a particular context).

Some existing tests get run five times rather than four, with
round-to-nearest tests both run in that as default rounding mode and
also with it explicitly set with fesetround (FE_TONEAREST).  This
duplication doesn't seem particularly useful, so ALL_RM_TEST only runs
tests four times.

Tested x86_64 and x86.

	* math/libm-test.inc (ALL_RM_TEST): New macro.
	(ceil_test): Use ALL_RM_TEST.
	(cimag_test): Likewise.
	(conj_test): Likewise.
	(copysign_test): Likewise.
	(cproj_test): Likewise.
	(creal_test): Likewise.
	(fabs_test): Likewise.
	(floor_test): Likewise.
	(fmax_test): Likewise.
	(fmin_test): Likewise.
	(fmod_test): Likewise.
	(fpclassify_test): Likewise.
	(frexp_test): Likewise.
	(ilogb_test): Likewise.
	(isfinite_test): Likewise.
	(finite_test): Likewise.
	(isgreater_test): Likewise.
	(isgreaterequal_test): Likewise.
	(isinf_test): Likewise.
	(isless_test): Likewise.
	(islessequal_test): Likewise.
	(islessgreater_test): Likewise.
	(isnan_test): Likewise.
	(isnormal_test): Likewise.
	(issignaling_test): Likewise.
	(isunordered_test): Likewise.
	(logb_test): Likewise.
	(logb_downward_test_data): Remove.
	(logb_test_downward): Likewise.
	(lround_test): Use ALL_RM_TEST.
	(llround_test): Likewise.
	(modf_test): Likewise.
	(nexttoward_test): Likewise.
	(remainder_test): Likewise.
	(drem_test): Likewise.
	(remainder_tonearest_test_data): Likewise.
	(remainder_test_tonearest): Likewise.
	(drem_test_tonearest): Likewise.
	(remainder_towardzero_test_data): Likewise.
	(remainder_test_towardzero): Likewise.
	(drem_test_towardzero): Likewise.
	(remainder_downward_test_data): Likewise.
	(remainder_test_downward): Likewise.
	(drem_test_downward): Likewise.
	(remainder_upward_test_data): Likewise.
	(remainder_test_upward): Likewise.
	(drem_test_upward): Likewise.
	(remquo_test): Use ALL_RM_TEST.  Remove comment about x.
	(round_test): Use ALL_RM_TEST.
	(signbit_test): Likewise.
	(trunc_test): Likewise.
	(significand_test): Likewise.
	(main): Don't call removed functions.
2014-03-08 14:08:38 +00:00
Joseph Myers 215db4029e Prepare libm-test.inc structures for multi-rounding-mode testing.
At present, libm-test.inc tests are run in multiple rounding modes by
having a separate array for each rounding mode (which might or might
not have the same test inputs as the other such arrays), a separate
function calling a RUN_TEST_LOOP_* macro over that array, and a
separate call to that function in main.  The number of functions
tested in multiple rounding modes has gradually increased as
rounding-mode-specific bugs have been found and fixed in different
functions.

It would be better to be able to use a single macro call, in a single
function, to run tests for a function over all rounding modes, with
this being done for all libm functions except in cases where it's
deferred until some bugs can be fixed because XFAILing all affected
tests would be painful (that's why the full set of pow tests isn't
currently run in all rounding modes).  This patch helps prepare for
that by making the structures storing expected results for tests store
results for all four rounding modes.  After this patch, the results
for all modes are just duplicates, but tests access the appropriate
field in the structure, so helping to pave the way for when the fields
stop being duplicates and multiple rounding modes can be tested from a
single array.  Tests might in future specify a single set of results,
to be used in all rounding modes; separate results for each rounding
mode, specified manually; or use of auto-libm-tests-* to generate
results for each rounding mode.

Tested x86_64.

	* math/libm-test.inc (struct test_f_f_data): Move expected results
	into structure for each rounding mode.
	(struct test_ff_f_data): Likewise.
	(struct test_ff_f_data_nexttoward): Likewise.
	(struct test_fi_f_data): Likewise.
	(struct test_fl_f_data): Likewise.
	(struct test_if_f_data): Likewise.
	(struct test_fff_f_data): Likewise.
	(struct test_c_f_data): Likewise.
	(struct test_f_f1_data): Likewise.
	(struct test_fF_f1_data): Likewise.
	(struct test_ffI_f1_data): Likewise.
	(struct test_c_c_data): Likewise.
	(struct test_cc_c_data): Likewise.
	(struct test_f_i_data): Likewise.
	(struct test_ff_i_data): Likewise.
	(struct test_f_l_data): Likewise.
	(struct test_f_L_data): Likewise.
	(struct test_fFF_11_data): Likewise.
	(RM_): New macro.
	(RM_FE_DOWNWARD): Likewise.
	(RM_FE_TONEAREST): Likewise.
	(RM_FE_TOWARDZERO): Likewise.
	(RM_FE_UPWARD): Likewise.
	(RUN_TEST_LOOP_f_f): Update references to expected results.
	(RUN_TEST_LOOP_2_f): Likewise.
	(RUN_TEST_LOOP_fff_f): Likewise.
	(RUN_TEST_LOOP_c_f): Likewise.
	(RUN_TEST_LOOP_f_f1): Likewise.
	(RUN_TEST_LOOP_fF_f1): Likewise.
	(RUN_TEST_LOOP_fI_f1): Likewise.
	(RUN_TEST_LOOP_ffI_f1): Likewise.
	(RUN_TEST_LOOP_c_c): Likewise.
	(RUN_TEST_LOOP_cc_c): Likewise.
	(RUN_TEST_LOOP_f_i): Likewise.
	(RUN_TEST_LOOP_f_i_tg): Likewise.
	(RUN_TEST_LOOP_ff_i_tg): Likewise.
	(RUN_TEST_LOOP_f_b): Likewise.
	(RUN_TEST_LOOP_f_b_tg): Likewise.
	(RUN_TEST_LOOP_f_l): Likewise.
	(RUN_TEST_LOOP_f_L): Likewise.
	(RUN_TEST_LOOP_fFF_11): Likewise.
	* math/gen-libm-test.pl (parse_args): Output four copies of
	expected results for each test.
2014-03-06 14:15:00 +00:00
Joseph Myers aa97dee16e Adjust how gen-auto-libm-tests handles before-rounding/after-rounding cases.
This patch changes gen-auto-libm-tests so that, when generating test
results that depend on whether the architecture has before-rounding or
after-rounding tininess detection, the :before-rounding or
:after-rounding conditions go on the exception / errno flags
generated, rather than generating two separate lines in
auto-libm-test-out for e.g. flt-32:before-rounding and
flt-32:after-rounding.

The rationale for this is as follows.  It would be desirable for
testing a libm function in all rounding modes to require just one
function and array in libm-test.inc, not four (or five), with the
array of test data including expected results for all rounding modes
rather than separate arrays for each rounding mode that also need to
repeat all the test inputs.  For gen-libm-test.pl to generate data for
such an array from auto-libm-test-out, it would be helpful if each
(format, test input) pair has exactly four lines in
auto-libm-test-out, one for each rounding mode, rather than some
rounding modes having just one line and some having two because the
exceptions depend on tininess detection.

Tested x86_64 and x86.

	* math/gen-auto-libm-tests.c: Update comment on output format.
	(output_for_one_input_case): Generate before-rounding and
	after-rounding information as conditions on output flags not
	floating-point format.
	* math/auto-libm-test-out: Regenerated.
	* math/gen-libm-test.pl (cond_value): New function.
	(or_cond_value): Use cond_value.
	(generate_testfile): Handle conditional exceptions.
2014-03-06 14:11:19 +00:00
Joseph Myers 2f0a0f4427 Automatically check sanity of ulps from libm tests.
This patch makes libm-test.inc apply sanity checks to ulps values
resulting from tests, or found in libm-test-ulps files, to avoid the
need for manual checking/editing of new ulps for cases that are
excessively large or involve functions that should not have any ulps.
For IBM long double, errors must be at most 14ulp (the largest
currently checked-in value), or at most 3ulp (the documented error
bound for division) in the case of exactly-determined functions; for
other formats, the limits are 9ulp (also the largest currently
checked-in value) and 0ulp.  Limits from ulps files are saturated to
those bounds, and regen-ulps will ignore any errors outside those
bounds.  (Thus if, say, you have an architecture-specific problem with
fma, the tests can still be XFAILed in auto-libm-test-in, but errors
outside the permitted range can no longer be listed in
libm-test-ulps.)

Tested x86_64.

	* math/libm-test.inc (max_valid_error): New variable.
	(init_max_error): Take new argument specifying whether function
	results are exactly determined.  Set max_valid_error and bound
	other variables for errors based on this argument.
	(set_max_error): Do not record results above max_valid_error.
	(check_float_internal): Only accept errors of up to 0.5ulps if
	also at most max_valid_error.
	(START): Take new argument EXACT and pass it to init_max_error.
	(acos_test): Update call to START.
	(acos_test_tonearest): Likewise.
	(acos_test_towardzero): Likewise.
	(acos_test_downward): Likewise.
	(acos_test_upward): Likewise.
	(acosh_test): Likewise.
	(asin_test): Likewise.
	(asin_test_tonearest): Likewise.
	(asin_test_towardzero): Likewise.
	(asin_test_downward): Likewise.
	(asin_test_upward): Likewise.
	(asinh_test): Likewise.
	(atan_test): Likewise.
	(atanh_test): Likewise.
	(atan2_test): Likewise.
	(cabs_test): Likewise.
	(cacos_test): Likewise.
	(cacosh_test): Likewise.
	(carg_test): Likewise.
	(casin_test): Likewise.
	(casinh_test): Likewise.
	(catan_test): Likewise.
	(catanh_test): Likewise.
	(cbrt_test): Likewise.
	(ccos_test): Likewise.
	(ccosh_test): Likewise.
	(ceil_test): Likewise.
	(cexp_test): Likewise.
	(cimag_test): Likewise.
	(clog_test): Likewise.
	(clog10_test): Likewise.
	(conj_test): Likewise.
	(copysign_test): Likewise.
	(cos_test): Likewise.
	(cos_test_tonearest): Likewise.
	(cos_test_towardzero): Likewise.
	(cos_test_downward): Likewise.
	(cos_test_upward): Likewise.
	(cosh_test): Likewise.
	(cosh_test_tonearest): Likewise.
	(cosh_test_towardzero): Likewise.
	(cosh_test_downward): Likewise.
	(cosh_test_upward): Likewise.
	(cpow_test): Likewise.
	(cproj_test): Likewise.
	(creal_test): Likewise.
	(csin_test): Likewise.
	(csinh_test): Likewise.
	(csqrt_test): Likewise.
	(ctan_test): Likewise.
	(ctan_test_tonearest): Likewise.
	(ctan_test_towardzero): Likewise.
	(ctan_test_downward): Likewise.
	(ctan_test_upward): Likewise.
	(ctanh_test): Likewise.
	(ctanh_test_tonearest): Likewise.
	(ctanh_test_towardzero): Likewise.
	(ctanh_test_downward): Likewise.
	(ctanh_test_upward): Likewise.
	(erf_test): Likewise.
	(erfc_test): Likewise.
	(exp_test): Likewise.
	(exp_test_tonearest): Likewise.
	(exp_test_towardzero): Likewise.
	(exp_test_downward): Likewise.
	(exp_test_upward): Likewise.
	(exp10_test): Likewise.
	(exp10_test_tonearest): Likewise.
	(exp10_test_towardzero): Likewise.
	(exp10_test_downward): Likewise.
	(exp10_test_upward): Likewise.
	(pow10_test): Likewise.
	(exp2_test): Likewise.
	(expm1_test): Likewise.
	(expm1_test_tonearest): Likewise.
	(expm1_test_towardzero): Likewise.
	(expm1_test_downward): Likewise.
	(expm1_test_upward): Likewise.
	(fabs_test): Likewise.
	(fdim_test): Likewise.
	(floor_test): Likewise.
	(fma_test): Likewise.
	(fma_test_towardzero): Likewise.
	(fma_test_downward): Likewise.
	(fma_test_upward): Likewise.
	(fmax_test): Likewise.
	(fmin_test): Likewise.
	(fmod_test): Likewise.
	(fpclassify_test): Likewise.
	(frexp_test): Likewise.
	(hypot_test): Likewise.
	(ilogb_test): Likewise.
	(isfinite_test): Likewise.
	(finite_test): Likewise.
	(isgreater_test): Likewise.
	(isgreaterequal_test): Likewise.
	(isinf_test): Likewise.
	(isless_test): Likewise.
	(islessequal_test): Likewise.
	(islessgreater_test): Likewise.
	(isnan_test): Likewise.
	(isnormal_test): Likewise.
	(issignaling_test): Likewise.
	(isunordered_test): Likewise.
	(j0_test): Likewise.
	(j1_test): Likewise.
	(jn_test): Likewise.
	(ldexp_test): Likewise.
	(lgamma_test): Likewise.
	(gamma_test): Likewise.
	(lrint_test): Likewise.
	(lrint_test_tonearest): Likewise.
	(lrint_test_towardzero): Likewise.
	(lrint_test_downward): Likewise.
	(lrint_test_upward): Likewise.
	(llrint_test): Likewise.
	(llrint_test_tonearest): Likewise.
	(llrint_test_towardzero): Likewise.
	(llrint_test_downward): Likewise.
	(llrint_test_upward): Likewise.
	(log_test): Likewise.
	(log10_test): Likewise.
	(log1p_test): Likewise.
	(log2_test): Likewise.
	(logb_test): Likewise.
	(logb_test_downward): Likewise.
	(lround_test): Likewise.
	(llround_test): Likewise.
	(modf_test): Likewise.
	(nearbyint_test): Likewise.
	(nextafter_test): Likewise.
	(nexttoward_test): Likewise.
	(pow_test): Likewise.
	(pow_test_tonearest): Likewise.
	(pow_test_towardzero): Likewise.
	(pow_test_downward): Likewise.
	(pow_test_upward): Likewise.
	(remainder_test): Likewise.
	(drem_test): Likewise.
	(remainder_test_tonearest): Likewise.
	(drem_test_tonearest): Likewise.
	(remainder_test_towardzero): Likewise.
	(drem_test_towardzero): Likewise.
	(remainder_test_downward): Likewise.
	(drem_test_downward): Likewise.
	(remainder_test_upward): Likewise.
	(drem_test_upward): Likewise.
	(remquo_test): Likewise.
	(rint_test): Likewise.
	(rint_test_tonearest): Likewise.
	(rint_test_towardzero): Likewise.
	(rint_test_downward): Likewise.
	(rint_test_upward): Likewise.
	(round_test): Likewise.
	(scalb_test): Likewise.
	(scalbn_test): Likewise.
	(scalbln_test): Likewise.
	(signbit_test): Likewise.
	(sin_test): Likewise.
	(sin_test_tonearest): Likewise.
	(sin_test_towardzero): Likewise.
	(sin_test_downward): Likewise.
	(sin_test_upward): Likewise.
	(sincos_test): Likewise.
	(sinh_test): Likewise.
	(sinh_test_tonearest): Likewise.
	(sinh_test_towardzero): Likewise.
	(sinh_test_downward): Likewise.
	(sinh_test_upward): Likewise.
	(sqrt_test): Likewise.
	(sqrt_test_tonearest): Likewise.
	(sqrt_test_towardzero): Likewise.
	(sqrt_test_downward): Likewise.
	(sqrt_test_upward): Likewise.
	(tan_test): Likewise.
	(tan_test_tonearest): Likewise.
	(tan_test_towardzero): Likewise.
	(tan_test_downward): Likewise.
	(tan_test_upward): Likewise.
	(tanh_test): Likewise.
	(tgamma_test): Likewise.
	(trunc_test): Likewise.
	(y0_test): Likewise.
	(y1_test): Likewise.
	(yn_test): Likewise.
	(significand_test): Likewise.
2014-03-05 15:05:20 +00:00
Joseph Myers e6b6a85705 Don't include individual test ulps in libm-test-ulps.
As recently discussed
<https://sourceware.org/ml/libc-alpha/2014-02/msg00670.html>, it
doesn't seem particularly useful for libm-test-ulps files to contain
huge amounts of data on ulps for individual tests; just the global
maximum observed ulps for each function, together with the
verification of exceptions, errno and special results such as
infinities and NaNs for each test, suffices to verify that a
function's behavior on the given test inputs is within the expected
accuracy.  Removing this data reduces source tree churn caused by
updates to these files when libm tests are added, and reduces the
frequency with which testsuite additions actually need libm-test-ulps
changes at all.

Accordingly, this patch removes that data, so that individual tests
get checked against the global bounds for the given function and only
generate an error if those are exceeded.  Tested x86_64 (including
verifying that if an ulps value is artificially reduced, the tests do
indeed fail as they should and "make regen-ulps" generates the
expected changes).

	* math/libm-test.inc (struct ulp_data): Don't refer to ulps for
	individual tests in comment.
	(libm-test-ulps.h): Don't refer to test_ulps in #include comment.
	(prev_max_error): New variable.
	(prev_real_max_error): Likewise.
	(prev_imag_max_error): Likewise.
	(compare_ulp_data): Don't refer to test names in comment.
	(find_test_ulps): Remove function.
	(find_function_ulps): Likewise.
	(find_complex_function_ulps): Likewise.
	(init_max_error): Take function name as argument.  Look up ulps
	for that function.
	(print_ulps): Remove function.
	(print_max_error): Use prev_max_error instead of calling
	find_function_ulps.
	(print_complex_max_error): Use prev_real_max_error and
	prev_imag_max_error instead of calling find_complex_function_ulps.
	(check_float_internal): Take max_ulp parameter instead of calling
	find_test_ulps.  Don't call print_ulps.
	(check_float): Update call to check_float_internal.
	(check_complex): Update calls to check_float_internal.
	(START): Pass argument to init_max_error.
	* math/gen-libm-test.pl (%results): Don't include "kind"
	information.
	(parse_ulps): Don't handle ulps of individual tests.
	(print_ulps_file): Likewise.
	(output_ulps): Likewise.
	* math/README.libm-test: Update.
	* manual/libm-err-tab.pl (parse_ulps): Don't handle ulps of
	individual tests.
	* sysdeps/aarch64/libm-test-ulps: Remove individual test ulps.
	* sysdeps/alpha/fpu/libm-test-ulps: Likewise.
	* sysdeps/arm/libm-test-ulps: Likewise.
	* sysdeps/i386/fpu/libm-test-ulps: Likewise.
	* sysdeps/ia64/fpu/libm-test-ulps: Likewise.
	* sysdeps/m68k/coldfire/fpu/libm-test-ulps: Likewise.
	* sysdeps/m68k/m680x0/fpu/libm-test-ulps: Likewise.
	* sysdeps/microblaze/libm-test-ulps: Likewise.
	* sysdeps/mips/mips32/libm-test-ulps: Likewise.
	* sysdeps/mips/mips64/libm-test-ulps: Likewise.
	* sysdeps/powerpc/fpu/libm-test-ulps: Likewise.
	* sysdeps/powerpc/nofpu/libm-test-ulps: Likewise.
	* sysdeps/s390/fpu/libm-test-ulps: Likewise.
	* sysdeps/sh/libm-test-ulps: Likewise.
	* sysdeps/sparc/fpu/libm-test-ulps: Likewise.
	* sysdeps/tile/libm-test-ulps: Likewise.
	* sysdeps/x86_64/fpu/libm-test-ulps: Likewise.

	* sysdeps/hppa/fpu/libm-test-ulps: Remove individual test ulps.
2014-03-05 15:02:38 +00:00
Joseph Myers 45adef3cf2 Fix libm-test.inc:print_complex_max_error handling of some error cases.
When regenerating ulps incrementally with "make regen-ulps", the
resulting diffs should only increase existing ulps, never decrease
them.  This allows successive uses of "make regen-ulps" on different
hardware or with different compiler configurations to accumulate ulps
that are sufficient for tests to pass in a variety of configurations.

However, sometimes changes that decrease ulps are wrongly generated;
thus, when applying
<https://sourceware.org/ml/libc-alpha/2014-02/msg00605.html> I had to
remove such changes manually.  The problem is
print_complex_max_error.  If the ulps for either the real or the
imaginary part of a function are out of range, this function prints
the maximum ulps seen for both parts, which then replace those
previously in libm-test-ulps.  So if the ulps for one part are bigger
than recorded before, but those for the other part are smaller, the
diffs reduce existing ulps.

This patch fixes the logic so that only increased ulps get printed.

Tested x86_64 ("make math/tests", and "make regen-ulps" in a situation
with ulps manually modified so one part would go up and the other
down, to confirm the changes have the intended effect then).

	* math/libm-test.inc (print_complex_max_error): Check separately
	whether real and imaginary errors are within allowed range and
	pass 0 to print_complex_function_ulps instead of value within
	allowed range.
2014-03-04 14:16:25 +00:00
Siddhesh Poyarekar 1cadc85813 Fix sign of input to bsloww1 (BZ #16623)
In 84ba214c, I removed some redundant sign computations and in the
process, I incorrectly got rid of a temporary variable, thus passing
the absolute value of the input to bsloww1.  This caused #16623.

This fix undoes the incorrect change.
2014-02-27 21:12:09 +05:30
Joseph Myers a5f891ac8d Consistently include Makeconfig after defining subdir.
In <https://sourceware.org/ml/libc-alpha/2014-01/msg00196.html> I
noted it was necessary to add includes of Makeconfig early in various
subdirectory makefiles for the tests-special variable settings added
by that patch to be conditional on configuration information.  No-one
commented on the general question there of whether Makeconfig should
always be included immediately after the definition of subdir.

This patch implements that early inclusion of Makeconfig in each
directory (which is a lot easier than consistent placement of includes
of Rules).  Includes are added if needed, or moved up if already
present.  Subdirectory "all:" targets are removed, since Makeconfig
provides one.

There is potential for further cleanups I haven't done.  Rules and
Makerules have code such as

ifneq   "$(findstring env,$(origin headers))" ""
headers :=
endif

to override to empty any value of various variables that came from the
environment.  I think there is a case for Makeconfig setting all the
subdirectory variables (other than subdir) to empty to ensure no
outside value is going to take effect if a subdirectory fails to
define a variable.  (A list of such variables, possibly out of date
and incomplete, is in manual/maint.texi.)  Rules and Makerules would
give errors if Makeconfig hadn't already been included, instead of
including it themselves.  The special code to override values coming
from the environment would then be obsolete and could be removed.

Tested x86_64, including that installed binaries are identical before
and after the patch.

	* argp/Makefile: Include Makeconfig immediately after defining
	subdir.
	* assert/Makefile: Likewise.
	* benchtests/Makefile: Likewise.
	* catgets/Makefile: Likewise.
	* conform/Makefile: Likewise.
	* crypt/Makefile: Likewise.
	* csu/Makefile: Likewise.
	(all): Remove target.
	* ctype/Makefile: Include Makeconfig immediately after defining
	subdir.
	* debug/Makefile: Likewise.
	* dirent/Makefile: Likewise.
	* dlfcn/Makefile: Likewise.
	* gmon/Makefile: Likewise.
	* gnulib/Makefile: Likewise.
	* grp/Makefile: Likewise.
	* gshadow/Makefile: Likewise.
	* hesiod/Makefile: Likewise.
	* hurd/Makefile: Likewise.
	(all): Remove target.
	* iconvdata/Makefile: Include Makeconfig immediately after
	defining subdir.
	* inet/Makefile: Likewise.
	* intl/Makefile: Likewise.
	* io/Makefile: Likewise.
	* libio/Makefile: Likewise.
	(all): Remove target.
	* locale/Makefile: Include Makeconfig immediately after defining
	subdir.
	* login/Makefile: Likewise.
	* mach/Makefile: Likewise.
	(all): Remove target.
	* malloc/Makefile: Include Makeconfig immediately after defining
	subdir.
	(all): Remove target.
	* manual/Makefile: Include Makeconfig immediately after defining
	subdir.
	* math/Makefile: Likewise.
	* misc/Makefile: Likewise.
	* nis/Makefile: Likewise.
	* nss/Makefile: Likewise.
	* po/Makefile: Likewise.
	(all): Remove target.
	* posix/Makefile: Include Makeconfig immediately after defining
	subdir.
	* pwd/Makefile: Likewise.
	* resolv/Makefile: Likewise.
	* resource/Makefile: Likewise.
	* rt/Makefile: Likewise.
	* setjmp/Makefile: Likewise.
	* shadow/Makefile: Likewise.
	* signal/Makefile: Likewise.
	* socket/Makefile: Likewise.
	* soft-fp/Makefile: Likewise.
	* stdio-common/Makefile: Likewise.
	* stdlib/Makefile: Likewise.
	* streams/Makefile: Likewise.
	* string/Makefile: Likewise.
	* sunrpc/Makefile: Likewise.
	(all): Remove target.
	* sysvipc/Makefile: Include Makeconfig immediately after defining
	subdir.
	* termios/Makefile: Likewise.
	* time/Makefile: Likewise.
	* timezone/Makefile: Likewise.
	(all): Remove target.
	* wcsmbs/Makefile: Include Makeconfig immediately after defining
	subdir.
	* wctype/Makefile: Likewise.

libidn/ChangeLog:
	* Makefile: Include Makeconfig immediately after defining subdir.

localedata/ChangeLog:
	* Makefile: Include Makeconfig immediately after defining subdir.
	(all): Remove target.

nptl/ChangeLog:
	* Makefile: Include Makeconfig immediately after defining subdir.

nptl_db/ChangeLog:
	* Makefile: Include Makeconfig immediately after defining subdir.
2014-02-26 23:12:03 +00:00
Joseph Myers acd7f096d7 Complete _BSD_SOURCE / _SVID_source followup cleanup.
This patch completes the headers cleanup consequent on removal of
_BSD_SOURCE and _SVID_SOURCE (apart from any subsequent deprecations):

* #endif conditionals that referred to BSD or SVID are updated.

* Redundant __USE_* tests in cases involving __USE_MISC are removed.
  This includes cases such as __USE_MISC || __USE_ISOC99, where
  __USE_MISC is redundant (because __USE_MISC is only ever defined in
  the default / _DEFAULT_SOURCE / _GNU_SOURCE case, when __USE_ISOC99
  is also defined; the same applies to the non-XSI-extended POSIX
  versions), and cases involving __USE_GNU, where __USE_GNU is
  redundant (because if __USE_GNU is defined, so are the other __USE_*
  macros).  There may well be other cases of __USE_FOO || __USE_BAR
  tests that could be simplified because one macro implies the other;
  this patch only addresses cases involving __USE_MISC.

Tested x86_64.

	* bits/fcntl.h [__USE_MISC]: Remove redundant conditionals.
	* bits/sigaction.h [__USE_MISC]: Likewise.
	* bits/waitstatus.h: Update #endif comments.
	* ctype/ctype.h: Likewise.
	* dirent/dirent.h: Likewise.
	[__USE_MISC]: Remove redundant conditionals.
	* grp/grp.h: Update #endif comments.
	[__USE_GNU]: Remove redundant conditionals.
	[__USE_MISC]: Likewise.
	* inet/netinet/in.h [__USE_GNU]: Likewise.
	* io/sys/stat.h [__USE_MISC]: Likewise.
	* libio/bits/stdio-ldbl.h [__USE_MISC]: Likewise.
	* libio/bits/stdio.h: Update #endif comments.
	[__USE_MISC]: Remove redundant conditionals.
	* libio/bits/stdio2.h [__USE_MISC]: Likewise.
	* libio/stdio.h: Update #endif comments.
	[__USE_MISC]: Remove redundant conditionals.
	* math/bits/math-finite.h [__USE_MISC]: Likewise.
	* math/bits/mathcalls.h [__USE_MISC]: Likewise.
	* math/math.h: Update #else and #endif comments.
	[__USE_MISC]: Remove redundant conditionals.
	* misc/sys/uio.h: Update #endif comments.
	* posix/bits/unistd.h [__USE_MISC]: Remove redundant conditionals.
	* posix/glob.h [__USE_MISC]: Likewise.
	* posix/sys/types.h: Update #endif comments.
	[__USE_MISC]: Remove redundant conditionals.
	* posix/sys/wait.h: Update #endif comments.
	[__USE_MISC]: Remove redundant conditionals.
	* posix/unistd.h: Update #endif comments.
	[__USE_MISC]: Remove redundant conditionals.
	* pwd/pwd.h [__USE_GNU]: Likewise.
	[__USE_MISC]: Likewise.
	* resolv/netdb.h [__USE_GNU]: Likewise.
	* signal/signal.h: Update #endif comments.
	[__USE_MISC]: Remove redundant conditionals.
	* stdlib/stdlib.h: Update #else and #endif comments.
	[__USE_MISC]: Remove redundant conditionals.
	[__USE_GNU]: Likewise.
	* string/bits/string2.h [__USE_MISC]: Likewise.
	* string/string.h: Update #endif comments.
	[__USE_MISC]: Remove redundant conditionals.
	* sysdeps/m68k/m680x0/fpu/bits/mathinline.h [__USE_MISC]:
	Likewise.
	* sysdeps/mach/hurd/bits/fcntl.h [__USE_MISC]: Likewise.
	* sysdeps/mach/hurd/bits/stat.h [__USE_MISC]: Likewise.
	* sysdeps/unix/sysv/linux/alpha/bits/sigaction.h [__USE_MISC]:
	Likewise.
	* sysdeps/unix/sysv/linux/alpha/bits/stat.h [__USE_MISC]:
	Likewise.
	* sysdeps/unix/sysv/linux/bits/fcntl-linux.h: Update #endif
	comments.
	[__USE_MISC]: Remove redundant conditionals.
	* sysdeps/unix/sysv/linux/bits/in.h [__USE_GNU]: Likewise.
	* sysdeps/unix/sysv/linux/bits/sigaction.h [__USE_MISC]: Likewise.
	* sysdeps/unix/sysv/linux/bits/socket.h [__USE_GNU]: Likewise.
	* sysdeps/unix/sysv/linux/bits/stat.h [__USE_MISC]: Likewise.
	* sysdeps/unix/sysv/linux/ia64/bits/sigaction.h [__USE_MISC]:
	Likewise.
	* sysdeps/unix/sysv/linux/m68k/bits/stat.h [__USE_MISC]: Likewise.
	* sysdeps/unix/sysv/linux/mips/bits/sigaction.h [__USE_MISC]:
	Likewise.
	* sysdeps/unix/sysv/linux/mips/bits/stat.h [__USE_MISC]: Likewise.
	* sysdeps/unix/sysv/linux/powerpc/bits/stat.h [__USE_MISC]:
	Likewise.
	* sysdeps/unix/sysv/linux/s390/bits/sigaction.h [__USE_MISC]:
	Likewise.
	* sysdeps/unix/sysv/linux/s390/bits/stat.h [__USE_MISC]: Likewise.
	* sysdeps/unix/sysv/linux/sparc/bits/sigaction.h [__USE_MISC]:
	Likewise.
	* sysdeps/unix/sysv/linux/sparc/bits/stat.h [__USE_MISC]:
	Likewise.
	* sysdeps/unix/sysv/linux/x86/bits/stat.h [__USE_MISC]: Likewise.
	* sysdeps/x86/bits/string.h: Update #endif comments.
	* sysdeps/x86/fpu/bits/mathinline.h [__USE_MISC]: Remove redundant
	conditionals.
	* time/sys/time.h: Update #endif comments.
	* time/time.h: Likewise.
	[__USE_MISC]: Remove redundant conditionals.
2014-02-21 21:45:26 +00:00
Joseph Myers 63689d6165 Move tests of clog10 from libm-test.inc to auto-libm-test-in.
This patch moves tests of clog10 to auto-libm-test-in.  Note that this
means gen-auto-libm-tests will now depend on the recent MPC 1.0.2
release which added a fix for a bug that made gen-auto-libm-tests hang
for clog10.  (It still can't conveniently be used for cacos cacosh
casin casinh catan catanh csin csinh because of extreme slowness of
those functions for special cases in MPC; at least some slow cases of
csin / csinh are fixed in MPC trunk, but not in a release.)

Tested x86_64 and x86 and ulps updated accordingly.

	* math/auto-libm-test-in: Add tests of clog10.
	* math/auto-libm-test-out: Regenerated.
	* math/libm-test.inc (clog10_test_data): Use AUTO_TESTS_c_c.
	* sysdeps/i386/fpu/libm-test-ulps: Update.
	* sysdeps/x86_64/fpu/libm-test-ulps: Likewise.
2014-02-19 14:26:29 +00:00
Joseph Myers c6af2d896c Move tests of fma from libm-test.inc to auto-libm-test-in.
This patch moves tests of fma to auto-libm-test-in, adding the
required support to gen-auto-libm-tests.

Because fma can have exact zero results depending on the rounding
mode, results of fma cannot always be determined from a single value
computed in higher precision with a sticky bit.  Thus, this patch adds
support for recomputing results with the original MPFR/MPC function in
the case where an exact zero is involved.  (This also affects some
results for cpow; when we start testing cpow in all rounding modes, I
think it will be most appropriate to make those tests use
IGNORE_ZERO_INF_SIGN, since ISO C does not attempt to determine signs
of zero results, or special caes in general, for cpow, and I think
signs of zero for cpow are beyond the scope of glibc's accuracy
goals.)

Simply treating the existing test inputs for fma like those for other
functions (i.e., as representing the given value rounded up or down to
any of the supported floating-point formats) increases the size of
auto-libm-test-out by about 16MB (i.e., about half the file is fma
test data).  While rounded versions of tests are perfectly reasonable
test inputs for fma, in this case having them seems excessive, so this
patch allows functions to specify in gen-auto-libm-tests that the
given test inputs are only to be interpreted exactly, not as
corresponding to values rounded up and down.  This reduces the size of
the generated test data for fma to a more reasonable 2MB.

A consequence of this patch is that fma is now tested for correct
presence or absence of "inexact" exceptions, where previously this
wasn't tested because I didn't want to try to add that test coverage
manually to all the existing tests.  As far as I know, the existing
fma implementations are already correct in this regard.

This patch provides the first cases where the gen-auto-libm-tests
support for distinguishing before-rounding/after-rounding underflow
actually produces separate entries in auto-libm-test-out (for
functions without exactly determined results, the affected cases are
all considered underflow-optional, so this only affects functions like
fma with exactly determined results).  I didn't see any signs of
problems with this logic in the output.

Tested x86_64 and x86.

	* math/auto-libm-test-in: Add tests of fma.
	* math/auto-libm-test-out: Regenerated.
	* math/libm-test.inc (fma_test_data): Use AUTO_TESTS_fff_f.
	(fma_towardzero_test_data): Likewise.
	(fma_downward_test_data): Likewise.
	(fma_upward_test_data): Likewise.
	* math/gen-auto-libm-tests.c (rounding_mode_desc): Add field
	mpc_mode.
	(rounding_modes): Add values for new field.
	(func_calc_method): Add value mpfr_fff_f.
	(func_calc_desc): Add mpfr_fff_f union field.
	(test_function): Add field exact_args.
	(FUNC): Add macro argument EXACT_ARGS.
	(FUNC_mpfr_f_f): Update call to FUNC.
	(FUNC_mpfr_f_f): Likewise.
	(FUNC_mpfr_ff_f): Likewise.
	(FUNC_mpfr_if_f): Likewise.
	(FUNC_mpc_c_f): Likewise.
	(FUNC_mpc_c_c): Likewise.
	(test_functions): Add fma.  Update calls to FUNC.
	(handle_input_arg): Add argument exact_args.
	(add_test): Update call to handle_input_arg.
	(calc_generic_results): Add argument mode.  Handle mpfr_fff_f.
	(output_for_one_input_case): Update call to calc_generic_results.
	Recalculate exact zero results in each rounding mode.
2014-02-18 21:48:51 +00:00
Joseph Myers a4fb786185 Fix gen-auto-libm-tests sticky bit setting for negative results.
gen-auto-libm-tests has a bug in the logic for setting a sticky bit
based on the ternary value from MPFR: it is correct for positive
results, but for negative results mpz_setbit acts as if a two's
complement representation is used, whereas the low bit needs setting
based on the sign-magnitude representation GMP actually uses.  (This
showed up in converting fma tests to use auto-libm-test-in /
gen-auto-libm-tests.)

This patch fixes the problem by negating the mpz_t value to set its
low bit.  There are lots of changes to auto-libm-test-out (mainly 1ulp
fixes to ldbl-128 expected results), but only a few ulps updates are
needed on x86 / x86_64.  In one case, a corrected expectation showed
up a spurious underflow exception where the correct result is slightly
outside the underflowing range.

Tested x86_64 and x86 and ulps updated accordingly.

	* math/gen-auto-libm-tests.c (adjust_real): Ensure integers are
	non-negative before setting low bit.
	* math/auto-libm-test-in: Mark one asin test possibly having
	spurious underflow.
	* math/auto-libm-test-out: Regenerated.
	* sysdeps/i386/fpu/libm-test-ulps: Update.
	* sysdeps/x86_64/fpu/libm-test-ulps: Likewise.
2014-02-18 14:45:41 +00:00
Joseph Myers 498afc54df Combine __USE_BSD and __USE_SVID into __USE_MISC.
This patch cleans up following the obsoletion of _BSD_SOURCE and
_SVID_SOURCE by combining __USE_BSD and __USE_SVID into __USE_MISC.

The only non-mechanical part of this patch is the changes to
features.h; everything else is simple substitution of __USE_MISC for
the old macros.  Thus, this patch leaves obviously redundant
conditionals such as "defined __USE_MISC || defined __USE_MISC", and
does not update #endif comments where they referred to BSD or SVID in
words instead of the literal macro name.  This is intended to
facilitate patch review by separating the less mechanical changes from
these purely mechanical changes into a separate patch.  (I do intend
to integrate all the changes from
<https://sourceware.org/ml/libc-alpha/2013-12/msg00226.html>, which I
believe includes all the trailing comment updates, in subsequent
patches.)

Tested x86_64.

	* include/features.h (__USE_BSD): Remove macro definitions.
	(__USE_SVID): Likewise.
	(_BSD_SOURCE): Likewise.
	(_SVID_SOURCE): Likewise.
	[!defined _BSD_SOURCE && !defined _SVID_SOURCE]: Remove condition
	from definition of _DEFAULT_SOURCE.
	[_BSD_SOURCE || _SVID_SOURCE]: Change condition to
	[_DEFAULT_SOURCE].
	* bits/fcntl.h [__USE_BSD]: Change condition to [__USE_MISC].
	* bits/mman.h [__USE_BSD]: Likewise.
	* bits/termios.h [__USE_BSD]: Likewise.
	* bits/waitstatus.h [__USE_BSD]: Likewise.
	* ctype/ctype.h [__USE_SVID]: Likewise.
	* dirent/dirent.h [__USE_BSD]: Likewise.
	* grp/grp.h [__USE_SVID]: Likewise.
	[__USE_BSD]: Likewise.
	* inet/netinet/igmp.h [__USE_BSD]: Likewise.
	* io/fcntl.h [__USE_BSD]: Likewise.
	* io/ftw.h [__USE_BSD]: Likewise.
	* io/sys/stat.h [__USE_BSD]: Likewise.
	* libio/bits/stdio-ldbl.h [__USE_BSD]: Likewise.
	* libio/bits/stdio2.h [__USE_BSD]: Likewise.
	* libio/stdio.h [__USE_SVID]: Likewise.
	[__USE_BSD]: Likewise.
	* math/math.h [__USE_SVID]: Likewise.
	[__USE_BSD]: Likewise.
	* misc/bits/syslog-ldbl.h [__USE_BSD]: Likewise.
	* misc/bits/syslog.h [__USE_BSD]: Likewise.
	* misc/search.h [__USE_SVID]: Likewise.
	* misc/sys/mman.h [__USE_BSD]: Likewise.
	* misc/sys/syslog.h [__USE_BSD]: Likewise.
	* misc/sys/uio.h [__USE_BSD]: Likewise.
	* posix/bits/unistd.h [__USE_BSD]: Likewise.
	* posix/glob.h [__USE_BSD]: Likewise.
	* posix/regex.h [__USE_BSD]: Likewise.
	* posix/sys/types.h [__USE_BSD]: Likewise.
	[__USE_SVID]: Likewise.
	* posix/sys/utsname.h [__USE_SVID]: Likewise.
	* posix/sys/wait.h [__USE_BSD]: Likewise.
	[__USE_SVID]: Likewise.
	* posix/unistd.h [__USE_BSD]: Likewise.
	[__USE_SVID]: Likewise.
	* pwd/pwd.h [__USE_SVID]: Likewise.
	* resolv/netdb.h [__USE_BSD]: Likewise.
	* setjmp/setjmp.h [__USE_BSD]: Likewise.
	* signal/signal.h [__USE_BSD]: Likewise.
	[__USE_SVID]: Likewise.
	* socket/sys/socket.h [__USE_BSD]: Likewise.
	* stdlib/fmtmsg.h [__USE_SVID]: Likewise.
	* stdlib/stdlib.h [__USE_BSD]: Likewise.
	[__USE_SVID]: Likewise.
	* string/bits/string2.h [__USE_BSD]: Likewise.
	[__USE_SVID]: Likewise.
	* string/bits/string3.h [__USE_BSD]: Likewise.
	* string/endian.h [__USE_BSD]: Likewise.
	* string/string.h [__USE_SVID]: Likewise.
	[__USE_BSD]: Likewise.
	* string/strings.h [__USE_BSD]: Likewise.
	* sysdeps/generic/netinet/ip.h [__USE_BSD]: Likewise.
	* sysdeps/gnu/netinet/ip_icmp.h [__USE_BSD]: Likewise.
	* sysdeps/mach/hurd/bits/fcntl.h [__USE_BSD]: Likewise.
	* sysdeps/mach/hurd/bits/stat.h [__USE_BSD]: Likewise.
	* sysdeps/unix/sysv/linux/alpha/bits/mman.h [__USE_BSD]: Likewise.
	* sysdeps/unix/sysv/linux/alpha/bits/termios.h [__USE_BSD]:
	Likewise.
	* sysdeps/unix/sysv/linux/bits/fcntl-linux.h [__USE_BSD]:
	Likewise.
	* sysdeps/unix/sysv/linux/bits/mman-linux.h [__USE_BSD]: Likewise.
	* sysdeps/unix/sysv/linux/bits/sys_errlist.h [__USE_BSD]:
	Likewise.
	* sysdeps/unix/sysv/linux/bits/termios.h [__USE_BSD]: Likewise.
	* sysdeps/unix/sysv/linux/mips/bits/termios.h [__USE_BSD]:
	Likewise.
	* sysdeps/unix/sysv/linux/netinet/if_ether.h [__USE_BSD]:
	Likewise.
	* sysdeps/unix/sysv/linux/netinet/if_fddi.h [__USE_BSD]: Likewise.
	* sysdeps/unix/sysv/linux/netinet/if_tr.h [__USE_BSD]: Likewise.
	* sysdeps/unix/sysv/linux/powerpc/bits/termios.h [__USE_BSD]:
	Likewise.
	* sysdeps/unix/sysv/linux/sparc/bits/termios.h [__USE_BSD]:
	Likewise.
	* sysdeps/x86/bits/string.h [__USE_BSD]: Likewise.
	* sysvipc/sys/ipc.h [__USE_SVID]: Likewise.
	* termios/termios.h [__USE_BSD]: Likewise.
	* time/sys/time.h [__USE_BSD]: Likewise.
	* time/time.h [__USE_BSD]: Likewise.
	[__USE_SVID]: Likewise.

	* sysdeps/unix/sysv/linux/hppa/bits/mman.h [__USE_BSD]: Change
	condition to [__USE_MISC].
2014-02-12 23:41:01 +00:00
Joseph Myers c941736c92 Remove _BSD_SOURCE and _SVID_SOURCE.
This is a minimal patch to remove _BSD_SOURCE and _SVID_SOURCE from
the documented user API, making them into aliases for _DEFAULT_SOURCE
with a #warning given, but keeping most of the features.h logic using
those macros and all the exising __USE_* conditionals, on the basis
that all the consequent cleanups will go in followup patches.

Tested x86_64.

	* include/features.h: Update comment documenting feature test
	macros.
	[_BSD_SOURCE || _SVID_SOURCE]: Give #warning.  Define
	_DEFAULT_SOURCE.
	* manual/creature.texi (_BSD_SOURCE): Remove documentation.
	(_SVID_SOURCE): Likewise.
	(_DEFAULT_SOURCE): Update description of default features.
	(Feature Test Macros): Don't mention _SVID_SOURCE in conjunction
	with _GNU_SOURCE.
	* manual/filesys.texi (__ftw_func_t): Do not refer to _BSD_SOURCE.
	(S_ISVTX): Likewise.
	* manual/math.texi (Mathematical Constants): Likewise.
	* manual/signal.texi (Interrupted Primitives): Likewise.
	* manual/startup.texi (putenv): Do not refer to _SVID_SOURCE.
	* math/test-matherr.c (_SVID_SOURCE): Do not define.
	* sysvipc/sys/ipc.h [__USE_SVID && !__USE_XOPEN && __GNUC__ >= 2]:
	Don't refer to _SVID_SOURCE in warning text.
2014-02-11 23:40:07 +00:00
Andreas Krebbel 7e6424e343 BZ #16447: Fix ldbl-128 expl implementation.
Extend the range of numbers handled via unsafe mode.
Add expl testcase and regenerate ULPs for s390.
2014-02-11 13:47:47 +01:00
Ondřej Bílka a1ffb40e32 Use glibc_likely instead __builtin_expect. 2014-02-10 15:07:12 +01:00
Andreas Schwab 1c0d11bce5 Let gen-libm-test.pl find itself when run outside source directory 2014-01-27 18:43:22 +01:00
Joseph Myers 94d0cea0ad Fix math/test-fpucw-*.c for sysdeps test-fpucw.c overrides.
ARM has an override of the test math/test-fpucw.c, to disable (for
soft-float testing) definitions of hard-float macros in fpu_control.h
that the header normally defines not only when building for
hard-float, but also when building for soft-float with _LIBC defined
so that libc code can dynamically test whether VFP hardware is
present.  (_LIBC is defined when building tests, although ideally it
wouldn't be.)

The override doesn't work for the derived tests test-fpucw-*.c because
they use #include "" instead of <> to include test-fpucw.c, so always
get the math/ version instead of the ARM sysdeps override.  This patch
changes them to use <> so the sysdeps override is effective.
(test-fpucw-ieee-static.c doesn't need a change because it includes
test-fpucw-ieee.c, which isn't itself being overridden, which in turn
includes test-fpucw.c with a #include changed by this patch.)

Tested for ARM (big-endian soft-float, non-VFP hardware).

	* math/test-fpucw-ieee.c: Use <> in #include of test-fpucw.c.
	* math/test-fpucw-static.c: Likewise.
2014-01-16 05:30:52 +00:00
Joseph Myers a5a326f660 Mark more libm tests with xfail-rounding:ldbl-128ibm.
This patch marks more libm tests as expected to fail for ldbl-128ibm
in non-default rounding modes.  Given this, my expm1l fix
<https://sourceware.org/ml/libc-alpha/2014-01/msg00135.html> and my
libgcc fix <http://gcc.gnu.org/ml/gcc-patches/2014-01/msg00157.html>
for spurious overflows, the remaining failures in test-ldouble.out
(for powerpc32 hard float) are small ulps, spurious underflow and
inexact exceptions (the former probably arising from libgcc bugs
though I haven't checked each case; the latter are barely meaningful
for this format anyway when basic arithmetic isn't correctly rounding,
though most of them are probably GCC bug 59412 which doesn't actually
involve long double), missing underflow exceptions from clog, ctan and
ctanh (probably one of the known bugs for another function), and logb
in round-downward mode (bug 887, though it's really a GCC bug that
we're not currently working around).

Tested for powerpc32 hard float.

	* math/auto-libm-test-in: Mark various tests with
	xfail-rounding:ldbl-128ibm.
	* math/auto-libm-test-out: Regenerated.
2014-01-07 22:41:58 +00:00
Joseph Myers 7dd009d865 Mark various libm tests with xfail-rounding:ldbl-128ibm.
This patch marks various libm tests with xfail-rounding:ldbl-128ibm,
where the failures appear to relate to GCC bug 59666 (bad libgcc
handling of directed rounding), so as to allow clean libm-test-ulps
regeneration without needing to edit out large ulps for various
functions manually.

Note that this only deals with the cases problematic for ulps
regeneration.  There are plenty of test failures left that do not
affect ulps regeneration - results that are infinities or NaNs but
should be finite, or vice versa, and missing and spurious exceptions -
which should also be resolved during the release testing period.

Tested for powerpc32 (hard float).

	* math/auto-libm-test-in: Mark various tests with
	xfail-rounding:ldbl-128ibm.
	* math/auto-libm-test-out: Regenerated.
2014-01-03 17:08:10 +00:00
Allan McRae d4697bc93d Update copyright notices with scripts/update-copyrights 2014-01-01 22:00:23 +10:00
Joseph Myers 5b0626b9c5 Fix x86 / x86_64 expl / expl10l wild results in directed rounding modes (bug 16356).
This patch fixes bug 16356, bad results from x86 / x86_64 expl /
exp10l in directed rounding modes, the most serious of the bugs shown
up by my patch expanding libm test coverage.  When I fixed bug 16293,
I thought it was only necessary to set round-to-nearest when using
frndint in expm1 functions, because in other cases the cancellation
error from having the resulting fractional part close to 1 or -1 would
not be significant.  However, in expl and exp10l, the way the final
fractional part gets computed (something more complicated than a
simple subtraction, because more precision is needed than you'd get
that way) can result in a value outside the range [-1, 1] when the
argument to frndint was very close to an integer and was rounded the
"wrong" way because of the rounding mode - and the f2xm1 instruction
has undefined results if its argument is outside [-1, 1], so resulting
in the large errors seen.  So this patch removes the USE_AS_EXPM1L
conditionals on the round-to-nearest settings, so all of expl, expm1l
and exp10l now get round-to-nearest used for frndint (meaning the
final fractional part can at most be slightly above 0.5 in
magnitude).  Associated tests of exp and exp10 are added and testing
of exp10 in directed rounding modes enabled.

Tested x86_64 and x86 and ulps updated accordingly.

	* sysdeps/i386/fpu/e_expl.S (IEEE754_EXPL): Also set
	round-to-nearest for [!USE_AS_EXPM1L].
	* sysdeps/x86_64/fpu/e_expl.S (IEEE754_EXPL): Likewise.
	* math/auto-libm-test-in: Do not expect cosh tests to fail.  Add
	more tests of exp and exp10.  Expect some exp10 tests to miss
	exceptions or fail in directed rounding modes.
	* math/auto-libm-test-out: Regenerated.
	* math/libm-test.inc (exp10_tonearest_test_data): New array.
	(exp10_test_tonearest): New function.
	(exp10_towardzero_test_data): New array.
	(exp10_test_towardzero): New function.
	(exp10_downward_test_data): New array.
	(exp10_test_downward): New function.
	(exp10_upward_test_data): New array.
	(exp10_test_upward): New function.
	(main): Call the new functions.
	* sysdeps/i386/fpu/libm-test-ulps: Update.
	* sysdeps/x86_64/fpu/libm-test-ulps: Likewise.
2013-12-21 13:07:16 +00:00
Joseph Myers 31e3a40588 Add more libm-test coverage of [a-c]* real functions.
Various libm functions have inadequate test coverage in libm-test.inc
/ auto-libm-test-in - failing to cover all the usual special cases
(infinities, NaNs, zero, large and small finite values, subnormals) as
well as a reasonable range of ordinary inputs and, where appropriate,
inputs close to the thresholds for underflow and overflow.

This patch improves test coverage for real functions [a-c]* (with the
expectation of adding more coverage for other functions later).

Tested x86_64 and x86 and ulps updated accordingly (and eight glibc
bugs and one C11 DR filed for issues found in the process).

	* math/auto-libm-test-in: Add more tests of acos, acosh, asin,
	asinh, atan, atan2, atanh, cbrt, cos and cosh.
	* math/auto-libm-test-out: Regenerated.
	* math/libm-test.inc (acosh_test_data): Add more tests.
	(atanh_test_data): Likewise.
	(ceil_test_data): Likewise.
	(copysign_test_data): Likewise.
	* sysdeps/i386/fpu/libm-test-ulps: Update.
	* sysdeps/x86_64/fpu/libm-test-ulps: Likewise.
2013-12-20 21:03:39 +00:00
Joseph Myers b7867a3bfb Move tests of cpow from libm-test.inc to auto-libm-test-in.
This patch moves tests of cpow to auto-libm-test-in, adding the
required support to gen-auto-libm-tests.

Tested x86_64 and x86 and ulps updated accordingly.

	* math/auto-libm-test-in: Add tests of cpow.
	* math/auto-libm-test-out: Regenerated.
	* math/libm-test.inc (cpow_test_data): Use AUTO_TESTS_cc_c.
	* * math/gen-auto-libm-tests.c (func_calc_method): Add value
	mpc_cc_c.
	(func_calc_desc): Add mpc_cc_c union field.
	(test_functions): Add cpow.
	(special_fill_2pi): New function.
	(special_real_inputs): Add 2pi.
	(calc_generic_results): Handle mpc_cc_c.
	* sysdeps/i386/fpu/libm-test-ulps: Update.
	* sysdeps/x86_64/fpu/libm-test-ulps: Likewise.
2013-12-20 12:35:10 +00:00
Joseph Myers 7fda568229 Move various TEST_c_c tests from libm-test.inc to auto-libm-test-inc.
This patch moves tests of ccos, ccosh, cexp, clog, csqrt, ctan and
ctanh to auto-libm-test-in, adding the required support to
gen-auto-libm-tests.  Other TEST_c_c functions aren't moved for now
(although the relevant table entries are put in gen-auto-libm-tests
for it to know how to handle them): clog10 because of a known MPC bug
causing it to hang for at least some pure imaginary inputs (fixed in
SVN, but I'd rather not rely on unreleased versions of MPFR or MPC
even if relying on very recent releases); the inverse trig and
hyperbolic functions because of known slowness in special cases; and
csin / csinh because of observed slowness that I need to investigate
and report to the MPC maintainers.  Slowness can be bypassed by moving
to incremental generation (only for new / changed tests) rather than
regenerating the whole of auto-libm-test-out every time, but that
needs implementing.  (This patch takes the time for running
gen-auto-libm-tests from about one second to seven, on my system,
which I think is reasonable.  The slow functions would make it take
several minutes at least, which seems unreasonable.)

Tested x86_64 and x86 and ulps updated accordingly.

	* math/auto-libm-test-in: Add tests of ccos, ccosh, cexp, clog,
	csqrt, ctan and ctanh.
	* math/auto-libm-test-out: Regenerated.
	* math/libm-test.inc (TEST_COND_x86_64): New macro.
	(TEST_COND_x86): Likewise.
	(ccos_test_data): Use AUTO_TESTS_c_c.
	(ccosh_test_data): Likewise.
	(cexp_test_data): Likewise.
	(clog_test_data): Likewise.
	(csqrt_test_data): Likewise.
	(ctan_test_data): Likewise.
	(ctan_tonearest_test_data): Likewise.
	(ctan_towardzero_test_data): Likewise.
	(ctan_downward_test_data): Likewise.
	(ctan_upward_test_data): Likewise.
	(ctanh_test_data): Likewise.
	(ctanh_tonearest_test_data): Likewise.
	(ctanh_towardzero_test_data): Likewise.
	(ctanh_downward_test_data): Likewise.
	(ctanh_upward_test_data): Likewise.
	* math/gen-auto-libm-tests.c (func_calc_method): Add value
	mpc_c_c.
	(func_calc_desc): Add mpc_c_c union field.
	(FUNC_mpc_c_c): New macro.
	(test_functions): Add cacos, cacosh, casin, casinh, catan, catanh,
	ccos, ccosh, cexp, clog, clog10, csin, csinh, csqrt, ctan and
	ctanh.
	(special_fill_min_subnorm_p120): New function.
	(special_real_inputs): Add min_subnorm_p120.
	(calc_generic_results): Handle mpc_c_c.
	* sysdeps/i386/fpu/libm-test-ulps: Update.
	* sysdeps/x86_64/fpu/libm-test-ulps: Likewise.
2013-12-20 12:32:44 +00:00
Joseph Myers 64a17f1add Move tests of cabs and carg from libm-test.inc to auto-libm-test-in.
This patch moves tests of cabs and carg to auto-libm-test-in, adding
the required support to gen-auto-libm-tests.

Tested x86_64 and x86; no ulps updates needed.

	* math/auto-libm-test-in: Add tests of cabs and carg.
	* math/auto-libm-test-out: Regenerated.
	* math/libm-test.inc (cabs_test_data): Use AUTO_TESTS_c_f.
	(carg_test_data): Likewise.
	* math/gen-auto-libm-tests.c (func_calc_method): Add value
	mpc_c_f.
	(func_calc_desc): Add mpc_c_f union field.
	(test_functions): Add cabs and carg.
	(calc_generic_results): Handle mpc_c_f.
2013-12-19 21:28:30 +00:00
Joseph Myers 6f6fc48226 Move tests of sincos from libm-test.inc to auto-libm-test-in.
This patch moves tests of sincos to auto-libm-test-in, adding the
required support to gen-auto-libm-tests.

Tested x86_64 and x86 and ulps updated accordingly.

(auto-libm-test-out diffs omitted below.)

	* math/auto-libm-test-in: Add tests of sincos.
	* math/auto-libm-test-out: Regenerated.
	* math/libm-test.inc (sincos_test_data): Use AUTO_TESTS_fFF_11.
	* math/gen-auto-libm-tests.c (func_calc_method): Add value
	mpfr_f_11.
	(func_calc_desc): Add mpfr_f_11 union field.
	(test_functions): Add sincos.
	(calc_generic_results): Handle mpfr_f_11.
	* sysdeps/i386/fpu/libm-test-ulps: Update.
	* sysdeps/x86_64/fpu/libm-test-ulps: Likewise.
2013-12-19 17:21:01 +00:00
Joseph Myers 335ee09231 Disable libm-test test name beautification for M_* constants.
math/gen-libm-test.pl has code to beautify names of various constants,
transforming the source form in libm-test.inc into the version
appearing in test names in libm-test-ulps files.

This has become decreasingly relevant over time for the M_* constants,
first as I changed the test names so only the arguments and not the
expected results appeared in them, then as tests have moved to
auto-libm-test-* so that automatically generated hex float constants
get used instead of M_* in test inputs.

This patch removes the beautification for all M_* constants.  Tested
x86_64 and x86 and ulps updated accordingly.  Even the one case where
this affected the name in the ulps files will disappear once complex
function tests are moved to auto-libm-test-*.

	* math/gen-libm-test.pl (%beautify): Remove M_* constants.
	* sysdeps/i386/fpu/libm-test-ulps: Update.
	* sysdeps/x86_64/fpu/libm-test-ulps: Likewise.
2013-12-19 14:59:22 +00:00
Joseph Myers f88acd39da Fix x86/x86_64 expm1 inaccuracy near 0 in directed rounding modes (bug 16293).
Bug 16293 is inaccuracy of x86/x86_64 versions of expm1, near 0 in
directed rounding modes, that arises from frndint rounding the
exponent to 1 or -1 instead of 0, resulting in large cancellation
error.  This inaccuracy in turn affects other functions such as sinh
that use expm1.  This patch fixes the problem by setting
round-to-nearest mode temporarily around the affected calls to
frndint.  I don't think this is needed for other uses of frndint, such
as in exp itself, as only for expm1 is the cancellation error
significant.

Tested x86_64 and x86 and ulps updated accordingly.

	* sysdeps/i386/fpu/e_expl.S (IEEE754_EXPL) [USE_AS_EXPM1L]: Set
	round-to-nearest mode when using frndint.
	* sysdeps/i386/fpu/s_expm1.S (__expm1): Likewise.
	* sysdeps/i386/fpu/s_expm1f.S (__expm1f): Likewise.
	* sysdeps/x86_64/fpu/e_expl.S (IEEE754_EXPL) [USE_AS_EXPM1L]:
	Likewise.
	* math/auto-libm-test-in: Add more tests of expm1.  Do not expect
	sinh test to fail.
	* math/auto-libm-test-out: Regenerated.
	* math/libm-test.inc (TEST_COND_x86_64): Remove macro.
	(TEST_COND_x86): Likewise.
	(expm1_tonearest_test_data): New array.
	(expm1_test_tonearest): New function.
	(expm1_towardzero_test_data): New array.
	(expm1_test_towardzero): New function.
	(expm1_downward_test_data): New array.
	(expm1_test_downward): New function.
	(expm1_upward_test_data): New array.
	(expm1_test_upward): New function.
	(main): Run the new test functions.
	* sysdeps/i386/fpu/libm-test-ulps: Update.
	* sysdeps/x86_64/fpu/libm-test-ulps: Likewise.
2013-12-19 13:36:10 +00:00
Joseph Myers f889953b44 Move tests of jn and yn from libm-test.inc to auto-libm-test-in.
This patch moves tests of jn and yn to auto-libm-test-in, adding the
required support for gen-auto-libm-tests (and adding a missing
assertion there and fixing logic that was broken for functions with
integer arguments).

Tested x86_64 and x86 and ulps updated accordingly.

	* math/auto-libm-test-in: Add tests of jn and yn.
	* math/auto-libm-test-out: Regenerated.
	* math/libm-test.inc (jn_test_data): Use AUTO_TESTS_if_f.
	(yn_test_data): Likewise.
	* math/gen-auto-libm-tests.c (func_calc_method): Add value
	mpfr_if_f.
	(func_calc_desc): Add mpfr_if_f union field.
	(FUNC_mpfr_if_f): New macro.
	(test_functions): Add jn and yn.
	(calc_generic_results): Assert type of second input for
	mpfr_ff_f.  Handle mpfr_if_f.
	(output_for_one_input_case): Disable all checking for arguments
	fitting floating-point types in case of an integer argument.
	* sysdeps/i386/fpu/libm-test-ulps: Update.
	* sysdeps/x86_64/fpu/libm-test-ulps: Likewise.
2013-12-18 17:59:29 +00:00
Joseph Myers 5953eb3ad7 Mark some hypot tests no-test-inline.
As needed on x86.

	* math/auto-libm-test-in: Mark some hypot tests no-test-inline.
	* math/auto-libm-test-out: Regenerated.
2013-12-18 11:46:16 +00:00
Joseph Myers 2dec468fd8 Fix ldbl-128 logl for subnormals (bug 16338).
This patch fixes bug 16338, ldbl-128 logl not handling subnormals
(with consequent inaccuracy for lgammal as well).  The fix is simply
to use __frexpl when determining the exponent, as done already in
log2l and log10l.  Given the lack of testing of small arguments to any
of the log* functions, appropriate tests are added for all of them.

Tested x86_64 and x86 and ulps updated accordingly, and spot tests
also run for mips64 to confirm the ldbl-128 fix.

Note that while this fixes lgammal inaccuracy for small positive
arguments, I suspect that there will still be problems with spurious
underflows in that case.

	* sysdeps/ieee754/ldbl-128/e_logl.c (__ieee754_logl): Use __frexpl
	to determine exponent and adjust argument to have exponent of -1.
	* math/auto-libm-test-in: Add more tests of log, log10, log1p and
	log2.
	* math/auto-libm-test-out: Regenerated.
	* sysdeps/x86_64/fpu/libm-test-ulps: Update.
2013-12-18 11:38:27 +00:00
Joseph Myers 6432a5409c Fix dbl-64 hypot spurious underflows (bug 16314). 2013-12-17 13:43:40 +00:00
Joseph Myers c88769dda4 Fix hypot handling of subnormals (bug 16316, bug 16330). 2013-12-17 13:42:13 +00:00
Joseph Myers ff362e5b93 Move tests of atan2, hypot and pow from libm-test.inc to auto-libm-test-in. 2013-12-16 21:18:07 +00:00
Joseph Myers 9f0be4f8b5 Move tests of lgamma from libm-test.inc to auto-libm-test-in. 2013-12-08 23:56:28 +00:00
Joseph Myers e47cc4e0ed Fix tgamma errno setting on underflow (bug 6810). 2013-12-05 14:01:41 +00:00
Joseph Myers bbf37bdc12 Move TEST_f_f tests for [l-y]* functions from libm-test.inc to auto-libm-test-in. 2013-12-05 13:54:50 +00:00
Joseph Myers 699ff83712 Fix Bessel function error handling (bug 6807, bug 15901). 2013-12-04 14:39:37 +00:00
Joseph Myers 749008ff03 Fix exp missing underflows (bug 15268, bug 15425). 2013-12-03 21:49:56 +00:00
Joseph Myers 17dea1887f Fix exp2 errno setting on underflow (bug 16283). 2013-12-03 20:50:51 +00:00
Joseph Myers 34e16df5a1 Fix erfc errno setting on underflow (bug 6786). 2013-12-03 16:25:18 +00:00
Joseph Myers d8e2dbe3e3 Move TEST_f_f tests for [e-j]* functions from libm-test.inc to auto-libm-test-in. 2013-12-03 16:22:49 +00:00
Joseph Myers 176b0c7913 Move TEST_f_f tests for [a-c]* functions from libm-test.inc to auto-libm-test-in. 2013-11-30 22:04:13 +00:00
Joseph Myers 2a77a467b2 Fix exp10 errno setting on underflow (bug 6787). 2013-11-29 16:32:49 +00:00
Joseph Myers ea3bc4e821 Fix x86 sqrt rounding (bug 14032). 2013-11-29 16:31:16 +00:00
Joseph Myers 0712c9d861 Test sqrt in all rounding modes. 2013-11-29 16:28:47 +00:00
Joseph Myers ffb536d0ac Start generating libm tests automatically with MPFR. 2013-11-29 16:27:55 +00:00
Joseph Myers 3c1c46a64a Fix dbl-64 e_sqrt.c for non-default rounding modes (bug 16271). 2013-11-28 16:50:38 +00:00
Joseph Myers 73c1ce4fdb Make powerpc-nofpu floating-point state thread-local (bug 15483). 2013-11-19 13:39:56 +00:00
Chris Metcalf e186536b6f test-fpucw-ieee: Don't use _FPU_IEEE if not defined
Not all architectures define this value, and if they don't,
just let the test run the same as test-fpucw, with __fpu_control
set to _FPU_DEFAULT explicitly.
2013-11-18 18:19:02 -05:00
Joseph Myers ce66581742 Test signs of NaNs in libm-test.inc where appropriate. 2013-11-16 12:48:35 +00:00
Joseph Myers ee1466a953 Add libm-test support for ignored return value, add more lrint / llrint / lround / llround tests. 2013-11-16 12:47:38 +00:00
Joseph Myers 14407b7e60 Replace libm-test.inc TEST_INLINE conditionals with NO_TEST_INLINE flag. 2013-11-16 12:46:52 +00:00
Joseph Myers ca07f1973b Make libm-test.inc check for "inexact" exceptions for NaN argument. 2013-11-16 12:46:03 +00:00
Alan Modra 650ef4bd79 PowerPC floating point little-endian [4 of 15]
http://sourceware.org/ml/libc-alpha/2013-08/msg00084.html

Another batch of ieee854 macros and union replacement.  These four
files also have bugs fixed with this patch.  The fact that the two
doubles in an IBM long double may have different signs means that
negation and absolute value operations can't just twiddle one sign bit
as you can with ieee864 style extended double.  fmodl, remainderl,
erfl and erfcl all had errors of this type.  erfl also returned +1 for
large magnitude negative input where it should return -1.  The hypotl
error is innocuous since the value adjusted twice is only used as a
flag.  The e_hypotl.c tests for large "a" and small "b" are mutually
exclusive because we've already exited when x/y > 2**120.  That allows
some further small simplifications.

	[BZ #15734], [BZ #15735]
	* sysdeps/ieee754/ldbl-128ibm/e_fmodl.c (__ieee754_fmodl): Rewrite
	all uses of ieee875 long double macros and unions.  Simplify test
	for 0.0L.  Correct |x|<|y| and |x|=|y| test.  Use
	ldbl_extract_mantissa value for ix,iy exponents.  Properly
	normalize after ldbl_extract_mantissa, and don't add hidden bit
	already handled.  Don't treat low word of ieee854 mantissa like
	low word of IBM long double and mask off bit when testing for
	zero.
	* sysdeps/ieee754/ldbl-128ibm/e_hypotl.c (__ieee754_hypotl): Rewrite
	all uses of ieee875 long double macros and unions.  Simplify tests
	for 0.0L and inf.  Correct double adjustment of k.  Delete dead code
	adjusting ha,hb.  Simplify code setting kld.  Delete two600 and
	two1022, instead use their values.  Recognise that tests for large
	"a" and small "b" are mutually exclusive.  Rename vars.  Comment.
	* sysdeps/ieee754/ldbl-128ibm/e_remainderl.c (__ieee754_remainderl):
	Rewrite all uses of ieee875 long double macros and unions.  Simplify
	test for 0.0L and nan.  Correct negation.
	* sysdeps/ieee754/ldbl-128ibm/s_erfl.c (__erfl): Rewrite all uses of
	ieee875 long double macros and unions.  Correct output for large
	magnitude x.  Correct absolute value calculation.
	(__erfcl): Likewise.
	* math/libm-test.inc: Add tests for errors discovered in IBM long
	double versions of fmodl, remainderl, erfl and erfcl.
2013-10-04 10:32:48 +09:30
Alan Modra 1b6adf888d PowerPC floating point little-endian [1 of 15]
http://sourceware.org/ml/libc-alpha/2013-08/msg00081.html

This is the first of a series of patches to ban ieee854_long_double
and the ieee854_long_double macros when using IBM long double.  union
ieee854_long_double just isn't correct for IBM long double, especially
when little-endian, and pretending it is OK has allowed a number of
bugs to remain undetected in sysdeps/ieee754/ldbl-128ibm/.

This changes the few places in generic code that use it.

	* stdio-common/printf_size.c (__printf_size): Don't use
	union ieee854_long_double in fpnum union.
	* stdio-common/printf_fphex.c (__printf_fphex): Likewise.  Use
	signbit macro to retrieve sign from long double.
	* stdio-common/printf_fp.c (___printf_fp): Use signbit macro to
	retrieve sign from long double.
	* sysdeps/ieee754/ldbl-128ibm/printf_fphex.c: Adjust for fpnum change.
	* sysdeps/ieee754/ldbl-128/printf_fphex.c: Likewise.
	* sysdeps/ieee754/ldbl-96/printf_fphex.c: Likewise.
	* sysdeps/x86_64/fpu/printf_fphex.c: Likewise.
	* math/test-misc.c (main): Don't use union ieee854_long_double.
ports/
	* sysdeps/ia64/fpu/printf_fphex.c: Adjust for fpnum change.
2013-10-04 10:31:41 +09:30
Siddhesh Poyarekar cfa3c8865f New test cases for sin and cos for multiple precision fallback 2013-09-19 16:54:24 +05:30
Maciej W. Rozycki 95e7cf295e Fix static-binary lazy FPU context allocation
Long ago static startup did not parse the auxiliary vector and therefore
could not get at any `AT_FPUCW' tag to check whether upon FPU context
allocation the kernel would use a FPU control word setting different to
that provided by the `__fpu_control' variable.  Static startup therefore
always initialized the FPU control word, forcing immediate FPU context
allocation even for binaries that otherwise never used the FPU.

As from GIT commit f8f900ecb9 static
startup supports parsing the auxiliary vector, so now it can avoid
explicit initialization of the FPU control word, just as can dynamic
startup, in the usual case where the setting written to the FPU control
word would be the same as the kernel uses.  This defers FPU context
allocation until the binary itself actually pokes at the FPU.

Note that the `AT_FPUCW' tag is usually absent from the auxiliary vector
in which case _FPU_DEFAULT is assumed to be the kernel default.
2013-09-09 22:36:57 +01:00
Joseph Myers ffa3cd7f1a Fix lgammaf spurious underflow (bug 15427). 2013-09-03 15:32:54 +00:00
Joseph Myers b7835e3223 Fix spurious jnf underflows (bug 14155). 2013-09-02 14:51:24 +00:00
Thomas Schwinge f1cc4c8654 math: Additional type conversion tests
These have helped me find and fix type conversion issues in QEMU's MIPS
hardware emulation.  While certainly glibc is not the best place for such
tests, they're just an enhancement of tests already present.
2013-08-29 12:21:07 +02:00
Joseph Myers 8fe89494e6 Fix cexp (NaN + i0) (bug 15532). 2013-08-23 19:45:38 +00:00
Joseph Myers acd06bb11f Fix fdim handling of infinities (bug 15797). 2013-08-21 19:56:48 +00:00
Joseph Myers c980f2f4fe Fix cproj handling of (finite, NaN) arguments (bug 15531). 2013-08-20 19:41:15 +00:00
Andreas Schwab ca0a6bc4c5 Fix cbrtl for ldbl-96 2013-08-13 09:45:02 +02:00
David S. Miller f959cfd790 Annotate more cases of math bug 15319.
* math/libm-test.inc (casin_test_data): Annotate more cases of missing
	underflows from atanl/atan2l due to bug 15319.
	(casinh_test_data): Likewise.
2013-07-13 16:57:05 -07:00
Joseph Myers b8c792af85 Allow fesetround failures in math/test-misc.c if ROUNDING_TESTS fails. 2013-06-20 19:11:34 +00:00
Joseph Myers c91e082525 Avoid spurious failures from <fenv.h> fallback functions (bug 15654). 2013-06-20 19:10:44 +00:00
Joseph Myers 1a8463176c Use math-tests.h more in math/test-misc. 2013-06-17 11:48:11 +00:00
Joseph Myers 8fc75e6fb7 Add another fma test. 2013-06-15 19:58:38 +00:00
Joseph Myers 94f2c07669 Make more libm tests condition exceptions tests with math-tests.h. 2013-06-12 12:41:25 +00:00
Joseph Myers f1d73d30df Add exception information to math-tests.h and use it in libm-test.inc. 2013-06-11 15:44:31 +00:00
Joseph Myers 0efa6f8b99 Add rounding mode information to math-tests.h and use it in libm-test.inc. 2013-06-10 12:34:49 +00:00
Joseph Myers 9c84384cc1 Remove trailing whitespace. 2013-06-05 20:44:03 +00:00
Carlos O'Donell 8b0ccb2d7f BZ #15536: Fix ulp for 128-bit IBM long double.
In 128-bit IBM long double the precision of the type
decreases as you approach subnormal numbers, equaling
that of a double for subnormal numbers. Therefore
adjust the computation in ulp to use 2^(MIN_EXP - MANT_DIG)
which is correct for FP_SUBNORMAL for all types.
2013-06-03 14:49:48 -04:00
Joseph Myers fab7ce3f5b Link extra-libs consistently with libc and ld.so. 2013-05-31 16:16:33 +00:00
Joseph Myers 0323d08657 Fix ldbl-96 hypotl of subnormals (bug 15529). 2013-05-24 20:52:55 +00:00
Joseph Myers dd4259b9f7 Test drem and pow10 in libm-test.inc. 2013-05-24 20:33:14 +00:00
Joseph Myers 4f8dfe270b Use same tests for isfinite/finite, lgamma/gamma. 2013-05-24 19:21:22 +00:00
Carlos O'Donell e96e37676f Correctly compute ulp near zero.
The current value used for ulp near zero is wrong,
and this commit fixes it such that ulp(0) is the smallest
subnormal value nearest to zero, which makes the most
sense for testing values near zero. Note that this is not
what Java does; they use the nearest normal value, which
is less accurate than what we want for glibc. Note that
there is no correct implementation of ulp since there
is no strict mathmatical definition that is accepted by
all groups using IEEE 754.

Previously with the large ulp values near zero there
were tests that previously passed, but were in fact
billions of ulp away from the precise answer. With this
commit we now need to disable one of the cpow tests which
is revealed to be inaccurate (bug 14473).

---

2013-05-24  Carlos O'Donell  <carlos@redhat.com>

	* math/libm-test.inc (MAX_EXP): Define.
	(ULPDIFF): Define.
	(ulp): New function.
	(check_float_internal): Use ULPDIFF.
	(cpow_test): Disable failing test.
	(check_ulp): Test ulp() implemetnation.
	(main): Call check_ulp before starting tests.
2013-05-24 14:23:15 -04:00
Joseph Myers e8bdba36c5 Remove libm-test START_DATA and END_DATA. 2013-05-24 13:10:42 +00:00
Joseph Myers b679a606ca Make libm-test START and END into ordinary macros. 2013-05-24 12:22:04 +00:00
Joseph Myers 351fe55087 Don't include function names in test data in generated libm-test.c. 2013-05-22 21:01:44 +00:00
Joseph Myers b50a71810b Don't include expected results in libm-test test names. 2013-05-22 11:49:36 +00:00
Joseph Myers db62a90753 Handle sincos with generic libm-test logic. 2013-05-19 14:45:41 +00:00
Joseph Myers f16cc3eb81 Simplify gen-libm-test.pl handling of tests with extra outputs. 2013-05-19 14:40:40 +00:00
Joseph Myers 2ee094ff75 Don't disable CMPLXL macro for __NO_LONG_DOUBLE_MATH (bug 15488). 2013-05-18 12:12:38 +00:00
Joseph Myers 3779b5b64a Make libm-test look up ulps by name at runtime. 2013-05-18 12:10:59 +00:00
Joseph Myers bb38759d6d Fix remainder exceptions and directed-rounding results (bugs 15480, 15485). 2013-05-17 19:04:08 +00:00
Joseph Myers a00bdcf0e0 Simplify libm-test extra-output initialization. 2013-05-17 19:02:19 +00:00
Joseph Myers de407f79a2 Don't handle ulps for integer tests in libm-test.inc. 2013-05-17 19:01:27 +00:00
Joseph Myers 8269107fe6 Test more cases of "inexact" exceptions in libm-test.inc. 2013-05-17 14:45:50 +00:00
Joseph Myers c58b274f01 Test for errno setting in more pole error cases. 2013-05-16 21:57:25 +00:00
Joseph Myers 0ab349044b Remove ENOSYS tests in libm-test.inc. 2013-05-16 19:09:54 +00:00
Joseph Myers 323e5cb792 Remove libm-test support for TEST_* inside functions. 2013-05-16 19:09:03 +00:00
Joseph Myers 8c75f67421 Convert TEST_extra tests from code to data. 2013-05-16 15:53:40 +00:00
Richard Henderson e6e49e59c1 De-stringify constants in math/atest-exp2.c. 2013-05-16 06:34:01 -07:00
Joseph Myers 105a07dfc0 Support testing "inexact" exceptions in libm-test.inc. 2013-05-16 13:19:38 +00:00
Joseph Myers e9eee333b9 Test for errno setting in more overflow error cases. 2013-05-16 13:18:48 +00:00
Joseph Myers 1c38ff73fd Convert TEST_cc_c tests from code to data. 2013-05-16 13:17:55 +00:00
Joseph Myers 15c7c18dc6 Convert TEST_f_L tests from code to data. 2013-05-16 13:16:56 +00:00
Peter Collingbourne f137ff1383 Remove const attribute on get_log2
This function is not const, as it can modify log2_m and log2_m_inited.
2013-05-15 14:27:53 -07:00
Joseph Myers 3608cb241e Convert TEST_f_l tests from code to data. 2013-05-15 19:48:17 +00:00
Joseph Myers b861c6c4c9 Consistently use TEST_f_L in tests of llrint and llround. 2013-05-15 16:58:41 +00:00
Joseph Myers 7abeee129e Convert TEST_f_b tests from code to data. 2013-05-15 12:04:07 +00:00
Joseph Myers cbe8c4d333 Test for errno setting in more domain error cases. 2013-05-15 10:43:19 +00:00
Joseph Myers 5575c0e5cd Disable libm-test errno testing for TEST_INLINE. 2013-05-15 10:42:18 +00:00
Joseph Myers d369f53178 Convert TEST_ff_i tests from code to data. 2013-05-15 10:41:39 +00:00
Joseph Myers 5e90827081 Fix whitespace in RUN_TEST_LOOP_2_f. 2013-05-14 21:17:19 +00:00
Joseph Myers f71172e551 Correct types of fields in libm-test.inc structures. 2013-05-14 21:00:56 +00:00
Joseph Myers 8cfa635ab8 Convert TEST_ffI_f1 tests from code to data. 2013-05-14 20:36:03 +00:00
Joseph Myers acbd839a07 Convert TEST_f_i tests from code to data. 2013-05-14 19:13:43 +00:00
Joseph Myers e414d745ee Fix function name in scalbln_test call to END. 2013-05-14 19:12:54 +00:00
Joseph Myers d9c2a0fd2c Convert TEST_fI_f1 tests from code to data. 2013-05-14 19:12:10 +00:00
Joseph Myers 9dc9095d56 Convert TEST_fF_f1 tests from code to data. 2013-05-14 14:49:26 +00:00
Joseph Myers 87aa21df6f Convert TEST_f_f1 tests from code to data. 2013-05-14 12:01:19 +00:00
Joseph Myers 68fc074ca0 Convert TEST_fl_f tests from code to data. 2013-05-13 22:38:15 +00:00
Joseph Myers 243216e126 Convert TEST_fi_f tests from code to data. 2013-05-13 19:45:36 +00:00
Joseph Myers 6a1992e268 Convert TEST_c_f tests from code to data. 2013-05-13 18:58:17 +00:00
Joseph Myers 0e400df55d Convert TEST_if_f tests from code to data. 2013-05-13 18:57:35 +00:00
Joseph Myers 6d33265c72 Consistently use TEST_fl_f in tests of scalbln. 2013-05-13 18:56:50 +00:00
Adhemerval Zanella f98ece5fe2 Define decimal constant M_1_DIV_El in libm-test.inc
This patch replaces the 1.0 / M_El by the decimal constant M_1_DIV_El.
2013-05-13 12:08:42 -05:00
Joseph Myers 4f184d30cb Convert TEST_fff_f tests from code to data. 2013-05-12 21:07:58 +00:00
Joseph Myers 081988778f Convert TEST_c_c tests from code to data. 2013-05-12 17:38:26 +00:00
Joseph Myers 601a3a5fd5 Convert TEST_ff_f tests from code to data. 2013-05-12 13:17:09 +00:00
Joseph Myers 8329e4da35 Make fma and nextafter tests use max_value instead of fltmax. 2013-05-11 11:10:31 +00:00
Joseph Myers 74c574788d Convert TEST_f_f tests from code to data. 2013-05-11 11:09:30 +00:00
Joseph Myers 51df539d98 Start converting libm tests from code to data. 2013-05-10 16:45:04 +00:00
Joseph Myers ab2b94613d Fix tgamma errno setting on domain error (bug 6809). 2013-05-10 11:35:11 +00:00
Joseph Myers 0d3e777af2 Use M_SQRT1_2l instead of local M_SQRT_2_2 in libm-test.inc. 2013-05-09 14:33:30 +00:00
Joseph Myers 24f5606614 Use M_PI_34l consistently in libm-test.inc. 2013-05-09 14:13:10 +00:00
Joseph Myers faa7f8119f Use decimal constants in defining M_* in libm-test.inc. 2013-05-09 12:24:44 +00:00
Joseph Myers a0d9f9d745 Factor out initializers for libm-test.inc constants. 2013-05-08 16:10:44 +00:00
Joseph Myers ae08db3ba0 Use correct TEST_* macros for jn, ldexp and yn tests. 2013-05-08 16:09:54 +00:00
Joseph Myers f44bf14a9c Move some libm-test logic for running tests from gen-libm-test.pl to libm-test.inc. 2013-05-08 12:02:22 +00:00
Joseph Myers d8cd06db62 Improve tgamma accuracy (bugs 2546, 2560, 5159, 15426). 2013-05-08 11:58:18 +00:00
Joseph Myers 9ea3513c91 Initialize x in frexp, modf, remqou tests. 2013-05-06 20:23:40 +00:00
Joseph Myers 5bf96de5ef Consistently use TEST_f_f1 in gamma tests. 2013-05-06 20:23:01 +00:00
Adhemerval Zanella 16e616a72f PowerPC: fix hypot/hypof FP exceptions
This patch fixes hypot/hypotf spurious floating-point exceptions
generate by internal operations.
2013-05-06 14:40:17 -05:00
Joseph Myers b7dab1e4d7 Remove unused libm-test expected-failure mechanism. 2013-05-04 16:45:15 +00:00
Joseph Myers a7548d41a7 Use static initializers for constant variables in libm-test.inc. 2013-05-04 13:08:34 +00:00
Joseph Myers c31a5b1e8f Consistently use TEST_f_f1 in lgamma tests. 2013-05-03 19:05:37 +00:00
Joseph Myers d5dc2af390 Don't use IGNORE_ZERO_INF_SIGN in hypot tests. 2013-05-03 19:04:52 +00:00
Joseph Myers 10de07f5fd Fix catan, catanh spurious underflows (bug 15423). 2013-05-01 10:07:00 +00:00
Joseph Myers caf84319c1 Fix catan, catanh inaccuracy from atan2 denominators near 0 (bug 15416). 2013-04-30 11:27:35 +00:00
Joseph Myers f2da779309 Integrate errno testing better in libm-test.inc. 2013-04-29 20:36:48 +00:00
Joseph Myers 4d14f4499d Add missing semicolons to libm-test.inc tests. 2013-04-29 13:48:19 +00:00
Joseph Myers 5b4217d71f Fix catan, catanh spurious overflows (bug 15409). 2013-04-27 14:57:41 +00:00
Joseph Myers 9457fd952c Fix catan, catanh missing underflows (bug 15406). 2013-04-26 19:26:22 +00:00
Joseph Myers f0302940e7 Fix csin, csinh, ccos, ccosh missing underflows (bug 15405). 2013-04-26 19:25:19 +00:00
Carlos O'Donell 418601aa84 math: Use accurate answers for cos and sincos.
Use the most accurate hex literals possible for the answers to the
cos and sincos tests that vary according to the error in the rounding
of PI/2.

---

2013-04-24  Carlos O'Donell  <carlos@redhat.com>

	* math/libm-test.inc (cos_test): Use accurate hex constants.
	(sincost_test): Likewise.
2013-04-24 16:29:33 -04:00
Joseph Myers 5e22180060 Add catan, catanh tests at +/- 1 and +/- i. 2013-04-24 20:14:15 +00:00
Joseph Myers 77f143fdb4 Use suffixed floating-point constants in float and long double catan/catanh. 2013-04-24 18:59:37 +00:00
Joseph Myers 2f38fbfe09 Fix catan, catanh inaccuracy through use of log (bug 15394). 2013-04-24 18:49:13 +00:00
Carlos O'Donell aba5e333d4 libm-test.inc: Fix tests where cos(PI/2) != 0.
The value of PI is never exactly PI in any floating point representation,
and the value of PI/2 is never PI/2. It is wrong to expect cos(M_PI_2l)
to return 0, instead it will return an answer that is  non-zero because
M_PI_2l doesn't round to exactly PI/2 in the type used.

That is to say that the correct answer is to do the following:
* Take PI or PI/2.
* Round to the floating point representation.
* Take the rounded value and compute an infinite precision cos or sin.
* Use the rounded result of the infinite precision cos or sin as the
  answer to the test.

I used printf to do the type rounding, and Wolfram's Alpha to do the
infinite precision cos calculations.

The following changes bring x86-64 and x86 to 1/2 ulp for two tests.
It shows that the x86 cos implementation is quite good, and that
our test are flawed.

Unfortunately given that the rounding errors are type dependent we
need to fix this for each type. No regressions on x86-64 or x86.

---

2013-04-11  Carlos O'Donell  <carlos@redhat.com>

	* math/libm-test.inc (cos_test): Fix PI/2 test.
	(sincos_test): Likewise.
	* sysdeps/x86_64/fpu/libm-test-ulps: Regenerate.
	* sysdeps/i386/fpu/libm-test-ulps: Regenerate.
2013-04-11 08:52:18 -04:00
Siddhesh Poyarekar 01dc6df938 Don't use run-via-rtld-prefix for anything other than tests
run-via-rtld-prefix checks whether the program to be run is a static
test and skips if it is.  This is fine, except that it assumes that
the program to be run is the second $^, which is true only for tests.

This change creates an rtld-prefix, which is simply the dynamic linker
prefix with the necessary arguments and uses that in the non-test
targets.
2013-04-11 09:37:50 +05:30
Carlos O'Donell 085b2d41a4 README.libm-test: Use testrun.sh to run libm test.
Document the use of the convenience testrun.sh script for
running the libm test.

---

2013-04-06  Carlos O'Donell  <carlos@redhat.com>

	* math/README.libm-test (How can I generate "libm-test-ulps"?):
	Use testrun.sh to run libm tests.
2013-04-06 17:13:19 -04:00
Carlos O'Donell 26510bdda1 New Makefile target `regen-ulps'.
The wiki "Regeneration" page has this to say about update ULPs.

"The libm-test-ulps files are semiautomatically updated. To
update an ulps baseline, run each of the failing tests (test-float,
 test-double, etc.) with -u; this will generate a file called ULPs;
concatenate each of those files with the existing libm-test-ulps
file, after removing any entries for particularly huge numbers of
ulps that you do not want to mark as expected. Then run
gen-libm-test.pl -n -u FILE where FILE is the concatenated file
produced in the previous step. This generates a file called
NewUlps which is the new sorted version of libm-test-ulps."

The same information is listed in math/README.libm-test, and is a
lot of manual work that you often want to run over-and-over again
while working on a particular test.

The `regen-ulps' convenience target does this automatically for
developers.

We strictly assume the source tree is readonly and add a
new --output-dir option to libm-test.inc to allow for writing
out ULPs to $(objpfx).

When run the new target does the following:
* Starts with the baseline ULPs file.
* Runs each of the libm math tests with -u.
* Adds new changes seen with -u to the baseline.
* Sorts and prepares the test output with gen-libm-test.pl.
* Leaves math/NewUlps in your build tree to copy to your source
  tree, cleanup, and checkin.

The math test documentation in math/README.libm-test is updated
document the new Makefile target.

---

2013-04-06  Carlos O'Donell  <carlos@redhat.com>

	* Makefile.in (regen-ulps): New target.
	* math/Makefile [ifneq (no,$(PERL)]: Declare regen-ulps with .PHONY.
	[ifneq (no,$(PERL)] (run-regen-ulps): New variable.
	[ifneq (no,$(PERL)] (regen-ulps): New target.
	[ifeq (no,$(PERL)] (regen-ulps): New target.
	* math/libm-test.inc (ulps_file_name): Define.
	(output_dir): New variable.
	(options): Add "output-dir" option.
	(parse_opt): Handle 'o' case.
	(main): If output_dir is non-NULL use it as a prefix
	otherwise use "".
	* math/README.libm-test: Update `How can I generate "libm-test-ulps"?'
2013-04-06 16:22:47 -04:00
Thomas Schwinge a1cbf437a5 [BZ #14686, #15336] Fix standard compliance. Don't use hard-coded qNaN values. 2013-04-05 22:34:52 +02:00
Joseph Myers 05e166c887 Fix missing underflow from cexp (bug 14478). 2013-04-03 16:51:46 +00:00
Joseph Myers 52ce486045 Fix cacosh inaccuracy and spurious exceptions (bug 15327). 2013-04-02 22:54:00 +00:00
Thomas Schwinge 572676160d New <math.h> macro named issignaling to check for a signaling NaN (sNaN).
It is based on draft TS 18661 and currently enabled as a GNU extension.
2013-04-02 13:51:02 +02:00
Joseph Myers ccc8cadf75 Fix casinh inaccuracy for imaginary part < 1.0, real part small (bug 10357). 2013-03-30 13:31:53 +00:00
Joseph Myers 3a7182a14b Fix casinh inaccuracy near i, imaginary part > 1 (bug 15307). 2013-03-27 14:38:44 +00:00
Adhemerval Zanella e42a38dd9d BZ#13889: expl (709.75) wrongly overflows for ldbl-128ibm
The patch increase the high value to check if expl overflows. Current
high mark value is not really correct, the algorithm accepts high values.
It also adds a correct wrapper function to check for overflow and underflow.
2013-03-22 12:39:10 -03:00
Thomas Schwinge bdef0be784 libm-test: Properly wrap blocks consisting of several statements. 2013-03-21 16:07:48 +01:00
Thomas Schwinge 5aa4a1a1fd On 32-bit x86, disable certain tests involving sNaN values.
Follow-up to commit 495ded2c8c.
2013-03-21 16:05:29 +01:00
Joseph Myers 98c48fe5cc Fix Bessel function spurious overflows for ldbl-128 / ldbl-128ibm (bug 15285). 2013-03-21 13:57:21 +00:00
Joseph Myers 0a1b2ae6f6 Fix casinh inaccuracy for argument with imaginary part 1 (bug 15287). 2013-03-21 10:27:10 +00:00
Joseph Myers 6b18bea625 Fix types of constants in k_casinh*.c. 2013-03-19 22:38:25 +00:00
Joseph Myers d2f9799e7c Fix y1l spurious overflows for ldbl-96 (bug 15283). 2013-03-16 17:51:48 +00:00
Joseph Myers 2a185d32e8 Fix spurious underflow exceptions for Bessel functions for ldbl-128 / ldbl-128ibm (bug 14155). 2013-03-16 17:50:28 +00:00
Thomas Schwinge 6cbec759de Move "-sNaN" value into a separate variable. 2013-03-16 13:59:52 +01:00
Thomas Schwinge af00a34d08 * math/libm-test.inc (ldexp_test): Add missing START/END markers. 2013-03-15 19:13:53 +01:00
Thomas Schwinge 495ded2c8c Promote a math test for sNaN handling to the top-level. 2013-03-15 19:12:10 +01:00
Thomas Schwinge 777b0332c0 Use GCC's builtins for generating NaNs. 2013-03-15 19:10:20 +01:00
Thomas Schwinge 64d063b800 Add one test, removed a duplicated one, add a few comments about missing tests. 2013-03-15 19:08:04 +01:00
Thomas Schwinge 67e971f18f Better distinguish between NaN/qNaN/sNaN. 2013-03-15 19:06:02 +01:00
Thomas Schwinge 64487e1264 Enable tests for x86_64, too, which currently are enabled only for x86. 2013-03-15 19:02:18 +01:00
Thomas Schwinge e015e27b90 Fix copy'n'pastos. 2013-03-15 19:00:23 +01:00
Joseph Myers 41c7328e85 Fix spurious underflow exceptions for Bessel functions for double (bug 14155). 2013-03-14 17:47:30 +00:00
Siddhesh Poyarekar e4f223248e Fix some testsuite build warning fixes in libm 2013-02-19 21:20:44 +05:30
Joseph Myers daaa7713e9 Remove bounded-pointers build system support. 2013-02-15 15:07:54 +00:00
Joseph Myers e97ed6ddbe Remove bp-sym.h and BP_SYM uses from C code. 2013-02-14 13:12:02 +00:00
Joseph Myers 8cf28c5ebe Fix casinh spurious underflows away from [-i,i] (bug 15062). 2013-01-31 22:55:29 +00:00
Joseph Myers 728d7b43fc Fix cacos real-part inaccuracy for result real part near 0 (bug 15023). 2013-01-17 20:25:51 +00:00
David S. Miller 32fcb36dbf Add 64-bit VIS3 optimized GMP routines for sparc.
* math/Makefile: Recognize gmp-sysdep_routines.
	* sysdeps/sparc/sparc64/multiarch/Makefile: Add VIS3 optimized GMP routines
	to sysdeps.
	* sysdeps/sparc/sparc64/multiarch/add_n-vis3.S: New file.
	* sysdeps/sparc/sparc64/multiarch/add_n.S: New file.
	* sysdeps/sparc/sparc64/multiarch/addmul_1-vis3.S: New file.
	* sysdeps/sparc/sparc64/multiarch/addmul_1.S: New file.
	* sysdeps/sparc/sparc64/multiarch/mul_1-vis3.S: New file.
	* sysdeps/sparc/sparc64/multiarch/mul_1.S: New file.
	* sysdeps/sparc/sparc64/multiarch/sub_n-vis3.S: New file.
	* sysdeps/sparc/sparc64/multiarch/sub_n.S: New file.
	* sysdeps/sparc/sparc64/multiarch/submul_1-vis3.S: New file.
	* sysdeps/sparc/sparc64/multiarch/submul_1.S: New file.
2013-01-11 23:39:02 -08:00
Joseph Myers 828beb132d Use __extension__ with long long in installed headers. 2013-01-10 20:19:45 +00:00
Andreas Schwab 8790af5f9f Revert "CFLAGS-test-tgmath2.c"
This reverts commit 3167bfc62b.
2013-01-10 10:44:04 +01:00
Andreas Schwab 3167bfc62b CFLAGS-test-tgmath2.c 2013-01-10 09:59:58 +01:00
Joseph Myers a9708fed77 Fix casinh, casin overflow (bug 14996). 2013-01-07 14:59:53 +00:00
Joseph Myers cdc1c96fba Fix casinh, casin inaccuracy from cancellation (bug 14994). 2013-01-04 13:25:17 +00:00
Joseph Myers 568035b787 Update copyright notices with scripts/update-copyrights. 2013-01-02 19:05:09 +00:00
Mike Frysinger 9c89fca6e0 math: use existing nonnull attribute define
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2012-12-30 13:00:13 -05:00
Joseph Myers 1bead169c3 Fix powl inaccuracy for x86_64 and x86 (bug 13881). 2012-11-28 13:40:54 +00:00
Joseph Myers 7184dcdf26 Disable some fma tests for ldbl-128ibm. 2012-11-22 19:57:58 +00:00
Joseph Myers 0a42601f27 Fix ldbl-128ibm atanl spurious underflows (bug 14871). 2012-11-22 19:56:47 +00:00
Joseph Myers 1468ded38e Fix ldbl-128ibm hypotl internal underflows (bug 14869). 2012-11-22 14:58:41 +00:00
Joseph Myers 8e27e3cc45 Fix ldbl-128ibm hypotl inaccuracy for arguments with large ratio (bug 14868). 2012-11-22 14:57:22 +00:00
Joseph Myers c9c0279bcb Mark some clog / clog10 underflows as expected for IBM long double. 2012-11-22 14:56:14 +00:00
David S. Miller 6d33cc9d9b Fix spurious underflows in ldbl-128 atan implementation.
With help from Joseph Myers.
	* sysdeps/ieee754/ldbl-128/s_atanl.c (__atanl): Handle tiny and
	very large arguments properly.
	* math/libm-test.inc (atan_test): New tests.
	(atan2_test): New tests.
	* sysdeps/sparc/fpu/libm-test-ulps: Update.
	* sysdeps/x86_64/fpu/libm-test-ulps: Update.
2012-11-19 15:31:24 -08:00
David S. Miller 05b227bdae Correct tinyness handling in long-double and float y0/y1.
With help from Joseph Myers.
	* sysdeps/ieee754/flt-32/e_j0f.c (__ieee754_y0f): Adjust tinyness
	cutoff to 2**-13.
	* sysdeps/ieee754/flt-32/e_j1f.c (__ieee754_y1f): Adjust tinyness
	cutoff to 2**-25.
	* sysdeps/ieee754/ldbl-128/e_j0l.c (U0): New constant.
	( __ieee754_y0l): Avoid arithmetic underflow when 'x' is very
	small.
	* sysdeps/ieee754/ldbl-128/e_j1l.c (__ieee754_y1l): Likewise.
	* math/libm-test.inc (y0_test): New tests.
	(y1_test): New tests.
	* sysdeps/i386/fpu/libm-test-ulps: Update.
	* sysdeps/x86_64/fpu/libm-test-ulps: Update.
	* sysdeps/sparc/fpu/libm-test-ulps: Update.
2012-11-18 12:33:53 -08:00
Marcus Shawcroft 2fd8978571 Fix buffer overflow in libm-test.inc check_complex() 2012-11-15 18:02:03 +00:00
Joseph Myers 60e235ee2a Fix spurious underflows from pow with results close to 1 (bug 14811). 2012-11-07 13:03:31 +00:00
Joseph Myers 82477c28f4 Fix fma underflows with small x * y (bug 14793). 2012-11-06 14:12:54 +00:00
Joseph Myers a0c2940d67 Fix fma overflow results outside round-to-nearest mode (bug 14797). 2012-11-04 19:26:02 +00:00
Thomas Schwinge b830319d49 [BZ #157] Remove include/stub-tag.h for good. 2012-11-04 19:59:40 +01:00
Joseph Myers 5b5b04d628 Make fma use of Dekker and Knuth algorithms use round-to-nearest (bug 14796). 2012-11-03 19:48:53 +00:00
Joseph Myers 0155d5b26e Make math.h FP_* macros usable in #if (bug 3439). 2012-11-02 22:11:21 +00:00
Joseph Myers 473611b22d Fix fma (a, b, c) for small a * b (bugs 14784, 14785). 2012-11-01 16:47:26 +00:00
Joseph Myers 16a0e2ec87 Fix ldbl-128ibm atan2l for x near 1. 2012-10-31 20:44:59 +00:00
Joseph Myers ef82f4da79 Fix fma underflow exceptions in after-rounding edge cases. 2012-10-31 13:01:17 +00:00
Joseph Myers 8627a2329c Fix fma missing underflows and bad results for some subnormal results (bugs 14152, 14783). 2012-10-30 13:54:50 +00:00