platform/upstream/glibc.git
5 years agoMove float128 inlines from sysdeps/generic/math_private.h to include/math.h.
Joseph Myers [Wed, 5 Sep 2018 11:53:35 +0000 (11:53 +0000)]
Move float128 inlines from sysdeps/generic/math_private.h to include/math.h.

Continuing the cleanup of math_private.h, with a view to it becoming
the header for the APIs defined therein and not also a header with
inline variants of math.h APIs, this patch moves inline definitions of
__isinff128 and fabsf128 to include/math.h, so that any users of
math.h in glibc automatically get the optimized functions rather than
quietly missing them if they do not also include math_private.h.

Tested for x86_64 and x86, and with build-many-glibcs.py with GCC 6.
There are changes to installed stripped libc.so on configurations with
distinct _Float128, because of __printf_fp_l code that now gets the
__isinff128 inline where previously it called the out-of-line
function because of the lack of a math_private.h call.  It seems
appropriate that this code does get the inline (as it would
automatically with GCC 7 and later when the built-in function is used)
rather than being the only place in glibc that does not.

* sysdeps/generic/math_private.h
[__HAVE_DISTINCT_FLOAT128 && !__GNUC_PREREQ (7, 0)] (__isinff128):
Move this inline function ....
[__HAVE_DISTINCT_FLOAT128] (fabsf128): And this one ....
* include/math.h [!_ISOMAC]: To here....

5 years agoMove fenv.h soft-float inlines from fenv_private.h to include/fenv.h.
Joseph Myers [Tue, 4 Sep 2018 19:52:06 +0000 (19:52 +0000)]
Move fenv.h soft-float inlines from fenv_private.h to include/fenv.h.

<fenv_private.h> has inline versions of various <fenv.h> functions,
and their __fe* variants, for systems (generally soft-float) without
support for floating-point exceptions, rounding modes or both.

Having these inlines in a separate header introduces a risk of a
source file including <fenv.h> and compiling OK on x86_64, but failing
to compile (because the feraiseexcept inline is actually a macro that
discards its argument, to avoid the need for #ifdef FE_INVALID
conditionals), or not being properly optimized, on systems without the
exceptions and rounding modes support (when these inlines were in
math_private.h, we had a few cases where this broke the build because
there was no obvious reason for a file to need math_private.h and it
didn't need that header on x86_64).  By moving those inlines to
include/fenv.h, this risk can be avoided, and fenv_private.h becomes
more clearly defined as specifically the header for the internal
libc_fe* and SET_RESTORE_ROUND* interfaces.

This patch makes that move, removing fenv_private.h includes that are
no longer needed (or replacing them by fenv.h includes in a few cases
that didn't already have such an include).

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

* sysdeps/generic/fenv_private.h [FE_ALL_EXCEPT == 0]: Move this
code ....
[!FE_HAVE_ROUNDING_MODES]: And this code ....
* include/fenv.h [!_ISOMAC]: ... to here.
* math/fraiseexcpt.c (__feraiseexcept): Undefine as macro.
(feraiseexcept): Likewise.
* math/fromfp.h: Do not include <fenv_private.h>.
* math/s_cexp_template.c: Likewise.
* math/s_csin_template.c: Likewise.
* math/s_csinh_template.c: Likewise.
* math/s_ctan_template.c: Likewise.
* math/s_ctanh_template.c: Likewise.
* math/s_iseqsig_template.c: Likewise.
* math/w_acos_compat.c: Likewise.
* math/w_acosf_compat.c: Likewise.
* math/w_acosl_compat.c: Likewise.
* math/w_asin_compat.c: Likewise.
* math/w_asinf_compat.c: Likewise.
* math/w_asinl_compat.c: Likewise.
* math/w_j0_compat.c: Likewise.
* math/w_j0f_compat.c: Likewise.
* math/w_j0l_compat.c: Likewise.
* math/w_j1_compat.c: Likewise.
* math/w_j1f_compat.c: Likewise.
* math/w_j1l_compat.c: Likewise.
* math/w_jn_compat.c: Likewise.
* math/w_jnf_compat.c: Likewise.
* math/w_log10_compat.c: Likewise.
* math/w_log10f_compat.c: Likewise.
* math/w_log10l_compat.c: Likewise.
* math/w_log2_compat.c: Likewise.
* math/w_log2f_compat.c: Likewise.
* math/w_log2l_compat.c: Likewise.
* math/w_log_compat.c: Likewise.
* math/w_logf_compat.c: Likewise.
* math/w_logl_compat.c: Likewise.
* sysdeps/ieee754/dbl-64/s_llrint.c: Likewise.
* sysdeps/ieee754/dbl-64/s_llround.c: Likewise.
* sysdeps/ieee754/dbl-64/s_lrint.c: Likewise.
* sysdeps/ieee754/dbl-64/s_lround.c: Likewise.
* sysdeps/ieee754/dbl-64/wordsize-64/s_lround.c: Likewise.
* sysdeps/ieee754/flt-32/s_llrintf.c: Likewise.
* sysdeps/ieee754/flt-32/s_llroundf.c: Likewise.
* sysdeps/ieee754/flt-32/s_lrintf.c: Likewise.
* sysdeps/ieee754/flt-32/s_lroundf.c: Likewise.
* sysdeps/ieee754/k_standardl.c: Likewise.
* sysdeps/ieee754/ldbl-128/e_expl.c: Likewise.
* sysdeps/ieee754/ldbl-128/s_fmal.c: Likewise.
* sysdeps/ieee754/ldbl-128/s_llrintl.c: Likewise.
* sysdeps/ieee754/ldbl-128/s_llroundl.c: Likewise.
* sysdeps/ieee754/ldbl-128/s_lrintl.c: Likewise.
* sysdeps/ieee754/ldbl-128/s_lroundl.c: Likewise.
* sysdeps/ieee754/ldbl-128/s_nearbyintl.c: Likewise.
* sysdeps/ieee754/ldbl-128ibm/s_llrintl.c: Likewise.
* sysdeps/ieee754/ldbl-128ibm/s_llroundl.c: Likewise.
* sysdeps/ieee754/ldbl-128ibm/s_lrintl.c: Likewise.
* sysdeps/ieee754/ldbl-128ibm/s_lroundl.c: Likewise.
* sysdeps/ieee754/ldbl-96/s_fma.c: Likewise.
* sysdeps/ieee754/ldbl-96/s_fmal.c: Likewise.
* sysdeps/ieee754/ldbl-96/s_llrintl.c: Likewise.
* sysdeps/ieee754/ldbl-96/s_llroundl.c: Likewise.
* sysdeps/ieee754/ldbl-96/s_lrintl.c: Likewise.
* sysdeps/ieee754/ldbl-96/s_lroundl.c: Likewise.
* math/w_ilogb_template.c: Include <fenv.h> instead of
<fenv_private.h>.
* math/w_llogb_template.c: Likewise.
* sysdeps/powerpc/fpu/e_sqrt.c: Likewise.
* sysdeps/powerpc/fpu/e_sqrtf.c: Likewise.

5 years agoDo not include fenv_private.h in math_private.h.
Joseph Myers [Mon, 3 Sep 2018 21:09:04 +0000 (21:09 +0000)]
Do not include fenv_private.h in math_private.h.

Continuing the clean-up related to the catch-all math_private.h
header, this patch stops math_private.h from including fenv_private.h.
Instead, fenv_private.h is included directly from those users of
math_private.h that also used interfaces from fenv_private.h.  No
attempt is made to remove unused includes of math_private.h, but that
is a natural followup.

(However, since math_private.h sometimes defines optimized versions of
math.h interfaces or __* variants thereof, as well as defining its own
interfaces, I think it might make sense to get all those optimized
versions included from include/math.h, not requiring a separate header
at all, before eliminating unused math_private.h includes - that
avoids a file quietly becoming less-optimized if someone adds a call
to one of those interfaces without restoring a math_private.h include
to that file.)

There is still a pitfall that if code uses plain fe* and __fe*
interfaces, but only includes fenv.h and not fenv_private.h or (before
this patch) math_private.h, it will compile on platforms with
exceptions and rounding modes but not get the optimized versions (and
possibly not compile) on platforms without exception and rounding mode
support, so making it easy to break the build for such platforms
accidentally.

I think it would be most natural to move the inlines / macros for fe*
and __fe* in the case of no exceptions and rounding modes into
include/fenv.h, so that all code including fenv.h with _ISOMAC not
defined automatically gets them.  Then fenv_private.h would be purely
the header for the libc_fe*, SET_RESTORE_ROUND etc. internal
interfaces and the risk of breaking the build on other platforms than
the one you tested on because of a missing fenv_private.h include
would be much reduced (and there would be some unused fenv_private.h
includes to remove along with unused math_private.h includes).

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

* sysdeps/generic/math_private.h: Do not include <fenv_private.h>.
* math/fromfp.h: Include <fenv_private.h>.
* math/math-narrow.h: Likewise.
* math/s_cexp_template.c: Likewise.
* math/s_csin_template.c: Likewise.
* math/s_csinh_template.c: Likewise.
* math/s_ctan_template.c: Likewise.
* math/s_ctanh_template.c: Likewise.
* math/s_iseqsig_template.c: Likewise.
* math/w_acos_compat.c: Likewise.
* math/w_acosf_compat.c: Likewise.
* math/w_acosl_compat.c: Likewise.
* math/w_asin_compat.c: Likewise.
* math/w_asinf_compat.c: Likewise.
* math/w_asinl_compat.c: Likewise.
* math/w_ilogb_template.c: Likewise.
* math/w_j0_compat.c: Likewise.
* math/w_j0f_compat.c: Likewise.
* math/w_j0l_compat.c: Likewise.
* math/w_j1_compat.c: Likewise.
* math/w_j1f_compat.c: Likewise.
* math/w_j1l_compat.c: Likewise.
* math/w_jn_compat.c: Likewise.
* math/w_jnf_compat.c: Likewise.
* math/w_llogb_template.c: Likewise.
* math/w_log10_compat.c: Likewise.
* math/w_log10f_compat.c: Likewise.
* math/w_log10l_compat.c: Likewise.
* math/w_log2_compat.c: Likewise.
* math/w_log2f_compat.c: Likewise.
* math/w_log2l_compat.c: Likewise.
* math/w_log_compat.c: Likewise.
* math/w_logf_compat.c: Likewise.
* math/w_logl_compat.c: Likewise.
* sysdeps/aarch64/fpu/feholdexcpt.c: Likewise.
* sysdeps/aarch64/fpu/fesetround.c: Likewise.
* sysdeps/aarch64/fpu/fgetexcptflg.c: Likewise.
* sysdeps/aarch64/fpu/ftestexcept.c: Likewise.
* sysdeps/ieee754/dbl-64/e_atan2.c: Likewise.
* sysdeps/ieee754/dbl-64/e_exp.c: Likewise.
* sysdeps/ieee754/dbl-64/e_exp2.c: Likewise.
* sysdeps/ieee754/dbl-64/e_gamma_r.c: Likewise.
* sysdeps/ieee754/dbl-64/e_jn.c: Likewise.
* sysdeps/ieee754/dbl-64/e_pow.c: Likewise.
* sysdeps/ieee754/dbl-64/e_remainder.c: Likewise.
* sysdeps/ieee754/dbl-64/e_sqrt.c: Likewise.
* sysdeps/ieee754/dbl-64/gamma_product.c: Likewise.
* sysdeps/ieee754/dbl-64/lgamma_neg.c: Likewise.
* sysdeps/ieee754/dbl-64/s_atan.c: Likewise.
* sysdeps/ieee754/dbl-64/s_fma.c: Likewise.
* sysdeps/ieee754/dbl-64/s_fmaf.c: Likewise.
* sysdeps/ieee754/dbl-64/s_llrint.c: Likewise.
* sysdeps/ieee754/dbl-64/s_llround.c: Likewise.
* sysdeps/ieee754/dbl-64/s_lrint.c: Likewise.
* sysdeps/ieee754/dbl-64/s_lround.c: Likewise.
* sysdeps/ieee754/dbl-64/s_nearbyint.c: Likewise.
* sysdeps/ieee754/dbl-64/s_sin.c: Likewise.
* sysdeps/ieee754/dbl-64/s_sincos.c: Likewise.
* sysdeps/ieee754/dbl-64/s_tan.c: Likewise.
* sysdeps/ieee754/dbl-64/wordsize-64/s_lround.c: Likewise.
* sysdeps/ieee754/dbl-64/wordsize-64/s_nearbyint.c: Likewise.
* sysdeps/ieee754/dbl-64/x2y2m1.c: Likewise.
* sysdeps/ieee754/float128/float128_private.h: Likewise.
* sysdeps/ieee754/flt-32/e_gammaf_r.c: Likewise.
* sysdeps/ieee754/flt-32/e_j1f.c: Likewise.
* sysdeps/ieee754/flt-32/e_jnf.c: Likewise.
* sysdeps/ieee754/flt-32/lgamma_negf.c: Likewise.
* sysdeps/ieee754/flt-32/s_llrintf.c: Likewise.
* sysdeps/ieee754/flt-32/s_llroundf.c: Likewise.
* sysdeps/ieee754/flt-32/s_lrintf.c: Likewise.
* sysdeps/ieee754/flt-32/s_lroundf.c: Likewise.
* sysdeps/ieee754/flt-32/s_nearbyintf.c: Likewise.
* sysdeps/ieee754/k_standardl.c: Likewise.
* sysdeps/ieee754/ldbl-128/e_expl.c: Likewise.
* sysdeps/ieee754/ldbl-128/e_gammal_r.c: Likewise.
* sysdeps/ieee754/ldbl-128/e_j1l.c: Likewise.
* sysdeps/ieee754/ldbl-128/e_jnl.c: Likewise.
* sysdeps/ieee754/ldbl-128/gamma_productl.c: Likewise.
* sysdeps/ieee754/ldbl-128/lgamma_negl.c: Likewise.
* sysdeps/ieee754/ldbl-128/s_fmal.c: Likewise.
* sysdeps/ieee754/ldbl-128/s_llrintl.c: Likewise.
* sysdeps/ieee754/ldbl-128/s_llroundl.c: Likewise.
* sysdeps/ieee754/ldbl-128/s_lrintl.c: Likewise.
* sysdeps/ieee754/ldbl-128/s_lroundl.c: Likewise.
* sysdeps/ieee754/ldbl-128/s_nearbyintl.c: Likewise.
* sysdeps/ieee754/ldbl-128/x2y2m1l.c: Likewise.
* sysdeps/ieee754/ldbl-128ibm/e_expl.c: Likewise.
* sysdeps/ieee754/ldbl-128ibm/e_gammal_r.c: Likewise.
* sysdeps/ieee754/ldbl-128ibm/e_j1l.c: Likewise.
* sysdeps/ieee754/ldbl-128ibm/e_jnl.c: Likewise.
* sysdeps/ieee754/ldbl-128ibm/lgamma_negl.c: Likewise.
* sysdeps/ieee754/ldbl-128ibm/s_fmal.c: Likewise.
* sysdeps/ieee754/ldbl-128ibm/s_llrintl.c: Likewise.
* sysdeps/ieee754/ldbl-128ibm/s_llroundl.c: Likewise.
* sysdeps/ieee754/ldbl-128ibm/s_lrintl.c: Likewise.
* sysdeps/ieee754/ldbl-128ibm/s_lroundl.c: Likewise.
* sysdeps/ieee754/ldbl-128ibm/s_rintl.c: Likewise.
* sysdeps/ieee754/ldbl-128ibm/x2y2m1l.c: Likewise.
* sysdeps/ieee754/ldbl-96/e_gammal_r.c: Likewise.
* sysdeps/ieee754/ldbl-96/e_jnl.c: Likewise.
* sysdeps/ieee754/ldbl-96/gamma_productl.c: Likewise.
* sysdeps/ieee754/ldbl-96/lgamma_negl.c: Likewise.
* sysdeps/ieee754/ldbl-96/s_fma.c: Likewise.
* sysdeps/ieee754/ldbl-96/s_fmal.c: Likewise.
* sysdeps/ieee754/ldbl-96/s_llrintl.c: Likewise.
* sysdeps/ieee754/ldbl-96/s_llroundl.c: Likewise.
* sysdeps/ieee754/ldbl-96/s_lrintl.c: Likewise.
* sysdeps/ieee754/ldbl-96/s_lroundl.c: Likewise.
* sysdeps/ieee754/ldbl-96/x2y2m1l.c: Likewise.
* sysdeps/powerpc/fpu/e_sqrt.c: Likewise.
* sysdeps/powerpc/fpu/e_sqrtf.c: Likewise.
* sysdeps/riscv/rv64/rvd/s_ceil.c: Likewise.
* sysdeps/riscv/rv64/rvd/s_floor.c: Likewise.
* sysdeps/riscv/rv64/rvd/s_nearbyint.c: Likewise.
* sysdeps/riscv/rv64/rvd/s_round.c: Likewise.
* sysdeps/riscv/rv64/rvd/s_roundeven.c: Likewise.
* sysdeps/riscv/rv64/rvd/s_trunc.c: Likewise.
* sysdeps/riscv/rvd/s_finite.c: Likewise.
* sysdeps/riscv/rvd/s_fmax.c: Likewise.
* sysdeps/riscv/rvd/s_fmin.c: Likewise.
* sysdeps/riscv/rvd/s_fpclassify.c: Likewise.
* sysdeps/riscv/rvd/s_isinf.c: Likewise.
* sysdeps/riscv/rvd/s_isnan.c: Likewise.
* sysdeps/riscv/rvd/s_issignaling.c: Likewise.
* sysdeps/riscv/rvf/fegetround.c: Likewise.
* sysdeps/riscv/rvf/feholdexcpt.c: Likewise.
* sysdeps/riscv/rvf/fesetenv.c: Likewise.
* sysdeps/riscv/rvf/fesetround.c: Likewise.
* sysdeps/riscv/rvf/feupdateenv.c: Likewise.
* sysdeps/riscv/rvf/fgetexcptflg.c: Likewise.
* sysdeps/riscv/rvf/ftestexcept.c: Likewise.
* sysdeps/riscv/rvf/s_ceilf.c: Likewise.
* sysdeps/riscv/rvf/s_finitef.c: Likewise.
* sysdeps/riscv/rvf/s_floorf.c: Likewise.
* sysdeps/riscv/rvf/s_fmaxf.c: Likewise.
* sysdeps/riscv/rvf/s_fminf.c: Likewise.
* sysdeps/riscv/rvf/s_fpclassifyf.c: Likewise.
* sysdeps/riscv/rvf/s_isinff.c: Likewise.
* sysdeps/riscv/rvf/s_isnanf.c: Likewise.
* sysdeps/riscv/rvf/s_issignalingf.c: Likewise.
* sysdeps/riscv/rvf/s_nearbyintf.c: Likewise.
* sysdeps/riscv/rvf/s_roundevenf.c: Likewise.
* sysdeps/riscv/rvf/s_roundf.c: Likewise.
* sysdeps/riscv/rvf/s_truncf.c: Likewise.

5 years ago[BZ #20271] Add newlines in __libc_fatal calls.
Paul Pluzhnikov [Sat, 1 Sep 2018 01:04:32 +0000 (18:04 -0700)]
[BZ #20271] Add newlines in __libc_fatal calls.

5 years agoReplace conform/list-header-symbols.pl with a Python script.
Joseph Myers [Fri, 31 Aug 2018 21:19:51 +0000 (21:19 +0000)]
Replace conform/list-header-symbols.pl with a Python script.

Continuing the move of test code from Perl to Python (which seems
uncontroversial, unlike dependencies on Python in the actual build of
glibc), this patch replaces conform/list-header-symbols.pl with a
Python script, as a first step in converting the conform/ tests.
(conform/glibcconform.py is an equivalent to GlibcConform.pm,
containing code that will be relevant to move than one of the conform/
scripts.)

Tested for x86_64, including verifying that the symbol lists generated
are identical to those generated by the Perl version.

* conform/glibcconform.py: New file.
* conform/list-header-symbols.py: Likewise.
* conform/list-header-symbols.pl: Remove.
* conform/Makefile (tests-special): Only add linknamespace tests
if [PYTHON].
($(linknamespace-symlists-tests)): Use list-header-symbols.py.

5 years agotest-container: Use xcopy_file_range for cross-device copy [BZ #23597]
H.J. Lu [Fri, 31 Aug 2018 20:07:47 +0000 (13:07 -0700)]
test-container: Use xcopy_file_range for cross-device copy [BZ #23597]

copy_file_range can't be used to copy a file from glibc source directory
to glibc build directory since they may be on different filesystems.
This patch adds xcopy_file_range for cross-device copy.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
[BZ #23597]
* support/Makefile (libsupport-routines): Add
support_copy_file_range and xcopy_file_range.
* support/support.h: Include <sys/types.h>.
(support_copy_file_range): New prototype.
* support/support_copy_file_range.c: New file.  Copied and
modified from io/copy_file_range-compat.c.
* support/test-container.c (copy_one_file): Call xcopy_file_rang
instead of copy_file_range.
* support/xcopy_file_range.c: New file.
* support/xunistd.h (xcopy_file_range): New prototype.

5 years agoFix test failure with -DNDEBUG.
Carlos O'Donell [Thu, 30 Aug 2018 15:01:33 +0000 (11:01 -0400)]
Fix test failure with -DNDEBUG.

The elf/tst-dlopen-aout.c test uses asserts to verify properties of the
test execution.  Instead of using assert it should use xpthread_create
and xpthread_join to catch errors starting the threads and fail the
test.  This shows up in Fedora 28 when building for i686-pc-linux-gnu
and using gcc 8.1.1.

Tested on i686, and fixes a check failure with -DNDEBUG.

Signed-off-by: Carlos O'Donell <carlos@redhat.com>
5 years agoreallocarray: Declare under _DEFAULT_SOURCE
Florian Weimer [Thu, 30 Aug 2018 12:14:53 +0000 (14:14 +0200)]
reallocarray: Declare under _DEFAULT_SOURCE

Initially, this function was restricted to _GNU_SOURCE, but experience
shows that compatibility with existing build systems is improved if we
declare it under _DEFAULT_SOURCE as well.

5 years agoTest stdlib/test-bz22786 exits now with unsupported if malloc fails.
Stefan Liebler [Thu, 30 Aug 2018 06:44:32 +0000 (08:44 +0200)]
Test stdlib/test-bz22786 exits now with unsupported if malloc fails.

The test tries to allocate more than 2^31 bytes which will always fail on s390
as it has maximum 2^31bit of memory.
Before commit 6c3a8a9d868a8deddf0d6dcc785b6d120de90523, this test returned
unsupported if malloc fails.  This patch re enables this behaviour.

Furthermore support_delete_temp_files() failed to remove the temp directory
in this case as it is not empty due to the created symlink.
Thus the creation of the symlink is moved behind malloc.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
ChangeLog:

* stdlib/test-bz22786.c (do_test): Return EXIT_UNSUPPORTED
if malloc fails.

5 years agoMake gen-libm-test.py treat plus_oflow and minus_oflow as non-finite.
Joseph Myers [Wed, 29 Aug 2018 20:01:57 +0000 (20:01 +0000)]
Make gen-libm-test.py treat plus_oflow and minus_oflow as non-finite.

When converting gen-libm-test to Python, in one place I noted a bug in
the old Perl version that I preserved in the Python version so that
the generated output files were the same with both versions, as such
comparisons help give confidence in the correctness of such a rewrite
of a script.  Now that the conversion has been done, this patch fixes
that bug, by arranging for tests with plus_oflow or minus_oflow
results (manually written tests in libm-test-*.inc that have
overflowing results that thus depend on the rounding mode) to be
properly treated as having non-finite results, and thus not run for
the __FINITE_MATH_ONLY__ tests.  (As the affected tests in fact did
pass for __FINITE_MATH_ONLY__ testing, this is just a matter of
logical correctness in the choice of which tests run for that case,
rather than fixing any actual test failures.)

Tested for x86_64.

* math/gen-libm-test.py (gen_test_args_res): Also treat plus_oflow
and minus_oflow as non-finite.

5 years agoSplit fenv_private.h out of math_private.h more consistently.
Joseph Myers [Tue, 28 Aug 2018 20:48:49 +0000 (20:48 +0000)]
Split fenv_private.h out of math_private.h more consistently.

On some architectures, the parts of math_private.h relating to the
floating-point environment are in a separate file fenv_private.h
included from math_private.h.  As this is purely an
architecture-specific convention used by several architectures,
however, all such architectures still need their own math_private.h,
even if it has nothing to do beyond #include <fenv_private.h> and
peculiarity of including the i386 file directly instead of having a
shared file in sysdeps/x86.

This patch makes the fenv_private.h name an architecture-independent
convention in glibc.  The include of fenv_private.h from
math_private.h becomes architecture-independent (until callers are
updated to include fenv_private.h directly so the include from
math_private.h is no longer needed).  Some architecture math_private.h
headers are removed if no longer needed, or renamed to fenv_private.h
if all they define belongs in that header; architecture fenv_private.h
headers now do require #include_next <fenv_private.h>.  The i386
fenv_private.h file moves to sysdeps/x86/fpu/ to reflect how it is
actually shared with x86_64.  The generic math_private.h gets a new
include of <stdbool.h>, as needed for bool in some prototypes in that
header (previously that was indirectly included via include/fenv.h,
which now only gets included too late in math_private.h, after those
prototypes).

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

* sysdeps/aarch64/fpu/fenv_private.h: New file.  Based on ....
* sysdeps/aarch64/fpu/math_private.h: ... this file.  All contents
moved to fenv_private.h except for ...
(TOINT_INTRINSICS): Kept in math_private.h.
(roundtoint): Likewise.
(converttoint): Likewise.
* sysdeps/arm/fenv_private.h: Change multiple-include guard to
[ARM_FENV_PRIVATE_H].  Include next <fenv_private.h>.
* sysdeps/arm/math_private.h: Remove.
* sysdeps/generic/fenv_private.h: New file.  Contents moved from
....
* sysdeps/generic/math_private.h: ... this file.  Include
<stdbool.h>.  Do not include <fenv.h> or <get-rounding-mode.h>.
Include <fenv_private.h>.  Remove functions and macros moved to
fenv_private.h.
* sysdeps/i386/fpu/math_private.h: Remove.
* sysdeps/mips/math_private.h: Move to ....
* sysdeps/mips/fpu/fenv_private.h: ... here.  Change
multiple-include guard to [MIPS_FENV_PRIVATE_H].  Remove
[__mips_hard_float] conditional.  Include next <fenv_private.h>.
* sysdeps/powerpc/fpu/fenv_private.h: Change multiple-include
guard to [POWERPC_FENV_PRIVATE_H].  Include next <fenv_private.h>.
* sysdeps/powerpc/fpu/math_private.h: Do not include
<fenv_private.h>.
* sysdeps/riscv/rvf/math_private.h: Move to ....
* sysdeps/riscv/rvf/fenv_private.h: ... here.  Change
multiple-include guard to [RISCV_FENV_PRIVATE_H].  Include next
<fenv_private.h>.
* sysdeps/sparc/fpu/fenv_private.h: Change multiple-include guard
to [SPARC_FENV_PRIVATE_H].  Include next <fenv_private.h>.
* sysdeps/sparc/fpu/math_private.h: Remove.
* sysdeps/i386/fpu/fenv_private.h: Move to ....
* sysdeps/x86/fpu/fenv_private.h: ... here.  Change
multiple-include guard to [X86_FENV_PRIVATE_H].  Include next
<fenv_private.h>.
* sysdeps/x86_64/fpu/math_private.h: Do not include
<sysdeps/i386/fpu/fenv_private.h>.

5 years agoregex: Add test tst-regcomp-truncated [BZ #23578]
Florian Weimer [Tue, 28 Aug 2018 10:57:46 +0000 (12:57 +0200)]
regex: Add test tst-regcomp-truncated [BZ #23578]

5 years agotest-container: EPERM from unshare is UNSUPPORTED
Florian Weimer [Tue, 28 Aug 2018 12:02:47 +0000 (14:02 +0200)]
test-container: EPERM from unshare is UNSUPPORTED

For example, the security policy on the Fedora build daemons results in
this EPERM error.

5 years agonscd: Fix use-after-free in addgetnetgrentX [BZ #23520]
Florian Weimer [Tue, 28 Aug 2018 11:19:27 +0000 (13:19 +0200)]
nscd: Fix use-after-free in addgetnetgrentX [BZ #23520]

addinnetgrX may use the heap-allocated buffer, so free the buffer
in this function.

5 years agoSpeedup first memmem match
Rajalakshmi Srinivasaraghavan [Tue, 28 Aug 2018 07:12:19 +0000 (12:42 +0530)]
Speedup first memmem match

As done in commit 284f42bc778e487dfd5dff5c01959f93b9e0c4f5, memcmp
can be used after memchr to avoid the initialization overhead of the
two-way algorithm for the first match.  This has shown improvement
>40% for first match.

5 years agoen_IN: Set the correct date format for "%x" (bug 17426).
Rafal Luzynski [Fri, 24 Aug 2018 10:06:05 +0000 (12:06 +0200)]
en_IN: Set the correct date format for "%x" (bug 17426).

[BZ #17426]
* localedata/locales/en_IN (d_fmt): Use "%d/%m/%y".

5 years agolinks-dso-program: Fix build-programs=no build case.
DJ Delorie [Mon, 27 Aug 2018 20:31:33 +0000 (16:31 -0400)]
links-dso-program: Fix build-programs=no build case.

* support/Makefile (others): Don't list programs explicitly as a
dependency of "others".

5 years agoMove EXCEPTION_SET_FORCES_TRAP out of math-tests.h.
Joseph Myers [Mon, 27 Aug 2018 18:52:41 +0000 (18:52 +0000)]
Move EXCEPTION_SET_FORCES_TRAP out of math-tests.h.

Completing the move of macros out of math-tests.h to smaller headers
following typo-proof conventions instead of using #ifndef, this patch
moves the EXCEPTION_SET_FORCES_TRAP macro out to its own
math-tests-trap-force.h header.

Tested with build-many-glibcs.py.

* sysdeps/generic/math-tests-trap-force.h: New file.
* sysdeps/generic/math-tests.h: Include <math-tests-trap-force.h>.
(EXCEPTION_SET_FORCES_TRAP): Do not define here.
* sysdeps/powerpc/math-tests.h: Remove file.
* sysdeps/powerpc/fpu/math-tests-trap-force.h: New file.

5 years agopthread_cond_broadcast: Fix waiters-after-spinning case [BZ #23538]
Martin Kuchta [Mon, 27 Aug 2018 15:03:35 +0000 (17:03 +0200)]
pthread_cond_broadcast: Fix waiters-after-spinning case [BZ #23538]

5 years agoUpdate netinet/udp.h from Linux 4.18.
Joseph Myers [Mon, 27 Aug 2018 13:43:05 +0000 (13:43 +0000)]
Update netinet/udp.h from Linux 4.18.

This patch adds the UDP_SEGMENT constant from Linux 4.18 to
netinet/udp.h.

Tested for x86_64.

* sysdeps/gnu/netinet/udp.h (UDP_SEGMENT): New macro.

5 years agoregex: fix uninitialized memory access
Paul Eggert [Sun, 26 Aug 2018 03:34:34 +0000 (20:34 -0700)]
regex: fix uninitialized memory access

I introduced this bug into gnulib in commit
8335a4d6c7b4448cd0bcb6d0bebf1d456bcfdb17 dated 2006-04-10;
eventually it was merged into glibc.  The bug was found by
project-repo <bugs@feusi.co> and reported here:
https://lists.gnu.org/r/sed-devel/2018-08/msg00017.html
Diagnosis and draft fix reported by Assaf Gordon here:
https://lists.gnu.org/r/bug-gnulib/2018-08/msg00071.html
https://lists.gnu.org/r/bug-gnulib/2018-08/msg00142.html
* posix/regex_internal.c (build_wcs_upper_buffer):
Fix bug when mbrtowc returns 0.

5 years agoUpdate translations for be.
Carlos O'Donell [Sat, 25 Aug 2018 02:26:41 +0000 (22:26 -0400)]
Update translations for be.

5 years agoFix IA64 links-dso-program link.
DJ Delorie [Sat, 25 Aug 2018 02:07:23 +0000 (22:07 -0400)]
Fix IA64 links-dso-program link.

* support/Makefile (LDLIBS-links-dso-program): Add -lgcc and
$(libunwind).

5 years agoFix BZ#23400 (creating temporary files in source tree), and undefined behavior in...
Paul Pluzhnikov [Sat, 25 Aug 2018 01:08:51 +0000 (18:08 -0700)]
Fix BZ#23400 (creating temporary files in source tree), and undefined behavior in test.

5 years agoMove EXCEPTION_ENABLE_SUPPORTED out of math-tests.h.
Joseph Myers [Fri, 24 Aug 2018 19:18:16 +0000 (19:18 +0000)]
Move EXCEPTION_ENABLE_SUPPORTED out of math-tests.h.

Continuing moving macros out of math-tests.h to smaller headers
following typo-proof conventions instead of using #ifndef, this patch
moves the EXCEPTION_ENABLE_SUPPORTED macro out to its own
math-tests-trap.h header.

Tested with build-many-glibcs.py.

* sysdeps/generic/math-tests-trap.h: New file.
* sysdeps/generic/math-tests.h: Include <math-tests-trap.h>.
(EXCEPTION_ENABLE_SUPPORTED): Do not define here.
* sysdeps/aarch64/math-tests.h: Remove file.
* sysdeps/arm/math-tests.h: Likewise.
* sysdeps/riscv/math-tests.h: Likewise.
* sysdeps/aarch64/math-tests-trap.h: New file.
* sysdeps/arm/math-tests-trap.h: Likewise.
* sysdeps/riscv/math-tests-trap.h: Likewise.

5 years agoRemove unused math files
Wilco Dijkstra [Fri, 24 Aug 2018 14:31:25 +0000 (15:31 +0100)]
Remove unused math files

Remove empty files due to the sin/cos improvements: k_sinf.c, k_cosf.c,
k_cos.c, k_sin.c.  After the tanf change s_rem_pio2f.c and k_rem_pio2f.c
(and the ia64, m68k and powerpc equivalents) are no longer used,
so remove them.  All e_rem_pio2.c files were already empty or commented
out, so remove them too.  Passes build-many-glibcs.

* math/Makefile: Remove empty files k_sin(f).c, k_cos(f).c.
Remove unused files e_rem_pio2(f).c, k_rem_pio2f.c.
* sysdeps/i386/fpu/e_rem_pio2.c: Delete file.
* sysdeps/ia64/fpu/e_rem_pio2.c: Likewise.
* sysdeps/ia64/fpu/e_rem_pio2f.c: Likewise.
* sysdeps/ia64/fpu/k_rem_pio2f.c: Likewise.
* sysdeps/ieee754/dbl-64/e_rem_pio2.c: Likewise.
* sysdeps/ieee754/dbl-64/k_cos.c: Likewise.
* sysdeps/ieee754/dbl-64/k_sin.c: Likewise.
* sysdeps/ieee754/flt-32/e_rem_pio2f.c: Likewise.
* sysdeps/ieee754/flt-32/k_cosf.c: Likewise.
* sysdeps/ieee754/flt-32/k_rem_pio2f.c: Likewise.
* sysdeps/ieee754/flt-32/k_sinf.c: Likewise.
* sysdeps/m68k/m680x0/fpu/e_rem_pio2.c: Likewise
* sysdeps/m68k/m680x0/fpu/e_rem_pio2f.c: Likewise
* sysdeps/m68k/m680x0/fpu/k_rem_pio2f.c: Likewise
* sysdeps/powerpc/fpu/e_rem_pio2f.c: Likewise.
* sysdeps/powerpc/fpu/k_rem_pio2f.c: Likewise.

5 years agoMove EXCEPTION_TESTS_* out of math-tests.h
Joseph Myers [Thu, 23 Aug 2018 23:41:13 +0000 (23:41 +0000)]
Move EXCEPTION_TESTS_* out of math-tests.h

Continuing moving macros out of math-tests.h to smaller headers
following typo-proof conventions instead of using #ifndef, this patch
moves the EXCEPTION_TESTS_* macros for individual types out to their
own sysdeps header.

As with ROUNDING_TESTS_*, there is no need to define these macros if
FE_ALL_EXCEPT == 0 and the individual exception macros are undefined;
thus, math-tests-exceptions.h headers are only needed for soft-float
ARM and RISC-V, while the other cases that defined these macros do not
need to do so (and the associated math-tests.h headers are thus
removed without needing replacement by math-tests-exceptions.h
headers).

Tested with build-many-glibcs.py.

* sysdeps/generic/math-tests-exceptions.h: New file.
* sysdeps/generic/math-tests.h: Include <math-tests-exceptions.h>.
(EXCEPTION_TESTS_float): Do not define here.
(EXCEPTION_TESTS_double): Likewise.
(EXCEPTION_TESTS_long_double): Likewise.
(EXCEPTION_TESTS_float128): Likewise.
* sysdeps/arm/math-tests.h [__SOFTFP__] (EXCEPTION_TESTS_float):
Likewise.
[__SOFTFP__] (EXCEPTION_TESTS_double): Likewise.
[__SOFTFP__] (EXCEPTION_TESTS_long_double): Likewise.
* sysdeps/arm/nofpu/math-tests-exceptions.h: New file.
* sysdeps/m68k/coldfire/math-tests.h: Remove file.
* sysdeps/mips/math-tests.h: Likewise.
* sysdeps/nios2/math-tests.h: Likewise.
* sysdeps/riscv/math-tests.h [!__riscv_flen]
(EXCEPTION_TESTS_float): Do not define here.
[!__riscv_flen] (EXCEPTION_TESTS_double): Likewise.
[!__riscv_flen] (EXCEPTION_TESTS_long_double): Likewise.
* sysdeps/riscv/nofpu/math-tests-exceptions.h: New file.

5 years agoUpdate NEWS for sinf improvements
Wilco Dijkstra [Thu, 23 Aug 2018 11:55:28 +0000 (12:55 +0100)]
Update NEWS for sinf improvements

The NEWS entry for sinf improvements is listed for 2.28, while it was
committed in 2.29, so move it there and mention tanf.

Committed as obvious.

* NEWS: Move optimized sinf entry to 2.29.

5 years agoSpeedup tanf range reduction
Wilco Dijkstra [Thu, 23 Aug 2018 11:38:16 +0000 (12:38 +0100)]
Speedup tanf range reduction

Speedup tanf range reduction by using the new sincosf range
reduction algorithm.  Overall code quality is improved due to
inlining, so there is a speedup even if no range reduction is
required.

tanf throughput gains on Cortex-A72:
* |x| < M_PI_4  : 1.1x
* |x| < M_PI_2  : 1.2x
* |x| < 2 * M_PI: 1.5x
* |x| < 120.0   : 1.6x
* |x| < Inf     : 12.1x

* sysdeps/ieee754/flt-32/s_tanf.c (__tanf): Use fast range reduction.

5 years agoAdd test-in-container infrastructure.
DJ Delorie [Fri, 6 Jul 2018 05:10:41 +0000 (01:10 -0400)]
Add test-in-container infrastructure.

* Makefile (testroot.pristine): New rules to initialize the
test-in-container "testroot".
* Makerules (all-testsuite): Add tests-container.
* Rules (tests-expected): Add tests-container.
(binaries-all-tests): Likewise.
(tests-container): New, run these tests in the testroot container.
* support/Makefile (others): Add *-container, support_paths.c,
xmkdirp, and links-dso-program.
* support/links-dso-program-c.c: New.
* support/links-dso-program.cc: New.
* support/test-container.c: New.
* support/shell-container.c: New.
* support/echo-container.c: New.
* support/true-container.c: New.
* support/xmkdirp.c: New.
* support/xsymlink.c: New.
* support/support_paths.c: New.
* support/support.h: Add support paths prototypes.
* support/xunistd.h: Add xmkdirp () and xsymlink ().

* nss/tst-nss-test3.c: Convert to test-in-container.
* nss/tst-nss-test3.root/: New.

5 years agoregex: port Gnulib code to z/OS POSIX environment
Paul Eggert [Thu, 23 Aug 2018 00:46:32 +0000 (17:46 -0700)]
regex: port Gnulib code to z/OS POSIX environment

Problem reported by Arnold Robbins in:
https://lists.gnu.org/r/bug-gnulib/2018-08/msg00129.html
* posix/regex_internal.h (__iswalnum, __towlower, __towupper) [!_LIBC]:
Undef.

5 years agoDon't redefine ROUNDING_TESTS_* in math/test-*-vlen*.h.
Joseph Myers [Wed, 22 Aug 2018 15:22:06 +0000 (15:22 +0000)]
Don't redefine ROUNDING_TESTS_* in math/test-*-vlen*.h.

This patch completes the move of ROUNDING_TESTS_* macros to typo-proof
conventions by stopping redefining them in test-*-vlen*.h.  Instead,
libm-test-driver.c is made to check TEST_MATHVEC when setting
non-to-nearest rounding modes.

Tested for x86_64.

* math/test-double-vlen2.h: Don't include <math-tests-rounding.h>.
(ROUNDING_TESTS_double): Remove.
* math/test-double-vlen4.h: Don't include <math-tests-rounding.h>.
(ROUNDING_TESTS_double): Remove.
* math/test-double-vlen8.h: Don't include <math-tests-rounding.h>.
(ROUNDING_TESTS_double): Remove.
* math/test-float-vlen16.h: Don't include <math-tests-rounding.h>.
(ROUNDING_TESTS_float): Remove.
* math/test-float-vlen4.h: Don't include <math-tests-rounding.h>.
(ROUNDING_TESTS_float): Remove.
* math/test-float-vlen8.h: Don't include <math-tests-rounding.h>.
(ROUNDING_TESTS_float): Remove.
* math/libm-test-driver.c (IF_ROUND_INIT_FE_DOWNWARD): Check
!TEST_MATHVEC here.
(IF_ROUND_INIT_FE_TOWARDZERO): Likewise.
(IF_ROUND_INIT_FE_UPWARD): Likewise.

5 years agoMove ROUNDING_TESTS_* out of math-tests.h.
Joseph Myers [Wed, 22 Aug 2018 12:25:50 +0000 (12:25 +0000)]
Move ROUNDING_TESTS_* out of math-tests.h.

Continuing moving macros out of math-tests.h to smaller headers
following typo-proof conventions instead of using #ifndef, this patch
moves the ROUNDING_TESTS_* macros for individual types out to their
own sysdeps header.

In the soft-float case where FE_TONEAREST is the only rounding mode
macro defined, there is no need to define ROUNDING_TESTS_*; it is only
necessary when rounding modes macros are defined that may not be
supported at runtime.  Thus, the ROUNDING_TESTS_* definitions for some
configurations are just removed, not moved to new
math-tests-rounding.h headers; the only architectures needing
math-tests-rounding.h are those where the macros are defined in
bits/fenv.h because of the possibility of a soft-float compilation
using a hard-float glibc with the same ABI (i.e., ARM and RISC-V).

The test-*-vlen*.h headers, by using #undef, do not yet follow
typo-proof conventions (but they no longer implicitly rely on being
included before math-tests.h, and this area can always be cleaned up
further in future).

Tested with build-many-glibcs.py.

* sysdeps/generic/math-tests-rounding.h: New file.
* sysdeps/generic/math-tests.h: Include <math-tests-rounding.h>.
(ROUNDING_TESTS_float): Do not define here.
(ROUNDING_TESTS_double): Likewise.
(ROUNDING_TESTS_long_double): Likewise.
(ROUNDING_TESTS_float128): Likewise.
* math/test-double-vlen2.h: Include <math-tests-rounding.h>.
(ROUNDING_TESTS_double): Undefine before defining.
* math/test-double-vlen4.h: Include <math-tests-rounding.h>.
(ROUNDING_TESTS_double): Undefine before defining.
* math/test-double-vlen8.h: Include <math-tests-rounding.h>.
(ROUNDING_TESTS_double): Undefine before defining.
* math/test-float-vlen16.h: Include <math-tests-rounding.h>.
(ROUNDING_TESTS_float): Undefine before defining.
* math/test-float-vlen4.h: Include <math-tests-rounding.h>.
(ROUNDING_TESTS_float): Undefine before defining.
* math/test-float-vlen8.h: Include <math-tests-rounding.h>.
(ROUNDING_TESTS_float): Undefine before defining.
* sysdeps/arm/nofpu/math-tests-rounding.h: New file.
* sysdeps/arm/math-tests.h [__SOFTFP__] (ROUNDING_TESTS_float): Do
not define here.
[__SOFTFP__] (ROUNDING_TESTS_double): Likewise.
[__SOFTFP__] (ROUNDING_TESTS_long_double): Likewise.
* sysdeps/riscv/nofpu/math-tests-rounding.h: New file.
* sysdeps/riscv/math-tests.h [!__riscv_flen]
(ROUNDING_TESTS_float): Do not define here.
[!__riscv_flen] (ROUNDING_TESTS_double): Likewise.
[!__risv_flen] (ROUNDING_TESTS_long_double): Likewise.
* sysdeps/m68k/coldfire/math-tests.h [!__mcffpu__]
(ROUNDING_TESTS_float): Likewise.
[!__mcffpu__] (ROUNDING_TESTS_double): Likewise.
[!__mcffpu__] (ROUNDING_TESTS_long_double): Likewise.
* sysdeps/mips/math-tests.h [__mips_soft_float]
(ROUNDING_TESTS_float): Likewise.
[__mips_soft_float] (ROUNDING_TESTS_double): Likewise.
[__mips_soft_float] (ROUNDING_TESTS_long_double): Likewise.
* sysdeps/nios2/math-tests.h (ROUNDING_TESTS_float): Likewise.
(ROUNDING_TESTS_double): Likewise.
(ROUNDING_TESTS_long_double): Likewise.

5 years agoAdd PF_XDP, AF_XDP and SOL_XDP from Linux 4.18 to bits/socket.h.
Tobias Klauser [Tue, 21 Aug 2018 17:22:53 +0000 (17:22 +0000)]
Add PF_XDP, AF_XDP and SOL_XDP from Linux 4.18 to bits/socket.h.

This patch adds the PF_XDP, AF_XDP and SOL_XDP macros from Linux 4.18 to
sysdeps/unix/sysv/linux/bits/socket.h.

* sysdeps/unix/sysv/linux/bits/socket.h (PF_MAX): Set to 45.
(PF_XDP): New macro.
(AF_XDP): New macro.
(SOL_XDP): New macro.

5 years agoUpdate netinet/tcp.h from Linux 4.18.
Joseph Myers [Tue, 21 Aug 2018 15:57:22 +0000 (15:57 +0000)]
Update netinet/tcp.h from Linux 4.18.

This patch adds constants from netinet/tcp.h in Linux 4.18, and an
associated struct tcp_zerocopy_receive, to sysdeps/gnu/netinet/tcp.h.
The new TCP_REPAIR_* constants seemed sufficiently related to those
already present to include them.

Note that this patch does not include additions to struct tcp_info;
there are many other elements in this structure in the Linux kernel
that are not included in the glibc version (which was last extended in
2007, it seems).  Such additions to the end of the structure may be OK
with the expected way it is used (size passed explicitly to the kernel
with getsockopt), but in principle any change to the size of a type
provided by glibc is an ABI change for external applications /
libraries using that type in their ABIs, and has the associated risks
of such a change.

Tested for x86_64.

* sysdeps/gnu/netinet/tcp.h (TCP_ZEROCOPY_RECEIVE): New macro.
(TCP_INQ): Likewise.
(TCP_CM_INQ): Likewise.
(TCP_REPAIR_ON): Likewise.
(TCP_REPAIR_OFF): Likewise.
(TCP_REPAIR_OFF_NO_WP): Likewise.
(struct tcp_zerocopy_receive): New type.

5 years agoAvoid running some tests if the file system does not support holes
Florian Weimer [Tue, 21 Aug 2018 10:56:53 +0000 (12:56 +0200)]
Avoid running some tests if the file system does not support holes

Otherwise, these tests fills up the entire disk (or just run very
slowly and eventually time out).

5 years agoMakeconfig: Do not sort and deduplicate +cflags [BZ # 17248]
Florian Weimer [Tue, 21 Aug 2018 09:43:35 +0000 (11:43 +0200)]
Makeconfig: Do not sort and deduplicate +cflags [BZ # 17248]

The original intent behind this is unclear.  It interferes with flags
that has to be ordered in a particular way.

5 years ago__readlink_chk: Remove micro-optimization
Florian Weimer [Tue, 21 Aug 2018 09:24:12 +0000 (11:24 +0200)]
__readlink_chk: Remove micro-optimization

5 years ago__readlink_chk: Assume HAVE_INLINED_SYSCALLS
Florian Weimer [Mon, 20 Aug 2018 16:23:28 +0000 (18:23 +0200)]
__readlink_chk: Assume HAVE_INLINED_SYSCALLS

HAVE_INLINED_SYSCALLS is always defined on Linux.
Switch to INLINE_SYSCALL_CALL as well.

5 years agoUpdate struct signalfd_siginfo from Linux 4.18.
Joseph Myers [Mon, 20 Aug 2018 15:48:16 +0000 (15:48 +0000)]
Update struct signalfd_siginfo from Linux 4.18.

This patch updates struct signalfd_siginfo in sys/signalfd.h with new
members from Linux 4.18 (plus ssi_addr_lsb, added to the kernel in
2.6.37 without being added to sys/signalfd.h at that time).  The
__pad2 member name follows the kernel and the existing __pad name.

Tested for x86_64.

* sysdeps/unix/sysv/linux/sys/signalfd.h (struct
signalfd_siginfo): Add ssi_addr_lsb, ssi_syscall, ssi_call_addr
and ssi_arch members.

5 years agoAdd NT_VMCOREDD, AT_MINSIGSTKSZ from Linux 4.18 to elf.h.
Joseph Myers [Mon, 20 Aug 2018 15:46:26 +0000 (15:46 +0000)]
Add NT_VMCOREDD, AT_MINSIGSTKSZ from Linux 4.18 to elf.h.

This patch adds two new constants from Linux 4.18 to elf.h,
NT_VMCOREDD and AT_MINSIGSTKSZ.

Tested for x86_64.

* elf/elf.c (NT_VMCOREDD): New macro.
(AT_MINSIGSTKSZ): Likewise.

5 years agomalloc: Add ChangeLog for accidentally committed change
Florian Weimer [Mon, 20 Aug 2018 12:57:13 +0000 (14:57 +0200)]
malloc: Add ChangeLog for accidentally committed change

Commit b90ddd08f6dd688e651df9ee89ca3a69ff88cd0c ("malloc: Additional
checks for unsorted bin integrity I.") was committed without a
whitespace fix, so it is adjusted here as well.

5 years agopowerpc: Remove powerpc specific sinf and cosf optimization
Rajalakshmi Srinivasaraghavan [Mon, 20 Aug 2018 03:17:43 +0000 (08:47 +0530)]
powerpc: Remove powerpc specific sinf and cosf optimization

New generic optimization of sinf and cosf introduced by commit
599cf3976679e1b345307d9c02057f02aa95528f shows improvement
compared to powerpc specific assembly version.  Hence removing
the powerpc assembly versions to make use of generic code.

5 years agomath: Regenerate s390 ulps
Florian Weimer [Fri, 17 Aug 2018 14:39:13 +0000 (16:39 +0200)]
math: Regenerate s390 ulps

Based on results on a s390x 2964 machine, with -march=z196 and
-mtune=zEC12, and separately with -march=z13 and -mtune=z14.

5 years agomalloc: Additional checks for unsorted bin integrity I.
Istvan Kurucsai [Tue, 16 Jan 2018 13:54:32 +0000 (14:54 +0100)]
malloc: Additional checks for unsorted bin integrity I.

On Thu, Jan 11, 2018 at 3:50 PM, Florian Weimer <fweimer@redhat.com> wrote:
> On 11/07/2017 04:27 PM, Istvan Kurucsai wrote:
>>
>> +          next = chunk_at_offset (victim, size);
>
>
> For new code, we prefer declarations with initializers.

Noted.

>> +          if (__glibc_unlikely (chunksize_nomask (victim) <= 2 * SIZE_SZ)
>> +              || __glibc_unlikely (chunksize_nomask (victim) >
>> av->system_mem))
>> +            malloc_printerr("malloc(): invalid size (unsorted)");
>> +          if (__glibc_unlikely (chunksize_nomask (next) < 2 * SIZE_SZ)
>> +              || __glibc_unlikely (chunksize_nomask (next) >
>> av->system_mem))
>> +            malloc_printerr("malloc(): invalid next size (unsorted)");
>> +          if (__glibc_unlikely ((prev_size (next) & ~(SIZE_BITS)) !=
>> size))
>> +            malloc_printerr("malloc(): mismatching next->prev_size
>> (unsorted)");
>
>
> I think this check is redundant because prev_size (next) and chunksize
> (victim) are loaded from the same memory location.

I'm fairly certain that it compares mchunk_size of victim against
mchunk_prev_size of the next chunk, i.e. the size of victim in its
header and footer.

>> +          if (__glibc_unlikely (bck->fd != victim)
>> +              || __glibc_unlikely (victim->fd != unsorted_chunks (av)))
>> +            malloc_printerr("malloc(): unsorted double linked list
>> corrupted");
>> +          if (__glibc_unlikely (prev_inuse(next)))
>> +            malloc_printerr("malloc(): invalid next->prev_inuse
>> (unsorted)");
>
>
> There's a missing space after malloc_printerr.

Noted.

> Why do you keep using chunksize_nomask?  We never investigated why the
> original code uses it.  It may have been an accident.

You are right, I don't think it makes a difference in these checks. So
the size local can be reused for the checks against victim. For next,
leaving it as such avoids the masking operation.

> Again, for non-main arenas, the checks against av->system_mem could be made
> tighter (against the heap size).  Maybe you could put the condition into a
> separate inline function?

We could also do a chunk boundary check similar to what I proposed in
the thread for the first patch in the series to be even more strict.
I'll gladly try to implement either but believe that refining these
checks would bring less benefits than in the case of the top chunk.
Intra-arena or intra-heap overlaps would still be doable here with
unsorted chunks and I don't see any way to counter that besides more
generic measures like randomizing allocations and your metadata
encoding patches.

I've attached a revised version with the above comments incorporated
but without the refined checks.

Thanks,
Istvan

From a12d5d40fd7aed5fa10fc444dcb819947b72b315 Mon Sep 17 00:00:00 2001
From: Istvan Kurucsai <pistukem@gmail.com>
Date: Tue, 16 Jan 2018 14:48:16 +0100
Subject: [PATCH v2 1/1] malloc: Additional checks for unsorted bin integrity
 I.

Ensure the following properties of chunks encountered during binning:
- victim chunk has reasonable size
- next chunk has reasonable size
- next->prev_size == victim->size
- valid double linked list
- PREV_INUSE of next chunk is unset

    * malloc/malloc.c (_int_malloc): Additional binning code checks.

5 years agoAdd --with-nonshared-cflags option to configure
Florian Weimer [Fri, 17 Aug 2018 09:44:39 +0000 (11:44 +0200)]
Add --with-nonshared-cflags option to configure

5 years agoMakeconfig (ASFLAGS): Always append required assembler flags
Florian Weimer [Fri, 17 Aug 2018 09:35:42 +0000 (11:35 +0200)]
Makeconfig (ASFLAGS): Always append required assembler flags

Otherwise, it is impossible to set ASFLAGS differently from CFLAGS
without also overriding essential flags such as -Wa,--noexecstack.

5 years agoFix attribution of previous change in ChangeLog
Florian Weimer [Fri, 17 Aug 2018 09:33:29 +0000 (11:33 +0200)]
Fix attribution of previous change in ChangeLog

5 years agomalloc: Mitigate null-byte overflow attacks
Moritz Eckert [Fri, 17 Aug 2018 01:08:36 +0000 (21:08 -0400)]
malloc: Mitigate null-byte overflow attacks

* malloc/malloc.c (_int_free): Check for corrupt prev_size vs size.
(malloc_consolidate): Likewise.

5 years agomalloc: Verify size of top chunk.
Pochang Chen [Thu, 16 Aug 2018 19:24:24 +0000 (15:24 -0400)]
malloc: Verify size of top chunk.

The House of Force is a well-known technique to exploit heap
overflow. In essence, this exploit takes three steps:
1. Overwrite the size of top chunk with very large value (e.g. -1).
2. Request x bytes from top chunk. As the size of top chunk
   is corrupted, x can be arbitrarily large and top chunk will
   still be offset by x.
3. The next allocation from top chunk will thus be controllable.

If we verify the size of top chunk at step 2, we can stop such attack.

5 years agoReallocate buffers for every run in strlen
Siddhesh Poyarekar [Thu, 16 Aug 2018 08:39:56 +0000 (14:09 +0530)]
Reallocate buffers for every run in strlen

Try and avoid influencing performance of neighbouring functions.

5 years agoPrint strlen benchmark output in json
Siddhesh Poyarekar [Thu, 16 Aug 2018 08:29:13 +0000 (13:59 +0530)]
Print strlen benchmark output in json

Allow reading the benchmark using the compare_strings.py script.

5 years agopowerpc: Rearrange little endian specific files
Rajalakshmi Srinivasaraghavan [Thu, 16 Aug 2018 06:42:02 +0000 (12:12 +0530)]
powerpc: Rearrange little endian specific files

This patch moves little endian specific POWER9 optimization files to
sysdeps/powerpc/powerpc64/le and creates POWER9 ifunc functions
only for little endian.

5 years ago[aarch64] Add an ASIMD variant of strlen for falkor
Siddhesh Poyarekar [Wed, 15 Aug 2018 17:31:33 +0000 (23:01 +0530)]
[aarch64] Add an ASIMD variant of strlen for falkor

This variant of strlen uses vector loads and operations to reduce the
size of the code and also eliminate the non-ascii fallback.  This
works very well for falkor because of its two vector units and
efficient vector ops.  In the best case it reduces latency of cases in
bench-strlen by 48%, with gains throughout the benchmark.
strlen-walk also sees uniform gains in the 5%-15% range.

Overall the routine appears to work better than the stock one for falkor
regardless of the benchmark, length of string or cache state.

The same cannot be said of a53 and a72 though.  a53 performance was
greatly reduced and for a72 it was a bit of a mixed bag, slightly on the
negative side but I reckon it might be fast in some situations.

* sysdeps/aarch64/strlen.S (__strlen): Rename to STRLEN.
[!STRLEN](STRLEN): Set to __strlen.
* sysdeps/aarch64/multiarch/strlen.c: New file.
* sysdeps/aarch64/multiarch/strlen_generic.S: Likewise.
* sysdeps/aarch64/multiarch/strlen_asimd.S: Likewise.
* sysdeps/aarch64/multiarch/ifunc-impl-list.c
(__libc_ifunc_impl_list): Add strlen.
* sysdeps/aarch64/multiarch/Makefile (sysdep_routines): Add
strlen_generic and strlen_asimd.

Reviewed-By: szabolcs.nagy@arm.com
CC: pinskia@gmail.com
5 years agoUse generic sinf/cosf in lgammaf_r
Wilco Dijkstra [Wed, 15 Aug 2018 15:01:21 +0000 (16:01 +0100)]
Use generic sinf/cosf in lgammaf_r

The internal functions __kernel_sinf and __kernel_cosf are used only by
lgammaf_r.  Removing the internal functions and using the generic sinf
and cosf is better overall.  Benchmarking on Cortex-A72 shows the generic
sinf and cosf are 1.4x and 2.3x faster in the range |x| < PI/4, and 0.66x
and 1.1x for |x| < PI/2, so it should make lgammaf_r faster on average.

GLIBC regression tests pass on AArch64.

* sysdeps/ieee754/flt-32/e_lgammaf_r.c (sin_pif): Use __sinf/__cosf.
* sysdeps/ieee754/flt-32/k_cosf.c (__kernel_cosf): Remove all code.
* sysdeps/ieee754/flt-32/k_sinf.c (__kernel_sinf): Likewise.

5 years agoFix spaces in x86_64 ULP file
Wilco Dijkstra [Wed, 15 Aug 2018 11:56:22 +0000 (12:56 +0100)]
Fix spaces in x86_64 ULP file

Fix a few missing spaces, it's now identical to the regenerated version.

Passes GLIBC tests on x64.

* sysdeps/x86_64/fpu/libm-test-ulps: Regenerate to fix spaces.

5 years agoerror, warn, warnx: Use __fxprintf for wide printing [BZ #23519]
Florian Weimer [Tue, 14 Aug 2018 11:36:10 +0000 (13:36 +0200)]
error, warn, warnx: Use __fxprintf for wide printing [BZ #23519]

Also introduce the __vfxprintf function.

5 years agoImprove performance of sinf and cosf
Wilco Dijkstra [Tue, 14 Aug 2018 09:45:59 +0000 (10:45 +0100)]
Improve performance of sinf and cosf

The second patch improves performance of sinf and cosf using the same
algorithms and polynomials.  The returned values are identical to sincosf
for the same input.  ULP definitions for AArch64 and x64 are updated.

sinf/cosf througput gains on Cortex-A72:
* |x| < 0x1p-12 : 1.2x
* |x| < M_PI_4  : 1.8x
* |x| < 2 * M_PI: 1.7x
* |x| < 120.0   : 2.3x
* |x| < Inf     : 3.0x

* NEWS: Mention sinf, cosf, sincosf.
* sysdeps/aarch64/libm-test-ulps: Update ULP for sinf, cosf, sincosf.
* sysdeps/x86_64/fpu/libm-test-ulps: Update ULP for sinf and cosf.
* sysdeps/x86_64/fpu/multiarch/s_sincosf-fma.c: Add definitions of
constants rather than including generic sincosf.h.
* sysdeps/x86_64/fpu/s_sincosf_data.c: Remove.
* sysdeps/ieee754/flt-32/s_cosf.c (cosf): Rewrite.
* sysdeps/ieee754/flt-32/s_sincosf.h (reduced_sin): Remove.
(reduced_cos): Remove.
(sinf_poly): New function.
* sysdeps/ieee754/flt-32/s_sinf.c (sinf): Rewrite.

5 years agonss_files: Fix file stream leak in aliases lookup [BZ #23521]
Florian Weimer [Tue, 14 Aug 2018 08:52:06 +0000 (10:52 +0200)]
nss_files: Fix file stream leak in aliases lookup [BZ #23521]

In order to get a clean test case, it was necessary to fix partially
fixed bug 23522 as well.

5 years agonscd: Deallocate existing user names in file parser
Florian Weimer [Tue, 14 Aug 2018 08:51:07 +0000 (10:51 +0200)]
nscd: Deallocate existing user names in file parser

This avoids a theoretical memory leak (theoretical because it depends on
multiple server-user/stat-user directives in the configuration file).

5 years agoUpdate syscall-names.list for Linux 4.18.
Joseph Myers [Mon, 13 Aug 2018 21:35:27 +0000 (21:35 +0000)]
Update syscall-names.list for Linux 4.18.

This patch updates sysdeps/unix/sysv/linux/syscall-names.list for
Linux 4.18.  The io_pgetevents and rseq syscalls are added to the
kernel on various architectures, so need to be mentioned in this file.

Tested with build-many-glibcs.py.

* sysdeps/unix/sysv/linux/syscall-names.list: Update kernel
version to 4.18.
(io_pgetevents): New syscall.
(rseq): Likewise.

5 years agoUpdate install.texi documentation of uses of Perl and Python.
Joseph Myers [Mon, 13 Aug 2018 17:20:46 +0000 (17:20 +0000)]
Update install.texi documentation of uses of Perl and Python.

The install.texi documentation of uses of Perl and Python is
substantially out of date.

The description of Perl is "to test the installation" (which I
interpret as referring to test-installation.pl), but it's used for
more tests than that, and to build the manual, and to regenerate one
file in the source tree.

The description of Python is only for pretty-printer tests, but it's
used for other tests / benchmarks as well (and for other internal uses
such as updating Unicode data, for which we already require Python 3,
but I think install.texi only needs to describe uses from the main
glibc Makefiles).

This patch updates the descriptions of what those tools are used for.
The Python information (and information about other tools for testing
pretty printers) was awkwardly in the middle of the general
description of building and testing glibc, rather than with the rest
of information about tools used in glibc build and test; this patch
moves the information about those tools into the main list.

Tested with regeneration of INSTALL as well as "make info" and "make
pdf".

* manual/install.texi (Configuring and compiling): Do not list
tools used for testing pretty printers here.
(Tools for Compilation): List Python, PExpect and GDB here.
Update descriptions of uses of Perl and Python.
* INSTALL: Regenerate.

5 years agoUse Linux 4.18 in build-many-glibcs.py.
Joseph Myers [Mon, 13 Aug 2018 16:46:13 +0000 (16:46 +0000)]
Use Linux 4.18 in build-many-glibcs.py.

* scripts/build-many-glibcs.py (Context.checkout): Default Linux
version to 4.18.

5 years agoerror, error_at_line: Add missing va_end calls
Florian Weimer [Mon, 13 Aug 2018 12:28:07 +0000 (14:28 +0200)]
error, error_at_line: Add missing va_end calls

5 years agombstowcs: Remove outdated comment
Florian Weimer [Mon, 13 Aug 2018 12:05:00 +0000 (14:05 +0200)]
mbstowcs: Remove outdated comment

ISO C requires that there is no effect on any global conversion state,
so the change in commit 9f097308c7465443765d1e25699a4cf33eff5455 was
correct in princple.

5 years ago[benchtests] Add workload test properties to schema
Siddhesh Poyarekar [Sat, 11 Aug 2018 13:24:46 +0000 (18:54 +0530)]
[benchtests] Add workload test properties to schema

Add the workload test properties (max-throughput, latency, etc.) to
the schema to prevent benchmark output validation from failing.

* benchtests/scripts/benchout.schema.json (properties): Add
new properties.

5 years ago[benchtests] Add mandatory attributes to workload tests
Siddhesh Poyarekar [Sat, 11 Aug 2018 13:15:03 +0000 (18:45 +0530)]
[benchtests] Add mandatory attributes to workload tests

Add the duration and iterations attributes to the workloads tests to
make the json schema parser happy

* benchtests/bench-skeleton.c (main): Add duration and
iterations attributes.

5 years agoChangeLog: Fix an obvious typo.
Rafal Luzynski [Fri, 10 Aug 2018 21:57:35 +0000 (23:57 +0200)]
ChangeLog: Fix an obvious typo.

The typo has been introduced in commit
08a5ee14c6fcd87caa4f6f5c442be2fc345211f0.

5 years agoregex: Gnulib unibyte RRI uses bytes not chars
Paul Eggert [Fri, 10 Aug 2018 21:19:05 +0000 (14:19 -0700)]
regex: Gnulib unibyte RRI uses bytes not chars

Adjust the non-glibc code to agree with what Gawk needs for
rational range interpretation (RRI) for regular expression ranges.
In unibyte locales, Gawk wants ranges to use the underlying byte
rather than the character code point.  This change does not affect
glibc proper.
* posix/regcomp.c (parse_byte) [!LIBC && RE_ENABLE_I18N]:
In unibyte locales, use the byte value rather than
running it through btowc.

5 years agoMove SNAN_TESTS_* out of math-tests.h.
Joseph Myers [Fri, 10 Aug 2018 19:22:01 +0000 (19:22 +0000)]
Move SNAN_TESTS_* out of math-tests.h.

Continuing moving macros out of math-tests.h to smaller headers
following typo-proof conventions instead of using #ifndef, this patch
moves the SNAN_TESTS_* macros for individual types out to their own
sysdeps header (while the type-generic SNAN_TESTS wrapper for those
macros remains in math-tests.h).

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

* sysdeps/generic/math-tests-snan.h: New file.
* sysdeps/generic/math-tests.h: Include <math-tests-snan.h>.
(SNAN_TESTS_float): Do not define here.
(SNAN_TESTS_double): Likewise.
(SNAN_TESTS_long_double): Likewise.
(SNAN_TESTS_float128): Likewise.
* sysdeps/i386/fpu/math-tests-snan.h: New file.
* sysdeps/i386/fpu/math-tests.h: Remove file.
* sysdeps/ia64/math-tests-snan.h: New file.
* sysdeps/ia64/math-tests.h: Remove file.
* sysdeps/x86/math-tests.h: Likewise.
* sysdeps/x86_64/fpu/math-tests-snan.h: New file.

5 years agoImprove performance of sincosf
Wilco Dijkstra [Fri, 10 Aug 2018 16:31:30 +0000 (17:31 +0100)]
Improve performance of sincosf

This patch is a complete rewrite of sincosf.  The new version is
significantly faster, as well as simple and accurate.
The worst-case ULP is 0.5607, maximum relative error is 0.5303 * 2^-23 over
all 4 billion inputs.  In non-nearest rounding modes the error is 1ULP.

The algorithm uses 3 main cases: small inputs which don't need argument
reduction, small inputs which need a simple range reduction and large inputs
requiring complex range reduction.  The code uses approximate integer
comparisons to quickly decide between these cases.

The small range reducer uses a single reduction step to handle values up to
120.0.  It is fastest on targets which support inlined round instructions.

The large range reducer uses integer arithmetic for simplicity.  It does a
32x96 bit multiply to compute a 64-bit modulo result.  This is more than
accurate enough to handle the worst-case cancellation for values close to
an integer multiple of PI/4.  It could be further optimized, however it is
already much faster than necessary.

sincosf throughput gains on Cortex-A72:
* |x| < 0x1p-12 : 1.6x
* |x| < M_PI_4  : 1.7x
* |x| < 2 * M_PI: 1.5x
* |x| < 120.0   : 1.8x
* |x| < Inf     : 2.3x

* math/Makefile: Add s_sincosf_data.c.
* sysdeps/ia64/fpu/s_sincosf_data.c: New file.
* sysdeps/ieee754/flt-32/s_sincosf.h (abstop12): Add new function.
(sincosf_poly): Likewise.
(reduce_small): Likewise.
(reduce_large): Likewise.
* sysdeps/ieee754/flt-32/s_sincosf.c (sincosf): Rewrite.
* sysdeps/ieee754/flt-32/s_sincosf_data.c: New file with sincosf data.
* sysdeps/m68k/m680x0/fpu/s_sincosf_data.c: New file.
* sysdeps/x86_64/fpu/s_sincosf_data.c: New file.

5 years agoClean up converttoint handling and document the semantics
Szabolcs Nagy [Wed, 4 Jul 2018 11:29:29 +0000 (12:29 +0100)]
Clean up converttoint handling and document the semantics

This patch currently only affects aarch64.

The roundtoint and converttoint internal functions are only called with small
values, so 32 bit result is enough for converttoint and it is a signed int
conversion so the return type is changed to int32_t.

The original idea was to help the compiler keeping the result in uint64_t,
then it's clear that no sign extension is needed and there is no accidental
undefined or implementation defined signed int arithmetics.

But it turns out gcc does a good job with inlining so changing the type has
no overhead and the semantics of the conversion is less surprising this way.
Since we want to allow the asuint64 (x + 0x1.8p52) style conversion, the top
bits were never usable and the existing code ensures that only the bottom
32 bits of the conversion result are used.

On aarch64 the neon intrinsics (which round ties to even) are changed to
round and lround (which round ties away from zero) this does not affect the
results in a significant way, but more portable (relies on round and lround
being inlined which works with -fno-math-errno).

The TOINT_SHIFT and TOINT_RINT macros were removed, only keep separate code
paths for TOINT_INTRINSICS and !TOINT_INTRINSICS.

* sysdeps/aarch64/fpu/math_private.h (roundtoint): Use round.
(converttoint): Use lround.
* sysdeps/ieee754/flt-32/math_config.h (roundtoint): Declare and
document the semantics when TOINT_INTRINSICS is set.
(converttoint): Likewise.
(TOINT_RINT): Remove.
(TOINT_SHIFT): Remove.
* sysdeps/ieee754/flt-32/e_expf.c (__expf): Remove the TOINT_RINT code
path.

5 years agoLinux: Rewrite __old_getdents64 [BZ #23497]
Florian Weimer [Fri, 10 Aug 2018 08:20:13 +0000 (10:20 +0200)]
Linux: Rewrite __old_getdents64 [BZ #23497]

Commit 298d0e3129c0b5137f4989275b13fe30d0733c4d ("Consolidate Linux
getdents{64} implementation") broke the implementation because it does
not take into account struct offset differences.

The new implementation is close to the old one, before the
consolidation, but has been cleaned up slightly.

5 years agoS390: Fix unwind in 32-bit _mcount
Ilya Leoshkevich [Fri, 10 Aug 2018 07:07:44 +0000 (09:07 +0200)]
S390: Fix unwind in 32-bit _mcount

* Fix CFI offset for %r14.
* Fix unwound value of %r15 being off by 128 bytes.

ChangeLog:

* sysdeps/s390/s390-32/s390-mcount.S (_mcount):
Fix unwind.

5 years agoS390: Implement 64-bit __fentry__
Ilya Leoshkevich [Fri, 10 Aug 2018 07:07:44 +0000 (09:07 +0200)]
S390: Implement 64-bit __fentry__

* Since __fentry__ is almost the same as _mcount, reuse the code by
  #including it twice with different #defines around.
* Remove LA usages - they are needed in 31-bit mode to clear the top
  bit, but in 64-bit they appear to do nothing.
* Add CFI rule for the nonstandard return register. This rule applies
  to the current function (binutils generates a new CIE - see
  gas/dw2gencfi.c:select_cie_for_fde()), so it is not necessary to put
  __fentry__ into a new file.
* Fix CFI offset for %r14.
* Add CFI rule for %r0.
* Fix unwound value of %r15 being off by 244 bytes.
* Unwinding in __fentry__@plt does not work, no plan to fix it - it
  would require asking linker to generate CFI for return address in
  %r0.  From functional perspective keeping it broken is fine, since
  the callee did not have a chance to do anything yet.  From
  convenience perspective it would be possible to enhance GDB in the
  future to treat __fentry__@plt in a special way.
* Fix whitespace.
* Fix offsets in comments, which were copied from 32-bit code.
* 32-bit version will not be implemented, since it's not compatible
  with the corresponding PLT stubs: they assume %r12 points to GOT,
  which is not the case for gcc-emitted __fentry__ stub, which runs
  before the prolog.

This patch adds the runtime support in glibc for the -mfentry
gcc feature introduced in [1] and [2].

[1] https://gcc.gnu.org/ml/gcc-patches/2018-07/msg00784.html
[2] https://gcc.gnu.org/ml/gcc-patches/2018-07/msg00912.html

ChangeLog:

* sysdeps/s390/s390-64/Versions (__fentry__): Add.
* sysdeps/s390/s390-64/s390x-mcount.S: Move the common
code to s390x-mcount.h and #include it.
* sysdeps/s390/s390-64/s390x-mcount.h: New file.
* sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist
(__fentry__): Add.

5 years agoMove __fentry__ version definition to sysdeps/{i386,x86_64}
Ilya Leoshkevich [Fri, 10 Aug 2018 07:07:44 +0000 (09:07 +0200)]
Move __fentry__ version definition to sysdeps/{i386,x86_64}

__fentry__ symbol is currently not defined for other architectures.
Attempts to introduce it cause abicheck to fail, because it will be
available since 2.29 earliest, and not 2.13, which is the case for
Intel.  With the new code, abicheck passes for i686-linux-gnu,
x86_64-linux-gnu and x86_64-linux-gnu32 triples.

ChangeLog:

* stdlib/Versions: Remove __fentry__.
* sysdeps/i386/Versions: Add __fentry__.
* sysdeps/x86_64/Versions: Add __fentry__.

5 years agoS390: Test that lazy binding does not clobber R0
Ilya Leoshkevich [Fri, 10 Aug 2018 07:07:43 +0000 (09:07 +0200)]
S390: Test that lazy binding does not clobber R0

The following combinations need to be tested:
* 32- (g5, esa and zarch) and 64-bit
  * linux32 glibc/configure CC='gcc -m31 -march=g5'
  * linux32 glibc/configure CC='gcc -m31'
  * linux32 glibc/configure CC='gcc -m31 -mzarch'
* With and without VX:
  * glibc/configure libc_cv_asm_s390_vx=no
* With and without profiling (using LD_PROFILE)
* With and without pltexit (using LD_AUDIT)

ChangeLog:

* sysdeps/s390/Makefile: Register the new tests.
* sysdeps/s390/tst-dl-runtime-mod.S: New file.
* sysdeps/s390/tst-dl-runtime-profile-audit.c: New file.
* sysdeps/s390/tst-dl-runtime-profile-noaudit.c: New file.
* sysdeps/s390/tst-dl-runtime-resolve-audit.c: New file.
* sysdeps/s390/tst-dl-runtime-resolve-noaudit.c: New file.
* sysdeps/s390/tst-dl-runtime.c: New file.

5 years agoS390: Do not clobber R0 in 64-bit _dl_runtime_profile
Ilya Leoshkevich [Fri, 10 Aug 2018 07:07:43 +0000 (09:07 +0200)]
S390: Do not clobber R0 in 64-bit _dl_runtime_profile

Preparation for the usage of R0 by __fentry__.

ChangeLog:

* sysdeps/s390/s390-64/dl-trampoline.h (_dl_runtime_profile):
Do not clobber R0.

5 years agoS390: Do not clobber R0 in 64-bit _dl_runtime_resolve
Ilya Leoshkevich [Fri, 10 Aug 2018 07:07:43 +0000 (09:07 +0200)]
S390: Do not clobber R0 in 64-bit _dl_runtime_resolve

Preparation for the usage of R0 by __fentry__.

ChangeLog:

* sysdeps/s390/s390-64/dl-trampoline.h (_dl_runtime_resolve):
Do not clobber R0.

5 years agoS390: Do not clobber R0 in 32-bit _dl_runtime_profile
Ilya Leoshkevich [Fri, 10 Aug 2018 07:07:43 +0000 (09:07 +0200)]
S390: Do not clobber R0 in 32-bit _dl_runtime_profile

Preparation for the usage of R0 by __fentry__.

ChangeLog:

* sysdeps/s390/s390-32/dl-trampoline.h (_dl_runtime_profile):
Do not clobber R0.

5 years agoS390: Do not clobber R0 in 32-bit _dl_runtime_resolve
Ilya Leoshkevich [Fri, 10 Aug 2018 07:07:42 +0000 (09:07 +0200)]
S390: Do not clobber R0 in 32-bit _dl_runtime_resolve

Preparation for the usage of R0 by __fentry__.

ChangeLog:

* sysdeps/s390/s390-32/dl-trampoline.h (_dl_runtime_resolve):
Do not clobber R0.

5 years agoS390: Use symbolic offsets for stack variables in 64-bit _dl_runtime_profile
Ilya Leoshkevich [Fri, 10 Aug 2018 07:07:42 +0000 (09:07 +0200)]
S390: Use symbolic offsets for stack variables in 64-bit _dl_runtime_profile

Maintainability improvement.

ChangeLog:

* sysdeps/s390/s390-64/dl-trampoline.h (_dl_runtime_profile):
Use symbolic offsets for stack variables.

5 years agoS390: Use symbolic offsets for stack variables in 64-bit _dl_runtime_resolve
Ilya Leoshkevich [Fri, 10 Aug 2018 07:07:42 +0000 (09:07 +0200)]
S390: Use symbolic offsets for stack variables in 64-bit _dl_runtime_resolve

Maintainability improvement.

ChangeLog:

* sysdeps/s390/s390-64/dl-trampoline.h (_dl_runtime_resolve):
Use symbolic offsets for stack variables.

5 years agoS390: Use symbolic offsets for stack variables in 32-bit _dl_runtime_profile
Ilya Leoshkevich [Fri, 10 Aug 2018 07:07:41 +0000 (09:07 +0200)]
S390: Use symbolic offsets for stack variables in 32-bit _dl_runtime_profile

Maintainability improvement.

ChangeLog:

* sysdeps/s390/s390-32/dl-trampoline.h (_dl_runtime_profile):
Use symbolic offsets for stack variables.

5 years agoS390: Use symbolic offsets for stack variables in 32-bit _dl_runtime_resolve
Ilya Leoshkevich [Fri, 10 Aug 2018 07:07:41 +0000 (09:07 +0200)]
S390: Use symbolic offsets for stack variables in 32-bit _dl_runtime_resolve

Maintainability improvement.

ChangeLog:

* sysdeps/s390/s390-32/dl-trampoline.h (_dl_runtime_resolve):
Use symbolic offsets for stack variables.

5 years agoReplace gen-libm-test.pl with gen-libm-test.py.
Joseph Myers [Thu, 9 Aug 2018 15:34:12 +0000 (15:34 +0000)]
Replace gen-libm-test.pl with gen-libm-test.py.

Following the recent discussion of using Python instead of Perl and
Awk for glibc build / test, this patch replaces gen-libm-test.pl with
a new gen-libm-test.py script.  This script should work with all
Python versions supported by glibc (tested by hand with Python 2.7,
tested in the build system with Python 3.5; configure prefers Python 3
if available).

This script is designed to give identical output to gen-libm-test.pl
for ease of verification of the change, except for generated comments
referring to .py instead of .pl.  (That is, identical for actual
inputs passed to the script, not necessarily for all possible input;
for example, this version more precisely follows the C standard syntax
for floating-point constants when deciding when to add LIT macro
calls.)  In one place a comment notes that the generation of
NON_FINITE flags is replicating a bug in the Perl script to assist in
such comparisons (with the expectation that this bug can then be
separately fixed in the Python script later).

Tested for x86_64, including comparison of generated files (and hand
testing of the case of generating a sorted libm-test-ulps file, which
isn't covered by normal "make check").

I'd expect to follow this up by extending the new script to produce
the ulps tables for the manual as well (replacing
manual/libm-err-tab.pl, so that then we just have one ulps file
parser) - at which point the manual build would depend on both Perl
and Python (eliminating the Perl dependency would require someone to
rewrite summary.pl in Python, and that would only eliminate the
*direct* Perl dependency; current makeinfo is written in Perl so there
would still be an indirect dependency).

I think install.texi is more or less equally out-of-date regarding
Perl and Python uses before and after this patch, so I don't think
this patch depends on my patch
<https://sourceware.org/ml/libc-alpha/2018-08/msg00133.html> to update
install.texi regarding such uses (pending review).

* math/gen-libm-test.py: New file.
* math/gen-libm-test.pl: Remove.
* math/Makefile [$(PERL) != no]: Change condition to [PYTHON].
($(objpfx)libm-test-ulps.h): Use gen-libm-test.py instead of
gen-libm-test.pl.
($(libm-test-c-noauto-obj)): Likewise.
($(libm-test-c-auto-obj)): Likewise.
($(libm-test-c-narrow-obj)): Likewise.
(regen-ulps): Likewise.
* math/README.libm-test: Update references to gen-libm-test.pl.
* math/libm-test-driver.c (struct test_fj_f_data): Update comment
referencing gen-libm-test.pl.
* math/libm-test-nexttoward.inc (nexttoward_test_data): Likewise.
* math/libm-test-support.c: Likewise.
* math/libm-test-support.h: Likewise.
* sysdeps/generic/libm-test-ulps: Likewise.

5 years agohurd: Avoid PLTs for __pthread_get/setspecific
Samuel Thibault [Wed, 8 Aug 2018 23:26:19 +0000 (01:26 +0200)]
hurd: Avoid PLTs for __pthread_get/setspecific

* sysdeps/htl/pthreadP.h [IS_IN (libpthread)] (__pthread_getspecific,
__pthread_setspecific): Add hidden proto.
* sysdeps/htl/pt-getspecific.c (__pthread_getspecific): Add hidden def.
* sysdeps/htl/pt-setspecific.c (__pthread_setspecific): Add hidden def.

5 years ago[aarch64] Fix value of MIN_PAGE_SIZE for testing
Siddhesh Poyarekar [Wed, 8 Aug 2018 15:46:07 +0000 (21:16 +0530)]
[aarch64] Fix value of MIN_PAGE_SIZE for testing

MIN_PAGE_SIZE is normally set to 4096 but for testing it can be set to
16 so that it exercises the page crossing code for every misaligned
access.  The value was set to 15, which is obviously wrong, so fixed
as obvious and tested.

* sysdeps/aarch64/strlen.S [TEST_PAGE_CROSS](MIN_PAGE_SIZE):
Fix value.

5 years agoMove comment from libm-test-nextdown.inc to libm-test-nexttoward.inc.
Joseph Myers [Wed, 8 Aug 2018 16:16:59 +0000 (16:16 +0000)]
Move comment from libm-test-nextdown.inc to libm-test-nexttoward.inc.

When libm tests were split into separate per-function .inc files, a
comment relating to the nexttoward tests ended up at the end of
libm-test-nextdown.inc (because the split was based on starting each
function's tests with the <function>_test_data definition, which
failed to allow for comments before such definitions).  This patch
moves that comment to the correct location.

Tested for x86_64.

* math/libm-test-nextdown.inc (do_test): Move comment to ....
* math/libm-test-nexttoward.inc (nexttoward_test_data): ... here.

5 years agohurd: Add missing symbols for proper libc_get/setspecific
Samuel Thibault [Tue, 7 Aug 2018 23:55:04 +0000 (01:55 +0200)]
hurd: Add missing symbols for proper libc_get/setspecific

* htl/Versions (__pthread_getspecific, __pthread_setspecific): Add
symbols.

5 years agobenchtests: Clean up the alloc_bufs
Siddhesh Poyarekar [Tue, 7 Aug 2018 19:14:56 +0000 (00:44 +0530)]
benchtests: Clean up the alloc_bufs

Drop realloc_bufs in favour of making alloc_bufs transparently
reallocate the buffers if it had allocated before.  Also consolidate
computation of buffer lengths so that they don't get repeated on every
reallocation.

* benchtests/bench-string.h (buf1_size, buf2_size): New
variables.
(init_sizes): New function.
(test_init): Use it.
(alloc_buf, exit_error): New functions.
(alloc_bufs): Use ALLOC_BUF.
(realloc_bufs): Remove.
* benchtests/bench-memcmp.c (do_test): Adjust.
* benchtests/bench-memset-large.c (do_test): Likewise.
* benchtests/bench-memset-walk.c (do_test): Likewise.
* benchtests/bench-memset.c (do_test): Likewise.
* benchtests/bench-strncmp.c (do_test): Likewise.

5 years agoRISC-V: Don't use ps_get_thread_area in libthread_db (bug 23402)
Andreas Schwab [Thu, 12 Jul 2018 07:24:36 +0000 (09:24 +0200)]
RISC-V: Don't use ps_get_thread_area in libthread_db (bug 23402)

Since RISC-V stores the thread pointer in a general register libthread_db
can just ask the debugger for the register contents instead of trying to
call ps_get_thread_area.  This enables thread debugging in gdb.

* sysdeps/riscv/nptl/tls.h (DB_THREAD_SELF): Use REGISTER instead
of CONST_THREAD_AREA.

5 years agox86: Move STATE_SAVE_OFFSET/STATE_SAVE_MASK to sysdep.h
H.J. Lu [Mon, 6 Aug 2018 13:25:28 +0000 (06:25 -0700)]
x86: Move STATE_SAVE_OFFSET/STATE_SAVE_MASK to sysdep.h

Move STATE_SAVE_OFFSET and STATE_SAVE_MASK to sysdep.h to make
sysdeps/x86/cpu-features.h a C header file.

* sysdeps/x86/cpu-features.h (STATE_SAVE_OFFSET): Removed.
(STATE_SAVE_MASK): Likewise.
Don't check __ASSEMBLER__ to include <cpu-features-offsets.h>.
* sysdeps/x86/sysdep.h (STATE_SAVE_OFFSET): New.
(STATE_SAVE_MASK): Likewise.
* sysdeps/x86_64/dl-trampoline.S: Include <cpu-features-offsets.h>
instead of <cpu-features.h>.

5 years agoImprove ChangeLog message.
DJ Delorie [Fri, 3 Aug 2018 23:24:14 +0000 (19:24 -0400)]
Improve ChangeLog message.

5 years agoRegen RISC-V rvd ULPs
DJ Delorie [Fri, 3 Aug 2018 17:52:01 +0000 (13:52 -0400)]
Regen RISC-V rvd ULPs

* sysdeps/riscv/rv64/rvd/libm-test-ulps: Update.

Note: I regen'd these from scratch, but I'm only committing the
increases, as I only tested on hardware.  There were a few 2->1
decreases that I omitted, possibly "for now".

5 years agoRISC-V: Fix rounding save/restore bug.
DJ Delorie [Fri, 3 Aug 2018 17:43:31 +0000 (13:43 -0400)]
RISC-V: Fix rounding save/restore bug.

* sysdeps/riscv/rvf/math_private.h (libc_feholdexcept_setround_riscv):
Fix rounding save-restore bug.

Fixes about a hundred off-by-ULP failures in the math testsuite.

5 years agoConsistently terminate libm-test-*.inc TEST lines with commas.
Joseph Myers [Fri, 3 Aug 2018 16:56:02 +0000 (16:56 +0000)]
Consistently terminate libm-test-*.inc TEST lines with commas.

Some TEST_* lines in libm-test-*.inc end with semicolons not commas.
This works at present because gen-libm-test.pl ignores whatever comes
after the TEST_* call, but is logically wrong (since the TEST_* calls
generate array elements, not statements) and the Python replacement
for gen-libm-test.pl that I'm working on is stricter about the syntax
here.  This patch fixes the lines in question to use commas like most
such lines already do.

Tested for x86_64.

* math/libm-test-ilogb.inc (ilogb_test_data): Use ',' not ';'
after TEST_* calls.
* math/libm-test-llogb.inc (llogb_test_data): Likewise.
* math/libm-test-logb.inc (logb_test_data): Likewise.

5 years agoSimplify and speedup strstr/strcasestr first match
Wilco Dijkstra [Fri, 3 Aug 2018 16:24:12 +0000 (17:24 +0100)]
Simplify and speedup strstr/strcasestr first match

Looking at the benchtests, both strstr and strcasestr spend a lot of time
in a slow initialization loop handling one character per iteration.
This can be simplified and use the much faster strlen/strnlen/strchr/memcmp.
Read ahead a few cachelines to reduce the number of strnlen calls, which
improves performance by ~3-4%.  This patch improves the time taken for the
full strstr benchtest by >40%.

* string/strcasestr.c (STRCASESTR): Simplify and speedup first match.
* string/strstr.c (AVAILABLE): Likewise.

5 years agox86: Don't include <init-arch.h> in assembly codes
H.J. Lu [Fri, 3 Aug 2018 15:04:49 +0000 (08:04 -0700)]
x86: Don't include <init-arch.h> in assembly codes

There is no need to include <init-arch.h> in assembly codes since all
x86 IFUNC selector functions are written in C.  Tested on i686 and
x86-64.  There is no code change in libc.so, ld.so and libmvec.so.

* sysdeps/i386/i686/multiarch/bzero-ia32.S: Don't include
<init-arch.h>.
* sysdeps/x86_64/fpu/multiarch/svml_d_sin8_core-avx2.S: Likewise.
* sysdeps/x86_64/fpu/multiarch/svml_s_expf16_core-avx2.S: Likewise.
* sysdeps/x86_64/multiarch/memset-sse2-unaligned-erms.S: Likewise.

5 years agoUpdate be translations.
Carlos O'Donell [Fri, 3 Aug 2018 14:13:47 +0000 (10:13 -0400)]
Update be translations.