Commit Graph

953 Commits

Author SHA1 Message Date
Zack Weinberg 9964a14579 Mechanically remove _IO_ name aliases for types and constants.
This patch mechanically removes all remaining uses, and the
definitions, of the following libio name aliases:

 name                         replaced with
 ----                         -------------
 _IO_FILE                     FILE
 _IO_fpos_t                   __fpos_t
 _IO_fpos64_t                 __fpos64_t
 _IO_size_t                   size_t
 _IO_ssize_t                  ssize_t or __ssize_t
 _IO_off_t                    off_t
 _IO_off64_t                  off64_t
 _IO_pid_t                    pid_t
 _IO_uid_t                    uid_t
 _IO_wint_t                   wint_t
 _IO_va_list                  va_list or __gnuc_va_list
 _IO_BUFSIZ                   BUFSIZ
 _IO_cookie_io_functions_t    cookie_io_functions_t
 __io_read_fn                 cookie_read_function_t
 __io_write_fn                cookie_write_function_t
 __io_seek_fn                 cookie_seek_function_t
 __io_close_fn                cookie_close_function_t

I used __fpos_t and __fpos64_t instead of fpos_t and fpos64_t because
the definitions of fpos_t and fpos64_t depend on the largefile mode.
I used __ssize_t and __gnuc_va_list in a handful of headers where
namespace cleanliness might be relevant even though they're
internal-use-only.  In all other cases, I used the public-namespace
name.

There are a tiny handful of places where I left a use of 'struct _IO_FILE'
alone, because it was being used together with 'struct _IO_FILE_plus'
or 'struct _IO_FILE_complete' in the same arithmetic expression.

Because this patch was almost entirely done with search and replace, I
may have introduced indentation botches.  I did proofread the diff,
but I may have missed something.

The ChangeLog below calls out all of the places where this was not a
pure search-and-replace change.

Installed stripped libraries and executables are unchanged by this patch,
except that some assertions in vfscanf.c change line numbers.

	* libio/libio.h (_IO_FILE): Delete; all uses changed to FILE.
	(_IO_fpos_t): Delete; all uses changed to __fpos_t.
	(_IO_fpos64_t): Delete; all uses changed to __fpos64_t.
	(_IO_size_t): Delete; all uses changed to size_t.
	(_IO_ssize_t): Delete; all uses changed to ssize_t or __ssize_t.
	(_IO_off_t): Delete; all uses changed to off_t.
	(_IO_off64_t): Delete; all uses changed to off64_t.
	(_IO_pid_t): Delete; all uses changed to pid_t.
	(_IO_uid_t): Delete; all uses changed to uid_t.
	(_IO_wint_t): Delete; all uses changed to wint_t.
	(_IO_va_list): Delete; all uses changed to va_list or __gnuc_va_list.
	(_IO_BUFSIZ): Delete; all uses changed to BUFSIZ.
	(_IO_cookie_io_functions_t): Delete; all uses changed to
	cookie_io_functions_t.
	(__io_read_fn): Delete; all uses changed to cookie_read_function_t.
	(__io_write_fn): Delete; all uses changed to cookie_write_function_t.
	(__io_seek_fn): Delete; all uses changed to cookie_seek_function_t.
	(__io_close_fn): Delete: all uses changed to cookie_close_function_t.

	* libio/iofopncook.c: Remove unnecessary forward declarations.
	* libio/iolibio.h: Correct outdated commentary.
	* malloc/malloc.c (__malloc_stats): Remove unnecessary casts.
	* stdio-common/fxprintf.c (__fxprintf_nocancel):
	Remove unnecessary casts.
	* stdio-common/getline.c: Use _IO_getdelim directly.
	Don't redefine ssize_t.
	* stdio-common/printf_fp.c, stdio_common/printf_fphex.c
	* stdio-common/printf_size.c: Don't redefine size_t or FILE.
	Remove outdated comments.
	* stdio-common/vfscanf.c: Don't redefine va_list.
2018-02-21 14:11:05 -05:00
Wilco Dijkstra 610ee1fc93 Remove mplog and mpexp
Remove the now unused mplog and mpexp files.

	* math/Makefile: Remove mpexp.c and mplog.c
	* sysdeps/i386/fpu/mpexp.c: Delete file.
	* sysdeps/i386/fpu/mplog.c: Likewise.
	* sysdeps/ia64/fpu/mpexp.c: Likewise.
	* sysdeps/ia64/fpu/mplog.c: Likewise.
	* sysdeps/ieee754/dbl-64/e_exp.c: Remove mention of mpexp and mplog.
	* sysdeps/ieee754/dbl-64/mpa.h (__pow_mp): Remove unused function.
	* sysdeps/ieee754/dbl-64/mpexp.c: Delete file.
	* sysdeps/ieee754/dbl-64/mplog.c: Likewise.
	* sysdeps/m68k/m680x0/fpu/mpexp.c: Likewise.
	* sysdeps/m68k/m680x0/fpu/mplog.c: Likewise.
	* sysdeps/x86_64/fpu/multiarch/Makefile: Remove mpexp* and mplog*.
	* sysdeps/x86_64/fpu/multiarch/e_log-avx.c: Remove unused defines.
	* sysdeps/x86_64/fpu/multiarch/e_log-fma.c: Likewise.
	* sysdeps/x86_64/fpu/multiarch/e_log-fma4.c: Likewise.
	* sysdeps/x86_64/fpu/multiarch/mpexp-avx.c: Delete file.
	* sysdeps/x86_64/fpu/multiarch/mpexp-fma.c: Likewise.
	* sysdeps/x86_64/fpu/multiarch/mpexp-fma4.c: Likewise.
	* sysdeps/x86_64/fpu/multiarch/mplog-avx.c: Likewise.
	* sysdeps/x86_64/fpu/multiarch/mplog-fma.c: Likewise.
	* sysdeps/x86_64/fpu/multiarch/mplog-fma4.c: Likewise.
2018-02-15 12:41:05 +00:00
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 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
Zack Weinberg 63fb8f9aa9 Post-cleanup 2: minimize _G_config.h.
Nearly everything in _G_config.h is either junk or more appropriately
defined elsewhere:

 * _G_fpos_t, _G_fpos64_t, and _G_BUFSIZ are already completely unused.
 * All remaining uses of _G_va_list have been changed to __gnuc_va_list.
 * The definition of _G_HAVE_ST_BLKSIZE/_IO_HAVE_ST_BLKSIZE has
   been inlined into its sole use.
 * The complete definition of _G_iconv_t has been moved to libio.h and
   renamed _IO_iconv_t (all actual users used that name).
 * _G_IO_IO_FILE_VERSION is vestigial; some code cares whether
   _IO_stdin_used exists, but nothing looks at its value.  I've
   preserved the value as a hardwired constant in csu/init.c.
   This means csu/init.c no longer needs to include anything.
 * Many of the headers included by _G_config.h were already being
   included directly by either either libio.h or stdio.h; the
   remaining ones were moved to libio.h.
 * _G_HAVE_MREMAP is still relevant, because mremap genuinely is a
   Linux extension; it's not in POSIX and as far as I can tell it's
   not available on the Hurd either.  I also preserved _G_HAVE_MMAP,
   since it's conceivable someone would want to port glibc to a
   MMU-less, mmap-less environment in the future.  Both are now always
   defined to 1/0 as is the current convention, instead of the older
   1/undef convention.  These are the only symbols still defined in
   _G_config.h.
 * The actual inclusion of _G_config.h moves from libio.h to libioP.h,
   as this is where a potential override of _G_HAVE_MMAP happens.
 * The #ifdef logic in libioP.h controlling _IO_JUMPS_OFFSET has been
   simplified.

After this patch, the only surviving _G_ symbols are the struct tag
names _G_fpos_t and _G_fpos64_t, which are preserved for the sake of
C++ mangled names in applications, and _G_HAVE_MMAP and _G_HAVE_MREMAP,
which do not seem worth renaming.

Installed stripped libraries are unchanged by this patch.

	* bits/_G_config.h: Move back to sysdeps/generic/_G_config.h.
	Delete all contents except for definitions of _G_HAVE_MMAP and
	_G_HAVE_MREMAP.  Add commentary explaining those two symbols.
	* sysdeps/unix/sysv/linux/bits/_G_config.h: Move back to
	sysdeps/unix/sysv/linux/_G_config.h.  Make same content
	change as above.

	* libio/libio.h: Don't include bits/_G_config.h here.
	Include stddef.h with __need_wchar_t defined.  Include
	bits/types/__mbstate_t.h, bits/types/wint_t.h, and gconv.h.
	Define _IO_iconv_t here, directly.
	Don't define _IO_HAVE_ST_BLKSIZE.
	* libio/libioP.h: Include _G_config.h here.  Move include of
	shlib-compat.h up with rest of includes.  Simplify conditionals
	controlling definition of _IO_JUMPS_OFFSET.

	* csu/init.c: Remove always-true #if around entire file.
	Don't include stdio.h.  Set _IO_stdin_used to hardwired
	constant 0x20001, and update commentary.
	* include/stdio.h, sysdeps/ieee754/ldbl-opt/nldbl-compat.h:
	Replace all uses of _G_va_list with __gnuc_va_list.
	* libio/filedoalloc.c: Use #if defined _STATBUF_ST_BLKSIZE
	instead of #if _IO_HAVE_ST_BLKSIZE.
	* libio/fileops.c: Test _G_HAVE_MREMAP with #if, not #ifdef.
	* libio/iofdopen.c, libio/iofopen.c: Test _G_HAVE_MMAP with #if,
	not #ifdef.
2018-02-07 10:10:32 -05:00
Wilco Dijkstra b7c83ca30e Remove slow paths from log
Remove the slow paths from log.  Like several other double precision math
functions, log 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.

Interestingly removing the slow paths makes hardly any difference in practice:
the worst case error is still ~0.502ULP, and exp(log(x)) shows identical results
before/after on many millions of random cases.  All GLIBC math tests pass on
AArch64 and x64 with no change in ULP error.  A simple test over a few hundred
million values shows log is now 18% faster on average.

	* manual/probes.texi (slowlog): Delete documentation of removed probe.
	(slowlog_inexact): Likewise
	* sysdeps/ieee754/dbl-64/e_log.c (__ieee754_log): Remove slow paths.
	* sysdeps/ieee754/dbl-64/ulog.h: Remove unused declarations.
2018-02-07 12:24:43 +00:00
Joseph Myers 6f9a3dd8b8 Move LDBL_CLASSIFY_COMPAT to its own header.
The general rule in glibc is that it's better for a macro to be always
defined, and tested with #if, than for it to be tested with #ifdef,
because the latter is prone to typos in the macro name as well as to
the header with the macro accidentally not being included in a file
testing it.  (Testing with an "if" statement is even better, in those
cases where it's possible to do things that way, as it then means both
cases in the code get checked for syntax in glibc builds with either
value of the condition.)

math_private.h has several different groups of macros, meaning that
architectures wanting to override some of them need to define those
then include the generic version, which then defines macros if not
already defined.  It's hard to avoid that arrangement completely, but
various cases can be improved by splitting out macros or groups of
macros into separate files.

This patch splits out the LDBL_CLASSIFY_COMPAT macro into a separate
ldbl-classify-compat.h header.  This macro is tested with #ifdef; this
patch changes it to testing with #if, with a default definition to 0
in the generic header and then architecture-specific headers defining
it to 1.

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

	* sysdeps/generic/ldbl-classify-compat.h: New file.
	* sysdeps/arm/ldbl-classify-compat.h: Likewise.
	* sysdeps/m68k/coldfire/ldbl-classify-compat.h: Likewise.
	* sysdeps/microblaze/ldbl-classify-compat.h: Likewise.
	* sysdeps/mips/ldbl-classify-compat.h: Likewise.
	* sysdeps/nios2/ldbl-classify-compat.h: Likewise.
	* sysdeps/sh/ldbl-classify-compat.h: Likewise.
	* sysdeps/ieee754/dbl-64/s_finite.c: Include
	<ldbl-classify-compat.h>.
	[LDBL_CLASSIFY_COMPAT]: Test value, not whether defined.
	* sysdeps/ieee754/dbl-64/s_isinf.c: Include
	<ldbl-classify-compat.h>.
	[LDBL_CLASSIFY_COMPAT]: Test value, not whether defined.
	* sysdeps/ieee754/dbl-64/s_isnan.c: Include
	<ldbl-classify-compat.h>.
	[LDBL_CLASSIFY_COMPAT]: Test value, not whether defined.
	* sysdeps/ieee754/dbl-64/wordsize-64/s_finite.c: Include
	<ldbl-classify-compat.h>.
	[LDBL_CLASSIFY_COMPAT]: Test value, not whether defined.
	* sysdeps/ieee754/dbl-64/wordsize-64/s_isinf.c: Include
	<ldbl-classify-compat.h>.
	[LDBL_CLASSIFY_COMPAT]: Test value, not whether defined.
	* sysdeps/ieee754/dbl-64/wordsize-64/s_isnan.c: Include
	<ldbl-classify-compat.h>.
	[LDBL_CLASSIFY_COMPAT]: Test value, not whether defined.
	* sysdeps/arm/math_private.h (LDBL_CLASSIFY_COMPAT): Remove macro.
	* sysdeps/mips/math_private.h (LDBL_CLASSIFY_COMPAT): Likewise.
	* sysdeps/m68k/coldfire/math_private.h: Remove file.
	* sysdeps/microblaze/math_private.h: Likewise.
	* sysdeps/nios2/math_private.h: Likewise.
	* sysdeps/sh/math_private.h: Likewise.
2018-02-01 21:01:00 +00:00
Carlos O'Donell f1d7368196 Fix -Os log1p, log1pf build (bug 21314).
As reported in bug 21314, building log1p and log1pf fails with -Os
because of a spurious -Wmaybe-uninitialized warning (reported there
for GCC 5 for MIPS, I see it also with GCC 7 for x86_64).  This patch,
based on the patches in the bug, fixes this using the DIAG_* macros.

Tested for x86_64 with -Os that this eliminates those warnings and so
allows the build to progress further.

2018-02-01  Carlos O'Donell  <carlos@redhat.com>
	    Ramin Seyed-Moussavi  <lordrasmus@gmail.com>
	    Joseph Myers  <joseph@codesourcery.com>

	[BZ #21314]
	* sysdeps/ieee754/dbl-64/s_log1p.c: Include <libc-diag.h>.
	(__log1p): Disable -Wmaybe-uninitialized for -Os around
	computation using c.
	* sysdeps/ieee754/flt-32/s_log1pf.c: Include <libc-diag.h>.
	(__log1pf): Disable -Wmaybe-uninitialized for -Os around
	computation using c.
2018-02-01 20:40:48 +00:00
Joseph Myers b303185df9 Fix ldbl-128ibm log1pl (-qNaN) spurious "invalid" exception (bug 22693).
The ldbl-128ibm implementation of log1pl does ordered comparisons on a
negative qNaN argument, so resulting in spurious "invalid" exceptions
(for soft-float powerpc; hard-float only avoids this because of GCC
bug 58684 meaning ordered comparison instructions never get
generated).  This patch fixes this by arranging for the test for NaN
or infinity arguments to handle negative arguments as well.

Tested for powerpc (soft float).

	[BZ #22693]
	* sysdeps/ieee754/ldbl-128ibm/s_log1pl.c (__log1pl): Handle
	negative arguments in test for NaN or infinity argument.
2018-01-10 17:59:01 +00:00
Joseph Myers 1272748886 Fix ldbl-128ibm lrintl, lroundl missing "invalid" exceptions (bug 22690).
The ldbl-128ibm implementations of lrintl and lroundl are missing
"invalid" exceptions for certain overflow cases when compiled with GCC
8.  The cause of this is after-the-fact integer overflow checks that
fail when the compiler optimizes on the basis of integer overflow
being undefined; GCC 8 must be able to detect new cases of
undefinedness here.

Failure: lrint (-0x80000001p0): Exception "Invalid operation" not set
Failure: lrint_downward (-0x80000001p0): Exception "Invalid operation" not set
Failure: lrint_towardzero (-0x80000001p0): Exception "Invalid operation" not set
Failure: lrint_upward (-0x80000001p0): Exception "Invalid operation" not set

Failure: lround (-0x80000001p0): Exception "Invalid operation" not set
Failure: lround_downward (-0x80000001p0): Exception "Invalid operation" not set
Failure: lround_towardzero (-0x80000001p0): Exception "Invalid operation" not set
Failure: lround_upward (-0x80000001p0): Exception "Invalid operation" not set

(Tested that these failures occur before the patch for powerpc
soft-float, but the issue applies in principle for hard-float as well,
whether or not the particular optimizations in fact occur there at
present.)

This patch fixes the bug by ensuring the additions / subtractions in
question cast arguments to unsigned long int, or use 1UL as a constant
argument, so that the arithmetic occurs in an unsigned type with the
result then converted back to a signed type.

Tested for powerpc (soft-float).

	[BZ #22690]
	* sysdeps/ieee754/ldbl-128ibm/s_lrintl.c (__lrintl): Use unsigned
	long int for arguments of possibly overflowing addition or
	subtraction.
	* sysdeps/ieee754/ldbl-128ibm/s_lroundl.c (__lroundl): Likewise.
2018-01-10 00:02:35 +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
Bernd Edlinger 648615e13f Avoid signed shift overflow in pow (bug 21309).
As noted in bug 21309, dbl-64/e_pow.c contains signed int shifts that,
although the shift count is in the range [0, 31], shift bits into and
beyond the sign bit and so are undefined in ISO C.  Although this is
defined in GNU C, this patch from the bug cleans up the code to avoid
those shifts.

Tested for x86_64.

	[BZ #21309]
	* sysdeps/ieee754/dbl-64/e_pow.c (checkint): Make m and n
	unsigned.
2017-12-19 18:41:01 +00: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
Rajalakshmi Srinivasaraghavan 984ae9967b New generic sincosf
This implementation is based on generic s_sinf.c and s_cosf.c.
Tested on s390x, powerpc64le and powerpc32.
2017-12-16 14:01:37 +05:30
Joseph Myers 6f7c009282 Add sysdeps/ieee754/soft-fp.
The default sysdeps/ieee754 fma implementations rely on exceptions and
rounding modes to achieve correct results through internal use of
round-to-odd.  Thus, glibc configurations without support for
exceptions and rounding modes instead need to use implementations of
fma based on soft-fp.

At present, this is achieved via having implementation files in
soft-fp/ that are #included by sysdeps files for each glibc
configuration that needs them.  In general this means such a
configuration has its own s_fma.c and s_fmaf.c.

TS 18661-1 adds functions that do an operation (+ - * / sqrt fma) on
arguments wider than the return type, with a single rounding of the
infinite-precision result to that return type.  These are also
naturally implemented using round-to-odd on platforms with hardware
support for rounding modes and exceptions but lacking hardware support
for these narrowing operations themselves.  (Platforms that have
direct hardware support for such narrowing operations include at least
ia64, and Power ISA 2.07 or later, which I think means POWER8 or
later.)

So adding the remaining TS 18661-1 functions would mean at least six
narrowing function implementations (fadd fsub fmul fdiv ffma fsqrt),
with aliases for other types and further implementations in some
configurations, that need to be overridden for configurations lacking
hardware exceptions and rounding modes.  Requiring all such
configurations (currently seven of them) to have their own source
files for all those functions seems undesirable.

Thus, this patch adds a directory sysdeps/ieee754/soft-fp to contain
libm function implementations based on soft-fp.  This directory is
then used via Implies from all the configurations that need it, so no
more files need adding to every such configuration when adding more
functions with soft-fp implementations.  A configuration can still
selectively #include a particular file from this directory if desired;
thus, the MIPS #include of the fmal implementation is retained, since
that's appropriate even for hard float (because long double is always
implementated in software for MIPS64, so the soft-fp implementation of
fmal is better than the ldbl-128 one).

This also provides additional motivation for my recent patch removing
--with-fp / --without-fp: previously there was no need for correct use
of --without-fp for no-FPU ARM or SH3, and now we have autodetection
nofpu/ sysdeps directories can be used by this patch for those
configurations without imposing any new requirements on how glibc is
configured.

(The mips64/*/fpu/s_fma.c files added by this patch are needed to keep
the dbl-64 version of fma for double, rather than the ldbl-128 one,
used in that case.)

Tested with build-many-glibcs.py that installed stripped shared
libraries are unchanged by this patch.

	* soft-fp/fmadf4.c: Move to ....
	* sysdeps/ieee754/soft-fp/s_fma.c: ... here.
	* soft-fp/fmasf4.c: Move to ....
	* sysdeps/ieee754/soft-fp/s_fmaf.c: ... here.
	* soft-fp/fmatf4.c: Move to ....
	* sysdeps/ieee754/soft-fp/s_fmal.c: ... here.
	* sysdeps/ieee754/soft-fp/Makefile: New file.
	* sysdeps/arm/preconfigure.ac: Define with_fp_cond.
	* sysdeps/arm/preconfigure: Regenerated.
	* sysdeps/arm/nofpu/Implies: New file.
	* sysdeps/arm/s_fma.c: Remove file.
	* sysdeps/arm/s_fmaf.c: Likewise.
	* sysdeps/m68k/coldfire/nofpu/Implies: New file.
	* sysdeps/m68k/coldfire/nofpu/s_fma.c: Remove file.
	* sysdeps/m68k/coldfire/nofpu/s_fmaf.c: Likewise.
	* sysdeps/microblaze/Implies: Add ieee754/soft-fp.
	* sysdeps/microblaze/s_fma.c: Remove file.
	* sysdeps/microblaze/s_fmaf.c: Likewise.
	* sysdeps/mips/mips32/nofpu/Implies: New file.
	* sysdeps/mips/mips64/n32/fpu/s_fma.c: Likewise.
	* sysdeps/mips/mips64/n32/nofpu/Implies: Likewise.
	* sysdeps/mips/mips64/n64/fpu/s_fma.c: Likewise.
	* sysdeps/mips/mips64/n64/nofpu/Implies: Likewise.
	* sysdeps/mips/ieee754/s_fma.c: Remove file.
	* sysdeps/mips/ieee754/s_fmaf.c: Likewise.
	* sysdeps/mips/ieee754/s_fmal.c: Update include for move of fmal
	implementation.
	* sysdeps/nios2/Implies: Add ieee754/soft-fp.
	* sysdeps/nios2/s_fma.c: Remove file.
	* sysdeps/nios2/s_fmaf.c: Likewise.
	* sysdeps/sh/nofpu/Implies: New file.
	* sysdeps/sh/s_fma.c: Remove file.
	* sysdeps/sh/s_fmaf.c: Likewise.
	* sysdeps/tile/Implies: Add ieee754/soft-fp.
	* sysdeps/tile/s_fma.c: Remove file.
	* sysdeps/tile/s_fmaf.c: Likewise.
2017-12-12 23:35:21 +00:00
Paul Clarke f4b2aea6e1 New generic cosf
The same logic used in s_cosf.S version for x86 and powerpc
is used to create a generic s_cosf.c, so there is no performance
improvement in x86_64 and powerpc64.

	* sysdeps/ieee754/flt-32/s_cosf.c: New implementation.
2017-12-11 17:39:42 -02:00
Joseph Myers 1dbe6f64ab Don't make local variables static in ldbl-96 j1l.
The ldbl-96 implementation of j1l has some function-local variables
that are declared static for no apparent reason (this dates back to
the first addition of that file).

Any vaguely recent compiler, probably including any that are supported
for building glibc, optimizes away the "static" here, as the values of
the variables on entry to the function are dead.  So there is not
actually a user-visible bug here at present (but with any compilers
that didn't optimize away the static at all, possibly building with
less or no optimization, so that the function stored intermediate
values to and then loaded them from the variables, there would have
been a thread-safety issue).  But the "static" clearly doesn't belong
there and might potentially make things unsafe were compilation
without optimization to be supported in future, so this patch removes
it.

Tested for x86_64.

	* sysdeps/ieee754/ldbl-96/e_j1l.c (qone): Don't make local
	variables static.
2017-12-06 15:19:06 +00:00
Joseph Myers 53994f1263 Make some ldbl-128, ldbl-128ibm arrays const.
I noticed that an x86_64 build of libm unexpectedly contained more
non-constant data than an older version (before _Float128 support)
did.  The problem is non-const arrays in the ldbl-128 j0l and j1l
implementations; this patch makes those arrays, and the corresponding
ldbl-128ibm ones, const.

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

	* sysdeps/ieee754/ldbl-128/e_j0l.c (Y0_2N): Make const.
	(Y0_2D): Likewise.
	* sysdeps/ieee754/ldbl-128/e_j1l.c (Y0_2N): Likewise.
	(Y0_2D): Likewise.
	* sysdeps/ieee754/ldbl-128ibm/e_j0l.c (Y0_2N): Likewise.
	(Y0_2D): Likewise.
	* sysdeps/ieee754/ldbl-128ibm/e_j1l.c (Y0_2N): Likewise.
	(Y0_2D): Likewise.
2017-12-06 13:42:58 +00:00
Adhemerval Zanella 94d80dfc73 math: Use sign as double for reduced case in sinf
This patch avoid an extra floating point to integer conversion in
reduced internal function for generic sinf by defining the sign as
double instead of integers.

There is no much difference on Haswell with GCC 7.2.1:

           Before        After
min          9.11        9.108
mean       21.982      21.9224

However H.J. Lu reported gains on Skylake:

Before:

  "sinf": {
   "": {
    "duration": 3.4044e+10,
    "iterations": 1.9942e+09,
    "max": 141.106,
    "min": 7.704,
    "mean": 17.0715
   }
  }

After:

  "sinf": {
   "": {
    "duration": 3.40665e+10,
    "iterations": 2.03199e+09,
    "max": 95.994,
    "min": 7.704,
    "mean": 16.765
   }
  }

Checked on x86_64-linux-gnu.

	* sysdeps/ieee754/flt-32/s_sinf.c (ones): Define as double.
	(reduced): Use ones as double instead of integer.
2017-12-05 16:27:44 -02:00
Szabolcs Nagy 00d54af7c8 [PATCH] fix sinf(NAN)
sinf(NAN) should not signal invalid fp exception
so use isless instead of < where NAN is compared.

this makes the sinf tests pass on aarch64.

	* sysdeps/ieee754/flt-32/s_sinf.c (sinf): Use isless.
2017-12-05 18:09:22 +00:00
Joseph Myers f2d64d621e Support _Float64, _Float32x in libm_alias_double.
This patch makes the libm_alias_double macros support creating
_Float64 and _Float32x aliases, in preparation for enabling glibc
support for those types.

Tested for x86_64; also tested with build-many-glibcs.py in
conjunction with other _Float64 / _Float32x changes.

	* sysdeps/generic/libm-alias-double.h: Include <bits/floatn.h>.
	(libm_alias_double_other_r_f64): New macro.
	(libm_alias_double_other_r_f32x): Likewise.
	(libm_alias_double_other_r): Use libm_alias_double_other_r_f64 and
	libm_alias_double_other_r_f32x.
	(libm_alias_double_r): Use semicolon before call to
	libm_alias_double_other_r.
	* sysdeps/ieee754/ldbl-opt/libm-alias-double.h: Include
	<bits/floatn.h>.
	(libm_alias_double_other_r_f64): New macro.
	(libm_alias_double_other_r_f32x): Likewise.
	(libm_alias_double_other_r): Use libm_alias_double_other_r_f64 and
	libm_alias_double_other_r_f32x.
2017-12-05 17:00:57 +00:00
H.J. Lu 91c318e7b9 s_sinf.c: Replace floor with simple casts
Since s_sinf.c either assigns the return value of floor to integer or
passes double converted from integer to floor, this patch replaces
floor with simple casts.

Also since long == int for 32-bit targets, we can use long instead of
int to avoid 64-bit integer for 64-bit targets.

On Skylake, bench-sinf reports performance improvement:

           Before        After         Improvement
max        130.566       129.564           30%
min        7.704         7.706             0%
mean       21.8188       19.1363           30%

	* sysdeps/ieee754/flt-32/s_sinf.c (reduced): Replace long with
	int.
	(SINF_FUNC): Likewise.  Replace floor with simple casts.
2017-12-05 08:47:27 -08:00
Joseph Myers 73895b499b Use __floor not floor in sinf.
The new sinf implementation introduced localplt failures for all
platforms where the compiler did not inline the calls to floor
(converted to trunc by machine-independent optimizations).  This patch
changes the calls to use __floor as normal in libm.

We can't use the public function names floor / floorf / floorl /
floorf128 in libm code in the absence of appropriate asms to redirect
floor/trunc calls, if not inlined, to use the internal names instead
(while avoiding breaking code building the floor functions themselves)
- while having such asms and then calling the public functions
unconditionally would be desirable for optimization (few architectures
have __floor inlines in math_private.h, and once the built-in function
is used you don't need them), using __floor is the minimum safe fix
for the present test regressions.

Tested with build-many-glibcs.py that this fixes the localplt test
failure for arm-linux-gnueabi.

	* sysdeps/ieee754/flt-32/s_sinf.c (SINF_FUNC): Use __floor instead
	of floor.
2017-12-04 16:58:08 +00:00
Rajalakshmi Srinivasaraghavan 7863a71181 New generic sinf
This implementation is based on optimized sinf assembly versions
of x86_64 and powerpc.
2017-12-04 10:12:10 +05:30
Joseph Myers d812486444 Support ldbl-opt libm_alias_double use from .S files.
This patch makes the ldbl-opt libm_alias_double implementation support
use from .S sources, by adding a semicolon after its use of
weak_alias.

Tested (compilation only) with build-many-glibcs.py for
alpha-linux-gnu, in conjunction with a patch introducing uses of
libm_alias_double in alpha .S files.

	* sysdeps/ieee754/ldbl-opt/libm-alias-double.h
	(libm_alias_double_r): Add semicolon after weak_alias call.
2017-11-28 00:01:11 +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 de61465c04 Use libm_alias_float128 more in sysdeps/ieee754/float128.
This patch uses libm_alias_float128 in place of weak_alias more in
sysdeps/ieee754/float128, in preparation for defining _Float64x
aliases when appropriate.

Tested for x86_64, and for powerpc64le (compilation only) with
build-many-glibcs.py in conjunction with _Float64x support patches.

	* sysdeps/ieee754/float128/s_fromfpf128.c (fromfpf128): Define
	using libm_alias_float128.
	* sysdeps/ieee754/float128/s_fromfpxf128.c (fromfpxf128):
	Likewise.
	* sysdeps/ieee754/float128/s_setpayloadf128.c (setpayloadf128):
	Likewise.
	* sysdeps/ieee754/float128/s_setpayloadsigf128.c
	(setpayloadsigf128): Likewise.
	* sysdeps/ieee754/float128/s_ufromfpf128.c (ufromfpf128):
	Likewise.
	* sysdeps/ieee754/float128/s_ufromfpxf128.c (ufromfpxf128):
	Likewise.
2017-11-24 23:53:54 +00:00
Joseph Myers 6e70d156c7 Support _Float64x in libm_alias macros.
This patch adds support for libm_alias_ldouble and libm_alias_float128
to create *f64x function aliases when appropriate.

Making such aliases work for functions defined in assembly sources
requires adding some semicolons after weak_alias calls in alias macro
definitions.  For C, semicolons are already present in the macros
called when required, but a GNU C extension allows excess semicolons
at file scope in a source file (and glibc already uses this), so it is
OK to have extra semicolons present in the macro definitions.  For
assembly sources, making multiple alias macro calls from a single
macro expansion means there are no newlines between the calls, so an
explicit separator is needed.  If hppa were to have .S sources in
libm, a more complicated approach would be needed that used
ASM_LINE_SEP when building assembly sources but not for C, but right
now there are no such sources so just using a semicolon (as already
present unconditionally in some such macro expansions) suffices.

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

	* sysdeps/generic/libm-alias-float128.h: Include <bits/floatn.h>.
	(libm_alias_float128_other_r): If
	[__HAVE_FLOAT64X && !__HAVE_FLOAT64X_LONG_DOUBLE], define f64x
	alias.
	(libm_alias_float128_r): Add semicolon after weak_alias call.
	* sysdeps/generic/libm-alias-ldouble.h
	(libm_alias_ldouble_other_r_f128): New macro.
	(libm_alias_ldouble_other_r_f64x): Likewise.
	(libm_alias_ldouble_other_r): Use libm_alias_ldouble_other_r_f128
	and libm_alias_ldouble_other_r_f64x.
	(libm_alias_ldouble_r): Add semicolon after weak_alias call.
	* sysdeps/ieee754/ldbl-opt/libm-alias-ldouble.h
	(libm_alias_ldouble_other_r_f128): New macro.
	(libm_alias_ldouble_other_r_f64x): Likewise.
	(libm_alias_ldouble_other_r): Use libm_alias_ldouble_other_r_f128
	and libm_alias_ldouble_other_r_f64x.
2017-11-24 23:33:14 +00:00
Joseph Myers df2806cdb5 Support strfromf64x alias.
This patch adds support for defining strfromf64x as a function alias
(of strfroml or strfromf128, as appropriate) when _Float64x is
supported.

Tested for x86_64, including in conjunction with _Float64x support
patches, and also tested build for other configurations (in
conjunction with _Float64x support patches) with build-many-glibcs.py
to cover the various different files needing updating to define these
aliases.

	* stdlib/strfroml.c: Always include <stdlib.h>.
	[__HAVE_FLOAT64X_LONG_DOUBLE] (strfromf64x): Define and later
	undefine as macro and define as weak alias.
	* sysdeps/ieee754/float128/strfromf128.c: Include <bits/floatn.h>.
	[__HAVE_FLOAT64X && !__HAVE_FLOAT64X_LONG_DOUBLE]: Include
	<stdlib.h>.
	[__HAVE_FLOAT64X && !__HAVE_FLOAT64X_LONG_DOUBLE] (strfromf64x):
	Define and later undefine as macro and define as weak alias.
2017-11-24 23:12:30 +00:00
Joseph Myers 0df4fe3557 Support strtof64x, wcstof64x aliases.
This patch adds support for defining strtof64x, strtof64x_l, wcstof64
and wcstof64x_l function aliases when _Float64x is supported.

Tested for x86_64, including in conjunction with _Float64x support
patches, and also tested build for other configurations (in
conjunction with _Float64x support patches) with build-many-glibcs.py
to cover the various different files needing updating to define these
aliases.

	* stdlib/strtold.c [__HAVE_FLOAT64X_LONG_DOUBLE] (strtof64x):
	Define and later undefine as macro.  Define as weak alias if
	[!USE_WIDE_CHAR].
	[__HAVE_FLOAT64X_LONG_DOUBLE] (wcstof64x): Define and later
	undefine as macro.  Define as weak alias if [USE_WIDE_CHAR].
	* sysdeps/ieee754/float128/strtof128.c: Include <bits/floatn.h>.
	[__HAVE_FLOAT64X && !__HAVE_FLOAT64X_LONG_DOUBLE] (strtof64x):
	Define and later undefine as macro.  Define as weak alias if
	[!USE_WIDE_CHAR].
	[__HAVE_FLOAT64X && !__HAVE_FLOAT64X_LONG_DOUBLE] (wcstof64x):
	Define and later undefine as macro.  Define as weak alias if
	[USE_WIDE_CHAR].
	* sysdeps/ieee754/float128/strtof128_l.c
	[__HAVE_FLOAT64X && !__HAVE_FLOAT64X_LONG_DOUBLE] (strtof64x_l):
	Define and later undefine as macro.  Define as weak alias if
	[!USE_WIDE_CHAR].
	[__HAVE_FLOAT64X && !__HAVE_FLOAT64X_LONG_DOUBLE] (wcstof64x_l):
	Define and later undefine as macro.  Define as weak alias if
	[USE_WIDE_CHAR].
	* sysdeps/ieee754/ldbl-128/strtold_l.c
	[__HAVE_FLOAT64X_LONG_DOUBLE] (strtof64x_l): Define and later
	undefine as macro.  Define as weak alias if [!USE_WIDE_CHAR].
	[__HAVE_FLOAT64X_LONG_DOUBLE] (wcstof64x_l): Define and later
	undefine as macro.  Define as weak alias if [USE_WIDE_CHAR].
	* sysdeps/ieee754/ldbl-64-128/strtold_l.c
	[__HAVE_FLOAT64X_LONG_DOUBLE] (strtof64x_l): Define and later
	undefine as macro.  Define as weak alias if [!USE_WIDE_CHAR].
	[__HAVE_FLOAT64X_LONG_DOUBLE] (wcstof64x_l): Define and later
	undefine as macro.  Define as weak alias if [USE_WIDE_CHAR].
	* sysdeps/ieee754/ldbl-96/strtold_l.c
	[__HAVE_FLOAT64X_LONG_DOUBLE] (strtof64x_l): Define and later
	undefine as macro.  Define as weak alias if [!USE_WIDE_CHAR].
	[__HAVE_FLOAT64X_LONG_DOUBLE] (wcstof64x_l): Define and later
	undefine as macro.  Define as weak alias if [USE_WIDE_CHAR].
2017-11-24 22:51:53 +00:00
Joseph Myers 015c6dc288 Support bits/floatn.h inclusion from .S files.
Further _FloatN / _FloatNx type alias support will involve making
architecture-specific .S files use the common macros for libm function
aliases.  Making them use those macros will also serve to simplify
existing code for aliases / symbol versions in various cases, similar
to such simplifications for ldbl-opt code.

The libm-alias-*.h files sometimes need to include <bits/floatn.h> to
determine which aliases they should define.  At present, this does not
work for inclusion from .S files because <bits/floatn.h> can define
typedefs for old compilers.  This patch changes all the
<bits/floatn.h> and <bits/floatn-common.h> headers to include
__ASSEMBLER__ conditionals.  Those conditionals disable everything
related to C syntax in the __ASSEMBLER__ case, not just the problem
typedefs, as that seemed cleanest.  The __HAVE_* definitions remain in
the __ASSEMBLER__ case, as those provide information that is required
to define the correct set of aliases.

Tested with build-many-glibcs.py for a representative set of
configurations (x86_64-linux-gnu i686-linux-gnu ia64-linux-gnu
powerpc64le-linux-gnu mips64-linux-gnu-n64 sparc64-linux-gnu) with GCC
6.  Also tested with GCC 6 for i686-linux-gnu in conjunction with
changes to use alias macros in .S files.

	* bits/floatn-common.h [!__ASSEMBLER]: Disable everything related
	to C syntax instead of availability and properties of types.
	* bits/floatn.h [!__ASSEMBLER]: Likewise.
	* sysdeps/ia64/bits/floatn.h [!__ASSEMBLER]: Likewise.
	* sysdeps/ieee754/ldbl-128/bits/floatn.h [!__ASSEMBLER]: Likewise.
	* sysdeps/mips/ieee754/bits/floatn.h [!__ASSEMBLER]: Likewise.
	* sysdeps/powerpc/bits/floatn.h [!__ASSEMBLER]: Likewise.
	* sysdeps/x86/bits/floatn.h [!__ASSEMBLER]: Likewise.
2017-11-17 22:01:43 +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
Joseph Myers 81325b12b1 Add _Float128 function aliases.
This patch adds support for *f128 function aliases on platforms where
long double has the binary128 format (and thus GCC 7 provides the
_Float128 type with the same ABI as long double but as a distinct type
in terms of C type compatibility).  This is the same API as provided
in glibc 2.26 for powerpc64le / x86_64 / x86 / ia64 where _Float128
has a different format from long double, with the bulk of the API
coming from TS 18661-3.  All the functions alias the corresponding
long double functions, and __* function names are not provided since
those are only needed once for each floating-point format, not more
than once for different types with the same format (so for example,
-ffinite-math-only maps foof128 to __fool_finite, while type-generic
macros end up calling e.g. __issignalingl for _Float128 arguments on
such platforms).

The preparation for this feature was done in previous patches, so this
one just needs to add the relevant makefile and header definitions,
and update macro definitions of libm_alias_ldouble_other_r, to turn on
the feature, and update documentation and ABI baselines.

Tested (a) for x86_64, (b) for aarch64, (c) with build-many-glibcs.py
with both GCC 6 and GCC 7.

	* sysdeps/ieee754/ldbl-128/Makeconfig: New file.
	* sysdeps/ieee754/ldbl-128/bits/floatn.h: Likewise.
	* sysdeps/ieee754/ldbl-128/float128-abi.h: Likewise.
	* sysdeps/generic/libm-alias-ldouble.h: Include <bits/floatn.h>.
	[__HAVE_FLOAT128 && !__HAVE_DISTINCT_FLOAT128]
	(libm_alias_ldouble_other_r): Also create _Float128 alias.
	* sysdeps/ieee754/ldbl-opt/libm-alias-ldouble.h: Include
	<bits/floatn.h>.
	[__HAVE_FLOAT128 && !__HAVE_DISTINCT_FLOAT128]
	(libm_alias_ldouble_other_r): Also create _Float128 alias.
	* manual/math.texi (Mathematics): Document additional architecture
	support for _Float128.
	* 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/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/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.
2017-10-18 17:37:18 +00: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 02010e79ce Support strtof128 etc. aliases.
This patch adds support for building strtof128, wcstof128, strtof128_l
and wcstof128_l as aliases, in the case of __HAVE_FLOAT128 &&
!__HAVE_DISTINCT_FLOAT128.

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

	* stdlib/strtold.c: Include <bits/floatn.h>
	[__HAVE_FLOAT128 && !__HAVE_DISTINCT_FLOAT128] (strtof128): Define
	and later undefine as macro.  Define as weak alias if
	[!USE_WIDE_CHAR].
	[__HAVE_FLOAT128 && !__HAVE_DISTINCT_FLOAT128] (wcstof128): Define
	and later undefine as macro.  Define as weak alias if
	[USE_WIDE_CHAR].
	* sysdeps/ieee754/ldbl-128/strtold_l.c [__HAVE_FLOAT128 &&
	!__HAVE_DISTINCT_FLOAT128] (strtof128_l): Define and later
	undefine as macro.  Define as weak alias if [!USE_WIDE_CHAR].
	[__HAVE_FLOAT128 && !__HAVE_DISTINCT_FLOAT128] (wcstof128_l):
	Define and later undefine as macro.  Define as weak alias if
	[USE_WIDE_CHAR].
	* sysdeps/ieee754/ldbl-64-128/strtold_l.c: Include
	<bits/floatn.h>.
	[__HAVE_FLOAT128 && !__HAVE_DISTINCT_FLOAT128] (strtof128_l):
	Define and later undefine as macro.  Define as weak alias if
	[!USE_WIDE_CHAR].
	[__HAVE_FLOAT128 && !__HAVE_DISTINCT_FLOAT128] (wcstof128_l):
	Define and later undefine as macro.  Define as weak alias if
	[USE_WIDE_CHAR].
2017-10-16 13:22:11 +00:00
Joseph Myers f8718a9e16 Use libm_alias_ldouble_other in ldbl-64-128/s_nextafterl.c.
This patch makes ldbl-64-128/s_nextafterl.c restore the default
weak_alias definition and use libm_alias_ldouble_other (having
undefined and redefined weak_alias for the include of
ldbl-128/s_nextafterl.c, so the libm_alias_ldouble use in the latter
file is ineffective).

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

	* sysdeps/ieee754/ldbl-64-128/s_nextafterl.c (weak_alias):
	Undefine and restore default definition.  Use
	libm_alias_ldouble_other.
2017-10-13 23:05:15 +00:00
Joseph Myers 1def91b304 Fix ldbl-opt/w_lgamma_compatl.c libm_alias_ldouble_other usage.
Testing with changes to enable _Float128 function aliases shows that
the libm_alias_ldouble_other usage in ldbl-opt/w_lgamma_compatl.c does
not in fact work.  Furthermore, it is unnecessary; the relevant
aliases get created through w_lgammal_compat2.c.  This patch removes
the problem code.

Tested with build-many-glibcs.py that installed stripped shared
libraries are unchanged by the patch.  Also tested in conjunction with
patches to enable _Float128 function aliases.

	* sysdeps/ieee754/ldbl-opt/w_lgamma_compatl.c [BUILD_LGAMMA]:
	Remove conditional code.
2017-10-13 16:38:37 +00:00
Joseph Myers 7d25d410c2 Fix ldbl-opt/s_clog10l.c libm_alias_ldouble_other usage.
Testing with changes to enable _Float128 function aliases shows that
the libm_alias_ldouble_other usage in ldbl-opt/s_clog10l.c does not in
fact work, because __clog10l is defined with long_double_symbol rather
than as a normal C alias.  This patch fixes this by renaming the
__clog10l__internal alias (not strictly necessary, but avoids a hack
with "__clog10l_interna" / "__clog10l__interna" as first argument to
libm_alias_ldouble_other) and using the renamed alias when calling
libm_alias_ldouble_other.

Tested with build-many-glibcs.py that installed stripped shared
libraries are unchanges by the patch.  Also tested in conjunction with
patches to enable _Float128 function aliases.

	* sysdeps/ieee754/ldbl-opt/s_clog10l.c (__clog10l__internal):
	Rename to __clog10_internal_l.
	(__clog10_internal_l): Define aliases using
	libm_alias_ldouble_other instead of using libm_alias_ldouble_other
	with __clog10.
2017-10-13 16:36:45 +00:00
Joseph Myers 0ff64d3a18 Use generic alias macros in ldbl-opt.
This patch fixes ldbl-opt code to use generic libm alias macros in
preparation for getting _FloatN / _FloatNx aliases where appropriate.

Four functions are affected, that undefine and redefine alias macros
before including the implementations they wrap in such a way that
_FloatN / _FloatNx aliases would not appear.  s_clog10l.c undefines
and redefined declare_mgen_alias, so just needs a
libm_alias_ldouble_other call added.  w_exp10l_compat.c undefines and
redefines weak_alias, but in fact does not need to do so, since
math/w_exp10l_compat.c uses libm_alias_ldouble and does not use
weak_alias other than through that, so the undefines and redefines of
weak_alias are removed.  w_lgamma_compatl.c and w_remainderl_compat.c
are made to use libm_alias_ldouble_other in conjunction with restoring
the original definition of weak_alias so this is effective.

Tested with build-many-glibcs.py.  Installed stripped shared libraries
are unchanged by this patch.

	* sysdeps/ieee754/ldbl-opt/s_clog10l.c: Use
	libm_alias_ldouble_other.
	* sysdeps/ieee754/ldbl-opt/w_exp10l_compat.c (weak_alias): Do not
	undefine and redefine.
	[LIBM_SVID_COMPAT && !LONG_DOUBLE_COMPAT (libm, GLIBC_2_1)]
	(exp10l): Do not define here.
	* sysdeps/ieee754/ldbl-opt/w_lgamma_compatl.c [BUILD_LGAMMA]
	(weak_alias): Undefine and redefine.
	[BUILD_LGAMMA]: Use libm_alias_ldouble_other.
	* sysdeps/ieee754/ldbl-opt/w_remainderl_compat.c
	[LIBM_SVID_COMPAT] (weak_alias): Undefine and redefine here.
	[LIBM_SVID_COMPAT]: Use libm_alias_ldouble_other.
2017-10-11 02:51:39 +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
Joseph Myers c7509db215 Remove ldbl-opt w_scalbln.c.
The ldbl-opt version of w_scalbln.c is not in fact needed; it handles
compat symbol versions for libc, but this file isn't built for libc,
only for libm.  This patch removes this file.

Tested with build-many-glibcs.py that installed stripped shared
libraries are unchanged by this patch.

	* sysdeps/ieee754/ldbl-opt/w_scalbln.c: Remove file.
2017-10-09 16:52:56 +00:00
Joseph Myers f85a176f3f Use libm_alias_double in ldbl-128, ldbl-96 fma.
This patch makes the ldbl-128 and ldbl-96 implementations of fma use
libm_alias_double.

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

	* sysdeps/ieee754/ldbl-128/s_fma.c: Include <libm-alias-double.h>.
	[!__fma] (fma): Define using libm_alias_double.
	* sysdeps/ieee754/ldbl-96/s_fma.c: Include <libm-alias-double.h>.
	[!__fma] (fma): Define using libm_alias_double.
2017-10-06 20:23:58 +00:00
Joseph Myers fd3b4e7c8a Use libm_alias_ldouble for ldbl-128 functions.
This patch makes ldbl-128 functions use libm_alias_ldouble to define
function aliases.  float128_private.h is updated accordingly.  Most of
the ldbl-64-128 wrappers are removed as no longer needed with this
change (leaving those that involve versioning for functions in libc or
that shouldn't be exported from libm for _Float128 / _Float64x types
with the same format as long double).

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

	* sysdeps/ieee754/float128/float128_private.h: Include
	<libm-alias-ldouble.h> and <libm-alias-float128.h>.
	(libm_alias_ldouble_r): Undefine and redefine.
	* sysdeps/ieee754/ldbl-128/s_asinhl.c: Include
	<libm-alias-ldouble.h>.
	(asinhl): Define using libm_alias_ldouble.
	* sysdeps/ieee754/ldbl-128/s_atanl.c: Include
	<libm-alias-ldouble.h>.
	(atanl): Define using libm_alias_ldouble.
	* sysdeps/ieee754/ldbl-128/s_cbrtl.c: Include
	<libm-alias-ldouble.h>.
	(cbrtl): Define using libm_alias_ldouble.
	* sysdeps/ieee754/ldbl-128/s_ceill.c: Include
	<libm-alias-ldouble.h>.
	(ceill): Define using libm_alias_ldouble.
	* sysdeps/ieee754/ldbl-128/s_copysignl.c: Include
	<libm-alias-ldouble.h>.
	(copysignl): Define using libm_alias_ldouble.
	* sysdeps/ieee754/ldbl-128/s_cosl.c: Include
	<libm-alias-ldouble.h>.
	(cosl): Define using libm_alias_ldouble.
	* sysdeps/ieee754/ldbl-128/s_erfl.c: Include
	<libm-alias-ldouble.h>.
	(erfl): Define using libm_alias_ldouble.
	(erfcl): Likewise.
	* sysdeps/ieee754/ldbl-128/s_expm1l.c: Include
	<libm-alias-ldouble.h>.
	(expm1l): Define using libm_alias_ldouble.
	* sysdeps/ieee754/ldbl-128/s_fabsl.c: Include
	<libm-alias-ldouble.h>.
	(fabsl): Define using libm_alias_ldouble.
	* sysdeps/ieee754/ldbl-128/s_floorl.c: Include
	<libm-alias-ldouble.h>.
	(floorl): Define using libm_alias_ldouble.
	* sysdeps/ieee754/ldbl-128/s_fmal.c: Include
	<libm-alias-ldouble.h>.
	(fmal): Define using libm_alias_ldouble.
	* sysdeps/ieee754/ldbl-128/s_frexpl.c: Include
	<libm-alias-ldouble.h>.
	(frexpl): Define using libm_alias_ldouble.
	* sysdeps/ieee754/ldbl-128/s_fromfpl.c (fromfpl): Define using
	libm_alias_ldouble.
	* sysdeps/ieee754/ldbl-128/s_fromfpl_main.c: Include
	<libm-alias-ldouble.h>.
	* sysdeps/ieee754/ldbl-128/s_fromfpxl.c (fromfpxl): Define using
	libm_alias_ldouble.
	* sysdeps/ieee754/ldbl-128/s_getpayloadl.c: Include
	<libm-alias-ldouble.h>.
	(getpayloadl): Define using libm_alias_ldouble.
	* sysdeps/ieee754/ldbl-128/s_llrintl.c: Include
	<libm-alias-ldouble.h>.
	(llrintl): Define using libm_alias_ldouble.
	* sysdeps/ieee754/ldbl-128/s_llroundl.c: Include
	<libm-alias-ldouble.h>.
	(llroundl): Define using libm_alias_ldouble.
	* sysdeps/ieee754/ldbl-128/s_logbl.c: Include
	<libm-alias-ldouble.h>.
	(logbl): Define using libm_alias_ldouble.
	* sysdeps/ieee754/ldbl-128/s_lrintl.c: Include
	<libm-alias-ldouble.h>.
	(lrintl): Define using libm_alias_ldouble.
	* sysdeps/ieee754/ldbl-128/s_lroundl.c: Include
	<libm-alias-ldouble.h>.
	(lroundl): Define using libm_alias_ldouble.
	* sysdeps/ieee754/ldbl-128/s_modfl.c: Include
	<libm-alias-ldouble.h>.
	(modfl): Define using libm_alias_ldouble.
	* sysdeps/ieee754/ldbl-128/s_nearbyintl.c: Include
	<libm-alias-ldouble.h>.
	(nearbyintl): Define using libm_alias_ldouble.
	* sysdeps/ieee754/ldbl-128/s_nextafterl.c: Include
	<libm-alias-ldouble.h>.
	(nextafterl): Define using libm_alias_ldouble.
	* sysdeps/ieee754/ldbl-128/s_nextupl.c: Include
	<libm-alias-ldouble.h>.
	(nextupl): Define using libm_alias_ldouble.
	* sysdeps/ieee754/ldbl-128/s_remquol.c: Include
	<libm-alias-ldouble.h>.
	(remquol): Define using libm_alias_ldouble.
	* sysdeps/ieee754/ldbl-128/s_rintl.c: Include
	<libm-alias-ldouble.h>.
	(rintl): Define using libm_alias_ldouble.
	* sysdeps/ieee754/ldbl-128/s_roundevenl.c: Include
	<libm-alias-ldouble.h>.
	(roundevenl): Define using libm_alias_ldouble.
	* sysdeps/ieee754/ldbl-128/s_roundl.c: Include
	<libm-alias-ldouble.h>.
	(roundl): Define using libm_alias_ldouble.
	* sysdeps/ieee754/ldbl-128/s_setpayloadl.c (setpayloadl): Define
	using libm_alias_ldouble.
	* sysdeps/ieee754/ldbl-128/s_setpayloadl_main.c: Include
	<libm-alias-ldouble.h>.
	* sysdeps/ieee754/ldbl-128/s_setpayloadsigl.c (setpayloadsigl):
	Define using libm_alias_ldouble.
	* sysdeps/ieee754/ldbl-128/s_sincosl.c: Include
	<libm-alias-ldouble.h>.
	(sincosl): Define using libm_alias_ldouble.
	* sysdeps/ieee754/ldbl-128/s_sinl.c: Include
	<libm-alias-ldouble.h>.
	(sinl): Define using libm_alias_ldouble.
	* sysdeps/ieee754/ldbl-128/s_tanhl.c: Include
	<libm-alias-ldouble.h>.
	(tanhl): Define using libm_alias_ldouble.
	* sysdeps/ieee754/ldbl-128/s_tanl.c: Include
	<libm-alias-ldouble.h>.
	(tanl): Define using libm_alias_ldouble.
	* sysdeps/ieee754/ldbl-128/s_totalorderl.c: Include
	<libm-alias-ldouble.h>.
	(totalorderl): Define using libm_alias_ldouble.
	* sysdeps/ieee754/ldbl-128/s_totalordermagl.c: Include
	<libm-alias-ldouble.h>.
	(totalordermagl): Define using libm_alias_ldouble.
	* sysdeps/ieee754/ldbl-128/s_truncl.c: Include
	<libm-alias-ldouble.h>.
	(truncl): Define using libm_alias_ldouble.
	* sysdeps/ieee754/ldbl-128/s_ufromfpl.c (ufromfpl): Define using
	libm_alias_ldouble.
	* sysdeps/ieee754/ldbl-128/s_ufromfpxl.c (ufromfpxl): Define using
	libm_alias_ldouble.
	* sysdeps/ieee754/ldbl-64-128/s_copysignl.c: Include
	<libm-alias-ldouble.h>.
	(weak_alias): Do not undefine and redefine.
	[IS_IN (libc)] (libm_alias_ldouble): Undefine and redefine.
	(copysignl): Define with long_double_symbol only if [IS_IN
	(libc)].
	* sysdeps/ieee754/ldbl-64-128/s_frexpl.c: Include
	<libm-alias-ldouble.h>.
	(weak_alias): Do not undefine and redefine.
	[IS_IN (libc)] (libm_alias_ldouble): Undefine and redefine.
	(frexpl): Define with long_double_symbol only if [IS_IN (libc)].
	* sysdeps/ieee754/ldbl-64-128/s_modfl.c: Include
	<libm-alias-ldouble.h>.
	(weak_alias): Do not undefine and redefine.
	[IS_IN (libc)] (libm_alias_ldouble): Undefine and redefine.
	(modfl): Define with long_double_symbol only if [IS_IN (libc)].
	* sysdeps/ieee754/ldbl-64-128/s_asinhl.c: Remove file.
	* sysdeps/ieee754/ldbl-64-128/s_atanl.c: Likewise.
	* sysdeps/ieee754/ldbl-64-128/s_cbrtl.c: Likewise.
	* sysdeps/ieee754/ldbl-64-128/s_ceill.c: Likewise.
	* sysdeps/ieee754/ldbl-64-128/s_cosl.c: Likewise.
	* sysdeps/ieee754/ldbl-64-128/s_erfl.c: Likewise.
	* sysdeps/ieee754/ldbl-64-128/s_expm1l.c: Likewise.
	* sysdeps/ieee754/ldbl-64-128/s_fabsl.c: Likewise.
	* sysdeps/ieee754/ldbl-64-128/s_floorl.c: Likewise.
	* sysdeps/ieee754/ldbl-64-128/s_fmal.c: Likewise.
	* sysdeps/ieee754/ldbl-64-128/s_llrintl.c: Likewise.
	* sysdeps/ieee754/ldbl-64-128/s_llroundl.c: Likewise.
	* sysdeps/ieee754/ldbl-64-128/s_logbl.c: Likewise.
	* sysdeps/ieee754/ldbl-64-128/s_lrintl.c: Likewise.
	* sysdeps/ieee754/ldbl-64-128/s_lroundl.c: Likewise.
	* sysdeps/ieee754/ldbl-64-128/s_nearbyintl.c: Likewise.
	* sysdeps/ieee754/ldbl-64-128/s_remquol.c: Likewise.
	* sysdeps/ieee754/ldbl-64-128/s_rintl.c: Likewise.
	* sysdeps/ieee754/ldbl-64-128/s_roundl.c: Likewise.
	* sysdeps/ieee754/ldbl-64-128/s_sincosl.c: Likewise.
	* sysdeps/ieee754/ldbl-64-128/s_sinl.c: Likewise.
	* sysdeps/ieee754/ldbl-64-128/s_tanhl.c: Likewise.
	* sysdeps/ieee754/ldbl-64-128/s_tanl.c: Likewise.
	* sysdeps/ieee754/ldbl-64-128/s_truncl.c: Likewise.
2017-10-06 17:45:05 +00:00
Joseph Myers 6dff198369 Remove redundant ldbl-64-128 files.
Various source files in ldbl-64-128 are redundant, because they wrap
files that no longer provide public symbols that need special
versioning (those symbols having moved to separate errno-setting
wrappers), or, in the case of w_scalblnl.c, because the type-generic
template now does everything required (it deals with symbol versioning
for use in libm, and this file is never built for libc anyway - the
compat scalbln* symbols in libc, as opposed to scalbn*, are only for
i386 and m68k and are aliases to the corresponding scalbn* symbols).
This patch removes those redundant files.

Tested with build-many-glibcs.py (for all ldbl-64-128 configurations)
that installed stripped shared libraries are unchanged by this patch.

	* sysdeps/ieee754/ldbl-64-128/e_ilogbl.c: Remove file.
	* sysdeps/ieee754/ldbl-64-128/s_log1pl.c: Likewise.
	* sysdeps/ieee754/ldbl-64-128/s_scalblnl.c: Likewise.
	* sysdeps/ieee754/ldbl-64-128/s_scalbnl.c: Likewise.
	* sysdeps/ieee754/ldbl-64-128/w_scalblnl.c: Likewise.
2017-10-06 15:02:12 +00:00
Joseph Myers 86f9568af6 Use libm_alias_ldouble for ldbl-96 functions.
This patch makes ldbl-96 functions use libm_alias_ldouble to define
function aliases.

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

	* sysdeps/ieee754/ldbl-96/s_asinhl.c: Include
	<libm-alias-ldouble.h>.
	(asinhl): Define using libm_alias_ldouble.
	* sysdeps/ieee754/ldbl-96/s_cbrtl.c: Include
	<libm-alias-ldouble.h>.
	(cbrtl): Define using libm_alias_ldouble.
	* sysdeps/ieee754/ldbl-96/s_copysignl.c: Include
	<libm-alias-ldouble.h>.
	(copysignl): Define using libm_alias_ldouble.
	* sysdeps/ieee754/ldbl-96/s_cosl.c: Include
	<libm-alias-ldouble.h>.
	(cosl): Define using libm_alias_ldouble.
	* sysdeps/ieee754/ldbl-96/s_erfl.c: Include
	<libm-alias-ldouble.h>.
	(erfl): Define using libm_alias_ldouble.
	(erfcl): Likewise.
	* sysdeps/ieee754/ldbl-96/s_fmal.c: Include
	<libm-alias-ldouble.h>.
	(fmal): Define using libm_alias_ldouble.
	* sysdeps/ieee754/ldbl-96/s_frexpl.c: Include
	<libm-alias-ldouble.h>.
	(frexpl): Define using libm_alias_ldouble.
	* sysdeps/ieee754/ldbl-96/s_fromfpl.c (fromfpl): Define using
	libm_alias_ldouble.
	* sysdeps/ieee754/ldbl-96/s_fromfpl_main.c: Include
	<libm-alias-ldouble.h>.
	* sysdeps/ieee754/ldbl-96/s_fromfpxl.c (fromfpxl): Define using
	libm_alias_ldouble.
	* sysdeps/ieee754/ldbl-96/s_getpayloadl.c: Include
	<libm-alias-ldouble.h>.
	(getpayloadl): Define using libm_alias_ldouble.
	* sysdeps/ieee754/ldbl-96/s_llrintl.c: Include
	<libm-alias-ldouble.h>.
	(llrintl): Define using libm_alias_ldouble.
	* sysdeps/ieee754/ldbl-96/s_llroundl.c: Include
	<libm-alias-ldouble.h>.
	(llroundl): Define using libm_alias_ldouble.
	* sysdeps/ieee754/ldbl-96/s_lrintl.c: Include
	<libm-alias-ldouble.h>.
	(lrintl): Define using libm_alias_ldouble.
	* sysdeps/ieee754/ldbl-96/s_lroundl.c: Include
	<libm-alias-ldouble.h>.
	(lroundl): Define using libm_alias_ldouble.
	* sysdeps/ieee754/ldbl-96/s_modfl.c: Include
	<libm-alias-ldouble.h>.
	(modfl): Define using libm_alias_ldouble.
	* sysdeps/ieee754/ldbl-96/s_nextupl.c: Include
	<libm-alias-ldouble.h>.
	(nextupl): Define using libm_alias_ldouble.
	* sysdeps/ieee754/ldbl-96/s_remquol.c: Include
	<libm-alias-ldouble.h>.
	(remquol): Define using libm_alias_ldouble.
	* sysdeps/ieee754/ldbl-96/s_roundevenl.c: Include
	<libm-alias-ldouble.h>.
	(roundevenl): Define using libm_alias_ldouble.
	* sysdeps/ieee754/ldbl-96/s_roundl.c: Include
	<libm-alias-ldouble.h>.
	(roundl): Define using libm_alias_ldouble.
	* sysdeps/ieee754/ldbl-96/s_setpayloadl.c (setpayloadl): Define
	using libm_alias_ldouble.
	* sysdeps/ieee754/ldbl-96/s_setpayloadl_main.c: Include
	<libm-alias-ldouble.h>.
	* sysdeps/ieee754/ldbl-96/s_setpayloadsigl.c: Include
	<libm-alias-ldouble.h>.
	(setpayloadsigl): Define using libm_alias_ldouble.
	* sysdeps/ieee754/ldbl-96/s_sincosl.c: Include
	<libm-alias-ldouble.h>.
	(sincosl): Define using libm_alias_ldouble.
	* sysdeps/ieee754/ldbl-96/s_sinl.c: Include
	<libm-alias-ldouble.h>.
	(sinl): Define using libm_alias_ldouble.
	* sysdeps/ieee754/ldbl-96/s_tanhl.c: Include
	<libm-alias-ldouble.h>.
	(tanhl): Define using libm_alias_ldouble.
	* sysdeps/ieee754/ldbl-96/s_tanl.c: Include
	<libm-alias-ldouble.h>.
	(tanl): Define using libm_alias_ldouble.
	* sysdeps/ieee754/ldbl-96/s_totalorderl.c: Include
	<libm-alias-ldouble.h>.
	(totalorderl): Define using libm_alias_ldouble.
	* sysdeps/ieee754/ldbl-96/s_totalordermagl.c: Include
	<libm-alias-ldouble.h>.
	(totalordermagl): Define using libm_alias_ldouble.
	* sysdeps/ieee754/ldbl-96/s_ufromfpl.c (ufromfpl): Define using
	libm_alias_ldouble.
	* sysdeps/ieee754/ldbl-96/s_ufromfpxl.c (ufromfpxl): Define using
	libm_alias_ldouble.
2017-10-05 21:13:40 +00:00