platform/upstream/glibc.git
7 years agoMove -U__LIBC_INTERNAL_MATH_INLINES to test-math-inline.h.
Joseph Myers [Thu, 9 Feb 2017 17:32:48 +0000 (17:32 +0000)]
Move -U__LIBC_INTERNAL_MATH_INLINES to test-math-inline.h.

The libm tests of inline functions undefine __NO_MATH_INLINES (from
math-CPPFLAGS) in test-math-inline.h, but __LIBC_INTERNAL_MATH_INLINES
via -U options in the makefile.

This is an odd inconsistency between the handling of the two macros.
It also depends on the ordering (in compilation commands) of the
various variables providing compiler options (which I think is why
it's using CPPFLAGS-*.c instead of CFLAGS-*.c).

This patch moves the undefine to test-math-inline.h, so improving
consistency and eliminating the dependency on the order in which
variables go in the compilation commands.  The CPPFLAGS-*.c variables
are renamed to CFLAGS-*.c, matching those for the non-inline libm
function tests.

By moving the -U option to the header file, this should ensure that
ordering issues don't arise with a subsequent move of the options to
these tests to target-specific CFLAGS += ... variable settings (for
when tests for each function are build separately and so compilation
options need setting for many more makefile targets, for which
target-specific variable settings seem to be the most convenient form
to generate with iterators).

Tested for x86_64.

* math/test-math-inline.h (__LIBC_INTERNAL_MATH_INLINES): Undefine
macro.
* math/Makefile (CPPFLAGS-test-ifloat.c): Rename to ...
(CFLAGS-test-ifloat.c): ... this.  Remove
-U__LIBC_INTERNAL_MATH_INLINES.
* math/Makefile (CPPFLAGS-test-idouble.c): Rename to ...
(CFLAGS-test-idouble.c): ... this.  Remove
-U__LIBC_INTERNAL_MATH_INLINES.
* math/Makefile (CPPFLAGS-test-ildouble.c): Rename to ...
(CFLAGS-test-ildouble.c): ... this.  Remove
-U__LIBC_INTERNAL_MATH_INLINES.

7 years agoBuild most libm-test support code once per type.
Joseph Myers [Wed, 8 Feb 2017 21:11:49 +0000 (21:11 +0000)]
Build most libm-test support code once per type.

libm-test-driver.c contains various functions used in the course of
libm testing, which are built as part of each test using this
machinery.

Currently, these functions get built for three tests for each type
(e.g. test-float, test-ifloat, test-float-finite), plus the vector
function tests.  All these tests are huge and thus slow to build; the
output of gen-libm-test.pl totals around 40 MB across all functions.
To make the individual tests built from the Makefile smaller, it makes
sense to split these tests up so the tests for each function are built
separately (thus, three tests for each (function, type) pair, plus
vector tests built only for functions that actually have vector
versions).  This improves parallelism and means that if tests fail,
the summary of failed tests makes it more obvious where the problem
might be without needing to look in the .out files to see which
functions' tests failed (though architecture maintainers still need to
keep libm-test-ulps up to date to avoid spurious failures of little
interest).

Simply including libm-test-driver.c as-is in such individual-function
tests does not work because of unused static check_* functions (those
functions only being used for the types of the outputs of the function
under test).  It also means the common code gets built over 1000 times
instead of nine (plus vector tests).  To avoid that issue, this patch
splits out the bulk of the libm-test-driver.c code into a separate
file libm-test-support.c (with a few functions made non-static).  That
separate file is built only once for each floating-point type (so at
present three times, or twice on architectures with long double =
double).  Definitions needed in both libm-test-support.c and
libm-test-driver.c go in libm-test-support.h (it's possible some of
those are in fact only needed in one of the two files).
libm-test-driver.c keeps definitions of a limited number of variables
used to configure how libm-test-support.c behaves, various macros and
structures needed by individual-function tests, and the main function.

This move is also consistent in spirit with the move away from
test-skeleton.c having all the test support code, to a small
support/test-driver.c included in individual tests with most of the
code built separately.

Tested for x86_64 and x86.

* math/libm-test-support.c: New file.  Content from
math/libm-test-driver.c.
* math/libm-test-support.h: Likewise.
* math/libm-test-support-double.c: New file.
* math/libm-test-support-float.c: Likewise.
* math/libm-test-support-ldouble.c: Likewise.
* math/libm-test-driver.c: Remove main comment and header
includes.  Include libm-test-support.h.
[!_GNU_SOURCE] (_GNU_SOURCE): Do not define.
(flag_test_errno): Remove static.
(flag_test_exceptions): Likewise.
(flag_test_finite): Likewise.
(flag_test_inline): Likewise.
(flag_test_mathvec): Likewise.
(test_msg): Likewise.
(NO_EXCEPTION): Remove.
(INVALID_EXCEPTION): Likewise.
(DIVIDE_BY_ZERO_EXCEPTION): Likewise.
(OVERFLOW_EXCEPTION): Likewise.
(UNDERFLOW_EXCEPTION): Likewise.
(INEXACT_EXCEPTION): Likewise.
(INVALID_EXCEPTION_OK): Likewise.
(DIVIDE_BY_ZERO_EXCEPTION_OK): Likewise.
(OVERFLOW_EXCEPTION_OK): Likewise.
(UNDERFLOW_EXCEPTION_OK): Likewise.
(NO_INEXACT_EXCEPTION): Likewise.
(EXCEPTIONS_OK): Likewise.
(IGNORE_ZERO_INF_SIGN): Likewise.
(TEST_NAN_SIGN): Likewise.
(TEST_NAN_PAYLOAD): Likewise.
(NO_TEST_INLINE): Likewise.
(XFAIL_TEST): Likewise.
(ERRNO_UNCHANGED): Likewise.
(ERRNO_EDOM): Likewise.
(ERRNO_ERANGE): Likewise.
(IGNORE_RESULT): Likewise.
(NON_FINITE): Likewise.
(TEST_SNAN): Likewise.
(NO_TEST_MATHVEC): Likewise.
(__CONCATX): Likewise.
(TYPE_MIN): Likewise.
(TYPE_TRUE_MIN): Likewise.
(TYPE_MAX): Likewise.
(MIN_EXP): Likewise.
(MAX_EXP): Likewise.
(MANT_DIG): Likewise.
(FSTR_MAX): Likewise.
(ulp_idx): Likewise.
(qtype_str): Remove static.
(TEST_COND_binary32): Remove.
(TEST_COND_binary64): Likewise.
(TEST_COND_binary128): Likewise.
(TEST_COND_ibm128): Likewise.
(TEST_COND_intel96): Likewise.
(TEST_COND_m68k96): Likewise.
(TEST_COND_ibm128_libgcc): Likewise.
(XFAIL_IBM128_LIBGCC): Likewise.
(PAYLOAD_DIG): Likewise.
(UNDERFLOW_EXCEPTION_FLOAT): Likewise.
(UNDERFLOW_EXCEPTION_OK_FLOAT): Likewise.
(UNDERFLOW_EXCEPTION_DOUBLE): Likewise.
(UNDERFLOW_EXCEPTION_OK_DOUBLE): Likewise.
(UNDERFLOW_EXCEPTION_LDOUBLE_IBM): Likewise.
(UNDERFLOW_EXCEPTION_BEFORE_ROUNDING): Likewise.
(TEST_COND_long32): Likewise.
(TEST_COND_long64): Likewise.
(TEST_COND_before_rounding): Likewise.
(TEST_COND_after_rounding): Likewise.
(ulps_file_name): Likewise.
(ulps_file): Likewise.
(output_ulps): Likewise.
(output_dir): Likewise.
(noErrors): Likewise.
(noTests): Likewise.
(noExcTests): Likewise.
(noErrnoTests): Likewise.
(verbose): Likewise.
(output_max_error): Likewise.
(output_points): Likewise.
(ignore_max_ulp): Likewise.
(max_error): Likewise.
(real_max_error): Likewise.
(imag_max_error): Likewise.
(prev_max_error): Likewise.
(prev_real_max_error): Likewise.
(prev_imag_max_error): Likewise.
(max_valid_error): Likewise.
(TYPE_DECIMAL_DIG): Likewise.
(TYPE_HEX_DIG): Likewise.
(fmt_ftostr): Likewise.
(compare_ulp_data): Likewise.
(find_ulps): Likewise.
(init_max_error): Likewise.
(set_max_error): Likewise.
(print_float): Likewise.
(print_screen): Likewise.
(print_screen_max_error): Likewise.
(update_stats): Likewise.
(print_function_ulps): Likewise.
(print_complex_function_ulps): Likewise.
(fpstack_test): Likewise.
(print_max_error): Likewise.
(print_complex_max_error): Likewise.
(test_single_exception): Likewise.
(test_exceptions): Likewise.
(test_single_errno): Likewise.
(test_errno): Likewise.
(ULPDIFF): Likewise.
(ulp): Likewise.
(check_float_internal): Likewise.
(check_float): Likewise.
(check_complex): Likewise.
(check_int): Likewise.
(check_long): Likewise.
(check_bool): Likewise.
(check_longlong): Likewise.
(check_intmax_t): Likewise.
(check_uintmax_t): Likewise.
(enable_test): Likewise.
(matherr): Likewise.
(initialize): Likewise.
(options): Likewise.
(doc): Remove static.
(argp): Likewise.
(parse_opt): Remove.
(check_ulp): Likewise.
(libm_test_init): Likewise.
(libm_test_finish): Likewise.
* math/Makefile (libm-test-support): New variable.
(test-extras): Add libm-test-support files.
(extra-test-objs): Likewise.
(CFLAGS-libm-test-support-float.c): New variable.
(CFLAGS-libm-test-support-double.c): Likewise.
(CFLAGS-libm-test-support-ldouble.c): Likewise.
($(addprefix $(objpfx),$(libm-tests)): Depend on appropriate
libm-test-support objects.

7 years agoMove w_exp to libm-compat-call-auto
Gabriel F. T. Gomes [Mon, 30 Jan 2017 19:01:05 +0000 (17:01 -0200)]
Move w_exp to libm-compat-call-auto

This patch adds the "_compat" suffix to the wrappers of the function
exp, which use _LIB_VERSION / matherr / __kernel_standard
functionality.

Tested for powerpc64le, s390, and x86_64.

* math/Makefile (libm-calls): Move w_exp...
(libm-compat-calls-auto): Here.

* math/w_expl.c: Add suffix "_compat" to filename.
* sysdeps/ia64/fpu/w_expl.c: Likewise.
* sysdeps/ia64/fpu/w_expf.c: Likewise.
* sysdeps/ia64/fpu/w_exp.c: Likewise.
* sysdeps/ieee754/dbl-64/w_exp.c: Likewise.
* sysdeps/ieee754/flt-32/w_expf.c: Likewise.
* sysdeps/ieee754/ldbl-128/w_expl.c: Likewise.
* sysdeps/ieee754/ldbl-128ibm/w_expl.c: Likewise.
* sysdeps/ieee754/ldbl-96/w_expl.c: Likewise.

* math/w_expl_compat.c: New file, copied from above.
* sysdeps/ia64/fpu/w_exp_compat.c: Likewise.
* sysdeps/ia64/fpu/w_expf_compat.c: Likewise.
* sysdeps/ia64/fpu/w_expl_compat.c: Likewise.
* sysdeps/ieee754/dbl-64/w_exp_compat.c: Likewise.
* sysdeps/ieee754/flt-32/w_expf_compat.c: Likewise.
* sysdeps/ieee754/ldbl-128/w_expl_compat.c: Likewise.
* sysdeps/ieee754/ldbl-128ibm/w_expl_compat.c: Likewise.
* sysdeps/ieee754/ldbl-96/w_expl_compat.c: Likewise.

* sysdeps/ieee754/ldbl-64-128/w_expl.c: Add suffix "_compat"
to filename.
* sysdeps/ieee754/ldbl-opt/w_exp.c: Likewise.

* sysdeps/ieee754/ldbl-64-128/w_expl_compat.c: New file,
copied from above and adjusted for the new filenames.
* sysdeps/ieee754/ldbl-opt/w_exp_compat.c: Likewise.

7 years agoMove w_lgamma to libm-compat-calls-auto
Gabriel F. T. Gomes [Wed, 21 Dec 2016 11:33:32 +0000 (09:33 -0200)]
Move w_lgamma to libm-compat-calls-auto

This patch adds the suffix "_compat2" to the wrappers for lgamma,
which use _LIB_VERSION / matherr / __kernel_standard functionality.
The suffix "_compat2" is used because the suffix "_compat" is already
used.

Tested for powerpc64le, s390, and x86_64.

* math/Makefile (libm-calls): Move w_lgammaF...
(libm-compat-calls-auto): Here.

* math/w_lgamma.c: Add suffix "_compat2" to filename.
* math/w_lgammaf.c: Likewise.
* math/w_lgammal.c: Likewise.

* math/w_lgamma_compat2.c: New file, copied from above.
* math/w_lgammaf_compat2.c: Likewise.
* math/w_lgammal_compat2.c: Likewise.

7 years agoMove w_lgamma_r to libm-compat-calls-auto
Gabriel F. T. Gomes [Wed, 21 Dec 2016 12:20:08 +0000 (10:20 -0200)]
Move w_lgamma_r to libm-compat-calls-auto

This patch adds the suffix "_compat" to lgamma_r wrappers and make
some adjustments to #includes and Makefiles.  This is a step towards
deprecation of wrappers that use _LIB_VERSION / matherr /
__kernel_standard functionality.

Tested for powerpc64le, s390, and x86_64.

* math/Makefile (libm-calls): Move w_lgammaF_r...
(libm-compat-calls-auto): Here.

* math/w_lgamma_r.c: Add suffix "_compat" to filename.
* math/w_lgammaf_r.c: Likewise.
* math/w_lgammal_r.c: Likewise.
* sysdeps/ia64/fpu/w_lgammal_r.c: Likewise.
* sysdeps/ia64/fpu/w_lgammaf_r.c: Likewise.
* sysdeps/ia64/fpu/w_lgamma_r.c: Likewise.

* math/w_lgamma_r_compat.c: New file, copied from above.
* math/w_lgammaf_r_compat.c: Likewise.
* math/w_lgammal_r_compat.c: Likewise.
* sysdeps/ia64/fpu/w_lgamma_r_compat.c: Likewise.
* sysdeps/ia64/fpu/w_lgammaf_r_compat.c: Likewise.
* sysdeps/ia64/fpu/w_lgammal_r_compat.c: Likewise.

* sysdeps/ieee754/ldbl-opt/w_lgamma_r.c: Add suffix "_compat"
to filename.
* sysdeps/ieee754/ldbl-opt/w_lgammal_r.c: Likewise.

* sysdeps/ieee754/ldbl-opt/w_lgamma_r_compat.c: New file
copied from above and adjusted for the new filenames.
* sysdeps/ieee754/ldbl-opt/w_lgammal_r_compat.c: Likewise.

7 years agoaarch64: fix errno address calculation in SYSCALL_ERROR_HANDLER
Adhemerval Zanella [Wed, 8 Feb 2017 18:30:43 +0000 (16:30 -0200)]
aarch64: fix errno address calculation in SYSCALL_ERROR_HANDLER

This patch fixes the last regression in LTP lite scenario (mmap16) comparing
to lp64 in my source trees [1, 2]. The fix has been suggested back in 2015 [3]
but was never applied.

Checked on aarch64-linux-gnu.

* sysdeps/unix/sysv/linux/aarch64/sysdep.h: use PTR_REG() for offset
calculation in SYSCALL_ERROR_HANDLER().

[1] https://github.com/norov/glibc/tree/dev9
[2] https://github.com/norov/linux/tree/ilp32-20170203
[3] https://sourceware.org/ml/libc-alpha/2015-03/msg00587.html

7 years agoFix a typo in the manual.
Rical Jasan [Wed, 8 Feb 2017 09:34:12 +0000 (01:34 -0800)]
Fix a typo in the manual.

I only caught this because I saw a file in manual/ change.  Oh, the
irony...  and thank you!

* manual/contrib.texi: Fix typo.

7 years agoFix getting tunable values on big-endian (BZ #21109)
Siddhesh Poyarekar [Wed, 8 Feb 2017 05:48:23 +0000 (11:18 +0530)]
Fix getting tunable values on big-endian (BZ #21109)

The code to set value passed a tunable_val_t, which when cast to
int32_t on big-endian gives the wrong value.  Instead, use
tunable_val_t.numval instead, which can then be safely cast into
int32_t.

7 years agoAdd Linux PTRACE_EVENT_STOP
Kir Kolyshkin [Tue, 7 Feb 2017 08:06:05 +0000 (00:06 -0800)]
Add Linux PTRACE_EVENT_STOP

Add PTRACE_EVENT_STOP value to Linux's sys/ptrace.h, modify related
comments accordingly.

This constant initially appeared in Linux 3.1 (kernel commit 3544d72a,
"ptrace: implement PTRACE_SEIZE") but its value has changed later
in Linux 3.4 (kernel commit 5cdf389a, "ptrace: renumber
PTRACE_EVENT_STOP so that future new options and events can match").

The comment is also taken from the above commit.

This constant is used by e.g. strace, CRIU, Mozilla RR.

* sysdeps/unix/sysv/linux/aarch64/sys/ptrace.h (__ptrace_eventcodes):
Add PTRACE_EVENT_STOP.
* sysdeps/unix/sysv/linux/ia64/sys/ptrace.h: Likewise.
* sysdeps/unix/sysv/linux/powerpc/sys/ptrace.h: Likewise.
* sysdeps/unix/sysv/linux/s390/sys/ptrace.h: Likewise.
* sysdeps/unix/sysv/linux/sparc/sys/ptrace.h: Likewise.
* sysdeps/unix/sysv/linux/sys/ptrace.h: Likewise.
* sysdeps/unix/sysv/linux/tile/sys/ptrace.h: Likewise.

7 years agoClean up libm vector tests exception test disabling.
Joseph Myers [Tue, 7 Feb 2017 23:06:19 +0000 (23:06 +0000)]
Clean up libm vector tests exception test disabling.

The libm vector tests disable tests of exception raising via defining
macros EXCEPTION_TESTS_float and EXCEPTION_TESTS_double to 0 in the
headers for individual vector lengths.

As EXCEPTION_TESTS is used in code in libm-test-driver.c that is
otherwise ready to be built only once per type, this is not a good
idea; it's better to define TEST_EXCEPTIONS appropriately so that
flag_test_exceptions then gets initialized appropriately.
Furthermore, it's better to do this just once, in test-math-vector.h,
since there is no actual dependence on the vector length or type.
This patch duly makes that change.

Tested for x86_64.

* math/test-math-finite.h (TEST_EXCEPTIONS): New macro.
* math/test-math-no-finite.h (TEST_EXCEPTIONS): Likewise.
* math/test-math-vector.h (TEST_EXCEPTIONS): Likewise.
* math/test-math-no-inline.h (TEST_EXCEPTIONS): Remove macro.
* math/test-double-vlen2.h (EXCEPTION_TESTS_double): Likewise.
* math/test-double-vlen4.h (EXCEPTION_TESTS_double): Likewise.
* math/test-double-vlen8.h (EXCEPTION_TESTS_double): Likewise.
* math/test-float-vlen4.h (EXCEPTION_TESTS_float): Likewise.
* math/test-float-vlen8.h (EXCEPTION_TESTS_float): Likewise.
* math/test-float-vlen16.h (EXCEPTION_TESTS_float): Likewise.

7 years agoFix powf inaccuracy (bug 21112).
Joseph Myers [Tue, 7 Feb 2017 17:15:47 +0000 (17:15 +0000)]
Fix powf inaccuracy (bug 21112).

Bug 21112 reports a case where powf is substantially inaccurate.  This
results from a multiplication where cp_h*p_h is required to be exact,
and p_h is masked to have only 12 leading nonzero bits in its
mantissa, but the value of cp_h has the 13th bit nonzero, leading to
inexact multiplication results in some cases that can result in large
errors in the final result of powf.  This patch fixes this by using a
value of cp_h correctly rounded to nearest to 12 bits, with a
corresponding updated value of cp_l.

Tested for x86_64 and x86.

[BZ #21112]
* sysdeps/ieee754/flt-32/e_powf.c (cp_h): Use value with trailing
12 bits zero.
(cp_l): Update for new value of cp_h.
* math/auto-libm-test-in: Add another test of pow.
* math/auto-libm-test-out-pow: Regenerated.

7 years agoFix typo in manual
Siddhesh Poyarekar [Tue, 7 Feb 2017 13:17:30 +0000 (18:47 +0530)]
Fix typo in manual

Apparently, implementating is not a word; who would have thunk it...

7 years agopowerpc: Set minimum kernel version for powerpc64le
Rajalakshmi Srinivasaraghavan [Tue, 7 Feb 2017 05:19:47 +0000 (10:49 +0530)]
powerpc: Set minimum kernel version for powerpc64le

This patch sets the minimum kernel version required for ppc64le as 3.10.0.

7 years agopowerpc: Use latest optimizations for internal function calls
Rajalakshmi Srinivasaraghavan [Tue, 7 Feb 2017 05:12:06 +0000 (10:42 +0530)]
powerpc: Use latest optimizations for internal function calls

Some of the power8 strings optimizations are not updated to use the latest
version of other string optimizations

7 years agopowerpc: Improve strcmp performance for shorter strings
Rajalakshmi Srinivasaraghavan [Tue, 7 Feb 2017 05:10:26 +0000 (10:40 +0530)]
powerpc: Improve strcmp performance for shorter strings

For strings >16B and <32B existing algorithm takes more time than default
implementation when strings are placed closed to end of page. This is due
to byte by byte access for handling page cross. This is improved by
following >32B code path where the address is adjusted to aligned memory
before doing load doubleword operation instead of loading bytes.

Tested on powerpc64 and powerpc64le.

7 years agoRefactor some code in libm-test-driver.c.
Joseph Myers [Mon, 6 Feb 2017 23:23:54 +0000 (23:23 +0000)]
Refactor some code in libm-test-driver.c.

Splitting libm tests by function will mean about a thousand such tests
built separately instead of the present nine (plus vector variants).

When this is done, it's desirable to avoid needing to build all the
test infrastructure so many times.  Also, simply including
libm-test-driver.c as-is into per-function tests doesn't actually
work, because the various check_* functions are not used by all tests
and so generate errors for unused static functions.

Although some pieces of infrastructure depend on the type being tested
while others don't, building once per type seems the simplest
approach.  This patch makes changes to libm-test-driver.c in
preparation for that.  Various cases where functions directly use
macros such as TEST_ERRNO (that may vary depending on things other
than the type under test) are changed to use variables initialized
using those macros, while most of the code in main is moved out to
functions libm_test_init and libm_test_fini.

The idea is that all the functions in libm-test-driver.c will be moved
out in a subsequent patch to be built once per type (and be no longer
static when they are used from per-function tests), while
libm-test-driver.c remains containing definitions of various variables
(no longer static, of course, because they'll be used in the per-type
code) and the main function.  Declarations / macros relevant to both
the once-per-type code and the per-function tests will go in a shared
header.

Tested for x86_64.

* math/libm-test-driver.c (flag_test_errno): New variable.
(flag_test_exceptions): Likewise.
(flag_test_finite): Likewise.
(flag_test_inline): Likewise.
(flag_test_mathvec): Likewise.
(test_msg): Likewise.
(ulp_idx): Likewise.
(qtype_str): Likewise.
(ULP_IDX): Remove macro.
(QTYPE_STR): Likewise.
(find_ulps): Use ulp_idx not ULP_IDX.
(print_function_ulps): Use qtype_str, printed with %s, not
QTYPE_STR, printed with concatentation to format string.
(print_complex_function_ulps): Likewise.
(test_exceptions): Use flag_test_exceptions not TEST_EXCEPTIONS.
(test_errno): Use flag_test_errno not TEST_ERRNO.
(enable_test): Use flag_test_inline, flag_test_finite and
flag_test_mathvec instead of TEST_INLINE, TEST_FINITE and
TEST_MATHVEC.
(libm_test_init): New function.  Factored out of main.
(libm_test_finish): Likewise.
(main): Call libm_test_init and libm_test_finish and move most
code to those functions.

7 years agoMove libm-test TEST_MSG definitions to libm-test-driver.c.
Joseph Myers [Mon, 6 Feb 2017 23:07:22 +0000 (23:07 +0000)]
Move libm-test TEST_MSG definitions to libm-test-driver.c.

Various files using the libm-test infrastructure define a TEST_MSG
macro with an informal description of the tests being run.

This patch moves this macro to libm-test-driver.c (the definition
depending on other macros already defined), so files specific to
(type, choice of whether to test inline functions or finite-math-only
functions, vector length) no longer need to define it.  This is in
preparation for replacing files such as test-float.c with per-function
test-float-<func>.c etc. automatically generated in the build
directory when tests are run.

Tested for x86_64.

* math/libm-test-driver.c (STRX): New macro.
(STR): Likewise.
(STR_FLOAT): Likewise.
(STR_VEC_LEN): Likewise.
(TEST_MSG): Likewise.  Define here instead of expecting to be
defined by including file.
* math/test-double-finite.c (TEST_MSG): Remove macro.
* math/test-double-vlen2.h (TEST_MSG): Likewise.
* math/test-double-vlen4.h (TEST_MSG): Likewise.
* math/test-double-vlen8.h (TEST_MSG): Likewise.
* math/test-double.c (TEST_MSG): Likewise.
* math/test-float-finite.c (TEST_MSG): Likewise.
* math/test-float-vlen16.h (TEST_MSG): Likewise.
* math/test-float-vlen4.h (TEST_MSG): Likewise.
* math/test-float-vlen8.h (TEST_MSG): Likewise.
* math/test-float.c (TEST_MSG): Likewise.
* math/test-idouble.c (TEST_MSG): Likewise.
* math/test-ifloat.c (TEST_MSG): Likewise.
* math/test-ildouble.c (TEST_MSG): Likewise.
* math/test-ldouble-finite.c (TEST_MSG): Likewise.
* math/test-ldouble.c (TEST_MSG): Likewise.

7 years agoSplit libm-test.inc by function.
Joseph Myers [Mon, 6 Feb 2017 18:57:25 +0000 (18:57 +0000)]
Split libm-test.inc by function.

Continuing the process of splitting up libm tests into more reasonably
sized units, this patch splits libm-test.inc into 121 separate
libm-test-<function>.inc files, one per array of test data.  (There
are 126 libm *_test functions, but five of those are for functions
that are aliases for test purposes and so share arrays of test data.)

In the present patch, the 121 files get processed separately by
gen-libm-test.pl, each using only the auto-libm-test-out-<function>
file that is relevant (/dev/null for functions not using
auto-libm-test-* at all).  This effectively eliminates the
serialization on running gen-libm-test.pl.  However, the resulting .c
files still all get #included together, so compiling the limited
number of libm tests using libm-test.inc may still act as a
serialization point (the compilations still all have 40 MB of code to
process).  libm-test.inc doesn't actually have anything in it any more
that needs gen-libm-test.pl processing, but is left as a .inc file
that gets processed to produce a .c file, rather than being renamed,
since the intent of this patch is as an intermediate step before
libm-test.inc gets removed and tests get compiled separately for each
function being tested.

Tested for x86_64.

* math/libm-test.inc: Move all tests of individual functions to
libm-test-*.inc and #include libm-test-*.c files.
(acos_test_data): Remove.
(acos_test): Likewise.
(acosh_test_data): Likewise.
(acosh_test): Likewise.
(asin_test_data): Likewise.
(asin_test): Likewise.
(asinh_test_data): Likewise.
(asinh_test): Likewise.
(atan_test_data): Likewise.
(atan_test): Likewise.
(atanh_test_data): Likewise.
(atanh_test): Likewise.
(atan2_test_data): Likewise.
(atan2_test): Likewise.
(cabs_test_data): Likewise.
(cabs_test): Likewise.
(cacos_test_data): Likewise.
(cacos_test): Likewise.
(cacosh_test_data): Likewise.
(cacosh_test): Likewise.
(canonicalize_test_data): Likewise.
(canonicalize_test): Likewise.
(carg_test_data): Likewise.
(carg_test): Likewise.
(casin_test_data): Likewise.
(casin_test): Likewise.
(casinh_test_data): Likewise.
(casinh_test): Likewise.
(catan_test_data): Likewise.
(catan_test): Likewise.
(catanh_test_data): Likewise.
(catanh_test): Likewise.
(cbrt_test_data): Likewise.
(cbrt_test): Likewise.
(ccos_test_data): Likewise.
(ccos_test): Likewise.
(ccosh_test_data): Likewise.
(ccosh_test): Likewise.
(ceil_test_data): Likewise.
(ceil_test): Likewise.
(cexp_test_data): Likewise.
(cexp_test): Likewise.
(cimag_test_data): Likewise.
(cimag_test): Likewise.
(clog_test_data): Likewise.
(clog_test): Likewise.
(clog10_test_data): Likewise.
(clog10_test): Likewise.
(conj_test_data): Likewise.
(conj_test): Likewise.
(copysign_test_data): Likewise.
(copysign_test): Likewise.
(cos_test_data): Likewise.
(cos_test): Likewise.
(cosh_test_data): Likewise.
(cosh_test): Likewise.
(cpow_test_data): Likewise.
(cpow_test): Likewise.
(cproj_test_data): Likewise.
(cproj_test): Likewise.
(creal_test_data): Likewise.
(creal_test): Likewise.
(csin_test_data): Likewise.
(csin_test): Likewise.
(csinh_test_data): Likewise.
(csinh_test): Likewise.
(csqrt_test_data): Likewise.
(csqrt_test): Likewise.
(ctan_test_data): Likewise.
(ctan_test): Likewise.
(ctanh_test_data): Likewise.
(ctanh_test): Likewise.
(erf_test_data): Likewise.
(erf_test): Likewise.
(erfc_test_data): Likewise.
(erfc_test): Likewise.
(exp_test_data): Likewise.
(exp_test): Likewise.
(exp10_test_data): Likewise.
(exp10_test): Likewise.
(pow10_test): Likewise.
(exp2_test_data): Likewise.
(exp2_test): Likewise.
(expm1_test_data): Likewise.
(expm1_test): Likewise.
(fabs_test_data): Likewise.
(fabs_test): Likewise.
(fdim_test_data): Likewise.
(fdim_test): Likewise.
(floor_test_data): Likewise.
(floor_test): Likewise.
(fma_test_data): Likewise.
(fma_test): Likewise.
(fmax_test_data): Likewise.
(fmax_test): Likewise.
(fmaxmag_test_data): Likewise.
(fmaxmag_test): Likewise.
(fmin_test_data): Likewise.
(fmin_test): Likewise.
(fminmag_test_data): Likewise.
(fminmag_test): Likewise.
(fmod_test_data): Likewise.
(fmod_test): Likewise.
(fpclassify_test_data): Likewise.
(fpclassify_test): Likewise.
(frexp_test_data): Likewise.
(frexp_test): Likewise.
(fromfp_test_data): Likewise.
(fromfp_test): Likewise.
(fromfpx_test_data): Likewise.
(fromfpx_test): Likewise.
(getpayload_test_data): Likewise.
(getpayload_test): Likewise.
(hypot_test_data): Likewise.
(hypot_test): Likewise.
(ilogb_test_data): Likewise.
(ilogb_test): Likewise.
(iscanonical_test_data): Likewise.
(iscanonical_test): Likewise.
(iseqsig_test_data): Likewise.
(iseqsig_test): Likewise.
(isfinite_test_data): Likewise.
(isfinite_test): Likewise.
(finite_test): Likewise.
(isgreater_test_data): Likewise.
(isgreater_test): Likewise.
(isgreaterequal_test_data): Likewise.
(isgreaterequal_test): Likewise.
(isinf_test_data): Likewise.
(isinf_test): Likewise.
(isless_test_data): Likewise.
(isless_test): Likewise.
(islessequal_test_data): Likewise.
(islessequal_test): Likewise.
(islessgreater_test_data): Likewise.
(islessgreater_test): Likewise.
(isnan_test_data): Likewise.
(isnan_test): Likewise.
(isnormal_test_data): Likewise.
(isnormal_test): Likewise.
(issignaling_test_data): Likewise.
(issignaling_test): Likewise.
(issubnormal_test_data): Likewise.
(issubnormal_test): Likewise.
(isunordered_test_data): Likewise.
(isunordered_test): Likewise.
(iszero_test_data): Likewise.
(iszero_test): Likewise.
(j0_test_data): Likewise.
(j0_test): Likewise.
(j1_test_data): Likewise.
(j1_test): Likewise.
(jn_test_data): Likewise.
(jn_test): Likewise.
(lgamma_test_data): Likewise.
(lgamma_test): Likewise.
(gamma_test): Likewise.
(llogb_test_data): Likewise.
(llogb_test): Likewise.
(lrint_test_data): Likewise.
(lrint_test): Likewise.
(llrint_test_data): Likewise.
(llrint_test): Likewise.
(log_test_data): Likewise.
(log_test): Likewise.
(log10_test_data): Likewise.
(log10_test): Likewise.
(log1p_test_data): Likewise.
(log1p_test): Likewise.
(log2_test_data): Likewise.
(log2_test): Likewise.
(logb_test_data): Likewise.
(logb_test): Likewise.
(lround_test_data): Likewise.
(lround_test): Likewise.
(llround_test_data): Likewise.
(llround_test): Likewise.
(modf_test_data): Likewise.
(modf_test): Likewise.
(nearbyint_test_data): Likewise.
(nearbyint_test): Likewise.
(nextafter_test_data): Likewise.
(nextafter_test): Likewise.
(nextup_test_data): Likewise.
(nextup_test): Likewise.
(nextdown_test_data): Likewise.
(nextdown_test): Likewise.
(nexttoward_test_data): Likewise.
(nexttoward_test): Likewise.
(pow_test_data): Likewise.
(pow_test): Likewise.
(remainder_test_data): Likewise.
(remainder_test): Likewise.
(drem_test): Likewise.
(remquo_test_data): Likewise.
(remquo_test): Likewise.
(rint_test_data): Likewise.
(rint_test): Likewise.
(round_test_data): Likewise.
(round_test): Likewise.
(roundeven_test_data): Likewise.
(roundeven_test): Likewise.
(scalb_test_data): Likewise.
(scalb_test): Likewise.
(scalbn_test_data): Likewise.
(scalbn_test): Likewise.
(ldexp_test): Likewise.
(scalbln_test_data): Likewise.
(scalbln_test): Likewise.
(setpayload_test_data): Likewise.
(setpayload_test): Likewise.
(setpayloadsig_test_data): Likewise.
(setpayloadsig_test): Likewise.
(signbit_test_data): Likewise.
(signbit_test): Likewise.
(sin_test_data): Likewise.
(sin_test): Likewise.
(sincos_test_data): Likewise.
(sincos_test): Likewise.
(sinh_test_data): Likewise.
(sinh_test): Likewise.
(sqrt_test_data): Likewise.
(sqrt_test): Likewise.
(tan_test_data): Likewise.
(tan_test): Likewise.
(tanh_test_data): Likewise.
(tanh_test): Likewise.
(tgamma_test_data): Likewise.
(tgamma_test): Likewise.
(totalorder_test_data): Likewise.
(totalorder_test): Likewise.
(totalordermag_test_data): Likewise.
(totalordermag_test): Likewise.
(trunc_test_data): Likewise.
(trunc_test): Likewise.
(ufromfp_test_data): Likewise.
(ufromfp_test): Likewise.
(ufromfpx_test_data): Likewise.
(ufromfpx_test): Likewise.
(y0_test_data): Likewise.
(y0_test): Likewise.
(y1_test_data): Likewise.
(y1_test): Likewise.
(yn_test_data): Likewise.
(yn_test): Likewise.
(significand_test_data): Likewise.
(significand_test): Likewise.
* math/Makefile (auto-libm-test-out-files): Remove variable.
(libm-test-funcs-noauto): New variable.
(libm-test-funcs-all): Likewise.
(libm-test-c-auto): Likewise.
(libm-test-c-noauto): Likewise.
(libm-tests-generated): Add $(libm-test-c-auto) and
$(libm-test-c-noauto).
(generated): Do not add auto-libm-test-out.
(libm-test-c-auto-obj): New variable.
(libm-test-c-noauto-obj): Likewise.
($(objpfx)libm-test.c): Do not generate or use auto-libm-test-out.
($(libm-test-c-noauto-obj)): New static pattern rule.
($(libm-test-c-auto-obj)): Likewise.
(libm-test-incs): New variable.
($(objpfx)libm-have-vector-test.h): Depend on $(libm-test-incs)
and pass it to gen-libm-have-vector-test.sh.
* math/gen-libm-have-vector-test.sh: Expect list of .inc files to
be passed on command line.
* math/libm-test-acos.inc: New file.  Content from
math/libm-test.inc.
* math/libm-test-acosh.inc: Likewise.
* math/libm-test-asin.inc: Likewise.
* math/libm-test-asinh.inc: Likewise.
* math/libm-test-atan.inc: Likewise.
* math/libm-test-atan2.inc: Likewise.
* math/libm-test-atanh.inc: Likewise.
* math/libm-test-cabs.inc: Likewise.
* math/libm-test-cacos.inc: Likewise.
* math/libm-test-cacosh.inc: Likewise.
* math/libm-test-canonicalize.inc: Likewise.
* math/libm-test-carg.inc: Likewise.
* math/libm-test-casin.inc: Likewise.
* math/libm-test-casinh.inc: Likewise.
* math/libm-test-catan.inc: Likewise.
* math/libm-test-catanh.inc: Likewise.
* math/libm-test-cbrt.inc: Likewise.
* math/libm-test-ccos.inc: Likewise.
* math/libm-test-ccosh.inc: Likewise.
* math/libm-test-ceil.inc: Likewise.
* math/libm-test-cexp.inc: Likewise.
* math/libm-test-cimag.inc: Likewise.
* math/libm-test-clog.inc: Likewise.
* math/libm-test-clog10.inc: Likewise.
* math/libm-test-conj.inc: Likewise.
* math/libm-test-copysign.inc: Likewise.
* math/libm-test-cos.inc: Likewise.
* math/libm-test-cosh.inc: Likewise.
* math/libm-test-cpow.inc: Likewise.
* math/libm-test-cproj.inc: Likewise.
* math/libm-test-creal.inc: Likewise.
* math/libm-test-csin.inc: Likewise.
* math/libm-test-csinh.inc: Likewise.
* math/libm-test-csqrt.inc: Likewise.
* math/libm-test-ctan.inc: Likewise.
* math/libm-test-ctanh.inc: Likewise.
* math/libm-test-erf.inc: Likewise.
* math/libm-test-erfc.inc: Likewise.
* math/libm-test-exp.inc: Likewise.
* math/libm-test-exp10.inc: Likewise.
* math/libm-test-exp2.inc: Likewise.
* math/libm-test-expm1.inc: Likewise.
* math/libm-test-fabs.inc: Likewise.
* math/libm-test-fdim.inc: Likewise.
* math/libm-test-floor.inc: Likewise.
* math/libm-test-fma.inc: Likewise.
* math/libm-test-fmax.inc: Likewise.
* math/libm-test-fmaxmag.inc: Likewise.
* math/libm-test-fmin.inc: Likewise.
* math/libm-test-fminmag.inc: Likewise.
* math/libm-test-fmod.inc: Likewise.
* math/libm-test-fpclassify.inc: Likewise.
* math/libm-test-frexp.inc: Likewise.
* math/libm-test-fromfp.inc: Likewise.
* math/libm-test-fromfpx.inc: Likewise.
* math/libm-test-getpayload.inc: Likewise.
* math/libm-test-hypot.inc: Likewise.
* math/libm-test-ilogb.inc: Likewise.
* math/libm-test-iscanonical.inc: Likewise.
* math/libm-test-iseqsig.inc: Likewise.
* math/libm-test-isfinite.inc: Likewise.
* math/libm-test-isgreater.inc: Likewise.
* math/libm-test-isgreaterequal.inc: Likewise.
* math/libm-test-isinf.inc: Likewise.
* math/libm-test-isless.inc: Likewise.
* math/libm-test-islessequal.inc: Likewise.
* math/libm-test-islessgreater.inc: Likewise.
* math/libm-test-isnan.inc: Likewise.
* math/libm-test-isnormal.inc: Likewise.
* math/libm-test-issignaling.inc: Likewise.
* math/libm-test-issubnormal.inc: Likewise.
* math/libm-test-isunordered.inc: Likewise.
* math/libm-test-iszero.inc: Likewise.
* math/libm-test-j0.inc: Likewise.
* math/libm-test-j1.inc: Likewise.
* math/libm-test-jn.inc: Likewise.
* math/libm-test-lgamma.inc: Likewise.
* math/libm-test-llogb.inc: Likewise.
* math/libm-test-llrint.inc: Likewise.
* math/libm-test-llround.inc: Likewise.
* math/libm-test-log.inc: Likewise.
* math/libm-test-log10.inc: Likewise.
* math/libm-test-log1p.inc: Likewise.
* math/libm-test-log2.inc: Likewise.
* math/libm-test-logb.inc: Likewise.
* math/libm-test-lrint.inc: Likewise.
* math/libm-test-lround.inc: Likewise.
* math/libm-test-modf.inc: Likewise.
* math/libm-test-nearbyint.inc: Likewise.
* math/libm-test-nextafter.inc: Likewise.
* math/libm-test-nextdown.inc: Likewise.
* math/libm-test-nexttoward.inc: Likewise.
* math/libm-test-nextup.inc: Likewise.
* math/libm-test-pow.inc: Likewise.
* math/libm-test-remainder.inc: Likewise.
* math/libm-test-remquo.inc: Likewise.
* math/libm-test-rint.inc: Likewise.
* math/libm-test-round.inc: Likewise.
* math/libm-test-roundeven.inc: Likewise.
* math/libm-test-scalb.inc: Likewise.
* math/libm-test-scalbln.inc: Likewise.
* math/libm-test-scalbn.inc: Likewise.
* math/libm-test-setpayload.inc: Likewise.
* math/libm-test-setpayloadsig.inc: Likewise.
* math/libm-test-signbit.inc: Likewise.
* math/libm-test-significand.inc: Likewise.
* math/libm-test-sin.inc: Likewise.
* math/libm-test-sincos.inc: Likewise.
* math/libm-test-sinh.inc: Likewise.
* math/libm-test-sqrt.inc: Likewise.
* math/libm-test-tan.inc: Likewise.
* math/libm-test-tanh.inc: Likewise.
* math/libm-test-tgamma.inc: Likewise.
* math/libm-test-totalorder.inc: Likewise.
* math/libm-test-totalordermag.inc: Likewise.
* math/libm-test-trunc.inc: Likewise.
* math/libm-test-ufromfp.inc: Likewise.
* math/libm-test-ufromfpx.inc: Likewise.
* math/libm-test-y0.inc: Likewise.
* math/libm-test-y1.inc: Likewise.
* math/libm-test-yn.inc: Likewise.
* math/README.libm-test: Update.

7 years agoSplit auto-libm-test-out by function.
Joseph Myers [Mon, 6 Feb 2017 18:41:20 +0000 (18:41 +0000)]
Split auto-libm-test-out by function.

math/auto-libm-test-out is, at over 30 MB, by far the largest file in
the glibc source tree.  This patch splits it by function, so reducing
it to auto-libm-test-out-<func> files that are all under 5 MB in size.

This is preliminary to splitting up libm-test.inc as well so that each
function's tests can also be processed separately by
gen-libm-test.pl.  As a preliminary patch it doesn't actually
implement that step; rather, all the separate files get concatenated
by the Makefile to produce the monolithic auto-libm-test-out file
again as an input to gen-libm-test.pl.  (The concatentation is
identical to the file in the source tree before this patch.)

Even this preliminary step, however, is of use independent of
splitting up libm-test.inc: some tests for csin and csinh have not
been moved to auto-libm-test-in because they result in
auto-libm-test-out generation taking several minutes rather than a few
seconds (all released MPC versions are very slow for certain sin /
sinh inputs; there are some old improvements in MPC mainline which
should eventually become MPC 1.1, but the complex inverse trig and
hyperbolic functions are slow even in MPC mainline and have yet to be
moved to auto-libm-test-in at all), and it seems much more reasonable
to add such inputs to auto-libm-test-in when it will only slow down
regeneration for particular functions than when it will slow down
regeneration globally.

gen-auto-libm-tests still parses the whole input file, but only
generates output for the requested function.  This ensures bad syntax
in the file is always detected, and parsing the whole file is quick;
it's output generation that is comparatively slow for some functions.

Tested for x86_64.

* math/gen-auto-libm-tests.c: Update comment about use of program.
(generate_output): Add argument FUNCTION.
(main): Require extra argument.  Pass function name to
generate_output.
* math/Makefile (generated): Add auto-libm-test-out.
(libm-test-funcs-auto): New variable.
(auto-libm-test-out-files): New variable.
($(objpfx)libm-test.c): Depend on $(auto-libm-test-out-files).
Concatenate those files to form $(objpfx)auto-libm-test-out and
use it as input to gen-libm-test.pl.
* math/README.libm-test: Update.
* math/auto-libm-test-out: Remove.
* math/auto-libm-test-out-acos: New generated file.
* math/auto-libm-test-out-acosh: Likewise.
* math/auto-libm-test-out-asin: Likewise.
* math/auto-libm-test-out-asinh: Likewise.
* math/auto-libm-test-out-atan: Likewise.
* math/auto-libm-test-out-atan2: Likewise.
* math/auto-libm-test-out-atanh: Likewise.
* math/auto-libm-test-out-cabs: Likewise.
* math/auto-libm-test-out-carg: Likewise.
* math/auto-libm-test-out-cbrt: Likewise.
* math/auto-libm-test-out-ccos: Likewise.
* math/auto-libm-test-out-ccosh: Likewise.
* math/auto-libm-test-out-cexp: Likewise.
* math/auto-libm-test-out-clog: Likewise.
* math/auto-libm-test-out-clog10: Likewise.
* math/auto-libm-test-out-cos: Likewise.
* math/auto-libm-test-out-cosh: Likewise.
* math/auto-libm-test-out-cpow: Likewise.
* math/auto-libm-test-out-csin: Likewise.
* math/auto-libm-test-out-csinh: Likewise.
* math/auto-libm-test-out-csqrt: Likewise.
* math/auto-libm-test-out-ctan: Likewise.
* math/auto-libm-test-out-ctanh: Likewise.
* math/auto-libm-test-out-erf: Likewise.
* math/auto-libm-test-out-erfc: Likewise.
* math/auto-libm-test-out-exp: Likewise.
* math/auto-libm-test-out-exp10: Likewise.
* math/auto-libm-test-out-exp2: Likewise.
* math/auto-libm-test-out-expm1: Likewise.
* math/auto-libm-test-out-fma: Likewise.
* math/auto-libm-test-out-hypot: Likewise.
* math/auto-libm-test-out-j0: Likewise.
* math/auto-libm-test-out-j1: Likewise.
* math/auto-libm-test-out-jn: Likewise.
* math/auto-libm-test-out-lgamma: Likewise.
* math/auto-libm-test-out-log: Likewise.
* math/auto-libm-test-out-log10: Likewise.
* math/auto-libm-test-out-log1p: Likewise.
* math/auto-libm-test-out-log2: Likewise.
* math/auto-libm-test-out-pow: Likewise.
* math/auto-libm-test-out-sin: Likewise.
* math/auto-libm-test-out-sincos: Likewise.
* math/auto-libm-test-out-sinh: Likewise.
* math/auto-libm-test-out-sqrt: Likewise.
* math/auto-libm-test-out-tan: Likewise.
* math/auto-libm-test-out-tanh: Likewise.
* math/auto-libm-test-out-tgamma: Likewise.
* math/auto-libm-test-out-y0: Likewise.
* math/auto-libm-test-out-y1: Likewise.
* math/auto-libm-test-out-yn: Likewise.

7 years agoEliminate libm-test.stmp.
Joseph Myers [Mon, 6 Feb 2017 18:28:33 +0000 (18:28 +0000)]
Eliminate libm-test.stmp.

math/Makefile uses libm-test.stmp to handle dependencies involving
multiple generated files all generated by a single sequence of
commands in a single Makefile rule.

Having separated the libm-test-ulps.h and libm-test.c generation into
separate runs of gen-libm-test.pl, there is now no need for a single
rule to generate multiple target files; each of the three target files
involved can be generated by a separate Makefile rule, meaning normal
dependencies on the individual files can be used and so libm-test.stmp
is not needed at all.  This patch does just that, eliminating the
.stmp file, in further preparation for when there are many separate
libm-test-<func>.c files generated from libm-test-<func>.inc and the
dependencies are on just the relevant .c file in each case.

Tested for x86_64.

* math/Makefile (generated): Do not include libm-test.stmp.
($(addprefix $(objpfx), $(libm-tests-generated))): Do not depend
on $(objpfx)libm-test.stmp.
($(objpfx)libm-test.stmp): Remove rule.
($(objpfx)libm-test-ulps.h): New rule.
($(objpfx)libm-test.c): Likewise.
($(objpfx)libm-have-vector-test.h): Likewise.
($(addprefix $(objpfx), $(libm-tests.o)): Depend directly on
individual generated files, not libm-test.stmp.

7 years agoRework gen-libm-test.pl input/output handling.
Joseph Myers [Mon, 6 Feb 2017 18:20:15 +0000 (18:20 +0000)]
Rework gen-libm-test.pl input/output handling.

This patch reworks how input and output files are specified for
gen-libm-test.pl.

Previously, the script had names of various inputs and outputs
hardcoded, with a -o option to specify an output directory.  This
patch replaces this with all inputs and outputs being specified
explicitly as the arguments of options passed to the script.  Outputs
are only generated if the relevant option is passed, and only the
processing required for the indicated outputs is done.  The Makefile
is made to pass options for generating libm-test-ulps.h in a separate
invocation of gen-libm-test.pl from that generating libm-test.c.

This is all in preparation for splitting up libm-test.inc and
auto-libm-test-out and running tests separately for each function,
when gen-libm-test.pl will be run separately for each function to
generate the .c file but only once to generate libm-test-ulps.h (and
those runs will be able to be in parallel).

Tested for x86_64.  The generated libm-test.c and libm-test-ulps.h are
identical before and after the patch.  Also tested the "make
regen-ulps" case.

* math/gen-libm-test.pl ($output_dir): Remove variable.
($srcdir): Likewise.
($opt_a): New variable.
($opt_c): Likewise.
($opt_C): Likewise.
($opt_H): Likewise.
(-n): Make option take argument and use it as NewUlps output.
(-a): New option.  Use its argument for auto-libm-test-out input.
(-c): New option.  Use its argument for libm-test.inc input.
(-C): New option.  Use its argument for libm-test.c output.
(-H): New option.  Use its argument for libm-test-ulps.h output.
(top level): Only process inputs needed to generate outputs
specified by command-line options.  Only generate outputs
specified by command-line options.
* math/README.libm-test: Update example gen-libm-test.pl command.
* math/Makefile ($(objpfx)libm-test.stmp): Update gen-libm-test.pl
commands.
(regen-ulps): Likewise.

7 years agoAs a minor cleanup remove the (r)index defines from include/string.h as
Wilco Dijkstra [Mon, 6 Feb 2017 18:14:16 +0000 (18:14 +0000)]
As a minor cleanup remove the (r)index defines from include/string.h as
they are only used internally in a few places.  Rename all uses that
occur in GLIBC.

* hurd/path-lookup.c (file_name_path_scan): Rename index to strchr.
* include/string.h (index): Remove define.
(rindex): Likewise.
* misc/getttyent.c (__getttyent): Rename index to strchr.
* misc/ttyslot.c (ttyslot): Rename rindex to strrchr.
* sunrpc/rpc_main.c (mkfile_output): Likewise.

7 years agoMove non-function-specific parts of libm-test.inc to separate file.
Joseph Myers [Mon, 6 Feb 2017 18:12:16 +0000 (18:12 +0000)]
Move non-function-specific parts of libm-test.inc to separate file.

libm-test.inc contains both test infrastructure and tests of
individual functions.

This patch moves the infrastructure to a separate file
libm-test-driver.c.  This is in preparation for splitting the tests of
individual functions into separate source files, which will be
processed individually by gen-libm-test.pl (so e.g. libm-test-acos.inc
and auto-libm-test-out-acos will be processed by gen-libm-test.pl to
produce libm-test-acos.c, and files such as test-double-acos.c will be
generated by the Makefile to include appropriate headers,
libm-test-driver.c and libm-test-acos.c so tests of each function get
run separately).

It is no doubt possible to split things up further, so that functions
not depending on the type being tested only get compiled once and most
of those depending on the type being tested get compiled once per type
(rather than separately for variants such as inline / no-inline, and
separately for each function being tested after that split), but this
rearrangement as-is seems a useful incremental step towards splitting
these tests by function.

* math/libm-test-driver.c: New file.  Based on math/libm-test.inc.
* math/libm-test.inc: Move all contents, other than tests of
individual functions, to libm-test-driver.c.
[!FE_TONEAREST] (FE_TONEAREST): Move to libm-test-driver.c.
[!FE_TOWARDZERO] (FE_TOWARDZERO): Likewise.
[!FE_UPWARD] (FE_UPWARD): Likewise.
[!FE_DOWNWARD] (FE_DOWNWARD): Likewise.
(NO_EXCEPTION): Likewise.
(INVALID_EXCEPTION): Likewise.
(DIVIDE_BY_ZERO_EXCEPTION): Likewise.
(OVERFLOW_EXCEPTION): Likewise.
(UNDERFLOW_EXCEPTION): Likewise.
(INEXACT_EXCEPTION): Likewise.
(INVALID_EXCEPTION_OK): Likewise.
(DIVIDE_BY_ZERO_EXCEPTION_OK): Likewise.
(OVERFLOW_EXCEPTION_OK): Likewise.
(UNDERFLOW_EXCEPTION_OK): Likewise.
(NO_INEXACT_EXCEPTION): Likewise.
(EXCEPTIONS_OK): Likewise.
(IGNORE_ZERO_INF_SIGN): Likewise.
(TEST_NAN_SIGN): Likewise.
(TEST_NAN_PAYLOAD): Likewise.
(NO_TEST_INLINE): Likewise.
(XFAIL_TEST): Likewise.
(ERRNO_UNCHANGED): Likewise.
(ERRNO_EDOM): Likewise.
(ERRNO_ERANGE): Likewise.
(IGNORE_RESULT): Likewise.
(NON_FINITE): Likewise.
(TEST_SNAN): Likewise.
(NO_TEST_MATHVEC): Likewise.
(TEST_NAN_PAYLOAD_CANONICALIZE): Likewise.
(__CONCATX): Likewise.
(TYPE_MIN): Likewise.
(TYPE_TRUE_MIN): Likewise.
(TYPE_MAX): Likewise.
(MIN_EXP): Likewise.
(MAX_EXP): Likewise.
(MANT_DIG): Likewise.
(FSTR_MAX): Likewise.
(ULP_IDX): Likewise.
(QTYPE_STR): Likewise.
(TEST_COND_binary32): Likewise.
(TEST_COND_binary64): Likewise.
(TEST_COND_binary128): Likewise.
(TEST_COND_ibm128): Likewise.
(TEST_COND_intel96): Likewise.
(TEST_COND_m68k96): Likewise.
(TEST_COND_ibm128_libgcc): Likewise.
(XFAIL_IBM128_LIBGCC): Likewise.
(PAYLOAD_DIG): Likewise.
(UNDERFLOW_EXCEPTION_FLOAT): Likewise.
(UNDERFLOW_EXCEPTION_OK_FLOAT): Likewise.
(UNDERFLOW_EXCEPTION_DOUBLE): Likewise.
(UNDERFLOW_EXCEPTION_OK_DOUBLE): Likewise.
(UNDERFLOW_EXCEPTION_LDOUBLE_IBM): Likewise.
(UNDERFLOW_EXCEPTION_BEFORE_ROUNDING): Likewise.
(TEST_COND_long32): Likewise.
(TEST_COND_long64): Likewise.
(TEST_COND_before_rounding): Likewise.
(TEST_COND_after_rounding): Likewise.
(lit_pi_3_m_4_d): Likewise.
(lit_pi_3_m_4_ln10_m_d): Likewise.
(lit_pi_2_ln10_m_d): Likewise.
(lit_pi_4_ln10_m_d): Likewise.
(lit_pi_ln10_d): Likewise.
(lit_pi_2_d): Likewise.
(lit_pi_4_d): Likewise.
(lit_pi): Likewise.
(lit_e): Likewise.
(ulps_file_name): Likewise.
(ulps_file): Likewise.
(output_ulps): Likewise.
(output_dir): Likewise.
(noErrors): Likewise.
(noTests): Likewise.
(noExcTests): Likewise.
(noErrnoTests): Likewise.
(verbose): Likewise.
(output_max_error): Likewise.
(output_points): Likewise.
(ignore_max_ulp): Likewise.
(plus_zero): Likewise.
(minus_zero): Likewise.
(plus_infty): Likewise.
(minus_infty): Likewise.
(qnan_value_pl): Likewise.
(qnan_value): Likewise.
(snan_value_pl): Likewise.
(snan_value): Likewise.
(max_value): Likewise.
(min_value): Likewise.
(min_subnorm_value): Likewise.
(snan_value_ld): Likewise.
(max_error): Likewise.
(real_max_error): Likewise.
(imag_max_error): Likewise.
(prev_max_error): Likewise.
(prev_real_max_error): Likewise.
(prev_imag_max_error): Likewise.
(max_valid_error): Likewise.
(TYPE_DECIMAL_DIG): Likewise.
(TYPE_HEX_DIG): Likewise.
(fmt_ftostr): Likewise.
(compare_ulp_data): Likewise.
(find_ulps): Likewise.
(init_max_error): Likewise.
(set_max_error): Likewise.
(print_float): Likewise.
(print_screen): Likewise.
(print_screen_max_error): Likewise.
(update_stats): Likewise.
(print_function_ulps): Likewise.
(print_complex_function_ulps): Likewise.
(fpstack_test): Likewise.
(print_max_error): Likewise.
(print_complex_max_error): Likewise.
(test_single_exception): Likewise.
(test_exceptions): Likewise.
(test_single_errno): Likewise.
(test_errno): Likewise.
(ULPDIFF): Likewise.
(ulp): Likewise.
(check_float_internal): Likewise.
(check_float): Likewise.
(check_complex): Likewise.
(check_int): Likewise.
(check_long): Likewise.
(check_bool): Likewise.
(check_longlong): Likewise.
(check_intmax_t): Likewise.
(check_uintmax_t): Likewise.
(enable_test): Likewise.
(struct test_f_f_data): Likewise.
(struct test_ff_f_data): Likewise.
(struct test_fj_f_data): Likewise.
(struct test_fi_f_data): Likewise.
(struct test_fl_f_data): Likewise.
(struct test_if_f_data): Likewise.
(struct test_fff_f_data): Likewise.
(struct test_fiu_M_data): Likewise.
(struct test_fiu_U_data): Likewise.
(struct test_c_f_data): Likewise.
(struct test_f_f1_data): Likewise.
(struct test_fF_f1_data): Likewise.
(struct test_ffI_f1_data): Likewise.
(struct test_c_c_data): Likewise.
(struct test_cc_c_data): Likewise.
(struct test_f_i_data): Likewise.
(struct test_ff_i_data): Likewise.
(struct test_f_l_data): Likewise.
(struct test_f_L_data): Likewise.
(struct test_fFF_11_data): Likewise.
(struct test_Ff_b1_data): Likewise.
(IF_ROUND_INIT_): Likewise.
(IF_ROUND_INIT_FE_DOWNWARD): Likewise.
(IF_ROUND_INIT_FE_TONEAREST): Likewise.
(IF_ROUND_INIT_FE_TOWARDZERO): Likewise.
(IF_ROUND_INIT_FE_UPWARD): Likewise.
(ROUND_RESTORE_): Likewise.
(ROUND_RESTORE_FE_DOWNWARD): Likewise.
(ROUND_RESTORE_FE_TONEAREST): Likewise.
(ROUND_RESTORE_FE_TOWARDZERO): Likewise.
(ROUND_RESTORE_FE_UPWARD): Likewise.
(RM_): Likewise.
(RM_FE_DOWNWARD): Likewise.
(RM_FE_TONEAREST): Likewise.
(RM_FE_TOWARDZERO): Likewise.
(RM_FE_UPWARD): Likewise.
(COMMON_TEST_SETUP): Likewise.
(EXTRA_OUTPUT_TEST_SETUP): Likewise.
(COMMON_TEST_CLEANUP): Likewise.
(EXTRA_OUTPUT_TEST_CLEANUP): Likewise.
(RUN_TEST_f_f): Likewise.
(RUN_TEST_LOOP_f_f): Likewise.
(RUN_TEST_fp_f): Likewise.
(RUN_TEST_LOOP_fp_f): Likewise.
(RUN_TEST_2_f): Likewise.
(RUN_TEST_LOOP_2_f): Likewise.
(RUN_TEST_ff_f): Likewise.
(RUN_TEST_LOOP_ff_f): Likewise.
(RUN_TEST_LOOP_fj_f): Likewise.
(RUN_TEST_fi_f): Likewise.
(RUN_TEST_LOOP_fi_f): Likewise.
(RUN_TEST_fl_f): Likewise.
(RUN_TEST_LOOP_fl_f): Likewise.
(RUN_TEST_if_f): Likewise.
(RUN_TEST_LOOP_if_f): Likewise.
(RUN_TEST_fff_f): Likewise.
(RUN_TEST_LOOP_fff_f): Likewise.
(RUN_TEST_fiu_M): Likewise.
(RUN_TEST_LOOP_fiu_M): Likewise.
(RUN_TEST_fiu_U): Likewise.
(RUN_TEST_LOOP_fiu_U): Likewise.
(RUN_TEST_c_f): Likewise.
(RUN_TEST_LOOP_c_f): Likewise.
(RUN_TEST_f_f1): Likewise.
(RUN_TEST_LOOP_f_f1): Likewise.
(RUN_TEST_fF_f1): Likewise.
(RUN_TEST_LOOP_fF_f1): Likewise.
(RUN_TEST_fI_f1): Likewise.
(RUN_TEST_LOOP_fI_f1): Likewise.
(RUN_TEST_ffI_f1_mod8): Likewise.
(RUN_TEST_LOOP_ffI_f1_mod8): Likewise.
(RUN_TEST_Ff_b1): Likewise.
(RUN_TEST_LOOP_Ff_b1): Likewise.
(RUN_TEST_Ffp_b1): Likewise.
(RUN_TEST_LOOP_Ffp_b1): Likewise.
(RUN_TEST_c_c): Likewise.
(RUN_TEST_LOOP_c_c): Likewise.
(RUN_TEST_cc_c): Likewise.
(RUN_TEST_LOOP_cc_c): Likewise.
(RUN_TEST_f_i): Likewise.
(RUN_TEST_LOOP_f_i): Likewise.
(RUN_TEST_f_i_tg): Likewise.
(RUN_TEST_LOOP_f_i_tg): Likewise.
(RUN_TEST_ff_b): Likewise.
(RUN_TEST_LOOP_ff_b): Likewise.
(RUN_TEST_ff_i_tg): Likewise.
(RUN_TEST_LOOP_ff_i_tg): Likewise.
(RUN_TEST_f_b): Likewise.
(RUN_TEST_LOOP_f_b): Likewise.
(RUN_TEST_f_b_tg): Likewise.
(RUN_TEST_LOOP_f_b_tg): Likewise.
(RUN_TEST_f_l): Likewise.
(RUN_TEST_LOOP_f_l): Likewise.
(RUN_TEST_f_L): Likewise.
(RUN_TEST_LOOP_f_L): Likewise.
(RUN_TEST_fFF_11): Likewise.
(RUN_TEST_LOOP_fFF_11): Likewise.
(VEC_SUFF): Likewise.
(STR_CONCAT): Likewise.
(STR_CON3): Likewise.
(HAVE_VECTOR): Likewise.
(START): Likewise.
(END): Likewise.
(END_COMPLEX): Likewise.
(ALL_RM_TEST): Likewise.
(matherr): Likewise.
(initialize): Likewise.
(options): Likewise.
(doc): Likewise.
(parse_opt): Likewise.
(argp): Likewise.
(check_ulp): Likewise.
(main): Likewise.
(do_test): New function.  Call tests of individual functions
previously called from main.

7 years agoRemove libm-test.inc comment listing functions tested and not tested.
Joseph Myers [Mon, 6 Feb 2017 18:02:54 +0000 (18:02 +0000)]
Remove libm-test.inc comment listing functions tested and not tested.

math/libm-test.inc has a comment listing the functions tested and not
tested.  The list of functions tested duplicates what is immediately
obvious from the rest of the file and adds another place to update
when adding a function.  I've put the information about functions not
tested on the wiki todo list; this patch removes that comment, in
preparation for splitting tests of each function into separate .inc
files with common code staying in a separate .c file.

Tested for x86_64.

* math/libm-test.inc: Remove comment listing functions tested and
not tested.

7 years agonptl: Remove COLORING_INCREMENT
Adhemerval Zanella [Mon, 30 Jan 2017 20:07:32 +0000 (18:07 -0200)]
nptl: Remove COLORING_INCREMENT

This patch removes the COLORING_INCREMENT define and usage on allocatestack.c.
It has not been used since 564cd8b67ec487f (glibc-2.3.3) by any architecture.
The idea is to simplify the code by removing obsolete code.

* nptl/allocatestack.c [COLORING_INCREMENT] (nptl_ncreated): Remove.
(allocate_stack): Remove COLORING_INCREMENT usage.
* nptl/stack-aliasing.h (COLORING_INCREMENT). Likewise.
* sysdeps/i386/i686/stack-aliasing.h (COLORING_INCREMENT): Likewise.

7 years agoDo not hardcode list of libm functions in libm-err-tab.pl.
Joseph Myers [Mon, 6 Feb 2017 17:55:59 +0000 (17:55 +0000)]
Do not hardcode list of libm functions in libm-err-tab.pl.

manual/libm-err-tab.pl contains a hardcoded list of libm functions for
which ulps are listed in the manual, and another hardcoded list in a
comment of functions deliberately excluded because of an expected lack
of ulps (and the two together are not in fact an exhaustive list of
libm functions tested through the libm-test machinery).

This patch removes these hardcoded lists, so eliminating this from the
places needing updating when a new libm function is added.  Instead,
ulps are tabulated for functions for which they are seen in
libm-test-ulps files, in alphabetical order.  The pseudo-function
names such as *_downward and *_vlen* are excluded since they are
excluded from the existing lists, and the description in the manual is
updated to explain how those entries are excluded and if a function is
not listed at all it does not have known errors.

Tested for x86_64.

* manual/libm-err-tab.pl (@all_functions): Change to
%all_functions.  Initialize as empty.
(parse_ulps): Add to %all_functions based on functions found in
ulps files.  Ignore results for non-default rounding modes and
vector functions.
(print_platforms): Use %all_platforms.
* manual/math.texi (Errors in Math Functions): Document omissions
from the table.

7 years agoRemove before-compile setting in math/Makefile.
Joseph Myers [Mon, 6 Feb 2017 17:48:02 +0000 (17:48 +0000)]
Remove before-compile setting in math/Makefile.

In <https://sourceware.org/ml/libc-alpha/2015-12/msg00543.html>,
Florian noted highly parallel builds being slowed down by
gen-libm-test.pl running during the build, when it should only run for
testing, not for building glibc itself.

This is a consequence of libm-test.c being listed in before-compile.
That listing in before-compile arose from the error reported in
<https://sourceware.org/ml/libc-hacker/1999-10/msg00054.html> when
building dependencies: at that time, dependencies were generated
separation from compilation, so if a source file included a generated
file it wasn't enough for the dependencies for the .o file to be
correct, the generated file needed to be listed in before-compile.

Since <https://sourceware.org/ml/libc-hacker/2003-05/msg00001.html>,
dependencies are generated as a side-effect of compilation.  This
means that having the right dependencies for the .o files for the
tests fully suffices to ensure that libm-test.c is generated by the
time it's needed; no entry in before-compile is needed.  And we indeed
have such a dependency for all the tests using libm-test.c:

$(addprefix $(objpfx), $(libm-tests.o)): $(objpfx)libm-test.stmp

Thus, the before-compile definition is unnecessary, and this patch
removes it.  (This may of course move serialization from the glibc
build to glibc testing, but I intend to split up libm-test.inc so that
tests for each (floating-point type, libm function) pair are built and
run separately, which should reduce that serialization.)

Tested for x86_64.

* math/Makefile (before-compile): Remove.

7 years agosparc: Remove unused assignment in __clone
Ivo Raisr [Mon, 6 Feb 2017 12:49:50 +0000 (10:49 -0200)]
sparc: Remove unused assignment in __clone

It is no longer needed to preserve the flags parameter to `clone' since
the commit c579f48edba88380635ab98cb612030e3ed8691e (Remove cached
PID/TID in clone).

Testing was performed successfully on sparcv9/Linux.

[BZ #21075]
* sysdeps/unix/sysv/linux/sparc/sparc64/clone.S (__clone): Remove
unused assignment.
* sysdeps/unix/sysv/linux/sparc/sparc32/clone.S (__clone): Likewise.

7 years agoAdd __glibc_unlikely hint in lll_trylock, lll_cond_trylock.
Stefan Liebler [Mon, 6 Feb 2017 12:44:23 +0000 (13:44 +0100)]
Add __glibc_unlikely hint in lll_trylock, lll_cond_trylock.

The macros lll_trylock, lll_cond_trylock are extended by an __glibc_unlikely
hint.  Now the trylock macros are based on the same assumption about a
free/busy lock as lll_lock.
With the hint gcc emits code in e.g. pthread_mutex_trylock which does
not use jumps if the lock is free.  Without the hint it had to jump away
if the lock is free.

Tested on s390x, ppc.

ChangeLog:

* sysdeps/nptl/lowlevellock.h (lll_trylock, lll_cond_trylock):
Add __glibc_unlikely hint.

7 years agoRemove i686, x86_64, and powerpc strtok implementations
Adhemerval Zanella [Thu, 5 Jan 2017 21:43:25 +0000 (19:43 -0200)]
Remove i686, x86_64, and powerpc strtok implementations

Based on comments on previous attempt to address BZ#16640 [1],
the idea is not support invalid use of strtok (the original
bug report proposal).  This leader to a new strtok optimized
strtok implementation [2].

The idea of this patch is to fix BZ#16640 to align all the
implementations to a same contract.  However, with newer strtok
code it is better to get remove the old assembly ones instead of
fix them.

For x86 is a gain in all cases since the new implementation can
potentially use sse2/sse42 implementation for strspn and strcspn.
This shows a better performance on both i686 and x86_64 using
the string benchtests.

On powerpc64 the gains are mixed, where only for larger inputs
or keys some gains are showns (based on benchtest it seems that
it shows some gains for keys larger than 10 and inputs larger
than 32).  I would prefer to remove the optimized implementation
based on first code simplicity and second because some more gain
could be optimized using a better optimized strcspn/strspn
code (as for x86).  However if powerpc arch maintainers prefer I
can send a v2 with the assembly code adjusted instead.

Checked on x86_64-linux-gnu, i686-linux-gnu, and powerpc64le-linux-gnu.

[BZ #16640]
* sysdeps/i386/i686/strtok.S: Remove file.
* sysdeps/i386/i686/strtok_r.S: Likewise.
* sysdeps/i386/strtok.S: Likewise.
* sysdeps/i386/strtok_r.S: Likewise.
* sysdeps/powerpc/powerpc64/strtok.S: Likewise.
* sysdeps/powerpc/powerpc64/strtok_r.S: Likewise.
* sysdeps/x86_64/strtok.S: Likewise.
* sysdeps/x86_64/strtok_r.S: Likewise.

[1] https://sourceware.org/ml/libc-alpha/2016-10/msg00411.html
[2] https://sourceware.org/ml/libc-alpha/2016-12/msg00461.html

7 years agoConsolidate arm and mips posix_fadvise implementations
Adhemerval Zanella [Fri, 13 Jan 2017 17:24:53 +0000 (15:24 -0200)]
Consolidate arm and mips posix_fadvise implementations

As noted by c1f0601389db64d9, previous posix_fadvise consolidation
broke on mips o32.  As stated in commit message, MIPS o32 only defines
__NR_fadvise64 and it is behaves like __NR_fadvise64_64.

This patches consolidates both ARM and mips o32 version by fixing
the ARM used option (__NR_fadvise64_64 withouth the alignment required
by abi) and added another option, __ASSUME_FADVISE64_AS_64_64,
which is used on mips o32.

When this option is used, posix_fadvise will use __NR_fadvise64_64
behavior (by defining or not __ASSUME_FADVISE64_64_6ARG).  For
mips, if __NR_fadvise64_64 is not defined, __NR_fadvise will be used.

I also updated the posix_fadvise comments to explain better the
different kernel abi used in the supported architectures.

I checked with a mips o32 and verified that posix_fadvise.o is
indeed using 7 argument syscall with the expected argument position.
I also checked on i686-linux-gnu and arm-gnu-eabihf.

* sysdeps/unix/sysv/linux/arm/posix_fadvise.c: Remove file.
* sysdeps/unix/sysv/linux/mips/mips32/posix_fadvise.c: Likewise.
* sysdeps/unix/sysv/linux/mips/kernel-features.h
(__ASSUME_FADVISE64_AS_64_64): Define.
* sysdeps/unix/sysv/linux/posix_fadvise.c [__NR_fadvise64]: Add
!defined __ASSUME_FADVISE64_AS_64_64 to use syscall issue.
[!__NR_fadvise64 && __ASSUME_FADVISE64_64_6ARG]: Remove
__ALIGNMENT_ARG usage.
[!__NR_fadvise64 && !__ASSUME_FADVISE64_64_6ARG]: Define
__NR_fadvise64_64 if it is not defined.

7 years agoOpen master for development
Siddhesh Poyarekar [Sun, 5 Feb 2017 15:57:52 +0000 (21:27 +0530)]
Open master for development

7 years agoUpdate for 2.25 release
Siddhesh Poyarekar [Sun, 5 Feb 2017 15:28:42 +0000 (20:58 +0530)]
Update for 2.25 release

7 years agoAdd more contributors to contrib.texi
Siddhesh Poyarekar [Sun, 5 Feb 2017 13:48:20 +0000 (19:18 +0530)]
Add more contributors to contrib.texi

7 years agoAdd list of bugs fixed in 2.25
Siddhesh Poyarekar [Sun, 5 Feb 2017 13:15:21 +0000 (18:45 +0530)]
Add list of bugs fixed in 2.25

7 years agoAdd missing NEWS items
Siddhesh Poyarekar [Sun, 5 Feb 2017 13:06:06 +0000 (18:36 +0530)]
Add missing NEWS items

Add NEWS items for the two new pthreads implementations, i.e. the
condition variables algorithms and the pthread_rwlock algorithms.

7 years agotunables: Fail tests correctly when setgid does not work
Siddhesh Poyarekar [Sat, 4 Feb 2017 06:32:37 +0000 (12:02 +0530)]
tunables: Fail tests correctly when setgid does not work

The child process of the tst-env-setuid process was failing correctly
with EXIT_UNSUPPORTED but the parent did not carry that status forward
and failed instead.  This patch fixes this so that tests on nosuid
/tmp fails gracefully with UNSUPPORTED.  Tested by making my tmpfs
nosuid.

* elf/tst-env-setuid.c (do_execve): Return EXIT_UNSUPPORTED in
parent if child exited in that manner.  Print WEXITSTATUS
instead of the raw status.
(do_test_prep): Rename to do_test.
(do_test): Return the result of run_executable_sgid.
(TEST_FUNCTION_ARGV): Adjust.

7 years agoBug 20915: Do not initialize DTV of other threads.
Alexandre Oliva [Sat, 4 Feb 2017 01:35:16 +0000 (20:35 -0500)]
Bug 20915: Do not initialize DTV of other threads.

In _dl_nothread_init_static_tls() and init_one_static_tls() we must not
touch the DTV of other threads since we do not have ownership of them.
The DTV need not be initialized at this point anyway since only LD/GD
accesses will use them. If LD/GD accesses occur they will take care to
initialize their own thread's DTV.

Concurrency comments were removed from the patch since they need to be
reworked along with a full description of DTV ownership and when it is
or is not safe to modify these structures.

Alexandre Oliva's original patch and discussion:
https://sourceware.org/ml/libc-alpha/2016-09/msg00512.html

7 years agosparc: Remove optimized math routines which cause testsuite failures.
David S. Miller [Sat, 4 Feb 2017 01:48:39 +0000 (17:48 -0800)]
sparc: Remove optimized math routines which cause testsuite failures.

famx{,f}/fmin{,f} and 32-bit lrint cause math testsuite failures
either because they generate incorrect results or they fail to signal
the proper exceptions.

* sysdeps/sparc/sparc64/fpu/multiarch/s_fmax-vis3.S: Remove file.
* sysdeps/sparc/sparc64/fpu/multiarch/s_fmax.S: Likewise.
* sysdeps/sparc/sparc64/fpu/multiarch/s_fmaxf-vis3.S: Likewise.
* sysdeps/sparc/sparc64/fpu/multiarch/s_fmaxf.S: Likewise.
* sysdeps/sparc/sparc64/fpu/multiarch/s_fmin-vis3.S: Likewise.
* sysdeps/sparc/sparc64/fpu/multiarch/s_fmin.S: Likewise.
* sysdeps/sparc/sparc64/fpu/multiarch/s_fminf-vis3.S: Likewise.
* sysdeps/sparc/sparc64/fpu/multiarch/s_fminf.S: Likewise.
* sysdeps/sparc/sparc64/fpu/multiarch/Makefile
(libm-sysdep_routines): Update.
* sysdeps/sparc/sparc32/sparcv9/fpu/s_fmax.S: Remove file.
* sysdeps/sparc/sparc32/sparcv9/fpu/s_fmaxf.S: Likewise.
* sysdeps/sparc/sparc32/sparcv9/fpu/s_fmin.S: Likewise.
* sysdeps/sparc/sparc32/sparcv9/fpu/s_fminf.S: Likewise.
* sysdeps/sparc/sparc32/sparcv9/fpu/s_lrint.S: Likewise.
* sysdeps/sparc/sparc64/fpu/s_fmax.S: Likewise.
* sysdeps/sparc/sparc64/fpu/s_fmaxf.S: Likewise.
* sysdeps/sparc/sparc64/fpu/s_fmin.S: Likewise.
* sysdeps/sparc/sparc64/fpu/s_fminf.S: Likewise.
* sysdeps/sparc/sparc32/sparcv9/fpu/multiarch/s_fmax-vis3.S:
Likewise.
* sysdeps/sparc/sparc32/sparcv9/fpu/multiarch/s_fmax.S: Likewise.
* sysdeps/sparc/sparc32/sparcv9/fpu/multiarch/s_fmaxf-vis3.S:
Likewise.
* sysdeps/sparc/sparc32/sparcv9/fpu/multiarch/s_fmaxf.S: Likewise.
* sysdeps/sparc/sparc32/sparcv9/fpu/multiarch/s_fmin-vis3.S:
Likewise.
* sysdeps/sparc/sparc32/sparcv9/fpu/multiarch/s_fmin.S: Likewise.
* sysdeps/sparc/sparc32/sparcv9/fpu/multiarch/s_fminf-vis3.S:
Likewise.
* sysdeps/sparc/sparc32/sparcv9/fpu/multiarch/s_fminf.S: Likewise.
* sysdeps/sparc/sparc32/sparcv9/fpu/multiarch/Makefile
(libm-sysdep_routines): Update.

7 years agoAllow IFUNC relocation against unrelocated shared library
H.J. Lu [Thu, 2 Feb 2017 21:14:43 +0000 (13:14 -0800)]
Allow IFUNC relocation against unrelocated shared library

IFUNC relocation against definition in unrelocated shared library
will lead to segfault when the IFUNC function is called.  This
patch allows such IFUNC relocations with a warning.  This isn't
a real fix for

https://sourceware.org/bugzilla/show_bug.cgi?id=21041

It simply allows the program to load.  The program will segfault
when longjmp is called.

* sysdeps/i386/dl-machine.h (elf_machine_rel): Replace
_dl_fatal_printf with _dl_error_printf for IFUNC relocation
against unrelocated shared library.
* sysdeps/x86_64/dl-machine.h (elf_machine_rela): Likewise.

7 years agoDrop GLIBC_TUNABLES for setxid programs when tunables is disabled (bz #21073)
Siddhesh Poyarekar [Thu, 2 Feb 2017 10:18:06 +0000 (15:48 +0530)]
Drop GLIBC_TUNABLES for setxid programs when tunables is disabled (bz #21073)

A setxid program that uses a glibc with tunables disabled may pass on
GLIBC_TUNABLES as is to its child processes.  If the child process
ends up using a different glibc that has tunables enabled, it will end
up getting access to unsafe tunables.  To fix this, remove
GLIBC_TUNABLES from the environment for setxid process.

* sysdeps/generic/unsecvars.h: Add GLIBC_TUNABLES.
* elf/tst-env-setuid-tunables.c
(test_child_tunables)[!HAVE_TUNABLES]: Verify that
GLIBC_TUNABLES is removed in a setgid process.

7 years agotunables: Fix environment variable processing for setuid binaries (bz #21073)
Siddhesh Poyarekar [Thu, 2 Feb 2017 10:16:01 +0000 (15:46 +0530)]
tunables: Fix environment variable processing for setuid binaries (bz #21073)

Florian Weimer pointed out that we have three different kinds of
environment variables (and hence tunables):

1. Variables that are removed for setxid processes
2. Variables that are ignored in setxid processes but is passed on to
   child processes
3. Variables that are passed on to child processes all the time

Tunables currently only does (2) and (3) when it should be doing (1)
for MALLOC_CHECK_.  This patch enhances the is_secure flag in tunables
to an enum value that can specify which of the above three categories
the tunable (and its envvar alias) belongs to.

The default is for tunables to be in (1).  Hence, all of the malloc
tunables barring MALLOC_CHECK_ are explicitly specified to belong to
category (2).  There were discussions around abolishing category (2)
completely but we can do that as a separate exercise in 2.26.

Tested on x86_64 to verify that there are no regressions.

[BZ #21073]
* elf/dl-tunable-types.h (tunable_seclevel_t): New enum.
* elf/dl-tunables.c (tunables_strdup): Remove.
(get_next_env): Also return the previous envp.
(parse_tunables): Erase tunables of category
TUNABLES_SECLEVEL_SXID_ERASE.
(maybe_enable_malloc_check): Make MALLOC_CHECK_
TUNABLE_SECLEVEL_NONE if /etc/setuid-debug is accessible.
(__tunables_init)[TUNABLES_FRONTEND ==
TUNABLES_FRONTEND_valstring]: Update GLIBC_TUNABLES envvar
after parsing.
[TUNABLES_FRONTEND != TUNABLES_FRONTEND_valstring]: Erase
tunable envvars of category TUNABLES_SECLEVEL_SXID_ERASE.
* elf/dl-tunables.h (struct _tunable): Change member is_secure
to security_level.
* elf/dl-tunables.list: Add security_level annotations for all
tunables.
* scripts/gen-tunables.awk: Recognize and generate enum values
for security_level.
* elf/tst-env-setuid.c: New test case.
* elf/tst-env-setuid-tunables: new test case.
* elf/Makefile (tests-static): Add them.

7 years agoalpha: Use saturating arithmetic in memchr
Richard Henderson [Wed, 1 Feb 2017 22:37:58 +0000 (14:37 -0800)]
alpha: Use saturating arithmetic in memchr

7 years agoFix missing test dependency
Andreas Schwab [Wed, 1 Feb 2017 16:34:06 +0000 (17:34 +0100)]
Fix missing test dependency

7 years agom68k: fix 64bit atomic ops
Andreas Schwab [Wed, 1 Feb 2017 00:30:24 +0000 (01:30 +0100)]
m68k: fix 64bit atomic ops

7 years agoAdd ipc_priv.h header for Nios II to set __IPC_64 to zero.
Chung-Lin Tang [Tue, 31 Jan 2017 14:18:42 +0000 (06:18 -0800)]
Add ipc_priv.h header for Nios II to set __IPC_64 to zero.

7 years agoAdd VZEROUPPER to memset-vec-unaligned-erms.S [BZ #21081]
H.J. Lu [Mon, 30 Jan 2017 18:59:15 +0000 (10:59 -0800)]
Add VZEROUPPER to memset-vec-unaligned-erms.S [BZ #21081]

Since memset-vec-unaligned-erms.S has VDUP_TO_VEC0_AND_SET_RETURN at
function entry, memset optimized for AVX2 and AVX512 will always use
ymm/zmm register. VZEROUPPER should be placed before ret in

L(stosb):
        movq    %rdx, %rcx
        movzbl  %sil, %eax
        movq    %rdi, %rdx
        rep stosb
        movq    %rdx, %rax
        ret

since it can be reached from

L(stosb_more_2x_vec):
        cmpq    $REP_STOSB_THRESHOLD, %rdx
        ja      L(stosb)

[BZ #21081]
* sysdeps/x86_64/multiarch/memset-vec-unaligned-erms.S
(L(stosb)): Add VZEROUPPER before ret.

7 years agoBug 20116: Fix use after free in pthread_create()
Carlos O'Donell [Sun, 29 Jan 2017 00:13:34 +0000 (19:13 -0500)]
Bug 20116: Fix use after free in pthread_create()

The commit documents the ownership rules around 'struct pthread' and
when a thread can read or write to the descriptor. With those ownership
rules in place it becomes obvious that pd->stopped_start should not be
touched in several of the paths during thread startup, particularly so
for detached threads. In the case of detached threads, between the time
the thread is created by the OS kernel and the creating thread checks
pd->stopped_start, the detached thread might have already exited and the
memory for pd unmapped. As a regression test we add a simple test which
exercises this exact case by quickly creating detached threads with
large enough stacks to ensure the thread stack cache is bypassed and the
stacks are unmapped. Before the fix the testcase segfaults, after the
fix it works correctly and completes without issue.

For a detailed discussion see:
https://www.sourceware.org/ml/libc-alpha/2017-01/msg00505.html

7 years agonptl: Add tst-robust-fork
Florian Weimer [Fri, 27 Jan 2017 05:53:19 +0000 (06:53 +0100)]
nptl: Add tst-robust-fork

7 years agostring/tst-strcoll-overflow: Do not accept timeout as test result
Florian Weimer [Wed, 25 Jan 2017 15:27:03 +0000 (16:27 +0100)]
string/tst-strcoll-overflow: Do not accept timeout as test result

The test completes within 300 seconds if enough memory is available.

7 years ago * soft-fp/op-common.h (_FP_MUL, _FP_FMA, _FP_DIV): Add
Jakub Jelinek [Tue, 24 Jan 2017 22:27:36 +0000 (23:27 +0100)]
* soft-fp/op-common.h (_FP_MUL, _FP_FMA, _FP_DIV): Add
/* FALLTHRU */ comments.

7 years agoAdd missing bugzilla reference in previous ChangeLog entry
Adhemerval Zanella [Tue, 24 Jan 2017 12:01:39 +0000 (10:01 -0200)]
Add missing bugzilla reference in previous ChangeLog entry

7 years agoBug 21053: sh: Reduce namespace pollution from sys/ucontext.h
James Clarke [Tue, 24 Jan 2017 11:20:06 +0000 (09:20 -0200)]
Bug 21053: sh: Reduce namespace pollution from sys/ucontext.h

The problem is basically that sys/ucontext.h is defining R0..R15
which happens to conflict with some packages like Firefox when
trying to build on SH.

The very same problem existed on arm back then [1] and it was fixed by
renaming R0..R15 to REG_R0..REG_R15.  This patch imploy a similar
strategy for SH.

Checked on sh4-linux-gnu with run-built-tests=no and I also got reports
that it fixes Firefox build on Debian sh4.

* sysdeps/unix/sysv/linux/sh/sh3/ucontext_i.sym: Use new REG_R*
constants instead of the old R* ones.
* sysdeps/unix/sysv/linux/sh/sh4/ucontext_i.sym: Likewise.
* sysdeps/unix/sysv/linux/sh/sys/ucontext.h (NGPREG): Rename...
(NGREG): ... to this, to fit in with other architectures.
(gpregset_t): Use new NGREG macro.
[__USE_GNU]: Remove condition; all architectures other than tile
are unconditional.
(R*): Rename to REG_R*.

7 years ago* elf/dl-tunables.c (tunable_set_val_if_valid_range): Split into ...
DJ Delorie [Sat, 21 Jan 2017 00:52:52 +0000 (19:52 -0500)]
* elf/dl-tunables.c (tunable_set_val_if_valid_range): Split into ...
(tunable_set_val_if_valid_range_signed) ... this, and ...
(tunable_set_val_if_valid_range_unsigned) ... this.
(tunable_initialize): Call the correct one of the above based on type.

7 years agoRemove very old libm-test-ulps entries.
Joseph Myers [Fri, 20 Jan 2017 23:58:49 +0000 (23:58 +0000)]
Remove very old libm-test-ulps entries.

I noticed that some libm-test-ulps files still had long-obsolete
entries for *_tonearest functions, which will no longer be used since
functions with FE_TONEAREST explicitly set aren't tested separately
from those functions with it as the default rounding mode any more.

This patch removes those obsolete entries.  However, as they are a
sign of libm-test-ulps not having been regenerated from scratch for a
long time, I strongly advise people testing on those platforms to
remove / truncate the libm-test-ulps file, run "make regen-ulps" and
commit the regenerated-from-scratch file.  (Ideally any failures of
libm tests still present after regeneration would be investigated /
fixed - there are several open "math" bugs spread across these
platforms - but simply regenerating from scratch improves things.)

* sysdeps/hppa/fpu/libm-test-ulps: Remove *_tonearest entries.
* sysdeps/ia64/fpu/libm-test-ulps: Likewise.
* sysdeps/m68k/m680x0/fpu/libm-test-ulps: Likewise.
* sysdeps/microblaze/libm-test-ulps: Likewise.
* sysdeps/sh/libm-test-ulps: Likewise.

7 years agoUpdate README.libm-test.
Joseph Myers [Fri, 20 Jan 2017 23:25:13 +0000 (23:25 +0000)]
Update README.libm-test.

This patch updates math/README.libm-test to have a more complete and
up-to-date list of the characters used in TEST_* macros to indicate
the types of function inputs and outputs.

* math/README.libm-test: Update list of characters for input and
output types.

7 years agopowerpc: Fix adapt_count update in __lll_unlock_elision
Tulio Magno Quites Machado Filho [Fri, 20 Jan 2017 18:32:29 +0000 (16:32 -0200)]
powerpc: Fix adapt_count update in __lll_unlock_elision

Commit e9a96ea1aca4ebaa7c86e8b83b766f118d689d0f had an error that
prevents adapt_count from being updated in __lll_unlock_elision.

7 years agoFix mutex pretty printer test and pretty printer output.
Torvald Riegel [Fri, 20 Jan 2017 13:54:49 +0000 (14:54 +0100)]
Fix mutex pretty printer test and pretty printer output.

This fixes the mutex pretty printer so that, if the owner ID isn't recorded
(such as in the current lock elision implementation), "Owner ID" will be shown
as "Unknown" instead of 0. It also changes the mutex printer output so that it
says "Acquired" instead of "Locked". The mutex tests are updated accordingly.

In addition, this adds a paragraph to the "Known issues" section of the
printers README explaining that the printer output isn't guaranteed to cover
every detail.

2017-01-14  Martin Galvan  <martingalvan@sourceware.org>

        * README.pretty-printers (Known issues): Warn about printers not
        always covering everything.
        * nptl/nptl-printers.py (MutexPrinter): Change output.
        * nptl/test-mutex-printers.py: Fix test and adapt to changed output.

7 years agoS390: Adjust lock elision code after review.
Stefan Liebler [Fri, 20 Jan 2017 08:53:04 +0000 (09:53 +0100)]
S390: Adjust lock elision code after review.

This patch adjusts s390 specific lock elision code after review
of the following patches:
-S390: Use own tbegin macro instead of __builtin_tbegin.
(8bfc4a2ab4bebdf86c151665aae8a266e2f18fb4)
-S390: Use new __libc_tbegin_retry macro in elision-lock.c.
(53c5c3d5ac238901c13f28a73ba05b0678094e80)
-S390: Optimize lock-elision by decrementing adapt_count at unlock.
(dd037fb3df286b7c2d0b0c6f8d02a2dd8a8e8a08)

The futex value is not tested before starting a transaction,
__glibc_likely is used instead of __builtin_expect and comments
are adjusted.

ChangeLog:

* sysdeps/unix/sysv/linux/s390/htm.h: Adjust comments.
* sysdeps/unix/sysv/linux/s390/elision-unlock.c: Likewise.
* sysdeps/unix/sysv/linux/s390/elision-lock.c: Adjust comments.
(__lll_lock_elision): Do not test futex before starting a
transaction.  Use __glibc_likely instead of __builtin_expect.
* sysdeps/unix/sysv/linux/s390/elision-trylock.c: Adjust comments.
(__lll_trylock_elision): Do not test futex before starting a
transaction.  Use __glibc_likely instead of __builtin_expect.

7 years agoAdd target to incorporate translations from translations.org
Siddhesh Poyarekar [Fri, 20 Jan 2017 06:54:46 +0000 (12:24 +0530)]
Add target to incorporate translations from translations.org

Add a convenience target for maintainers to download and incorporate
translation updates from translations.org.  Invoke as follows:

  make -r PARALLELMFLAGS="" -C ../po objdir=`pwd` update-translations

similar to generating libc.pot.

* po/Makefile (update-translations): New target.

7 years agoRestore clock_* librt exports for MicroBlaze (bug 21061).
Joseph Myers [Thu, 19 Jan 2017 20:57:16 +0000 (20:57 +0000)]
Restore clock_* librt exports for MicroBlaze (bug 21061).

MicroBlaze had clock_* functions exported from librt in glibc 2.18 and
2.19, as confirmed in
<https://sourceware.org/ml/libc-alpha/2017-01/msg00369.html>, and they
then disappeared in 2.20, presumably as a result of the fix
<https://sourceware.org/ml/libc-alpha/2014-02/msg00598.html> for a
Versions.def bug that had resulted in their unintended inclusion in
2.18 (followed by removal of the Versions.def mechanism that allowed
such bugs).

As they were released in that library, they should be considered part
of the GLIBC_2.18 ABI and so restored for the sake of any binaries
that expect them in that library.  This patch restores them by adding
a MicroBlaze version of clock-compat.c that overrides SHLIB_COMPAT.

Tested (compilation only) with build-many-glibcs.py (where this fixes
the librt ABI test failure; elf/check-execstack still fails and still
needs architecture maintainer attention to fix it or XFAIL it with an
appropriate explanatory comment).

[BZ #21061]
* sysdeps/unix/sysv/linux/microblaze/clock-compat.c: New file.

7 years agoFix environment traversal when an envvar value is empty
Siddhesh Poyarekar [Thu, 19 Jan 2017 19:15:09 +0000 (00:45 +0530)]
Fix environment traversal when an envvar value is empty

The condition when the value of an envvar is empty (not just '\0'),
the loop in tunables_init gets stuck infinitely because envp is not
incremented.  Fix that by always incrementing envp in the loop.

Added test case (tst-empty-env.c) verifies the fix when the source is
configured with --enable-hardcoded-path-in-tests, thanks Josh Stone for
providing the test case.  Verified on x86_64.

* elf/dl-tunables (get_next_env): Always advance envp.
* stdlib/tst-empty-env.c: New test case.
* stdlib/Makefile (tests): Use it.

7 years agoFix ARM fpu_control.h for assemblers requiring VFP insn names (bug 21047).
Joseph Myers [Thu, 19 Jan 2017 00:05:34 +0000 (00:05 +0000)]
Fix ARM fpu_control.h for assemblers requiring VFP insn names (bug 21047).

Bug 21047 reports that the clang assembler disallows the ARM
implementations of _FPU_GETCW and _FPU_SETCW.

These are deliberately written the way they are, using generic
coprocessor instructions (from the days when VFP was just one possible
coprocessor for ARM) that have the right encodings, to handle the case
of the instructions being used runtime-conditionally inside glibc,
where use of these macros is not meant to result in either the
assembler requiring VFP to be enabled at assembly time or in it
marking the object as using VFP.  However, more recent ARM ARM
versions have restricted the definitions of the coprocessor
instructions and reportedly the clang assembler follows that in
disallowing those names for VFP instructions.

In the non-__SOFTFP__ case - which in fact is the only case where
these macro definitions can be used outside the build of glibc itself
- using VFP instruction names is of course fine, since we know that
VFP is enabled for that compilation.  Thus, this patch uses the
current VFP names for these instructions in that case to improve
compatibility for this header file.

Tested for hard-float and soft-float builds of glibc, including that
installed stripped shared libraries are unchanged by the patch.

[BZ #21047]
* sysdeps/arm/fpu_control.h [!__SOFTFP__] (_FPU_GETCW): Use VFP
name for instruction.
[!__SOFTFP__] (_FPU_SETCW): Likewise.

7 years agoAvoid parallel GCC install in build-many-glibcs.py.
Joseph Myers [Wed, 18 Jan 2017 23:13:09 +0000 (23:13 +0000)]
Avoid parallel GCC install in build-many-glibcs.py.

A recent build-many-glibcs.py build
<https://sourceware.org/ml/libc-testresults/2017-q1/msg00067.html> ran
into what proves to be an old known bug
<https://gcc.gnu.org/bugzilla/show_bug.cgi?id=42980> with parallel
install of GCC (one which as discussed there might require automake
changes to fix).  This patch makes build-many-glibcs.py avoid such
intermittent failures from parallel install by using -j1 for GCC make
install (the code in question also applies to binutils make install,
but it doesn't seem worth trying to avoid -j1 there; the builds and
installs of different toolchains are still fully parallel with each
other, this is only about the case when there are few enough of those
that multiple jobs can get used within a single make install).

* scripts/build-many-glibcs.py (Config.build_cross_tool): Use -j1
for make install.

7 years agoMerge translations from the Translation Project
Siddhesh Poyarekar [Wed, 18 Jan 2017 18:51:00 +0000 (00:21 +0530)]
Merge translations from the Translation Project

* po/bg.po: Merge from Translation Project.
* po/fr.po: Likewise.
* po/ko.po: Likewise.
* po/nl.po: Likewise.
* po/sv.po: Likewise.

7 years agoUpdate install.texi latest GCC version known to work.
Joseph Myers [Wed, 18 Jan 2017 17:27:47 +0000 (17:27 +0000)]
Update install.texi latest GCC version known to work.

* manual/install.texi (Tools for Compilation): Update GCC version
known to work to build glibc.
* INSTALL: Regenerated.

7 years agoS390: Fix FAIL in test string/tst-xbzero-opt [BZ #21006]
Stefan Liebler [Tue, 17 Jan 2017 07:54:58 +0000 (08:54 +0100)]
S390: Fix FAIL in test string/tst-xbzero-opt [BZ #21006]

On s390x this test failed with:
FAIL: explicit clear/test: expected 0 got 1

In setup_explicit_clear, the buffer is filled with the test_pattern.
On s390x the memcpy in prepare_test_buffer is done by loading
r4 / r5 with the test_pattern and using store multiple instruction
to store r4 / r5 to buf.
If explicit_bzero is resolved in setup_explicit_clear, r4 / r5 is
stored to stack by _dl_runtime_resolve and the call to memmem in
count_test_patterns finds a hit of the test_pattern on the stack.

This patch resolves all symbols at program startup by linking with
-z now.  This omits the call of _dl_runtime_resolve within
setup_explicit_clear and the test passes.

ChangeLog:

[BZ #21006]
* string/Makefile (LDFLAGS-tst-xbzero-opt): New variable.

7 years agoMake soft-float powerpc swapcontext restore the signal mask (bug 21045).
Joseph Myers [Mon, 16 Jan 2017 21:34:48 +0000 (21:34 +0000)]
Make soft-float powerpc swapcontext restore the signal mask (bug 21045).

The soft-float powerpc version of swapcontext does not restore the
signal mask, resulting in stdlib/tst-setcontext2 failing:

after getcontext
after setcontext
after swapcontext
FAIL: SIGUSR2 is blocked after swapcontext.

This patch fixes this by adjusting the arguments passed to
__sigprocmask so that it restores the saved signal mask as well as
saving the existing one.  (For hard-float, this code is only used for
a compat symbol, not for the current version of swapcontext.)

Tested for soft-float powerpc.

[BZ #21045]
* sysdeps/unix/sysv/linux/powerpc/powerpc32/swapcontext-common.S
(__CONTEXT_FUNC_NAME): Pass address of signal mask to be restored
to __sigprocmask.

7 years agotile: Check for pointer add overflow in memchr
Chris Metcalf [Mon, 16 Jan 2017 20:38:25 +0000 (15:38 -0500)]
tile: Check for pointer add overflow in memchr

As was done in b224637928e9, check for large size causing an overflow
in the loop that walks over the array.

Branching out of line here is the fastest approach for handling this
problem, since tile can bundle the instructions to compute the branch
test in parallel with doing the required memchr loop setup computation.

Unfortunately, the existing saturated ops (e.g. tilegx addxsc) are
all signed saturing ops, so don't help with unsigned saturation.

7 years agotile: pass __IPC_64 as zero for SysV IPC calls
Chris Metcalf [Thu, 12 Jan 2017 15:19:43 +0000 (10:19 -0500)]
tile: pass __IPC_64 as zero for SysV IPC calls

In 1e5834c38a22 ("Refactor Linux ipc_priv header") a different
approach to passing __IPC_64 as zero was created.  The tile
architecture also needs to pass __IPC_64 as zero since it does
not set CONFIG_ARCH_WANT_IPC_PARSE_VERSION in the kernel.
So create a minimal ipc_priv.h that specifies __IPC_64 as zero.

7 years agoFix typo in NEWS
Siddhesh Poyarekar [Sat, 14 Jan 2017 11:07:41 +0000 (16:37 +0530)]
Fix typo in NEWS

The ip6-bytestring resolver corresponds to the RES_USEBSTRING flag and
not RES_NOIP6DOTINT.  Thank you Michael Kerrisk for noticing and
pointing it out.

7 years agoAdd compiler barriers around modifications of the robust mutex list.
Torvald Riegel [Fri, 23 Dec 2016 23:40:46 +0000 (00:40 +0100)]
Add compiler barriers around modifications of the robust mutex list.

Any changes to the per-thread list of robust mutexes currently acquired as
well as the pending-operations entry are not simply sequential code but
basically concurrent with any actions taken by the kernel when it tries
to clean up after a crash.  This is not quite like multi-thread concurrency
but more like signal-handler concurrency.
This patch fixes latent bugs by adding compiler barriers where necessary so
that it is ensured that the kernel crash handling sees consistent data.

This is meant to be easy to backport, so we do not use C11-style signal
fences yet.

* nptl/descr.h (ENQUEUE_MUTEX_BOTH, DEQUEUE_MUTEX): Add compiler
barriers and comments.
* nptl/pthread_mutex_lock.c (__pthread_mutex_lock_full): Likewise.
* nptl/pthread_mutex_timedlock.c (pthread_mutex_timedlock): Likewise.
* nptl/pthread_mutex_unlock.c (__pthread_mutex_unlock_full): Likewise.

7 years agoClear list of acquired robust mutexes in the child process after forking.
Torvald Riegel [Wed, 21 Dec 2016 12:37:19 +0000 (13:37 +0100)]
Clear list of acquired robust mutexes in the child process after forking.

Robust mutexes acquired at the time of a call to fork() do not remain
acquired by the forked child process.  We have to clear the list of
acquired robust mutexes before registering this list with the kernel;
otherwise, if some of the robust mutexes are process-shared, the parent
process can alter the child's robust mutex list, which can lead to
deadlocks or even modification of memory that may not be occupied by a
mutex anymore.

[BZ #19402]
* sysdeps/nptl/fork.c (__libc_fork): Clear list of acquired robust
mutexes.

7 years agorobust mutexes: Fix broken x86 assembly by removing it
Torvald Riegel [Thu, 22 Dec 2016 09:20:43 +0000 (10:20 +0100)]
robust mutexes: Fix broken x86 assembly by removing it

lll_robust_unlock on i386 and x86_64 first sets the futex word to
FUTEX_WAITERS|0 before calling __lll_unlock_wake, which will set the
futex word to 0.  If the thread is killed between these steps, then the
futex word will be FUTEX_WAITERS|0, and the kernel (at least current
upstream) will not set it to FUTEX_OWNER_DIED|FUTEX_WAITERS because 0 is
not equal to the TID of the crashed thread.

The lll_robust_lock assembly code on i386 and x86_64 is not prepared to
deal with this case because the fastpath tries to only CAS 0 to TID and
not FUTEX_WAITERS|0 to TID; the slowpath simply waits until it can CAS 0
to TID or the futex_word has the FUTEX_OWNER_DIED bit set.

This issue is fixed by removing the custom x86 assembly code and using
the generic C code instead.  However, instead of adding more duplicate
code to the custom x86 lowlevellock.h, the code of the lll_robust* functions
is inlined into the single call sites that exist for each of these functions
in the pthread_mutex_* functions.  The robust mutex paths in the latter
have been slightly reorganized to make them simpler.

This patch is meant to be easy to backport, so C11-style atomics are not
used.

[BZ #20985]
* nptl/Makefile: Adapt.
* nptl/pthread_mutex_cond_lock.c (LLL_ROBUST_MUTEX_LOCK): Remove.
(LLL_ROBUST_MUTEX_LOCK_MODIFIER): New.
* nptl/pthread_mutex_lock.c (LLL_ROBUST_MUTEX_LOCK): Remove.
(LLL_ROBUST_MUTEX_LOCK_MODIFIER): New.
(__pthread_mutex_lock_full): Inline lll_robust* functions and adapt.
* nptl/pthread_mutex_timedlock.c (pthread_mutex_timedlock): Inline
lll_robust* functions and adapt.
* nptl/pthread_mutex_unlock.c (__pthread_mutex_unlock_full): Likewise.
* sysdeps/nptl/lowlevellock.h (__lll_robust_lock_wait,
__lll_robust_lock, lll_robust_cond_lock, __lll_robust_timedlock_wait,
__lll_robust_timedlock, __lll_robust_unlock): Remove.
* sysdeps/unix/sysv/linux/i386/lowlevellock.h (lll_robust_lock,
lll_robust_cond_lock, lll_robust_timedlock, lll_robust_unlock): Remove.
* sysdeps/unix/sysv/linux/x86_64/lowlevellock.h (lll_robust_lock,
lll_robust_cond_lock, lll_robust_timedlock, lll_robust_unlock): Remove.
* sysdeps/unix/sysv/linux/sparc/lowlevellock.h (__lll_robust_lock_wait,
__lll_robust_lock, lll_robust_cond_lock, __lll_robust_timedlock_wait,
__lll_robust_timedlock, __lll_robust_unlock): Remove.
* nptl/lowlevelrobustlock.c: Remove file.
* nptl/lowlevelrobustlock.sym: Likewise.
* sysdeps/unix/sysv/linux/i386/lowlevelrobustlock.S: Likewise.
* sysdeps/unix/sysv/linux/x86_64/lowlevelrobustlock.S: Likewise.

7 years agopowerpc: Regenerate ULPs
Tulio Magno Quites Machado Filho [Fri, 13 Jan 2017 11:33:42 +0000 (09:33 -0200)]
powerpc: Regenerate ULPs

After this update, math/test-ildouble, math/test-ldouble and
math/test-ldouble-finite pass on hard float, POWER < 7 builds.

Tested on powerpc, powerpc64 and powerpc64le.

7 years agoMerge translations from the Translation Project
Siddhesh Poyarekar [Thu, 12 Jan 2017 09:37:01 +0000 (15:07 +0530)]
Merge translations from the Translation Project

Update translations from the 2.25 candidate libc.pot.

* po/cs.po: Merge translations from the Translation Project.
* po/de.po: Likewise.
* po/pl.po: Likewise.
* po/ru.po: Likewise.
* po/tr.po: Likewise.
* po/uk.po: Likewise.
* po/vi.po: Likewise.
* po/zh_CN.po: Likewise.

7 years agoFix MIPS o32 posix_fadvise.
Joseph Myers [Thu, 12 Jan 2017 02:19:00 +0000 (02:19 +0000)]
Fix MIPS o32 posix_fadvise.

The posix_fadvise consolidation broke posix_fadvise for MIPS o32, so
resulting in posix/tst-posix_fadvise failing.

MIPS o32 (and the other ABIs) has only the posix_fadvise64 syscall,
which acts like posix_fadvise64_64 (in the o32 case, because of the
alignment argument it's actually a 7-argument syscall).  The generic
posix_fadvise implementation presumes that if __NR_fadvise64 is
defined, it's for the case where a single len argument is passed to
the syscall rather than two syscall arguments in the case of a 32-bit
system.

The generic posix_fadvise64 works fine for this case (defining
__NR_fadvise64_64 to __NR_fadvise64 as needed).  ARM has a
posix_fadvise.c that uses __posix_fadvise64_l64 in posix_fadvise, and
that approach also works for MIPS o32, so this patch makes MIPS o32
include the ARM file.

Tested for MIPS o32.

* sysdeps/unix/sysv/linux/mips/mips32/posix_fadvise.c: New file.

7 years agoMake fallback fegetexceptflag work with generic fetestexceptflag.
Joseph Myers [Thu, 12 Jan 2017 01:52:37 +0000 (01:52 +0000)]
Make fallback fegetexceptflag work with generic fetestexceptflag.

The generic implementation of fetestexceptflag does:

int
fetestexceptflag (const fexcept_t *flagp, int excepts)
{
  /* Most versions of fegetexceptflag store exceptions in a form such
     that this works.  */
  return *flagp & excepts & FE_ALL_EXCEPT;
}

In the case where FE_ALL_EXCEPT is nonzero but exceptions may not be
supported at runtime, this only works if fegetexceptflag cleared all
the bits of FE_ALL_EXCEPT in *flagp; otherwise it accesses
uninitialized data.  This showed up as a failure of
math/test-fetestexceptflag for MIPS o32 soft-float.  This patch makes
the fallback fegetexceptflag store 0 (fexcept_t is an integer type
everywhere) so that this works.  (No bug report in Bugzilla because
this wasn't user-visible - at least, without using tools to detect
uninitialized memory use at runtime - without fetestexceptflag, which
is new in 2.25.)

Tested for MIPS o32 soft-float.

* math/fgetexcptflg.c (__fegetexceptflag): Store 0 in fexcept_t
object.

7 years agoMake endian-conversion macros always return correct types (bug 16458).
Joseph Myers [Wed, 11 Jan 2017 15:28:08 +0000 (15:28 +0000)]
Make endian-conversion macros always return correct types (bug 16458).

Bug 16458 reports that the endian-conversion macros in <endian.h> and
<netinet/in.h>, in the case where no endian conversion is needed, just
return their arguments without converting to the expected return type,
so failing to act as expected for a macro version of a function.  (The
<netinet/in.h> macros, in particular, are described with prototypes in
POSIX so should act like correspondingly prototyped functions.)

Where previously this was a fairly obscure issue, it now results in
glibc build with GCC mainline breaking for big-endian systems:

nss_hesiod/hesiod-service.c: In function '_nss_hesiod_getservbyport_r':
nss_hesiod/hesiod-service.c:142:39: error: '%d' directive output may be truncated writing between 1 and 11 bytes into a region of size 6 [-Werror=format-truncation=]
   snprintf (portstr, sizeof portstr, "%d", ntohs (port));
                                       ^~
nss_hesiod/hesiod-service.c:142:38: note: using the range [1, -2147483648] for directive argument
   snprintf (portstr, sizeof portstr, "%d", ntohs (port));
                                      ^~~~
nss_hesiod/hesiod-service.c:142:3: note: format output between 2 and 12 bytes into a destination of size 6
   snprintf (portstr, sizeof portstr, "%d", ntohs (port));
   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

The port argument is passed as int to this function, so when ntohs
does not convert the compiler cannot tell that the result is within
the range of uint16_t.  (I don't know if in fact it's possible for
out-of-range values to reach this function and so get truncated as
strings without this patch or as integers with it.)

This patch arranges for these macros to use identity functions to
ensure appropriate conversions while having warnings for implicit
conversions of function arguments that might not occur with a cast.

Tested for x86_64 and x86; with build-many-glibcs.py with GCC 6; and
with build-many-glibcs.py with GCC mainline for powerpc to test the
build fix.

[BZ #16458]
* bits/uintn-identity.h: New file.
* inet/netinet/in.h: Include <bits/uintn-identity.h>.
[__BYTE_ORDER == __BIG_ENDIAN] (ntohl): Use __uint32_identity.
[__BYTE_ORDER == __BIG_ENDIAN] (ntohs): Use __uint16_identity.
[__BYTE_ORDER == __BIG_ENDIAN] (htonl): Use __uint32_identity.
[__BYTE_ORDER == __BIG_ENDIAN] (htohs): Use __uint16_identity.
* string/endian.h: Include <bits/uintn-identity.h>.
[__BYTE_ORDER == __LITTLE_ENDIAN] (htole16): Use
__uint16_identity.
[__BYTE_ORDER == __LITTLE_ENDIAN] (le16toh): Likewise.
[__BYTE_ORDER == __LITTLE_ENDIAN] (htole32): Use
__uint32_identity.
[__BYTE_ORDER == __LITTLE_ENDIAN] (le32toh): Likewise.
[__BYTE_ORDER == __LITTLE_ENDIAN] (htole64): Use
__uint64_identity.
[__BYTE_ORDER == __LITTLE_ENDIAN] (le64toh): Likewise.
[__BYTE_ORDER != __LITTLE_ENDIAN] (htobe16): Use
__uint16_identity.
[__BYTE_ORDER != __LITTLE_ENDIAN] (be16toh): Likewise.
[__BYTE_ORDER != __LITTLE_ENDIAN] (htobe32): Use
__uint32_identity.
[__BYTE_ORDER != __LITTLE_ENDIAN] (be32toh): Likewise.
[__BYTE_ORDER != __LITTLE_ENDIAN] (htobe64): Use
__uint64_identity.
[__BYTE_ORDER != __LITTLE_ENDIAN] (be64toh): Likewise.
* string/Makefile (headers): Add bits/uintn-identity.h.
(tests): Add test-endian-types.
* string/test-endian-types.c: New file.
* inet/Makefile (tests): Add test-hnto-types.
* inet/test-hnto-types.c: New file.

7 years agoUpdate translations from the Translation Project
Siddhesh Poyarekar [Wed, 11 Jan 2017 14:05:35 +0000 (19:35 +0530)]
Update translations from the Translation Project

Pulled from:

http://translationproject.org/latest/libc/

7 years agoFix testsuite build for GCC 7 -Wformat-truncation.
Joseph Myers [Wed, 11 Jan 2017 14:02:23 +0000 (14:02 +0000)]
Fix testsuite build for GCC 7 -Wformat-truncation.

This patch fixes the glibc testsuite build for GCC 7
-Wformat-truncation, newly moved out of -Wformat-length and with some
further warnings that didn't previously appear.  Two tests that
previously disabled -Wformat-length are changed to disable
-Wformat-truncation instead; two others are made to disable that
option as well.

Tested (compilation only) with build-many-glibcs.py for aarch64 with
GCC mainline.

* stdio-common/tst-printf.c [__GNUC_PREREQ (7, 0)]: Ignore
-Wformat-truncation instead of -Wformat-length.
* time/tst-strptime2.c (mkbuf) [__GNUC_PREREQ (7, 0)]: Likewise.
* stdio-common/tstdiomisc.c (F): Ignore -Wformat-truncation for
GCC 7.
* wcsmbs/tst-wcstof.c: Include <libc-internal.h>.
(do_test): Ignore -Wformat-truncation for GCC 7.

7 years agoFix ld-address format-truncation error.
Joseph Myers [Wed, 11 Jan 2017 13:59:01 +0000 (13:59 +0000)]
Fix ld-address format-truncation error.

With the elf/sotruss-lib.c failure fixed, building 64-bit glibc with
GCC mainline fails with another format-truncation error in
locale/programs/ld-address.c, where 11 bytes are allocated for a
buffer to print a long int value.

This patch changes that code to allocate 21 bytes.  Treating this
value as signed is questionable and I don't think large values are
actually useful here, but I think those can be considered as instances
of bug 21036 which I've filed for overflow checks for numeric values
in localedef in general, and don't need to be addressed to fix the
build.

Tested with GCC mainline with compilation for aarch64 with
build-many-glibcs.py, and with glibc testsuite for x86_64 (built with
GCC 6).

(Note that while this fixes the build of 64-bit glibc with GCC
mainline, further fixes will be needed to get the testsuite building
with GCC mainline again.)

* locale/programs/ld-address.c (INT_STR_ELEM): Increase size of
buffer used to print long int value.

7 years agoFix elf/sotruss-lib format-truncation error.
Joseph Myers [Wed, 11 Jan 2017 13:57:59 +0000 (13:57 +0000)]
Fix elf/sotruss-lib format-truncation error.

Building 64-bit glibc with GCC mainline fails with:

../elf/sotruss-lib.c: In function 'la_version':
../elf/sotruss-lib.c:91:28: error: '%lu' directive output may be truncated writing between 1 and 20 bytes into a region of size 11 [-Werror=format-truncation=]
      snprintf (endp, 12, ".%lu", (unsigned long int) pid);
                            ^~~
../elf/sotruss-lib.c:91:26: note: using the range [1, 18446744073709551615] for directive argument
      snprintf (endp, 12, ".%lu", (unsigned long int) pid);
                          ^~~~~~
../elf/sotruss-lib.c:91:6: note: format output between 3 and 22 bytes into a destination of size 12
      snprintf (endp, 12, ".%lu", (unsigned long int) pid);
      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Pids from getpid cannot actually be negative, but the compiler doesn't
know this.  Other places in this file use (signed) long int for
printing, so this patch makes this place do so as well.  Then it
increases the buffer size by one byte to allow for the minus sign that
can't actually occur.  It doesn't seem worth using diagnostic pragmas
to save one byte; other place in this file just use a cruder 3 *
sizeof (pid_t) calculation for number of digits.

Tested with GCC mainline with compilation for aarch64 with
build-many-glibcs.py, and with glibc testsuite for x86_64 (built with
GCC 6).

* elf/sotruss-lib.c (init): Increase space allocated for pid by
one byte.  Print it with %ld, cast to long int.

7 years agoMake build-many-glibcs.py work on python3.2
Szabolcs Nagy [Tue, 10 Jan 2017 18:31:19 +0000 (16:31 -0200)]
Make build-many-glibcs.py work on python3.2

I used this patch to run the new build script with python3.2, it may be worth
adding this hack if python3.5 is not widespread (might work with older python,
i haven't tested that).

This patch make build-many-glibcs.py work with python 3.2 by
adding fallback implementation to python 3.5 facilities if they
are not present.

Checked building a x86_64-linux-gnu toolchain with python 3.2.

2016-11-22  Szabolcs Nagy  <szabolcs.nagy@arm.com>

* scripts/build-many-glibcs.py (os.cpu_count): Add compatibility definition.
(re.fullmatch, subprocess.run): Likewise.

7 years agoRegenerate libc.pot
Siddhesh Poyarekar [Wed, 11 Jan 2017 11:58:58 +0000 (17:28 +0530)]
Regenerate libc.pot

7 years agotunables: Avoid getenv calls and disable glibc.malloc.check by default
Siddhesh Poyarekar [Tue, 10 Jan 2017 11:05:58 +0000 (16:35 +0530)]
tunables: Avoid getenv calls and disable glibc.malloc.check by default

Builds with --enable-tunables failed on i686 because a call to getenv
got snuck into tunables, which pulled in strncmp.  This patch fixes
this build failure by making the glibc.malloc.check check even
simpler.  The previous approach was convoluted where the tunable was
disabled using an unsetenv and overwriting the tunable value with
colons.  The easier way is to simply mark the tunable as insecure by
default (i.e. won't be read for AT_SECURE programs) and then enabled
only when the /etc/suid-debug file is found.

This also ends up removing a bunch of functions that were specially
reimplemented (strlen, unsetenv) to avoid calling into string
routines.

Tested on x86_64 and i686.

* elf/dl-tunables.c (tunables_unsetenv): Remove function.
(min_strlen): Likewise.
(disable_tunable): Likewise.
(maybe_disable_malloc_check): Rename to
maybe_enable_malloc_check.
(maybe_enable_malloc_check): Enable glibc.malloc.check tunable
if /etc/suid-debug file exists.
(__tunables_init): Update caller.
* elf/dl-tunables.list (glibc.malloc.check): Don't mark as
secure.

7 years agoNew pthread rwlock that is more scalable.
Torvald Riegel [Thu, 22 May 2014 14:00:12 +0000 (16:00 +0200)]
New pthread rwlock that is more scalable.

This replaces the pthread rwlock with a new implementation that uses a
more scalable algorithm (primarily through not using a critical section
anymore to make state changes).  The fast path for rdlock acquisition and
release is now basically a single atomic read-modify write or CAS and a few
branches.  See nptl/pthread_rwlock_common.c for details.

* nptl/DESIGN-rwlock.txt: Remove.
* nptl/lowlevelrwlock.sym: Remove.
* nptl/Makefile: Add new tests.
* nptl/pthread_rwlock_common.c: New file.  Contains the new rwlock.
* nptl/pthreadP.h (PTHREAD_RWLOCK_PREFER_READER_P): Remove.
(PTHREAD_RWLOCK_WRPHASE, PTHREAD_RWLOCK_WRLOCKED,
PTHREAD_RWLOCK_RWAITING, PTHREAD_RWLOCK_READER_SHIFT,
PTHREAD_RWLOCK_READER_OVERFLOW, PTHREAD_RWLOCK_WRHANDOVER,
PTHREAD_RWLOCK_FUTEX_USED): New.
* nptl/pthread_rwlock_init.c (__pthread_rwlock_init): Adapt to new
implementation.
* nptl/pthread_rwlock_rdlock.c (__pthread_rwlock_rdlock_slow): Remove.
(__pthread_rwlock_rdlock): Adapt.
* nptl/pthread_rwlock_timedrdlock.c
(pthread_rwlock_timedrdlock): Adapt.
* nptl/pthread_rwlock_timedwrlock.c
(pthread_rwlock_timedwrlock): Adapt.
* nptl/pthread_rwlock_trywrlock.c (pthread_rwlock_trywrlock): Adapt.
* nptl/pthread_rwlock_tryrdlock.c (pthread_rwlock_tryrdlock): Adapt.
* nptl/pthread_rwlock_unlock.c (pthread_rwlock_unlock): Adapt.
* nptl/pthread_rwlock_wrlock.c (__pthread_rwlock_wrlock_slow): Remove.
(__pthread_rwlock_wrlock): Adapt.
* nptl/tst-rwlock10.c: Adapt.
* nptl/tst-rwlock11.c: Adapt.
* nptl/tst-rwlock17.c: New file.
* nptl/tst-rwlock18.c: New file.
* nptl/tst-rwlock19.c: New file.
* nptl/tst-rwlock2b.c: New file.
* nptl/tst-rwlock8.c: Adapt.
* nptl/tst-rwlock9.c: Adapt.
* sysdeps/aarch64/nptl/bits/pthreadtypes.h (pthread_rwlock_t): Adapt.
* sysdeps/arm/nptl/bits/pthreadtypes.h (pthread_rwlock_t): Adapt.
* sysdeps/hppa/nptl/bits/pthreadtypes.h (pthread_rwlock_t): Adapt.
* sysdeps/ia64/nptl/bits/pthreadtypes.h (pthread_rwlock_t): Adapt.
* sysdeps/m68k/nptl/bits/pthreadtypes.h (pthread_rwlock_t): Adapt.
* sysdeps/microblaze/nptl/bits/pthreadtypes.h (pthread_rwlock_t): Adapt.
* sysdeps/mips/nptl/bits/pthreadtypes.h (pthread_rwlock_t): Adapt.
* sysdeps/nios2/nptl/bits/pthreadtypes.h (pthread_rwlock_t): Adapt.
* sysdeps/s390/nptl/bits/pthreadtypes.h (pthread_rwlock_t): Adapt.
* sysdeps/sh/nptl/bits/pthreadtypes.h (pthread_rwlock_t): Adapt.
* sysdeps/sparc/nptl/bits/pthreadtypes.h (pthread_rwlock_t): Adapt.
* sysdeps/tile/nptl/bits/pthreadtypes.h (pthread_rwlock_t): Adapt.
* sysdeps/unix/sysv/linux/alpha/bits/pthreadtypes.h
(pthread_rwlock_t): Adapt.
* sysdeps/unix/sysv/linux/powerpc/bits/pthreadtypes.h
(pthread_rwlock_t): Adapt.
* sysdeps/x86/bits/pthreadtypes.h (pthread_rwlock_t): Adapt.
* nptl/nptl-printers.py (): Adapt.
* nptl/nptl_lock_constants.pysym: Adapt.
* nptl/test-rwlock-printers.py: Adapt.
* nptl/test-rwlockattr-printers.c: Adapt.
* nptl/test-rwlockattr-printers.py: Adapt.

7 years agoXFAIL libm-test.inc tests as needed for ibm128.
Joseph Myers [Tue, 10 Jan 2017 00:14:09 +0000 (00:14 +0000)]
XFAIL libm-test.inc tests as needed for ibm128.

This patch arranges for various libm-test.inc tests to be XFAILed for
ibm128-libgcc in non-default rounding modes.  The tests are marked
with XFAIL_ROUNDING_IBM128_LIBGCC and gen-libm-test.pl is made to
transform that to XFAIL_IBM128_LIBGCC or 0 depending on the rounding
mode.

This should allow test-ldouble, test-ildouble and test-ldouble-finite
to pass with unmodified libgcc, given an ulps regeneration.  (The case
of patched libgcc was already clean up to ulps and possibly hypot
cases very close to the overflow threshold that may need more
XFAILing; patched libgcc, which should work with
TEST_COND_ibm128_libgcc defined to 0 to disable all these XFAILs, does
need slightly different ulps from unpatched.)  Note that soft-float
powerpc will still fail because of
<https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64811> resulting in
spurious "invalid" exceptions in the libgcc code (for hard float,
<https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58684> hides that bug).

Tested for powerpc.

* math/libm-test.inc (XFAIL_IBM128_LIBGCC): New macro.
(fdim_test_data): Use XFAIL_ROUNDING_IBM128_LIBGCC for some tests.
(fma_test_data): Likewise.
(hypot_test_data): Likewise.
(log1p_test_data): Likewise.
(modf_test_data): Likewise.
(pow_test_data): Likewise.
(remainder_test_data): Likewise.
(remquo_test_data): Likewise.
(scalb_test_data): Likewise.
(scalbn_test_data): Likewise.
(scalbln_test_data): Likewise.
* math/gen-libm-test.pl (parse_args): Transform
XFAIL_ROUNDING_IBM128_LIBGCC to XFAIL_IBM128_LIBGCC or 0 depending
on the rounding mode.

7 years agoImprove libm-test XFAILing for ibm128-libgcc.
Joseph Myers [Mon, 9 Jan 2017 22:40:59 +0000 (22:40 +0000)]
Improve libm-test XFAILing for ibm128-libgcc.

This patch further improves XFAILing for ibm128-libgcc of tests in
auto-libm-test-*.

The bulk of the cases needing XFAILing are
xfail-rounding:ibm128-libgcc used for inputs where (possibly after
rounding the inputs to another floating-point type) the result
overflows (and the result in non-default rounding modes may be wildly
wrong with unpatched libgcc) or underflows near 0 (and the result in
non-default rounding modes may end up having the wrong sign).  This
patch makes gen-auto-libm-tests detect such cases and apply
xfail-rounding:ibm128-libgcc automatically to them, so most of the
manual XFAILs in auto-libm-test-in are no longer needed (some are
still needed if e.g. the result is very close to overflow, resulting
in an internal overflow in libgcc in some rounding modes).  A few
manual XFAILs are added for cases not covered by this
gen-auto-libm-tests change, and a few existing such XFAILs are left
in.

Tested for powerpc.

* math/gen-auto-libm-tests.c (output_for_one_input_case): Apply
xfail-rounding:ibm128-libgcc automatically to tests overflowing
and those that can underflow to zero.
* math/auto-libm-test-in: Remove most XFAILs for ibm128-libgcc and
add others.
* math/auto-libm-test-out: Regenerated.

7 years agoFix math/test-fenv for no-exceptions / no-rounding-modes configurations.
Joseph Myers [Mon, 9 Jan 2017 18:27:49 +0000 (18:27 +0000)]
Fix math/test-fenv for no-exceptions / no-rounding-modes configurations.

This patch fixes math/test-fenv.c to check EXCEPTION_TESTS and
ROUNDING_TESTS to avoid failing in cases where some exceptions or
rounding modes are defined but not supported at runtime.

Tested for mips64 soft float and for x86_64.

* math/test-fenv.c (fe_tests): Skip most tests when exceptions not
supported.
(feholdexcept_tests): Skip tests requiring exceptions or rounding
modes support if not supported.

7 years agoUpdate MicroBlaze localplt.data.
Joseph Myers [Mon, 9 Jan 2017 16:09:53 +0000 (16:09 +0000)]
Update MicroBlaze localplt.data.

This patch updates the MicroBlaze localplt.data based on the results
of a build with build-many-glibcs.py.  This is simply an empirical
update; quite possibly the port could be optimized to remove more
local PLT entry usage.

Tested (compilation tests) with build-many-glibcs.py.

* sysdeps/unix/sysv/linux/microblaze/localplt.data (__pread64):
Add libc.so PLT entry.
(__tls_get_addr): Make ld.so PLT entry optional.

7 years agoMove fortified explicit_bzero back to string3
Adhemerval Zanella [Fri, 6 Jan 2017 13:05:27 +0000 (11:05 -0200)]
Move fortified explicit_bzero back to string3

Commit 38765ab68f329fd moved the bzero, bcopy, and explicit_bzero
fortified macros to a common header (strings_fortified.h).  However
the side effect is a fortified explicit_bzero is defined when including
only strings.h.

This patch moves back the fortified explicit_bzero definition to
strings3.h header.

Checked on x86_64-linux-gnu.

* string/bits/strings_fortified.h (explicit_bzero): Move back to ..
* string/bits/string3.h: ... here.

7 years agoMake fallback fesetexceptflag always succeed (bug 21028).
Joseph Myers [Thu, 5 Jan 2017 23:15:47 +0000 (23:15 +0000)]
Make fallback fesetexceptflag always succeed (bug 21028).

The fallback implementation of fesetexceptflag currently fails if any
exceptions are specified.  It should always succeed, because the
exception state is always that all exceptions (if any are defined in
<fenv.h> but not supported in this configuration) are always clear,
just as fallback fetestexcept always succeeds and fallback fesetenv
always succeeds unless asked to set FE_NOMASK_ENV.

This patch fixes it accordingly.  Together with the patch to
test-fexcept.c to allow feraiseexcept to fail in another place, this
stops that test from failing for MIPS soft-float.

Tested for mips64 soft-float.

[BZ #21028]
* math/fsetexcptflg.c (__fesetexceptflag): Always return 0.
* math/test-fexcept.c (test_set): Allow failure of feraiseexcept
if EXCEPTION_TESTS returns false.

7 years agoUse fortify macros for b{zero,copy} along decl from strings.h
Adhemerval Zanella [Thu, 5 Jan 2017 12:07:24 +0000 (10:07 -0200)]
Use fortify macros for b{zero,copy} along decl from strings.h

As described in BZ#20558, bzero and bcopy declaration can only benefit
from fortified macros when decl came from string.h and when __USE_MISC
is defined (default behaviour).

This is due no standard includes those functions in string.h, so they
are only declared if __USE_MISC is defined (as pointed out in comment 4).
However fortification should be orthogona to other features test macros,
i.e, any function should be fortified if that function is declared.

To fix this behavior, the patch moved the bzero, bcopy, and
__explicit_bzero_chk to a common header (string/bits/strings_fortified.h)
and explicit fortified inclusion macros similar to string.h is added
on strings.h.  This allows to get fortified declarions by only including
strings.h.

Checked on x86_64-linux-gnu and along on a bootstrap installation to check
if the fortified are correctly triggered with example from bug report.

[BZ #20558]
* string/bits/string3.h [__USE_MISC] (bcopy): Move to
strings_fortified.h.
[__USE_MISC] (bzero): Likewise.
[__USE_MISC] (explicit_bzero): Likewise.
* string/strings.h: Include strings_fortified.h.
* string/Makefile (headers): Add strings_fortified.h.
* string/bits/strings_fortified.h: New file.
* include/bits/strings_fortified.h: Likewise.

7 years agoIncrease some test timeouts.
Joseph Myers [Thu, 5 Jan 2017 17:39:38 +0000 (17:39 +0000)]
Increase some test timeouts.

This patch increases timeouts on some tests I've observed timing out.

elf/tst-tls13 and iconvdata/tst-loading both dynamically load many
objects and so are slow when testing over NFS.  They had timeouts set
from before the default changed from 2 to 20 seconds; this patch
removes those old settings, so effectively increasing the timeout to
20 seconds (from 3 and 10 seconds respectively).

malloc/tst-malloc-thread-fail.c and malloc/tst-mallocfork2.c are slow
on slow systems and so I set a fairly arbitrary 100 second timeout,
which seems to suffice on the system where I saw them timing out.

nss/tst-cancel-getpwuid_r.c and nss/tst-nss-getpwent.c are slow on
systems with a large passwd file; I set timeouts that empirically
worked for me.  (It seems tst-cancel-getpwuid_r.c is hitting the
100000 getpwuid_r call limit in my testing, with each call taking a
bit over 0.007 seconds, so 700 seconds for the test.)

* elf/tst-tls13.c (TIMEOUT): Remove.
* iconvdata/tst-loading.c (TIMEOUT): Likewise.
* malloc/tst-malloc-thread-fail.c (TIMEOUT): Increase to 100.
* malloc/tst-mallocfork2.c (TIMEOUT): Define to 100.
* nss/tst-cancel-getpwuid_r.c (TIMEOUT): Define to 900.
* nss/tst-nss-getpwent.c (TIMEOUT): Define to 300.

7 years agoFix MIPS n64 readahead (bug 21026).
Joseph Myers [Thu, 5 Jan 2017 17:35:53 +0000 (17:35 +0000)]
Fix MIPS n64 readahead (bug 21026).

As noted in bug 20126, MIPS n64 uses an incorrect implementation of
readahead intended for 32-bit systems.  This patch adds a
syscalls.list entry to fix this.  An updated version of the
consolidation patch
<https://sourceware.org/ml/libc-alpha/2016-09/msg00527.html> could
remove this syscalls.list entry again.

Tested with compilation (only) for mips64; the nature of the syscall
doesn't allow for a glibc test to detect this issue.

[BZ #21026]
* sysdeps/unix/sysv/linux/mips/mips64/n64/syscalls.list
(readahead): New syscall entry.

7 years agoFix string/tester.c for GCC 7 -Wstringop-overflow=.
Joseph Myers [Wed, 4 Jan 2017 23:33:31 +0000 (23:33 +0000)]
Fix string/tester.c for GCC 7 -Wstringop-overflow=.

GCC 7 has a -Wstringop-overflow= warning that includes warning for
strncat with a size specified that is larger than the size of the
buffer (which is dubious usage, but valid at runtime if in fact there
isn't an overflow with the particular buffer contents present).
string/tester.c tests such cases; this patch arranges for this warning
to be ignored around relevant strncat calls.

Tested compilation for aarch64 (GCC mainline) with
build-many-glibcs.py; did execution testing for x86_64 (GCC 5).

* string/tester.c (test_strncat): Disable -Wstringop-overflow=
around tests of strncat with large sizes.

7 years agoFix malloc/ tests for GCC 7 -Walloc-size-larger-than=.
Joseph Myers [Wed, 4 Jan 2017 23:32:14 +0000 (23:32 +0000)]
Fix malloc/ tests for GCC 7 -Walloc-size-larger-than=.

GCC 7 has a -Walloc-size-larger-than= warning for allocations of half
the address space or more.  This causes errors building glibc tests
that deliberately test failure of very large allocations.  This patch
arranges for this warning to be ignored around the problematic
function calls.

Tested compilation for aarch64 (GCC mainline) with
build-many-glibcs.py; did execution testing for x86_64 (GCC 5).

* malloc/tst-malloc.c: Include <libc-internal.h>.
(do_test): Disable -Walloc-size-larger-than= around tests of
malloc with negative sizes.
* malloc/tst-mcheck.c: Include <libc-internal.h>.
(do_test): Disable -Walloc-size-larger-than= around tests of
malloc and realloc with negative sizes.
* malloc/tst-realloc.c: Include <libc-internal.h>.
(do_test): Disable -Walloc-size-larger-than= around tests of
realloc with negative sizes.

7 years agoUpdate libm-test XFAILs for ibm128 format.
Joseph Myers [Wed, 4 Jan 2017 23:29:42 +0000 (23:29 +0000)]
Update libm-test XFAILs for ibm128 format.

This patch cleans up and updates the libm-test XFAILs for the ibm128
format.  More of them are changed to use a new ibm128-libgcc
conditional, to reflect that they are not in fact needed if you've
patched libgcc to fix the known issues (at substantial performance
cost).  Many additional XFAILs are added for tests that fail with
unpatched libgcc (most but not all of them xfail-rounding).

Note that further such fixes will be needed for test-ldouble actually
to pass with default libgcc (in particular, XFAILs for pow tests and
for various affected tests directly embedded in libm-test.inc).  With
patched libgcc, there may be a few XFAILs needed but the results are
already substantially clean apart from a few ulps differences.

Tested for powerpc.

* math/libm-test.inc (TEST_COND_ibm128_libgcc): New macro.
(init_max_error) [TEST_COND_ibm128]: Increase maximum error
allowed to 16 ulps.
* math/auto-libm-test-in: Change most XFAILs for ibm128 to use
ibm128-libgcc.  XFAIL more tests for ibm128-libgcc.
* math/auto-libm-test-out: Regenerated.

7 years agoMove wrappers to libm-compat-calls-auto
Gabriel F. T. Gomes [Wed, 14 Dec 2016 00:42:51 +0000 (22:42 -0200)]
Move wrappers to libm-compat-calls-auto

This commit moves one step towards the deprecation of wrappers that
use _LIB_VERSION / matherr / __kernel_standard functionality, by
adding the suffix '_compat' to their filenames and adjusting Makefiles
and #includes accordingly.

New template wrappers that do not use such functionality will be added
by future patches and will be first used by the float128 wrappers.