This is transformed into rawmemchr by the bits/string2.h header.
However this is generally slower than strlen on most targets, even when
an optimized rawmemchr implementation exists. Since GCC7 optimizes
strchr (s, '\0') to strlen (s) + s, the GLIBC headers should not
transform this to rawmemchr. As GCC recognizes strchr as a builtin,
defining strchr as the builtin is not useful.
* string/bits/string2.h (strchr): Remove define.
When I moved tests of csin and csinh to auto-libm-test-in, I didn't
move a few tests for which gen-auto-libm-tests was very slow because
of MPC slowness on certain inputs.
Now that auto-libm-test-out has been split up, such slowness only
affects regenerating the test expectations for the individual
functions in question, rather than any addition of tests for any
function to auto-libm-test-in. Thus, I no longer consider it a
problem to have these inputs in auto-libm-test-in, and this patch
moves them there. This results in test generation for csin and csinh
taking 5m43s (for each of csin and csinh) on my system, while other
functions are unaffected.
I expect the test generation to be much faster in MPC 1.1 (the
relevant performance improvements went in MPC mainline in Dec 2013,
but there hasn't been a release from mainline since then).
Tested for x86_64 and x86.
* math/auto-libm-test-in: Add more tests of csin and csinh.
* math/auto-libm-test-out-csin: Regenerated.
* math/auto-libm-test-out-csinh: Likewise.
* math/libm-test-csin.inc (csin_test_data): Remove tests moved to
auto-libm-test-in.
* math/libm-test-csinh.inc (csinh_test_data): Likewise.
Both libm-compat-calls and libm-compat-calls-auto list the functions
that must be built for the types float, double, and long double, but
not for other floating-point types that get added to libm. Besides
that, the use of libm-compat-calls-ldouble-yes to select if
w_lgamma_compatl and k_standardl should be built for long-double (in
libm-compat-calls) has the same effect of the use of type-foreach
(in libm-compat-calls-auto).
This patch merges the contents of libm-compat-calls into
libm-compat-calls-auto, then renames the latter to libm-compat-calls.
Tested for powerpc64le, s390, and x86_64.
* math/Makefile (libm-compat-calls-ldouble-yes): Merge into
libm-compat-calls-auto.
(libm-compat-calls): Likewise.
(libm-compat-calls-auto): Rename to libm-compat-calls and add
w_lgamma_compatF and k_standardF (merged from the items above).
(libm-routines): Use libm-compat-calls, instead of
libm-compat-calls-auto, with type-foreach.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
This patch removes the COLORING_INCREMENT define and usage on allocatestack.c.
It has not been used since 564cd8b67e (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.
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.
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.
It is no longer needed to preserve the flags parameter to `clone' since
the commit c579f48edb (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.
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.
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
As noted by c1f0601389, 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.
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.
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
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.
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.
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.
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.
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
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*.
(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.
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.
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.
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.
This patch adjusts s390 specific lock elision code after review
of the following patches:
-S390: Use own tbegin macro instead of __builtin_tbegin.
(8bfc4a2ab4)
-S390: Use new __libc_tbegin_retry macro in elision-lock.c.
(53c5c3d5ac)
-S390: Optimize lock-elision by decrementing adapt_count at unlock.
(dd037fb3df)
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.
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.
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.
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.
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.
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.
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.
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.
As was done in b224637928, 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.
In 1e5834c38a ("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.
The ip6-bytestring resolver corresponds to the RES_USEBSTRING flag and
not RES_NOIP6DOTINT. Thank you Michael Kerrisk for noticing and
pointing it out.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
Commit 38765ab68f 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.
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.
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.
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.
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.
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.
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.
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.
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.
For MicroBlaze, setjmp/check-installed-headers-cxx fails with:
../setjmp/setjmp.h:34:8: error: '__jmp_buf_tag' has a field '__jmp_buf_tag::__jmpbuf' whose type depends on the type '<unnamed struct>' which has no linkage [-Werror=subobject-linkage]
This patch fixes this in the same way as for some other architectures:
the struct used for the internal __jmp_buf type is given the tag
__jmp_buf_internal_tag.
Tested (compilation tests) with build-many-glibcs.py.
* sysdeps/microblaze/bits/setjmp.h (__jmp_buf): Give struct tag
__jmp_buf_internal_tag.
This corresponds to a patch applied to libgcc. In glibc it doesn't
actually affect much (only fma, I think).
The MIPS sfp-machine.h files have an _FP_CHOOSENAN implementation
which emulates hardware semantics of not preserving signaling NaN
payloads for an operation with two NaN arguments (although that
doesn't suffice to avoid sNaN payload preservation in any case with
just one NaN argument).
However, those are only hardware semantics in the legacy NaN case; in
the NAN2008 case, the architecture documentation says hardware
preserves payloads in such cases. Furthermore, this implementation
assumes legacy NaN semantics, so in the NAN2008 case the
implementation actually has the effect of preserving sNaN payloads but
not preserving qNaN payloads, when both should be preserved.
This patch fixes the code just to copy from the first argument.
Tested for mips64 soft-float.
* sysdeps/mips/mips32/sfp-machine.h (_FP_CHOOSENAN): Always
preserve NaN payload if [__mips_nan2008].
* sysdeps/mips/mips64/sfp-machine.h (_FP_CHOOSENAN): Likewise.
Many linknamespace tests fail for MicroBlaze because __backtrace (as
brought in by libc_fatal.c) uses an inline function get_frame_size
which is not declared static. This patch fixes it to be declared
static.
Tested (compilation tests) with build-many-glibcs.py.
[BZ #21022]
* sysdeps/microblaze/backtrace.c (get_frame_size): Make static.
When testing changes to i386 libm functions (that are shadowed for
i686 builds by i686 versions) recently, I saw that the plain i386
libm-test-ulps (as opposed to the i686 multiarch version) needed
updating for tests that had been added since it was last updated.
This patch updates it accordingly.
* sysdeps/i386/fpu/libm-test-ulps: Update.
Since commit 6e46de42fe default strcat implementation is essentially
the same for specialized ia64 and powerpc ones. This patch removes the
redundant implementation and adjust powerpc64 ifunc code to use the
default one.
Checked on powerpc32-linux-gnu (default and power4) and ia64-linux build
and on powerpc64le-linux-gnu.
* sysdeps/ia64/strcat.c: Remove file.
* sysdeps/powerpc/strcat.c: Likewise.
* sysdeps/powerpc/powerpc64/multiarch/strcat-power7.c: Use default
C implementation.
* sysdeps/powerpc/powerpc64/multiarch/strcat-power8.c: Likewise.
* sysdeps/powerpc/powerpc64/multiarch/strcat-ppc64.c: Likewise.
The update of *adapt_count after the release of the lock causes a race
condition when thread A unlocks, thread B continues and destroys the
mutex, and thread A writes to *adapt_count.
This patch fixes math/test-fenvinline.c to stop it failing in
no-exceptions configurations (where some exception macros are defined
but may not be supported at runtime). The relevant parts of the test
are disabled in that case; some parts can still run (and the rounding
mode tests are written in a way such that they work even if the
rounding modes aren't supported).
Tested for mips64 soft-float, and for x86_64 to make sure the tests
still run when the exceptions are supported.
* math/test-fenvinline.c (do_test): Disable tests of raised
exceptions if !EXCEPTION_TESTS (FLOAT).
Similar to BZ#19387, BZ#21014, and BZ#20971, both x86 sse2 strncat
optimized assembly implementations do not handle the size overflow
correctly.
The x86_64 one is in fact an issue with strcpy-sse2-unaligned, but
that is triggered also with strncat optimized implementation.
This patch uses a similar strategy used on 3daef2c8ee, where
saturared math is used for overflow case.
Checked on x86_64-linux-gnu and i686-linux-gnu. It fixes BZ #19390.
[BZ #19390]
* string/test-strncat.c (test_main): Add tests with SIZE_MAX as
maximum string size.
* sysdeps/i386/i686/multiarch/strcat-sse2.S (STRCAT): Avoid overflow
in pointer addition.
* sysdeps/x86_64/multiarch/strcpy-sse2-unaligned.S (STRCPY):
Likewise.
elf/Makefile passes arguments to tst-ldconfig-X.sh that are different
from what it expects, so resulting in the test failing in cross
testing. This patch corrects the arguments passed (the script itself
has correct logic for cross testing, it's just the Makefile that's
wrong).
Tested for powerpc (cross testing) and for x86_64 (native testing).
* elf/Makefile ($(objpfx)tst-ldconfig-X.out): Correct arguments
passed to tst-ldconfig-X.sh.
Mixing them up breaks the gdb pretty printer tests.
ChangeLog:
2017-01-02 Martin Galvan <martingalvan@sourceware.org>
* nptl/nptl-printers.py: Fix tabs/spaces mismatches.
The lseek consolidation broke lseek64 for MIPS n32, so resulting in
io/test-lfs failing with an incorrect return from ftello64. This
configuration uses the lseek syscall with a 64-bit return value; as
the C syscall macros return long, they cannot be used in this case and
so an assembly implementation is needed; accordingly, this patch adds
lseek64 back to syscalls.list for this configuration.
lseek was also broken, truncating the result without checking for
overflow. lseek however was already broken before the consolidation;
it aliased lseek64 so would return an out-of-range value, resulting in
architecturally undefined behavior in the caller if it tried to use a
non-sign-extended value with a 32-bit instruction. This patch adds a
custom lseek implementation in C for n32, which calls __lseek64 to get
the 64-bit value then checks for overflow.
Because the prior lseek breakage did not show in test results, and the
lseek64 breakage showed only indirectly through tests of ftello64,
test coverage was clearly inadequate. This patch extends
io/test-lfs.c to test the lseek64 return value (at a point where it
has already seeked over 2GB into a file), and then to test the lseek
return value (with the latter's expectations depending on whether
off_t is smaller than off64_t).
Tested for mips64 n32. Also tested test-lfs for x86_64 and x86, where
as expected it passes.
[BZ #21019]
* sysdeps/unix/sysv/linux/mips/mips64/n32/syscalls.list (lseek64):
New syscall entry.
* sysdeps/unix/sysv/linux/mips/mips64/n32/lseek.c: New file.
* io/test-lfs.c (do_test): Test offset returned from lseek64 and
lseek.
The 32-bit powerpc configurations in build-many-glibcs.py were failing
to cover the powerpc32 multiarch code at all, because that code is
only built for power4 and above configurations. This patch adds a
32-bit power4 configuration so that at least some of that multiarch
code gets build-tested. (This is preparation for reviewing the w_*
file renaming, which affects such powerpc32 multiarch files.)
* scripts/build-many-glibcs.py (Context.add_all_configs): Add
power4 glibc for powerpc-linux-gnu.
The command IPC_STAT of semctl expects an union semun in its fourth
argument instead of struct semid_ds *. This can cause failures on
powerpc32-linux-gnu.
Checked on x86_64-linux-gnu, i686-linux-gnu, and powerpc32-linux-gnu
(qemu system emulation).
The test math/test-nearbyint-except conditions some of its tests on an
EXCEPTION_TESTS call, not not all that need such a condition. This
patch fixes it to use such a conditional for all its tests and to
return 77 (UNSUPPORTED) if none of the floating-point types tested
support exceptions.
Tested for mips64 soft float (where the test previously failed and is
now UNSUPPORTED); also tested for x86_64 to make sure the test still
PASSes in exceptions-supported cases.
* math/test-nearbyint-except.c: Include <stdbool.h>.
(any_supported): New variable.
(TEST_FUNC): Return early if !EXCEPTION_TESTS (FLOAT). Otherwise
set any_supported.
(do_test): Return 77 if no floating-point type supported
exceptions.
Testing for MIPS soft float shows that the issue with NaN payload
preservation applies to soft float as well as hard float: the
sfp-machine.h emulates hardware non-preservation semantics, although
only for the case of two NaN arguments.
This patch duly changes the MIPS math-tests.h to expect such
non-preservation for soft float as well as hard float. The issue in
the NAN2008 case for which I posted
<https://gcc.gnu.org/ml/gcc-patches/2017-01/msg00034.html>, of sNaN
payloads being preserved but qNaN payloads not being preserved, is not
currently an issue for glibc tests because we don't have any tests
that check for qNaN payloads being preserved by arithmetic, so a
simple __mips_nan2008 conditional suffices without needing compiler
version checks in the __mips_nan2008 case.
Tested for mips64 soft float.
* sysdeps/mips/math-tests.h (SNAN_TESTS_PRESERVE_PAYLOAD): Do not
condition on [__mips_hard_float].
Similar to BZ#19387 and BZ#20971, both i686 memchr optimized assembly
implementations (memchr-sse2-bsf and memchr-sse2) do not handle the
size overflow correctly.
It is shown by the new tests added by commit 3daef2c8ee, where
both implementation fails with size as SIZE_MAX.
This patch uses a similar strategy used on 3daef2c8ee, where
saturared math is used for overflow case.
Checked on i686-linux-gnu.
[BZ #21014]
* sysdeps/i386/i686/multiarch/memchr-sse2-bsf.S (MEMCHR): Avoid overflow
in pointer addition.
* sysdeps/i386/i686/multiarch/memchr-sse2.S (MEMCHR): Likewise.
Now that a release branch exists for binutils 2.28, this patch makes
build-many-glibcs.py use that by default in place of 2.27.
* scripts/build-many-glibcs.py (Context.checkout): Default
binutils version to 2.28 branch.
Create a new node for tunables documentation and add notes for the
malloc tunables.
* manual/tunables.texi: New chapter.
* manual/Makefile (chapters): Add it.
* manual/probes.texi (@node): Point to the Tunables chapter.
At the GNU Tools Cauldron 2016, the state of the current tunables
patchset was considered OK with the addition of a way to select the
frontend to be used for the tunables. That is, to avoid being locked
in to one type of frontend initially, it should be possible to build
tunables with a different frontend with something as simple as a
configure switch.
To that effect, this patch enhances the --enable-tunables option to
accept more values than just 'yes' or 'no'. The current frontend (and
default when enable-tunables is 'yes') is called 'valstring', to
select the frontend where a single environment variable is set to a
colon-separated value string. More such frontends can be added in
future.
* Makeconfig (have-tunables): Check for non-negative instead
of positive.
* configure.ac: Add 'valstring' as a valid value for
--enable-tunables.
* configure: Regenerate.
* elf/Makefile (have-tunables): Check for non-negative instead
of positive.
(CPPFLAGS-dl-tunables.c): Define TUNABLES_FRONTEND for
dl-tunables.c.
* elf/dl-tunables.c (GLIBC_TUNABLES): Define only when
TUNABLES_FRONTEND == TUNABLES_FRONTEND_valstring.
(tunables_strdup): Likewise.
(disable_tunables): Likewise.
(parse_tunables): Likewise.
(__tunables_init): Process GLIBC_TUNABLES envvar only when.
TUNABLES_FRONTEND == TUNABLES_FRONTEND_valstring.
* elf/dl-tunables.h (TUNABLES_FRONTEND_valstring): New macro.
(TUNABLES_FRONTEND_yes): New macro, define as
TUNABLES_FRONTEND_valstring by default.
* manual/install.texi: Document new acceptable values for
--enable-tunables.
* INSTALL: Regenerate.
Read tunables values from the users using the GLIBC_TUNABLES
environment variable. The value of this variable is a colon-separated
list of name=value pairs. So a typical string would look like this:
GLIBC_TUNABLES=glibc.malloc.mmap_threshold=2048:glibc.malloc.trim_threshold=1024
* config.make.in (have-loop-to-function): Define.
* elf/Makefile (CFLAGS-dl-tunables.c): Add
-fno-tree-loop-distribute-patterns.
* elf/dl-tunables.c: Include libc-internals.h.
(GLIBC_TUNABLES): New macro.
(tunables_strdup): New function.
(parse_tunables): New function.
(min_strlen): New function.
(__tunables_init): Use the new functions and macro.
(disable_tunable): Disable tunable from GLIBC_TUNABLES.
* malloc/tst-malloc-usable-tunables.c: New test case.
* malloc/tst-malloc-usable-static-tunables.c: New test case.
* malloc/Makefile (tests, tests-static): Add tests.
The tunables framework allows us to uniformly manage and expose global
variables inside glibc as switches to users. tunables/README has
instructions for glibc developers to add new tunables.
Tunables support can be enabled by passing the --enable-tunables
configure flag to the configure script. This patch only adds a
framework and does not pose any limitations on how tunable values are
read from the user. It also adds environment variables used in malloc
behaviour tweaking to the tunables framework as a PoC of the
compatibility interface.
* manual/install.texi: Add --enable-tunables option.
* INSTALL: Regenerate.
* README.tunables: New file.
* Makeconfig (CPPFLAGS): Define TOP_NAMESPACE.
(before-compile): Generate dl-tunable-list.h early.
* config.h.in: Add HAVE_TUNABLES.
* config.make.in: Add have-tunables.
* configure.ac: Add --enable-tunables option.
* configure: Regenerate.
* csu/init-first.c (__libc_init_first): Move
__libc_init_secure earlier...
* csu/init-first.c (LIBC_START_MAIN):... to here.
Include dl-tunables.h, libc-internal.h.
(LIBC_START_MAIN) [!SHARED]: Initialize tunables for static
binaries.
* elf/Makefile (dl-routines): Add dl-tunables.
* elf/Versions (ld): Add __tunable_set_val to GLIBC_PRIVATE
namespace.
* elf/dl-support (_dl_nondynamic_init): Unset MALLOC_CHECK_
only when !HAVE_TUNABLES.
* elf/rtld.c (process_envvars): Likewise.
* elf/dl-sysdep.c [HAVE_TUNABLES]: Include dl-tunables.h
(_dl_sysdep_start): Call __tunables_init.
* elf/dl-tunable-types.h: New file.
* elf/dl-tunables.c: New file.
* elf/dl-tunables.h: New file.
* elf/dl-tunables.list: New file.
* malloc/tst-malloc-usable-static.c: New test case.
* malloc/Makefile (tests-static): Add it.
* malloc/arena.c [HAVE_TUNABLES]: Include dl-tunables.h.
Define TUNABLE_NAMESPACE.
(DL_TUNABLE_CALLBACK (set_mallopt_check)): New function.
(DL_TUNABLE_CALLBACK_FNDECL): New macro. Use it to define
callback functions.
(ptmalloc_init): Set tunable values.
* scripts/gen-tunables.awk: New file.
* sysdeps/mach/hurd/dl-sysdep.c: Include dl-tunables.h.
(_dl_sysdep_start): Call __tunables_init.
This causes more test programs to link in the support_record_failure
function, which triggers an early call to mmap from an ELF
constructor, but this should not have side effects intefering
with the functionality actually under test (unlike, say, a call
to malloc).
This is a new implementation for condition variables, required
after http://austingroupbugs.net/view.php?id=609 to fix bug 13165. In
essence, we need to be stricter in which waiters a signal or broadcast
is required to wake up; this couldn't be solved using the old algorithm.
ISO C++ made a similar clarification, so this also fixes a bug in
current libstdc++, for example.
We can't use the old algorithm anymore because futexes do not guarantee
to wake in FIFO order. Thus, when we wake, we can't simply let any
waiter grab a signal, but we need to ensure that one of the waiters
happening before the signal is woken up. This is something the previous
algorithm violated (see bug 13165).
There's another issue specific to condvars: ABA issues on the underlying
futexes. Unlike mutexes that have just three states, or semaphores that
have no tokens or a limited number of them, the state of a condvar is
the *order* of the waiters. A waiter on a semaphore can grab a token
whenever one is available; a condvar waiter must only consume a signal
if it is eligible to do so as determined by the relative order of the
waiter and the signal.
Therefore, this new algorithm maintains two groups of waiters: Those
eligible to consume signals (G1), and those that have to wait until
previous waiters have consumed signals (G2). Once G1 is empty, G2
becomes the new G1. 64b counters are used to avoid ABA issues.
This condvar doesn't yet use a requeue optimization (ie, on a broadcast,
waking just one thread and requeueing all others on the futex of the
mutex supplied by the program). I don't think doing the requeue is
necessarily the right approach (but I haven't done real measurements
yet):
* If a program expects to wake many threads at the same time and make
that scalable, a condvar isn't great anyway because of how it requires
waiters to operate mutually exclusive (due to the mutex usage). Thus, a
thundering herd problem is a scalability problem with or without the
optimization. Using something like a semaphore might be more
appropriate in such a case.
* The scalability problem is actually at the mutex side; the condvar
could help (and it tries to with the requeue optimization), but it
should be the mutex who decides how that is done, and whether it is done
at all.
* Forcing all but one waiter into the kernel-side wait queue of the
mutex prevents/avoids the use of lock elision on the mutex. Thus, it
prevents the only cure against the underlying scalability problem
inherent to condvars.
* If condvars use short critical sections (ie, hold the mutex just to
check a binary flag or such), which they should do ideally, then forcing
all those waiter to proceed serially with kernel-based hand-off (ie,
futex ops in the mutex' contended state, via the futex wait queues) will
be less efficient than just letting a scalable mutex implementation take
care of it. Our current mutex impl doesn't employ spinning at all, but
if critical sections are short, spinning can be much better.
* Doing the requeue stuff requires all waiters to always drive the mutex
into the contended state. This leads to each waiter having to call
futex_wake after lock release, even if this wouldn't be necessary.
[BZ #13165]
* nptl/pthread_cond_broadcast.c (__pthread_cond_broadcast): Rewrite to
use new algorithm.
* nptl/pthread_cond_destroy.c (__pthread_cond_destroy): Likewise.
* nptl/pthread_cond_init.c (__pthread_cond_init): Likewise.
* nptl/pthread_cond_signal.c (__pthread_cond_signal): Likewise.
* nptl/pthread_cond_wait.c (__pthread_cond_wait): Likewise.
(__pthread_cond_timedwait): Move here from pthread_cond_timedwait.c.
(__condvar_confirm_wakeup, __condvar_cancel_waiting,
__condvar_cleanup_waiting, __condvar_dec_grefs,
__pthread_cond_wait_common): New.
(__condvar_cleanup): Remove.
* npt/pthread_condattr_getclock.c (pthread_condattr_getclock): Adapt.
* npt/pthread_condattr_setclock.c (pthread_condattr_setclock):
Likewise.
* npt/pthread_condattr_getpshared.c (pthread_condattr_getpshared):
Likewise.
* npt/pthread_condattr_init.c (pthread_condattr_init): Likewise.
* nptl/tst-cond1.c: Add comment.
* nptl/tst-cond20.c (do_test): Adapt.
* nptl/tst-cond22.c (do_test): Likewise.
* sysdeps/aarch64/nptl/bits/pthreadtypes.h (pthread_cond_t): Adapt
structure.
* sysdeps/arm/nptl/bits/pthreadtypes.h (pthread_cond_t): Likewise.
* sysdeps/ia64/nptl/bits/pthreadtypes.h (pthread_cond_t): Likewise.
* sysdeps/m68k/nptl/bits/pthreadtypes.h (pthread_cond_t): Likewise.
* sysdeps/microblaze/nptl/bits/pthreadtypes.h (pthread_cond_t):
Likewise.
* sysdeps/mips/nptl/bits/pthreadtypes.h (pthread_cond_t): Likewise.
* sysdeps/nios2/nptl/bits/pthreadtypes.h (pthread_cond_t): Likewise.
* sysdeps/s390/nptl/bits/pthreadtypes.h (pthread_cond_t): Likewise.
* sysdeps/sh/nptl/bits/pthreadtypes.h (pthread_cond_t): Likewise.
* sysdeps/tile/nptl/bits/pthreadtypes.h (pthread_cond_t): Likewise.
* sysdeps/unix/sysv/linux/alpha/bits/pthreadtypes.h (pthread_cond_t):
Likewise.
* sysdeps/unix/sysv/linux/powerpc/bits/pthreadtypes.h (pthread_cond_t):
Likewise.
* sysdeps/x86/bits/pthreadtypes.h (pthread_cond_t): Likewise.
* sysdeps/nptl/internaltypes.h (COND_NWAITERS_SHIFT): Remove.
(COND_CLOCK_BITS): Adapt.
* sysdeps/nptl/pthread.h (PTHREAD_COND_INITIALIZER): Adapt.
* nptl/pthreadP.h (__PTHREAD_COND_CLOCK_MONOTONIC_MASK,
__PTHREAD_COND_SHARED_MASK): New.
* nptl/nptl-printers.py (CLOCK_IDS): Remove.
(ConditionVariablePrinter, ConditionVariableAttributesPrinter): Adapt.
* nptl/nptl_lock_constants.pysym: Adapt.
* nptl/test-cond-printers.py: Adapt.
* sysdeps/unix/sysv/linux/hppa/internaltypes.h (cond_compat_clear,
cond_compat_check_and_clear): Adapt.
* sysdeps/unix/sysv/linux/hppa/pthread_cond_timedwait.c: Remove file ...
* sysdeps/unix/sysv/linux/hppa/pthread_cond_wait.c
(__pthread_cond_timedwait): ... and move here.
* nptl/DESIGN-condvar.txt: Remove file.
* nptl/lowlevelcond.sym: Likewise.
* nptl/pthread_cond_timedwait.c: Likewise.
* sysdeps/unix/sysv/linux/i386/i486/pthread_cond_broadcast.S: Likewise.
* sysdeps/unix/sysv/linux/i386/i486/pthread_cond_signal.S: Likewise.
* sysdeps/unix/sysv/linux/i386/i486/pthread_cond_timedwait.S: Likewise.
* sysdeps/unix/sysv/linux/i386/i486/pthread_cond_wait.S: Likewise.
* sysdeps/unix/sysv/linux/i386/i586/pthread_cond_broadcast.S: Likewise.
* sysdeps/unix/sysv/linux/i386/i586/pthread_cond_signal.S: Likewise.
* sysdeps/unix/sysv/linux/i386/i586/pthread_cond_timedwait.S: Likewise.
* sysdeps/unix/sysv/linux/i386/i586/pthread_cond_wait.S: Likewise.
* sysdeps/unix/sysv/linux/i386/i686/pthread_cond_broadcast.S: Likewise.
* sysdeps/unix/sysv/linux/i386/i686/pthread_cond_signal.S: Likewise.
* sysdeps/unix/sysv/linux/i386/i686/pthread_cond_timedwait.S: Likewise.
* sysdeps/unix/sysv/linux/i386/i686/pthread_cond_wait.S: Likewise.
* sysdeps/unix/sysv/linux/x86_64/pthread_cond_broadcast.S: Likewise.
* sysdeps/unix/sysv/linux/x86_64/pthread_cond_signal.S: Likewise.
* sysdeps/unix/sysv/linux/x86_64/pthread_cond_timedwait.S: Likewise.
* sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S: Likewise.
TS 18661-1 defines fromfp functions (fromfp, fromfpx, ufromfp,
ufromfpx, and float and long double variants) to convert from
floating-point to an integer type with any signedness and any given
width up to that of intmax_t, in any of the five IEEE rounding modes
(the usual four for binary floating point, plus rounding to nearest
with ties rounding away from zero), with control of whether in-range
non-integer values should result in the "inexact" exception being
raised. This patch implements these functions for glibc.
These implementations are (apart from raising exceptions) pure integer
implementations; it's entirely possible optimized versions could be
devised for some architectures. A common math/fromfp.h header
provides various common helper code that can readily be shared between
the implementations for different types. For each type, the bulk of
the implementation is also shared between the four functions, with
wrappers that define UNSIGNED and INEXACT macros appropriately before
including the main implementation.
As the functions return intmax_t and uintmax_t without math.h being
allowed to expose those typedef names, they are declared using
__intmax_t and __uintmax_t as obtained from <bits/types.h>.
The FP_INT_* rounding direction macros are defined as ascending
integers in the order the names are listed in the TS; I see no
significant value in allowing architectures to vary the values of
them.
The libm-test machinery is duly adapted to handle unsigned int
arguments, and intmax_t and uintmax_t results. Because each test
input is generally tested for four functions, five rounding modes and
several different widths, the libm-test.inc additions are very large.
Thus, the diffs in the body of this message exclude the libm-test.inc
changes, with the full patch being attached gzipped. The bulk of the
new tests were generated (expanded from a test input plus rounding
results and information about where it lies in the relevant interval
between integers, to libm-test tests for all relevant combinations of
function, rounding direction and width) by a script that's included in
the patch as math/gen-fromfp-tests.py (input data
math/gen-fromfp-tests-inputs); as an ad hoc script that's not really
expected to be rerun, it's not very polished, but it's at least
plausibly useful for adding any further tests for these functions in
future. I may split the libm-test tests up by function in future (so
both libm-test.inc and auto-libm-test-out are split into separate
files, and the tests for each function are also built and run
separately), but not for 2.25.
For no obvious reason, adding tgmath tests for the new functions
resulted in -Wuninitialized errors from test-tgmath.c about the
variable i being used uninitialized. Those errors were correct - the
variable is read by the frexp version in test-tgmath.c (where real
frexp would write through that pointer instead of reading it) - but I
don't know why this patch would result in the pre-existing issue being
newly detected. The patch initializes the variable to avoid those
errors.
With these changes, glibc 2.25 should have all the library features
from TS 18661-1 other than the functions that round result to narrower
type (and constant rounding directions, but I'm considering those
mainly a compiler feature not a library one).
Tested for x86_64, x86, mips64 and powerpc.
* math/bits/mathcalls.h [__GLIBC_USE (IEC_60559_BFP_EXT)]
(fromfp): New declaration.
[__GLIBC_USE (IEC_60559_BFP_EXT)] (fromfpx): Likewise.
[__GLIBC_USE (IEC_60559_BFP_EXT)] (ufromfp): Likewise.
[__GLIBC_USE (IEC_60559_BFP_EXT)] (ufromfpx): Likewise.
* math/tgmath.h (__TGMATH_TERNARY_FIRST_REAL_RET_ONLY): New macro.
[__GLIBC_USE (IEC_60559_BFP_EXT)] (fromfp): Likewise.
[__GLIBC_USE (IEC_60559_BFP_EXT)] (ufromfp): Likewise.
[__GLIBC_USE (IEC_60559_BFP_EXT)] (fromfpx): Likewise.
[__GLIBC_USE (IEC_60559_BFP_EXT)] (ufromfpx): Likewise.
* math/math.h: Include <bits/types.h>.
[__GLIBC_USE (IEC_60559_BFP_EXT)] (FP_INT_UPWARD): New enum
constant and macro.
(FP_INT_DOWNWARD): Likewise.
(FP_INT_TOWARDZERO): Likewise.
(FP_INT_TONEARESTFROMZERO): Likewise.
(FP_INT_TONEAREST): Likewise.
* math/Versions (fromfp): New libm symbol at version GLIBC_2.25.
(fromfpf): Likewise.
(fromfpl): Likewise.
(ufromfp): Likewise.
(ufromfpf): Likewise.
(ufromfpl): Likewise.
(fromfpx): Likewise.
(fromfpxf): Likewise.
(fromfpxl): Likewise.
(ufromfpx): Likewise.
(ufromfpxf): Likewise.
(ufromfpxl): Likewise.
* math/Makefile (libm-calls): Add s_fromfpF, s_ufromfpF,
s_fromfpxF and s_ufromfpxF.
* math/gen-fromfp-tests.py: New file.
* math/gen-fromfp-tests-inputs: Likewise.
* math/libm-test.inc: Include <stdint.h>
(check_intmax_t): New function.
(check_uintmax_t): Likewise.
(struct test_fiu_M_data): New type.
(struct test_fiu_U_data): Likewise.
(RUN_TEST_fiu_M): New macro.
(RUN_TEST_LOOP_fiu_M): Likewise.
(RUN_TEST_fiu_U): Likewise.
(RUN_TEST_LOOP_fiu_U): Likewise.
(fromfp_test_data): New array.
(fromfp_test): New function.
(fromfpx_test_data): New array.
(fromfpx_test): New function.
(ufromfp_test_data): New array.
(ufromfp_test): New function.
(ufromfpx_test_data): New array.
(ufromfpx_test): New function.
(main): Call fromfp_test, fromfpx_test, ufromfp_test and
ufromfpx_test.
* math/gen-libm-test.pl (parse_args): Handle u, M and U descriptor
characters.
* math/test-tgmath-ret.c: Include <stdint.h>.
(rm): New variable.
(width): Likewise.
(CHECK_RET_CONST_TYPE): Take extra arguments and pass them to
called function.
(CHECK_RET_CONST_FLOAT): Take extra arguments and pass them to
CHECK_RET_CONST_TYPE.
(CHECK_RET_CONST_DOUBLE): Likewise.
(CHECK_RET_CONST_LDOUBLE): Likewise.
(CHECK_RET_CONST): Take extra arguments and pass them to calls
macros.
(fromfp): New CHECK_RET_CONST call.
(ufromfp): Likewise.
(fromfpx): Likewise.
(ufromfpx): Likewise.
(do_test): Call check_return_fromfp, check_return_ufromfp,
check_return_fromfpx and check_return_ufromfpx.
* math/test-tgmath.c: Include <stdint.h>
(NCALLS): Increase to 138.
(F(compile_test)): Initialize i. Call fromfp functions.
(F(fromfp)): New function.
(F(fromfpx)): Likewise.
(F(ufromfp)): Likewise.
(F(ufromfpx)): Likewise.
* manual/arith.texi (Rounding Functions): Document FP_INT_UPWARD,
FP_INT_DOWNWARD, FP_INT_TOWARDZERO, FP_INT_TONEARESTFROMZERO,
FP_INT_TONEAREST, fromfp, fromfpf, fromfpl, ufromfp, ufromfpf,
ufromfpl, fromfpx, fromfpxf, fromfpxl, ufromfpx, ufromfpxf and
ufromfpxl.
* manual/libm-err-tab.pl (@all_functions): Add fromfp, fromfpx,
ufromfp and ufromfpx.
* math/fromfp.h: New file.
* sysdeps/ieee754/dbl-64/s_fromfp.c: Likewise.
* sysdeps/ieee754/dbl-64/s_fromfp_main.c: Likewise.
* sysdeps/ieee754/dbl-64/s_fromfpx.c: Likewise.
* sysdeps/ieee754/dbl-64/s_ufromfp.c: Likewise.
* sysdeps/ieee754/dbl-64/s_ufromfpx.c: Likewise.
* sysdeps/ieee754/flt-32/s_fromfpf.c: Likewise.
* sysdeps/ieee754/flt-32/s_fromfpf_main.c: Likewise.
* sysdeps/ieee754/flt-32/s_fromfpxf.c: Likewise.
* sysdeps/ieee754/flt-32/s_ufromfpf.c: Likewise.
* sysdeps/ieee754/flt-32/s_ufromfpxf.c: Likewise.
* sysdeps/ieee754/ldbl-128/s_fromfpl.c: Likewise.
* sysdeps/ieee754/ldbl-128/s_fromfpl_main.c: Likewise.
* sysdeps/ieee754/ldbl-128/s_fromfpxl.c: Likewise.
* sysdeps/ieee754/ldbl-128/s_ufromfpl.c: Likewise.
* sysdeps/ieee754/ldbl-128/s_ufromfpxl.c: Likewise.
* sysdeps/ieee754/ldbl-128ibm/s_fromfpl.c: Likewise.
* sysdeps/ieee754/ldbl-128ibm/s_fromfpl_main.c: Likewise.
* sysdeps/ieee754/ldbl-128ibm/s_fromfpxl.c: Likewise.
* sysdeps/ieee754/ldbl-128ibm/s_ufromfpl.c: Likewise.
* sysdeps/ieee754/ldbl-128ibm/s_ufromfpxl.c: Likewise.
* sysdeps/ieee754/ldbl-96/s_fromfpl.c: Likewise.
* sysdeps/ieee754/ldbl-96/s_fromfpl_main.c: Likewise.
* sysdeps/ieee754/ldbl-96/s_fromfpxl.c: Likewise.
* sysdeps/ieee754/ldbl-96/s_ufromfpl.c: Likewise.
* sysdeps/ieee754/ldbl-96/s_ufromfpxl.c: Likewise.
* sysdeps/ieee754/ldbl-opt/Makefile (libnldbl-calls): Add fromfp,
ufromfp, fromfpx and ufromfpx.
(CFLAGS-nldbl-fromfp.c): New variable.
(CFLAGS-nldbl-fromfpx.c): Likewise.
(CFLAGS-nldbl-ufromfp.c): Likewise.
(CFLAGS-nldbl-ufromfpx.c): Likewise.
* sysdeps/ieee754/ldbl-opt/nldbl-compat.h: Include <stdint.h>.
* sysdeps/ieee754/ldbl-opt/nldbl-fromfp.c: New file.
* sysdeps/ieee754/ldbl-opt/nldbl-fromfpx.c: Likewise.
* sysdeps/ieee754/ldbl-opt/nldbl-ufromfp.c: Likewise.
* sysdeps/ieee754/ldbl-opt/nldbl-ufromfpx.c: Likewise.
* sysdeps/nacl/libm.abilist: Update.
* sysdeps/unix/sysv/linux/aarch64/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/alpha/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/arm/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/hppa/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/i386/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/ia64/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/m68k/coldfire/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/m68k/m680x0/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/microblaze/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/mips/mips32/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/mips/mips64/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/nios2/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libm.abilist:
Likewise.
* sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libm.abilist:
Likewise.
* sysdeps/unix/sysv/linux/powerpc/powerpc64/libm-le.abilist:
Likewise.
* sysdeps/unix/sysv/linux/powerpc/powerpc64/libm.abilist:
Likewise.
* sysdeps/unix/sysv/linux/s390/s390-32/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/s390/s390-64/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/sh/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/sparc/sparc32/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/sparc/sparc64/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/tile/tilegx/tilegx32/libm.abilist:
Likewise.
* sysdeps/unix/sysv/linux/tile/tilegx/tilegx64/libm.abilist:
Likewise.
* sysdeps/unix/sysv/linux/tile/tilepro/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/x86_64/64/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/x86_64/x32/libm.abilist: Likewise.
This change also removes the preprocessor-based function renaming.
It also applied to tests in resolv/, which ended up running against
the historic functions.
_endhtent was not part of the ABI because it is not listed in the
resolv/Versions file.
TS 18661-1 defines *fromfp* functions, which are declared in math.h
and whose return types are intmax_t and uintmax_t, without allowing
math.h to define those typedefs. (This is similar to e.g. ISO C
declaring vprintf in stdio.h without allowing that header to define
va_list.) Thus, math.h needs to access those typedefs under internal
names.
This patch accordingly arranges for bits/types.h (which defines only
internal names, not public *_t typedefs) to define __intmax_t and
__uintmax_t. stdint.h is made to use bits/types.h and define intmax_t
and uintmax_t using __intmax_t and __uintmax_t, to avoid duplication
of information. (It would be reasonable to define more of the types
in stdint.h - and in sys/types.h, where it duplicates such types -
using information already available in bits/types.h.) The idea is
that the subsequent addition of fromfp functions would then make
math.h include bits/types.h and use __intmax_t and __uintmax_t as the
return types of those functions.
Tested for x86_64 and x86 (testsuite, and that installed stripped
shared libraries are unchanged by the patch).
* bits/types.h (__intmax_t): New typedef.
(__uintmax_t): Likewise.
* sysdeps/generic/stdint.h: Include <bits/types.h>.
(intmax_t): Define using __intmax_t.
(uintmax_t): Define using __uintmax_t.
The support/tst-support_record_failure-2.out test attempts to run
built code even if run-built-tests = no, so failing with
build-many-glibcs.py for all architectures whose code cannot be run on
the system running the script. This patch disables the test in that
case.
Tested for x86_64 (native), and for aarch64 with build-many-glibcs.py.
* support/Makefile (tests-special): Make definition conditional on
[$(run-built-tests) = yes].
($(objpfx)tst-support_record_failure-2.out): Make rule conditional
on [$(run-built-tests) = yes].
In my change to add configure tests for python I had a brainfart where
I tried to filter out unsupported tests from tests-printers-programs
instead of tests-printers to select tests to build. I realize now
that all of that is completely unnecessary and it would be safe to
just build the tests as long as we don't try to run it.
This patch reverts that bit of the change. Tested with
run-built-tests = no in config.make.
* Rules (tests): Add tests-printers-programs to tests to be
built.
This patch adds a simple SYSV shared memory test to check for correct
argument passing on kernel. The idea is neither to be an extensive
testing nor to check for any specific Linux test.
* sysvipc/Makefile (tests): Add test-sysvshm.
* sysvipc/test-sysvshm.c: New file.
this patch add a direct call to shmget syscall if it is supported by
kernel features.
Checked on x86_64, i686, powerpc64le, aarch64, and armhf.
* sysdeps/unix/sysv/linux/alpha/syscalls.list (shmget): Remove.
* sysdeps/unix/sysv/linux/arm/syscalls.list (shmget): Likewise.
* sysdeps/unix/sysv/linux/generic/syscalls.list (shmget): Likewise.
* sysdeps/unix/sysv/linux/hppa/syscalls.list (shmget): Likewise.
* sysdeps/unix/sysv/linux/ia64/syscalls.list (shmget): Likewise.
* sysdeps/unix/sysv/linux/microblaze/syscalls.list (shmget): Likewise.
* sysdeps/unix/sysv/linux/mips/mips64/syscalls.list (shmget):
Likewise.
* sysdeps/unix/sysv/linux/s390/s390-64/syscalls.list (shmget):
Likewise.
* sysdeps/unix/sysv/linux/x86_64/syscalls.list (shmget): Likewise.
* sysdeps/unix/sysv/linux/shmget.c (shmget): Use shmget syscall if it
is defined.