Commit Graph

1368 Commits

Author SHA1 Message Date
Szabolcs Nagy de800d8305 Remove slow paths from exp
Remove the __slowexp code, so exp is no longer correctly rounded.  The
result is computed to about 70 bits precision so the worst case ulp
error is about 0.500007 in nearest rounding mode.

	* manual/probes.texi: Remove slowexp probes.
	* math/Makefile: Remove slowexp.
	* sysdeps/generic/math_private.h (__slowexp): Remove.
	* sysdeps/ieee754/dbl-64/e_exp.c (__ieee754_exp): Remove __slowexp and
	document error bounds.
	* sysdeps/i386/fpu/slowexp.c: Remove.
	* sysdeps/ia64/fpu/slowexp.c: Remove.
	* sysdeps/ieee754/dbl-64/slowexp.c: Remove.
	* sysdeps/ieee754/dbl-64/uexp.h (err_0): Remove.
	* sysdeps/m68k/m680x0/fpu/slowexp.c: Remove.
	* sysdeps/powerpc/power4/fpu/Makefile (CPPFLAGS-slowexp.c): Remove.
	* sysdeps/x86_64/fpu/multiarch/Makefile: Remove slowexp-fma.
	* sysdeps/x86_64/fpu/multiarch/e_exp-avx.c (__slowexp): Remove.
	* sysdeps/x86_64/fpu/multiarch/e_exp-fma.c (__slowexp): Remove.
	* sysdeps/x86_64/fpu/multiarch/e_exp-fma4.c (__slowexp): Remove.
	* sysdeps/x86_64/fpu/multiarch/slowexp-avx.c: Remove.
	* sysdeps/x86_64/fpu/multiarch/slowexp-fma.c: Remove.
	* sysdeps/x86_64/fpu/multiarch/slowexp-fma4.c: Remove.
2018-02-12 11:33:33 +00:00
Wilco Dijkstra c3d466cba1 Remove slow paths from pow
Remove the slow paths from pow.  Like several other double precision math
functions, pow is exactly rounded.  This is not required from math functions
and causes major overheads as it requires multiple fallbacks using higher
precision arithmetic if a result is close to 0.5ULP.  Ridiculous slowdowns
of up to 100000x have been reported when the highest precision path triggers.

All GLIBC math tests pass on AArch64 and x64 (with ULP of pow set to 1).
The worst case error is ~0.506ULP.  A simple test over a few hundred million
values shows pow is 10% faster on average.  This fixes BZ #13932.

	[BZ #13932]
	* sysdeps/ieee754/dbl-64/uexp.h (err_1): Remove.
	* benchtests/pow-inputs: Update comment for slow path cases.
	* manual/probes.texi (slowpow_p10): Delete removed probe.
	(slowpow_p10): Likewise.
	* math/Makefile: Remove halfulp.c and slowpow.c.
	* sysdeps/aarch64/libm-test-ulps: Set ULP of pow to 1.
	* sysdeps/generic/math_private.h (__exp1): Remove error argument.
	(__halfulp): Remove.
	(__slowpow): Remove.
	* sysdeps/i386/fpu/halfulp.c: Delete file.
	* sysdeps/i386/fpu/slowpow.c: Likewise.
	* sysdeps/ia64/fpu/halfulp.c: Likewise.
	* sysdeps/ia64/fpu/slowpow.c: Likewise.
	* sysdeps/ieee754/dbl-64/e_exp.c (__exp1): Remove error argument,
	improve comments and add error analysis.
	* sysdeps/ieee754/dbl-64/e_pow.c (__ieee754_pow): Add error analysis.
	(power1): Remove function:
	(log1): Remove error argument, add error analysis.
	(my_log2): Remove function.
	* sysdeps/ieee754/dbl-64/halfulp.c: Delete file.
	* sysdeps/ieee754/dbl-64/slowpow.c: Likewise.
	* sysdeps/m68k/m680x0/fpu/halfulp.c: Likewise.
	* sysdeps/m68k/m680x0/fpu/slowpow.c: Likewise.
	* sysdeps/powerpc/power4/fpu/Makefile: Remove CPPFLAGS-slowpow.c.
	* sysdeps/x86_64/fpu/libm-test-ulps: Set ULP of pow to 1.
	* sysdeps/x86_64/fpu/multiarch/Makefile: Remove slowpow-fma.c,
	slowpow-fma4.c, halfulp-fma.c, halfulp-fma4.c.
	* sysdeps/x86_64/fpu/multiarch/e_pow-fma.c (__slowpow): Remove define.
	* sysdeps/x86_64/fpu/multiarch/e_pow-fma4.c (__slowpow): Likewise.
	* sysdeps/x86_64/fpu/multiarch/halfulp-fma.c: Delete file.
	* sysdeps/x86_64/fpu/multiarch/halfulp-fma4.c: Likewise.
	* sysdeps/x86_64/fpu/multiarch/slowpow-fma.c: Likewise.
	* sysdeps/x86_64/fpu/multiarch/slowpow-fma4.c: Likewise.
2018-02-12 10:47:09 +00:00
Joseph Myers d8742dd82f Add narrowing add functions.
This patch adds the narrowing add functions from TS 18661-1 to glibc's
libm: fadd, faddl, daddl, f32addf64, f32addf32x, f32xaddf64 for all
configurations; f32addf64x, f32addf128, f64addf64x, f64addf128,
f32xaddf64x, f32xaddf128, f64xaddf128 for configurations with
_Float64x and _Float128; __nldbl_daddl for ldbl-opt.  As discussed for
the build infrastructure patch, tgmath.h support is deliberately
deferred, and FP_FAST_* macros are not applicable without optimized
function implementations.

Function implementations are added for all relevant pairs of formats
(including certain cases of a format and itself where more than one
type has that format).  The main implementations use round-to-odd, or
a trivial computation in the case where both formats are the same or
where the wider format is IBM long double (in which case we don't
attempt to be correctly rounding).  The sysdeps/ieee754/soft-fp
implementations use soft-fp, and are used automatically for
configurations without exceptions and rounding modes by virtue of
existing Implies files.  As previously discussed, optimized versions
for particular architectures are possible, but not included.

i386 gets a special version of f32xaddf64 to avoid problems with
double rounding (similar to the existing fdim version), since this
function must round just once without an intermediate rounding to long
double.  (No such special version is needed for any other function,
because the nontrivial functions use round-to-odd, which does the
intermediate computation with the rounding mode set to round-to-zero,
and double rounding is OK except in round-to-nearest mode, so is OK
for that intermediate round-to-zero computation.)  mul and div will
need slightly different special versions for i386 (using round-to-odd
on long double instead of precision control) because of the
possibility of inexact intermediate results in the subnormal range for
double.

To reduce duplication among the different function implementations,
math-narrow.h gets macros CHECK_NARROW_ADD, NARROW_ADD_ROUND_TO_ODD
and NARROW_ADD_TRIVIAL.

In the trivial cases and for any architecture-specific optimized
implementations, the overhead of the errno setting might be
significant, but I think that's best handled through compiler built-in
functions rather than providing separate no-errno versions in glibc
(and likewise there are no __*_finite entry points for these function
provided, __*_finite effectively being no-errno versions at present in
most cases).

Tested for x86_64 and x86, with both GCC 6 and GCC 7.  Tested for
mips64 (all three ABIs, both hard and soft float) and powerpc with GCC
7.  Tested with build-many-glibcs.py with both GCC 6 and GCC 7.

	* math/Makefile (libm-narrow-fns): Add add.
	(libm-test-funcs-narrow): Likewise.
	* math/Versions (GLIBC_2.28): Add narrowing add functions.
	* math/bits/mathcalls-narrow.h (add): Use __MATHCALL_NARROW .
	* math/gen-auto-libm-tests.c (test_functions): Add add.
	* math/math-narrow.h (CHECK_NARROW_ADD): New macro.
	(NARROW_ADD_ROUND_TO_ODD): Likewise.
	(NARROW_ADD_TRIVIAL): Likewise.
	* sysdeps/ieee754/float128/float128_private.h (__faddl): New
	macro.
	(__daddl): Likewise.
	* sysdeps/ieee754/ldbl-opt/Makefile (libnldbl-calls): Add fadd and
	dadd.
	(CFLAGS-nldbl-dadd.c): New variable.
	(CFLAGS-nldbl-fadd.c): Likewise.
	* sysdeps/ieee754/ldbl-opt/Versions (GLIBC_2.28): Add
	__nldbl_daddl.
	* sysdeps/ieee754/ldbl-opt/nldbl-compat.h (__nldbl_daddl): New
	prototype.
	* manual/arith.texi (Misc FP Arithmetic): Document fadd, faddl,
	daddl, fMaddfN, fMaddfNx, fMxaddfN and fMxaddfNx.
	* math/auto-libm-test-in: Add tests of add.
	* math/auto-libm-test-out-narrow-add: New generated file.
	* math/libm-test-narrow-add.inc: New file.
	* sysdeps/i386/fpu/s_f32xaddf64.c: Likewise.
	* sysdeps/ieee754/dbl-64/s_f32xaddf64.c: Likewise.
	* sysdeps/ieee754/dbl-64/s_fadd.c: Likewise.
	* sysdeps/ieee754/float128/s_f32addf128.c: Likewise.
	* sysdeps/ieee754/float128/s_f64addf128.c: Likewise.
	* sysdeps/ieee754/float128/s_f64xaddf128.c: Likewise.
	* sysdeps/ieee754/ldbl-128/s_daddl.c: Likewise.
	* sysdeps/ieee754/ldbl-128/s_f64xaddf128.c: Likewise.
	* sysdeps/ieee754/ldbl-128/s_faddl.c: Likewise.
	* sysdeps/ieee754/ldbl-128ibm/s_daddl.c: Likewise.
	* sysdeps/ieee754/ldbl-128ibm/s_faddl.c: Likewise.
	* sysdeps/ieee754/ldbl-96/s_daddl.c: Likewise.
	* sysdeps/ieee754/ldbl-96/s_faddl.c: Likewise.
	* sysdeps/ieee754/ldbl-opt/nldbl-dadd.c: Likewise.
	* sysdeps/ieee754/ldbl-opt/nldbl-fadd.c: Likewise.
	* sysdeps/ieee754/soft-fp/s_daddl.c: Likewise.
	* sysdeps/ieee754/soft-fp/s_fadd.c: Likewise.
	* sysdeps/ieee754/soft-fp/s_faddl.c: Likewise.
	* sysdeps/powerpc/fpu/libm-test-ulps: Update.
	* sysdeps/mach/hurd/i386/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/aarch64/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/alpha/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/arm/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/hppa/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/i386/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/ia64/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/m68k/coldfire/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/m68k/m680x0/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/microblaze/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/mips/mips32/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/mips/mips64/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/nios2/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/powerpc/powerpc64/libm-le.abilist: Likewise.
	* sysdeps/unix/sysv/linux/powerpc/powerpc64/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/riscv/rv64/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/s390/s390-32/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/s390/s390-64/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/sh/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/sparc/sparc32/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/sparc/sparc64/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/tile/tilegx32/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/tile/tilegx64/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/x86_64/64/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/x86_64/x32/libm.abilist: Likewise.
2018-02-10 02:08:43 +00:00
Joseph Myers 3195833899 Handle narrowing function sNaN test disabling based on argument format.
Testing narrowing functions for x86_64 with GCC 6 showed up a further
testsuite fix needed: there is no _Float128 sNaN support before GCC 7
on x86_64 / x86, and the existing tests of SNAN_TESTS only checked it
for the return type, not for the argument type.  This patch fixes the
code to check SNAN_TESTS (ARG_FLOAT) as well (in a variable set in
libm-test-driver.c, since libm-test-support.c is compiled only once
for each choice of FLOAT).

Tested for x86_64 and x86 with GCC 6 in conjunction with the main
patch adding narrowing add functions.

	* math/libm-test-driver.c (snan_tests_arg): New variable.
	* math/libm-test-support.h (snan_tests_arg): New declaration.
	* math/libm-test-support.c (enable_test): Check snan_tests_arg.
2018-02-09 22:56:35 +00:00
Joseph Myers 8e554659ad Add test infrastructure for narrowing libm functions.
This patch continues preparations for adding TS 18661-1 narrowing libm
functions by adding the required testsuite infrastructure to test such
functions through the libm-test infrastructure.

That infrastructure is based around testing for a single type, FLOAT.
For the narrowing functions, FLOAT, the "main" type for testing, is
the function return type; the argument type is ARG_FLOAT.  This is
consistent with how the code built once for each type,
libm-test-support.c, depends on FLOAT for such things as calculating
ulps errors in results but can already handle different argument types
(pointers, integers, long double for nexttoward).

Makefile machinery is added to handle building tests for all pairs of
types for which there are narrowing functions (as with non-narrowing
functions, aliases are tested just the same as the functions they
alias).  gen-auto-libm-tests gains a --narrow option for building
outputs for narrowing functions (so narrowing sqrt and fma will share
the same inputs as non-narrowing, but gen-auto-libm-tests will be run
with and without that option to generate different output files).  In
the narrowing case, the auto-libm-test-out-narrow-* files include
annotations for each test about what properties ARG_FLOAT must have to
be able to represent all the inputs for that test; those annotations
result in calls to the TEST_COND_arg_fmt macro.

gen-libm-test.pl has some minor updates to handle narrowing tests (for
example, arguments in such tests must be surrounded by ARG_LIT calls
instead of LIT calls).  Various new macros are added to the C test
support code (for example, sNaN initializers need to be properly
typed, so arg_snan_value is added; other such arg_* macros are added
as it seems cleanest to do so, though some are not strictly required).
Special-casing of the ibm128 format to allow for its limitations is
adjusted to handle it as the argument format as well as as the result
format; thus, the tests of the new functions allow nonzero ulps only
in the case where ibm128 is the argument format, as otherwise the
functions correspond to fully-defined IEEE operations.  The ulps in
question appear as e.g. 'Function: "add_ldouble"' in libm-test-ulps
(with 1ulp errors then listed for double and float for that function
in powerpc); no support is added to generate corresponding faddl /
daddl ulps listings in the ulps table in the manual.

For the previous patch, I noted the need to avoid spurious macro
expansions of identifiers such as "add".  A test test-narrow-macros.c
is added to verify such macro expansions are successfully avoided, and
there is also a -mlong-double-64 version of that test for ldbl-opt.
This test is set up to cover the full set of relevant identifiers from
the start rather than adding functions one at a time as each function
group is added.

Tested for x86_64 (this patch in isolation, as well as testing for
various configurations in conjunction with the actual addition of
"add" functions).

	* math/Makefile (test-type-pairs): New variable.
	(test-type-pairs-f64xf128-yes): Likewise.
	(tests): Add test-narrow-macros.
	(libm-test-funcs-narrow): New variable.
	(libm-test-c-narrow): Likewise.
	(generated): Add $(libm-test-c-narrow).
	(libm-tests-base-narrow): New variable.
	(libm-tests-narrow): Likewise.
	(libm-tests): Add $(libm-tests-narrow).
	(libm-tests-for-type): Handle $(libm-tests-narrow).
	(libm-test-c-narrow-obj): New variable.
	($(libm-test-c-narrow-obj)): New rule.
	($(foreach t,$(libm-tests-narrow),$(objpfx)$(t).c)): Likewise.
	($(foreach f,$(libm-test-funcs-narrow),$(objpfx)$(o)-$(f).o)): Use
	$(o-iterator) to set dependencies and CFLAGS.
	* math/gen-auto-libm-tests.c: Document use for narrowing
	functions.
	(output_for_one_input_case): Take argument NARROW.
	(generate_output): Likewise.  Update call to
	output_for_one_input_case.
	(main): Take --narrow option.  Update call to generate_output.
	* math/gen-libm-test.pl (_apply_lit): Take macro name as argument.
	(apply_lit): Update call to _apply_lit.
	(apply_arglit): New function.
	(parse_args): Handle "a" arguments.
	(parse_auto_input): Handle format names using ":".
	* math/README.libm-test: Document "a" parameter type.
	* math/libm-test-support.h (ARG_TYPE_MIN): New macro.
	(ARG_TYPE_TRUE_MIN): Likewise.
	(ARG_TYPE_MAX): Likwise.
	(ARG_MIN_EXP): Likewise.
	(ARG_MAX_EXP): Likewise.
	(ARG_MANT_DIG): Likewise.
	(TEST_COND_arg_ibm128): Likewise.
	(TEST_COND_ibm128_libgcc): Define conditional on [ARG_FLOAT].
	(TEST_COND_arg_fmt): New macro.
	(init_max_error): Update prototype.
	* math/libm-test-support.c (test_ibm128): New variable.
	(init_max_error): Take argument testing_ibm128 and set test_ibm128
	instead of using [TEST_COND_ibm128] conditional.
	(test_exceptions): Use test_ibm128 instead of TEST_COND_ibm128.
	* math/libm-test-driver.c (STR_ARG_FLOAT): New macro.
	[TEST_NARROW] (TEST_MSG): New definition.
	(arg_plus_zero): New macro.
	(arg_minus_zero): Likewise.
	(arg_plus_infty): Likewise.
	(arg_minus_infty): Likewise.
	(arg_qnan_value_pl): Likewise.
	(arg_qnan_value): Likewise.
	(arg_snan_value_pl): Likewise.
	(arg_snan_value): Likewise.
	(arg_max_value): Likewise.
	(arg_min_value): Likewise.
	(arg_min_subnorm_value): Likewise.
	[ARG_FLOAT] (struct test_aa_f_data): New struct type.
	(RUN_TEST_LOOP_aa_f): New macro.
	(TEST_SUFF): New macro.
	(TEST_SUFF_STR): Likewise.
	[!TEST_MATHVEC] (VEC_SUFF): Don't define.
	(TEST_COND_any_ibm128): New macro.
	(START): Use TEST_SUFF and TEST_SUFF_STR in initializer for
	this_func.  Update call to init_max_error.
	* math/test-double.h (FUNC_NARROW_PREFIX): New macro.
	* math/test-float.h (FUNC_NARROW_PREFIX): Likewise.
	* math/test-float128.h (FUNC_NARROW_PREFIX): Likewise.
	* math/test-float32.h (FUNC_NARROW_PREFIX): Likewise.
	* math/test-float32x.h (FUNC_NARROW_PREFIX): Likewise.
	* math/test-float64.h (FUNC_NARROW_PREFIX): Likewise.
	* math/test-float64x.h (FUNC_NARROW_PREFIX): Likewise.
	* math/test-math-scalar.h (TEST_NARROW): Likewise.
	* math/test-math-vector.h (TEST_NARROW): Likewise.
	* math/test-arg-double.h: New file.
	* math/test-arg-float128.h: Likewise.
	* math/test-arg-float32x.h: Likewise.
	* math/test-arg-float64.h: Likewise.
	* math/test-arg-float64x.h: Likewise.
	* math/test-arg-ldouble.h: Likewise.
	* math/test-math-narrow.h: Likewise.
	* math/test-narrow-macros.c: Likewise.
	* sysdeps/ieee754/ldbl-opt/test-narrow-macros-ldbl-64.c: Likewise.
	* sysdeps/ieee754/ldbl-opt/Makefile (tests): Add
	test-narrow-macros-ldbl-64.
	(CFLAGS-test-narrow-macros-ldbl-64.c): New variable.
2018-02-09 21:55:48 +00:00
Joseph Myers 63716ab270 Add build infrastructure for narrowing libm functions.
TS 18661-1 defines libm functions that carry out an operation (+ - * /
sqrt fma) on their arguments and return a result rounded to a
(usually) narrower type, as if the original result were computed to
infinite precision and then rounded directly to the result type
without any intermediate rounding to the argument type.  For example,
fadd, faddl and daddl for addition.  These are the last remaining TS
18661-1 functions left to be added to glibc.  TS 18661-3 extends this
to corresponding functions for _FloatN and _FloatNx types.

As functions parametrized by two rather than one varying
floating-point types, these functions require infrastructure in glibc
that was not required for previous libm functions.  This patch
provides such infrastructure - excluding test support, and actual
function implementations, which will be in subsequent patches.

Declaring the functions uses a header bits/mathcalls-narrow.h, which
is included many times, for each relevant pair of types.  This will
end up containing macro calls of the form

__MATHCALL_NARROW (__MATHCALL_NAME (add), __MATHCALL_REDIR_NAME (add), 2);

for each family of narrowing functions.  (The structure of this macro
call, with the calls to __MATHCALL_NAME and __MATHCALL_REDIR_NAME
there rather than in the definition of __MATHCALL_NARROW, arises from
the names such as "add" *not* themselves being reserved identifiers -
meaning it's necessary to avoid any indirection that would result in a
user-defined "add" macro being expanded.)  Whereas for existing
functions declaring long double functions is disabled if _LIBC in the
case where they alias double functions, to facilitate defining the
long double functions as aliases of the double ones, there is no such
logic for the narrowing functions in this patch.  Rather, the files
defining such functions are expected to use #define to hide the
original declarations of the alias names, to avoid errors about
defining aliases with incompatible types.

math/Makefile support is added for building the functions (listed in
libm-narrow-fns, currently empty) for all relevant pairs of types.  An
internal header math-narrow.h is added for macros shared between
multiple function implementations - currently a ROUND_TO_ODD macro to
facilitate writing functions using the round-to-odd implementation
approach, and alias macros to create all the required function
aliases.  libc_feholdexcept_setroundf128 and libc_feupdateenv_testf128
are added for use when required (only for x86_64).  float128_private.h
support is added for ldbl-128 narrowing functions to be used for
_Float128.

Certain things are specifically omitted from this patch and the
immediate followups.  tgmath.h support is deferred; there remain
unresolved questions about how the type-generic macros for these
functions are supposed to work, especially in the case of arguments of
integer type.  The math.h / bits/mathcalls-narrow.h logic, and the
logic for determining what functions / aliases to define, will need
some adjustments to support the sqrt and fma functions, where
e.g. f32xsqrtf64 can just be an alias for sqrt rather than a separate
function.  TS 18661-1 defines FP_FAST_* macros but no support is
included for defining them (they won't in general be true without
architecture-specific optimized function versions).

For each of the function groups (add sub mul div sqrt fma) there are
always six functions present (e.g. fadd, faddl, daddl, f32addf64,
f32addf32x, f32xaddf64).  When _Float64x and _Float128 are supported,
there are seven more (e.g. f32addf64x, f32addf128, f64addf64x,
f64addf128, f32xaddf64x, f32xaddf128, f64xaddf128).  In addition, in
the ldbl-opt case there are function names such as __nldbl_daddl (an
alias for f32xaddf64, which is not a reserved name in TS 18661-1, only
in TS 18661-3), for calls to daddl to be mapped to in the
-mlong-double-64 case.  (Calls to faddl just get mapped to fadd, and
for sqrt and fma there won't be __nldbl_* functions because dsqrtl and
dfmal can just be mapped to sqrt and fma with -mlong-double-64.)

While there are six or thirteen functions present in each group (plus
__nldbl_* names only as an ABI, not an API), not all are distinct;
they fall in various groups of aliases.  There are two distinct
versions built if long double has the same format as double; four if
they have distinct formats but there is no _Float64x or _Float128
support; five if long double has binary128 format; seven when
_Float128 is distinct from long double.

Architecture-specific optimized versions are possible, but not
included in my patches.  For example, IA64 generally supports
narrowing the result of most floating-point instructions; Power ISA
2.07 (POWER8) supports double values as arguments to float
instructions, with the results narrowed as expected; Power ISA 3
(POWER9) supports round-to-odd for float128 instructions, so meaning
that approach can be used without needing to set and restore the
rounding mode and test "inexact".  I intend to leave any such
optimized versions to the architecture maintainers.  Generally in such
cases it would also make sense for calls to these functions to be
expanded inline (given -fno-math-errno); I put a suggestion for TS
18661-1 built-in functions at <https://gcc.gnu.org/wiki/SummerOfCode>.

Tested for x86_64 (this patch in isolation, as well as testing for
various configurations in conjunction with further patches).

	* math/bits/mathcalls-narrow.h: New file.
	* include/bits/mathcalls-narrow.h: Likewise.
	* math/math-narrow.h: Likewise.
	* math/math.h (__MATHCALL_NARROW_ARGS_1): New macro.
	(__MATHCALL_NARROW_ARGS_2): Likewise.
	(__MATHCALL_NARROW_ARGS_3): Likewise.
	(__MATHCALL_NARROW_NORMAL): Likewise.
	(__MATHCALL_NARROW_REDIR): Likewise.
	(__MATHCALL_NARROW): Likewise.
	[__GLIBC_USE (IEC_60559_BFP_EXT)]: Repeatedly include
	<bits/mathcalls-narrow.h> with _Mret_, _Marg_ and __MATHCALL_NAME
	defined.
	[__GLIBC_USE (IEC_60559_TYPES_EXT)]: Likewise.
	* math/Makefile (headers): Add bits/mathcalls-narrow.h.
	(libm-narrow-fns): New variable.
	(libm-narrow-types-basic): Likewise.
	(libm-narrow-types-ldouble-yes): Likewise.
	(libm-narrow-types-float128-yes): Likewise.
	(libm-narrow-types-float128-alias-yes): Likewise.
	(libm-narrow-types): Likewise.
	(libm-routines): Add narrowing functions.
	* sysdeps/i386/fpu/fenv_private.h [__x86_64__]
	(libc_feholdexcept_setroundf128): New macro.
	[__x86_64__] (libc_feupdateenv_testf128): Likewise.
	* sysdeps/ieee754/float128/float128_private.h: Include
	<math/math-narrow.h>.
	[libc_feholdexcept_setroundf128] (libc_feholdexcept_setroundl):
	Undefine and redefine.
	[libc_feupdateenv_testf128] (libc_feupdateenv_testl): Likewise.
	(libm_alias_float_ldouble): Undefine and redefine.
	(libm_alias_double_ldouble): Likewise.
2018-02-09 21:18:52 +00:00
Joseph Myers bfd475876f Remove unused math/Makefile variable libm-test-incs.
The math/Makefile variable libm-test-incs was formerly used, but no
longer is.  This patch removes it.

Tested for x86_64.

	* math/Makefile [$(PERL) != no] (libm-test-incs): Remove variable.
2018-02-09 18:15:32 +00:00
Wilco Dijkstra 3c7d031294 Improve math_errhandling
Currently math_errhandling is always set to MATH_ERRNO | MATH_ERREXCEPT
even if -fno-math-errno is used.  It is not defined at all when fast-math
is used.  Set it to 0 with fast-math - this is noncomforming but more
useful than not define math_errhandling at all. Also take __NO_MATH_ERRNO__
into account and update comment.

	* math/math.h (math_errhandling): Set to 0 with __FAST_MATH__.
	Add __NO_MATH_ERRNO__ check.
2018-01-03 13:14:10 +00:00
Joseph Myers b9256ab6bb Reduce command length in regen-ulps.
I found that "make regen-ulps" failed when building with unmodified
GNU make 4.1, and an objdir /some/where/math/ longer than about 37
characters, because the list of tests in the "for run in $^" loop
exceeded the Linux kernel's MAX_ARG_STRLEN limit (131072 bytes) on the
length of a single argument passed to a command.

Some GNU/Linux distributions have a patch to make to work around this
limit (see e.g. Debian bug 688601), but clearly this ought to work
without needing such a patch.  This patch arranges for the shell loop
to be over the test names without a $(objdir) prefix, which reduces
the space used to less than half MAX_ARG_STRLEN.

(I think we ought to aim to get rid of bits/mathinline.h completely -
filing GCC bugs for any optimizations GCC can't currently do with
-ffast-math - which would mean we could halve the number of libm tests
run because separate inline function tests would no longer be needed.
However, with a long directory name even half the number of tests
could make this command exceed MAX_ARG_STRLEN without my patch.)

Tested regen-ulps on a system where it failed before this patch.

	* math/Makefile (run-regen-ulps): Add $(objpfx) to test name here.
	(regen-ulps): Use $(libm-tests) not $^ in shell loop.
2018-01-02 18:33:18 +00:00
Joseph Myers 688903eb3e Update copyright dates with scripts/update-copyrights.
* All files with FSF copyright notices: Update copyright dates
	using scripts/update-copyrights.
	* locale/programs/charmap-kw.h: Regenerated.
	* locale/programs/locfile-kw.h: Likewise.
2018-01-01 00:32:25 +00:00
Gabriel F. T. Gomes c85e54ac6c Provide a C++ version of iseqsig (bug 22377)
In C++ mode, __MATH_TG cannot be used for defining iseqsig, because
__MATH_TG relies on __builtin_types_compatible_p, which is a C-only
builtin.  This is true when float128 is provided as an ABI-distinct type
from long double.

Moreover, the comparison macros from ISO C take two floating-point
arguments, which need not have the same type.  Choosing what underlying
function to call requires evaluating the formats of the arguments, then
selecting which is wider.  The macro __MATH_EVAL_FMT2 provides this
information, however, only the type of the macro expansion is relevant
(actually evaluating the expression would be incorrect).

This patch provides a C++ version of iseqsig, in which only the type of
__MATH_EVAL_FMT2 (__typeof or decltype) is used as a template parameter
for __iseqsig_type.  This function calls the appropriate underlying
function.

Tested for powerpc64le and x86_64.

	[BZ #22377]
	* math/Makefile [C++] (tests): Add test for iseqsig.
	* math/math.h [C++] (iseqsig): New implementation, which does
	not rely on __MATH_TG/__builtin_types_compatible_p.
	* math/test-math-iseqsig.cc: New file.
	* sysdeps/powerpc/powerpc64le/Makefile
	(CFLAGS-test-math-iseqsig.cc): New variable.
2017-12-19 23:26:59 -02:00
Joseph Myers f1e005022e Revert exp reimplementation (causes test failures).
Revert:

	2017-12-19  Joseph Myers  <joseph@codesourcery.com>

	* sysdeps/x86_64/fpu/libm-test-ulps: Update.

	2017-12-19  Patrick McGehearty  <patrick.mcgehearty@oracle.com>

	* sysdeps/ieee754/dbl-64/e_exp.c: Include <math-svid-compat.h> and
	<errno.h>.  Include "eexp.tbl".
	(half): New constant.
	(one): Likewise.
	(__ieee754_exp): Rewrite.
	(__slowexp): Remove prototype.
	* sysdeps/ieee754/dbl-64/eexp.tbl: New file.
	* sysdeps/ieee754/dbl-64/slowexp.c: Remove file.
	* sysdeps/i386/fpu/slowexp.c: Likewise.
	* sysdeps/ia64/fpu/slowexp.c: Likewise.
	* sysdeps/m68k/m680x0/fpu/slowexp.c: Likewise.
	* sysdeps/x86_64/fpu/multiarch/slowexp-avx.c: Likewise.
	* sysdeps/x86_64/fpu/multiarch/slowexp-fma.c: Likewise.
	* sysdeps/x86_64/fpu/multiarch/slowexp-fma4.c: Likewise.
	* sysdeps/generic/math_private.h (__slowexp): Remove prototype.
	* sysdeps/ieee754/dbl-64/e_pow.c: Remove mention of slowexp.c in
	comment.
	* sysdeps/powerpc/power4/fpu/Makefile [$(subdir) = math]
	(CPPFLAGS-slowexp.c): Remove variable.
	* sysdeps/x86_64/fpu/multiarch/Makefile (libm-sysdep_routines):
	Remove slowexp-fma, slowexp-fma4 and slowexp-avx.
	(CFLAGS-slowexp-fma.c): Remove variable.
	(CFLAGS-slowexp-fma4.c): Likewise.
	(CFLAGS-slowexp-avx.c): Likewise.
	* sysdeps/x86_64/fpu/multiarch/e_exp-avx.c (__slowexp): Do not
	define as macro.
	* sysdeps/x86_64/fpu/multiarch/e_exp-fma.c (__slowexp): Likewise.
	* sysdeps/x86_64/fpu/multiarch/e_exp-fma4.c (__slowexp): Likewise.
	* math/Makefile (type-double-routines): Remove slowexp.
	* manual/probes.texi (slowexp_p6): Remove.
	(slowexp_p32): Likewise.
2017-12-19 18:11:37 +00:00
Patrick McGehearty 6fd0a3c6a8 Improve __ieee754_exp() performance by greater than 5x on sparc/x86.
These changes will be active for all platforms that don't provide
their own exp() routines. They will also be active for ieee754
versions of ccos, ccosh, cosh, csin, csinh, sinh, exp10, gamma, and
erf.

Typical performance gains is typically around 5x when measured on
Sparc s7 for common values between exp(1) and exp(40).

Using the glibc perf tests on sparc,
      sparc (nsec)    x86 (nsec)
      old     new     old     new
max   17629   395    5173     144
min     399    54      15      13
mean   5317   200    1349      23

The extreme max times for the old (ieee754) exp are due to the
multiprecision computation in the old algorithm when the true value is
very near 0.5 ulp away from an value representable in double
precision. The new algorithm does not take special measures for those
cases. The current glibc exp perf tests overrepresent those values.
Informal testing suggests approximately one in 200 cases might
invoke the high cost computation. The performance advantage of the new
algorithm for other values is still large but not as large as indicated
by the chart above.

Glibc correctness tests for exp() and expf() were run. Within the
test suite 3 input values were found to cause 1 bit differences (ulp)
when "FE_TONEAREST" rounding mode is set. No differences in exp() were
seen for the tested values for the other rounding modes.
Typical example:
exp(-0x1.760cd2p+0)  (-1.46113312244415283203125)
 new code:    2.31973271630014299393707e-01   0x1.db14cd799387ap-3
 old code:    2.31973271630014271638132e-01   0x1.db14cd7993879p-3
    exp    =  2.31973271630014285508337 (high precision)
Old delta: off by 0.49 ulp
New delta: off by 0.51 ulp

In addition, because ieee754_exp() is used by other routines, cexp()
showed test results with very small imaginary input values where the
imaginary portion of the result was off by 3 ulp when in upward
rounding mode, but not in the other rounding modes.  For x86, tgamma
showed a few values where the ulp increased to 6 (max ulp for tgamma
is 5). Sparc tgamma did not show these failures.  I presume the tgamma
differences are due to compiler optimization differences within the
gamma function.The gamma function is known to be difficult to compute
accurately.

	* sysdeps/ieee754/dbl-64/e_exp.c: Include <math-svid-compat.h> and
	<errno.h>.  Include "eexp.tbl".
	(half): New constant.
	(one): Likewise.
	(__ieee754_exp): Rewrite.
	(__slowexp): Remove prototype.
	* sysdeps/ieee754/dbl-64/eexp.tbl: New file.
	* sysdeps/ieee754/dbl-64/slowexp.c: Remove file.
	* sysdeps/i386/fpu/slowexp.c: Likewise.
	* sysdeps/ia64/fpu/slowexp.c: Likewise.
	* sysdeps/m68k/m680x0/fpu/slowexp.c: Likewise.
	* sysdeps/x86_64/fpu/multiarch/slowexp-avx.c: Likewise.
	* sysdeps/x86_64/fpu/multiarch/slowexp-fma.c: Likewise.
	* sysdeps/x86_64/fpu/multiarch/slowexp-fma4.c: Likewise.
	* sysdeps/generic/math_private.h (__slowexp): Remove prototype.
	* sysdeps/ieee754/dbl-64/e_pow.c: Remove mention of slowexp.c in
	comment.
	* sysdeps/powerpc/power4/fpu/Makefile [$(subdir) = math]
	(CPPFLAGS-slowexp.c): Remove variable.
	* sysdeps/x86_64/fpu/multiarch/Makefile (libm-sysdep_routines):
	Remove slowexp-fma, slowexp-fma4 and slowexp-avx.
	(CFLAGS-slowexp-fma.c): Remove variable.
	(CFLAGS-slowexp-fma4.c): Likewise.
	(CFLAGS-slowexp-avx.c): Likewise.
	* sysdeps/x86_64/fpu/multiarch/e_exp-avx.c (__slowexp): Do not
	define as macro.
	* sysdeps/x86_64/fpu/multiarch/e_exp-fma.c (__slowexp): Likewise.
	* sysdeps/x86_64/fpu/multiarch/e_exp-fma4.c (__slowexp): Likewise.
	* math/Makefile (type-double-routines): Remove slowexp.
	* manual/probes.texi (slowexp_p6): Remove.
	(slowexp_p32): Likewise.
2017-12-19 17:27:31 +00:00
Szabolcs Nagy 4e0dca54e9 [BZ #22593] Fix nextafter and nexttoward declaration
These functions set errno and thus the const attribute was wrong.

	[BZ #22593]
	* math/bits/mathcalls.h (nextafter): Remove const.
	(nexttoward): Likewise.
2017-12-12 13:59:18 +00:00
H.J. Lu 36975e8e7e Replace = with += in CFLAGS-xxx.c/CPPFLAGS-xxx.c
Replace = with += in CFLAGS-xxx.c and CPPFLAGS-xxx.c to allow Makefile
under sysdeps to define CFLAGS-xx.c and CPPFLAGS-xxx.c.

	* argp/Makefile (CFLAGS-argp-help.c): Replace = with +=.
	(CFLAGS-argp-parse.c): Likewise.
	(CFLAGS-argp-fmtstream.c): Likewise.
	* crypt/Makefile (CPPFLAGS-sha256-crypt.c): Likewise.
	(CPPFLAGS-sha512-crypt.c): Likewise.
	(CPPFLAGS-md5-crypt.c): Likewise.
	* debug/Makefile (CFLAGS-stack_chk_fail.c): Likewise.
	(CFLAGS-stack_chk_fail_local.c): Likewise.
	(CFLAGS-backtrace.c): Likewise.
	(CFLAGS-sprintf_chk.c): Likewise.
	(CFLAGS-snprintf_chk.c): Likewise.
	(CFLAGS-vsprintf_chk.c): Likewise.
	(CFLAGS-vsnprintf_chk.c): Likewise.
	(CFLAGS-asprintf_chk.c): Likewise.
	(CFLAGS-vasprintf_chk.c): Likewise.
	(CFLAGS-obprintf_chk.c): Likewise.
	(CFLAGS-dprintf_chk.c): Likewise.
	(CFLAGS-vdprintf_chk.c): Likewise.
	(CFLAGS-printf_chk.c): Likewise.
	(CFLAGS-fprintf_chk.c): Likewise.
	(CFLAGS-vprintf_chk.c): Likewise.
	(CFLAGS-vfprintf_chk.c): Likewise.
	(CFLAGS-gets_chk.c): Likewise.
	(CFLAGS-fgets_chk.c): Likewise.
	(CFLAGS-fgets_u_chk.c): Likewise.
	(CFLAGS-fread_chk.c): Likewise.
	(CFLAGS-fread_u_chk.c): Likewise.
	(CFLAGS-swprintf_chk.c): Likewise.
	(CFLAGS-vswprintf_chk.c): Likewise.
	(CFLAGS-wprintf_chk.c): Likewise.
	(CFLAGS-fwprintf_chk.c): Likewise.
	(CFLAGS-vwprintf_chk.c): Likewise.
	(CFLAGS-vfwprintf_chk.c): Likewise.
	(CFLAGS-fgetws_chk.c): Likewise.
	(CFLAGS-fgetws_u_chk.c): Likewise.
	(CFLAGS-read_chk.c): Likewise.
	(CFLAGS-pread_chk.c): Likewise.
	(CFLAGS-pread64_chk.c): Likewise.
	(CFLAGS-recv_chk.c): Likewise.
	(CFLAGS-recvfrom_chk.c): Likewise.
	(CFLAGS-tst-longjmp_chk.c): Likewise.
	(CPPFLAGS-tst-longjmp_chk.c): Likewise.
	(CFLAGS-tst-longjmp_chk2.c): Likewise.
	(CPPFLAGS-tst-longjmp_chk2.c): Likewise.
	(CFLAGS-tst-longjmp_chk3.c): Likewise.
	(CPPFLAGS-tst-longjmp_chk3.c): Likewise.
	(CFLAGS-tst-chk1.c): Likewise.
	(CFLAGS-tst-chk2.c): Likewise.
	(CFLAGS-tst-chk3.c): Likewise.
	(CFLAGS-tst-chk4.cc): Likewise.
	(CFLAGS-tst-chk5.cc): Likewise.
	(CFLAGS-tst-chk6.cc): Likewise.
	(CFLAGS-tst-lfschk1.c): Likewise.
	(CFLAGS-tst-lfschk2.c): Likewise.
	(CFLAGS-tst-lfschk3.c): Likewise.
	(CFLAGS-tst-lfschk4.cc): Likewise.
	(CFLAGS-tst-lfschk5.cc): Likewise.
	(CFLAGS-tst-lfschk6.cc): Likewise.
	(CFLAGS-tst-ssp-1.c): Likewise.
	* dirent/Makefile (CFLAGS-scandir.c): Likewise.
	(CFLAGS-scandir64.c): Likewise.
	(CFLAGS-scandir-tail.c): Likewise.
	(CFLAGS-scandir64-tail.c): Likewise.
	* elf/Makefile (CPPFLAGS-dl-tunables.c): Likewise.
	(CFLAGS-dl-tunables.c): Likewise.
	(CFLAGS-dl-runtime.c): Likewise.
	(CFLAGS-dl-lookup.c): Likewise.
	(CFLAGS-dl-iterate-phdr.c): Likewise.
	(CFLAGS-vismain.c): Likewise.
	(CFLAGS-tst-linkall-static.c): Likewise.
	(CFLAGS-tst-linkall-static.c): Likewise.
	(CPPFLAGS-dl-load.c): Likewise.
	(CFLAGS-ldconfig.c): Likewise.
	(CFLAGS-dl-cache.c): Likewise.
	(CFLAGS-cache.c): Likewise.
	(CFLAGS-rtld.c): Likewise.
	(CFLAGS-multiload.c): Likewise.
	(CFLAGS-filtmod1.c): Likewise.
	(CFLAGS-tst-align.c): Likewise.
	(CFLAGS-tst-align2.c): Likewise.
	(CFLAGS-tst-alignmod.c): Likewise.
	(CFLAGS-tst-alignmod2.c): Likewise.
	(CPPFLAGS-tst-execstack.c): Likewise.
	(CFLAGS-tst-ptrguard1-static.c): Likewise.
	(CFLAGS-tst-latepthreadmod.c): Likewise.
	* grp/Makefile (CFLAGS-getgrgid_r.c): Likewise.
	(CFLAGS-getgrnam_r.c): Likewise.
	(CFLAGS-getgrent_r.c): Likewise.
	(CFLAGS-getgrent.c): Likewise.
	(CFLAGS-fgetgrent.c): Likewise.
	(CFLAGS-fgetgrent_r.c): Likewise.
	(CFLAGS-putgrent.c): Likewise.
	(CFLAGS-initgroups.c): Likewise.
	(CFLAGS-getgrgid.c): Likewise.
	* gshadow/Makefile (CFLAGS-getsgent_r.c): Likewise.
	(CFLAGS-getsgent.c): Likewise.
	(CFLAGS-fgetsgent.c): Likewise.
	(CFLAGS-fgetsgent_r.c): Likewise.
	(CFLAGS-putsgent.c): Likewise.
	(CFLAGS-getsgnam.c): Likewise.
	(CFLAGS-getsgnam_r.c): Likewise.
	* iconv/Makefile (CFLAGS-iconv_prog.c): Likewise.
	(CFLAGS-iconv_charmap.c): Likewise.
	(CFLAGS-dummy-repertoire.c): Likewise.
	(CFLAGS-charmap.c): Likewise.
	(CFLAGS-linereader.c): Likewise.
	(CFLAGS-simple-hash.c): Likewise.
	(CFLAGS-gconv_conf.c): Likewise.
	(CFLAGS-iconvconfig.c): Likewise.
	* inet/Makefile (CFLAGS-gethstbyad_r.c): Likewise.
	(CFLAGS-gethstbyad.c): Likewise.
	(CFLAGS-gethstbynm_r.c): Likewise.
	(CFLAGS-gethstbynm.c): Likewise.
	(CFLAGS-gethstbynm2_r.c): Likewise.
	(CFLAGS-gethstbynm2.c): Likewise.
	(CFLAGS-gethstent_r.c): Likewise.
	(CFLAGS-gethstent.c): Likewise.
	(CFLAGS-rcmd.c): Likewise.
	(CFLAGS-getnetbynm_r.c): Likewise.
	(CFLAGS-getnetbynm.c): Likewise.
	(CFLAGS-getnetbyad_r.c): Likewise.
	(CFLAGS-getnetbyad.c): Likewise.
	(CFLAGS-getnetent_r.c): Likewise.
	(CFLAGS-getnetent.c): Likewise.
	(CFLAGS-getaliasent_r.c): Likewise.
	(CFLAGS-getaliasent.c): Likewise.
	(CFLAGS-getrpcent_r.c): Likewise.
	(CFLAGS-getrpcent.c): Likewise.
	(CFLAGS-getservent_r.c): Likewise.
	(CFLAGS-getservent.c): Likewise.
	(CFLAGS-getprtent_r.c): Likewise.
	(CFLAGS-getprtent.c): Likewise.
	(CFLAGS-either_ntoh.c): Likewise.
	(CFLAGS-either_hton.c): Likewise.
	(CFLAGS-getnetgrent.c): Likewise.
	(CFLAGS-getnetgrent_r.c): Likewise.
	(CFLAGS-tst-checks-posix.c): Likewise.
	(CFLAGS-tst-sockaddr.c): Likewise.
	* intl/Makefile (CFLAGS-tst-gettext.c): Likewise.
	(CFLAGS-tst-translit.c): Likewise.
	(CFLAGS-tst-gettext2.c): Likewise.
	(CFLAGS-tst-codeset.c): Likewise.
	(CFLAGS-tst-gettext3.c): Likewise.
	(CFLAGS-tst-gettext4.c): Likewise.
	(CFLAGS-tst-gettext5.c): Likewise.
	(CFLAGS-tst-gettext6.c): Likewise.
	* io/Makefile (CFLAGS-open.c): Likewise.
	(CFLAGS-open64.c): Likewise.
	(CFLAGS-creat.c): Likewise.
	(CFLAGS-creat64.c): Likewise.
	(CFLAGS-fcntl.c): Likewise.
	(CFLAGS-poll.c): Likewise.
	(CFLAGS-ppoll.c): Likewise.
	(CFLAGS-lockf.c): Likewise.
	(CFLAGS-statfs.c): Likewise.
	(CFLAGS-fstatfs.c): Likewise.
	(CFLAGS-statvfs.c): Likewise.
	(CFLAGS-fstatvfs.c): Likewise.
	(CFLAGS-fts.c): Likewise.
	(CFLAGS-fts64.c): Likewise.
	(CFLAGS-ftw.c): Likewise.
	(CFLAGS-ftw64.c): Likewise.
	(CFLAGS-lockf.c): Likewise.
	(CFLAGS-posix_fallocate.c): Likewise.
	(CFLAGS-posix_fallocate64.c): Likewise.
	(CFLAGS-fallocate.c): Likewise.
	(CFLAGS-fallocate64.c): Likewise.
	(CFLAGS-read.c): Likewise.
	(CFLAGS-write.c): Likewise.
	(CFLAGS-test-stat.c): Likewise.
	(CFLAGS-test-lfs.c): Likewise.
	* libio/Makefile (CFLAGS-fileops.c): Likewise.
	(CFLAGS-fputc.c): Likewise.
	(CFLAGS-fputwc.c): Likewise.
	(CFLAGS-freopen64.c): Likewise.
	(CFLAGS-freopen.c): Likewise.
	(CFLAGS-fseek.c): Likewise.
	(CFLAGS-fseeko64.c): Likewise.
	(CFLAGS-fseeko.c): Likewise.
	(CFLAGS-ftello64.c): Likewise.
	(CFLAGS-ftello.c): Likewise.
	(CFLAGS-fwide.c): Likewise.
	(CFLAGS-genops.c): Likewise.
	(CFLAGS-getc.c): Likewise.
	(CFLAGS-getchar.c): Likewise.
	(CFLAGS-getwc.c): Likewise.
	(CFLAGS-getwchar.c): Likewise.
	(CFLAGS-iofclose.c): Likewise.
	(CFLAGS-iofflush.c): Likewise.
	(CFLAGS-iofgetpos64.c): Likewise.
	(CFLAGS-iofgetpos.c): Likewise.
	(CFLAGS-iofgets.c): Likewise.
	(CFLAGS-iofgetws.c): Likewise.
	(CFLAGS-iofputs.c): Likewise.
	(CFLAGS-iofputws.c): Likewise.
	(CFLAGS-iofread.c): Likewise.
	(CFLAGS-iofsetpos64.c): Likewise.
	(CFLAGS-iofsetpos.c): Likewise.
	(CFLAGS-ioftell.c): Likewise.
	(CFLAGS-iofwrite.c): Likewise.
	(CFLAGS-iogetdelim.c): Likewise.
	(CFLAGS-iogetline.c): Likewise.
	(CFLAGS-iogets.c): Likewise.
	(CFLAGS-iogetwline.c): Likewise.
	(CFLAGS-ioputs.c): Likewise.
	(CFLAGS-ioseekoff.c): Likewise.
	(CFLAGS-ioseekpos.c): Likewise.
	(CFLAGS-iosetbuffer.c): Likewise.
	(CFLAGS-iosetvbuf.c): Likewise.
	(CFLAGS-ioungetc.c): Likewise.
	(CFLAGS-ioungetwc.c): Likewise.
	(CFLAGS-oldfileops.c): Likewise.
	(CFLAGS-oldiofclose.c): Likewise.
	(CFLAGS-oldiofgetpos64.c): Likewise.
	(CFLAGS-oldiofgetpos.c): Likewise.
	(CFLAGS-oldiofsetpos64.c): Likewise.
	(CFLAGS-oldiofsetpos.c): Likewise.
	(CFLAGS-peekc.c): Likewise.
	(CFLAGS-putc.c): Likewise.
	(CFLAGS-putchar.c): Likewise.
	(CFLAGS-putwc.c): Likewise.
	(CFLAGS-putwchar.c): Likewise.
	(CFLAGS-rewind.c): Likewise.
	(CFLAGS-wfileops.c): Likewise.
	(CFLAGS-wgenops.c): Likewise.
	(CFLAGS-oldiofopen.c): Likewise.
	(CFLAGS-iofopen.c): Likewise.
	(CFLAGS-iofopen64.c): Likewise.
	(CFLAGS-oldtmpfile.c): Likewise.
	(CFLAGS-tst_putwc.c): Likewise.
	* locale/Makefile (CFLAGS-md5.c): Likewise.
	(CFLAGS-charmap.c): Likewise.
	(CFLAGS-locfile.c): Likewise.
	(CFLAGS-charmap-dir.c): Likewise.
	* login/Makefile (CFLAGS-grantpt.c): Likewise.
	(CFLAGS-getpt.c): Likewise.
	(CFLAGS-pt_chown.c): Likewise.
	* malloc/Makefile (CFLAGS-mcheck-init.c): Likewise.
	(CFLAGS-obstack.c): Likewise.
	* math/Makefile (CFLAGS-test-tgmath3.c): Likewise.
	(CFLAGS-test-double-vlen4-wrappers.c): Likewise.
	(CFLAGS-test-double-vlen8-wrappers.c): Likewise.
	(CFLAGS-test-float-vlen8-wrappers.c): Likewise.
	(CFLAGS-test-float-vlen16-wrappers.c): Likewise.
	(CFLAGS-test-tgmath.c): Likewise.
	(CFLAGS-test-tgmath2.c): Likewise.
	(CFLAGS-test-tgmath-ret.c): Likewise.
	(CFLAGS-test-powl.c): Likewise.
	(CFLAGS-test-snan.c): Likewise.
	(CFLAGS-test-signgam-finite.c): Likewise.
	(CFLAGS-test-signgam-finite-c99.c): Likewise.
	(CFLAGS-test-signgam-finite-c11.c): Likewise.
	(CFLAGS-test-signgam-uchar.c): Likewise.
	(CFLAGS-test-signgam-uchar-init.c): Likewise.
	(CFLAGS-test-signgam-uchar-static.c): Likewise.
	(CFLAGS-test-signgam-uchar-init-static.c): Likewise.
	(CFLAGS-test-signgam-uint.c): Likewise.
	(CFLAGS-test-signgam-uint-init.c): Likewise.
	(CFLAGS-test-signgam-uint-static.c): Likewise.
	(CFLAGS-test-signgam-uint-init-static.c): Likewise.
	(CFLAGS-test-signgam-ullong.c): Likewise.
	(CFLAGS-test-signgam-ullong-init.c): Likewise.
	(CFLAGS-test-signgam-ullong-static.c): Likewise.
	(CFLAGS-test-signgam-ullong-init-static.c): Likewise.
	(CFLAGS-test-math-cxx11.cc): Likewise.
	(CFLAGS-test-math-isinff.cc): Likewise.
	(CFLAGS-test-math-iszero.cc): Likewise.
	(CFLAGS-test-math-issignaling.cc): Likewise.
	(CFLAGS-test-math-iscanonical.cc): Likewise.
	(CFLAGS-test-iszero-excess-precision.c): Likewise.
	(CFLAGS-test-iseqsig-excess-precision.c): Likewise.
	(CFLAGS-test-flt-eval-method.c): Likewise.
	(CFLAGS-test-fe-snans-always-signal.c): Likewise.
	(CFLAGS-test-finite-macros.c): Likewise.
	* misc/Makefile (CFLAGS-select.c): Likewise.
	(CFLAGS-tsearch.c): Likewise.
	(CFLAGS-lsearch.c): Likewise.
	(CFLAGS-pselect.c): Likewise.
	(CFLAGS-readv.c): Likewise.
	(CFLAGS-writev.c): Likewise.
	(CFLAGS-preadv.c): Likewise.
	(CFLAGS-preadv64.c): Likewise.
	(CFLAGS-pwritev.c): Likewise.
	(CFLAGS-pwritev64.c): Likewise.
	(CFLAGS-preadv2.c): Likewise.
	(CFLAGS-preadv64v2.c): Likewise.
	(CFLAGS-pwritev2.c): Likewise.
	(CFLAGS-pwritev64v2.c): Likewise.
	(CFLAGS-usleep.c): Likewise.
	(CFLAGS-syslog.c): Likewise.
	(CFLAGS-error.c): Likewise.
	(CFLAGS-getpass.c): Likewise.
	(CFLAGS-mkstemp.c): Likewise.
	(CFLAGS-mkstemp64.c): Likewise.
	(CFLAGS-getsysstats.c): Likewise.
	(CFLAGS-getusershell.c): Likewise.
	(CFLAGS-err.c): Likewise.
	(CFLAGS-tst-tsearch.c): Likewise.
	(CFLAGS-msync.c): Likewise.
	(CFLAGS-fdatasync.c): Likewise.
	(CFLAGS-fsync.c): Likewise.
	* nptl/Makefile (CFLAGS-nptl-init.c): Likewise.
	(CFLAGS-unwind.c): Likewise.
	(CFLAGS-unwind-forcedunwind.c): Likewise.
	(CFLAGS-pthread_cancel.c): Likewise.
	(CFLAGS-pthread_setcancelstate.c): Likewise.
	(CFLAGS-pthread_setcanceltype.c): Likewise.
	(CFLAGS-cancellation.c): Likewise.
	(CFLAGS-libc-cancellation.c): Likewise.
	(CFLAGS-pthread_exit.c): Likewise.
	(CFLAGS-forward.c): Likewise.
	(CFLAGS-pthread_testcancel.c): Likewise.
	(CFLAGS-pthread_join.c): Likewise.
	(CFLAGS-pthread_timedjoin.c): Likewise.
	(CFLAGS-pthread_once.c): Likewise.
	(CFLAGS-pthread_cond_wait.c): Likewise.
	(CFLAGS-sem_wait.c): Likewise.
	(CFLAGS-sem_timedwait.c): Likewise.
	(CFLAGS-fcntl.c): Likewise.
	(CFLAGS-lockf.c): Likewise.
	(CFLAGS-pread.c): Likewise.
	(CFLAGS-pread64.c): Likewise.
	(CFLAGS-pwrite.c): Likewise.
	(CFLAGS-pwrite64.c): Likewise.
	(CFLAGS-wait.c): Likewise.
	(CFLAGS-waitpid.c): Likewise.
	(CFLAGS-sigwait.c): Likewise.
	(CFLAGS-msgrcv.c): Likewise.
	(CFLAGS-msgsnd.c): Likewise.
	(CFLAGS-tcdrain.c): Likewise.
	(CFLAGS-open.c): Likewise.
	(CFLAGS-open64.c): Likewise.
	(CFLAGS-pause.c): Likewise.
	(CFLAGS-recv.c): Likewise.
	(CFLAGS-send.c): Likewise.
	(CFLAGS-accept.c): Likewise.
	(CFLAGS-sendto.c): Likewise.
	(CFLAGS-connect.c): Likewise.
	(CFLAGS-recvfrom.c): Likewise.
	(CFLAGS-recvmsg.c): Likewise.
	(CFLAGS-sendmsg.c): Likewise.
	(CFLAGS-close.c): Likewise.
	(CFLAGS-read.c): Likewise.
	(CFLAGS-write.c): Likewise.
	(CFLAGS-nanosleep.c): Likewise.
	(CFLAGS-sigsuspend.c): Likewise.
	(CFLAGS-msync.c): Likewise.
	(CFLAGS-fdatasync.c): Likewise.
	(CFLAGS-fsync.c): Likewise.
	(CFLAGS-pt-system.c): Likewise.
	(CFLAGS-tst-cleanup2.c): Likewise.
	(CFLAGS-tst-cleanupx2.c): Likewise.
	(CFLAGS-flockfile.c): Likewise.
	(CFLAGS-ftrylockfile.c): Likewise.
	(CFLAGS-funlockfile.c): Likewise.
	(CFLAGS-tst-initializers1.c): Likewise.
	(CFLAGS-tst-initializers1-c89.c): Likewise.
	(CFLAGS-tst-initializers1-c99.c): Likewise.
	(CFLAGS-tst-initializers1-c11.c): Likewise.
	(CFLAGS-tst-initializers1-gnu89.c): Likewise.
	(CFLAGS-tst-initializers1-gnu99.c): Likewise.
	(CFLAGS-tst-initializers1-gnu11.c): Likewise.
	* nscd/Makefile (CFLAGS-nscd_getpw_r.c): Likewise.
	(CFLAGS-nscd_getgr_r.c): Likewise.
	(CFLAGS-nscd_gethst_r.c): Likewise.
	(CFLAGS-nscd_getai.c): Likewise.
	(CFLAGS-nscd_initgroups.c): Likewise.
	* posix/Makefile (CFLAGS-getaddrinfo.c): Likewise.
	(CFLAGS-pause.c): Likewise.
	(CFLAGS-pread.c): Likewise.
	(CFLAGS-pread64.c): Likewise.
	(CFLAGS-pwrite.c): Likewise.
	(CFLAGS-pwrite64.c): Likewise.
	(CFLAGS-sleep.c): Likewise.
	(CFLAGS-wait.c): Likewise.
	(CFLAGS-waitid.c): Likewise.
	(CFLAGS-waitpid.c): Likewise.
	(CFLAGS-getopt.c): Likewise.
	(CFLAGS-wordexp.c): Likewise.
	(CFLAGS-sysconf.c): Likewise.
	(CFLAGS-pathconf.c): Likewise.
	(CFLAGS-fpathconf.c): Likewise.
	(CFLAGS-spawn.c): Likewise.
	(CFLAGS-spawnp.c): Likewise.
	(CFLAGS-spawni.c): Likewise.
	(CFLAGS-glob.c): Likewise.
	(CFLAGS-glob64.c): Likewise.
	(CFLAGS-getconf.c): Likewise.
	(CFLAGS-nanosleep.c): Likewise.
	* pwd/Makefile (CFLAGS-getpwent_r.c): Likewise.
	(CFLAGS-getpwent.c): Likewise.
	(CFLAGS-getpw.c): Likewise.
	(CFLAGS-fgetpwent_r.c): Likewise.
	* resolv/Makefile (CFLAGS-res_hconf.c): Likewise.
	* rt/Makefile (CFLAGS-aio_suspend.c): Likewise.
	(CFLAGS-mq_timedreceive.c): Likewise.
	(CFLAGS-mq_timedsend.c): Likewise.
	(CFLAGS-clock_nanosleep.c): Likewise.
	(CFLAGS-librt-cancellation.c): Likewise.
	* shadow/Makefile (CFLAGS-getspent_r.c): Likewise.
	(CFLAGS-getspent.c): Likewise.
	(CFLAGS-fgetspent.c): Likewise.
	(CFLAGS-fgetspent_r.c): Likewise.
	(CFLAGS-putspent.c): Likewise.
	(CFLAGS-getspnam.c): Likewise.
	(CFLAGS-getspnam_r.c): Likewise.
	* signal/Makefile (CFLAGS-sigpause.c): Likewise.
	(CFLAGS-sigsuspend.c): Likewise.
	(CFLAGS-sigtimedwait.c): Likewise.
	(CFLAGS-sigwait.c): Likewise.
	(CFLAGS-sigwaitinfo.c): Likewise.
	(CFLAGS-sigreturn.c): Likewise.
	* stdio-common/Makefile (CFLAGS-vfprintf.c): Likewise.
	(CFLAGS-vfwprintf.c): Likewise.
	(CFLAGS-tmpfile.c): Likewise.
	(CFLAGS-tmpfile64.c): Likewise.
	(CFLAGS-tempname.c): Likewise.
	(CFLAGS-psignal.c): Likewise.
	(CFLAGS-vprintf.c): Likewise.
	(CFLAGS-cuserid.c): Likewise.
	(CFLAGS-errlist.c): Likewise.
	(CFLAGS-siglist.c): Likewise.
	(CFLAGS-scanf15.c): Likewise.
	(CFLAGS-scanf17.c): Likewise.
	* stdlib/Makefile (CFLAGS-bsearch.c): Likewise.
	(CFLAGS-msort.c): Likewise.
	(CFLAGS-qsort.c): Likewise.
	(CFLAGS-system.c): Likewise.
	(CFLAGS-fmtmsg.c): Likewise.
	(CFLAGS-strfmon.c): Likewise.
	(CFLAGS-strfmon_l.c): Likewise.
	(CFLAGS-strfromd.c): Likewise.
	(CFLAGS-strfromf.c): Likewise.
	(CFLAGS-strfroml.c): Likewise.
	(CFLAGS-tst-bsearch.c): Likewise.
	(CFLAGS-tst-qsort.c): Likewise.
	(CFLAGS-tst-makecontext2.c): Likewise.
	* sunrpc/Makefile (CFLAGS-xbootparam_prot.c): Likewise.
	(CFLAGS-xnlm_prot.c): Likewise.
	(CFLAGS-xrstat.c): Likewise.
	(CFLAGS-xyppasswd.c): Likewise.
	(CFLAGS-xklm_prot.c): Likewise.
	(CFLAGS-xrex.c): Likewise.
	(CFLAGS-xsm_inter.c): Likewise.
	(CFLAGS-xmount.c): Likewise.
	(CFLAGS-xrusers.c): Likewise.
	(CFLAGS-xspray.c): Likewise.
	(CFLAGS-xnfs_prot.c): Likewise.
	(CFLAGS-xrquota.c): Likewise.
	(CFLAGS-xkey_prot.c): Likewise.
	(CFLAGS-auth_unix.c): Likewise.
	(CFLAGS-key_call.c): Likewise.
	(CFLAGS-pmap_rmt.c): Likewise.
	(CFLAGS-clnt_perr.c): Likewise.
	(CFLAGS-openchild.c): Likewise.
	* sysvipc/Makefile (CFLAGS-msgrcv.c): Likewise.
	(CFLAGS-msgsnd.c): Likewise.
	* termios/Makefile (CFLAGS-tcdrain.c): Likewise.
	* time/Makefile (CFLAGS-tzfile.c): Likewise.
	(CFLAGS-tzset.c): Likewise.
	(CFLAGS-getdate.c): Likewise.
	(CFLAGS-test_time.c): Likewise.
	(CPPFLAGS-tst-tzname.c): Likewise.
	* timezone/Makefile (CFLAGS-zdump.c): Likewise.
	(CFLAGS-zic.c): Likewise.
	* wcsmbs/Makefile (CFLAGS-wcwidth.c): Likewise.
	(CFLAGS-wcswidth.c): Likewise.
	(CFLAGS-wcstol.c): Likewise.
	(CFLAGS-wcstoul.c): Likewise.
	(CFLAGS-wcstoll.c): Likewise.
	(CFLAGS-wcstoull.c): Likewise.
	(CFLAGS-wcstod.c): Likewise.
	(CFLAGS-wcstold.c): Likewise.
	(CFLAGS-wcstof128.c): Likewise.
	(CFLAGS-wcstof.c): Likewise.
	(CFLAGS-wcstol_l.c): Likewise.
	(CFLAGS-wcstoul_l.c): Likewise.
	(CFLAGS-wcstoll_l.c): Likewise.
	(CFLAGS-wcstoull_l.c): Likewise.
	(CFLAGS-wcstod_l.c): Likewise.
	(CFLAGS-wcstold_l.c): Likewise.
	(CFLAGS-wcstof128_l.c): Likewise.
	(CFLAGS-wcstof_l.c): Likewise.
	(CPPFLAGS-tst-wchar-h.c): Likewise.
	(CPPFLAGS-wcstold_l.c): Likewise.

Reviewed-by: Jonathan Nieder <jrnieder@gmail.com>
2017-12-11 13:11:33 -08:00
Joseph Myers d15e83c5f5 Fix ctanh (0 + i NaN), ctanh (0 + i Inf) (bug 22568, DR#471).
As per C11 DR#471, ctanh (0 + i NaN) and ctanh (0 + i Inf) should
return 0 + i NaN (with "invalid" exception in the second case but not
the first), not NaN + i NaN.  This has corresponding implications for
ctan since its special cases are defined by ctan (z) = -i ctanh (iz).
This patch implements these cases for ctanh and ctan, updating
tests accordingly.

Tested for x86_64.

	[BZ #22568]
	* math/s_ctan_template.c (M_DECL_FUNC (__ctan)): Set imaginary
	part of result to imaginary part of argument if it is zero and the
	real part of the argument is not finite.
	* math/s_ctanh_template.c (M_DECL_FUNC (__ctanh)): Set real part
	of result to real part of argument if it is zero and the imaginary
	part of the argument is not finite.
2017-12-07 16:21:00 +00:00
Joseph Myers 1f9055ce04 Add _Float32 function aliases.
This patch concludes filling out TS 18661-3 support for different
types by adding *f32 function aliases of float functions to support
_Float32.  As with _Float64 and _Float32x, this is supported for all
glibc configurations.  As with the previous such patches there are
some x86 ulps updates because of inline functions present for float
but not for _Float32.  The patch also has the usual
bits/floatn-common.h update, symbol versions, ABI baselines updates,
test enablement and documentation.

Tested for x86_64 and x86, and with build-many-glibcs.py, with both
GCC 6 and GCC 7.

	* bits/floatn-common.h (__HAVE_FLOAT32): Define to 1.
	* manual/math.texi (Mathematics): Document support for _Float32.
	* math/Makefile (test-types): Add float32.
	* math/Versions (GLIBC_2.27): Add _Float32 functions.
	* stdlib/Versions (GLIBC_2.27): Likewise.
	* wcsmbs/Versions (GLIBC_2.27): Likewise.
	* sysdeps/unix/sysv/linux/aarch64/libc.abilist: Update.
	* sysdeps/unix/sysv/linux/aarch64/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/alpha/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/alpha/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/arm/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/arm/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/hppa/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/hppa/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/i386/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/i386/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/ia64/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/ia64/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/m68k/coldfire/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/m68k/m680x0/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/microblaze/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/microblaze/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/mips/mips32/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist:
	Likewise.
	* sysdeps/unix/sysv/linux/mips/mips64/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/nios2/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/nios2/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist:
	Likewise.
	* sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libm.abilist:
	Likewise.
	* sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist:
	Likewise.
	* sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libm.abilist:
	Likewise.

	* sysdeps/unix/sysv/linux/powerpc/powerpc64/libc-le.abilist:
	Likewise.
	* sysdeps/unix/sysv/linux/powerpc/powerpc64/libc.abilist:
	Likewise.
	* sysdeps/unix/sysv/linux/powerpc/powerpc64/libm-le.abilist:
	Likewise.
	* sysdeps/unix/sysv/linux/powerpc/powerpc64/libm.abilist:
	Likewise.
	* sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/s390/s390-32/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/s390/s390-64/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/sh/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/sh/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/sparc/sparc32/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/sparc/sparc64/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/tile/tilegx/tilegx32/libc.abilist:
	Likewise.
	* sysdeps/unix/sysv/linux/tile/tilegx/tilegx32/libm.abilist:
	Likewise.
	* sysdeps/unix/sysv/linux/tile/tilegx/tilegx64/libc.abilist:
	Likewise.
	* sysdeps/unix/sysv/linux/tile/tilegx/tilegx64/libm.abilist:
	Likewise.
	* sysdeps/unix/sysv/linux/tile/tilepro/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/tile/tilepro/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/x86_64/64/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/x86_64/64/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/x86_64/x32/libm.abilist: Likewise.
	* sysdeps/i386/fpu/libm-test-ulps: Likewise.
	* sysdeps/i386/i686/fpu/multiarch/libm-test-ulps: Likewise.
2017-12-07 00:48:31 +00:00
Joseph Myers e420d22826 Add header for _Float32 testing.
This patch adds the header required for testing _Float32 function
aliases, using float ulps.  The corresponding makefile support will be
included in the main patch that enables those aliases.

In conjunction with other _Float32 changes, tested for x86_64 and with
build-many-glibcs.py.

	* math/test-float32.h: New file.
2017-12-06 22:17:11 +00:00
Joseph Myers 5244527da1 Make cacosh (0 + iNaN) return NaN + i pi/2 (bug 22561, DR#471).
As per C11 DR#471 (adjusted resolution accepted for C17), cacosh (0 +
iNaN) should return NaN +/- i pi/2, not NaN + iNaN.

This patch fixes the code accordingly.  The test has hardcoded the
result with positive sign of the imaginary part (with an associated
comment), since the unspecified sign for a result other than 0 or
infinity isn't currently supported by the test infrastructure.

Tested for x86_64.

	[BZ #22561]
	* math/s_cacosh_template.c (M_DECL_FUNC (__cacosh)): Use pi/2 for
	real part of result for argument 0 + i * NaN.
	* math/libm-test-cacosh.inc (cacosh_test_data): Update expected
	results for tests of 0 + i * NaN.
2017-12-06 21:35:20 +00:00
Joseph Myers 0d93b7fd7c Add _Float64, _Float32x function aliases.
This patch continues filling out TS 18661-3 support by adding *f64 and
*f32x function aliases, supporting _Float64 and _Float32x, as aliases
for double functions.  These types are supported for all glibc
configurations.  The API corresponds exactly to that for _Float128 and
_Float64x.  _Float32 aliases to float functions remain to be added in
subsequent patches to complete this process (then there are a few
miscellaneous functions in TS 18661-3 to implement that aren't simply
versions of existing functions for new types).

The patch enables the feature in bits/floatn-common.h, adds symbol
versions and documentation with updates to ABI baselines, and arranges
for the libm functions for the new types to be tested.  As with the
_Float64x changes there are some x86 ulps updates because of header
inlines not used for the new types (and one other change to the
non-multiarch libm-test-ulps, which I suppose comes from using a
different compiler version / configuration from when it was last
regenerated).

Tested for x86_64 and x86, and with build-many-glibcs.py, with both
GCC 6 and GCC 7.

	* bits/floatn-common.h (__HAVE_FLOAT64): Define to 1.
	(__HAVE_FLOAT32X): Likewise.
	* manual/math.texi (Mathematics): Document support for _Float64
	and _Float32x.
	* math/Makefile (test-types): Add float64 and float32x.
	* math/Versions (GLIBC_2.27): Add _Float64 and _Float32x
	functions.
	* stdlib/Versions (GLIBC_2.27): Likewise.
	* wcsmbs/Versions (GLIBC_2.27): Likewise.
	* sysdeps/unix/sysv/linux/aarch64/libc.abilist: Update.
	* sysdeps/unix/sysv/linux/aarch64/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/alpha/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/alpha/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/arm/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/arm/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/hppa/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/hppa/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/i386/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/i386/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/ia64/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/ia64/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/m68k/coldfire/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/m68k/m680x0/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/microblaze/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/microblaze/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/mips/mips32/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist:
	Likewise.
	* sysdeps/unix/sysv/linux/mips/mips64/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/nios2/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/nios2/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist:
	Likewise.
	* sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libm.abilist:
	Likewise.
	* sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist:
	Likewise.
	* sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libm.abilist:
	Likewise.
	* sysdeps/unix/sysv/linux/powerpc/powerpc64/libc-le.abilist:
	Likewise.
	* sysdeps/unix/sysv/linux/powerpc/powerpc64/libc.abilist:
	Likewise.
	* sysdeps/unix/sysv/linux/powerpc/powerpc64/libm-le.abilist:
	Likewise.
	* sysdeps/unix/sysv/linux/powerpc/powerpc64/libm.abilist:
	Likewise.
	* sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/s390/s390-32/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/s390/s390-64/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/sh/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/sh/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/sparc/sparc32/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/sparc/sparc64/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/tile/tilegx/tilegx32/libc.abilist:
	Likewise.
	* sysdeps/unix/sysv/linux/tile/tilegx/tilegx32/libm.abilist:
	Likewise.
	* sysdeps/unix/sysv/linux/tile/tilegx/tilegx64/libc.abilist:
	Likewise.
	* sysdeps/unix/sysv/linux/tile/tilegx/tilegx64/libm.abilist:
	Likewise.
	* sysdeps/unix/sysv/linux/tile/tilepro/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/tile/tilepro/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/x86_64/64/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/x86_64/64/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/x86_64/x32/libm.abilist: Likewise.
	* sysdeps/i386/fpu/libm-test-ulps: Likewise.
	* sysdeps/i386/i686/fpu/multiarch/libm-test-ulps: Likewise.
2017-12-06 00:58:03 +00:00
Joseph Myers e2c4dce535 Add headers for _Float64, _Float32x testing.
This patch adds the headers required for testing _Float64 and
_Float32x function aliases (using double ulps).  The corresponding
makefile support will be included in the patch that actually adds
those aliases; there doesn't seem much point in adding makefile
conditionals for testing something that will be available
unconditionally.

In conjunction with other _Float64 / _Float32x changes, test for
x86_64 and with build-many-glibcs.py.

	* math/test-float32x.h: New file.
	* math/test-float64.h: Likewise.
2017-12-05 17:34:25 +00:00
Joseph Myers a23aa5b727 Add _Float64x function aliases.
This patch continues filling out TS 18661-3 support by adding *f64x
function aliases on platforms with _Float64x support.  (It so happens
the set of such platforms is exactly the same as the set of platforms
with _Float128 support, although on x86_64, x86 and ia32 the _Float64x
format is Intel extended rather than binary128.)  The API provided
corresponds exactly to that provided for _Float128, mostly coming from
TS 18661-3.  As these functions always alias those for another type
(long double, _Float128 or both), __* function names are not provided,
as in other cases of alias types.

Given the preparation done in previous patches, this one just enables
the feature via Makeconfig and bits/floatn.h, adds symbol versions,
and updates documentation and ABI baselines.  The symbol versions are
present unconditionally as GLIBC_2.27 in the relevant Versions files,
as it's OK for those to specify versions for functions that may not be
present in some configurations; no additional complexity is needed
unless in future some configuration gains support for this type that
didn't have such support in 2.27.  The Makeconfig additions for ia64
and x86 aren't strictly needed, as those configurations also get
float64x-alias-fcts definitions from
sysdeps/ieee754/float128/Makeconfig, but still seem appropriate given
that _Float64x is not _Float128 for those configurations.

A libm-test-ulps update for x86 is included.  This is because
bits/mathinline.h does not have _Float64x support added and for two
functions the use of out-of-line functions results in increased ulps
(ifloat64x shares ulps with ildouble / ifloat128 as appropriate).
Given that we'd like generally to eliminate bits/mathinline.h
optimizations, preferring to have such optimizations in GCC instead,
it seems reasonable not to add such support there for new types.  GCC
support for _FloatN / _FloatNx built-in functions is limited, but has
been improved in GCC 8, and at some point I hope the full set of libm
built-in functions in GCC, and other optimizations with
per-floating-type aspects, will be enabled for all _FloatN / _FloatNx
types.

Tested for x86_64 and x86, and with build-many-glibcs.py, with both
GCC 6 and GCC 7.

	* sysdeps/ia64/Makeconfig (float64x-alias-fcts): New variable.
	* sysdeps/ieee754/float128/Makeconfig (float64x-alias-fcts):
	Likewise.
	* sysdeps/ieee754/ldbl-128/Makeconfig (float64x-alias-fcts):
	Likewise.
	* sysdeps/x86/Makeconfig: New file.
	* bits/floatn-common.h (__HAVE_FLOAT64X): Remove macro.
	(__HAVE_FLOAT64X_LONG_DOUBLE): Likewise.
	* bits/floatn.h (__HAVE_FLOAT64X): New macro.
	(__HAVE_FLOAT64X_LONG_DOUBLE): Likewise.
	* sysdeps/ia64/bits/floatn.h (__HAVE_FLOAT64X): Likewise.
	(__HAVE_FLOAT64X_LONG_DOUBLE): Likewise.
	* sysdeps/ieee754/ldbl-128/bits/floatn.h (__HAVE_FLOAT64X):
	Likewise.
	(__HAVE_FLOAT64X_LONG_DOUBLE): Likewise.
	* sysdeps/mips/ieee754/bits/floatn.h (__HAVE_FLOAT64X): Likewise.
	(__HAVE_FLOAT64X_LONG_DOUBLE): Likewise.
	* sysdeps/powerpc/bits/floatn.h (__HAVE_FLOAT64X): Likewise.
	(__HAVE_FLOAT64X_LONG_DOUBLE): Likewise.
	* sysdeps/x86/bits/floatn.h (__HAVE_FLOAT64X): Likewise.
	(__HAVE_FLOAT64X_LONG_DOUBLE): Likewise.
	* manual/math.texi (Mathematics): Document support for _Float64x.
	* math/Versions (GLIBC_2.27): Add _Float64x functions.
	* stdlib/Versions (GLIBC_2.27): Likewise.
	* wcsmbs/Versions (GLIBC_2.27): Likewise.
	* sysdeps/unix/sysv/linux/aarch64/libc.abilist: Update.
	* sysdeps/unix/sysv/linux/aarch64/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/alpha/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/alpha/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/i386/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/i386/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/ia64/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/ia64/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/mips/mips64/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/powerpc/powerpc64/libc-le.abilist:
	Likewise.
	* sysdeps/unix/sysv/linux/powerpc/powerpc64/libm-le.abilist:
	Likewise.
	* sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/s390/s390-32/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/s390/s390-64/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/sparc/sparc32/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/sparc/sparc64/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/x86_64/64/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/x86_64/64/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/x86_64/x32/libm.abilist: Likewise.
	* sysdeps/i386/fpu/libm-test-ulps: Likewise.
	* sysdeps/i386/i686/fpu/multiarch/libm-test-ulps: Likewise.
2017-11-27 14:16:47 +00:00
Joseph Myers ae7207d033 Support testing _Float64x libm functions.
This patch adds support for testing _Float64x libm functions.  A
configuration with such functions sets float64x-alias-fcts = yes in a
sysdeps Makeconfig file; until such settings are added, this test
support is inactive.

Tested for x86_64, including in conjunction with _Float64x support
patches.

	* math/test-float64x.h: New file.
	* math/Makefile (type-float64x-yes): New variable.
	(test-types): Add $(type-float64x-$(float64x-alias-fcts)).
2017-11-24 22:25:03 +00:00
Joseph Myers 01e659e711 Fix gen-tgmath-tests.py for _Float64, _Float64x testing.
math/gen-tgmath-tests.py was missing a create_type argument when
creating the internal types for combinations of long double with
_Float64 and _Float64x, so resulting in output that did not compile
when glibc support for those types was enabled.  This patch adds the
missing argument so that the tests properly compile in that case.

Tested for x86_64, including in conjunction with _Float64x support
patches.

	* math/gen-tgmath-tests.py (Type.init_types): Pass suffix argument
	for combinations of long double with _Float64 and _Float64x.
2017-11-24 21:22:34 +00:00
Joseph Myers be3a79a3cc Use __builtin_tgmath in tgmath.h with GCC 8 (bug 21660).
GCC mainline now supports __builtin_tgmath to allow <tgmath.h> macro
implementations that expand their arguments only once, so avoiding
exponential blowup in the size of macro expansions when calls to those
macros are nested in arguments to those macros.

This patch makes glibc's tgmath.h support using __builtin_tgmath, as a
much simpler and more efficient alternative to the existing
implementation.  (As a side effect, the new feature would make it much
more practical to support decimal floating point in <tgmath.h> with
new compilers; currently, libdfp does not provide a <tgmath.h>
implementation, and making decimal arguments cause integer arguments
to be considered of type _Decimal64 instead of double would have been
very problematic in the old implementation.)

Tested for x86_64 (with GCC mainline).

	[BZ #21660]
	* math/tgmath.h (__HAVE_BUILTIN_TGMATH): New macro.
	[__HAVE_BUILTIN_TGMATH] (__TG_F16_ARG): Likewise.
	[__HAVE_BUILTIN_TGMATH] (__TG_F32_ARG): Likewise.
	[__HAVE_BUILTIN_TGMATH] (__TG_F64_ARG): Likewise.
	[__HAVE_BUILTIN_TGMATH] (__TG_F128_ARG): Likewise.
	[__HAVE_BUILTIN_TGMATH] (__TG_F32X_ARG): Likewise.
	[__HAVE_BUILTIN_TGMATH] (__TG_F64X_ARG): Likewise.
	[__HAVE_BUILTIN_TGMATH] (__TG_F128X_ARG): Likewise.
	[__HAVE_BUILTIN_TGMATH] (__TGMATH_FUNCS): Likewise.
	[__HAVE_BUILTIN_TGMATH] (__TGMATH_RCFUNCS): Likewise.
	[__HAVE_BUILTIN_TGMATH] (__TGMATH_1): Likewise.
	[__HAVE_BUILTIN_TGMATH] (__TGMATH_2): Likewise.
	[__HAVE_BUILTIN_TGMATH] (__TGMATH_2STD): Likewise.
	[__HAVE_BUILTIN_TGMATH] (__TGMATH_3): Likewise.
	[__HAVE_BUILTIN_TGMATH] (__TGMATH_1C): Likewise.
	[__HAVE_BUILTIN_TGMATH] (__TGMATH_2C): Likewise.
	(__tgml): Make conditional on [!__HAVE_BUILTIN_TGMATH].
	(__floating_type): Likewise.
	(__real_integer_type): Likewise.
	(__complex_integer_type): Likewise.
	(__expr_is_real): Likewise.
	(__tgmath_real_type_sub): Likewise.
	(__tgmath_real_type): Likewise.
	(__tgmath_complex_type_sub): Likewise.
	(__tgmath_complex_type): Likewise.
	(__TGMATH_F128): Likewise.
	(__TGMATH_CF128): Likewise.
	[__HAVE_BUILTIN_TGMATH] (__TGMATH_UNARY_REAL_ONLY): Define using
	new macros.
	[__HAVE_BUILTIN_TGMATH] (__TGMATH_UNARY_REAL_RET_ONLY): Likewise.
	[__HAVE_BUILTIN_TGMATH] (__TGMATH_BINARY_FIRST_REAL_ONLY):
	Likewise.
	[__HAVE_BUILTIN_TGMATH] (__TGMATH_BINARY_FIRST_REAL_STD_ONLY):
	Likewise.
	[__HAVE_BUILTIN_TGMATH] (__TGMATH_BINARY_REAL_ONLY): Likewise.
	[__HAVE_BUILTIN_TGMATH] (__TGMATH_BINARY_REAL_STD_ONLY): Likewise.
	[__HAVE_BUILTIN_TGMATH] (__TGMATH_BINARY_REAL_RET_ONLY): Likewise.
	[__HAVE_BUILTIN_TGMATH] (__TGMATH_TERNARY_FIRST_SECOND_REAL_ONLY):
	Likewise.
	[__HAVE_BUILTIN_TGMATH] (__TGMATH_TERNARY_REAL_ONLY): Likewise.
	[__HAVE_BUILTIN_TGMATH] (__TGMATH_TERNARY_FIRST_REAL_RET_ONLY):
	Likewise.
	[__HAVE_BUILTIN_TGMATH] (__TGMATH_UNARY_REAL_IMAG): Likewise.
	[__HAVE_BUILTIN_TGMATH] (__TGMATH_UNARY_IMAG): Likewise.
	[__HAVE_BUILTIN_TGMATH] (__TGMATH_UNARY_REAL_IMAG_RET_REAL):
	Likewise.
	[__HAVE_BUILTIN_TGMATH] (__TGMATH_BINARY_REAL_IMAG): Likewise.
	(__TGMATH_UNARY_REAL_IMAG_RET_REAL_SAME): New macro.
	(carg): Use __TGMATH_UNARY_REAL_IMAG_RET_REAL_SAME.
	(cimag): Likewise.
	(creal): Likewise.
2017-11-15 02:08:56 +00:00
Joseph Myers 4ca70e1a2b Handle more _FloatN, _FloatNx types in __MATH_TG.
Continuing the preparation for additional _FloatN / _FloatNx type
support, this patch prepares __MATH_TG to handle more such types.

Various unhandled cases, which do not correspond to any current glibc
configuration, have explicit #errors added.  _Float32 and _Float64x
are then handled appropriately in the _Generic case, which is the only
one, other than the cases where use of sizeof is sufficient, where
they should ever be explicit types at the language level instead of
typedefs.  There is no need to handle _Float64 or _Float32x explicitly
there because the default case calling a double function is correct
for those types.

Tested for x86_64.

	* math/math.h [__HAVE_DISTINCT_FLOAT16
	|| __HAVE_DISTINCT_FLOAT32 || __HAVE_DISTINCT_FLOAT64
	|| __HAVE_DISTINCT_FLOAT32X || __HAVE_DISTINCT_FLOAT64X
	|| __HAVE_DISTINCT_FLOAT128X]: Use #error.
	[__NO_LONG_DOUBLE_MATH && __HAVE_DISTINCT_FLOAT128]: Likewise.
	[__HAVE_DISTINCT_FLOAT128 && !__HAVE_GENERIC_SELECTION
	&& __HAVE_FLOATN_NOT_TYPEDEF]: Likewise.
	[__HAVE_DISTINCT_FLOAT128 && __HAVE_GENERIC_SELECTION]
	(__MATH_TG_F32): New macro.
	[__HAVE_DISTINCT_FLOAT128 && __HAVE_GENERIC_SELECTION]
	(__MATH_TG_F64X): Likewise.
	[__HAVE_DISTINCT_FLOAT128 && __HAVE_GENERIC_SELECTION]
	(__MATH_TG): Use __MATH_TG_F32 and __MATH_TG_F64X.
2017-11-03 23:50:00 +00:00
Joseph Myers 86ec486597 Handle more _FloatN, _FloatNx types in tgmath.h.
Continuing the preparation for additional _FloatN / _FloatNx type
support, this patch improves how <tgmath.h> handles such types.

Use of #error is added for cases of distinct types that are not
supported by the header, to indicate that additional work on the
header would be needed if, for example, _Float16 support were added to
glibc.  Given that #error, types with the same format as other types
are handled automatically by the sizeof-based logic, so the only case
needing special handling is that where _Float64x exists, has the same
format as _Float128, does not have the same format as long double, and
is not a typedef for _Float128.  In this case (which will apply for
powerpc64le once _Float64x support is added to glibc), the
__builtin_types_compatible_p calls testing for _Float128 need
corresponding calls testing for _Float64x, which this patch adds.

Tested for x86_64.

	* math/tgmath.h [__HAVE_DISTINCT_FLOAT16
	|| __HAVE_DISTINCT_FLOAT32 || __HAVE_DISTINCT_FLOAT64
	|| __HAVE_DISTINCT_FLOAT32X || __HAVE_DISTINCT_FLOAT64X
	|| __HAVE_DISTINCT_FLOAT128X]: Use #error.
	[__HAVE_DISTINCT_FLOAT128 && __GLIBC_USE (IEC_60559_TYPES_EXT)
	&& __HAVE_FLOAT64X && !__HAVE_FLOAT64X_LONG_DOUBLE
	&& __HAVE_FLOATN_NOT_TYPEDEF] (__TGMATH_F128): Handle _Float64x
	the same as _Float128.
	[__HAVE_DISTINCT_FLOAT128 && __GLIBC_USE (IEC_60559_TYPES_EXT)
	&& __HAVE_FLOAT64X && !__HAVE_FLOAT64X_LONG_DOUBLE
	&& __HAVE_FLOATN_NOT_TYPEDEF] (__TGMATH_CF128): Likewise.
2017-11-03 21:11:50 +00:00
Joseph Myers 260fbd0a39 Include bits/cmathcalls.h for more _FloatN, _FloatNx types.
Continuing the preparation for additional _FloatN / _FloatNx type
support, this patch arranges for <bits/cmathcalls.h> to be included by
<complex.h> for each such type under conditions and with macros
defined corresponding to those used for _Float128.

Tested for x86_64.

	* math/complex.h
	[(__HAVE_DISTINCT_FLOAT16 || (__HAVE_FLOAT16 && !_LIBC))
	&& __GLIBC_USE (IEC_60559_TYPES_EXT)]: Include <bits/cmathcalls.h>
	with appropriate macros defined and undefined.
	[(__HAVE_DISTINCT_FLOAT32 || (__HAVE_FLOAT32 && !_LIBC))
	&& __GLIBC_USE (IEC_60559_TYPES_EXT)]: Likewise.
	[(__HAVE_DISTINCT_FLOAT64 || (__HAVE_FLOAT64 && !_LIBC))
	&& __GLIBC_USE (IEC_60559_TYPES_EXT)]: Likewise.
	[(__HAVE_DISTINCT_FLOAT32X || (__HAVE_FLOAT32X && !_LIBC))
	&& __GLIBC_USE (IEC_60559_TYPES_EXT)]: Likewise.
	[(__HAVE_DISTINCT_FLOAT64X || (__HAVE_FLOAT64X && !_LIBC))
	&& __GLIBC_USE (IEC_60559_TYPES_EXT)]: Likewise.
	[(__HAVE_DISTINCT_FLOAT128X || (__HAVE_FLOAT128X && !_LIBC))
	&& __GLIBC_USE (IEC_60559_TYPES_EXT)]: Likewise.
2017-11-01 23:42:31 +00:00
Joseph Myers 2f1b212e54 Clean up complex.h handling of float128.
This patch cleans up the way complex.h handles inclusion of
bits/cmathcalls.h for float128.  The inclusion was between those for
the types float and long double; the patch moves it after that for
long double, matching how bits/mathcalls.h and bits/math-finite.h
inclusions are ordered.  There is no need for the undefine and define
of _Mdouble_complex_ to be conditional, since __CFLOAT128 is always
defined by bits/floatn.h when _Float128 is supported, so the patch
removes the unnecessary conditionals.

Tested for x86_64.

	* math/complex.h
	[(__HAVE_DISTINCT_FLOAT128 || (__HAVE_FLOAT128 && !LIBC))
	&& __GLIBC_USE (IEC_60559_TYPES_EXT)]: Move conditional code after
	that for long double.  Do not condition define and undefine of
	_Mdouble_complex_ on [__CFLOAT128].
2017-11-01 17:03:58 +00:00
Joseph Myers 43e662837c Define CMPLX macros for more _FloatN, _FloatNx types.
Continuing the preparation for additional _FloatN / _FloatNx type
support, this patch defines CMPLX* macros for all such types, as
already done for _Float128.

Tested for x86_64.

	* math/complex.h
	[__HAVE_FLOAT16 && __GLIBC_USE (IEC_60559_TYPES_EXT)] (CMPLXF16):
	New macro.
	[__HAVE_FLOAT32 && __GLIBC_USE (IEC_60559_TYPES_EXT)] (CMPLXF32):
	Likewise.
	[__HAVE_FLOAT64 && __GLIBC_USE (IEC_60559_TYPES_EXT)] (CMPLXF64):
	Likewise.
	[__HAVE_FLOAT32X && __GLIBC_USE (IEC_60559_TYPES_EXT)]
	(CMPLXF32X): Likewise.
	[__HAVE_FLOAT64X && __GLIBC_USE (IEC_60559_TYPES_EXT)]
	(CMPLXF64X): Likewise.
	[__HAVE_FLOAT128X && __GLIBC_USE (IEC_60559_TYPES_EXT)]
	(CMPLXF128X): Likewise.
2017-10-31 17:04:30 +00:00
Joseph Myers 540af6e2f1 Adjust __MATH_EVAL_FMT2 definition to handle _Float16 better.
Continuing the preparation for additional _FloatN / _FloatNx type
support, this patch adds an additional case in the definition of
__MATH_EVAL_FMT2, as used in defining iseqsig: when
__FLT_EVAL_METHOD__ is 0 or 32, it adds 0.0f to the arguments, so that
the correct function would be selected in the case of _Float16
arguments with excess precision (were glibc to support _Float16, which
of course __MATH_TG and other facilities do not at present - and
_Float16 support is not part of what this patch series is aiming for,
but this particular fix is simple so is included anyway).

Tested for x86_64.

	* math/math.h
	[__FLT_EVAL_METHOD__ == 0 || __FLT_EVAL_METHOD__ == 32]
	(__MATH_EVAL_FMT2): Define to add 0.0f.
2017-10-31 16:01:51 +00:00
Joseph Myers b61afe8c81 Include bits/math-finite.h for more _FloatN, _FloatNx types.
Continuing the preparation for additional _FloatN / _FloatNx type
support, this patch extends the includes of <bits/math-finite.h> to
cover all such types, under conditions analogous to those for
_Float128.

Tested for x86_64.

	* math/math.h [__HAVE_DISTINCT_FLOAT16 || (__HAVE_FLOAT16 && !_LIBC)]:
	Include <bits/math-finite.h> with appropriate macros defined and
	undefined.
	[__HAVE_DISTINCT_FLOAT32 || (__HAVE_FLOAT32 && !_LIBC)]: Likewise.
	[__HAVE_DISTINCT_FLOAT64 || (__HAVE_FLOAT64 && !_LIBC)]: Likewise.
	[__HAVE_DISTINCT_FLOAT32X || (__HAVE_FLOAT32X && !_LIBC)]: Likewise.
	[__HAVE_DISTINCT_FLOAT64X || (__HAVE_FLOAT64X && !_LIBC)]: Likewise.
	[__HAVE_DISTINCT_FLOAT128X || (__HAVE_FLOAT128X && !_LIBC)]: Likewise.
2017-10-30 22:15:40 +00:00
Joseph Myers eda162dd8a Remove _Mlong_double_ etc. macros.
math.h has a macro _Mlong_double_ for the type to use when declaring
long double functions, and similar macros for other types.
math/Makefile uses -D_Mlong_double_=double in the case of long double
having the same ABI as double.

This originates with:

Mon Jul  8 13:37:40 1996  Roland McGrath  <roland@delasyd.gnu.ai.mit.edu>

        * math/math.h (_Mfloat_, _Mlong_double_): New macros, defined iff not
        already defined to float, long double.  Use those macros for _Mdouble_
        defns when including mathcalls.h.
        * math/Makefile [$(long-double-fcts) != yes] (CPPFLAGS): Append
        -D_Mlong_double_=double.

However, math.h stopped declaring long double functions in the case of
long double having the same ABI as double (and thus probably stopped
actually needing the Makefile definition of _Mlong_double_) with:

1998-11-05  Ulrich Drepper  <drepper@cygnus.com>

        * math/math.h: Unconditionally include bits/mathdef.h.  Declare
        long double functions only if __NO_LONG_DOUBLE_MATH is not
        defined.
        * sysdeps/generic/bits/mathdef.h: Define only if __USE_ISOC9X.
        Define __NO_LONG_DOUBLE_MATH.
        * sysdeps/m68k/fpu/bits/mathdef.h: Define only if __USE_ISOC9X.
        * sysdeps/i386/fpu/bits/mathdef.h: Likewise.

The declarations were since restored for compiling user code, but
remain absent when _LIBC is defined, which is sufficient to avoid
problems declaring function aliases of incompatible types.  Thus the
indirection through the _Mlong_double_ macro is not needed (probably
since that 1998 patch), and this patch removes _Mlong_double_ and
associated macros for other types, leaving only the macro _Mdouble_
which is actually used as the type for which a given inclusion of
<bits/mathcalls.h> should declared functions.

Tested for x86_64, and tested with build-many-glibcs.py that installed
stripped shared libraries are unchanged by this patch.

	* math/math.h [!_Mfloat_] (_Mfloat_): Do not define.
	[!_Mlong_double_] (_Mlong_double_): Likewise.
	[!_Mfloat16_] (_Mfloat16_): Likewise.
	[!_Mfloat32_] (_Mfloat32_): Likewise.
	[!_Mfloat64_] (_Mfloat64_): Likewise.
	[!_Mfloat128_] (_Mfloat128_): Likewise.
	[!_Mfloat32x_] (_Mfloat32x_): Likewise.
	[!_Mfloat64x_] (_Mfloat64x_): Likewise.
	[!_Mfloat128x_] (_Mfloat128x_): Likewise.
	(_Mdouble_): Define without indirection through those macros.
	* math/complex.h [!_Mfloat_] (_Mfloat_): Do not define.
	[!_Mfloat128_] (_Mfloat128_): Likewise.
	[_Mlong_double_] (_Mlong_double_): Likewise.
	(_Mdouble_): Define without indirection through those macros.
	* math/Makefile [$(long-double-fcts) != yes] (math-CPPFLAGS): Do
	not add -D_Mlong_double_=double.
	* include/math.h [_ISOMAC] (_Mlong_double_): Do not undefine.
	* math/test-signgam-finite-c99.c (_Mlong_double_): Likewise.
2017-10-30 20:58:51 +00:00
Joseph Myers ce12269fac Add _FloatN, _FloatNx M_* constants.
Continuing the preparation for additional _FloatN / _FloatNx type
support, this patch adds M_* constants for such types.  The decimal
expansions used are all the same as used for _Float128; there's no
need to reduce the precision used.  In the case of _Float128x, #error
is used because the constants would need additional precision, but how
much is needed would depend on the actual _Float128x format used, so
it's not possible to add header support simply as part of code that
handles all _FloatN / _FloatNx types similarly.

Tested for x86_64.

	* math/math.h [__HAVE_FLOAT16 && __USE_GNU] (M_Ef16): New macro.
	[__HAVE_FLOAT16 && __USE_GNU] (M_LOG2Ef16): Likewise.
	[__HAVE_FLOAT16 && __USE_GNU] (M_LOG10Ef16): Likewise.
	[__HAVE_FLOAT16 && __USE_GNU] (M_LN2f16): Likewise.
	[__HAVE_FLOAT16 && __USE_GNU] (M_LN10f16): Likewise.
	[__HAVE_FLOAT16 && __USE_GNU] (M_PIf16): Likewise.
	[__HAVE_FLOAT16 && __USE_GNU] (M_PI_2f16): Likewise.
	[__HAVE_FLOAT16 && __USE_GNU] (M_PI_4f16): Likewise.
	[__HAVE_FLOAT16 && __USE_GNU] (M_1_PIf16): Likewise.
	[__HAVE_FLOAT16 && __USE_GNU] (M_2_PIf16): Likewise.
	[__HAVE_FLOAT16 && __USE_GNU] (M_2_SQRTPIf16): Likewise.
	[__HAVE_FLOAT16 && __USE_GNU] (M_SQRT2f16): Likewise.
	[__HAVE_FLOAT16 && __USE_GNU] (M_SQRT1_2f16): Likewise.
	[__HAVE_FLOAT32 && __USE_GNU] (M_Ef32): Likewise.
	[__HAVE_FLOAT32 && __USE_GNU] (M_LOG2Ef32): Likewise.
	[__HAVE_FLOAT32 && __USE_GNU] (M_LOG10Ef32): Likewise.
	[__HAVE_FLOAT32 && __USE_GNU] (M_LN2f32): Likewise.
	[__HAVE_FLOAT32 && __USE_GNU] (M_LN10f32): Likewise.
	[__HAVE_FLOAT32 && __USE_GNU] (M_PIf32): Likewise.
	[__HAVE_FLOAT32 && __USE_GNU] (M_PI_2f32): Likewise.
	[__HAVE_FLOAT32 && __USE_GNU] (M_PI_4f32): Likewise.
	[__HAVE_FLOAT32 && __USE_GNU] (M_1_PIf32): Likewise.
	[__HAVE_FLOAT32 && __USE_GNU] (M_2_PIf32): Likewise.
	[__HAVE_FLOAT32 && __USE_GNU] (M_2_SQRTPIf32): Likewise.
	[__HAVE_FLOAT32 && __USE_GNU] (M_SQRT2f32): Likewise.
	[__HAVE_FLOAT32 && __USE_GNU] (M_SQRT1_2f32): Likewise.
	[__HAVE_FLOAT64 && __USE_GNU] (M_Ef64): Likewise.
	[__HAVE_FLOAT64 && __USE_GNU] (M_LOG2Ef64): Likewise.
	[__HAVE_FLOAT64 && __USE_GNU] (M_LOG10Ef64): Likewise.
	[__HAVE_FLOAT64 && __USE_GNU] (M_LN2f64): Likewise.
	[__HAVE_FLOAT64 && __USE_GNU] (M_LN10f64): Likewise.
	[__HAVE_FLOAT64 && __USE_GNU] (M_PIf64): Likewise.
	[__HAVE_FLOAT64 && __USE_GNU] (M_PI_2f64): Likewise.
	[__HAVE_FLOAT64 && __USE_GNU] (M_PI_4f64): Likewise.
	[__HAVE_FLOAT64 && __USE_GNU] (M_1_PIf64): Likewise.
	[__HAVE_FLOAT64 && __USE_GNU] (M_2_PIf64): Likewise.
	[__HAVE_FLOAT64 && __USE_GNU] (M_2_SQRTPIf64): Likewise.
	[__HAVE_FLOAT64 && __USE_GNU] (M_SQRT2f64): Likewise.
	[__HAVE_FLOAT64 && __USE_GNU] (M_SQRT1_2f64): Likewise.
	[__HAVE_FLOAT32X && __USE_GNU] (M_Ef32x): Likewise.
	[__HAVE_FLOAT32X && __USE_GNU] (M_LOG2Ef32x): Likewise.
	[__HAVE_FLOAT32X && __USE_GNU] (M_LOG10Ef32x): Likewise.
	[__HAVE_FLOAT32X && __USE_GNU] (M_LN2f32x): Likewise.
	[__HAVE_FLOAT32X && __USE_GNU] (M_LN10f32x): Likewise.
	[__HAVE_FLOAT32X && __USE_GNU] (M_PIf32x): Likewise.
	[__HAVE_FLOAT32X && __USE_GNU] (M_PI_2f32x): Likewise.
	[__HAVE_FLOAT32X && __USE_GNU] (M_PI_4f32x): Likewise.
	[__HAVE_FLOAT32X && __USE_GNU] (M_1_PIf32x): Likewise.
	[__HAVE_FLOAT32X && __USE_GNU] (M_2_PIf32x): Likewise.
	[__HAVE_FLOAT32X && __USE_GNU] (M_2_SQRTPIf32x): Likewise.
	[__HAVE_FLOAT32X && __USE_GNU] (M_SQRT2f32x): Likewise.
	[__HAVE_FLOAT32X && __USE_GNU] (M_SQRT1_2f32x): Likewise.
	[__HAVE_FLOAT64X && __USE_GNU] (M_Ef64x): Likewise.
	[__HAVE_FLOAT64X && __USE_GNU] (M_LOG2Ef64x): Likewise.
	[__HAVE_FLOAT64X && __USE_GNU] (M_LOG10Ef64x): Likewise.
	[__HAVE_FLOAT64X && __USE_GNU] (M_LN2f64x): Likewise.
	[__HAVE_FLOAT64X && __USE_GNU] (M_LN10f64x): Likewise.
	[__HAVE_FLOAT64X && __USE_GNU] (M_PIf64x): Likewise.
	[__HAVE_FLOAT64X && __USE_GNU] (M_PI_2f64x): Likewise.
	[__HAVE_FLOAT64X && __USE_GNU] (M_PI_4f64x): Likewise.
	[__HAVE_FLOAT64X && __USE_GNU] (M_1_PIf64x): Likewise.
	[__HAVE_FLOAT64X && __USE_GNU] (M_2_PIf64x): Likewise.
	[__HAVE_FLOAT64X && __USE_GNU] (M_2_SQRTPIf64x): Likewise.
	[__HAVE_FLOAT64X && __USE_GNU] (M_SQRT2f64x): Likewise.
	[__HAVE_FLOAT64X && __USE_GNU] (M_SQRT1_2f64x): Likewise.
	[__HAVE_FLOAT128X && __USE_GNU]: Use #error.
2017-10-30 16:42:28 +00:00
Joseph Myers 7e9d70736b Include bits/mathcalls.h for more _FloatN, _FloatNx types.
Continuing the preparation for additional _FloatN / _FloatNx type
support, this patch arranges for <bits/mathcalls.h> and
<bits/mathcalls-helper-functions.h> to be included for each such type
under conditions and with macros defined corresponding to those
already present for _Float128.

Tested for x86_64.

	* math/math.h [__HAVE_DISTINCT_FLOAT16 || (__HAVE_FLOAT16 && !_LIBC)]:
	Include <bits/mathcalls-helper-functions.h> and <bits/mathcalls.h>
	with appropriate macros defined and undefined.
	[__HAVE_DISTINCT_FLOAT32 || (__HAVE_FLOAT32 && !_LIBC)]: Likewise.
	[__HAVE_DISTINCT_FLOAT64 || (__HAVE_FLOAT64 && !_LIBC)]: Likewise.
	[__HAVE_DISTINCT_FLOAT32X || (__HAVE_FLOAT32X && !_LIBC)]: Likewise.
	[__HAVE_DISTINCT_FLOAT64X || (__HAVE_FLOAT64X && !_LIBC)]: Likewise.
	[__HAVE_DISTINCT_FLOAT128X || (__HAVE_FLOAT128X && !_LIBC)]: Likewise.
2017-10-27 22:43:46 +00:00
Joseph Myers ecc7da5bb8 Add SNAN macros for more _FloatN, _FloatNx types.
This patch continues the preparation for additional _FloatN / _FloatNx
type support by adding appropriately conditional definitions of SNAN*
macros, corresponding to the SNANF128 definition already present.

Tested for x86_64.

	* math/math.h [__HAVE_FLOAT16 && __GLIBC_USE
	(IEC_60559_TYPES_EXT)] (SNANF16): New macro.
	[__HAVE_FLOAT32 && __GLIBC_USE (IEC_60559_TYPES_EXT)] (SNANF32):
	Likewise.
	[__HAVE_FLOAT64 && __GLIBC_USE (IEC_60559_TYPES_EXT)] (SNANF64):
	Likewise.
	[__HAVE_FLOAT32X && __GLIBC_USE (IEC_60559_TYPES_EXT)] (SNANF32X):
	Likewise.
	[__HAVE_FLOAT64X && __GLIBC_USE (IEC_60559_TYPES_EXT)] (SNANF64X):
	Likewise.
	[__HAVE_FLOAT128X && __GLIBC_USE (IEC_60559_TYPES_EXT)]
	(SNANF128X): Likewise.
2017-10-26 23:34:55 +00:00
Joseph Myers 5d220788b3 Add HUGE_VAL macros for more _FloatN, _FloatNx types.
This patch continues the preparation for additional _FloatN / _FloatNx
type support by adding appropriately conditional definitions of
HUGE_VAL_* macros, corresponding to the HUGE_VAL_F128 definition
already present.

Tested for x86_64.

	* math/math.h [__HAVE_FLOAT16 && __GLIBC_USE
	(IEC_60559_TYPES_EXT)] (HUGE_VAL_F16): New macro.
	[__HAVE_FLOAT32 && __GLIBC_USE (IEC_60559_TYPES_EXT)]
	(HUGE_VAL_F32): Likewise.
	[__HAVE_FLOAT64 && __GLIBC_USE (IEC_60559_TYPES_EXT)]
	(HUGE_VAL_F64): Likewise.
	[__HAVE_FLOAT32X && __GLIBC_USE (IEC_60559_TYPES_EXT)]
	(HUGE_VAL_F32X): Likewise.
	[__HAVE_FLOAT64X && __GLIBC_USE (IEC_60559_TYPES_EXT)]
	(HUGE_VAL_F64X): Likewise.
	[__HAVE_FLOAT128X && __GLIBC_USE (IEC_60559_TYPES_EXT)]
	(HUGE_VAL_F128X): Likewise.
2017-10-26 23:11:18 +00:00
Joseph Myers 797ba44ba2 Add bits/floatn.h defines for more _FloatN / _FloatNx types.
The bits/floatn.h header currently only has defines relating to
_Float128.  This patch adds defines relating to other _FloatN /
_FloatNx types.

The approach taken is to add defines for all _FloatN / _FloatNx types
known to GCC, and to put them in a common bits/floatn-common.h header
included at the end of all the individual bits/floatn.h headers.  If
in future some defines become different for different glibc
configurations, they will move out into the separate bits/floatn.h
headers.

Some defines are expected always to be the same across glibc ports.
Corresponding defines are nevertheless put in this header.  The intent
is that where there are conditionals (in headers or in non-installed
files) that can just repeat the same or nearly the same logic for each
floating-point type, they should do so, even if in fact the cases for
some types could be unconditionally present or absent because the same
conditionals are true or false for all glibc configurations.  This
should make the glibc code with such conditionals easier to read,
because the reader can just see that the same conditionals are
repeated for each type, rather than seeing different conditionals for
different types and needing to reason, at each location with such
differences, why those differences are indeed correct there.  (Cases
involving per-format rather than per-type logic are more likely still
to need differences in how they handle different types.)

Having such defines and conditionals also helps in incremental
preparation for adding _Float32 / _Float64 / _Float32x / _Float64x
function aliases.  I intend subsequent patches to add such
conditionals corresponding to those already present for _Float128, as
well as making more architecture-specific function implementations use
common macros to define aliases in preparation for adding such _FloatN
/ _FloatNx aliases.

Tested for x86_64.

	* bits/floatn-common.h: New file.
	* math/Makefile (headers): Add bits/floatn-common.h.
	* bits/floatn.h: Include <bits/floatn-common.h>.
	* sysdeps/ia64/bits/floatn.h: Likewise.
	* sysdeps/ieee754/ldbl-128/bits/floatn.h: Likewise.
	* sysdeps/mips/ieee754/bits/floatn.h: Likewise.
	* sysdeps/powerpc/bits/floatn.h: Likewise.
	* sysdeps/x86/bits/floatn.h: Likewise.
2017-10-20 21:42:51 +00:00
Romain Naour 386e1c26ac Let signbit use the builtin in C++ mode with gcc < 6.x (bug 22296)
When using gcc < 6.x, signbit does not use the type-generic
__builtin_signbit builtin, instead it uses __MATH_TG.
However, when library support for float128 is available, __MATH_TG uses
__builtin_types_compatible_p, which is not available in C++ mode.

On the other hand, libstdc++ undefines (in cmath) many macros from
math.h, including signbit, so that it can provide its own functions.
However, during its configure tests, libstdc++ just tests for the
availability of the macros (it does not undefine them, nor does it
provide its own functions).

Finally, libstdc++ configure tests include math.h and get the definition
of signbit that uses __MATH_TG (and __builtin_types_compatible_p).
Since libstdc++ does not undefine the macros during its configure
tests, they fail.

This patch lets signbit use the builtin in C++ mode when gcc < 6.x is
used. This allows the configure test in libstdc++ to work.

Tested for x86_64.

	[BZ #22296]
	* math/math.h: Let signbit use the builtin in C++ mode with gcc
	< 6.x

Cc: Gabriel F. T. Gomes <gftg@linux.vnet.ibm.com>
Cc: Joseph Myers <joseph@codesourcery.com>
2017-10-17 12:06:44 -02:00
Joseph Myers c38a4bfd59 Move some float128 symbol version definitions.
With support for _Float128 functions on platforms where that type has
the same ABI as long double, as well as on platforms where it is
ABI-distinct, those functions will need to be exported from glibc's
shared libraries at appropriate symbol versions in each case.

This patch avoids duplication of lists of symbols to export by moving
the symbols other than __* to math/Versions and stdlib/Versions.
There, they are conditional on <float128-abi.h> defining
FLOAT128_VERSION and a default version of that header is added that
does not define that macro.  Enabling the float128 function aliases
will then include adding a sysdeps/ieee754/ldbl-128/float128-abi.h
that defines FLOAT128_VERSION to GLIBC_2.27.  Symbols __* remain in
sysdeps/ieee754/float128/Versions; those symbols should be present
only once per floating-point format, not once per type.

Note that if any platforms currently lacking support for a type with
binary128 format get glibc support for such a type in future (whether
only as _Float128, or also as a new long double format), and new libm
functions (present for all types) have been added by then, additional
macros will be needed to allow such functions to get a version of the
form "GLIBC_2.28 if the platform had _Float128 support by then, or the
later version at which that platform had _Float128 support added".
This is not however a preexisting condition, but would have applied
equally to the existing support for _Float128 as an ABI-distinct
type.  New all-type libm functions should just be added to the
appropriate symbol version (currently GLIBC_2.27) for all types, with
such special-case handling for _Float128 versions (and _Float64x as
well in future) waiting until someone actually wants to add support
for _Float128 to an existing platform after a release in which that
platform and a post-2.26 libm function had support but that platform
lacked _Float128 support.

Tested with build-many-glibcs.py that installed stripped shared
libraries are unchanged by this patch.  Also tested in conjunction
with the remaining changes to enable float128 aliases.

	* sysdeps/generic/float128-abi.h: New file.
	* sysdeps/ieee754/float128/Versions (FLOAT128_VERSION): Move
	non-__prefixed symbols to ....
	* math/Versions: ... here.  Include <float128-abi.h>.
	* stdlib/Versions ... and here.  Include <float128-abi.h>
2017-10-16 22:04:42 +00:00
Joseph Myers 596f70134a Support running libm tests for float128 as alias for long double.
This patch adds support for running libm tests for float128 in the
case where the float128 functions are aliases of long double
functions.  In this case, the sysdeps Makeconfig file
(i.e. sysdeps/ieee754/ldbl-128/Makeconfig) will need to define
"float128-alias-fcts = yes" to enable the tests.

Tested for x86_64.  Also tested with build-many-glibcs.py; installed
stripped shared libraries are unchanged by the patch.  Also tested
together with changes to enable the float128 aliases.

	* math/Makefile (test-types): Add
	$(type-float128-$(float128-alias-fcts)).
	* math/test-float128.h (TYPE_STR): Define conditional on
	[FLT128_MANT_DIG == LDBL_MANT_DIG].
	(ULP_IDX): Likewise.
	(ULP_I_IDX): Likewise.
2017-10-16 13:28:30 +00:00
Joseph Myers bc9620d040 Run libm long double tests for long double = double.
All interfaces in the glibc API ought to be covered by the testsuite,
even where they alias other interfaces.  This patch arranges for libm
tests to be run for long double when it aliases double; previously
those tests were run only for the floating-point types with distinct
formats.  The long double tests are made to use the double ulps values
in this case, as having a separate duplicate set of ulps for them
seems unnecessary; to accommodate that, the test-<type>.h headers now
specify the macro indexing into the ulps array explicitly instead of
having it computed from PREFIX.

Nothing special is done about vector function tests.  None are
supported for any long double = double platforms, and supporting
vector functions for a type alias such as _Float32 would not simply
fall out of adding the scalar aliases for that type - it would require
vector function wrappers like those for *_finite (or, better, a new
GCC feature to allow specifying the asm name for vector functions
independently of that for scalar ones, as previously discussed), so it
seems reasonable to require the sysdeps makefile setting of
libmvec-tests to be updated if any such tests are to be run for type
aliases.

Tested for x86_64 and arm.

	* math/Makefile (test-types-basic): New variable.
	(test-types): Likewise.
	(libm-test-support): Use $(test-types) instead of $(types).
	(libm-tests-base-normal): Likewise.
	(libm-tests-base-finite): Likewise.
	(libm-tests-base-inline): Likewise.
	(generated): Likewise.
	($(objpfx)libm-test-support-$(t).c): Likewise.
	(libm-tests-for-type iterator): Likewise.
	(libm-test-support iterator): Likewise.
	* math/libm-test-support.c (ulp_i_idx): Use ULP_I_IDX.
	(ulp_idx): Use ULP_IDX.
	* math/test-ldouble.h: Include <float.h>.
	(TYPE_STR): Define conditional on [LDBL_MANT_DIG == DBL_MANT_DIG].
	(ULP_IDX): New macro.
	(ULP_I_IDX): Likewise.
	* math/test-double.h (ULP_IDX): Likewise.
	(ULP_I_IDX): Likewise.
	* math/test-float.h (ULP_IDX): Likewise.
	(ULP_I_IDX): Likewise.
	* math/test-float128.h (ULP_IDX): Likewise.
	(ULP_I_IDX): Likewise.
2017-10-11 17:46:19 +00:00
Joseph Myers 24b6515d87 Add libm_alias_*_other_r macros.
Some libm functions are unable to use the generic alias macros such as
libm_alias_double because they have special symbol versioning
requirements for the main float, double or long double public names.

To facilitate adding _FloatN / _FloatNx function aliases in future,
it's still desirable to have generic macros those functions can use as
far as possible.  This patch adds macros such as
libm_alias_double_other, which only define names for _FloatN /
_FloatNx aliases, not for float / double / long double.  As present,
all these new macros do nothing, but they are called in the
appropriate places in macros such as libm_alias_double.  This patch
also arranges for lgamma implementations, and the recently added
optimized float function implementations, to use the new macros to
make them ready for addition of _FloatN / _FloatNx aliases.

Tested for x86_64, and tested with build-many-glibcs.py that installed
stripped shared libraries are unchanged by this patch.

	* sysdeps/generic/libm-alias-double.h (libm_alias_double_other_r):
	New macro.
	(libm_alias_double_other): Likewise.
	(libm_alias_double_r): Use libm_alias_double_other_r.
	* sysdeps/generic/libm-alias-float.h (libm_alias_float_other_r):
	New macro.
	(libm_alias_float_other): Likewise.
	(libm_alias_float_r): Use libm_alias_float_other_r.
	* sysdeps/generic/libm-alias-float128.h
	(libm_alias_float128_other_r): New macro.
	(libm_alias_float128_other): Likewise.
	(libm_alias_float128_r): Use libm_alias_float128_other_r.
	* sysdeps/generic/libm-alias-ldouble.h
	(libm_alias_ldouble_other_r): New macro.
	(libm_alias_ldouble_other): Likewise.
	(libm_alias_ldouble_r): Use libm_alias_ldouble_other_r.
	* sysdeps/ieee754/ldbl-opt/libm-alias-double.h
	(libm_alias_double_other_r): New macro.
	(libm_alias_double_other): Likewise.
	(libm_alias_double_r): Use libm_alias_double_other_r.
	* sysdeps/ieee754/ldbl-opt/libm-alias-ldouble.h
	(libm_alias_ldouble_other_r): New macro.
	(libm_alias_ldouble_other): Likewise.
	(libm_alias_ldouble_r): Use libm_alias_ldouble_other_r.
	* math/w_lgamma_main.c: Include <libm-alias-double.h>.
	[!USE_AS_COMPAT]: Use libm_alias_double_other.
	* math/w_lgammaf_main.c: Include <libm-alias-float.h>.
	[!USE_AS_COMPAT]: Use libm_alias_float_other.
	* math/w_lgammal_main.c: Include <libm-alias-ldouble.h>.
	[!USE_AS_COMPAT]: Use libm_alias_ldouble_other.
	* math/w_exp2f.c: Use libm_alias_float_other.
	* math/w_expf.c: Likewise.
	* math/w_log2f.c: Likewise.
	* math/w_logf.c: Likewise.
	* math/w_powf.c: Likewise.
	* sysdeps/ieee754/flt-32/e_exp2f.c: Include <libm-alias-float.h>.
	[!__exp2f]: Use libm_alias_float_other.
	* sysdeps/ieee754/flt-32/e_expf.c: Include <libm-alias-float.h>.
	[!__expf]: Use libm_alias_float_other.
	* sysdeps/ieee754/flt-32/e_log2f.c: Include <libm-alias-float.h>.
	[!__log2f]: Use libm_alias_float_other.
	* sysdeps/ieee754/flt-32/e_logf.c: Include <libm-alias-float.h>.
	[!__logf]: Use libm_alias_float_other.
	* sysdeps/ieee754/flt-32/e_powf.c: Include <libm-alias-float.h>.
	[!__powf]: Use libm_alias_float_other.
2017-10-10 21:29:11 +00:00
Joseph Myers a8dce6197a Use generic macros for lgamma_r function aliases.
Continuing the use of generic macros for defining libm function
aliases, in preparation for adding more _FloatN / _FloatNx function
names, this patch makes the lgamma_r functions use such macros.

declare_mgen_alias_r becomes a standard macro in math-type-macros.h
instead of being locally defined in w_lgamma_r_templace.c.  This in
turn must be defined by each math-type-macros-<type>.h.  Rather than
providing an unused default in math-type-macros.h, that header is made
to give an error if math-type-macros-<type>.h failed to define
declare_mgen_alias or declare_mgen_alias_r.  The compat lgamma_r
wrappers are updated similarly.  The ldbl-opt versions are removed as
no longer needed.

Tested for x86_64, and with build-many-glibcs.py.  Installed stripped
shared libraries are unchanged except for powerpc64le (where the usual
issue applies that an ldbl-opt long double function previously used
long_double_symbol unconditionally and now the symbol versions on
powerpc64le mean weak_alias is used instead, resulting in the same
symbol versions in the final shared library but still enough
difference in the input objects for that library not to be
byte-identical).

	* sysdeps/generic/math-type-macros.h [!declare_mgen_alias]: Give
	error.  Remove default definition of declare_mgen_alias.
	[!declare_mgen_alias_r]: Likewise.
	* sysdeps/generic/math-type-macros-double.h
	[!declare_mgen_alias_r] (declare_mgen_alias_r): New macro.
	* sysdeps/generic/math-type-macros-float.h [!declare_mgen_alias_r]
	(declare_mgen_alias_r): Likewise.
	* sysdeps/generic/math-type-macros-float128.h
	[!declare_mgen_alias_r] (declare_mgen_alias_r): Likewise.
	* sysdeps/generic/math-type-macros-ldouble.h
	[!declare_mgen_alias_r] (declare_mgen_alias_r): Likewise.
	* math/w_lgamma_r_template.c (declare_mgen_alias_r_x): Remove
	macro.
	(declare_mgen_alias_r_s): Likewise.
	(declare_mgen_alias_r): Likewise.
	* math/w_lgamma_r_compat.c: Include <libm-alias-double.h>.
	(lgamma_r): Define using libm_alias_double_r.
	* math/w_lgammaf_r_compat.c: Include <libm-alias-float.h>.
	(lgammaf_r): Define using libm_alias_float_r.
	* math/w_lgammal_r_compat.c: Include <libm-alias-ldouble.h>.
	(lgammal_r): Define using libm_alias_ldouble_r.
	* sysdeps/ieee754/ldbl-opt/w_lgamma_r_compat.c: Remove file.
	* sysdeps/ieee754/ldbl-opt/w_lgammal_r_compat.c: Likewise.
2017-10-09 22:04:18 +00:00
Jonathan Wakely d6c064e914 Ensure C99 and C11 interfaces are available for C++ [BZ #21326]
This patch ensures that the C99 and C11 features required by C++ are
defined according to the value of the __cplusplus macro, and not just
because G++ always defines _GNU_SOURCE.  This will allow G++ to stop
defining _GNU_SOURCE some day, without causing the C99 and C11
interfaces to disappear for C++ programs.

	[BZ #21326]
	* include/features.h [__cplusplus >= 201103] (__USE_ISOC99): Define.
	[__cplusplus >= 201703] (__USE_ISOCXX17, __USE_ISOC11): Define.
	* math/Makefile (test-math-cxx11): New test.
	* math/test-math-cxx11.cc: New file.
2017-10-09 16:18:11 +02:00
H.J. Lu 758f1bfa2a test-math-iscanonical.cc: Return errors != 0
Since not all non-zero error counts are errors, return errors != 0
instead.

	* math/test-math-iscanonical.cc (do_test): Return errors != 0.
2017-10-04 14:31:16 -07:00
H.J. Lu cdd4155d6c test-math-iscanonical.cc: Replace bool with int
Fix GCC 7 compilation error:

test-math-iscanonical.cc: In function ‘void check_type()’:
test-math-iscanonical.cc:33:11: error: use of an operand of type ‘bool’ in ‘operator++’ is deprecated [-Werror=deprecated]
     errors++;
           ^~

	* math/test-math-iscanonical.cc (error): Replace bool with int.
2017-10-03 17:41:47 -07:00
Gabriel F. T. Gomes aa0235dfde Add C++ versions of iscanonical for ldbl-96 and ldbl-128ibm (bug 22235)
All representations of floating-point numbers in types with IEC 60559
binary exchange format are canonical.  On the other hand, types with IEC
60559 extended formats, such as those implemented under ldbl-96 and
ldbl-128ibm, contain representations that are not canonical.

TS 18661-1 introduced the type-generic macro iscanonical, which returns
whether a floating-point value is canonical or not.  In Glibc, this
type-generic macro is implemented using the macro __MATH_TG, which, when
support for float128 is enabled, relies on __builtin_types_compatible_p
to select between floating-point types.  However, this use of
iscanonical breaks C++ applications, because the builtin is only
available in C mode.

This patch provides a C++ implementation of iscanonical that relies on
function overloading, rather than builtins, to select between
floating-point types.

Unlike the C++ implementations for iszero and issignaling, this
implementation ignores __NO_LONG_DOUBLE_MATH.  The double type always
matches IEC 60559 double format, which is always canonical.  Thus, when
double and long double are the same (__NO_LONG_DOUBLE_MATH), iscanonical
always returns 1 and is not implemented with __MATH_TG.

Tested for powerpc64, powerpc64le and x86_64.

	[BZ #22235]
	* math/math.h: Trivial fix for unbalanced parentheses in comment.
	* math/Makefile [CXX] (tests): Add test-math-iscanonical.cc.
	(CFLAGS-test-math-iscanonical.cc): New variable.
	* math/test-math-iscanonical.cc: New file.
	* sysdeps/ieee754/ldbl-96/bits/iscanonical.h (iscanonical):
	Provide a C++ implementation based on function overloading,
	rather than using __MATH_TG, which uses C-only builtins.
	* sysdeps/ieee754/ldbl-128ibm/bits/iscanonical.h (iscanonical):
	Likewise.
	* sysdeps/powerpc/powerpc64le/Makefile
	(CFLAGS-test-math-iscanonical.cc): New variable.
2017-10-03 16:01:37 -03:00
Szabolcs Nagy f275f64e7e fix drem symbol for static linking and new targets
The compat remainder code is no longer built for !LIBM_SVID_COMPAT targets,
but the legacy drem, dremf and dreml symbols should be still defined since
removing them may break existing code, so keep them as aliases in the
non-compat remainder code.

	* math/w_remainder.c: New file.
	* math/w_remainderf.c: New file.
	* math/w_remainderl.c: New file.
2017-10-03 14:31:59 +01:00
Szabolcs Nagy bdc5c59214 fix gamma symbol for static linking and new targets
The lgamma compat code is no longer built for !LIBM_SVID_COMPAT targets,
but the legacy gamma, gammaf and gammal symbols should be still defined,
so make them aliases to the non-compat lgamma code.

	* math/w_lgamma.c: New file.
	* math/w_lgammaf.c: New file.
	* math/w_lgammal.c: New file.
2017-10-02 17:33:13 +01:00
Szabolcs Nagy 72d3d28108 New symbol version for logf, log2f and powf without SVID compat
This patch changes the logf, log2f and powf error handling semantics
to only set errno accoring to POSIX rules. New symbol version is
introduced at GLIBC_2.27.

The old wrappers are kept for compat symbols.

ia64 needed assembly change to have the new and compat versioned
symbol map to the same function.

All linux libm abilists are updated.

	* math/Versions (logf): New libm symbol at GLIBC_2.27.
	(log2f): Likewise.
	(powf): Likewise.
	* math/w_log2f.c: New file.
	* math/w_logf.c: New file.
	* math/w_powf.c: New file.
	* math/w_log2f_compat.c (__log2f_compat): For compat symbol only.
	* math/w_logf_compat.c (__logf_compat): Likewise.
	* math/w_powf_compat.c (__powf_compat): Likewise.
	* sysdeps/ia64/fpu/e_log2f.S: Add versioned symbols.
	* sysdeps/ia64/fpu/e_logf.S: Likewise.
	* sysdeps/ia64/fpu/e_powf.S: Likewise.
	* sysdeps/unix/sysv/linux/aarch64/libm.abilist: Update.
	* sysdeps/unix/sysv/linux/alpha/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/arm/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/hppa/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/i386/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/ia64/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/m68k/coldfire/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/m68k/m680x0/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/microblaze/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/mips/mips32/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/mips/mips64/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/nios2/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libm.abilist:
	Likewise.
	* sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libm.abilist:
	Likewise.
	* sysdeps/unix/sysv/linux/powerpc/powerpc64/libm-le.abilist:
	Likewise.
	* sysdeps/unix/sysv/linux/powerpc/powerpc64/libm.abilist:
	Likewise.
	* sysdeps/unix/sysv/linux/s390/s390-32/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/s390/s390-64/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/sh/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/sparc/sparc32/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/sparc/sparc64/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/tile/tilegx/tilegx32/libm.abilist:
	Likewise.
	* sysdeps/unix/sysv/linux/tile/tilegx/tilegx64/libm.abilist:
	Likewise.
	* sysdeps/unix/sysv/linux/tile/tilepro/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/x86_64/64/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/x86_64/x32/libm.abilist: Likewise.
2017-10-02 14:38:03 +01:00
Wilco Dijkstra fffb150735 Remove old cimag inlines
Remove old cimag inlines that are only used in GCC 2.96 or older.

	* math/bits/cmathcalls.h (cimag): Remove inline.
	(creal): Remove inline.
	(conj): Remove inline.
2017-09-29 17:53:57 +01:00
Szabolcs Nagy 4ea49f4c08 New generic powf
without wrapper on aarch64:
powf reciprocal-throughput: 4.2x faster
powf latency: 2.6x faster
old worst-case error: 1.11 ulp
new worst-case error: 0.82 ulp
aarch64 .text size: -780 bytes
aarch64 .rodata size: +144 bytes

powf(x,y) is implemented as exp2(y*log2(x)) with the same algorithms
that are used in exp2f and log2f, except that the log2f polynomial is
larger for extra precision and its output (and exp2f input) may be
scaled by a power of 2 (POWF_SCALE) to simplify the argument reduction
step of exp2 (possible when efficient round and convert toint operation
is available).

The special case handling tries to minimize the checks in the hot path.
When the input of exp2_inline is checked, int arithmetics is used as
that was faster on the tested aarch64 cores.

	* math/Makefile (type-float-routines): Add e_powf_log2_data.
	* sysdeps/ieee754/flt-32/e_powf.c: New implementation.
	* sysdeps/ieee754/flt-32/e_powf_log2_data.c: New file.
	* sysdeps/ieee754/flt-32/math_config.h (__powf_log2_data): Define.
	(issignalingf_inline): Likewise.
	(POWF_LOG2_TABLE_BITS): Likewise.
	(POWF_LOG2_POLY_ORDER): Likewise.
	(POWF_SCALE_BITS): Likewise.
	(POWF_SCALE): Likewise.
	* sysdeps/i386/fpu/e_powf_log2_data.c: New file.
	* sysdeps/ia64/fpu/e_powf_log2_data.c: New file.
	* sysdeps/m68k/m680x0/fpu/e_powf_log2_data.c: New file.
2017-09-29 17:30:53 +01:00
Szabolcs Nagy 875c76c704 New generic log2f
Similar to the new logf: double precision arithmetics and a small
lookup table is used. The argument reduction step is the same as in
the new logf.

without wrapper on aarch64:
log2f reciprocal-throughput: 2.3x faster
log2f latency: 2.1x faster
old worst case error: 1.72 ulp
new worst case error: 0.75 ulp
aarch64 .text size: -252 bytes
aarch64 .rodata size: +244 bytes

	* math/Makefile (type-float-routines): Add e_log2f_data.
	* sysdeps/ieee754/flt-32/e_log2f.c: New implementation.
	* sysdeps/ieee754/flt-32/e_log2f_data.c: New file.
	* sysdeps/ieee754/flt-32/math_config.h (__log2f_data): Define.
	(LOG2F_TABLE_BITS, LOG2F_POLY_ORDER): Define.
	* sysdeps/i386/fpu/e_log2f_data.c: New file.
	* sysdeps/ia64/fpu/e_log2f_data.c: New file.
	* sysdeps/m68k/m680x0/fpu/e_log2f_data.c: New file.
2017-09-29 17:17:41 +01:00
Szabolcs Nagy bf27d3973d New generic logf
without wrapper on aarch64:
logf reciprocal-throughput: 2.2x faster
logf latency: 1.9x faster
old worst case error: 0.89 ulp
new worst case error: 0.82 ulp
aarch64 .text size: -356 bytes
aarch64 .rodata size: +240 bytes

Uses double precision arithmetics and a lookup table to allow smaller
polynomial and avoid the use of division.

Data is in a separate translation unit with fixed layout to prevent the
compiler generating suboptimal literal access.

Errors are handled inline according to POSIX rules, but this patch
keeps the wrapper with SVID compatible error handling.

Needs libm-test-ulps adjustment for clogf in non-nearest rounding mode.

	* math/Makefile (type-float-routines): Add e_logf_data.
	* sysdeps/ieee754/flt-32/e_logf.c: New implementation.
	* sysdeps/ieee754/flt-32/e_logf_data.c: New file.
	* sysdeps/ieee754/flt-32/math_config.h (__logf_data): Define.
	(LOGF_TABLE_BITS, LOGF_POLY_ORDER): Define.
	* sysdeps/i386/fpu/e_logf_data.c: New file.
	* sysdeps/ia64/fpu/e_logf_data.c: New file.
	* sysdeps/m68k/m680x0/fpu/e_logf_data.c: New file.
2017-09-29 11:46:46 +01:00
Wilco Dijkstra 1e6d07234f Simplify C99 isgreater macros
Simplify the C99 isgreater macros.  Although some support was added
in GCC 2.97, not all targets added support until GCC 3.1.  Therefore
only use the builtins in math.h from GCC 3.1 onwards, and defer to
generic macros otherwise.  Improve the generic isunordered macro
to use compares rather than call fpclassify twice - this is not only
faster but also correct for signaling NaNs.

	* math/math.h: Improve handling of C99 isgreater macros.
	* sysdeps/alpha/fpu/bits/mathinline.h: Remove isgreater macros.
	* sysdeps/m68k/m680x0/fpu/bits/mathinline.h: Likewise.
	* sysdeps/powerpc/bits/mathinline.h: Likewise.
	* sysdeps/sparc/fpu/bits/mathinline.h: Likewise.
	* sysdeps/x86/fpu/bits/mathinline.h: Likewise.
2017-09-28 19:43:54 +01:00
Szabolcs Nagy f5f0f52651 New expf and exp2f version without SVID compat wrapper
This patch changes the expf and exp2f error handling semantics to only
set errno accoring to POSIX rules. New symbol version is introduced at
GLIBC_2.27.

The old wrappers are kept for compat symbols.

Internal calls to __expf now get the new error semantics, this seems to
only affect sysdeps/i386/fpu/s_expm1f.S where the errno-only behaviour
should be correct.

ia64 needed assembly change to have the new and compat versioned symbol
map to the same function.

All linux libm abilists are updated.

	* math/Versions (expf): New libm symbol at GLIBC_2.27.
	(exp2f): Likewise.
	* math/w_exp2f.c: New file.
	* math/w_expf.c: New file.
	* math/w_exp2f_compat.c (__exp2f_compat): For compat symbol only.
	* math/w_expf_compat.c (__expf_compat): Likewise.
	* sysdeps/ia64/fpu/e_exp2f.S: Add versioned symbols.
	* sysdeps/ia64/fpu/e_expf.S: Likewise.
	* sysdeps/unix/sysv/linux/aarch64/libm.abilist: Update.
	* sysdeps/unix/sysv/linux/alpha/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/arm/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/hppa/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/i386/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/ia64/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/m68k/coldfire/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/m68k/m680x0/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/microblaze/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/mips/mips32/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/mips/mips64/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/nios2/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libm.abilist:
	Likewise.
	* sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libm.abilist:
	Likewise.
	* sysdeps/unix/sysv/linux/powerpc/powerpc64/libm-le.abilist:
	Likewise.
	* sysdeps/unix/sysv/linux/powerpc/powerpc64/libm.abilist:
	Likewise.
	* sysdeps/unix/sysv/linux/s390/s390-32/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/s390/s390-64/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/sh/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/sparc/sparc32/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/sparc/sparc64/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/tile/tilegx/tilegx32/libm.abilist:
	Likewise.
	* sysdeps/unix/sysv/linux/tile/tilegx/tilegx64/libm.abilist:
	Likewise.
	* sysdeps/unix/sysv/linux/tile/tilepro/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/x86_64/64/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/x86_64/x32/libm.abilist: Likewise.
2017-09-25 10:45:08 +01:00
Szabolcs Nagy 72aa623345 Optimized generic expf and exp2f with wrappers
Based on new expf and exp2f code from
https://github.com/ARM-software/optimized-routines/

with wrapper on aarch64:
expf reciprocal-throughput: 2.3x faster
expf latency: 1.7x faster
without wrapper on aarch64:
expf reciprocal-throughput: 3.3x faster
expf latency: 1.7x faster
without wrapper on aarch64:
exp2f reciprocal-throughput: 2.8x faster
exp2f latency: 1.3x faster
libm.so size on aarch64:
.text size: -152 bytes
.rodata size: -1740 bytes
expf/exp2f worst case nearest rounding error: 0.502 ulp
worst case non-nearest rounding error: 1 ulp

Error checks are inline and errno setting is in separate tail called
functions, but the wrappers are kept in this patch to handle the
_LIB_VERSION==_SVID_ case.  (So e.g. errno is set twice for expf calls
and once for __expf_finite calls on targets where the new code is used.)

Double precision arithmetics is used which is expected to be faster on
most targets (including soft-float) than using single precision and it
is easier to get good precision result with it.

Const data is kept in a separate translation unit which complicates
maintenance a bit, but is expected to give good code for literal loads
on most targets and allows sharing data across expf, exp2f and powf.
(This data is disabled on i386, m68k and ia64 which have their own
expf, exp2f and powf code.)

Some details may need target specific tweaks:
- best convert and round to int operation in the arg reduction may be
different across targets.
- code was optimized on fma target, optimal polynomial eval may be
different without fma.
- gcc does not always generate good code for fp bit representation
access via unions or it may be inherently slow on some targets.

The libm-test-ulps will need adjustment because..
- The argument reduction ideally uses nearest rounded rint, but that is
not efficient on most targets, so the polynomial can get evaluated on a
wider interval in non-nearest rounding mode making 1 ulp errors common
in that case.
- The polynomial is evaluated such that it may have 1 ulp error on
negative tiny inputs with upward rounding.

	* math/Makefile (type-float-routines): Add math_errf and e_exp2f_data.
	* sysdeps/aarch64/fpu/math_private.h (TOINT_INTRINSICS): Define.
	(roundtoint, converttoint): Likewise.
	* sysdeps/ieee754/flt-32/e_expf.c: New implementation.
	* sysdeps/ieee754/flt-32/e_exp2f.c: New implementation.
	* sysdeps/ieee754/flt-32/e_exp2f_data.c: New file.
	* sysdeps/ieee754/flt-32/math_config.h: New file.
	* sysdeps/ieee754/flt-32/math_errf.c: New file.
	* sysdeps/ieee754/flt-32/t_exp2f.h: Remove.
	* sysdeps/i386/fpu/e_exp2f_data.c: New file.
	* sysdeps/i386/fpu/math_errf.c: New file.
	* sysdeps/ia64/fpu/e_exp2f_data.c: New file.
	* sysdeps/ia64/fpu/math_errf.c: New file.
	* sysdeps/m68k/m680x0/fpu/e_exp2f_data.c: New file.
	* sysdeps/m68k/m680x0/fpu/math_errf.c: New file.
2017-09-25 10:44:39 +01:00
Gabriel F. T. Gomes c5c4a62609 Let fpclassify use the builtin when optimizing for size in C++ mode (bug 22146)
When optimization for size is on (-Os), fpclassify does not use the
type-generic __builtin_fpclassify builtin, instead it uses __MATH_TG.
However, when library support for float128 is available, __MATH_TG uses
__builtin_types_compatible_p, which is not available in C++ mode.

On the other hand, libstdc++ undefines (in cmath) many macros from
math.h, including fpclassify, so that it can provide its own functions.
However, during its configure tests, libstdc++ just tests for the
availability of the macros (it does not undefine them, nor does it
provide its own functions).

Finally, when libstdc++ is configured with optimization for size
enabled, its configure tests include math.h and get the definition of
fpclassify that uses __MATH_TG (and __builtin_types_compatible_p).
Since libstdc++ does not undefine the macros during its configure tests,
they fail.

This patch lets fpclassify use the builtin in C++ mode, even when
optimization for size is on.  This allows the configure test in
libstdc++ to work.

Tested for powerpc64le and x86_64.

	[BZ #22146]
	math/math.h: Let fpclassify use the builtin in C++ mode, even
	when optimazing for size.
2017-09-22 14:47:16 -03:00
Joseph Myers 92892fdbfa Use libm_alias_ldouble in math/.
This patch converts libm function implementations in math/ from using
weak_alias to using libm_alias_ldouble to define public function
names, in cases where it would be appropriate to define _Float128 /
_Float64x aliases for those functions as well (in cases where either
or both of those types exist and have the same ABI as long double).
This eliminates many ldbl-opt wrappers round these function
implementations.

Tested for x86_64, and with build-many-glibcs.py.  All installed
stripped shared libraries are unchanged except for libm.so on
powerpc64le.  As noted for a previous patch, powerpc64le's use of
ldbl-opt means various long double functions get defined using
long_double_symbol which gives them an explicit symbol version in the
object files, and this patch results in some such functions using
weak_alias instead (because powerpc64le never had a previous version
of these functions for long double = double); both produce a valid
libm.so with the same public symbols at the same versions, but macros
expanding to call weak_alias is cleaner in this case.

	* math/s_fmal.c: Include <libm-alias-ldouble.h>.
	(fmal): Define using libm_alias_ldouble.
	* math/w_acoshl_compat.c: Include <libm-alias-ldouble.h>.
	(acoshl): Define using libm_alias_ldouble.
	* math/w_acosl_compat.c: Include <libm-alias-ldouble.h>.
	(acosl): Define using libm_alias_ldouble.
	* math/w_asinl_compat.c: Include <libm-alias-ldouble.h>.
	(asinl): Define using libm_alias_ldouble.
	* math/w_atan2l_compat.c: Include <libm-alias-ldouble.h>.
	(atan2l): Define using libm_alias_ldouble.
	* math/w_atanhl_compat.c: Include <libm-alias-ldouble.h>.
	(atanhl): Define using libm_alias_ldouble.
	* math/w_coshl_compat.c: Include <libm-alias-ldouble.h>.
	(coshl): Define using libm_alias_ldouble.
	* math/w_exp10l_compat.c: Include <libm-alias-ldouble.h>.
	(exp10l): Define using libm_alias_ldouble.
	* math/w_exp2l_compat.c: Include <libm-alias-ldouble.h>.
	(exp2l): Define using libm_alias_ldouble.
	* math/w_expl_compat.c: Include <libm-alias-ldouble.h>.
	(expl): Define using libm_alias_ldouble.
	* math/w_fmodl_compat.c: Include <libm-alias-ldouble.h>.
	(fmodl): Define using libm_alias_ldouble.
	* math/w_hypotl_compat.c: Include <libm-alias-ldouble.h>.
	(hypotl): Define using libm_alias_ldouble.
	* math/w_j0l_compat.c: Include <libm-alias-ldouble.h>.
	(j0l): Define using libm_alias_ldouble.
	(y0l): Likewise.
	* math/w_j1l_compat.c: Include <libm-alias-ldouble.h>.
	(j1l): Define using libm_alias_ldouble.
	(y1l): Likewise.
	* math/w_jnl_compat.c: Include <libm-alias-ldouble.h>.
	(jnl): Define using libm_alias_ldouble.
	(ynl): Likewise.
	* math/w_log10l_compat.c: Include <libm-alias-ldouble.h>.
	(log10l): Define using libm_alias_ldouble.
	* math/w_log2l_compat.c: Include <libm-alias-ldouble.h>.
	(log2l): Define using libm_alias_ldouble.
	* math/w_logl_compat.c: Include <libm-alias-ldouble.h>.
	(logl): Define using libm_alias_ldouble.
	* math/w_powl_compat.c: Include <libm-alias-ldouble.h>.
	(powl): Define using libm_alias_ldouble.
	* math/w_remainderl_compat.c: Include <libm-alias-ldouble.h>.
	(remainderl): Define using libm_alias_ldouble.
	* math/w_sinhl_compat.c: Include <libm-alias-ldouble.h>.
	(sinhl): Define using libm_alias_ldouble.
	* math/w_sqrtl_compat.c: Include <libm-alias-ldouble.h>.
	(sqrtl): Define using libm_alias_ldouble.
	* math/w_tgammal_compat.c: Include <libm-alias-ldouble.h>.
	(tgammal): Define using libm_alias_ldouble.
	* sysdeps/ieee754/ldbl-opt/w_exp10l_compat.c [LIBM_SVID_COMPAT]
	(exp10l): Do not use long_double_symbol here.
	* sysdeps/ieee754/ldbl-opt/w_remainderl_compat.c
	[LIBM_SVID_COMPAT] (remainderl): Likewise.
	* sysdeps/ieee754/ldbl-opt/s_fmal.c: Remove.
	* sysdeps/ieee754/ldbl-opt/w_acoshl_compat.c: Likewise.
	* sysdeps/ieee754/ldbl-opt/w_acosl_compat.c: Likewise.
	* sysdeps/ieee754/ldbl-opt/w_asinl_compat.c: Likewise.
	* sysdeps/ieee754/ldbl-opt/w_atan2l_compat.c: Likewise.
	* sysdeps/ieee754/ldbl-opt/w_atanhl_compat.c: Likewise.
	* sysdeps/ieee754/ldbl-opt/w_coshl_compat.c: Likewise.
	* sysdeps/ieee754/ldbl-opt/w_expl_compat.c: Likewise.
	* sysdeps/ieee754/ldbl-opt/w_fmodl_compat.c: Likewise.
	* sysdeps/ieee754/ldbl-opt/w_hypotl_compat.c: Likewise.
	* sysdeps/ieee754/ldbl-opt/w_j0l_compat.c: Likewise.
	* sysdeps/ieee754/ldbl-opt/w_j1l_compat.c: Likewise.
	* sysdeps/ieee754/ldbl-opt/w_jnl_compat.c: Likewise.
	* sysdeps/ieee754/ldbl-opt/w_log10l_compat.c: Likewise.
	* sysdeps/ieee754/ldbl-opt/w_log2l_compat.c: Likewise.
	* sysdeps/ieee754/ldbl-opt/w_logl_compat.c: Likewise.
	* sysdeps/ieee754/ldbl-opt/w_powl_compat.c: Likewise.
	* sysdeps/ieee754/ldbl-opt/w_sinhl_compat.c: Likewise.
	* sysdeps/ieee754/ldbl-opt/w_sqrtl_compat.c: Likewise.
	* sysdeps/ieee754/ldbl-opt/w_tgammal_compat.c: Likewise.
2017-09-18 17:51:33 +00:00
Joseph Myers 9ac4470888 Use libm_alias_double in math/.
This patch converts libm function implementations in math/ from using
weak_alias to using libm_alias_double to define public function names,
in cases where it would be appropriate to define _Float64 / _Float32x
aliases for those functions as well.  This eliminates many
NO_LONG_DOUBLE conditionals and ldbl-opt wrappers round these function
implementations.

Tested for x86_64.  Also tested with build-many-glibcs.py.  Binary
differences seen are that the different order in which remainder and
drem symbols get defined as a result of this patch (the same source
file defines the same aliases, but in a different order of definition)
changes the order of symbols in the final libm.so when long double =
double, and for ldbl-opt configurations, the compat symbols for Bessel
functions were previously defined by e.g. "compat_symbol (libm, j0,
j0l, GLIBC_2_0)", which declares j0l as a compat symbol based on j0
and so makes j0l weak because j0 is weak, and are now defined
(indirectly via the relevant macros) based on e.g. __j0, so are no
longer weak because __j0 isn't weak.

	* math/s_fma.c: Include <libm-alias-double.h>.
	(fma): Define using libm_alias_double.
	* math/s_nextafter.c: Include <libm-alias-double.h>.
	(nextafter): Define using libm_alias_double.
	* math/w_acos_compat.c: Include <libm-alias-double.h>.
	(acos): Define using libm_alias_double.
	* math/w_acosh_compat.c: Include <libm-alias-double.h>.
	(aocsh): Define using libm_alias_double.
	* math/w_asin_compat.c: Include <libm-alias-double.h>.
	(asin): Define using libm_alias_double.
	* math/w_atan2_compat.c: Include <libm-alias-double.h>.
	(atan2): Define using libm_alias_double.
	* math/w_atanh_compat.c: Include <libm-alias-double.h>.
	(atanh): Define using libm_alias_double.
	* math/w_cosh_compat.c: Include <libm-alias-double.h>.
	(cosh): Define using libm_alias_double.
	* math/w_exp10_compat.c: Include <libm-alias-double.h>.
	(exp10): Define using libm_alias_double.
	* math/w_exp2_compat.c: Include <libm-alias-double.h>.
	(exp2): Define using libm_alias_double.
	* math/w_exp_compat.c: Include <libm-alias-double.h>.
	(exp): Define using libm_alias_double.
	* math/w_fmod_compat.c: Include <libm-alias-double.h>.
	(fmod): Define using libm_alias_double.
	* math/w_hypot_compat.c: Include <libm-alias-double.h>.
	(hypot): Define using libm_alias_double.
	* math/w_j0_compat.c: Include <libm-alias-double.h>.
	(j0): Define using libm_alias_double.
	(y0): Likewise.
	* math/w_j1_compat.c: Include <libm-alias-double.h>.
	(j1): Define using libm_alias_double.
	(y1): Likewise.
	* math/w_jn_compat.c: Include <libm-alias-double.h>.
	(jn): Define using libm_alias_double.
	(yn): Likewise.
	* math/w_log10_compat.c: Include <libm-alias-double.h>.
	(log10): Define using libm_alias_double.
	* math/w_log2_compat.c: Include <libm-alias-double.h>.
	(log2): Define using libm_alias_double.
	* math/w_log_compat.c: Include <libm-alias-double.h>.
	(log): Define using libm_alias_double.
	* math/w_pow_compat.c: Include <libm-alias-double.h>.
	(pow): Define using libm_alias_double.
	* math/w_remainder_compat.c: Include <libm-alias-double.h>.
	(remainder): Define using libm_alias_double.
	* math/w_sinh_compat.c: Include <libm-alias-double.h>.
	(sinh): Define using libm_alias_double.
	* math/w_sqrt_compat.c: Include <libm-alias-double.h>.
	(sqrt): Define using libm_alias_double.
	* math/w_tgamma_compat.c: Include <libm-alias-double.h>.
	(tgamma): Define using libm_alias_double.
	* sysdeps/ieee754/ldbl-opt/s_nextafter.c [LONG_DOUBLE_COMPAT(libm,
	GLIBC_2_0)] (nextafterl): Do not define compat symbol here.
	* sysdeps/ieee754/ldbl-opt/w_exp10_compat.c
	[LONG_DOUBLE_COMPAT(libm, GLIBC_2_1)] (exp10l): Likewise.
	* sysdeps/ieee754/ldbl-opt/w_remainder_compat.c
	[LONG_DOUBLE_COMPAT(libm, GLIBC_2_0)] (remainderl): Likewise.
	* sysdeps/ieee754/ldbl-opt/w_acos_compat.c: Remove.
	* sysdeps/ieee754/ldbl-opt/w_acosh_compat.c: Likewise.
	* sysdeps/ieee754/ldbl-opt/w_asin_compat.c: Likewise.
	* sysdeps/ieee754/ldbl-opt/w_atan2_compat.c: Likewise.
	* sysdeps/ieee754/ldbl-opt/w_atanh_compat.c: Likewise.
	* sysdeps/ieee754/ldbl-opt/w_cosh_compat.c: Likewise.
	* sysdeps/ieee754/ldbl-opt/w_exp_compat.c: Likewise.
	* sysdeps/ieee754/ldbl-opt/w_fmod_compat.c: Likewise.
	* sysdeps/ieee754/ldbl-opt/w_hypot_compat.c: Likewise.
	* sysdeps/ieee754/ldbl-opt/w_j0_compat.c: Likewise.
	* sysdeps/ieee754/ldbl-opt/w_j1_compat.c: Likewise.
	* sysdeps/ieee754/ldbl-opt/w_jn_compat.c: Likewise.
	* sysdeps/ieee754/ldbl-opt/w_log10_compat.c: Likewise.
	* sysdeps/ieee754/ldbl-opt/w_log2_compat.c: Likewise.
	* sysdeps/ieee754/ldbl-opt/w_log_compat.c: Likewise.
	* sysdeps/ieee754/ldbl-opt/w_pow_compat.c: Likewise.
	* sysdeps/ieee754/ldbl-opt/w_sinh_compat.c: Likewise.
	* sysdeps/ieee754/ldbl-opt/w_sqrt_compat.c: Likewise.
	* sysdeps/ieee754/ldbl-opt/w_tgamma_compat.c: Likewise.
2017-09-15 23:10:02 +00:00
Joseph Myers c67a2328c8 Remove ENOSYS math/ function stubs.
The math/ directory has various stub implementations of functions
(generally long double functions, plus sqrtf128) that set errno to
ENOSYS and print a message.

These are a relic of when the long double libm implementation in glibc
was originally incomplete.  They are only present for a limited set of
libm functions, not all those that would need implementing for any
hypothetical new long double format, and only for long double (plus
sqrtf128), not for other floating-point types.  I removed the
corresponding ENOSYS tests in the testsuite in
<https://sourceware.org/ml/libc-alpha/2013-05/msg00599.html>.

I think these stubs are an inherently different case from stubs for
functionality needing OS-specific implementations, since
floating-point formats are generally standardized between modern
processors (a new long double format does not seem likely - I'd expect
new ports all to have long double = binary128 or long double =
binary64 - though _Float16 functions *f16 are entirely possible in
future) and libm functions are generally only expected to fail for
domain / range / pole errors, not for other unknown system-specific
conditions the way the functions needing OS-specific implementations
may fail.

This patch removes these stub implementations.  The effect (which, as
noted above, was actually mostly already the case, given the
incompleteness of the set of stubs, and was certainly the case if you
wanted your libm port to *work* rather than just build) is that any
new long double format needs to provide a full set of functions for
the build to succeed; any port using ldbl-128 needs to provide sqrtl
(possibly using the soft-fp version from another port); any port using
ldbl-96 needs to provide all those functions that all of
x86_64/i386/ia64/m68k provide rather than getting from the ldbl-96
directory; any port with _Float128 as a type with a distinct format
needs to provide sqrtf128.

Tested for x86_64.  Also tested with build-many-glibcs.py that
installed stripped shared libraries are unchanged by the patch.

	* math/e_acoshl.c: Remove.
	* math/e_acosl.c: Likewise.
	* math/e_asinl.c: Likewise.
	* math/e_atan2l.c: Likewise.
	* math/e_atanhl.c: Likewise.
	* math/e_coshl.c: Likewise.
	* math/e_expl.c: Likewise.
	* math/e_fmodl.c: Likewise.
	* math/e_gammal_r.c: Likewise.
	* math/e_hypotl.c: Likewise.
	* math/e_j0l.c: Likewise.
	* math/e_j1l.c: Likewise.
	* math/e_jnl.c: Likewise.
	* math/e_lgammal_r.c: Likewise.
	* math/e_log10l.c: Likewise.
	* math/e_log2l.c: Likewise.
	* math/e_logl.c: Likewise.
	* math/e_powl.c: Likewise.
	* math/e_rem_pio2l.c: Likewise.
	* math/e_sinhl.c: Likewise.
	* math/e_sqrtf128.c: Likewise.
	* math/e_sqrtl.c: Likewise.
	* math/k_cosl.c: Likewise.
	* math/k_sinl.c: Likewise.
	* math/k_tanl.c: Likewise.
	* math/s_asinhl.c: Likewise.
	* math/s_atanl.c: Likewise.
	* math/s_cbrtl.c: Likewise.
	* math/s_erfl.c: Likewise.
	* math/s_expm1l.c: Likewise.
	* math/s_log1pl.c: Likewise.
	* math/s_tanhl.c: Likewise.
2017-09-15 20:05:09 +00:00
Joseph Myers 5bcdb31529 Use libm_alias_float in math/.
This patch converts libm function implementations in math/ from using
weak_alias to using libm_alias_float to define public function names,
in cases where it would be appropriate to define _Float32 aliases for
those functions as well.  expf and exp2f are omitted from this patch,
given the in-progress patches that would change their symbol
versioning arrangements (at a later stage it will be necessary to add
macros that can be used for functions with such symbol versioning
arrangements - which will apply to lgammaf as well - but for the
initial patches in this area I'm just dealing with easy cases, and any
symbol versioning changes to these functions while the work is in
progress can effectively just undo the libm_alias_* changes as regards
those functions).

Tested for x86_64.  Also tested with build-many-glibcs.py that
installed stripped shared libraries are unchanged by the patch.

	* math/s_fmaf.c: Include <libm-alias-float.h>.
	(fmaf): Define using libm_alias_float.
	* math/w_acosf_compat.c: Include <libm-alias-float.h>.
	(acosf): Define using libm_alias_float.
	* math/w_acoshf_compat.c: Include <libm-alias-float.h>.
	(acoshf): Define using libm_alias_float.
	* math/w_asinf_compat.c: Include <libm-alias-float.h>.
	(asinf): Define using libm_alias_float.
	* math/w_atan2f_compat.c: Include <libm-alias-float.h>.
	(atan2f): Define using libm_alias_float.
	* math/w_atanhf_compat.c: Include <libm-alias-float.h>.
	(atanhf): Define using libm_alias_float.
	* math/w_coshf_compat.c: Include <libm-alias-float.h>.
	(coshf): Define using libm_alias_float.
	* math/w_exp10f_compat.c: Include <libm-alias-float.h>.
	(exp10f): Define using libm_alias_float.
	* math/w_fmodf_compat.c: Include <libm-alias-float.h>.
	(fmodf): Define using libm_alias_float.
	* math/w_hypotf_compat.c: Include <libm-alias-float.h>.
	(hypotf): Define using libm_alias_float.
	* math/w_j0f_compat.c: Include <libm-alias-float.h>.
	(j0f): Define using libm_alias_float.
	(y0f): Likewise.
	* math/w_j1f_compat.c: Include <libm-alias-float.h>.
	(j1f): Define using libm_alias_float.
	(y1f): Likewise.
	* math/w_jnf_compat.c: Include <libm-alias-float.h>.
	(jnf): Define using libm_alias_float.
	(ynf): Likewise.
	* math/w_log10f_compat.c: Include <libm-alias-float.h>.
	(log10f): Define using libm_alias_float.
	* math/w_log2f_compat.c: Include <libm-alias-float.h>.
	(log2f): Define using libm_alias_float.
	* math/w_logf_compat.c: Include <libm-alias-float.h>.
	(logf): Define using libm_alias_float.
	* math/w_powf_compat.c: Include <libm-alias-float.h>.
	(powf): Define using libm_alias_float.
	* math/w_remainderf_compat.c: Include <libm-alias-float.h>.
	(remainderf): Define using libm_alias_float.
	* math/w_sinhf_compat.c: Include <libm-alias-float.h>.
	(sinhf): Define using libm_alias_float.
	* math/w_sqrtf_compat.c: Include <libm-alias-float.h>.
	(sqrtf): Define using libm_alias_float.
	* math/w_tgammaf_compat.c: Include <libm-alias-float.h>.
	(tgammaf): Define using libm_alias_float.
2017-09-15 17:12:02 +00:00
Joseph Myers 01f2881245 Make more libm functions into weak aliases.
Many libm functions define the function as __<func> and then define
<func> as a weak alias.  This is not at all limited to cases where
there is an internal call that has namespace reasons to need to call
__<func> instead of <func>.

The common macros for creating libm function aliases work on the basis
of public function names all being aliases; that is, they define
aliases for functions using the above pattern.  Thus, where a function
just defines the public name <func> directly, changing that to be a
weak alias enables a subsequent conversion to the common macros to
retain the exact existing symbols (and so be testable by comparison of
stripped binaries).

This patch converts many existing functions to use the weak alias
pattern, as preparation for subsequent conversions to common macros.
I do expect that _FloatN/_FloatNx function aliases will end up needing
new variants of the common macros that do *not* create the original
float / double / long double name of a function - for cases where that
name is created specially to give it a particular symbol version, for
example - but for functions that can use the most common macros to
create all the public names as aliases, it makes sense for them to do
so.

Regarding the Bessel function wrappers in this patch: only float and
double wrappers are changed because the long double wrappers already
used the weak alias pattern.

Tested for x86_64, and with build-many-glibcs.py.

	* include/math.h (roundeven): Change hidden_proto call to
	__roundeven.
	* math/w_j0_compat.c (j0): Rename to __j0 and define as weak
	alias.
	[NO_LONG_DOUBLE] (__j0l): New strong alias.
	(y0): Rename to __y0 and define as weak alias.
	[NO_LONG_DOUBLE] (__y0l): New strong alias.
	* math/w_j0f_compat.c (j0f): Rename to __j0f and define as weak
	alias.
	(y0f): Rename to __y0f and define as weak alias.
	* math/w_j1_compat.c (j1): Rename to __j1 and define as weak
	alias.
	[NO_LONG_DOUBLE] (__j1l): New strong alias.
	(y1): Rename to __y1 and define as weak alias.
	[NO_LONG_DOUBLE] (__y1l): New strong alias.
	* math/w_j1f_compat.c (j1f): Rename to __j1f and define as weak
	alias.
	(y1f): Rename to __y1f and define as weak alias.
	* math/w_jn_compat.c (jn): Rename to __jn and define as weak
	alias.
	[NO_LONG_DOUBLE] (__jnl): New strong alias.
	(yn): Rename to __yn and define as weak alias.
	[NO_LONG_DOUBLE] (__ynl): New strong alias.
	* math/w_jnf_compat.c (jnf): Rename to __jnf and define as weak
	alias.
	(ynf): Rename to __ynf and define as weak alias.
	* sysdeps/ieee754/dbl-64/s_fromfp.c (FUNC): Define to __fromfp.
	(fromfp): Define as weak alias.
	[NO_LONG_DOUBLE] (__fromfpl): New strong alias.
	* sysdeps/ieee754/dbl-64/s_fromfpx.c (FUNC): Define to __fromfpx.
	(fromfpx): Define as weak alias.
	[NO_LONG_DOUBLE] (__fromfpxl): New strong alias.
	* sysdeps/ieee754/dbl-64/s_getpayload.c (getpayload): Rename to
	__getpayload and define as weak alias.
	[NO_LONG_DOUBLE] (__getpayloadl): New strong alias.
	* sysdeps/ieee754/dbl-64/s_roundeven.c (roundeven): Rename to
	__roundeven and define as weak alias.
	[NO_LONG_DOUBLE] (__roundevenl): New strong alias.
	* sysdeps/ieee754/dbl-64/s_setpayload.c (FUNC): Define to
	__setpayload.
	(setpayload): Define as weak alias.
	[NO_LONG_DOUBLE] (__setpayloadl): New strong alias.
	* sysdeps/ieee754/dbl-64/s_setpayloadsig.c (FUNC): Define to
	__setpayloadsig.
	(setpayloadsig): Define as weak alias.
	[NO_LONG_DOUBLE] (__setpayloadsigl): New strong alias.
	* sysdeps/ieee754/dbl-64/s_totalorder.c (totalorder): Rename to
	__totalorder and define as weak alias.
	[NO_LONG_DOUBLE] (__totalorderl): New strong alias.
	* sysdeps/ieee754/dbl-64/s_totalordermag.c (totalordermag): Rename
	to __totalordermag and define as weak alias.
	[NO_LONG_DOUBLE] (__totalordermagl): New strong alias.
	* sysdeps/ieee754/dbl-64/s_ufromfp.c (FUNC): Define to __ufromfp.
	(ufromfp): Define as weak alias.
	[NO_LONG_DOUBLE] (__ufromfpl): New strong alias.
	* sysdeps/ieee754/dbl-64/s_ufromfpx.c (FUNC): Define to
	__ufromfpx.
	(ufromfpx): Define as weak alias.
	[NO_LONG_DOUBLE] (__ufromfpxl): New strong alias.
	* sysdeps/ieee754/dbl-64/wordsize-64/s_getpayload.c (getpayload):
	Rename to __getpayload and define as weak alias.
	[NO_LONG_DOUBLE] (__getpayloadl): New strong alias.
	* sysdeps/ieee754/dbl-64/wordsize-64/s_roundeven.c (roundeven):
	Rename to __roundeven and define as weak alias.
	[NO_LONG_DOUBLE] (__roundevenl): New strong alias.
	* sysdeps/ieee754/dbl-64/wordsize-64/s_totalorder.c (totalorder):
	Rename to __totalorder and define as weak alias.
	[NO_LONG_DOUBLE] (__totalorderl): New strong alias.
	* sysdeps/ieee754/dbl-64/wordsize-64/s_totalordermag.c
	(totalordermag): Rename to __totalordermag and define as weak
	alias.
	[NO_LONG_DOUBLE] (__totalordermagl): New strong alias.
	* sysdeps/ieee754/float128/float128_private.h (__getpayloadl): New
	macro.
	(__roundevenl): Likewise.
	(__totalorderl): Likewise.
	(__totalordermagl): Likewise
	* sysdeps/ieee754/float128/s_fromfpf128.c (FUNC): Define to
	__fromfpf128.
	(fromfpf128): Define as weak alias.
	* sysdeps/ieee754/float128/s_fromfpxf128.c (FUNC): Define to
	__fromfpxf128.
	(fromfpxf128): Define as weak alias.
	* sysdeps/ieee754/float128/s_setpayloadf128.c (FUNC): Define to
	__setpayloadf128.
	(setpayloadf128): Define as weak alias.
	* sysdeps/ieee754/float128/s_setpayloadsigf128.c (FUNC): Define to
	__setpayloadsigf128.
	(setpayloadsigf128): Define as weak alias.
	* sysdeps/ieee754/float128/s_ufromfpf128.c (FUNC): Define to
	__ufromfpf128.
	(ufromfpf128): Define as weak alias.
	* sysdeps/ieee754/float128/s_ufromfpxf128.c (FUNC): Define to
	__ufromfpxf128.
	(ufromfpxf128): Define as weak alias.
	* sysdeps/ieee754/flt-32/s_fromfpf.c (FUNC): Define to __fromfpf.
	(fromfpf): Define as weak alias.
	* sysdeps/ieee754/flt-32/s_fromfpxf.c (FUNC): Define to
	__fromfpxf.
	(fromfpxf): Define as weak alias.
	* sysdeps/ieee754/flt-32/s_getpayloadf.c (getpayloadf): Rename to
	__getpayloadf and define as weak alias.
	* sysdeps/ieee754/flt-32/s_roundevenf.c (roundevenf): Rename to
	__roundevenf and define as weak alias.
	* sysdeps/ieee754/flt-32/s_setpayloadf.c (FUNC): Define to
	__setpayloadf.
	(setpayloadf): Define as weak alias.
	* sysdeps/ieee754/flt-32/s_setpayloadsigf.c (FUNC): Define to
	__setpayloadsigf.
	(setpayloadsigf): Define as weak alias.
	* sysdeps/ieee754/flt-32/s_totalorderf.c (totalorderf): Rename to
	__totalorderf and define as weak alias.
	* sysdeps/ieee754/flt-32/s_totalordermagf.c (totalordermagf):
	Rename to __totalordermagf and define as weak alias.
	* sysdeps/ieee754/flt-32/s_ufromfpf.c (FUNC): Define to
	__ufromfpf.
	(ufromfpf): Define as weak alias.
	* sysdeps/ieee754/flt-32/s_ufromfpxf.c (FUNC): Define to
	__ufromfpxf.
	(ufromfpxf): Define as weak alias.
	* sysdeps/ieee754/ldbl-128/s_fromfpl.c (FUNC): Define to
	__fromfpl.
	(fromfpl): Define as weak alias.
	* sysdeps/ieee754/ldbl-128/s_fromfpxl.c (FUNC): Define to
	__fromfpxl.
	(fromfpxl): Define as weak alias.
	* sysdeps/ieee754/ldbl-128/s_getpayloadl.c (getpayloadl): Rename
	to __getpayloadl and define as weak alias.
	* sysdeps/ieee754/ldbl-128/s_roundevenl.c (roundevenl): Rename to
	__roundevenl and define as weak alias.
	* sysdeps/ieee754/ldbl-128/s_setpayloadl.c (FUNC): Define to
	__setpayloadl.
	(setpayloadl): Define as weak alias.
	* sysdeps/ieee754/ldbl-128/s_setpayloadsigl.c (FUNC): Define to
	__setpayloadsigl.
	(setpayloadsigl): Define as weak alias.
	* sysdeps/ieee754/ldbl-128/s_totalorderl.c (totalorderl): Rename
	to __totalorderl and define as weak alias.
	* sysdeps/ieee754/ldbl-128/s_totalordermagl.c (totalordermagl):
	Rename to __totalordermagl and define as weak alias.
	* sysdeps/ieee754/ldbl-128/s_ufromfpl.c (FUNC): Define to
	__ufromfpl.
	(ufromfpl): Define as weak alias.
	* sysdeps/ieee754/ldbl-128/s_ufromfpxl.c (FUNC): Define to
	__ufromfpxl.
	(ufromfpxl): Define as weak alias.
	* sysdeps/ieee754/ldbl-128ibm/s_fromfpl.c (FUNC): Define to
	__fromfpl.
	(fromfpl): Define as weak alias.
	* sysdeps/ieee754/ldbl-128ibm/s_fromfpxl.c (FUNC): Define to
	__fromfpxl.
	(fromfpxl): Define as weak alias.
	* sysdeps/ieee754/ldbl-128ibm/s_getpayloadl.c (getpayloadl):
	Rename to __getpayloadl and define as weak alias.
	* sysdeps/ieee754/ldbl-128ibm/s_roundevenl.c (roundevenl): Rename
	to __roundevenl and define as weak alias.  Call __roundeven
	instead of roundeven.
	* sysdeps/ieee754/ldbl-128ibm/s_setpayloadl.c (FUNC): Define to
	__setpayloadl.
	(setpayloadl): Define as weak alias.
	* sysdeps/ieee754/ldbl-128ibm/s_setpayloadsigl.c (FUNC): Define to
	__setpayloadsigl.
	(setpayloadsigl): Define as weak alias.
	* sysdeps/ieee754/ldbl-128ibm/s_totalorderl.c (totalorderl):
	Rename to __totalorderl and define as weak alias.
	* sysdeps/ieee754/ldbl-128ibm/s_totalordermagl.c (totalordermagl):
	Rename to __totalordermagl and define as weak alias.
	* sysdeps/ieee754/ldbl-128ibm/s_ufromfpl.c (FUNC): Define to
	__ufromfpl.
	(ufromfpl): Define as weak alias.
	* sysdeps/ieee754/ldbl-128ibm/s_ufromfpxl.c (FUNC): Define to
	__ufromfpxl.
	(ufromfpxl): Define as weak alias.
	* sysdeps/ieee754/ldbl-96/s_fromfpl.c (FUNC): Define to
	__fromfpl.
	(fromfpl): Define as weak alias.
	* sysdeps/ieee754/ldbl-96/s_fromfpxl.c (FUNC): Define to
	__fromfpxl.
	(fromfpxl): Define as weak alias.
	* sysdeps/ieee754/ldbl-96/s_getpayloadl.c (getpayloadl): Rename to
	__getpayloadl and define as weak alias.
	* sysdeps/ieee754/ldbl-96/s_roundevenl.c (roundevenl): Rename to
	__roundevenl and define as weak alias.
	* sysdeps/ieee754/ldbl-96/s_setpayloadl.c (FUNC): Define to
	__setpayloadl.
	(setpayloadl): Define as weak alias.
	* sysdeps/ieee754/ldbl-96/s_setpayloadsigl.c (FUNC): Define to
	__setpayloadsigl.
	(setpayloadsigl): Define as weak alias.
	* sysdeps/ieee754/ldbl-96/s_totalorderl.c (totalorderl): Rename to
	__totalorderl and define as weak alias.
	* sysdeps/ieee754/ldbl-96/s_totalordermagl.c (totalordermagl):
	Rename to __totalordermagl and define as weak alias.
	* sysdeps/ieee754/ldbl-96/s_ufromfpl.c (FUNC): Define to
	__ufromfpl.
	(ufromfpl): Define as weak alias.
	* sysdeps/ieee754/ldbl-96/s_ufromfpxl.c (FUNC): Define to
	__ufromfpxl.
	(ufromfpxl): Define as weak alias.
2017-09-14 22:28:53 +00:00
Szabolcs Nagy bcea7ad608 Move exp compat wrappers under math/
Move exp compat wrappers to math/w_exp{,f,l}_compat.c to be
consistent with other wrappers.

	* sysdeps/ieee754/dbl-64/w_exp_compat.c: Move to...
	* math/w_exp_compat.c: ... here.
	* sysdeps/ieee754/flt-32/w_expf_compat.c: Move to...
	* math/w_expf_compat.c: ... here.
	* sysdeps/ieee754/ldbl-128/w_expl_compat.c: Move to...
	* math/w_expl_compat.c: ... here.
	* sysdeps/ieee754/ldbl-128ibm/w_expl_compat.c: Remove.
	* sysdeps/ieee754/ldbl-96/w_expl_compat.c: Remove.
	* sysdeps/ieee754/ldbl-opt/w_exp_compat.c: Use the new path.
	* sysdeps/ieee754/ldbl-opt/w_expl_compat.c: Likewise.
2017-09-13 17:22:22 +01:00
Joseph Myers 0fc56478a9 Clear up log1p, ldexp, scalbn, scalbln compat handling.
This patch cleans up how compat symbols / long double versioning are
handled for log1p, ldexp, scalbn and scalbln functions.

The general principle is to do as much as possible through the
type-generic templates.  Previously, when errno-setting wrappers were
added the compat long double symbols were left pointing directly to
the underlying implementations; they are moved to point to the
errno-setting wrappers.  For the functions also present in libc,
compat symbol handling for the libc copies needs to go in ldbl-opt
wrappers, but the type-generic templates can handle it for the libm
copies.  There is no need for w_scalbln_template.c to disable the
creation of an unused internal alias (such code made sense in the
context of patches trying to avoid any changes to generated code for
ease of comparison, but can be removed in a change that specifically
does intend to change details of where symbols point).

Tested for x86_64, and with build-many-glibcs.py.

	* math/w_scalbln_template.c (strong_alias): Do not undefine and
	redefine.
	* sysdeps/ieee754/ldbl-opt/s_ldexp.c (declare_mgen_alias): Remove
	macro.
	(ldexpl): Only define as compat symbol for libc, not libm.
	(scalbnl): Define as compat symbol for libc here.
	* sysdeps/ieee754/ldbl-opt/s_ldexpl.c (declare_mgen_alias): Only
	define for [IS_IN (libc)].
	(__ldexpl_2): Remove alias.
	(ldexpl): Only define with long_double_symbol if [IS_IN (libc)].
	(scalbnl): Likewise.  Use __wrap_scalbnl not __ldexpl_2 as base
	name in long_double_symbol call.
	* sysdeps/ieee754/ldbl-opt/s_log1p.c: Remove file.
	* sysdeps/ieee754/ldbl-opt/s_scalbln.c: Likewise.
	* sysdeps/ieee754/ldbl-opt/s_scalbn.c: Likewise.
	* sysdeps/ieee754/ldbl-opt/w_log1p.c: Likewise.
	* sysdeps/ieee754/ldbl-opt/w_scalbln.c (declare_mgen_alias):
	Remove macro.
	[IS_IN (libc) && LONG_DOUBLE_COMPAT (libc, GLIBC_2_1)] (scalblnl):
	Define as compat symbol.
2017-09-13 15:47:26 +00:00
Joseph Myers 620ff9eea6 Define and use libm_alias_double.
Continuing the process of setting up common macros for libm function
aliases, with a view to using them to define _FloatN / _FloatNx
aliases in future, this patch adds a libm_alias_double macro and uses
it in the type-generic templates.

This macro handles defining aliases for double, and for long double in
the NO_LONG_DOUBLE case.  It also handles defining compat symbols for
long double = double for architectures that changed their long double
format.  By so doing, it eliminates the need for the
M_LIBM_NEED_COMPAT and declare_mgen_libm_compat macros; the single
declare_mgen_alias call in each template now suffices to define all
required compat symbols.  When used for more double functions (not
based on type-generic templates), I expect it will eliminate the need
for most ldbl-opt wrappers for such functions.

A few special cases are needed.  __clog10l is a public symbol (for
historical reasons) so needs to be given appropriate compat versions
for architectures that changed their long double format, but is not
defined as an alias using the normal macros since __clog10* are *not*
public symbols for _FloatN / _FloatNx types.  For scalbn, scalbln and
log1p, the changes adding errno setting support for those functions
left compat symbols pointing directly to the non-errno-setting
implementations.  There is no requirement for the compat symbols not
to set errno; that just made for the simplest patches at that time.
Now, with these common macros, it's natural to redirect the compat
symbols to the errno-setting wrappers, which I intend to do in a
separate patch.

Tested for x86_64, and with build-many-glibcs.py.  For ldbl-opt
platforms the stripped libm.so binaries are changed (disassembly
unchanged) because the details of how the clog10l compat symbol is
created mean it ceases to be weak as it was before; for other
platforms, stripped libm.so binaries are unchanged.

2017-09-13  Joseph Myers  <joseph@codesourcery.com>

	* sysdeps/generic/libm-alias-double.h: New file.
	* sysdeps/ieee754/ldbl-opt/libm-alias-double.h: Likewise.
	* sysdeps/generic/math-type-macros-double.h: Include
	<libm-alias-double.h>.
	[declare_mgen_alias] (declare_mgen_alias): Define to use
	libm_alias_double.
	* sysdeps/generic/math-type-macros.h [!M_LIBM_NEED_COMPAT]
	(M_LIBM_NEED_COMPAT): Remove macro.
	[!M_LIBM_NEED_COMPAT] (declare_mgen_libm_compat): Likewise.
	* sysdeps/ieee754/ldbl-opt/math-type-macros-double.h: Remove.
	* math/cabs_template.c [M_LIBM_NEED_COMPAT]: Remove conditional
	code.
	* math/carg_template.c [M_LIBM_NEED_COMPAT]: Likewise.
	* math/cimag_template.c [M_LIBM_NEED_COMPAT]: Likewise.
	* math/conj_template.c [M_LIBM_NEED_COMPAT]: Likewise.
	* math/creal_template.c [M_LIBM_NEED_COMPAT]: Likewise.
	* math/s_cacos_template.c [M_LIBM_NEED_COMPAT]: Likewise.
	* math/s_cacosh_template.c [M_LIBM_NEED_COMPAT]: Likewise.
	* math/s_casin_template.c [M_LIBM_NEED_COMPAT]: Likewise.
	* math/s_casinh_template.c [M_LIBM_NEED_COMPAT]: Likewise.
	* math/s_catan_template.c [M_LIBM_NEED_COMPAT]: Likewise.
	* math/s_catanh_template.c [M_LIBM_NEED_COMPAT]: Likewise.
	* math/s_ccos_template.c [M_LIBM_NEED_COMPAT]: Likewise.
	* math/s_ccosh_template.c [M_LIBM_NEED_COMPAT]: Likewise.
	* math/s_cexp_template.c [M_LIBM_NEED_COMPAT]: Likewise.
	* math/s_clog10_template.c [M_LIBM_NEED_COMPAT]: Likewise.
	* math/s_clog_template.c [M_LIBM_NEED_COMPAT]: Likewise.
	* math/s_cpow_template.c [M_LIBM_NEED_COMPAT]: Likewise.
	* math/s_cproj_template.c [M_LIBM_NEED_COMPAT]: Likewise.
	* math/s_csin_template.c [M_LIBM_NEED_COMPAT]: Likewise.
	* math/s_csinh_template.c [M_LIBM_NEED_COMPAT]: Likewise.
	* math/s_csqrt_template.c [M_LIBM_NEED_COMPAT]: Likewise.
	* math/s_ctan_template.c [M_LIBM_NEED_COMPAT]: Likewise.
	* math/s_ctanh_template.c [M_LIBM_NEED_COMPAT]: Likewise.
	* math/s_fdim_template.c [M_LIBM_NEED_COMPAT]: Likewise.
	* math/s_fmax_template.c [M_LIBM_NEED_COMPAT]: Likewise.
	* math/s_fmin_template.c [M_LIBM_NEED_COMPAT]: Likewise.
	* math/s_nan_template.c [M_LIBM_NEED_COMPAT]: Likewise.
	* math/w_ilogb_template.c [M_LIBM_NEED_COMPAT]: Likewise.
	* sysdeps/ieee754/ldbl-opt/s_clog10.c: New file.
	* sysdeps/ieee754/ldbl-opt/s_ldexp.c (M_LIBM_NEED_COMPAT): Remove
	macro.
	(declare_mgen_alias): New macro.
	* sysdeps/ieee754/ldbl-opt/w_log1p.c: New file.
	* sysdeps/ieee754/ldbl-opt/w_scalbln.c: Likewise.
	* sysdeps/sparc/sparc32/sparcv9/fpu/multiarch/s_fdim-vis3.c
	(M_LIBM_NEED_COMPAT): Remove macro.
	* sysdeps/sparc/sparc32/sparcv9/fpu/multiarch/s_fdim.c
	[HAVE_AS_VIS3_SUPPORT]: Include <math_ldbl_opt.h> and
	<first-versions.h>.
	[HAVE_AS_VIS3_SUPPORT && LONG_DOUBLE_COMPAT (libm,
	FIRST_VERSION_libm_fdiml)]: Define fdiml as compat symbol.
2017-09-13 01:13:30 +00:00
Joseph Myers a891caff7a Remove declare_mgen_alias_2.
The libm template machinery includes a macro declare_mgen_alias_2, to
define two function aliases rather than one.  This macro is only used
in one place, to define ldexp and scalbn, and only has one nondefault
definition, for double in the case where long double has the same
format.  That definition is because declare_mgen_alias for double, in
that case, defines <internal-func>l as an alias of <internal-func>, so
cannot be called twice for aliases of the same function.

Now, I suspect the <internal-func>l aliases are generally not needed
(with maybe a few exceptions such as __clog10l, which is an exported
function).  But even in the presence of them, there is no need for a
special declare_mgen_alias_2 macro for this case.  This patch
eliminates the need for such a macro by defining __wrap_scalbn<suffix>
as an alias of __ldexp<suffix>, and then using that when defining the
scalbn public aliases.  This is similar to how such internal aliases
are created for functions with multiple symbol versions, for example.

Tested for x86_64, and with build-many-glibcs.py.  (There *are* some
cases where installed stripped shared libraries change - not in the
generated code but because such changes to static symbols on input to
ld, even nonexported symbols that don't affect the code or dynamic
symbols, can affect the particular representation in the output of
string tables, hash tables etc.)

	* sysdeps/generic/math-type-macros.h [!declare_mgen_alias_2]
	(declare_mgen_alias_2): Remove.
	* sysdeps/generic/math-type-macros-double.h
	[NO_LONG_DOUBLE && !declare_mgen_alias_2] (declare_mgen_alias_2):
	Likewise.
	* math/s_ldexp_template.c (M_SUF (__wrap_scalbn)): Define strong
	alias.
	(ldexp): Define with declare_mgen_alias.
	(scalbn): Likewise.
2017-09-12 20:00:00 +00:00
Joseph Myers 4f3647e46e Prefer new libm function wrappers for !LIBM_SVID_COMPAT.
The initial obsoletion of SVID libm error handling left the old
wrappers and __kernel_standard still being used for new ports and
static linking, just with macro definitions of _LIB_VERSION and
matherr that meant symbols with those names were never actually used
and the code for different error handling variants could be optimized
out.

This patch cleans things up further by eliminating the
__kernel_standard use for new ports and static linking.  Now, the old
wrappers no longer generate any code in the !LIBM_SVID_COMPAT case,
while the new errno-only wrappers that were added for float128 support
are now also used for float, double and long double in that case.

The changes are generally straightforward.  The w_scalb*_compat
wrappers continue to be used (scalb is obsolescent in the sense of not
being supported for float128, but is present in supported standards -
the 2001 edition of POSIX and earlier XSI versions - so remains
supported for static linking and new ports, as do the float and long
double variants that are existing GNU extensions).  Those wrappers
would only call __kernel_standard in the _LIB_VERSION == _SVID_ case.
Since we would like to be able to compile most of glibc without
optimization, relying on a static function whose only use is under an
if (0) condition being optimized away to avoid an undefined
__kernel_standard reference may not be a good idea.  Thus, the
relevant code in the scalb wrappers has LIBM_SVID_COMPAT conditionals
added to guarantee it's not built at all in the case where
__kernel_standard does not exist.

Just as i386 has its own w_sqrt_compat.c, so w_sqrt.c is also added.
ia64 gets dummy w_*.c to prevent those files being built where they
would conflict with the ia64 libm, as with its existing w_*_compat.c.

Conditions disabling code for !LIBM_SVID_COMPAT are needed in both the
math/ wrappers and in the long double wrappers in ldbl-opt (to avoid
them setting up aliases and symbol versions for undefined symbols).  I
hope that future cleanups to how libm function aliases and symbol
versioning are done will eliminate the need for most of the ldbl-opt
wrappers.

Tested for x86_64 and x86, and with build-many-glibcs.py.

	* sysdeps/generic/math-type-macros-double.h: Include
	<math-svid-compat.h>.
	(__USE_WRAPPER_TEMPLATE): Define to !LIBM_SVID_COMPAT.
	* sysdeps/generic/math-type-macros-float.h: Include
	<math-svid-compat.h>.
	(__USE_WRAPPER_TEMPLATE): Define to !LIBM_SVID_COMPAT.
	* sysdeps/generic/math-type-macros-ldouble.h: Include
	<math-svid-compat.h>.
	(__USE_WRAPPER_TEMPLATE): Define to !LIBM_SVID_COMPAT.
	* math/lgamma-compat.h (BUILD_LGAMMA): Include LIBM_SVID_COMPAT
	condition.
	* math/w_acos_compat.c: Condition contents on [LIBM_SVID_COMPAT].
	* math/w_acosf_compat.c: Likewise.
	* math/w_acosh_compat.c: Likewise.
	* math/w_acoshf_compat.c: Likewise.
	* math/w_acoshl_compat.c: Likewise.
	* math/w_acosl_compat.c: Likewise.
	* math/w_asin_compat.c: Likewise.
	* math/w_asinf_compat.c: Likewise.
	* math/w_asinl_compat.c: Likewise.
	* math/w_atan2_compat.c: Likewise.
	* math/w_atan2f_compat.c: Likewise.
	* math/w_atan2l_compat.c: Likewise.
	* math/w_atanh_compat.c: Likewise.
	* math/w_atanhf_compat.c: Likewise.
	* math/w_atanhl_compat.c: Likewise.
	* math/w_cosh_compat.c: Likewise.
	* math/w_coshf_compat.c: Likewise.
	* math/w_coshl_compat.c: Likewise.
	* math/w_exp10_compat.c: Likewise.
	* math/w_exp10f_compat.c: Likewise.
	* math/w_exp10l_compat.c: Likewise.
	* math/w_exp2_compat.c: Likewise.
	* math/w_exp2f_compat.c: Likewise.
	* math/w_exp2l_compat.c: Likewise.
	* math/w_fmod_compat.c: Likewise.
	* math/w_fmodf_compat.c: Likewise.
	* math/w_fmodl_compat.c: Likewise.
	* math/w_hypot_compat.c: Likewise.
	* math/w_hypotf_compat.c: Likewise.
	* math/w_hypotl_compat.c: Likewise.
	* math/w_j0_compat.c: Likewise.
	* math/w_j0f_compat.c: Likewise.
	* math/w_j0l_compat.c: Likewise.
	* math/w_j1_compat.c: Likewise.
	* math/w_j1f_compat.c: Likewise.
	* math/w_j1l_compat.c: Likewise.
	* math/w_jn_compat.c: Likewise.
	* math/w_jnf_compat.c: Likewise.
	* math/w_jnl_compat.c: Likewise.
	* math/w_lgamma_r_compat.c: Likewise.
	* math/w_lgammaf_r_compat.c: Likewise.
	* math/w_lgammal_r_compat.c: Likewise.
	* math/w_log10_compat.c: Likewise.
	* math/w_log10f_compat.c: Likewise.
	* math/w_log10l_compat.c: Likewise.
	* math/w_log2_compat.c: Likewise.
	* math/w_log2f_compat.c: Likewise.
	* math/w_log2l_compat.c: Likewise.
	* math/w_log_compat.c: Likewise.
	* math/w_logf_compat.c: Likewise.
	* math/w_logl_compat.c: Likewise.
	* math/w_pow_compat.c: Likewise.
	* math/w_powf_compat.c: Likewise.
	* math/w_powl_compat.c: Likewise.
	* math/w_remainder_compat.c: Likewise.
	* math/w_remainderf_compat.c: Likewise.
	* math/w_remainderl_compat.c: Likewise.
	* math/w_sinh_compat.c: Likewise.
	* math/w_sinhf_compat.c: Likewise.
	* math/w_sinhl_compat.c: Likewise.
	* math/w_sqrt_compat.c: Likewise.
	* math/w_sqrtf_compat.c: Likewise.
	* math/w_sqrtl_compat.c: Likewise.
	* math/w_tgamma_compat.c: Likewise.
	* math/w_tgammaf_compat.c: Likewise.
	* math/w_tgammal_compat.c: Likewise.
	* math/w_scalb_compat.c (sysv_scalb): Condition definition on
	[LIBM_SVID_COMPAT].
	(__scalb): Condition call to sysv_scalb on [LIBM_SVID_COMPAT].
	* math/w_scalbf_compat.c (sysv_scalbf): Condition definition on
	[LIBM_SVID_COMPAT].
	(__scalbf): Condition call to sysv_scalbf on [LIBM_SVID_COMPAT].
	* math/w_scalbl_compat.c (sysv_scalbl): Condition definition on
	[LIBM_SVID_COMPAT].
	(__scalbl): Condition call to sysv_scalbl on [LIBM_SVID_COMPAT].
	* sysdeps/i386/fpu/w_sqrt.c: New file.
	* sysdeps/ia64/fpu/w_acos.c: Likewise.
	* sysdeps/ia64/fpu/w_acosf.c: Likewise.
	* sysdeps/ia64/fpu/w_acosh.c: Likewise.
	* sysdeps/ia64/fpu/w_acoshf.c: Likewise.
	* sysdeps/ia64/fpu/w_acoshl.c: Likewise.
	* sysdeps/ia64/fpu/w_acosl.c: Likewise.
	* sysdeps/ia64/fpu/w_asin.c: Likewise.
	* sysdeps/ia64/fpu/w_asinf.c: Likewise.
	* sysdeps/ia64/fpu/w_asinl.c: Likewise.
	* sysdeps/ia64/fpu/w_atan2.c: Likewise.
	* sysdeps/ia64/fpu/w_atan2f.c: Likewise.
	* sysdeps/ia64/fpu/w_atan2l.c: Likewise.
	* sysdeps/ia64/fpu/w_atanh.c: Likewise.
	* sysdeps/ia64/fpu/w_atanhf.c: Likewise.
	* sysdeps/ia64/fpu/w_atanhl.c: Likewise.
	* sysdeps/ia64/fpu/w_cosh.c: Likewise.
	* sysdeps/ia64/fpu/w_coshf.c: Likewise.
	* sysdeps/ia64/fpu/w_coshl.c: Likewise.
	* sysdeps/ia64/fpu/w_exp.c: Likewise.
	* sysdeps/ia64/fpu/w_exp10.c: Likewise.
	* sysdeps/ia64/fpu/w_exp10f.c: Likewise.
	* sysdeps/ia64/fpu/w_exp10l.c: Likewise.
	* sysdeps/ia64/fpu/w_exp2.c: Likewise.
	* sysdeps/ia64/fpu/w_exp2f.c: Likewise.
	* sysdeps/ia64/fpu/w_exp2l.c: Likewise.
	* sysdeps/ia64/fpu/w_expf.c: Likewise.
	* sysdeps/ia64/fpu/w_expl.c: Likewise.
	* sysdeps/ia64/fpu/w_fmod.c: Likewise.
	* sysdeps/ia64/fpu/w_fmodf.c: Likewise.
	* sysdeps/ia64/fpu/w_fmodl.c: Likewise.
	* sysdeps/ia64/fpu/w_hypot.c: Likewise.
	* sysdeps/ia64/fpu/w_hypotf.c: Likewise.
	* sysdeps/ia64/fpu/w_hypotl.c: Likewise.
	* sysdeps/ia64/fpu/w_lgamma_r.c: Likewise.
	* sysdeps/ia64/fpu/w_lgammaf_r.c: Likewise.
	* sysdeps/ia64/fpu/w_lgammal_r.c: Likewise.
	* sysdeps/ia64/fpu/w_log.c: Likewise.
	* sysdeps/ia64/fpu/w_log10.c: Likewise.
	* sysdeps/ia64/fpu/w_log10f.c: Likewise.
	* sysdeps/ia64/fpu/w_log10l.c: Likewise.
	* sysdeps/ia64/fpu/w_log2.c: Likewise.
	* sysdeps/ia64/fpu/w_log2f.c: Likewise.
	* sysdeps/ia64/fpu/w_log2l.c: Likewise.
	* sysdeps/ia64/fpu/w_logf.c: Likewise.
	* sysdeps/ia64/fpu/w_logl.c: Likewise.
	* sysdeps/ia64/fpu/w_pow.c: Likewise.
	* sysdeps/ia64/fpu/w_powf.c: Likewise.
	* sysdeps/ia64/fpu/w_powl.c: Likewise.
	* sysdeps/ia64/fpu/w_remainder.c: Likewise.
	* sysdeps/ia64/fpu/w_remainderf.c: Likewise.
	* sysdeps/ia64/fpu/w_remainderl.c: Likewise.
	* sysdeps/ia64/fpu/w_sinh.c: Likewise.
	* sysdeps/ia64/fpu/w_sinhf.c: Likewise.
	* sysdeps/ia64/fpu/w_sinhl.c: Likewise.
	* sysdeps/ia64/fpu/w_sqrt.c: Likewise.
	* sysdeps/ia64/fpu/w_sqrtf.c: Likewise.
	* sysdeps/ia64/fpu/w_sqrtl.c: Likewise.
	* sysdeps/ia64/fpu/w_tgamma.c: Likewise.
	* sysdeps/ia64/fpu/w_tgammaf.c: Likewise.
	* sysdeps/ia64/fpu/w_tgammal.c: Likewise.
	* sysdeps/ieee754/dbl-64/w_exp_compat.c: Condition contents on
	[LIBM_SVID_COMPAT].
	* sysdeps/ieee754/flt-32/w_expf_compat.c: Likewise.
	* sysdeps/ieee754/k_standard.c: Likewise.
	* sysdeps/ieee754/k_standardf.c: Likewise.
	* sysdeps/ieee754/k_standardl.c: Likewise.
	* sysdeps/ieee754/ldbl-128/w_expl_compat.c: Likewise.
	* sysdeps/ieee754/ldbl-128ibm/w_expl_compat.c: Likewise.
	* sysdeps/ieee754/ldbl-96/w_expl_compat.c: Likewise.
	* sysdeps/ieee754/ldbl-64-128/w_expl_compat.c: Condition
	long_double_symbol call on [LIBM_SVID_COMPAT].
	* sysdeps/ieee754/ldbl-opt/w_acoshl_compat.c: Likewise.
	* sysdeps/ieee754/ldbl-opt/w_acosl_compat.c: Likewise.
	* sysdeps/ieee754/ldbl-opt/w_asinl_compat.c: Likewise.
	* sysdeps/ieee754/ldbl-opt/w_atan2l_compat.c: Likewise.
	* sysdeps/ieee754/ldbl-opt/w_atanhl_compat.c: Likewise.
	* sysdeps/ieee754/ldbl-opt/w_coshl_compat.c: Likewise.
	* sysdeps/ieee754/ldbl-opt/w_fmodl_compat.c: Likewise.
	* sysdeps/ieee754/ldbl-opt/w_hypotl_compat.c: Likewise.
	* sysdeps/ieee754/ldbl-opt/w_j0l_compat.c: Likewise.
	* sysdeps/ieee754/ldbl-opt/w_j1l_compat.c: Likewise.
	* sysdeps/ieee754/ldbl-opt/w_jnl_compat.c: Likewise.
	* sysdeps/ieee754/ldbl-opt/w_lgammal_r_compat.c: Likewise.
	* sysdeps/ieee754/ldbl-opt/w_log10l_compat.c: Likewise.
	* sysdeps/ieee754/ldbl-opt/w_log2l_compat.c: Likewise.
	* sysdeps/ieee754/ldbl-opt/w_logl_compat.c: Likewise.
	* sysdeps/ieee754/ldbl-opt/w_powl_compat.c: Likewise.
	* sysdeps/ieee754/ldbl-opt/w_remainderl_compat.c: Likewise.
	* sysdeps/ieee754/ldbl-opt/w_sinhl_compat.c: Likewise.
	* sysdeps/ieee754/ldbl-opt/w_sqrtl_compat.c: Likewise.
	* sysdeps/ieee754/ldbl-opt/w_tgammal_compat.c: Likewise.
	* sysdeps/ieee754/ldbl-opt/w_exp10l_compat.c: Condition
	long_double_symbol and compat_symbol calls on [LIBM_SVID_COMPAT].
2017-09-05 23:35:55 +00:00
Steve Ellcey 05b38d64b1 Fix tests that are testing obsoleted functionality
* include/shlib-compat.h (TEST_COMPAT): New Macro.
	* malloc/tst-mallocstate.c: Convert from test-skeleton
	to test-driver.  Ifdef code using TEST_COMPAT macro.
	* math/test-matherr-2.c: Ifdef test using TEST_COMPAT macro.
	* math/test-matherr.c: Likewise.
2017-09-05 12:24:00 -07:00
Joseph Myers f3a129b872 Fix bits/math-finite.h exp10 condition (bug 22082).
bits/math-finite.h handles exp10 if __USE_GNU.  It should use the
condition __GLIBC_USE (IEC_60559_FUNCS_EXT), as in bits/mathcalls.h.
This patch fixes the condition.

Tested for x86_64.

	[BZ #22082]
	* math/bits/math-finite.h (exp10): Redirect if [__GLIBC_USE
	(IEC_60559_FUNCS_EXT)], not [__USE_GNU].
2017-09-04 16:28:23 +00:00
Florian Weimer b38042f514 math.h: Warn about an already-defined log macro
This is a common programming error, and the cause of the problem is not
always obvious.

<tgmath.h> defines a log macro, but it includes <math.h> before that, so
that is compatible with the warning.
2017-09-04 17:56:31 +02:00
Joseph Myers 5a80d39d0d Obsolete pow10 functions.
This patch obsoletes the pow10, pow10f and pow10l functions (makes
them into compat symbols, not available for new ports or static
linking).  The exp10 names for these functions are standardized (in TS
18661-4) and were added in the same glibc version (2.1) as pow10 so
source code can change to use them without any loss of portability.
Since pow10 is deliberately not provided for _Float128, only exp10,
this slightly simplifies moving to the new wrapper templates in the
!LIBM_SVID_COMPAT case, by avoiding needing to arrange for pow10,
pow10f and pow10l to be defined by those templates.

Tested for x86_64, and with build-many-glibcs.py.

	* manual/math.texi (pow10): Do not document.
	(pow10f): Likewise.
	(pow10l): Likewise.
	* math/bits/mathcalls.h [__USE_GNU] (pow10): Do not declare.
	* math/bits/math-finite.h [__USE_GNU] (pow10): Likewise.
	* math/libm-test-exp10.inc (pow10_test): Remove.
	(do_test): Do not call pow10.
	* math/w_exp10_compat.c (pow10): Make into compat symbol.
	[NO_LONG_DOUBLE] (pow10l): Likewise.
	* math/w_exp10f_compat.c (pow10f): Likewise.
	* math/w_exp10l_compat.c (pow10l): Likewise.
	* sysdeps/ia64/fpu/e_exp10.S: Include <shlib-compat.h>.
	(pow10): Make into compat symbol.
	* sysdeps/ia64/fpu/e_exp10f.S: Include <shlib-compat.h>.
	(pow10f): Make into compat symbol.
	* sysdeps/ia64/fpu/e_exp10l.S: Include <shlib-compat.h>.
	(pow10l): Make into compat symbol.
	* sysdeps/ieee754/ldbl-opt/Makefile (libnldbl-calls): Remove
	pow10.
	(CFLAGS-nldbl-pow10.c): Remove variable..
	* sysdeps/ieee754/ldbl-opt/nldbl-pow10.c: Remove file.
	* sysdeps/ieee754/ldbl-opt/w_exp10_compat.c (pow10l): Condition on
	[SHLIB_COMPAT (libm, GLIBC_2_1, GLIBC_2_27)].
	* sysdeps/ieee754/ldbl-opt/w_exp10l_compat.c (compat_symbol):
	Undefine and redefine.
	(pow10l): Make into compat symbol.
	* sysdeps/aarch64/libm-test-ulps: Remove pow10 ulps.
	* sysdeps/alpha/fpu/libm-test-ulps: Likewise.
	* sysdeps/arm/libm-test-ulps: Likewise.
	* sysdeps/hppa/fpu/libm-test-ulps: Likewise.
	* sysdeps/i386/fpu/libm-test-ulps: Likewise.
	* sysdeps/i386/i686/fpu/multiarch/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/nios2/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.
2017-09-01 21:13:18 +00:00
Zack Weinberg a617bd119f math/math.h (HUGE_VAL): Improve commentary. 2017-09-01 11:19:47 -04:00
Joseph Myers c0c49d60cf Simplify NAN definitions.
Similar to my patches for HUGE_VAL and INFINITY. this patch eliminates
the bits/nan.h headers.  __builtin_nanf ("") is used to define NAN for
GCC 3.3 and later; the fallback is (0.0f / 0.0f), which is a constant
expression for a quiet NaN of type float, but raises a spurious
"invalid" exception outside static initializers, which seems the best
that can be done purely in standard C.  Again, if anyone actually uses
a compiler with its own incompatible extension for producing a
constant quiet NaN, we can add compiler conditionals.

Tested for x86_64.

	*  math/math.h [__USE_ISOC99] (NAN): Define directly here.  Do not
	include <bits/nan.h>.
	* math/Makefile (headers): Remove bits/nan.h.
	* bits/nan.h: Remove.
	* sysdeps/ieee754/bits/nan.h: Likewise.
	* sysdeps/mips/bits/nan.h: Likewise.
2017-08-31 16:39:25 +00:00
Joseph Myers 5ef1b2138d Simplify INFINITY definitions.
Similar to my patch for HUGE_VAL, this patch eliminates the bits/inf.h
headers and just unconditionally uses the same definitions as the
sysdeps/ieee754 version did (__builtin_inff () for GCC >= 3.3,
otherwise HUGE_VALF), directly in math.h, so removing an unnecessary
level of indirection.

Tested for x86_64.

	* math/math.h [__USE_ISOC99] (INFINITY): Define directly here.  Do
	not include <bits/inf.h>.
	* math/Makefile (headers): Remove bits/inf.h.
	* bits/inf.h: Remove.
	* sysdeps/ieee754/bits/inf.h: Likewise.
2017-08-31 16:12:46 +00:00
Joseph Myers a60eca2e55 Simplify HUGE_VAL definitions.
There are various bits/huge_val*.h headers to define HUGE_VAL and
related macros.  All of them use __builtin_huge_val etc. for GCC 3.3
and later.  Then there are various fallbacks, such as using a large
hex float constant for GCC 2.96 and later, or using unions (with or
without compound literals) to construct the bytes of an infinity, with
this last being the reason for having architecture-specific files.
Supporting TS 18661-3 _FloatN / _FloatNx types that have the same
format as other supported types will mean adding more such macros;
needing to add more headers for them doesn't seem very desirable.

The fallbacks based on bytes of the representation of an infinity do
not meet the standard requirements for a constant expression.  At
least one of them is also wrong: sysdeps/sh/bits/huge_val.h is
producing a mixed-endian representation which does not match what GCC
does.

This patch eliminates all those headers, defining the macros directly
in math.h.  For GCC 3.3 and later, the built-in functions are used as
now.  For other compilers, a large constant 1e10000 (with appropriate
suffix) is used.  This is like the fallback for GCC 2.96 and later,
but without using hex floats (which have no apparent advantage here).
It is unambiguously valid standard C for all floating-point formats
with infinities, which covers all formats supported by glibc or likely
to be supported by glibc in future (C90 DR#025 said that if a
floating-point format represents infinities, all real values lie
within the range of representable values, so the constraints for
constant expressions are not violated), but may generate compiler
warnings and wouldn't handle the TS 18661-1 FENV_ROUND pragma
correctly.  If someone is actually using a compiler with glibc that
does not claim to be GCC 3.3 or later, but which has a better way to
define the HUGE_VAL macros, we can always add compiler conditionals in
with alternative definitions.

I intend to make similar changes for INF and NAN.  The SNAN macros
already just use __builtin_nans etc. with no fallback for compilers
not claiming to be GCC 3.3 or later.

Tested for x86_64.

	* math/math.h: Do not include bits/huge_val.h, bits/huge_valf.h,
	bits/huge_vall.h or bits/huge_val_flt128.h.
	(HUGE_VAL): Define directly here.
	[__USE_ISOC99] (HUGE_VALF): Likewise.
	[__USE_ISOC99] (HUGE_VALL): Likewise.
	[__HAVE_FLOAT128 && __GLIBC_USE (IEC_60559_TYPES_EXT)]
	(HUGE_VAL_F128): Likewise.
	* math/Makefile (headers): Remove bits/huge_val.h,
	bits/huge_valf.h, bits/huge_vall.h and bits/huge_val_flt128.h.
	* bits/huge_val.h: Remove.
	* bits/huge_val_flt128.h: Likewise.
	* bits/huge_valf.h: Likewise.
	* bits/huge_vall.h: Likewise.
	* sysdeps/ia64/bits/huge_vall.h: Likewise.
	* sysdeps/ieee754/bits/huge_val.h: Likewise.
	* sysdeps/ieee754/bits/huge_valf.h: Likewise.
	* sysdeps/m68k/m680x0/bits/huge_vall.h: Likewise.
	* sysdeps/sh/bits/huge_val.h: Likewise.
	* sysdeps/sparc/bits/huge_vall.h: Likewise.
	* sysdeps/x86/bits/huge_vall.h: Likewise.
2017-08-31 15:50:50 +00:00
Joseph Myers 7daada0319 Fix bits/math-finite.h _MSUF_ expansion namespace (bug 22028).
The current bits/math-finite.h approach to defining functions for
different types, involving math.h defining _MSUF_ and _MSUFTO_ for the
function suffixes involved, is not namespace-clean if one of those
suffixes (f, l, f128) is defined as a macro by the user before math.h
is included; too many levels of macro expansion occur.  Instead, those
suffixes should appear directly in the expansion of the macro using ##
so they don't get expanded even if defined as macros by the user (that
is, math.h should be defining __REDIRFROM_X and __REDIRTO_X directly
to use those suffixes rather than suffixes being passed as an argument
by macro callers).  This patch makes that change.

Tested for x86_64.

	[BZ #22028]
	* math/math.h [__FINITE_MATH_ONLY__ && __FINITE_MATH_ONLY__ > 0]
	(_MSUF_): Remove macro.
	[__FINITE_MATH_ONLY__ && __FINITE_MATH_ONLY__ > 0] (_MSUFTO_):
	Likewise.
	[__FINITE_MATH_ONLY__ && __FINITE_MATH_ONLY__ > 0]
	(__REDIRFROM_X): New macro.
	[__FINITE_MATH_ONLY__ && __FINITE_MATH_ONLY__ > 0] (__REDIRTO_X):
	Likewise.
	* math/bits/math-finite.h (__REDIRFROM_X): Remove macro.
	(__REDIRTO_X): Likewise.
	(__MATH_REDIRCALL): Do not pass _MSUF_ or _MSUFTO_ macro
	arguments.
	(__MATH_REDIRCALL_2): Likewise.
	(__MATH_REDIRCALL_INTERNAL): Likewise.
	(__REDIRFROM (lgamma, , _MSUF_)): Likewise.
	(__REDIRFROM (gamma, , _MSUF_)): Likweise.
	(__REDIRFROM (__gamma, _r_finite, _MSUF_)): Likewise.
	(__REDIRFROM (tgamma, , _MSUF_)): Likewise.
	* math/test-finite-macros.c: New file.
	* math/Makefile (tests): Add test-finite-macros.
	(CFLAGS-test-finite-macros.c): New variable.
2017-08-29 14:15:37 +00:00
Gabriel F. T. Gomes 42496114ec Provide a C++ version of iszero that does not use __MATH_TG (bug 21930)
When signaling nans are enabled (with -fsignaling-nans), the C++ version
of iszero uses the fpclassify macro, which is defined with __MATH_TG.
However, when support for float128 is available, __MATH_TG uses the
builtin __builtin_types_compatible_p, which is only available in C mode.

This patch refactors the C++ version of iszero so that it uses function
overloading to select between the floating-point types, instead of
relying on fpclassify and __MATH_TG.

Tested for powerpc64le, s390x, x86_64, and with build-many-glibcs.py.

	[BZ #21930]
	* math/math.h [defined __cplusplus && defined __SUPPORT_SNAN__]
	(iszero): New C++ implementation that does not use
	fpclassify/__MATH_TG/__builtin_types_compatible_p, when
	signaling nans are enabled, since __builtin_types_compatible_p
	is a C-only feature.
	* math/test-math-iszero.cc: When __HAVE_DISTINCT_FLOAT128 is
	defined, include ieee754_float128.h for access to the union and
	member ieee854_float128.ieee.
	[__HAVE_DISTINCT_FLOAT128] (do_test): Call check_float128.
	[__HAVE_DISTINCT_FLOAT128] (check_float128): New function.
	* sysdeps/powerpc/powerpc64le/Makefile [subdir == math]
	(CXXFLAGS-test-math-iszero.cc): Add -mfloat128 to the build
	options of test-math-zero on powerpc64le.
2017-08-28 15:22:37 -03:00
Joseph Myers a48c0fb4b4 Simplify math-svid-compat code.
Now there are no more assembly wrappers using _LIB_VERSION or
__kernel_standard, the math-svid-compat code can be slighly
simplified.  math-svid-compat.h no longer needs __ASSEMBLER__
conditionals, and the _LIB_VERSION variable no longer needs to be
built for static libm, since all references are now in C code that
includes math-svid-compat.h and so gets the macro definition of
_LIB_VERSION to _POSIX_ outside the compat case.  This patch makes
those cleanups.

Tested for x86_64, and with build-many-glibcs.py.

	* math/math-svid-compat.h [!__ASSEMBLER__]: Make code
	unconditional.
	* sysdeps/ieee754/s_lib_version.c [!defined SHARED]: Remove
	conditional code; define contents only for [LIBM_SVID_COMPAT].
2017-08-28 15:19:52 +00:00
Joseph Myers a6ccdb0839 Use __HAVE_DISTINCT_FLOAT128 in tgmath.h.
When _Float128 is ABI-equivalent to long double, there is no need for
tgmath.h to have any special _Float128 handling: it's always OK to
call the long double versions of functions for _Float128 arguments in
that case, and the logic to determine return types is generic.  Thus,
this patch changes the use of __HAVE_FLOAT128 to
__HAVE_DISTINCT_FLOAT128, as a minor optimization to reduce the size
of the macro expansions in the ABI-equivalent case.

Tested for x86_64.

	* math/tgmath.h [__HAVE_FLOAT128]: Change conditional to
	[__HAVE_DISTINCT_FLOAT128].
2017-08-25 17:02:33 +00:00
Joseph Myers 23761119fe Clean up bits/math-finite.h for aliasing types.
This patch cleans up how bits/math-finite.h handles types that are
ABI-aliases of other types.

For such types, no __*_finite functions exist; instead,
bits/math-finite.h must redirect calls to a the functions for a
canonical choice of type for each floating-point format.  (For the
actual public interfaces, symbols need exporting for each type, even
those that are ABI-aliases, because of standard requirements that
programs can declare the functions themselves without including
<math.h>, but that does not apply to __*_finite.)

At present, there is a special-case conditional in bits/math-finite.h
on __MATH_DECLARING_LDOUBLE && defined __NO_LONG_DOUBLE_MATH to handle
redirecting long double function calls to double __*_finite.  This
patch replaces this by a more general mechanism.  math.h, before each
inclusion of bits/math-finite.h, defines _MSUFTO_ as the suffix to use
on the target of redirection, in addition to the existing _MSUF_.
This way, __MATH_DECLARING_LDOUBLE can go away, as can the special
conditional in bits/math-finite.h.  With this patch, math.h is now
prepared for the case of supporting float128 functions as aliases of
long double ones on platforms where long double is binary128, with
_MSUFTO_ appropriately defined for that case, and appropriate _MSUFTO_
definitions can easily be included when supporting _Float32 / _Float64
/ _Float32x / _Float64x (which will always be ABI-aliases of another
type when supported).

Tested for x86_64, and did a compilation test for ARM with
build-many-glibcs.py to cover the long double = double case.

	* math/math.h (_MSUFTO_): Define and undefine for each inclusion
	of <bits/math-finite.h>.
	(__MATH_DECLARING_LDOUBLE): Do not define and undefine for each
	inclusion of <bits/math-finite.h>.
	* math/bits/math-finite.h (__REDIRTO_X): Do not define
	conditionally on [__MATH_DECLARING_LDOUBLE && defined
	__NO_LONG_DOUBLE_MATH].
	(__MATH_REDIRCALL): Use _MSUFTO_ in __REDIRTO call.
	(__MATH_REDIRCALL_2): Likewise.
	(__MATH_REDIRCALL_INTERNAL): Likewise.
	(__REDIRFROM (lgamma, , _MSUF_)): Likewise.
	(__REDIRFROM (gamma, , _MSUF_)): Likewise.
	(__REDIRFROM (tgamma, , _MSUF_)): Likewise.
2017-08-25 16:11:13 +00:00
Gabriel F. T. Gomes 3d7b66f66c Fix the C++ version of issignaling when __NO_LONG_DOUBLE_MATH is defined
When __NO_LONG_DOUBLE_MATH is defined, __issignalingl is not available,
thus issignaling with long double argument should call __issignaling,
instead.

Tested for powerpc64le.

	* math/math.h [defined __cplusplus] (issignaling): In the long
	double case, call __issignalingl only if __NO_LONG_DOUBLE_MATH
	is not defined.  Call __issignaling, otherwise.
2017-08-24 16:06:42 -03:00
Gabriel F. T. Gomes 453a493d2b Remove duplicate inclusion of header math-svid-compat.h
The header math-svid-compat.h has been unintentionally included twice in
the wrappers for the remainder functions.  This patch removes the
duplicate inclusions.

	* math/w_remainder_compat.c: Remove duplicate inclusion of
	math-svid-compat.h.
	* math/w_remainderf_compat.c: Likewise.
	* math/w_remainderl_compat.c: Likewise.
2017-08-22 15:24:37 -03:00
Joseph Myers d9bef9c0a4 Fix tgmath.h handling of complex integers (bug 21684).
The tgmath.h macros return a real type not a complex type when an
argument is of complex integer type (a GNU extension) and there are no
arguments of complex floating type.  It seems clear that just as real
integers are mapped to double for tgmath.h, so complex integers should
be mapped to _Complex double.

This patch implements such a mapping.  The main complication in fixing
this bug is that the tgmath.h macros expand their arguments a large
number of times, resulting in exponential blowup of the size of the
expansion when calls to tgmath.h macros are used in the arguments of
such macros; it would be unfortunate for fixing a bug with a fairly
obscure extension to make the macros expand their arguments even more
times.  Thus, this patch optimizes the definitions of the relevant
macros.  __tgmath_real_type previously expanded its argument 7 times
and now expands it 3 times.  __tgmath_complex_type, used in place of
__tgmath_real_type only for functions that might return either real or
complex types, not for complex functions that always return real types
or always return complex types, expands its argument 5 times.  So the
sizes of the macro expansions from nested macro calls are
correspondingly reduced (remembering that each tgmath.h macro expands
__tgmath_real_type, or sometimes now __tgmath_complex_type, several
times).

Sometimes the real return type resulted from calling a complex
function and converting the result to a real type; sometimes it
resulted from calling a real function, because the logic for
determining whether arguments were real or complex, based on sizeof,
was confused by integer promotions applying to e.g. short int but not
_Complex short int.  The relevant tests are converted to use a new
macro __expr_is_real, which, by calling __builtin_classify_type rather
than comparing the results of two calls to sizeof, also reduces the
number of times macros expand their arguments.

Although there are reductions in the number of times macros expand
their arguments, I do not consider this to fix bug 21660, since a
proper fix means each macro expanding its arguments only once (via
using new compiler features designed for that purpose).

Tested for x86_64.

	[BZ #21684]
	* math/tgmath.h (__floating_type): Simplify definitions.
	(__real_integer_type): New macro.
	(__complex_integer_type): Likewise.
	(__expr_is_real): Likewise.
	(__tgmath_real_type_sub): Update comment to describe handling of
	complex types.
	(__tgmath_complex_type_sub): New macro.
	(__tgmath_complex_type): Likewise.
	[__HAVE_FLOAT128 && __GLIBC_USE (IEC_60559_TYPES_EXT)]
	(__TGMATH_CF128): Use __expr_is_real.
	(__TGMATH_UNARY_REAL_IMAG): Use __tgmath_complex_type and
	__expr_is_real.
	(__TGMATH_BINARY_REAL_IMAG): Likewise.
	(__TGMATH_UNARY_REAL_IMAG_RET_REAL): Use __expr_is_real.
	* math/gen-tgmath-tests.py (Type.create_type): Create complex
	integer types.
2017-08-22 17:55:42 +00:00
Gabriel F. T. Gomes a16e8bc08e Provide a C++ version of issignaling that does not use __MATH_TG
The macro __MATH_TG contains the logic to select between long double and
_Float128, when these types are ABI-distinct.  This logic relies on
__builtin_types_compatible_p, which is not available in C++ mode.

On the other hand, C++ function overloading provides the means to
distinguish between the floating-point types.  The overloading
resolution will match the correct parameter regardless of type
qualifiers, i.e.: const and volatile.

Tested for powerpc64le, s390x, and x86_64.

	* math/math.h [defined __cplusplus] (issignaling): Provide a C++
	definition for issignaling that does not rely on __MATH_TG,
	since __MATH_TG uses __builtin_types_compatible_p, which is only
	available in C mode.
	(CFLAGS-test-math-issignaling.cc): New variable.
	* math/Makefile [CXX] (tests): Add test-math-issignaling.
	* math/test-math-issignaling.cc: New test for C++ implementation
	of type-generic issignaling.
	* sysdeps/powerpc/powerpc64le/Makefile [subdir == math]
	(CXXFLAGS-test-math-issignaling.cc): Add -mfloat128 to the build
	options of test-math-issignaling on powerpc64le.
2017-08-22 10:05:41 -03:00
Florian Weimer a4d57b7947 math: Statically link tests of internal functionality 2017-08-22 13:50:27 +02:00
Joseph Myers 813378e9fe Obsolete matherr, _LIB_VERSION, libieee.a.
This patch obsoletes support for SVID libm error handling (the system
where a user-defined function matherr is called on a libm function
error; only enabled if you also set _LIB_VERSION = _SVID_ or
_LIB_VERSION = _XOPEN_) and the use of the _LIB_VERSION global
variable to control libm error handling.  matherr and _LIB_VERSION are
made into compat symbols, not supported for new ports or for static
linking.  The libieee.a object file (which sets _LIB_VERSION = _IEEE_,
so disabling errno setting for some functions) is also removed, and
all the related definitions are removed from math.h.

The manual already recommends against using matherr, and it's already
not supported for _Float128 functions (those use new wrappers that
don't support matherr, only errno) - this patch means that it becomes
possible to e.g. add sinf32 as an alias to sinf without that resulting
in undesired matherr support in sinf32 for existing glibc ports.
matherr support is not part of any standard supported by glibc (it was
removed in XPG4).

Because matherr is a function to be defined by the user, of course
user programs defining such a function will still continue to link; it
just quietly won't be used.  If they try to write to the library's
copy of _LIB_VERSION to enable SVID error handling, however, they will
get a link error (but if they define their own _LIB_VERSION variable,
they won't).

I expect the most likely case of build failures from this patch to be
programs with unconditional cargo-culted uses of -lieee (based on a
notion of "I want IEEE floating point", not any actual requirement for
that library).

Ideally, the new-port-or-static-linking case would use the new
wrappers used for _Float128.  This is not implemented in this patch,
because of the complication of architecture-specific (powerpc32 and
sparc) sqrt wrappers that use _LIB_VERSION and __kernel_standard
directly.  Thus, the old wrappers and __kernel_standard are still
built unconditionally, and _LIB_VERSION still exists in static libm.
But when the old wrappers and __kernel_standard are built in the
non-compat case, _LIB_VERSION and matherr are defined as macros so
code to support those features isn't actually built into static libm
or new ports' shared libm after this patch.

I intend to move to the new wrappers for static libm and new ports in
followup patches.  I believe the sqrt wrappers for powerpc32 and sparc
can reasonably be removed.  GCC already optimizes the normal case of
sqrt by generating code that uses a hardware instruction and only
calls the sqrt function if the argument was negative (if
-fno-math-errno, of course, it just uses the hardware instruction
without any check for negative argument being needed).  Thus those
wrappers will only actually get called in the case of negative
arguments, which is not a case it makes sense to optimize for.  But
even without removing the powerpc32 and sparc wrappers it should still
be possible to move to the new wrappers for static libm and new ports,
just without having those dubious architecture-specific optimizations
in static libm.

Everything said about matherr equally applies to matherrf and matherrl
(IA64-specific, undocumented), except that the structure of IA64 libm
means it won't be converted to using the new wrappers (it doesn't use
the old ones either, but its own error-handling code instead).

As with other tests of compat symbols, I expect test-matherr and
test-matherr-2 to need to become appropriately conditional once we
have a system for disabling such tests for ports too new to have the
relevant symbols.

Tested for x86_64 and x86, and with build-many-glibcs.py.

	* math/math.h [__USE_MISC] (_LIB_VERSION_TYPE): Remove.
	[__USE_MISC] (_LIB_VERSION): Likewise.
	[__USE_MISC] (struct exception): Likewise.
	[__USE_MISC] (matherr): Likewise.
	[__USE_MISC] (DOMAIN): Likewise.
	[__USE_MISC] (SING): Likewise.
	[__USE_MISC] (OVERFLOW): Likewise.
	[__USE_MISC] (UNDERFLOW): Likewise.
	[__USE_MISC] (TLOSS): Likewise.
	[__USE_MISC] (PLOSS): Likewise.
	[__USE_MISC] (HUGE): Likewise.
	[__USE_XOPEN] (MAXFLOAT): Define even if [__USE_MISC].
	* math/math-svid-compat.h: New file.
	* conform/linknamespace.pl (@whitelist): Remove matherr, matherrf
	and matherrl.
	* include/math.h [!_ISOMAC] (__matherr): Remove.
	* manual/arith.texi (FP Exceptions): Do not document matherr.
	* math/Makefile (tests): Change test-matherr to test-matherr-3.
	(tests-internal): New variable.
	(install-lib): Do not add libieee.a.
	(non-lib.a): Likewise.
	(extra-objs): Do not add libieee.a and ieee-math.o.
	(CPPFLAGS-s_lib_version.c): Remove variable.
	($(objpfx)libieee.a): Remove rule.
	($(addprefix $(objpfx), $(tests-internal)): Depend on $(libm).
	* math/ieee-math.c: Remove.
	* math/libm-test-support.c (matherr): Remove.
	* math/test-matherr.c: Use <support/test-driver.c>.  Add copyright
	and license notices.  Include <math-svid-compat.h> and
	<shlib-compat.h>.
	(matherr): Undefine as macro.  Use compat_symbol_reference.
	(_LIB_VERSION): Likewise.
	* math/test-matherr-2.c: New file.
	* math/test-matherr-3.c: Likewise.
	* sysdeps/generic/math_private.h (__kernel_standard): Remove
	declaration.
	(__kernel_standard_f): Likewise.
	(__kernel_standard_l): Likewise.
	* sysdeps/ieee754/s_lib_version.c: Do not include <math.h> or
	<math_private.h>.  Include <math-svid-compat.h>.
	(_LIB_VERSION): Undefine as macro.
	(_LIB_VERSION_INTERNAL): Always initialize to _POSIX_.  Define
	only if [LIBM_SVID_COMPAT || !defined SHARED].  If
	[LIBM_SVID_COMPAT], use compat_symbol.
	* sysdeps/ieee754/s_matherr.c: Do not include <math.h> or
	<math_private.h>.  Include <math-svid-compat.h>.
	(matherr): Undefine as macro.
	(__matherr): Define only if [LIBM_SVID_COMPAT].  Use
	compat_symbol.
	* sysdeps/ia64/fpu/libm_error.c: Include <math-svid-compat.h>.
	[_LIBC && LIBM_SVID_COMPAT] (matherrf): Use
	compat_symbol_reference.
	[_LIBC && LIBM_SVID_COMPAT] (matherrl): Likewise.
	[_LIBC && !LIBM_SVID_COMPAT] (matherrf): Define as macro.
	[_LIBC && !LIBM_SVID_COMPAT] (matherrl): Likewise.
	* sysdeps/ia64/fpu/libm_support.h: Include <math-svid-compat.h>.
	(MATHERR_D): Remove declaration.
	[!_LIBC] (_LIB_VERSION_TYPE): Likewise
	[!LIBM_BUILD] (_LIB_VERSIONIMF): Likewise.
	[LIBM_BUILD] (pmatherrf): Likewise.
	[LIBM_BUILD] (pmatherr): Likewise.
	[LIBM_BUILD] (pmatherrl): Likewise.
	(DOMAIN): Likewise.
	(SING): Likewise.
	(OVERFLOW): Likewise.
	(UNDERFLOW): Likewise.
	(TLOSS): Likewise.
	(PLOSS): Likewise.
	* sysdeps/ia64/fpu/s_matherrf.c: Include <math-svid-compat.h>.
	(__matherrf): Define only if [LIBM_SVID_COMPAT].  Use
	compat_symbol.
	* sysdeps/ia64/fpu/s_matherrl.c: Include <math-svid-compat.h>.
	(__matherrl): Define only if [LIBM_SVID_COMPAT].  Use
	compat_symbol.
	* math/lgamma-compat.h: Include <math-svid-compat.h>.
	* math/w_acos_compat.c: Likewise.
	* math/w_acosf_compat.c: Likewise.
	* math/w_acosh_compat.c: Likewise.
	* math/w_acoshf_compat.c: Likewise.
	* math/w_acoshl_compat.c: Likewise.
	* math/w_acosl_compat.c: Likewise.
	* math/w_asin_compat.c: Likewise.
	* math/w_asinf_compat.c: Likewise.
	* math/w_asinl_compat.c: Likewise.
	* math/w_atan2_compat.c: Likewise.
	* math/w_atan2f_compat.c: Likewise.
	* math/w_atan2l_compat.c: Likewise.
	* math/w_atanh_compat.c: Likewise.
	* math/w_atanhf_compat.c: Likewise.
	* math/w_atanhl_compat.c: Likewise.
	* math/w_cosh_compat.c: Likewise.
	* math/w_coshf_compat.c: Likewise.
	* math/w_coshl_compat.c: Likewise.
	* math/w_exp10_compat.c: Likewise.
	* math/w_exp10f_compat.c: Likewise.
	* math/w_exp10l_compat.c: Likewise.
	* math/w_exp2_compat.c: Likewise.
	* math/w_exp2f_compat.c: Likewise.
	* math/w_exp2l_compat.c: Likewise.
	* math/w_fmod_compat.c: Likewise.
	* math/w_fmodf_compat.c: Likewise.
	* math/w_fmodl_compat.c: Likewise.
	* math/w_hypot_compat.c: Likewise.
	* math/w_hypotf_compat.c: Likewise.
	* math/w_hypotl_compat.c: Likewise.
	* math/w_j0_compat.c: Likewise.
	* math/w_j0f_compat.c: Likewise.
	* math/w_j0l_compat.c: Likewise.
	* math/w_j1_compat.c: Likewise.
	* math/w_j1f_compat.c: Likewise.
	* math/w_j1l_compat.c: Likewise.
	* math/w_jn_compat.c: Likewise.
	* math/w_jnf_compat.c: Likewise.
	* math/w_jnl_compat.c: Likewise.
	* math/w_lgamma_main.c: Likewise.
	* math/w_lgamma_r_compat.c: Likewise.
	* math/w_lgammaf_main.c: Likewise.
	* math/w_lgammaf_r_compat.c: Likewise.
	* math/w_lgammal_main.c: Likewise.
	* math/w_lgammal_r_compat.c: Likewise.
	* math/w_log10_compat.c: Likewise.
	* math/w_log10f_compat.c: Likewise.
	* math/w_log10l_compat.c: Likewise.
	* math/w_log2_compat.c: Likewise.
	* math/w_log2f_compat.c: Likewise.
	* math/w_log2l_compat.c: Likewise.
	* math/w_log_compat.c: Likewise.
	* math/w_logf_compat.c: Likewise.
	* math/w_logl_compat.c: Likewise.
	* math/w_pow_compat.c: Likewise.
	* math/w_powf_compat.c: Likewise.
	* math/w_powl_compat.c: Likewise.
	* math/w_remainder_compat.c: Likewise.
	* math/w_remainderf_compat.c: Likewise.
	* math/w_remainderl_compat.c: Likewise.
	* math/w_scalb_compat.c: Likewise.
	* math/w_scalbf_compat.c: Likewise.
	* math/w_scalbl_compat.c: Likewise.
	* math/w_sinh_compat.c: Likewise.
	* math/w_sinhf_compat.c: Likewise.
	* math/w_sinhl_compat.c: Likewise.
	* math/w_sqrt_compat.c: Likewise.
	* math/w_sqrtf_compat.c: Likewise.
	* math/w_sqrtl_compat.c: Likewise.
	* math/w_tgamma_compat.c: Likewise.
	* math/w_tgammaf_compat.c: Likewise.
	* math/w_tgammal_compat.c: Likewise.
	* sysdeps/ieee754/dbl-64/w_exp_compat.c: Likewise.
	* sysdeps/ieee754/flt-32/w_expf_compat.c: Likewise.
	* sysdeps/ieee754/k_standard.c: Likewise.
	* sysdeps/ieee754/k_standardf.c: Likewise.
	* sysdeps/ieee754/k_standardl.c: Likewise.
	* sysdeps/ieee754/ldbl-128/w_expl_compat.c: Likewise.
	* sysdeps/ieee754/ldbl-128ibm/w_expl_compat.c: Likewise.
	* sysdeps/ieee754/ldbl-96/w_expl_compat.c: Likewise.
	* sysdeps/powerpc/powerpc32/power4/fpu/w_sqrt_compat.S: Likewise.
	* sysdeps/powerpc/powerpc32/power4/fpu/w_sqrtf_compat.S: Likewise.
	* sysdeps/powerpc/powerpc32/power5/fpu/w_sqrt_compat.S: Likewise.
	* sysdeps/powerpc/powerpc32/power5/fpu/w_sqrtf_compat.S: Likewise.
	* sysdeps/sparc/sparc32/fpu/w_sqrt_compat.S: Likewise.
	* sysdeps/sparc/sparc32/fpu/w_sqrtf_compat.S: Likewise.
	* sysdeps/sparc/sparc32/sparcv9/fpu/multiarch/w_sqrt_compat-vis3.S:
	Likewise.
	* sysdeps/sparc/sparc32/sparcv9/fpu/multiarch/w_sqrtf_compat-vis3.S:
	Likewise.
	* sysdeps/sparc/sparc32/sparcv9/fpu/w_sqrt_compat.S: Likewise.
	* sysdeps/sparc/sparc32/sparcv9/fpu/w_sqrtf_compat.S: Likewise.
	* sysdeps/sparc/sparc64/fpu/w_sqrt_compat.S: Likewise.
	* sysdeps/sparc/sparc64/fpu/w_sqrtf_compat.S: Likewise.
2017-08-21 17:45:10 +00:00
Gabriel F. T. Gomes 47a67213a9 Do not use __builtin_types_compatible_p in C++ mode (bug 21930)
The logic to define isinf for float128 depends on the availability of
__builtin_types_compatible_p, which is only available in C mode,
however, the conditionals do not check for C or C++ mode.  This lead to
an error in libstdc++ configure, as reported by bug 21930.

This patch adds a conditional for C mode in the definition of isinf for
float128.  No definition is provided in C++ mode, since libstdc++
headers undefine isinf.

Tested for powerpc64le (glibc test suite and libstdc++-v3 configure).

	[BZ #21930]
	* math/math.h (isinf): Check if in C or C++ mode before using
	__builtin_types_compatible_p, since this is a C mode feature.
2017-08-18 12:18:36 -03:00
Joseph Myers 24ab7723b8 Consistently use uintN_t not u_intN_t in libm.
This patch changes libm code to make consistent use of C99 uintN_t
types instead of sometimes using those and sometimes using the older
nonstandard u_intN_t names.  This makes sense as a cleanup in its own
right, and also facilitates merges to GCC's libquadmath (which gets
the types from stdint.h and so may not have u_intN_t available at
all).

Tested for x86_64, and with build-many-glibcs.py.

	* math/s_nextafter.c (__nextafter): Use uintN_t instead of
	u_intN_t.
	* math/s_nexttowardf.c (__nexttowardf): Likewise.
	* sysdeps/generic/math_private.h (ieee_double_shape_type):
	Likewise.
	(ieee_float_shape_type): Likewise.
	* sysdeps/i386/fpu/s_fpclassifyl.c (__fpclassifyl): Likewise.
	* sysdeps/i386/fpu/s_isnanl.c (__isnanl): Likewise.
	* sysdeps/i386/fpu/s_nextafterl.c (__nextafterl): Likewise.
	* sysdeps/i386/fpu/s_nexttoward.c (__nexttoward): Likewise.
	* sysdeps/i386/fpu/s_nexttowardf.c (__nexttowardf): Likewise.
	* sysdeps/ieee754/dbl-64/e_acosh.c (__ieee754_acosh): Likewise.
	* sysdeps/ieee754/dbl-64/e_cosh.c (__ieee754_cosh): Likewise.
	* sysdeps/ieee754/dbl-64/e_fmod.c (__ieee754_fmod): Likewise.
	* sysdeps/ieee754/dbl-64/e_gamma_r.c (__ieee754_gamma_r):
	Likewise.
	* sysdeps/ieee754/dbl-64/e_hypot.c (__ieee754_hypot): Likewise.
	* sysdeps/ieee754/dbl-64/e_jn.c (__ieee754_jn): Likewise.
	(__ieee754_yn): Likewise.
	* sysdeps/ieee754/dbl-64/e_log10.c (__ieee754_log10): Likewise.
	* sysdeps/ieee754/dbl-64/e_log2.c (__ieee754_log2): Likewise.
	* sysdeps/ieee754/dbl-64/e_rem_pio2.c (__ieee754_rem_pio2):
	Likewise.
	* sysdeps/ieee754/dbl-64/e_sinh.c (__ieee754_sinh): Likewise.
	* sysdeps/ieee754/dbl-64/s_ceil.c (__ceil): Likewise.
	* sysdeps/ieee754/dbl-64/s_copysign.c (__copysign): Likewise.
	* sysdeps/ieee754/dbl-64/s_erf.c (__erf): Likewise.
	(__erfc): Likewise.
	* sysdeps/ieee754/dbl-64/s_expm1.c (__expm1): Likewise.
	* sysdeps/ieee754/dbl-64/s_finite.c (FINITE): Likewise.
	* sysdeps/ieee754/dbl-64/s_floor.c (__floor): Likewise.
	* sysdeps/ieee754/dbl-64/s_fpclassify.c (__fpclassify): Likewise.
	* sysdeps/ieee754/dbl-64/s_isnan.c (__isnan): Likewise.
	* sysdeps/ieee754/dbl-64/s_issignaling.c (__issignaling):
	Likewise.
	* sysdeps/ieee754/dbl-64/s_llrint.c (__llrint): Likewise.
	* sysdeps/ieee754/dbl-64/s_llround.c (__llround): Likewise.
	* sysdeps/ieee754/dbl-64/s_lrint.c (__lrint): Likewise.
	* sysdeps/ieee754/dbl-64/s_lround.c (__lround): Likewise.
	* sysdeps/ieee754/dbl-64/s_modf.c (__modf): Likewise.
	* sysdeps/ieee754/dbl-64/s_nextup.c (__nextup): Likewise.
	* sysdeps/ieee754/dbl-64/s_remquo.c (__remquo): Likewise.
	* sysdeps/ieee754/dbl-64/s_round.c (__round): Likewise.
	* sysdeps/ieee754/dbl-64/s_trunc.c (__trunc): Likewise.
	* sysdeps/ieee754/dbl-64/wordsize-64/s_issignaling.c
	(__issignaling): Likewise.
	* sysdeps/ieee754/flt-32/e_atan2f.c (__ieee754_atan2f): Likewise.
	* sysdeps/ieee754/flt-32/e_fmodf.c (__ieee754_fmodf): Likewise.
	* sysdeps/ieee754/flt-32/e_gammaf_r.c (__ieee754_gammaf_r):
	Likewise.
	* sysdeps/ieee754/flt-32/e_jnf.c (__ieee754_ynf): Likewise.
	* sysdeps/ieee754/flt-32/e_log10f.c (__ieee754_log10f): Likewise.
	* sysdeps/ieee754/flt-32/e_powf.c (__ieee754_powf): Likewise.
	* sysdeps/ieee754/flt-32/e_rem_pio2f.c (__ieee754_rem_pio2f):
	Likewise.
	* sysdeps/ieee754/flt-32/e_remainderf.c (__ieee754_remainderf):
	Likewise.
	* sysdeps/ieee754/flt-32/e_sqrtf.c (__ieee754_sqrtf): Likewise.
	* sysdeps/ieee754/flt-32/s_ceilf.c (__ceilf): Likewise.
	* sysdeps/ieee754/flt-32/s_copysignf.c (__copysignf): Likewise.
	* sysdeps/ieee754/flt-32/s_erff.c (__erff): Likewise.
	(__erfcf): Likewise.
	* sysdeps/ieee754/flt-32/s_expm1f.c (__expm1f): Likewise.
	* sysdeps/ieee754/flt-32/s_finitef.c (FINITEF): Likewise.
	* sysdeps/ieee754/flt-32/s_floorf.c (__floorf): Likewise.
	* sysdeps/ieee754/flt-32/s_fpclassifyf.c (__fpclassifyf):
	Likewise.
	* sysdeps/ieee754/flt-32/s_isnanf.c (__isnanf): Likewise.
	* sysdeps/ieee754/flt-32/s_issignalingf.c (__issignalingf):
	Likewise.
	* sysdeps/ieee754/flt-32/s_llrintf.c (__llrintf): Likewise.
	* sysdeps/ieee754/flt-32/s_llroundf.c (__llroundf): Likewise.
	* sysdeps/ieee754/flt-32/s_lrintf.c (__lrintf): Likewise.
	* sysdeps/ieee754/flt-32/s_lroundf.c (__lroundf): Likewise.
	* sysdeps/ieee754/flt-32/s_modff.c (__modff): Likewise.
	* sysdeps/ieee754/flt-32/s_remquof.c (__remquof): Likewise.
	* sysdeps/ieee754/flt-32/s_roundf.c (__roundf): Likewise.
	* sysdeps/ieee754/ldbl-128/e_acoshl.c (__ieee754_acoshl):
	Likewise.
	* sysdeps/ieee754/ldbl-128/e_atan2l.c (__ieee754_atan2l):
	Likewise.
	* sysdeps/ieee754/ldbl-128/e_atanhl.c (__ieee754_atanhl):
	Likewise.
	* sysdeps/ieee754/ldbl-128/e_fmodl.c (__ieee754_fmodl): Likewise.
	* sysdeps/ieee754/ldbl-128/e_gammal_r.c (__ieee754_gammal_r):
	Likewise.
	* sysdeps/ieee754/ldbl-128/e_hypotl.c (__ieee754_hypotl):
	Likewise.
	* sysdeps/ieee754/ldbl-128/e_jnl.c (__ieee754_jnl): Likewise.
	(__ieee754_ynl): Likewise.
	* sysdeps/ieee754/ldbl-128/e_powl.c (__ieee754_powl): Likewise.
	* sysdeps/ieee754/ldbl-128/e_rem_pio2l.c (__ieee754_rem_pio2l):
	Likewise.
	* sysdeps/ieee754/ldbl-128/e_remainderl.c (__ieee754_remainderl):
	Likewise.
	* sysdeps/ieee754/ldbl-128/e_sinhl.c (__ieee754_sinhl): Likewise.
	* sysdeps/ieee754/ldbl-128/k_cosl.c (__kernel_cosl): Likewise.
	* sysdeps/ieee754/ldbl-128/k_sincosl.c (__kernel_sincosl):
	Likewise.
	* sysdeps/ieee754/ldbl-128/k_sinl.c (__kernel_sinl): Likewise.
	* sysdeps/ieee754/ldbl-128/s_ceill.c (__ceill): Likewise.
	* sysdeps/ieee754/ldbl-128/s_copysignl.c (__copysignl): Likewise.
	* sysdeps/ieee754/ldbl-128/s_erfl.c (__erfcl): Likewise.
	* sysdeps/ieee754/ldbl-128/s_fabsl.c (__fabsl): Likewise.
	* sysdeps/ieee754/ldbl-128/s_finitel.c (__finitel): Likewise.
	* sysdeps/ieee754/ldbl-128/s_floorl.c (__floorl): Likewise.
	* sysdeps/ieee754/ldbl-128/s_fpclassifyl.c (__fpclassifyl):
	Likewise.
	* sysdeps/ieee754/ldbl-128/s_frexpl.c (__frexpl): Likewise.
	* sysdeps/ieee754/ldbl-128/s_isnanl.c (__isnanl): Likewise.
	* sysdeps/ieee754/ldbl-128/s_issignalingl.c (__issignalingl):
	Likewise.
	* sysdeps/ieee754/ldbl-128/s_llrintl.c (__llrintl): Likewise.
	* sysdeps/ieee754/ldbl-128/s_llroundl.c (__llroundl): Likewise.
	* sysdeps/ieee754/ldbl-128/s_lrintl.c (__lrintl): Likewise.
	* sysdeps/ieee754/ldbl-128/s_lroundl.c (__lroundl): Likewise.
	* sysdeps/ieee754/ldbl-128/s_modfl.c (__modfl): Likewise.
	* sysdeps/ieee754/ldbl-128/s_nearbyintl.c (__nearbyintl):
	Likewise.
	* sysdeps/ieee754/ldbl-128/s_nextafterl.c (__nextafterl):
	Likewise.
	* sysdeps/ieee754/ldbl-128/s_nexttoward.c (__nexttoward):
	Likewise.
	* sysdeps/ieee754/ldbl-128/s_nexttowardf.c (__nexttowardf):
	Likewise.
	* sysdeps/ieee754/ldbl-128/s_nextupl.c (__nextupl): Likewise.
	* sysdeps/ieee754/ldbl-128/s_remquol.c (__remquol): Likewise.
	* sysdeps/ieee754/ldbl-128/s_rintl.c (__rintl): Likewise.
	* sysdeps/ieee754/ldbl-128/s_roundl.c (__roundl): Likewise.
	* sysdeps/ieee754/ldbl-128/s_tanhl.c (__tanhl): Likewise.
	* sysdeps/ieee754/ldbl-128/s_truncl.c (__truncl): Likewise.
	* sysdeps/ieee754/ldbl-128ibm/e_fmodl.c (__ieee754_fmodl):
	Likewise.
	* sysdeps/ieee754/ldbl-128ibm/e_gammal_r.c (__ieee754_gammal_r):
	Likewise.
	* sysdeps/ieee754/ldbl-128ibm/e_powl.c (__ieee754_powl): Likewise.
	* sysdeps/ieee754/ldbl-128ibm/e_rem_pio2l.c (__ieee754_rem_pio2l):
	Likewise.
	* sysdeps/ieee754/ldbl-128ibm/e_remainderl.c
	(__ieee754_remainderl): Likewise.
	* sysdeps/ieee754/ldbl-128ibm/k_cosl.c (__kernel_cosl): Likewise.
	* sysdeps/ieee754/ldbl-128ibm/k_sinl.c (__kernel_sinl): Likewise.
	* sysdeps/ieee754/ldbl-128ibm/s_fabsl.c (__fabsl): Likewise.
	* sysdeps/ieee754/ldbl-128ibm/s_fpclassifyl.c (___fpclassifyl):
	Likewise.
	* sysdeps/ieee754/ldbl-128ibm/s_modfl.c (__modfl): Likewise.
	* sysdeps/ieee754/ldbl-128ibm/s_nexttowardf.c (__nexttowardf):
	Likewise.
	* sysdeps/ieee754/ldbl-128ibm/s_remquol.c (__remquol): Likewise.
	* sysdeps/ieee754/ldbl-96/e_acoshl.c (__ieee754_acoshl): Likewise.
	* sysdeps/ieee754/ldbl-96/e_asinl.c (__ieee754_asinl): Likewise.
	* sysdeps/ieee754/ldbl-96/e_atanhl.c (__ieee754_atanhl): Likewise.
	* sysdeps/ieee754/ldbl-96/e_coshl.c (__ieee754_coshl): Likewise.
	* sysdeps/ieee754/ldbl-96/e_gammal_r.c (__ieee754_gammal_r):
	Likewise.
	* sysdeps/ieee754/ldbl-96/e_hypotl.c (__ieee754_hypotl): Likewise.
	* sysdeps/ieee754/ldbl-96/e_j0l.c (__ieee754_j0l): Likewise.
	(__ieee754_y0l): Likewise.
	(pzero): Likewise.
	(qzero): Likewise.
	* sysdeps/ieee754/ldbl-96/e_j1l.c (__ieee754_j1l): Likewise.
	(__ieee754_y1l): Likewise.
	(pone): Likewise.
	(qone): Likewise.
	* sysdeps/ieee754/ldbl-96/e_jnl.c (__ieee754_jnl): Likewise.
	(__ieee754_ynl): Likewise.
	* sysdeps/ieee754/ldbl-96/e_lgammal_r.c (sin_pi): Likewise.
	(__ieee754_lgammal_r): Likewise.
	* sysdeps/ieee754/ldbl-96/e_rem_pio2l.c (__ieee754_rem_pio2l):
	Likewise.
	* sysdeps/ieee754/ldbl-96/e_sinhl.c (__ieee754_sinhl): Likewise.
	* sysdeps/ieee754/ldbl-96/s_copysignl.c (__copysignl): Likewise.
	* sysdeps/ieee754/ldbl-96/s_erfl.c (__erfl): Likewise.
	(__erfcl): Likewise.
	* sysdeps/ieee754/ldbl-96/s_frexpl.c (__frexpl): Likewise.
	* sysdeps/ieee754/ldbl-96/s_issignalingl.c (__issignalingl):
	Likewise.
	* sysdeps/ieee754/ldbl-96/s_llrintl.c (__llrintl): Likewise.
	* sysdeps/ieee754/ldbl-96/s_llroundl.c (__llroundl): Likewise.
	* sysdeps/ieee754/ldbl-96/s_lrintl.c (__lrintl): Likewise.
	* sysdeps/ieee754/ldbl-96/s_lroundl.c (__lroundl): Likewise.
	* sysdeps/ieee754/ldbl-96/s_modfl.c (__modfl): Likewise.
	* sysdeps/ieee754/ldbl-96/s_nexttoward.c (__nexttoward): Likewise.
	* sysdeps/ieee754/ldbl-96/s_nexttowardf.c (__nexttowardf):
	Likewise.
	* sysdeps/ieee754/ldbl-96/s_nextupl.c (__nextupl): Likewise.
	* sysdeps/ieee754/ldbl-96/s_remquol.c (__remquol): Likewise.
	* sysdeps/ieee754/ldbl-96/s_roundl.c (__roundl): Likewise.
	* sysdeps/ieee754/ldbl-96/s_tanhl.c (__tanhl): Likewise.
	* sysdeps/ieee754/ldbl-opt/s_nexttowardfd.c (__nldbl_nexttowardf):
	Likewise.
	* sysdeps/m68k/m680x0/fpu/e_pow.c (s(__ieee754_pow)): Likewise.
	* sysdeps/m68k/m680x0/fpu/s_fpclassifyl.c (__fpclassifyl):
	Likewise.
	* sysdeps/m68k/m680x0/fpu/s_llrint.c (__llrint): Likewise.
	* sysdeps/m68k/m680x0/fpu/s_llrintf.c (__llrintf): Likewise.
	* sysdeps/m68k/m680x0/fpu/s_llrintl.c (__llrintl): Likewise.
	* sysdeps/m68k/m680x0/fpu/s_nextafterl.c (__nextafterl): Likewise.
	* sysdeps/x86/fpu/powl_helper.c (__powl_helper): Likewise.
2017-08-03 19:55:04 +00:00
Joseph Myers 42df8d5921 Fix tgmath.h for __int128 (bug 21686).
When a tgmath.h macro is passed a double argument and an argument of
type __int128, it generates a call to a long double function (although
the result still gets converted to type double).  __int128 is similar
enough to integer types that it should be handled consistently like
them, so always like double for these macros rather than sometimes
like double and sometimes like long double.  This patch fixes the
logic accordingly and makes gen-tgmath-tests.py generate tests for
__int128.

Tested for x86_64 and x86.

	[BZ #21686]
	* math/tgmath.h (__TGMATH_BINARY_REAL_ONLY): Add arguments before
	comparing size with that of double.
	(__TGMATH_BINARY_REAL_STD_ONLY): Likewise.
	(__TGMATH_BINARY_REAL_RET_ONLY): Likewise.
	(__TGMATH_TERNARY_FIRST_SECOND_REAL_ONLY): Likewise.
	(__TGMATH_TERNARY_REAL_ONLY): Likewise.
	(__TGMATH_BINARY_REAL_IMAG): Likewise.
	* math/gen-tgmath-tests.py (Type.init_types): Create __int128 and
	unsigned __int128 types.
2017-08-02 20:16:05 +00:00
Joseph Myers 2fee621de0 Fix tgmath.h for bit-fields (bug 21685).
The tgmath.h macros produce errors for bit-field arguments, because
they apply sizeof and typeof to the arguments.  This patch fixes them
to use unary + systematically before using sizeof or typeof on
arguments that might be bit-fields (note that __real__ of a bit-field
is still a bit-field for this purpose, since it's an lvalue).
gen-tgmath-tests.py is extended to add tests for this case.

Tested for x86_64.

	[BZ #21685]
	* math/tgmath.h (__tgmath_real_type): Use unary + on potentially
	bit-field expressions passed to sizeof or typeof.
	[__HAVE_FLOAT128 && __GLIBC_USE (IEC_60559_TYPES_EXT)]
	(__TGMATH_F128): Likewise.
	[__HAVE_FLOAT128 && __GLIBC_USE (IEC_60559_TYPES_EXT)]
	(__TGMATH_CF128): Likewise.
	(__TGMATH_UNARY_REAL_ONLY): Likewise.
	(__TGMATH_UNARY_REAL_RET_ONLY): Likewise.
	(__TGMATH_BINARY_FIRST_REAL_ONLY): Likewise.
	(__TGMATH_BINARY_FIRST_REAL_STD_ONLY): Likewise.
	(__TGMATH_BINARY_REAL_ONLY): Likewise.
	(__TGMATH_BINARY_REAL_STD_ONLY): Likewise.
	(__TGMATH_BINARY_REAL_RET_ONLY): Likewise.
	(__TGMATH_TERNARY_FIRST_SECOND_REAL_ONLY): Likewise.
	(__TGMATH_TERNARY_REAL_ONLY): Likewise.
	(__TGMATH_TERNARY_FIRST_REAL_RET_ONLY): Likewise.
	(__TGMATH_UNARY_REAL_IMAG): Likewise.
	(__TGMATH_UNARY_IMAG): Likewise.
	(__TGMATH_UNARY_REAL_IMAG_RET_REAL): Likewise.
	(__TGMATH_BINARY_REAL_IMAG): Likewise.
	* math/gen-tgmath-tests.py (Type.init_types): Create bit_field
	type.
	(define_vars_for_type): Handle bit_field type specially.
	(Tests.__init__): Declare structure with bit-field element.
2017-08-02 16:09:01 +00:00
Joseph Myers fa562680ce Fix gen-tgmath-tests.py output for GCC 7 <float.h>.
* math/gen-tgmath-tests.py (Tests.__init__): Define
	__STDC_WANT_IEC_60559_TYPES_EXT__ at start of generated file.
2017-06-28 19:42:14 +00:00
Joseph Myers 614d15f932 Support _Float128 in tgmath.h.
This patch adds tgmath.h support for _Float128, so eliminating the
awkward caveat in NEWS about the type not being supported there.  This
does inevitably increase the size of macro expansions (which grows
particularly fast when you have nested calls to tgmath.h macros), but
only when _Float128 is supported and the declarations of _Float128
interfaces are visible; otherwise the expansions are unchanged.

Tested for x86_64 and arm.

	* math/tgmath.h: Include <bits/libc-header-start.h> and
	<bits/floatn.h>.
	(__TGMATH_F128): New macro.
	(__TGMATH_CF128): Likewise.
	(__TGMATH_UNARY_REAL_ONLY): Use __TGMATH_F128.
	(__TGMATH_UNARY_REAL_RET_ONLY): Likewise.
	(__TGMATH_BINARY_FIRST_REAL_ONLY): Likewise.
	(__TGMATH_BINARY_FIRST_REAL_STD_ONLY): New macro.
	(__TGMATH_BINARY_REAL_ONLY): Use __TGMATH_F128.
	(__TGMATH_BINARY_REAL_STD_ONLY): New macro.
	(__TGMATH_BINARY_REAL_RET_ONLY): Use __TGMATH_F128.
	(__TGMATH_TERNARY_FIRST_SECOND_REAL_ONLY): Likewise.
	(__TGMATH_TERNARY_REAL_ONLY): Likewise.
	(__TGMATH_TERNARY_FIRST_REAL_RET_ONLY): Likewise.
	(__TGMATH_UNARY_REAL_IMAG): Use __TGMATH_CF128.
	(__TGMATH_UNARY_IMAG): Use __TGMATH_F128.
	(__TGMATH_UNARY_REAL_IMAG_RET_REAL): Use __TGMATH_CF128.
	(__TGMATH_BINARY_REAL_IMAG): Likewise.
	(nexttoward): Use __TGMATH_BINARY_FIRST_REAL_STD_ONLY.
	[__USE_MISC] (scalb): Use __TGMATH_BINARY_REAL_STD_ONLY.
	* math/gen-tgmath-tests.py (Type.init_types): Enable _FloatN and
	_FloatNx types if the corresponding HUGE_VAL macros are defined.
2017-06-28 17:53:46 +00:00
Joseph Myers 0908a38adc Use clog10 not __clog10 in tgmath.h log10 macro.
As a GNU extension, for _GNU_SOURCE glibc's complex.h provides a
clog10 function and tgmath.h supports complex arguments to the log10
macro.  However, tgmath.h uses __clog10 not clog10 in defining the
macro.

There is no namespace reason (ignoring the block-scope namespace
issues that would apply equally to *every* function called by tgmath.h
macros) for using __clog10 here, since this is only for _GNU_SOURCE so
clog10 is always visible when this macro definition is used.
Furthermore, __clog10f128 is not exported, so supporting _Float128 in
tgmath.h implies using clog10 not __clog10 there.  (__clog10 and
clog10 aren't used in libstdc++ either, although that library would
have a good case for using the __clog10 reserved-namespace export: the
standard C++ library includes log10 of a complex number.)  This patch
duly changes the header to use clog10, and enables tests of the macro
for complex arguments.

Tested for x86_64.

	* math/tgmath.h [__USE_GNU] (log10): Use clog10 not __clog10.
	* math/gen-tgmath-tests.py (Tests.add_all_tests): Test log10 for
	complex arguments.
2017-06-28 16:43:50 +00:00
Joseph Myers d12a22c5d3 Fix tgmath.h totalorder, totalordermag return type (bug 21687).
The tgmath.h totalorder and totalordermag macros wrongly return a
floating-point type.  They should return int, like the underlying
functions.  This patch fixes them accordingly, updating tests
including enabling tests of those functions from gen-tgmath-tests.py.

Tested for x86_64.

	[BZ #21687]
	* math/tgmath.h (__TGMATH_BINARY_REAL_RET_ONLY): New macro.
	(totalorder): Use it.
	(totalordermag): Likewise.
	* math/gen-tgmath-tests.py (Tests.add_all_tests): Enable tests of
	totalorder and totalordermag.
	* math/test-tgmath.c (F(compile_test)): Do not call totalorder or
	totalordermag in arguments of calls to those functions.
	(NCALLS): Change to 134.
2017-06-28 16:31:10 +00:00
Joseph Myers cfa4434523 Simplify tgmath.h for integer return types.
The tgmath.h macros for function with integer return types generate
unnecessary casts to the return type.  Since in those cases the return
type does not depend on the argument type, all the cases in the
conditional expressions already have the right type, and no casts are
needed; this patch removes them.

Tested for x86_64.

	* math/tgmath.h (__TGMATH_UNARY_REAL_RET_ONLY): Do not take or
	cast to return type argument.
	(__TGMATH_TERNARY_FIRST_REAL_RET_ONLY): Likewise.
	(lrint): Update call to __TGMATH_UNARY_REAL_RET_ONLY.
	(llrint): Likewise.
	(lround): Likewise.
	(llround): Likewise.
	(ilogb): Likewise.
	(llogb): Likewise.
	(fromfp): Update call to __TGMATH_TERNARY_FIRST_REAL_RET_ONLY.
	(ufromfp): Likewise.
	(fromfpx): Likewise.
	(ufromfpx): Likewise.
2017-06-28 16:19:47 +00:00
Joseph Myers 51737193a9 Remove NO_LONG_DOUBLE conditionals in libm tests (bug 21607).
As noted in bug 21607, NO_LONG_DOUBLE conditionals in libm tests are
no longer effective.  For most this is harmless - they were only
present because of long double functions not being declared with _LIBC
defined, and _LIBC is no longer defined for building most tests.  For
the few where this is actually relevant to the test, testing
LDBL_MANT_DIG > DBL_MANT_DIG is more appropriate as that limits the
test to public APIs.  This patch fixes the tests accordingly.

Tested for x86_64 and arm.

	[BZ #21607]
	* math/basic-test.c [!NO_LONG_DOUBLE]: Change conditionals to
	[LDBL_MANT_DIG > DBL_MANT_DIG].
	* math/bug-nextafter.c [!NO_LONG_DOUBLE]: Remove conditionals.
	* math/bug-nexttoward.c [!NO_LONG_DOUBLE]: Likewise.
	* math/test-math-isinff.cc [!NO_LONG_DOUBLE]: Likewise.
	* math/test-math-iszero.cc [!NO_LONG_DOUBLE]: Likewise.
	* math/test-nan-overflow.c [!NO_LONG_DOUBLE]: Likewise.
	* math/test-nan-payload.c [!NO_LONG_DOUBLE]: Likewise.
	* math/test-nearbyint-except-2.c [!NO_LONG_DOUBLE]: Likewise.
	* math/test-nearbyint-except.c [!NO_LONG_DOUBLE]: Likewise.
	* math/test-powl.c [!NO_LONG_DOUBLE]: Likewise.
	* math/test-signgam-finite-c99.c [!NO_LONG_DOUBLE]: Likewise.
	* math/test-signgam-finite.c [!NO_LONG_DOUBLE]: Likewise.
	* math/test-signgam-main.c [!NO_LONG_DOUBLE]: Likewise.
	* math/test-snan.c [!NO_LONG_DOUBLE]: Likewise.
	* math/test-tgmath-ret.c [!NO_LONG_DOUBLE]: Likewise.
	* math/test-tgmath.c: Include <float.h>.
	[!NO_LONG_DOUBLE]: Change conditionals to [LDBL_MANT_DIG >
	DBL_MANT_DIG].
	* math/test-tgmath2.c: Include <float.h>.
	[!NO_LONG_DOUBLE]: Change conditionals to [LDBL_MANT_DIG >
	DBL_MANT_DIG].
2017-06-28 16:01:20 +00:00
Joseph Myers 2dd0aec531 Add more thorough generated tgmath.h test.
This patch adds a more thorough test of tgmath.h macros, verifying
both the return type and the function called for all the cases of
valid argument types.  (Cases with current problems - I've just filed
four bugs - are disabled or omitted pending fixing those problems.)
The test uses a Python generator (works with both Python 2 and 3) to
generate a C file which is then built and run as a test in the usual
way (and that C file includes its own dummy definitions of libm
functions similar to existing tgmath.h tests).  The motivation is to
make it easier to add tests of tgmath.h for _Float128 when adding
tgmath.h support for that type; the _FloatN / _FloatNx support is
present in the script, but disabled until the tgmath.h support is
written.

Tested for x86_64, and for arm to check things in the long double =
double case.  (In that case, it's OK to call either double or long
double functions when the selected type is double or long double, as
long as the return type of the macro is exactly correct.)

	* math/gen-tgmath-tests.py: New file.
	* math/Makefile [PYTHON] (tests): Add test-tgmath3.
	[PYTHON] (generated): Add test-tgmath3.c.
	[PYTHON] (CFLAGS-test-tgmath3.c): New variable.
	[PYTHON] ($(objpfx)test-tgmath3.c): New rule.
2017-06-28 14:20:21 +00:00
Joseph Myers 034e738021 Add float128 support for ia64.
This patch enables float128 support for ia64, so that all the
configurations where GCC supports _Float128 / __float128 as an
ABI-distinct type now have glibc support as well.  bits/floatn.h
declares the support to be available for GCC 4.4 and later, which is
when the libgcc support was added.  The removal of
sysdeps/ia64/fpu/k_rem_pio2.c is because the generic k_rem_pio2.c
defines a function required by the float128 code.

Tested (compilation only) with build-many-glibcs.py for ia64 (GCC 6
and GCC 7).

Given how long it is since libm-test-ulps has been updated for ia64, I
think truncating the file and regenerating it from scratch would be a
good idea when doing a regeneration to add float128 ulps.  I expect
various ia64 libm issues (at least some already filed in Bugzilla) to
result in test failures even after ulps regeneration, but hopefully
the float128 code will pass tests as it's the same as used on other
architectures.

	* sysdeps/ia64/Implies: Add ieee754/float128.
	* sysdeps/ia64/bits/floatn.h: New file.
	* sysdeps/ia64/float128-abi.h: Likewise.
	* manual/math.texi (Mathematics): Document support for _Float128
	on ia64.
	* sysdeps/ia64/Makefile [$(subdir) = math] (CPPFLAGS): Append to
	Makefile variable.
	* sysdeps/ia64/fpu/e_sqrtf128.c: New file.
	* sysdeps/ia64/fpu/k_rem_pio2.c: Remove file.
	* sysdeps/ia64/fpu/sfp-machine.h: New file.  Based on libgcc.
	* sysdeps/ia64/math-tests.h: New file.
	* math/libm-test-support.h (XFAIL_FLOAT128_PAYLOAD): Also define
	based on TEST_COND_binary128 for [__ia64__].
	* sysdeps/unix/sysv/linux/ia64/libc.abilist: Update.
	* sysdeps/unix/sysv/linux/ia64/libm.abilist: Likewise,
2017-06-26 22:50:45 +00:00