Commit Graph

23190 Commits

Author SHA1 Message Date
Stefan Liebler 26ea876087 S390: Refactor strrchr ifunc handling.
The ifunc handling for strrchr is adjusted in order to omit ifunc
variants if those will never be used as the minimum architecture level
already supports newer CPUs by default.
Glibc internal calls will then also use the "newer" ifunc variant.

ChangeLog:

	* sysdeps/s390/multiarch/Makefile
	(sysdep_routines): Remove strrchr variants.
	* sysdeps/s390/Makefile (sysdep_routines): Add strrchr variants.
	* sysdeps/s390/multiarch/ifunc-impl-list.c
	(__libc_ifunc_impl_list): Refactor ifunc handling for strrchr.
	* sysdeps/s390/multiarch/strrchr-c.c: Move to ...
	* sysdeps/s390/strrchr-c.c: ... here and adjust ifunc handling.
	* sysdeps/s390/multiarch/strrchr-vx.S: Move to ...
	* sysdeps/s390/strrchr-vx.S: ... here and adjust ifunc handling.
	* sysdeps/s390/multiarch/strrchr.c: Move to ...
	* sysdeps/s390/strrchr.c: ... here and adjust ifunc handling.
	* sysdeps/s390/ifunc-strrchr.h: New file.
2018-12-18 13:57:14 +01:00
Stefan Liebler a1361e6561 S390: Refactor strchrnul ifunc handling.
The ifunc handling for strchrnul is adjusted in order to omit ifunc
variants if those will never be used as the minimum architecture level
already supports newer CPUs by default.

ChangeLog:

	* sysdeps/s390/multiarch/Makefile
	(sysdep_routines): Remove strchrnul variants.
	* sysdeps/s390/Makefile (sysdep_routines): Add strchrnul variants.
	* sysdeps/s390/multiarch/ifunc-impl-list.c
	(__libc_ifunc_impl_list): Refactor ifunc handling for strchrnul.
	* sysdeps/s390/multiarch/strchrnul-c.c: Move to ...
	* sysdeps/s390/strchrnul-c.c: ... here and adjust ifunc handling.
	* sysdeps/s390/multiarch/strchrnul-vx.S: Move to ...
	* sysdeps/s390/strchrnul-vx.S: ... here and adjust ifunc handling.
	* sysdeps/s390/multiarch/strchrnul.c: Move to ...
	* sysdeps/s390/strchrnul.c: ... here and adjust ifunc handling.
	* sysdeps/s390/ifunc-strchrnul.h: New file.
2018-12-18 13:57:14 +01:00
Stefan Liebler 32f12653d4 S390: Refactor strchr ifunc handling.
The ifunc handling for strchr is adjusted in order to omit ifunc
variants if those will never be used as the minimum architecture level
already supports newer CPUs by default.
Glibc internal calls will then also use the "newer" ifunc variant.

ChangeLog:

	* sysdeps/s390/multiarch/Makefile
	(sysdep_routines): Remove strchr variants.
	* sysdeps/s390/Makefile (sysdep_routines): Add strchr variants.
	* sysdeps/s390/multiarch/ifunc-impl-list.c
	(__libc_ifunc_impl_list): Refactor ifunc handling for strchr.
	* sysdeps/s390/multiarch/strchr-c.c: Move to ...
	* sysdeps/s390/strchr-c.c: ... here and adjust ifunc handling.
	* sysdeps/s390/multiarch/strchr-vx.S: Move to ...
	* sysdeps/s390/strchr-vx.S: ... here and adjust ifunc handling.
	* sysdeps/s390/multiarch/strchr.c: Move to ...
	* sysdeps/s390/strchr.c: ... here and adjust ifunc handling.
	* sysdeps/s390/ifunc-strchr.h: New file.
2018-12-18 13:57:14 +01:00
Stefan Liebler 316b884219 S390: Refactor strncmp ifunc handling.
The ifunc handling for strncmp is adjusted in order to omit ifunc
variants if those will never be used as the minimum architecture level
already supports newer CPUs by default.
Glibc internal calls will then also use the "newer" ifunc variant.

ChangeLog:

	* sysdeps/s390/multiarch/Makefile
	(sysdep_routines): Remove strncmp variants.
	* sysdeps/s390/Makefile (sysdep_routines): Add strncmp variants.
	* sysdeps/s390/multiarch/ifunc-impl-list.c
	(__libc_ifunc_impl_list): Refactor ifunc handling for strncmp.
	* sysdeps/s390/multiarch/strncmp-c.c: Move to ...
	* sysdeps/s390/strncmp-c.c: ... here and adjust ifunc handling.
	* sysdeps/s390/multiarch/strncmp-vx.S: Move to ...
	* sysdeps/s390/strncmp-vx.S: ... here and adjust ifunc handling.
	* sysdeps/s390/multiarch/strncmp.c: Move to ...
	* sysdeps/s390/strncmp.c: ... here and adjust ifunc handling.
	* sysdeps/s390/ifunc-strncmp.h: New file.
2018-12-18 13:57:13 +01:00
Stefan Liebler cdab85fe33 S390: Refactor strcmp ifunc handling.
The ifunc handling for strcmp is adjusted in order to omit ifunc
variants if those will never be used as the minimum architecture level
already supports newer CPUs by default.
Glibc internal calls will then also use the "newer" ifunc variant.

Note: The fallback s390-32/s390-64 ifunc variants with clst instruction
are now moved to the unified strcmp-z900.S file which can be used for
31/64bit. The s390-32/s390-64 files multiarch/strcmp.c and strcmp.S
are deleted.

ChangeLog:

	* sysdeps/s390/multiarch/Makefile
	(sysdep_routines): Remove strcmp variants.
	* sysdeps/s390/Makefile (sysdep_routines): Add strcmp variants.
	* sysdeps/s390/multiarch/ifunc-impl-list.c
	(__libc_ifunc_impl_list): Refactor ifunc handling for strcmp.
	* sysdeps/s390/multiarch/strcmp-vx.S: Move to ...
	* sysdeps/s390/strcmp-vx.S: ... here and adjust ifunc handling.
	* sysdeps/s390/multiarch/strcmp.c: Move to ...
	* sysdeps/s390/strcmp.c: ... here and adjust ifunc handling.
	* sysdeps/s390/ifunc-strcmp.h: New file.
	* sysdeps/s390/s390-64/strcmp.S: Move to ...
	* sysdeps/s390/strcmp-z900.S: ... here and adjust to be usable
	for 31/64bit and ifunc handling.
	* sysdeps/s390/s390-32/multiarch/strcmp.c: Delete file.
	* sysdeps/s390/s390-64/multiarch/strcmp.c: Likewise.
	* sysdeps/s390/s390-32/strcmp.S: Likewise.
2018-12-18 13:57:13 +01:00
Stefan Liebler b935335155 S390: Refactor strncat ifunc handling.
The ifunc handling for strncat is adjusted in order to omit ifunc
variants if those will never be used as the minimum architecture level
already supports newer CPUs by default.
Glibc internal calls will then also use the "newer" ifunc variant.

ChangeLog:

	* sysdeps/s390/multiarch/Makefile
	(sysdep_routines): Remove strncat variants.
	* sysdeps/s390/Makefile (sysdep_routines): Add strncat variants.
	* sysdeps/s390/multiarch/ifunc-impl-list.c
	(__libc_ifunc_impl_list): Refactor ifunc handling for strncat.
	* sysdeps/s390/multiarch/strncat-c.c: Move to ...
	* sysdeps/s390/strncat-c.c: ... here and adjust ifunc handling.
	* sysdeps/s390/multiarch/strncat-vx.S: Move to ...
	* sysdeps/s390/strncat-vx.S: ... here and adjust ifunc handling.
	* sysdeps/s390/multiarch/strncat.c: Move to ...
	* sysdeps/s390/strncat.c: ... here and adjust ifunc handling.
	* sysdeps/s390/ifunc-strncat.h: New file.
2018-12-18 13:57:12 +01:00
Stefan Liebler 8e5a0afbbf S390: Refactor strcat ifunc handling.
The ifunc handling for strcat is adjusted in order to omit ifunc
variants if those will never be used as the minimum architecture level
already supports newer CPUs by default.
Glibc internal calls will then also use the "newer" ifunc variant.

ChangeLog:

	* sysdeps/s390/multiarch/Makefile
	(sysdep_routines): Remove strcat variants.
	* sysdeps/s390/Makefile (sysdep_routines): Add strcat variants.
	* sysdeps/s390/multiarch/ifunc-impl-list.c
	(__libc_ifunc_impl_list): Refactor ifunc handling for strcat.
	* sysdeps/s390/multiarch/strcat-c.c: Move to ...
	* sysdeps/s390/strcat-c.c: ... here and adjust ifunc handling.
	* sysdeps/s390/multiarch/strcat-vx.S: Move to ...
	* sysdeps/s390/strcat-vx.S: ... here and adjust ifunc handling.
	* sysdeps/s390/multiarch/strcat.c: Move to ...
	* sysdeps/s390/strcat.c: ... here and adjust ifunc handling.
	* sysdeps/s390/ifunc-strcat.h: New file.
2018-12-18 13:57:12 +01:00
Stefan Liebler 25218822bd S390: Refactor stpncpy ifunc handling.
The ifunc handling for stpncpy is adjusted in order to omit ifunc
variants if those will never be used as the minimum architecture level
already supports newer CPUs by default.
Glibc internal calls will then also use the "newer" ifunc variant.

ChangeLog:

	* sysdeps/s390/multiarch/Makefile
	(sysdep_routines): Remove stpncpy variants.
	* sysdeps/s390/Makefile (sysdep_routines): Add stpncpy variants.
	* sysdeps/s390/multiarch/ifunc-impl-list.c
	(__libc_ifunc_impl_list): Refactor ifunc handling for stpncpy.
	* sysdeps/s390/multiarch/stpncpy-c.c: Move to ...
	* sysdeps/s390/stpncpy-c.c: ... here and adjust ifunc handling.
	* sysdeps/s390/multiarch/stpncpy-vx.S: Move to ...
	* sysdeps/s390/stpncpy-vx.S: ... here and adjust ifunc handling.
	* sysdeps/s390/multiarch/stpncpy.c: Move to ...
	* sysdeps/s390/stpncpy.c: ... here and adjust ifunc handling.
	* sysdeps/s390/ifunc-stpncpy.h: New file.
2018-12-18 13:57:11 +01:00
Stefan Liebler d1bdbf3809 S390: Refactor strncpy ifunc handling.
The ifunc handling for strncpy is adjusted in order to omit ifunc
variants if those will never be used as the minimum architecture level
already supports newer CPUs by default.
Glibc internal calls will then also use the "newer" ifunc variant.

Note: The fallback s390-32/s390-64 ifunc variants are now moved to
the strncpy-z900.S files. The s390-32/s390-64 files multiarch/strncpy.c
and strncpy.S are deleted.

ChangeLog:

	* sysdeps/s390/multiarch/Makefile
	(sysdep_routines): Remove strncpy variants.
	* sysdeps/s390/Makefile (sysdep_routines): Add strncpy variants.
	* sysdeps/s390/multiarch/ifunc-impl-list.c
	(__libc_ifunc_impl_list): Refactor ifunc handling for strncpy.
	* sysdeps/s390/multiarch/strncpy-vx.S: Move to ...
	* sysdeps/s390/strncpy-vx.S: ... here and adjust ifunc handling.
	* sysdeps/s390/multiarch/strncpy.c: Move to ...
	* sysdeps/s390/strncpy.c: ... here and adjust ifunc handling.
	* sysdeps/s390/ifunc-strncpy.h: New file.
	* sysdeps/s390/s390-64/strncpy.S: Move to ...
	* sysdeps/s390/s390-64/strncpy-z900.S: ... here
	and adjust ifunc handling.
	* sysdeps/s390/s390-32/strncpy.S: Move to ...
	* sysdeps/s390/s390-32/strncpy-z900.S: ... here
	and adjust ifunc handling.
	* sysdeps/s390/s390-32/multiarch/strncpy.c: Delete file.
	* sysdeps/s390/s390-64/multiarch/strncpy.c: Likewise.
2018-12-18 13:57:11 +01:00
Stefan Liebler 970449311d S390: Refactor stpcpy ifunc handling.
The ifunc handling for stpcpy is adjusted in order to omit ifunc
variants if those will never be used as the minimum architecture level
already supports newer CPUs by default.
Glibc internal calls will then also use the "newer" ifunc variant.

ChangeLog:

	* sysdeps/s390/multiarch/Makefile
	(sysdep_routines): Remove stpcpy variants.
	* sysdeps/s390/Makefile (sysdep_routines): Add stpcpy variants.
	* sysdeps/s390/multiarch/ifunc-impl-list.c
	(__libc_ifunc_impl_list): Refactor ifunc handling for stpcpy.
	* sysdeps/s390/multiarch/stpcpy-c.c: Move to ...
	* sysdeps/s390/stpcpy-c.c: ... here and adjust ifunc handling.
	* sysdeps/s390/multiarch/stpcpy-vx.S: Move to ...
	* sysdeps/s390/stpcpy-vx.S: ... here and adjust ifunc handling.
	* sysdeps/s390/multiarch/stpcpy.c: Move to ...
	* sysdeps/s390/stpcpy.c: ... here and adjust ifunc handling.
	* sysdeps/s390/ifunc-stpcpy.h: New file.
2018-12-18 13:57:11 +01:00
Stefan Liebler 914a4e0557 S390: Refactor strcpy ifunc handling.
The ifunc handling for strcpy is adjusted in order to omit ifunc
variants if those will never be used as the minimum architecture level
already supports newer CPUs by default.
Glibc internal calls will then also use the "newer" ifunc variant.

Note: The fallback s390-32/s390-64 ifunc variants with mvst instruction
are now moved to the unified strcpy-z900.S file which can be used for
31/64bit. The s390-32/s390-64 files multiarch/strcpy.c and strcpy.S
are deleted.

ChangeLog:

	* sysdeps/s390/multiarch/Makefile
	(sysdep_routines): Remove strcpy variants.
	* sysdeps/s390/Makefile (sysdep_routines): Add strcpy variants.
	* sysdeps/s390/multiarch/ifunc-impl-list.c
	(__libc_ifunc_impl_list): Refactor ifunc handling for strcpy.
	* sysdeps/s390/multiarch/strcpy-vx.S: Move to ...
	* sysdeps/s390/strcpy-vx.S: ... here and adjust ifunc handling.
	* sysdeps/s390/multiarch/strcpy.c: Move to ...
	* sysdeps/s390/strcpy.c: ... here and adjust ifunc handling.
	* sysdeps/s390/ifunc-strcpy.h: New file.
	* sysdeps/s390/s390-64/strcpy.S: Move to ...
	* sysdeps/s390/strcpy-z900.S: ... here and adjust to be usable
	for 31/64bit and ifunc handling.
	* sysdeps/s390/s390-32/multiarch/strcpy.c: Delete file.
	* sysdeps/s390/s390-64/multiarch/strcpy.c: Likewise.
	* sysdeps/s390/s390-32/strcpy.S: Likewise.
2018-12-18 13:57:10 +01:00
Stefan Liebler de10e44dda S390: Refactor strnlen ifunc handling.
The ifunc handling for strnlen is adjusted in order to omit ifunc
variants if those will never be used as the minimum architecture level
already supports newer CPUs by default.
Glibc internal calls will then also use the "newer" ifunc variant.

ChangeLog:

	* sysdeps/s390/multiarch/Makefile
	(sysdep_routines): Remove strnlen variants.
	* sysdeps/s390/Makefile (sysdep_routines): Add strnlen variants.
	* sysdeps/s390/multiarch/ifunc-impl-list.c
	(__libc_ifunc_impl_list): Refactor ifunc handling for strnlen.
	* sysdeps/s390/multiarch/strnlen-c.c: Move to ...
	* sysdeps/s390/strnlen-c.c: ... here and adjust ifunc handling.
	* sysdeps/s390/multiarch/strnlen-vx.S: Move to ...
	* sysdeps/s390/strnlen-vx.S: ... here and adjust ifunc handling.
	* sysdeps/s390/multiarch/strnlen.c: Move to ...
	* sysdeps/s390/strnlen.c: ... here and adjust ifunc handling.
	* sysdeps/s390/ifunc-strnlen.h: New file.
2018-12-18 13:57:10 +01:00
Stefan Liebler ff3ca3743a S390: Refactor strlen ifunc handling.
The ifunc handling for strlen is adjusted in order to omit ifunc
variants if those will never be used as the minimum architecture level
already supports newer CPUs by default.
Glibc internal calls will then also use the "newer" ifunc variant.

ChangeLog:

	* sysdeps/s390/multiarch/Makefile
	(sysdep_routines): Remove strlen variants.
	* sysdeps/s390/Makefile (sysdep_routines): Add strlen variants.
	* sysdeps/s390/multiarch/ifunc-impl-list.c
	(__libc_ifunc_impl_list): Refactor ifunc handling for strlen.
	* sysdeps/s390/multiarch/strlen-c.c: Move to ...
	* sysdeps/s390/strlen-c.c: ... here and adjust ifunc handling.
	* sysdeps/s390/multiarch/strlen-vx.S: Move to ...
	* sysdeps/s390/strlen-vx.S: ... here and adjust ifunc handling.
	* sysdeps/s390/multiarch/strlen.c: Move to ...
	* sysdeps/s390/strlen.c: ... here and adjust ifunc handling.
	* sysdeps/s390/ifunc-strlen.h: New file.
2018-12-18 13:57:10 +01:00
Stefan Liebler d2c4c403fe S390: Add z13 memmem ifunc variant.
The new vector variant of memmem is using the common code
implementation, but instead of calling the default
mem* functions, the vector variants are called.

ChangeLog:

	* sysdeps/s390/Makefile (sysdep_routines): Add memmem variants.
	* sysdeps/s390/multiarch/ifunc-impl-list.c
	(__libc_ifunc_impl_list): Add ifunc variants for memmem.
	* sysdeps/s390/ifunc-memmem.h: New file.
	* sysdeps/s390/memmem.c: Likewise.
	* sysdeps/s390/memmem-c.c: Likewise.
	* sysdeps/s390/memmem-vx.c: Likewise.
2018-12-18 13:57:09 +01:00
Stefan Liebler 8c25dddd2e S390: Add z13 strstr ifunc variant.
The new vector variant of strstr is using the common code
implementation, but instead of calling the default
str* / mem* functions, the vector variants are called.

ChangeLog:

	* sysdeps/s390/Makefile (sysdep_routines): Add strstr variants.
	* sysdeps/s390/multiarch/ifunc-impl-list.c
	(__libc_ifunc_impl_list): Add ifunc variants for strstr.
	* sysdeps/s390/ifunc-strstr.h: New file.
	* sysdeps/s390/strstr.c: Likewise.
	* sysdeps/s390/strstr-c.c: Likewise.
	* sysdeps/s390/strstr-vx.c: Likewise.
2018-12-18 13:57:09 +01:00
Stefan Liebler cdd927d98c S390: Add z13 memmove ifunc variant.
This patch introduces a z13 specific ifunc variant for memmove.
As the common code implementation, it checks if we can copy from
the beginning to the end - with z196 memcpy implementation - or
if we have to copy from the end to the beginning.
The latter case is done by using vector load/store instructions.

If vector instructions are not available, the common-code is
used as fallback.  Therefore it is implemented in memmove-c with
a different name.
Furthermore the ifunc logic decides if we need the common-code
implementation at all.  If vector instructions are supported
due to the minimum architecture level set we can skip the
common-code ifunc variant.

ChangeLog:

	* sysdeps/s390/Makefile (sysdep_routines): Add memmove-c.
	* sysdeps/s390/ifunc-memcpy.h (HAVE_MEMMOVE_IFUNC,
	HAVE_MEMMOVE_IFUNC_AND_VX_SUPPORT, MEMMOVE_DEFAULT,
	HAVE_MEMMOVE_C, MEMMOVE_C,  HAVE_MEMMOVE_Z13, MEMMOVE_Z13):
	New defines.
	* sysdeps/s390/memcpy-z900.S: Add z13 memmove implementation.
	* sysdeps/s390/memmove-c.c: New file.
	* sysdeps/s390/memmove.c: Likewise.
	* sysdeps/s390/multiarch/ifunc-impl-list.c
	(__libc_ifunc_impl_list): Add ifunc variants for memmove.
2018-12-18 13:57:08 +01:00
Stefan Liebler 2ee1bc57ab S390: Add configure check to detect z13 as mininum architecture level set.
Add a configure check for z13 in the same way as done for z196.

ChangeLog:

	* config.h.in (HAVE_S390_MIN_Z13_ZARCH_ASM_SUPPORT): New undefine.
	* sysdeps/s390/configure.ac: Add check for z13 support.
	* sysdeps/s390/configure: Regenerated.
2018-12-18 13:57:08 +01:00
Stefan Liebler d097d97626 S390: Use memcpy for forward cases in memmove.
The s390/s390x memcpy implementations are safe to be
used by memmove.  Starting with this commit, memmove is
using memcpy for the forward cases on s390.

ChangeLog:

	* sysdeps/s390/memcopy.h: New file.
2018-12-18 13:57:07 +01:00
Stefan Liebler e099aab060 S390: Remove s390 specific implementation of bcopy.
Nowadays gcc is automatically replacing a call to bcopy
with a call to memmove.  Thus only old binaries will call
the s390 specific bcopy implementation.

The s390 specific implementation is using an own
implementation for memcpy in the forward case and is
relying on memmove in the backward case.

After removing the s390 specific bcopy, the common code
bcopy is used.  It just performs a tail call to memmove.

ChangeLog:
	* sysdeps/s390/s390-32/bcopy.S: Remove.
	* sysdeps/s390/s390-64/bcopy.S: Likewise.
2018-12-18 13:57:07 +01:00
Stefan Liebler 18eb862d45 S390: Refactor memcpy/mempcpy ifunc handling.
This patch moves all ifunc variants for memcpy/mempcpy
to sysdeps/s390/memcpy-z900.S. The configure-check/preprocessor logic
in sysdeps/s390/ifunc-memcpy.h decides if ifunc is needed at all
and which ifunc variants should be available.
E.g. if the compiler/assembler already supports z196 by default,
the older ifunc variants are not included.
If we only need the newest ifunc variant,
then we can skip ifunc at all.

Therefore the ifunc-resolvers and __libc_ifunc_impl_list are adjusted
in order to handle only the available ifunc variants.

ChangeLog:

	* sysdeps/s390/ifunc-memcpy.h: New File.
	* sysdeps/s390/memcpy.S: Move to ...
	* sysdeps/s390/memcpy-z900.S ... here.
	Move implementations from memcpy-s390x.s to here.
	* sysdeps/s390/multiarch/memcpy-s390x.S: Delete File.
	* sysdeps/s390/multiarch/Makefile (sysdep_routines):
	Remove memcpy/mempcpy variants.
	* sysdeps/s390/Makefile (sysdep_routines):
	Add memcpy/mempcpy variants.
	* sysdeps/s390/multiarch/ifunc-impl-list.c
	(__libc_ifunc_impl_list): Adjust ifunc variants for
	memcpy and mempcpy.
	* sysdeps/s390/multiarch/memcpy.c: Move ifunc resolver
	to ...
	* sysdeps/s390/memcpy.c: ... here.
	Adjust ifunc variants for memcpy.
	* sysdeps/s390/multiarch/mempcpy.c: Move to ...
	* sysdeps/s390/mempcpy.c: ... here.
	Adjust ifunc variants for mempcpy.
	* sysdeps/s390/mempcpy.S: Delete file.
2018-12-18 13:57:06 +01:00
Stefan Liebler df3eb8de31 S390: Unify 31/64bit memcpy.
The implementation of memcpy/mempcpy for s390-32 (31bit)
and s390-64 (64bit) is nearly the same.
This patch unifies it for maintability reasons.

__mem[p]cpy_z10 and __mem[p]cpy_z196 differs between 31 and 64bit:
-31bit needs .machinemode "zarch_nohighgprs" and llgfr   %r4,%r4
-lr vs lgr; lgr can be also used on 31bit as this ifunc variant
is only called if we are on a zarch machine.

__mem[p]cpy_default differs between 31 and 64bit:
-Some 31bit vs 64bit instructions (e.g. ltr vs ltgr.
Solved with 31/64 specific instruction macros).
-The address of mvc instruction is setup in different ways
(larl vs bras). Solved with #if defined __s390x__.

__memcpy_mvcle differs between 31 and 64bit:
-lr vs lgr; ahi vs aghi;
Solved with 31/64bit specific instruction macros.

Otherwise 31/64bit implementation has the same structure of the code.

ChangeLog:

	* sysdeps/s390/s390-64/memcpy.S: Move to ...
	* sysdeps/s390/memcpy.S: ... here.
	Adjust to be usable for 31/64bit.
	* sysdeps/s390/s390-32/memcpy.S: Delete File.
	* sysdeps/s390/multiarch/Makefile (sysdep_routines): Add memcpy.
	* sysdeps/s390/s390-32/multiarch/Makefile: Delete file.
	* sysdeps/s390/s390-64/multiarch/Makefile: Likewise.
	* sysdeps/s390/s390-64/multiarch/memcpy-s390x.S: Move to ...
	* sysdeps/s390/multiarch/memcpy-s390x.S: ... here.
	Adjust to be usable for 31/64bit.
	* sysdeps/s390/s390-32/multiarch/memcpy-s390.S: Delete File.
	* sysdeps/s390/s390-64/multiarch/memcpy.c: Move to ...
	* sysdeps/s390/multiarch/memcpy.c: ... here.
	* sysdeps/s390/s390-32/multiarch/memcpy.c: Delete File.
2018-12-18 13:57:06 +01:00
Stefan Liebler b7e024a838 S390: Refactor memcmp ifunc handling.
This patch moves all ifunc variants for memcmp
to sysdeps/s390/memcmp-z900.S. The configure-check/preprocessor logic
in sysdeps/s390/ifunc-memcmp.h decides if ifunc is needed at all
and which ifunc variants should be available.
E.g. if the compiler/assembler already supports z196 by default,
the older ifunc variants are not included.
If we only need the newest ifunc variant,
then we can skip ifunc at all.

Therefore the ifunc-resolvers and __libc_ifunc_impl_list are adjusted
in order to handle only the available ifunc variants.

ChangeLog:

	* sysdeps/s390/ifunc-memcmp.h: New File.
	* sysdeps/s390/memcmp.S: Move to ...
	* sysdeps/s390/memcmp-z900.S ... here.
	Move implementations from memcmp-s390x.s to here.
	* sysdeps/s390/multiarch/memcmp-s390x.S: Delete File.
	* sysdeps/s390/multiarch/Makefile (sysdep_routines):
	Remove memcmp variants.
	* sysdeps/s390/Makefile (sysdep_routines):
	Add memcmp variants.
	* sysdeps/s390/multiarch/ifunc-impl-list.c
	(__libc_ifunc_impl_list): Adjust ifunc variants for
	memcmp.
	* sysdeps/s390/multiarch/memcmp.c: Move ifunc resolver
	to ...
	* sysdeps/s390/memcmp.c: ... here.
	Adjust ifunc variants for memcmp.
2018-12-18 13:57:05 +01:00
Stefan Liebler 6c6b8c7470 S390: Unify 31/64bit memcmp.
The implementation of memcmp for s390-32 (31bit) and
s390-64 (64bit) is nearly the same.
This patch unifies it for maintability reasons.

__memcmp_z10 and __memcmp_z196 differs between 31 and 64bit:
-31bit needs .machinemode "zarch_nohighgprs" and llgfr   %r4,%r4
-lr vs lgr and some other instructions:
But lgr and co can be also used on 31bit as this ifunc variant
is only called if we are on a zarch machine.

__memcmp_default differs between 31 and 64bit:
-Some 31bit vs 64bit instructions (e.g. ltr vs ltgr.
Solved with 31/64 specific instruction macros).
-The address of mvc instruction is setup in different ways
(larl vs bras). Solved with #if defined __s390x__.

Otherwise 31/64bit implementation has the same structure of the code.

ChangeLog:

	* sysdeps/s390/s390-64/memcmp.S: Move to ...
	* sysdeps/s390/memcmp.S: ... here.
	Adjust to be usable for 31/64bit.
	* sysdeps/s390/s390-32/memcmp.S: Delete File.
	* sysdeps/s390/multiarch/Makefile (sysdep_routines): Add memcmp.
	* sysdeps/s390/s390-32/multiarch/Makefile (sysdep_routines):
	Remove memcmp.
	* sysdeps/s390/s390-64/multiarch/Makefile: Likewise.
	* sysdeps/s390/s390-64/multiarch/memcmp-s390x.S: Move to ...
	* sysdeps/s390/multiarch/memcmp-s390x.S: ... here.
	Adjust to be usable for 31/64bit.
	* sysdeps/s390/s390-32/multiarch/memcmp-s390.S: Delete File.
	* sysdeps/s390/s390-64/multiarch/memcmp.c: Move to ...
	* sysdeps/s390/multiarch/memcmp.c: ... here.
	* sysdeps/s390/s390-32/multiarch/memcmp.c: Delete File.
2018-12-18 13:57:05 +01:00
Stefan Liebler 07be392807 S390: Implement bzero with memset.
This patch removes the bzero s390 implementation with mvcle and
adds entry points for bzero in memset ifunc variants.
Therefore an ifunc resolver is implemented for bzero, too.

ChangeLog:

	* sysdeps/s390/s390-32/bzero.S: Delete file.
	* sysdeps/s390/s390-64/bzero.S: Likewise.
	* sysdeps/s390/Makefile (sysdep_routines): Add bzero.
	* sysdeps/s390/bzero.c: New file.
	* sysdeps/s390/memset-z900.S: Add bzero entry points.
	* sysdeps/s390/ifunc-memset.h: Add bzero function macros.
	* sysdeps/s390/multiarch/ifunc-impl-list.c
	(__libc_ifunc_impl_list): Add bzero ifunc variants.
2018-12-18 13:57:05 +01:00
Stefan Liebler 712a254a97 S390: Refactor memset ifunc handling.
This patch moves all ifunc variants for memset
to sysdeps/s390/memset-z900.S. The configure-check/preprocessor logic
in sysdeps/s390/ifunc-memset.h decides if ifunc is needed at all
and which ifunc variants should be available.
E.g. if the compiler/assembler already supports z196 by default,
the older ifunc variants are not included.
If we only need the newest ifunc variant,
then we can skip ifunc at all.

Therefore the ifunc-resolvers and __libc_ifunc_impl_list are adjusted
in order to handle only the available ifunc variants.

ChangeLog:

	* sysdeps/s390/ifunc-memset.h: New File.
	* sysdeps/s390/memset.S: Move to ...
	* sysdeps/s390/memset-z900.S ... here.
	Move implementations from memset-s390x.s to here.
	* sysdeps/s390/multiarch/memset-s390x.S: Delete File.
	* sysdeps/s390/multiarch/Makefile (sysdep_routines):
	Remove memset variants.
	* sysdeps/s390/Makefile (sysdep_routines):
	Add memset variants.
	* sysdeps/s390/multiarch/ifunc-impl-list.c
	(__libc_ifunc_impl_list): Adjust ifunc variants for
	memset.
	* sysdeps/s390/multiarch/memset.c: Move ifunc resolver
	to ...
	* sysdeps/s390/memset.c: ... here.
	Adjust ifunc variants for memset.
2018-12-18 13:57:04 +01:00
Stefan Liebler 5f1743d118 S390: Unify 31/64bit memset.
The implementation of memset for s390-32 (31bit) and
s390-64 (64bit) is nearly the same.
This patch unifies it for maintability reasons.

__memset_z10 and __memset_z196 differs between 31 and 64bit:
-31bit needs .machinemode "zarch_nohighgprs" and llgfr   %r4,%r4
-lr vs lgr and some other instructions:
But lgr and co can be also used on 31bit as this ifunc variant
is only called if we are on a zarch machine.

__memset_default differs between 31 and 64bit:
-Some 31bit vs 64bit instructions (e.g. ltr vs ltgr.
Solved with 31/64 specific instruction macros).
-The address of mvc instruction is setup in different ways
(larl vs bras). Solved with #if defined __s390x__.

Otherwise 31/64bit implementation has the same structure of the code.

ChangeLog:

	* sysdeps/s390/s390-64/memset.S: Move to ...
	* sysdeps/s390/memset.S: ... here.
	Adjust to be usable for 31/64bit.
	* sysdeps/s390/s390-32/memset.S: Delete File.
	* sysdeps/s390/multiarch/Makefile (sysdep_routines): Add memset.
	* sysdeps/s390/s390-32/multiarch/Makefile (sysdep_routines):
	Remove memset.
	* sysdeps/s390/s390-64/multiarch/Makefile: Likewise.
	* sysdeps/s390/s390-64/multiarch/memset-s390x.S: Move to ...
	* sysdeps/s390/multiarch/memset-s390x.S: ... here.
	Adjust to be usable for 31/64bit.
	* sysdeps/s390/s390-32/multiarch/memset-s390.S: Delete File.
	* sysdeps/s390/s390-64/multiarch/memset.c: Move to ...
	* sysdeps/s390/multiarch/memset.c: ... here.
	* sysdeps/s390/s390-32/multiarch/memset.c: Delete File.
2018-12-18 13:57:04 +01:00
Stefan Liebler e8023f2685 S390: Use hwcap instead of dl_hwcap in ifunc-resolvers.
The renaming of hwcap arguments in ifunc-resolvers is needed
in order to prepare for further commits which refactors
ifunc handling for memset, memcmp, and memcpy.  Now you are able
to use s390_libc_ifunc_init which stores the stfle bits
within the expression for an ifunc-resolver generated by
s390_libc_ifunc_expr.

ChangeLog:

	* sysdeps/s390/multiarch/ifunc-resolve.h
	(s390_libc_ifunc_init, s390_libc_ifunc,
	s390_vx_libc_ifunc2_redirected): Use hwcap instead of dl_hwcap.
2018-12-18 13:57:03 +01:00
Stefan Liebler b8686c0d70 S390: Add configure check to detect z10 as mininum architecture level set.
Add a configure check for z10 in the same way as done for z196.

ChangeLog:

	* config.h.in (HAVE_S390_MIN_Z10_ZARCH_ASM_SUPPORT): New undefine.
	* sysdeps/s390/configure.ac: Add check for z10 support.
	* sysdeps/s390/configure: Regenerated.
2018-12-18 13:57:03 +01:00
H.J. Lu cd815050e5 x86: Merge i386/x86_64 atomic-machine.h
Merge i386 and x86_64 atomic-machine.h to x86 atomic-machine.h.

Tested on i686 and x86_64 as well as with build-many-glibcs.py.

	* sysdeps/i386/atomic-machine.h: Merged with ...
	* sysdeps/x86_64/atomic-machine.h: To ...
	* sysdeps/x86/atomic-machine.h: This.  New file.
2018-12-18 04:25:26 -08:00
Florian Weimer 053c52b177 locale: Rewrite locale/gen-translit.pl in Python
This commit does not change the generated output file.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
2018-12-18 11:36:29 +01:00
Florian Weimer 40e6c1ec1f localedata: Remove executable bit from localedata/locales/bi_VU [BZ #23995] 2018-12-18 10:56:21 +01:00
Albert ARIBAUD (3ADEV) bfb79db4c3 Fix __TIMERSIZE and @theglibcadj typos
Fix following typos in parent commit:
- ChangeLog: __TIMERSIZE should be __TIMESIZE
- manual/maint.texi: @theglibcadj should be @glibcadj
2018-12-18 10:47:26 +01:00
Albert ARIBAUD (3ADEV) 6e15f3e26b Y2038: add function __localtime64
Tested with 'make check' on x86_64-linux-gnu and i686-linux.gnu.

	* include/time.h
	(__localtime64): Add.
	* manual/maint.texi: Document Y2038 symbol handling.
	* time/localtime.c
	(__localtime64): Add.
	[__TIMERSIZE != 64] (__localtime): Turn into a wrapper.
2018-12-17 22:56:15 +01:00
Joseph Myers 551e81d9e3 Do not clobber r12 for ia64 syscalls.
GCC mainline now gives errors for an asm that clobbers the stack
pointer.  According to
<https://gcc.gnu.org/ml/gcc-patches/2018-12/msg00932.html> GCC
previously ignored such a clobber; thus, this patch removes it from
the clobbers for ia64 syscalls.

Tested with build-many-glibcs.py for ia64-linux-gnu.

	* sysdeps/unix/sysv/linux/ia64/sysdep.h (ASM_CLOBBERS_6_COMMON):
	Do not clobber r12.
2018-12-17 18:31:50 +00:00
Joseph Myers df648905e7 Add test that MAP_* constants agree with kernel.
Continuing the process of building up and using Python infrastructure
for extracting and using values in headers, this patch adds a test
that MAP_* constants from sys/mman.h agree with those in the Linux
kernel headers.  (Other sys/mman.h constants could be added to the
test separately.)

This set of constants has grown over time, so the generic code is
enhanced to allow saying extra constants are OK on either side of the
comparison (where the caller sets those parameters based on the Linux
kernel headers version, compared with the version the headers were
last updated from).  Although the test is a custom Python file, my
intention is to move in future to a single Python script for such
tests and text files it takes as inputs, once there are enough
examples to provide a guide to the common cases in such tests (I'd
like to end up with most or all such sets of constants copied from
kernel headers having such tests, and likewise for structure layouts
from the kernel).

The Makefile code is essentially the same as for tst-signal-numbers,
but I didn't try to find an object file to depend on to represent the
dependency on the headers used by the test (the conform/ tests don't
try to represent such header dependencies at all, for example).

Tested with build-many-glibcs.py, and also for x86_64 with older
kernel headers.

	* scripts/glibcextract.py (compare_macro_consts): Take parameters
	to allow extra macros from first or second sources.
	* sysdeps/unix/sysv/linux/tst-mman-consts.py: New file.
	* sysdeps/unix/sysv/linux/Makefile [$(subdir) = misc]
	(tests-special): Add $(objpfx)tst-mman-consts.out.
	($(objpfx)tst-mman-consts.out): New makefile target.
2018-12-17 18:29:36 +00:00
Mao Han 6bbfc5c09f Add statx conditionals for wordsize-32 *xstat.c
Linux kernel have remove stat64 family from default syscall set, new
implementations with statx is needed when __ARCH_WANT_STAT64 is not
define. This patch add conditionals for relevant functions, using statx
system call to get information and then copy to the return buf, ref to
include/linux/fs.h from linux kernel.

	* sysdeps/unix/sysv/linux/Makefile: Add statx_cp.c.
	* sysdeps/unix/sysv/linux/fxstat64.c: Add conditionals for kernel
	without stat64 system call support.
	* sysdeps/unix/sysv/linux/fxstatat64.c: Likewise.
	* sysdeps/unix/sysv/linux/generic/wordsize-32/fxstat.c: Likewise.
	* sysdeps/unix/sysv/linux/generic/wordsize-32/fxstatat.c: Likewise.
	* sysdeps/unix/sysv/linux/generic/wordsize-32/lxstat.c: Likewise.
	* sysdeps/unix/sysv/linux/generic/wordsize-32/lxstat64.c: Likewise.
	* sysdeps/unix/sysv/linux/generic/wordsize-32/xstat.c: Likewise.
	* sysdeps/unix/sysv/linux/generic/wordsize-32/xstat64.c: Likewise.
	* sysdeps/unix/sysv/linux/mips/mips64/statx_cp.c: New file.
	* sysdeps/unix/sysv/linux/statx_cp.c: Likewise.
	* sysdeps/unix/sysv/linux/statx_cp.h: Likewise.
	* sysdeps/unix/sysv/linux/wordsize-64/statx_cp.c: Likewise.
2018-12-17 09:20:02 +08:00
Paul Eggert ef202e530c regex: fix storage-exhaustion error
[BZ #18040]
* posix/regexec.c (get_subexp):
Do not continue if storage is exhausted.
2018-12-16 07:08:29 -08:00
Assaf Gordon 077caf61d8 regex: fix heap-use-after-free error
[BZ #18040]
Problem reported by Saito Takaaki <tails.saito@gmail.com> in
https://debbugs.gnu.org/32592
Call stack get_subexp->get_subexp_sub->clean_state_log_if_needed may
call extend_buffers which reallocates the re_string_t internal buffer.
Local variable 'buf' was not updated in such case, resulting in
use-after-free.
* posix/regexec.c (get_subexp): Update 'buf' after call to
get_subexp_sub.
2018-12-16 07:08:29 -08:00
Florian Weimer 0c1719e65b support: Do not require overflow builtin in support/blob_repeat.c
It is only available in GCC 5 and later.

Tested-by: Romain Naour <romain.naour@gmail.com>
2018-12-15 18:58:56 +01:00
Joseph Myers 033a2c0a20 Remove x86 mathinline.h asinh, acosh, atanh inlines.
Continuing the removal of bits/mathinline.h inlines that would better
be done by the compiler, this patch removes x86 inlines for asinh,
acosh and atanh functions (only for fast-math, non-SSE 32-bit x86).
I've filed <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88502> for
adding such inlines as an optimization in GCC.

Tested for x86_64 and x86.

	* sysdeps/x86/fpu/bits/mathinline.h (asinh): Remove inline
	definition.
	(acosh): Likewise.
	(atanh): Likewise.
2018-12-14 22:35:57 +00:00
Florian Weimer e361dc043d manual: Document thread/task IDs for Linux
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
2018-12-14 21:11:09 +01:00
Gabriel F. T. Gomes bd51ff5ed0 Add tests for the long double version of ecvt and fcvt
The test case misc/tst-efgcvt.c only tests the double variants of the
Old-fashioned System V number-to-string functions: ecvt, fcvt, and their
re-entrant counterparts.  With a few macros, the code can be reused for
the long double versions of these functions.  A future patch will reuse
it again for IEEE long double on powerpc64le.

Tested for powerpc and powerpc64le.
2018-12-14 11:38:07 -02:00
Stefan Liebler 268bb71e47 Add missing libnss_testX.so requirement for tst-nss-test3.
Sometimes tst-nss-test3 fails with:
error: test-container.c:386: unable to open .../nss/libnss_test1.so for reading

The test tst-nss-test3 which runs in a container needs
libnss_test[12].so. (see e.g. tst-nss-test3.script).
Before this test was moved from tests to tests-container variable,
the requirement was met.  Thus this patch adds this requirement
also for tests in tests-container.

ChangeLog:

	* nss/Makefile (tst-nss-test3.out): New rule.
2018-12-14 09:50:53 +01:00
Joseph Myers db6df070cf Do not clobber sp in _hurd_stack_setup.
GCC mainline now gives errors for an asm that clobbers the stack
pointer.  According to
<https://gcc.gnu.org/ml/gcc-patches/2018-12/msg00932.html> GCC
previously ignored such a clobber; thus, this patch removes it from
_hurd_stack_setup.

Tested with build-many-glibcs.py for i686-gnu.

	* sysdeps/mach/hurd/i386/init-first.c (_hurd_stack_setup): Do not
	clobber sp.
2018-12-13 22:36:33 +00:00
Carlos O'Donell ade8b817fe x86: Add Hygon Dhyana support.
This patch fix Hygon Dhyana processor CPU Vendor ID detection
problem in glibc sysdep module, current glibc codes doesn't
recognize Dhyana CPU Vendor ID("HygonGenuine") and set kind to
arch_kind_other, which result to incorrect zero value for
__cache_sysconf() syscall. As Hygon Dhyana share most
architecture feature as AMD Family 17h, this patch add Hygon CPU
Vendor ID check and setup kind to arch_kind_amd and reuse AMD
code path, which lead to correct return value in
__cache_sysconf() syscall. we run the glibc test suite for both
Hygon Dhyana and AMD EPYC and found no failure case.

Background:
Chengdu Haiguang IC Design Co., Ltd (Hygon) is a Joint Venture
between AMD and Haiguang Information Technology Co.,Ltd., aims at
providing high performance x86 processor for China server market.
Its first generation processor codename is Dhyana, which
originates from AMD technology and shares most of the
architecture with AMD's family 17h, but with different CPU Vendor
ID("HygonGenuine")/Family series number(Family 18h).

Related Hygon kernel patch can be found on
http://lkml.kernel.org/r/5ce86123a7b9dad925ac583d88d2f921040e859b.1538583282.git.puwen@hygon.cn

Signed-off-by: fanjinke <fanjinke@hygon.cn>
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
2018-12-13 09:25:20 -05:00
Andreas Schwab f21e8f8ca4 Fix rwlock stall with PREFER_WRITER_NONRECURSIVE_NP (bug 23861)
In the read lock function (__pthread_rwlock_rdlock_full) there was a
code path which would fail to reload __readers while waiting for
PTHREAD_RWLOCK_RWAITING to change. This failure to reload __readers
into a local value meant that various conditionals used the old value
of __readers and with only two threads left it could result in an
indefinite stall of one of the readers (waiting for PTHREAD_RWLOCK_RWAITING
to go to zero, but it never would).
2018-12-13 12:22:30 +01:00
Andreas Schwab 3d265911c2 Reindent nptl/pthread_rwlock_common.c 2018-12-13 12:21:41 +01:00
Joseph Myers bf8ae8c09a Remove x86 mathinline.h hypot inline.
Continuing the removal of bits/mathinline.h inlines that would better
be done by the compiler, this patch removes an x86 inline for hypot
functions (only for fast-math, only for non-SSE 32-bit x86).  I've
filed <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88474> for adding
such an inline as an optimization in GCC.

Tested for x86_64 and x86.

	* sysdeps/x86/fpu/bits/mathinline.h (hypot): Remove inline
	definition.
2018-12-12 22:33:06 +00:00
Leonardo Sandoval de099757b6 benchtests: send non-consumable data to stderr
Non-consumable data, alias data not related to benchmarks, should be sent to
the standard error, thus pipelines can work as expected.

	* benchtests/scripts/compare_bench.py (do_compare): write to stderr in case
    stat is not present.
	* benchtests/scripts/compare_bench.py (plot_graphs): write to stderr in case
    timings field is not present. Also string showing the output filename goes
    into the stderr.
2018-12-12 11:05:22 -06:00
Leonardo Sandoval 1990185f5f benchtests: include --stats parameter
Allows user to pick a statistic, defaulting to min and mean, from command
line. At the same time, if stat does not exit, catch the run-time exception
and keep comparing the rest of benchmarked functions. Finally, take care of
division-by-zero exceptions and as the latter, keep comparing the rest of the
functions, turning the script a bit more fault tolerant thus useful.

	* benchtests/scripts/compare_bench.py (do_compare): Catch KeyError and
    ZeroDivisorError exceptions.
	* benchtests/scripts/compare_bench.py (compare_runs): Use stats argument to
    loop through user provided statistics.
	* benchtests/scripts/compare_bench.py (main): Include the --stats argument.
2018-12-12 11:05:22 -06:00
Leonardo Sandoval 587426d499 benchtests: keep comparing even if function timings do not match
Allows other functions to be processed, making the script a bit more fault
tolerant thus useful.

	* benchtests/scripts/compare_bench.py (compare_runs): Continue instead of return.
2018-12-12 11:05:22 -06:00
Florian Weimer 46703efa02 timespec_get (posix): Fix copyright header
The “any later version” clause was missing.  This change was approved
in principle by the FSF in RT ticket #1316403.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
2018-12-12 17:13:17 +01:00
Tulio Magno Quites Machado Filho 1d880d4a9b powerpc: Add missing CFI register information (bug #23614)
Add CFI information about the offset of registers stored in the stack
frame.

	[BZ #23614]
	* sysdeps/powerpc/powerpc64/addmul_1.S (FUNC): Add CFI offset for
	registers saved in the stack frame.
	* sysdeps/powerpc/powerpc64/lshift.S (__mpn_lshift): Likewise.
	* sysdeps/powerpc/powerpc64/mul_1.S (__mpn_mul_1): Likewise.

Signed-off-by: Tulio Magno Quites Machado Filho <tuliom@linux.ibm.com>
Reviewed-by: Gabriel F. T. Gomes <gabriel@inconstante.eti.br>
2018-12-12 10:56:51 -02:00
Gabriel F. T. Gomes 1a502f5260 Add *-ldbl.h headers to include/bits
On some platforms, long double may have either the same format as double
or another, wider format, such as the Quadruple IEC 60559 long double
format or the IBM Extended Precision format (both 128-bits wide).
Selecting between the available formats is done by using one of the
following compiler switches: -mlong-double-128, for the wider format, or
-mlong-double-64, for the narrower.  On all platforms that provide this
choice, the wider format is the default.

When the non-default format is selected by user code (i.e.: when
building with -mlong-double-64) calls to functions that take long double
parameters or return a long double type (e.g.: strfroml) are redirected
to a compat function, via assembler redirection, by headers such as
bits/stdlib-ldbl.h or bits/misc-ldbl.h.

In glibc builds, however, these headers are currently being read from
the system directories (/usr/include/bits) rather than from the source
directory.  Although this works correctly today, it raises
reproducibility concerns.  Besides that, builds for powerpc64le will
need these files from the source directory, because on powerpc64le, the
new redirections for long double with IEEE binary128 format will be
implemented in these headers.

Tested for powerpc64 and powerpc64le.
2018-12-11 15:00:11 -02:00
Gabriel F. T. Gomes df682d1d74 Remove redirection of _IO_vfprintf
Since the commit

commit 698fb75b9f
Author: Zack Weinberg <zackw@panix.com>
Date:   Wed Mar 7 14:32:01 2018 -0500

    Add __v*printf_internal with flags arguments

_IO_vfprintf is gone.  This did not trigger any test case failures on
powerpc and powerpc64le, because there were no tests that covered it.
However, new test cases for nldbl versions of argp.h functions exposed
the problem.

Tested for powerpc64 and powerpc64le.
2018-12-11 14:58:39 -02:00
Andreas Schwab c2c082c10f Remove support for abilist-pattern 2018-12-11 15:33:27 +01:00
Szabolcs Nagy 505b5b2922 Fix powf overflow handling in non-nearest rounding mode [BZ #23961]
The threshold value at which powf overflows depends on the rounding mode
and the current check did not take this into account. So when the result
was rounded away from zero it could become infinity without setting
errno to ERANGE.

Example: pow(0x1.7ac7cp+5, 23) is 0x1.fffffep+127 + 0.1633ulp

If the result goes above 0x1.fffffep+127 + 0.5ulp then errno is set,
which is fine in nearest rounding mode, but

  powf(0x1.7ac7cp+5, 23) is inf in upward rounding mode
  powf(-0x1.7ac7cp+5, 23) is -inf in downward rounding mode

and the previous implementation did not set errno in these cases.

The fix tries to avoid affecting the common code path or calling a
function that may introduce a stack frame, so float arithmetics is used
to check the rounding mode and the threshold is selected accordingly.

	[BZ #23961]
	* math/auto-libm-test-in: Add new test case.
	* math/auto-libm-test-out-pow: Regenerated.
	* sysdeps/ieee754/flt-32/e_powf.c (__powf): Fix overflow check.
2018-12-11 10:01:43 +00:00
DJ Delorie 304c61a24f test-container: move postclean outside of namespace changes
During postclean.req testing it was found that the fork in the
parent process (after the unshare syscall) would fail with ENOMEM
(see recursive_remove() in test-container.c).  While failing with
ENOMEM is certainly unexpected, it is simply easier to refactor
the design and have the parent remain outside of the namespace.
This change moves the postclean.req processing to a distinct
process (the parent) that then forks the test process (which will
have to fork once more to complete uid/gid transitions). When the
test process exists the cleanup process will ensure all files are
deleted when a post clean is requested.

Signed-off-by: DJ Delorie <dj@redhat.com>
Reviewed-by: Carlos O'Donell <carlos@redhat.com>

[BZ #23948]
* support/test-container.c: Move postclean step to before we
change namespaces.
2018-12-10 22:37:58 -05:00
Joseph Myers cb7be1590e Use gen-as-const.py to process .pysym files.
This patch eliminates the gen-py-const.awk variant of gen-as-const,
switching to use of gnu-as-const.py (with a new --python option) to
process .pysym files (i.e., to generate nptl_lock_constants.py), as
the syntax of those files is identical to that of .sym files.

Note that the generated nptl_lock_constants.py is *not* identical to
the version generated by the awk script.  Apart from the trivial
changes (comment referencing the new script, and output being sorted),
the constant FUTEX_WAITERS, PTHREAD_MUTEXATTR_FLAG_BITS,
PTHREAD_MUTEXATTR_FLAG_PSHARED and PTHREAD_MUTEX_PRIO_CEILING_MASK are
now output as positive rather than negative constants (on x86_64
anyway; maybe not necessarily on 32-bit systems):

< FUTEX_WAITERS = -2147483648
---
> FUTEX_WAITERS = 2147483648

< PTHREAD_MUTEXATTR_FLAG_BITS = -251662336
< PTHREAD_MUTEXATTR_FLAG_PSHARED = -2147483648
---
> PTHREAD_MUTEXATTR_FLAG_BITS = 4043304960
> PTHREAD_MUTEXATTR_FLAG_PSHARED = 2147483648

< PTHREAD_MUTEX_PRIO_CEILING_MASK = -524288
---
> PTHREAD_MUTEX_PRIO_CEILING_MASK = 4294443008

This is because gen-as-const has a cast of the constant value to long
int, which gen-py-const lacks.

I think the positive values are more logically correct, since the
constants in question are in fact unsigned in C.  But to reliably
produce gen-as-const.py output for constants that always (in C and
Python) reflects the signedness of values with the high bit of "long
int" set would mean more complicated logic needs to be used in
computing values.

The more correct positive values by themselves produce a failure of
nptl/test-mutexattr-printers, because masking with
~PTHREAD_MUTEXATTR_FLAG_BITS & ~PTHREAD_MUTEX_NO_ELISION_NP now leaves
a bit -1 << 32 in the Python value, resulting in a KeyError exception.
To avoid that, places masking with ~ of one of the constants in
question are changed to mask with 0xffffffff as well (this reflects
how ~ in Python applies to an infinite-precision integer whereas ~ in
C does not do any promotions beyond the width of int).

Tested for x86_64.

	* scripts/gen-as-const.py (main): Handle --python option.
	* scripts/gen-py-const.awk: Remove.
	* Makerules (py-const-script): Use gen-as-const.py.
	($(py-const)): Likewise.
	* nptl/nptl-printers.py (MutexPrinter.read_status_no_robust): Mask
	with 0xffffffff together with ~(PTHREAD_MUTEX_PRIO_CEILING_MASK).
	(MutexAttributesPrinter.read_values): Mask with 0xffffffff
	together with ~PTHREAD_MUTEXATTR_FLAG_BITS and
	~PTHREAD_MUTEX_NO_ELISION_NP.
	* manual/README.pretty-printers: Update reference to
	gen-py-const.awk.
2018-12-10 22:56:59 +00:00
Joseph Myers a8110b727e Move tst-signal-numbers to Python.
This patch converts the tst-signal-numbers test from shell + awk to
Python.

As with gen-as-const, the point is not so much that shell and awk are
problematic for this code, as that it's useful to build up general
infrastructure in Python for use of a range of code involving
extracting values from C headers.  This patch moves some code from
gen-as-const.py to a new glibcextract.py, which also gains functions
relating to listing macros, and comparing the values of a set of
macros from compiling two different pieces of code.

It's not just signal numbers that should have such tests; pretty much
any case where glibc copies constants from Linux kernel headers should
have such tests that the values and sets of constants agree except
where differences are known to be OK.  Much the same also applies to
structure layouts (although testing those without hardcoding lists of
fields to test will be more complicated).

Given this patch, another test for a set of macros would essentially
be just a call to glibcextract.compare_macro_consts (plus boilerplate
code - and we could move to having separate text files defining such
tests, like the .sym inputs to gen-as-const, so that only a single
Python script is needed for most such tests).  Some such tests would
of course need new features, e.g. where the set of macros changes in
new kernel versions (so you need to allow new macro names on the
kernel side if the kernel headers are newer than the version known to
glibc, and extra macros on the glibc side if the kernel headers are
older).  tst-syscall-list.sh could become a Python script that uses
common code to generate lists of macros but does other things with its
own custom logic.

There are a few differences from the existing shell + awk test.
Because the new test evaluates constants using the compiler, no
special handling is needed any more for one signal name being defined
to another.  Because asm/signal.h now needs to pass through the
compiler, not just the preprocessor, stddef.h is included as well
(given the asm/signal.h issue that it requires an externally provided
definition of size_t).  The previous code defined __ASSEMBLER__ with
asm/signal.h; this is removed (__ASSEMBLY__, a different macro,
eliminates the requirement for stddef.h on some but not all
architectures).

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

	* scripts/glibcextract.py: New file.
	* scripts/gen-as-const.py: Do not import os.path, re, subprocess
	or tempfile.  Import glibcexctract.
	(compute_c_consts): Remove.  Moved to glibcextract.py.
	(gen_test): Update reference to compute_c_consts.
	(main): Likewise.
	* sysdeps/unix/sysv/linux/tst-signal-numbers.py: New file.
	* sysdeps/unix/sysv/linux/tst-signal-numbers.sh: Remove.
	* sysdeps/unix/sysv/linux/Makefile
	($(objpfx)tst-signal-numbers.out): Use tst-signal-numbers.py.
	Redirect stderr as well as stdout.
2018-12-10 22:27:13 +00:00
Rafael Ávila de Espíndola f9ba9eb821 Enable VDSO for static linking on mips
I have tested that this builds and the resulting program still work.

This was tested on gcc23.fsffrance.org, and for some reason the vdso
there seems unused even when using shared libraries.

	[BZ #19767]
	* sysdeps/unix/sysv/linux/mips/init-first.c: Remove #ifdef SHARED.
        * sysdeps/unix/sysv/linux/mips/libc-vdso.h: Remove #ifdef SHARED.
        * sysdeps/unix/sysv/linux/mips/mips32/sysdep.h: Define
	ALWAYS_USE_VSYSCALL.
        * sysdeps/unix/sysv/linux/mips/mips64/n32/sysdep.h: Define
	ALWAYS_USE_VSYSCALL.
	* sysdeps/unix/sysv/linux/mips/mips64/n64/sysdep.h: Define
	ALWAYS_USE_VSYSCALL.
2018-12-10 21:27:54 +00:00
Florian Weimer 8d20a2f414 compat getdents64: Use correct offset for retry [BZ #23972]
d_off is the offset of the *next* entry, not the offset of the current
entry.
2018-12-10 16:25:09 +01:00
Andreas Schwab 80472e2fba Move *-le.abilist to le/*.abilist
Now that powerpc is using separate sysdep dirs for BE vs LE ABI, there is
no need for abilist-pattern any more.
2018-12-10 14:30:05 +01:00
Joseph Myers 0afcb29d50 Update timezone code from tzcode 2018g.
This patch updates files coming from tzcode to the versions in tzcode
2018g.  No changes elsewhere in glibc were needed.

Tested for x86_64.

	* timezone/private.h: Update from tzcode 2018g.
	* timezone/tzfile.h: Likewise.
	* timezone/tzselect.ksh: Likewise.
	* timezone/zdump.c: Likewise.
	* timezone/zic.c: Likewise.
2018-12-10 13:11:58 +00:00
Paul Pluzhnikov b93f4052fc Fix potential stack overflow [BZ #23490]
Since we are expecting the exact "IBT" string, adjust stack buffer size
and scanf format accordingly.
2018-12-08 10:51:36 -08:00
DJ Delorie 7c9a7c6836 malloc: Add another test for tcache double free check.
This one tests for BZ#23907 where the double free
test didn't check the tcache bin bounds before dereferencing
the bin.

[BZ #23907]
* malloc/tst-tcfree3.c: New.
* malloc/Makefile: Add it.
2018-12-07 19:34:47 -05:00
H.J. Lu 37caec3a11 Don't use __typeof__ (getcpu)
We can't use "__typeof__ (getcpu)" since getcpu is Linux specific and
Hurd doesn't have it.

Tested with build-many-glibcs.py.

	* include/sched.h (__getcpu): Don't use __typeof__ (getcpu).
2018-12-07 12:47:41 -08:00
Gabriel F. T. Gomes 10446f5d9f Prepare vfscanf to use __strtof128_internal
On powerpc64le, long double can currently take two formats: the same as
double (-mlong-double-64) or IBM Extended Precision (default with
-mlong-double-128 or explicitly with -mabi=ibmlongdouble).  The internal
implementation of scanf-like functions is aware of these possibilites
and, based on the format in use, properly calls __strtold_internal or
__strtod_internal, saving the return to a variable of type double or
long double.

When library support for TS 18661-3 was added to glibc, a new function,
__strtof128_internal, was added to enable reading of floating-point
values with IEEE binary128 format into the _Float128 type.  Now that
powerpc64le is getting support for its third long double format, and
taking into account that this format is the same as the format of
_Float128, this patch extends __vfscanf_internal and __vfwscanf_internal
to call __strtof128_internal or __wcstof128_internal when appropriate.
The result gets saved into a variable of _Float128 type.

Tested for powerpc64le.
2018-12-07 17:28:26 -02:00
Samuel Thibault 45f33aac78 hurd: Fix linknamespace of spawni
* include/unistd.h (__confstr): Add prototype and hidden prototype.
	* posix/confstr.c (confstr): Rename to __confstr.
	(__confstr): Add hidden def.
	(confstr): Add weak alias for __confstr.
	* sysdeps/mach/hurd/spawni.c (__spawni): Call __confstr instead of
	confstr.
2018-12-07 20:21:45 +01:00
H.J. Lu a092ca9453 Add getcpu
Add

  #include <sched.h>

  int getcpu (unsigned int *cpu, unsigned int *node);

to return currently used CPU and NUMA node.

Tested on x86-64, x32 and i686 as well as with build-many-glibcs.py.

	* NEWS: Mention getcpu.
	* include/sched.h (__getcpu): New libc_hidden_proto.
	* manual/resource.texi: Document getcpu.
	* sysdeps/unix/sysv/linux/Makefile (sysdep_routines): Add getcpu.
	* sysdeps/unix/sysv/linux/Versions (GLIBC_2.29): Add getcpu.
	* sysdeps/unix/sysv/linux/aarch64/libc.abilist: Add getcpu.
	* sysdeps/unix/sysv/linux/alpha/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/arm/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/hppa/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/i386/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/ia64/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/microblaze/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist:
	Likewise.
	* sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/nios2/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist:
	Likewise.
	* sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist:
	Likewise.
	* sysdeps/unix/sysv/linux/powerpc/powerpc64/libc-le.abilist:
	Likewise.
	* sysdeps/unix/sysv/linux/powerpc/powerpc64/libc.abilist:
	Likewise.
	* sysdeps/unix/sysv/linux/riscv/rv64/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/sh/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/x86_64/64/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/bits/sched.h (getcpu): New prototype.
	* sysdeps/unix/sysv/linux/getcpu.c: New file.
	* sysdeps/unix/sysv/linux/tst-skeleton-affinity.c (test_size):
	Also check getcpu.
2018-12-07 09:17:50 -08:00
Samuel Thibault 7c857b6f0d hurd: Implement support for posix_spawn_file_actions_addfchdir_np 2018-12-07 16:04:05 +01:00
Florian Weimer 3a3fb75572 posix: New function posix_spawn_file_actions_addfchdir_np [BZ #17405]
Along with posix_spawn_file_actions_addchdir,
posix_spawn_file_actions_addfchdir is the subject of a change proposal
for POSIX: <http://austingroupbugs.net/view.php?id=1208>
2018-12-07 16:04:05 +01:00
Joseph Myers c37cd4398a Update miscellaneous files from upstream sources.
This patch updates various miscellaneous files from their upstream
sources.

Tested for x86_64, including "make pdf".

	* manual/texinfo.tex: Update to version 2018-09-21.20 with
	trailing whitespace removed.
	* scripts/config.guess: Update to version 2018-11-28.
	* scripts/config.sub: Update to version 2018-11-28.
	* scripts/install-sh: Update to version 2018-03-11.20.
	* scripts/mkinstalldirs: Update to version 2018-03-07.03.
	* scripts/move-if-change: Update to version 2018-03-07 03:47.
2018-12-06 17:21:47 +00:00
Florian Weimer 899478c2bf inet/tst-if_index-long: New test case for CVE-2018-19591 [BZ #23927] 2018-12-06 15:39:50 +01:00
Florian Weimer f255336a93 support: Implement <support/descriptors.h> to track file descriptors 2018-12-06 15:39:42 +01:00
Zack Weinberg 35caceb145 Use PRINTF_LDBL_IS_DBL instead of __ldbl_is_dbl.
After all that prep work, nldbl-compat.c can now use PRINTF_LDBL_IS_DBL
instead of __no_long_double to control the behavior of printf-like
functions; this is the last thing we needed __no_long_double for, so it
can go away entirely.

Tested for powerpc and powerpc64le.
2018-12-05 18:15:43 -02:00
Zack Weinberg 4e2f43f842 Use PRINTF_FORTIFY instead of _IO_FLAGS2_FORTIFY (bug 11319)
The _chk variants of all of the printf functions become much simpler.
This is the last thing that we needed _IO_acquire_lock_clear_flags2
for, so it can go as well.  I took the opportunity to make the headers
included and the names of all local variables consistent across all the
affected files.

Since we ultimately want to get rid of __no_long_double as well, it
must be possible to get all of the nontrivial effects of the _chk
functions by calling the _internal functions with appropriate flags.
For most of the __(v)xprintf_chk functions, this is covered by
PRINTF_FORTIFY plus some up-front argument checks that can be
duplicated.  However, __(v)sprintf_chk installs a custom jump table so
that it can crash instead of overflowing the output buffer.  This
functionality is moved to __vsprintf_internal, which now has a
'maxlen' argument like __vsnprintf_internal; to get the unsafe
behavior of ordinary (v)sprintf, pass -1 for that argument.

obstack_printf_chk and obstack_vprintf_chk are no longer in the same
file.

As a side-effect of the unification of both fortified and non-fortified
vdprintf initialization, this patch fixes bug 11319 for __dprintf_chk
and __vdprintf_chk, which was previously fixed only for dprintf and
vdprintf by the commit

commit 7ca890b88e
Author: Ulrich Drepper <drepper@redhat.com>
Date:   Wed Feb 24 16:07:57 2010 -0800

    Fix reporting of I/O errors in *dprintf functions.

This patch adds a test case to avoid regressions.

Tested for powerpc and powerpc64le.
2018-12-05 18:15:43 -02:00
Zack Weinberg 124fc732c1 Add __vsyslog_internal, with same flags as __v*printf_internal.
__nldbl___vsyslog_chk will ultimately want to pass PRINTF_LDBL_IS_DBL
down to __vfprintf_internal *as well as* possibly setting PRINTF_FORTIFY.
To make that possible, we need a __vsyslog_internal that takes the
same flags as printf.  The code in misc/syslog.c does also get a
little simpler.

Tested for powerpc and powerpc64le.
2018-12-05 18:15:43 -02:00
Zack Weinberg 698fb75b9f Add __v*printf_internal with flags arguments
There are a lot more printf variants than there are scanf variants,
and the code for setting up and tearing down their custom FILE
variants around the call to __vf(w)printf is more complicated and
variable.  Therefore, I have added _internal versions of all the
v*printf variants, rather than introducing helper routines so that
they can all directly call __vf(w)printf_internal, as was done with
scanf.

As with the scanf changes, in this patch the _internal functions still
look at the environmental mode bits and all callers pass 0 for the
flags parameter.

Several of the affected public functions had _IO_ name aliases that
were not exported (but, in one case, appeared in libio.h anyway);
I was originally planning to leave them as aliases to avoid having
to touch internal callers, but it turns out ldbl_*_alias only work
for exported symbols, so they've all been removed instead.  It also
turns out there were hardly any internal callers.  _IO_vsprintf and
_IO_vfprintf *are* exported, so those two stick around.

Summary for the changes to each of the affected symbols:

  _IO_vfprintf, _IO_vsprintf:
    All internal calls removed, thus the internal declarations, as well
    as uses of libc_hidden_proto and libc_hidden_def, were also removed.
    The external symbol is now exposed via uses of ldbl_strong_alias
    to __vfprintf_internal and __vsprintf_internal, respectively.

  _IO_vasprintf, _IO_vdprintf, _IO_vsnprintf,
  _IO_vfwprintf, _IO_vswprintf,
  _IO_obstack_vprintf, _IO_obstack_printf:
    All internal calls removed, thus declaration in internal headers
    were also removed.  They were never exported, so there are no
    aliases tying them to the internal functions.  I.e.: entirely gone.

  __vsnprintf:
    Internal calls were always preceded by macros such as
      #define __vsnprintf _IO_vsnprintf, and
      #define __vsnprintf vsnprintf
    The macros were removed and their uses replaced with calls to the
    new internal function __vsnprintf_internal.  Since there were no
    internal calls, the internal declaration was also removed.  The
    external symbol is preserved with ldbl_weak_alias to ___vsnprintf.

  __vfwprintf:
    All internal calls converted into calls to __vfwprintf_internal,
    thus the internal declaration was removed.  The function is now a
    wrapper that calls __vfwprintf_internal.  The external symbol is
    preserved.

  __vswprintf:
    Similarly, but no external symbol.

  __vasprintf, __vdprintf, __vfprintf, __vsprintf:
    New internal wrappers.  Not exported.

  vasprintf, vdprintf, vfprintf, vsprintf, vsnprintf,
  vfwprintf, vswprintf,
  obstack_vprintf, obstack_printf:
    These functions used to be aliases to the respective _IO_* function,
    they are now aliases to their respective __* functions.

Tested for powerpc and powerpc64le.
2018-12-05 18:15:42 -02:00
Zack Weinberg d91798b31a Use SCANF_LDBL_IS_DBL instead of __ldbl_is_dbl.
Change the callers of __vfscanf_internal and __vfwscanf_internal that
want to treat 'long double' as another name for 'double' (all of which
happen to be in sysdeps/ieee754/ldbl-opt/nldbl-compat.c) to communicate
this via the new flags argument, instead of the per-thread variable
__no_long_double and its __ldbl_is_dbl wrapper macro.

Tested for powerpc and powerpc64le.
2018-12-05 18:15:42 -02:00
Zack Weinberg b87eb3f8fe Use SCANF_ISOC99_A instead of _IO_FLAGS2_SCANF_STD.
Change the callers of __vfscanf_internal and __vfwscanf_internal that
want C99-compliant behavior to communicate this via the new flags
argument, rather than setting bits on the FILE object.  This also
means these functions do not need to do their own locking.

Tested for powerpc and powerpc64le.
2018-12-05 18:15:42 -02:00
Zack Weinberg 349718d4d7 Add __vfscanf_internal and __vfwscanf_internal with flags arguments.
There are two flags currently defined: SCANF_LDBL_IS_DBL is the mode
used by __nldbl_ scanf variants, and SCANF_ISOC99_A is the mode used
by __isoc99_ scanf variants.  In this patch, the new functions honor
these flag bits if they're set, but they still also look at the
corresponding bits of environmental state, and callers all pass zero.

The new functions do *not* have the "errp" argument possessed by
_IO_vfscanf and _IO_vfwscanf.  All internal callers passed NULL for
that argument.  External callers could theoretically exist, so I
preserved wrappers, but they are flagged as compat symbols and they
don't preserve the three-way distinction among types of errors that
was formerly exposed.  These functions probably should have been in
the list of deprecated _IO_ symbols in 2.27 NEWS -- they're not just
aliases for vfscanf and vfwscanf.

(It was necessary to introduce ldbl_compat_symbol for _IO_vfscanf.
Please check that part of the patch very carefully, I am still not
confident I understand all of the details of ldbl-opt.)

This patch also introduces helper inlines in libio/strfile.h that
encapsulate the process of initializing an _IO_strfile object for
reading.  This allows us to call __vfscanf_internal directly from
sscanf, and __vfwscanf_internal directly from swscanf, without
duplicating the initialization code.  (Previously, they called their
v-counterparts, but that won't work if we want to control *both* C99
mode and ldbl-is-dbl mode using the flags argument to__vfscanf_internal.)
It's still a little awkward, especially for wide strfiles, but it's
much better than what we had.

Tested for powerpc and powerpc64le.
2018-12-05 18:15:42 -02:00
Albert ARIBAUD (3ADEV) 72b8692d7e Y2038: make __tz_convert compatible with 64-bit-time
Now that __time64_t exists, we can switch internal function
__tz_convert from 32-bit to 64-bit time. This involves switching
some other internal functions as well, namely __tz_compute and
__offtime.

Tested with 'make check' on x86_64-linux-gnu and i686-linux.gnu.

	* include/time.h
	(__tz_compute): Replace time_t with __time64_t.
	(__tz_convert): Replace time_t* with __time64_t.
	(__offtime): Replace time_t* with __time64_t.
	* time/gmtime.c
	(__gmtime_r): Adjust call to __tz_convert.
	(gmtime): Likewise.
	* time/localtime.c
	(__localtime_r): Likewise.
	(localtime): Likewise.
	* time/offtime.c: Replace time_t with __time64_t.
	* time/tzset.c: Likewise.
2018-12-05 21:01:22 +01:00
Joseph Myers bd598da9f4 Stop test-in-container trying to run other-OS binaries.
I noticed that, now that build-many-glibcs.py no longer copies glibc
sources, I was getting core dumps in my glibc source directories.  The
cause appears to be, from the i686-gnu build:

for dso in ` env LD_TRACE_LOADED_OBJECTS=1  \
        /scratch/jmyers/glibc-bot/build/glibcs/i686-gnu/glibc/elf/ld.so.1 \
        /scratch/jmyers/glibc-bot/build/glibcs/i686-gnu/glibc/testroot.pristine/bin/sh \
[...]
Segmentation fault (core dumped)

In this case, the x86 architecture means the binary executes, but
dumps core rather than actually working.

Anything involving running the newly built glibc should only be done
ifeq ($(run-built-tests),yes).  This patch conditions the relevant
part of the testroot setup accordingly.

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

	* Makefile ($(objpfx)testroot.pristine/install.stamp): Do not run
	dynamic linker unless [$(run-built-tests) = yes].
2018-12-04 16:52:39 +00:00
DJ Delorie b2e93de0ff test-container: add "su" command to run test as root, add unshare hints
* support/test-container.c (check_for_unshare_hints): New.
(main): Call it if unshare fails.  Add support for "su" scriptlet
command.
2018-12-04 00:03:12 -05:00
Joseph Myers 477a02f637 Make gen-as-const.py handle '--' consistently with awk script.
It was reported in
<https://sourceware.org/ml/libc-alpha/2018-12/msg00045.html> that
gen-as-const.py fails to generate test code in the case where a .sym
file has no symbols in it, so resulting in a test failing to link for
Hurd.

The relevant difference from the old awk script is that the old script
treated '--' lines as indicating that the text to do at the start of
the test (or file used to compute constants) should be output at that
point if not already output, as well as treating lines with actual
entries for constants like that.  This patch changes gen-as-const.py
accordingly, making it the sole responsibility of the code parsing
.sym files to determine when such text should be output and ensuring
it's always output at some point even if there are no symbols and no
'--' lines, since not outputting it means the test fails to link.
Handling '--' like that also avoids any problems that would arise if
the first entry for a symbol were inside #ifdef (since the text in
question must not be output inside #ifdef).

Tested for x86_64, and with build-many-glibcs.py for i686-gnu.  Note
that there are still compilation test failures for i686-gnu
(linknamespace tests, possibly arising from recent posix_spawn-related
changes).

	* scripts/gen-as-const.py (compute_c_consts): Take an argument
	'START' to indicate that start text should be output.
	(gen_test): Likewise.
	(main): Generate 'START' for first symbol or '--' line, or at end
	of input if not previously generated.
2018-12-03 22:08:50 +00:00
Rafael Ávila de Espíndola 6af956e5c0 Enable VDSO for static linking on arm
I have tested that this builds and the resulting program still work.
The kernel in gcc117 (which I ussed for testing) seems to be missing
https://patchwork.kernel.org/patch/10060431/, so the vdso is never used.

	[BZ #19767]
	* sysdeps/unix/sysv/linux/arm/init-first.c: Remove #ifdef SHARED.
	* sysdeps/unix/sysv/linux/arm/libc-vdso.h: Remove #ifdef SHARED.
	* sysdeps/unix/sysv/linux/arm/sysdep.h: Define
	ALWAYS_USE_VSYSCALL.
2018-12-03 20:59:22 +00:00
Adhemerval Zanella f5ec0ea9ea posix: Fix segfault in maybe_script_execute
This patch is essentially 28669f86f6 adjusted for the generic
implementation.

Checked on x86_64-linux-gnu with Linux spawni.c removed.  The only
failure is posix/tst-spawn3, which is expected.

	[BZ #23913]
	* sysdeps/posix/spawni.c (maybe_script_execute):
	Increment size of new_argv by one.
2018-12-03 18:23:11 -02:00
Carlos O'Donell 8cebd4ffe6 Add --no-hard-links option to localedef (bug 23923)
Downstream distributions need consistent sets of hardlinks in
order for rpm to operate effectively. This means that even if
locales are built with a high level of parallelism that the
resulting files need to have consistent hardlink counts. The only
way to achieve this is with a post-install hardlink pass using a
program like 'hardlink' (shipped in Fedora).

If the downstream distro wants to post-process the hardlinks then
the time spent in localedef looking up sibling directories and
processing hardlinks is wasted effort.

To optimize the build and install pass we add a --no-hard-links
option to localedef to avoid doing the hardlink optimziation for
size.

Tested on x86_64 with 'make localedata/install-locale-files'
before and after. Without the patch we have files with 100+
hardlink counts. After the patch and running with --no-hard-links
all link counts are 1. This patch also alters the convenience
target 'make localedata/install-locale-files' to use the new
option.

Signed-off-by: Carlos O'Donell <carlos@redhat.com>
2018-12-03 10:15:39 -05:00
H.J. Lu c22e4c2a14 x86: Extend CPUID support in struct cpu_features
Extend CPUID support for all feature bits from CPUID.  Add a new macro,
CPU_FEATURE_USABLE, which can be used to check if a feature is usable at
run-time, instead of HAS_CPU_FEATURE and HAS_ARCH_FEATURE.

Add COMMON_CPUID_INDEX_D_ECX_1, COMMON_CPUID_INDEX_80000007 and
COMMON_CPUID_INDEX_80000008 to check CPU feature bits in them.

Tested on i686 and x86-64 as well as using build-many-glibcs.py with
x86 targets.

	* sysdeps/x86/cacheinfo.c (intel_check_word): Updated for
	cpu_features_basic.
	(__cache_sysconf): Likewise.
	(init_cacheinfo): Likewise.
	* sysdeps/x86/cpu-features.c (get_extended_indeces): Also
	populate COMMON_CPUID_INDEX_80000007 and
	COMMON_CPUID_INDEX_80000008.
	(get_common_indices): Also populate COMMON_CPUID_INDEX_D_ECX_1.
	Use CPU_FEATURES_CPU_P (cpu_features, XSAVEC) to check if
	XSAVEC is available.  Set the bit_arch_XXX_Usable bits.
	(init_cpu_features): Use _Static_assert on
	index_arch_Fast_Unaligned_Load.
	__get_cpuid_registers and __get_arch_feature.  Updated for
	cpu_features_basic.  Set stepping in cpu_features.
	* sysdeps/x86/cpu-features.h: (FEATURE_INDEX_1): Changed to enum.
	(FEATURE_INDEX_2): New.
	(FEATURE_INDEX_MAX): Changed to enum.
	(COMMON_CPUID_INDEX_D_ECX_1): New.
	(COMMON_CPUID_INDEX_80000007): Likewise.
	(COMMON_CPUID_INDEX_80000008): Likewise.
	(cpuid_registers): Likewise.
	(cpu_features_basic): Likewise.
	(CPU_FEATURE_USABLE): Likewise.
	(bit_arch_XXX_Usable): Likewise.
	(cpu_features): Use cpuid_registers and cpu_features_basic.
	(bit_arch_XXX): Reweritten.
	(bit_cpu_XXX): Likewise.
	(index_cpu_XXX): Likewise.
	(reg_XXX): Likewise.
	* sysdeps/x86/tst-get-cpu-features.c: Include <stdio.h> and
	<support/check.h>.
	(CHECK_CPU_FEATURE): New.
	(CHECK_CPU_FEATURE_USABLE): Likewise.
	(cpu_kinds): Likewise.
	(do_test): Print vendor, family, model and stepping.  Check
	HAS_CPU_FEATURE and CPU_FEATURE_USABLE.
	(TEST_FUNCTION): Removed.
	Include <support/test-driver.c> instead of
	"../../test-skeleton.c".
	* sysdeps/x86_64/multiarch/sched_cpucount.c (__sched_cpucount):
	Check POPCNT instead of POPCOUNT.
	* sysdeps/x86_64/multiarch/test-multiarch.c (do_test): Likewise.
2018-12-03 05:54:56 -08:00
Samuel Thibault 7b36d26b22 Fix test-as-const-jmp_buf-ssp.c generation on gnu-i386
hurd's jmp_buf-ssp.sym does not define any symbol.
scripts/gen-as-const.py currently was emitting an empty line in that
case, and the gawk invocation was prepending "asconst_" to it, ending up
with:

.../build/glibc/setjmp/test-as-const-jmp_buf-ssp.c:1:2: error: expected « = », « , », « ; », « asm » or
« __attribute__ » at end of input
    1 |  asconst_
      |  ^~~~~~~~

        * scripts/gen-as-const.py (main): Avoid emitting empty line when
        there is no element in `consts'.
2018-12-03 14:40:48 +01:00
Florian Weimer 02cd5c1a8d support: Close original descriptors in support_capture_subprocess 2018-12-01 22:41:46 +01:00
Samuel Thibault fc493bc9e6 htl: Fix comparing attr with default values
Fortunately we were previously only missing an optimization.

Thanks dcb <dcb314@hotmail.com> for the report

	[BZ #23032]
	* sysdeps/htl/pt-barrier-init.c (pthread_barrier_init): Fix comparing
	attr with __pthread_default_barrierattr.
	* sysdeps/htl/pt-cond-init.c (__pthread_cond_init): Fix comparing
	attr with __pthread_default_condattr.
	* sysdeps/htl/pt-mutex-init.c (_pthread_mutex_init): Fix comparing
	attr with __pthread_default_mutexattr.
	* sysdeps/htl/pt-rwlock-init.c (_pthread_rwlock_init): Fix comparing
	attr with __pthread_default_rwlockattr.
2018-12-01 21:42:12 +01:00
Kemi Wang 6310e6be9b Mutex: Add pthread mutex tunables
This patch does not have any functionality change, we only provide a spin
count tunes for pthread adaptive spin mutex. The tunable
glibc.pthread.mutex_spin_count tunes can be used by system administrator to
squeeze system performance according to different hardware capabilities and
workload characteristics.

The maximum value of spin count is limited to 32767 to avoid the overflow
of mutex->__data.__spins variable with the possible type of short in
pthread_mutex_lock ().

The default value of spin count is set to 100 with the reference to the
previous number of times of spinning via trylock. This value would be
architecture-specific and can be tuned with kinds of benchmarks to fit most
cases in future.

I would extend my appreciation sincerely to H.J.Lu for his help to refine
this patch series.

	* manual/tunables.texi (POSIX Thread Tunables): New node.
	* nptl/Makefile (libpthread-routines): Add pthread_mutex_conf.
	* nptl/nptl-init.c: Include pthread_mutex_conf.h
	(__pthread_initialize_minimal_internal) [HAVE_TUNABLES]: Call
	 __pthread_tunables_init.
	* nptl/pthreadP.h (MAX_ADAPTIVE_COUNT): Remove.
	(max_adaptive_count): Define.
	* nptl/pthread_mutex_conf.c: New file.
	* nptl/pthread_mutex_conf.h: New file.
	* sysdeps/generic/adaptive_spin_count.h: New file.
	* sysdeps/nptl/dl-tunables.list: New file.
	* nptl/pthread_mutex_lock.c (__pthread_mutex_lock): Use
	max_adaptive_count () not MAX_ADAPTIVE_COUNT.
	* nptl/pthread_mutex_timedlock.c (__pthrad_mutex_timedlock):
	Likewise.

Suggested-by: Andi Kleen <andi.kleen@intel.com>
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Signed-off-by: Kemi.wang <kemi.wang@intel.com>
2018-12-01 08:19:20 -08:00
Paul Pluzhnikov 8e67b39eb4 stdlib: assert on NULL function pointer in atexit etc. [BZ #20544] 2018-11-30 16:18:34 -08:00
Rafael Ávila de Espíndola 15b8d67e29 Enable VDSO on i386 statically linked programs
[BZ #19767]
	* sysdeps/unix/sysv/linux/i386/init-first.c: Don't check SHARED.
	* sysdeps/unix/sysv/linux/i386/sysdep.h (ALWAYS_USE_VSYSCALL):
	New.
2018-11-30 14:32:35 -08:00
Florian Weimer 5e63c240a2 scripts/abilist.awk: Handle special _end symbol for Hurd
Hurd has this in libc.so:

0024db9c g    D  .bss   00000000  GLIBC_2.2.6 _end

This g/D combination was not recognized before.
2018-11-30 22:22:57 +01:00
Adhemerval Zanella 7105860262 Fix ChangeLog date from previous commit 2018-11-30 19:10:50 -02:00
Adhemerval Zanella 5fb7fc9635 posix: Use posix_spawn on system
This patch uses posix_spawn on system implementation.  On Linux this has
the advantage of much lower memory consumption (usually 32 Kb minimum for
the mmap stack area).

Although POSIX does not require, glibc system implementation aims to be
thread and cancellation safe.  The cancellation code is moved to generic
implementation and enabled iff SIGCANCEL is defined (similar on how the
cancellation handler is enabled on nptl-init.c).

Checked on x86_64-linux-gnu, i686-linux-gnu, aarch64-linux-gnu,
arm-linux-gnueabihf, and powerpc64le-linux-gnu.

	* sysdeps/unix/sysv/linux/spawni.c (__spawni_child): Use
	__sigismember instead of sigismember.
	* sysdeps/posix/system.c [SIGCANCEL] (cancel_handler_args,
	cancel_handler): New definitions.
	(CLEANUP_HANDLER, CLEANUP_RESET): Likewise.
	(DO_LOCK, DO_UNLOCK, INIT_LOCK, ADD_REF, SUB_REF): Remove.
	(do_system): Use posix_spawn instead of fork and execl and remove
	reentracy code.
	* sysdeps/generic/not-errno.h (__kill_noerrno): New prototype.
	* sysdeps/unix/sysv/linux/not-errno.h (__kill_noerrno): Likewise.
	* sysdeps/unix/sysv/linux/ia64/system.c: Remove file.
	* sysdeps/unix/sysv/linux/s390/system.c: Likewise.
	* sysdeps/unix/sysv/linux/sparc/system.c: Likewise.
	* sysdeps/unix/sysv/linux/system.c: Likewise.
2018-11-30 18:42:05 -02:00
Adhemerval Zanella 14d0e87d9b posix: Use posix_spawn on popen
This patch uses posix_spawn on popen instead of fork and execl.  On Linux
this has the advantage of much lower memory consumption (usually 32 Kb
minimum for the mmap stack area).

Two issues are also fixed with this change:

  * BZ#17490: although POSIX pthread_atfork description only list 'fork'
    as the function that should execute the atfork handlers, popen
    description states that:

      '[...] shall be *as if* a child process were created within the popen()
       call using the fork() function [...]'

    Other libc/system seems to follow the idea atfork handlers should not be
    executed for popen:

    libc/system	| run atfork handles   | notes
    ------------|----------------------|---------------------------------------
    Freebsd	|        no            | uses vfork
    Solaris 11	|        no            |
    MacOSX 11   |        no            | implemented through posix_spawn syscall
    ------------|----------------------|----------------------------------------

    Similar to posix_spawn and system, popen idea is to spawn a different
    binary so all the POSIX rationale to run the atfork handlers to avoid
    internal process inconsistency is not really required and in some cases
    might be unsafe.

  * BZ#22834: the described scenario, where the forked process might access
    invalid memory due an inconsistent state in multithreaded environment,
    should not happen because posix_spawn does not access the affected
    data structure (proc_file_chain).

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

	[BZ #22834]
	[BZ #17490]
	* NEWS: Add new semantic for atfork with popen and system.
	* libio/iopopen.c (_IO_new_proc_open): use posix_spawn instead of
	fork and execl.
2018-11-30 18:42:05 -02:00
Tulio Magno Quites Machado Filho e5d262effe Fix _dl_profile_fixup data-dependency issue (Bug 23690)
There is a data-dependency between the fields of struct l_reloc_result
and the field used as the initialization guard. Users of the guard
expect writes to the structure to be observable when they also observe
the guard initialized. The solution for this problem is to use an acquire
and release load and store to ensure previous writes to the structure are
observable if the guard is initialized.

The previous implementation used DL_FIXUP_VALUE_ADDR (l_reloc_result->addr)
as the initialization guard, making it impossible for some architectures
to load and store it atomically, i.e. hppa and ia64, due to its larger size.

This commit adds an unsigned int to l_reloc_result to be used as the new
initialization guard of the struct, making it possible to load and store
it atomically in all architectures. The fix ensures that the values
observed in l_reloc_result are consistent and do not lead to crashes.
The algorithm is documented in the code in elf/dl-runtime.c
(_dl_profile_fixup). Not all data races have been eliminated.

Tested with build-many-glibcs and on powerpc, powerpc64, and powerpc64le.

	[BZ #23690]
	* elf/dl-runtime.c (_dl_profile_fixup): Guarantee memory
	modification order when accessing reloc_result->addr.
	* include/link.h (reloc_result): Add field init.
	* nptl/Makefile (tests): Add tst-audit-threads.
	(modules-names): Add tst-audit-threads-mod1 and
	tst-audit-threads-mod2.
	Add rules to build tst-audit-threads.
	* nptl/tst-audit-threads-mod1.c: New file.
	* nptl/tst-audit-threads-mod2.c: Likewise.
	* nptl/tst-audit-threads.c: Likewise.
	* nptl/tst-audit-threads.h: Likewise.

Signed-off-by: Tulio Magno Quites Machado Filho <tuliom@linux.ibm.com>
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
2018-11-30 18:05:32 -02:00
Joseph Myers 7e1d42400c Replace gen-as-const.awk by gen-as-const.py.
This patch replaces gen-as-const.awk, and some fragments of the
Makefile code that used it, by a Python script.  The point is not such
much that awk is problematic for this particular script, as that I'd
like to build up a general Python infrastructure for extracting
information from C headers, for use in writing tests of such headers.
Thus, although this patch does not set up such infrastructure, the
compute_c_consts function in gen-as-const.py might be moved to a
separate Python module in a subsequent patch as a starting point for
such infrastructure.

The general idea of the code is the same as in the awk version, but no
attempt is made to make the output files textually identical.  When
generating a header, a dict of constant names and values is generated
internally then defines are printed in sorted order (rather than the
order in the .sym file, which would have been used before).  When
generating a test that the values computed match those from a normal
header inclusion, the test code is made into a compilation test using
_Static_assert, where previously the comparisons were done only when
the test was executed.  One fragment of test generation (converting
the previously generated header to use asconst_* prefixes on its macro
names) is still in awk code in the makefiles; only the .sym processing
and subsequent execution of the compiler to extract constants have
moved to the Python script.

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

	* scripts/gen-as-const.py: New file.
	* scripts/gen-as-const.awk: Remove.
	* Makerules ($(common-objpfx)%.h $(common-objpfx)%.h.d): Use
	gen-as-const.py.
	($(objpfx)test-as-const-%.c): Likewise.
2018-11-30 15:20:41 +00:00
H.J. Lu ce7387cc25 elf/dl-exception.c: Include <_itoa.h> for _itoa prototype
Tested with build-many-glibcs.py.

	* elf/dl-exception.c: Include <_itoa.h>.
2018-11-29 20:03:46 -08:00
Samuel Thibault c6a5bdc189 hurd: Fix returning value for fcntl(F_*LK*)
to avoid calling va_end again, etc.

	* sysdeps/mach/hurd/fcntl.c (__libc_fcntl): Directly return value
	returned by __f_setlk.
2018-11-30 02:41:50 +01:00
H.J. Lu a5275ba537 _dl_exception_create_format: Support %x/%lx/%zx
Add support for %x, %lx and %zx to _dl_exception_create_format and pad
to the full width with 0.

	* elf/Makefile (tests-internal): Add tst-create_format1.
	* elf/dl-exception.c (_dl_exception_create_format): Support
	%x, %lx and %zx.
	* elf/tst-create_format1.c: New file.
2018-11-29 14:47:27 -08:00
Charles-Antoine Couret 3a67e81d75 argp: do not call _IO_fwide() if _LIBC is not defined
_IO_fwide() is defined in libio.h file. This file is included only
when _LIBC is defined.

So, in case of compilation of these files without _LIBC definition,
the compilation failed due to this unknown function.

Now this function is called when libio.h file is included.

(Change merged from gnulib.  Tested on x86_64.)

	* argp/argp-fmtstream.c (__argp_fmtstream_update): Use [_LIBC]
	conditional on calls to _IO_fwide and putwc_unlocked.  (Merge from
	gnulib.)
	* argp/argp-help.c (__argp_failure): Likewise.
2018-11-29 17:56:55 +00:00
Mao Han 4975f0c3d0 C-SKY: Add dynamic relocations to elf.h
* elf/elf.h (EM_CSKY, R_CKCORE_NONE, R_CKCORE_ADDR32)
	(R_CKCORE_PCRELIMM8BY4, R_CKCORE_PCRELIMM11BY2, R_CKCORE_PCREL32)
	(R_CKCORE_PCRELJSR_IMM11BY2, R_CKCORE_RELATIVE, R_CKCORE_COPY)
	(R_CKCORE_GLOB_DAT, R_CKCORE_JUMP_SLOT, R_CKCORE_GOTOFF)
	(R_CKCORE_GOTPC, R_CKCORE_GOT32, R_CKCORE_PLT32, R_CKCORE_ADDRGOT)
	(R_CKCORE_ADDRPLT, R_CKCORE_PCREL_IMM26BY2, R_CKCORE_PCREL_IMM16BY2)
	(R_CKCORE_PCREL_IMM16BY4, R_CKCORE_PCREL_IMM10BY2)
	(R_CKCORE_PCREL_IMM10BY4, R_CKCORE_ADDR_HI16, R_CKCORE_ADDR_LO16)
	(R_CKCORE_GOTPC_HI16, R_CKCORE_GOTPC_LO16, R_CKCORE_GOTOFF_HI16)
	(R_CKCORE_GOTOFF_LO16, R_CKCORE_GOT12, R_CKCORE_GOT_HI16)
	(R_CKCORE_GOT_LO16, R_CKCORE_PLT12, R_CKCORE_PLT_HI16)
	(R_CKCORE_PLT_LO16, R_CKCORE_ADDRGOT_HI16, R_CKCORE_ADDRGOT_LO16)
	(R_CKCORE_ADDRPLT_HI16, R_CKCORE_ADDRPLT_LO16)
	(R_CKCORE_PCREL_JSR_IMM26BY2, R_CKCORE_TOFFSET_LO16)
	(R_CKCORE_DOFFSET_LO16, R_CKCORE_PCREL_IMM18BY2)
	(R_CKCORE_DOFFSET_IMM18, R_CKCORE_DOFFSET_IMM18BY2)
	(R_CKCORE_DOFFSET_IMM18BY4, R_CKCORE_GOT_IMM18BY4)
	(R_CKCORE_PLT_IMM18BY4, R_CKCORE_PCREL_IMM7BY4, R_CKCORE_TLS_LE32)
	(R_CKCORE_TLS_IE32, R_CKCORE_TLS_GD32, R_CKCORE_TLS_LDM32)
	(R_CKCORE_TLS_LDO32, R_CKCORE_TLS_DTPMOD32, R_CKCORE_TLS_DTPOFF32)
	(R_CKCORE_TLS_TPOFF32): New defines.
2018-11-29 17:32:13 +00:00
Florian Weimer 250102c844 posix: Do not include testcases.h, ptestcases.h in source tree
These files were both auto-generated and shipped in the source tree.
We can assume that sed is available and always generate the files
during the build.
2018-11-29 13:51:25 +01:00
Florian Weimer 96cd0558bc support: Add signal support to support_capture_subprocess_check
Signal zero does not terminate a process, so it is safe to use negative
values for signal numbers.

Adjust libio/tst-vtables-common.c to use this new functionality,
instead of determining the termination status for a signal indirectly.
2018-11-28 20:57:18 +01:00
Joseph Myers 530504e3a8 Do not copy glibc sources in build-many-glibcs.py.
Now that build-many-glibcs.py touches at checkout time all files that
might get rebuilt in the glibc source directory in a normal glibc
build and test run, this patch stops the script from copying the glibc
source directory, so that all builds use the original directory
directly (and less disk space is used, less I/O is involved and cached
copies of the sources in memory can be shared between all the builds -
as well as avoiding spurious failures from copying while "git gc" is
running).  This is similar to how all other components were already
handled.  Any bugs involving writing into the source directory can be
dealt with in future as normal bugs, just as such bugs already are
handled.

Tested with build-many-glibcs.py runs with a read-only glibc source
directory, with all files not touched by the script having timestamps
in forwards alphabetical order and separately with all files not
touched by the script having timestamps in backwards alphabetical
order.

	* scripts/build-many-glibcs.py (Glibc.build_glibc): Use original
	source directory instead of a copy.
	(CommandList.create_copy_dir): Remove.
2018-11-28 17:28:50 +00:00
Stefan Liebler 9a0b697033 S390: Regenerate ULPs.
Regenerated ulps from scratch as builds with gcc 5.5 / 6.4
resulted in +1 ulps.

ChangeLog:

	* sysdeps/s390/fpu/libm-test-ulps: Regenerated.
2018-11-28 15:20:18 +01:00
Florian Weimer 47d8d9a217 support_quote_string: Do not use str parameter name
This avoids a build failure if this identifier is used as a macro
in a test.
2018-11-28 07:16:48 +01:00
Joseph Myers b473b7d88e Fix Hurd build with read-only source directory.
The logic for generating sysdeps/mach/hurd/bits/errno.h involves a
stamp file and $(move-if-change).

The temporary file (generated unconditionally) is generated in the
source directory.  This means that even if
sysdeps/mach/hurd/bits/errno.h is up to date, and has an up to date
timestamp, the build will fail if the source directory is read-only.
Even with a writable source directory, multiple concurrent builds for
i686-gnu with the same source directory could race to access the
temporary file (which always has the same name).

This patch uses the build directory for the temporary file instead to
avoid those problems.  (In the case where the file is out of date and
the temporary file does need to be moved to the source directory, if
there are multiple concurrent builds for i686-gnu with the same source
directory, and the source and build directories are on different
filesystems, it's possible there might still be races replacing the
file in the source directory, depending on exactly how mv handles such
cross-filesystem moves.  This is certainly no worse than the present
situation, where such a case would have races regardless of whether
the file is out of date or whether different filesystems are in use.)

Tested with a build-many-glibcs.py build for i686-gnu.

	* sysdeps/mach/hurd/Makefile ($(common-objpfx)stamp-errnos): Use
	$(hurd-objpfx)bits/errno.h-tmp, not $(hurd)/bits/errno.h-tmp.
2018-11-27 22:05:49 +00:00
Florian Weimer c74a91deaa support: Implement support_quote_string
Reviewed-by: Jonathan Nieder <jrnieder@gmail.com>
2018-11-27 21:35:56 +01:00
Florian Weimer d527c860f5 CVE-2018-19591: if_nametoindex: Fix descriptor for overlong name [BZ #23927] 2018-11-27 18:12:49 +01:00
Rafael Ávila de Espíndola 979cfed05d Enable VDSO for static linking on aarch64
[BZ #19767]
	* sysdeps/unix/sysv/linux/aarch64/init-first.c: Remove #ifdef SHARED.
	* sysdeps/unix/sysv/linux/aarch64/libc-vdso.h: Remove #ifdef SHARED.
	* sysdeps/unix/sysv/linux/aarch64/sysdep.h (ALWAYS_USE_VSYSCALL):
	Define.
2018-11-27 12:27:39 +00:00
Carlos O'Donell ce035c6e90 abilist.awk: Treat .tdata like .tbss and reject unknown combinations.
Mathieu Desnoyers ran into an issue with his rseq patch where he
was the first person to add weak thread-local data and this
resulted in an ABI list update with entries like this:
"GLIBC_2.29 w ? D .tdata 0000000000000020".

The weakness of the symbol has nothing to do with the DSOs ABI
and so we should not write anything about weak symbols here. The
.tdata entries should be treated exactly like .tbss entries and
the output should have been: "GLIBC_2.29 __rseq_abi T 0x20"

This change makes abilist.awk handle .tdata just like .tbss,
while at the same time adding an error case for the default, and
the unknown line cases.  We never want anyone to be able to add
such entries to any ABI list files and should see an immediate
error and consult with experts.

Tested by Mathieu Desnoyers <mathieu.desnoyers@efficios.com> with
the rseq patch set and 'make update-all-abi'.

Tested myself with 'make update-all-abi' on x86_64 with no
changes.

Signed-off-by: Carlos O'Donell <carlos@redhat.com>
2018-11-26 21:23:50 -05:00
Joseph Myers 2bd0bfcc68 Touch more glibc source files in build-many-glibcs.py.
build-many-glibcs.py currently copies the source tree to avoid issues
with parallel builds trying to write into it.  This copying can result
in occasional spurious build failures from bots, when a "git gc" is in
progress that changes .git contents while copying is taking place, and
it would also be desirable to avoid the need to copy to save on disk
space, I/O and memory used in build-many-glibcs.py builds.

In preparation for removing the copying, this patch arranges for
build-many-glibcs.py to touch more files on checkout so their
timestamps do not result in make attempting to rebuild them.  Before
actually removing the copying, I intend to do further tests to ensure
I haven't missed any other such makefile dependencies.

This is of course without prejudice to possibly moving more of these
files to being generated in the build directory rather than being
checked in at all, where that can be done using build tools already
required for the build.  For sysdeps files (installed and otherwise)
it would be necessary to make sure this does not affect the search
ordering, for headers used in the build it would be necessary to
ensure they are generated early enough, and for errlist.c there may be
dual licensing reasons for keeping it checked in.

Tested that a checkout with build-many-glibcs.py does touch the
expected files and that a glibcs build for aarch64-linux-gnu succeeds.

	* scripts/build-many-glibcs.py (Context.fix_glibc_timestamps):
	Touch additional files.
2018-11-26 23:52:43 +00:00
Florian Weimer affec03b71 malloc: tcache: Validate tc_idx before checking for double-frees [BZ #23907]
The previous check could read beyond the end of the tcache entry
array.  If the e->key == tcache cookie check happened to pass, this
would result in crashes.
2018-11-26 20:06:37 +01:00
Rafael Ávila de Espíndola 8ae74eadb6 Enable VDSO on powerpc statically linked programs (bug 19767)
[BZ #19767]
	* sysdeps/unix/sysv/linux/powerpc/init-first.c: Remove #ifdef SHARED.
	* sysdeps/unix/sysv/linux/powerpc/libc-vdso.h: Remove #ifdef
	SHARED.  Include sysdep.h.
	* sysdeps/unix/sysv/linux/powerpc/powerpc32/sysdep.h: Define
	ALWAYS_USE_VSYSCALL.
	* sysdeps/unix/sysv/linux/powerpc/powerpc64/sysdep.h: Define
	ALWAYS_USE_VSYSCALL.

Reviewed-by: Tulio Magno Quites Machado Filho <tuliom@linux.ibm.com>
2018-11-26 11:37:19 -02:00
Rafael Ávila de Espíndola 1e8bdc3a2b Enable VDSO on x86_64 statically linked programs [BZ #19767]
All the required code already existed, and some of it was already
running.

AT_SYSINFO_EHDR is processed if NEED_DL_SYSINFO_DSO is defined, but it
looks like it always is. The call to setup_vdso is also unconditional,
so all that was left to do was setup the function pointers and use
them. This patch just deletes some #ifdef to enable that.

	[BZ #19767]
	* nptl/Makefile (tests-static): Add tst-cond11-static.
	(tests): Likewise.
	* nptl/tst-cond11-static.c: New File.
	* sysdeps/unix/sysv/linux/Makefile (tests-static): Add
	tst-affinity-static.
	(tests): Likewise.
	* sysdeps/unix/sysv/linux/sysdep-vdso.h: Check USE_VSYSCALL
	instead of SHARED.
	* sysdeps/unix/sysv/linux/sysdep.h (ALWAYS_USE_VSYSCALL): New.
	(USE_VSYSCALL): Likewise.
	* sysdeps/unix/sysv/linux/tst-affinity-static.c: New file.
	* sysdeps/unix/sysv/linux/x86/libc-vdso.h: Check USE_VSYSCALL
	instead of SHARED.
	* sysdeps/unix/sysv/linux/x86_64/init-first.c: Don't check
	SHARED.
	* sysdeps/unix/sysv/linux/x86_64/sysdep.h (ALWAYS_USE_VSYSCALL):
	New.
2018-11-23 16:50:29 -08:00
Joseph Myers 1283c478aa Fix Arm __ASSUME_COPY_FILE_RANGE (bug 23915).
The generic kernel-features.h defines __ASSUME_COPY_FILE_RANGE for 4.5
and later kernels.  However, for 32-bit Arm binaries running on 64-bit
Arm kernels, the syscall was only wired up in the 4.7 kernel, although
the 32-bit Arm kernel had the syscall from 4.5 onwards.  This patch
corrects the Arm kernel-features.h to undefine the macro for
configured minimum kernel versions before 4.7.

Tested (compilation only) with a build-many-glibcs.py build for
arm-linux-gnueabi.

	[BZ #23915]
	* sysdeps/unix/sysv/linux/arm/kernel-features.h
	[__LINUX_KERNEL_VERSION < 0x040700] (__ASSUME_COPY_FILE_RANGE):
	Undefine.
2018-11-23 17:53:50 +00:00
H.J. Lu c089fd80c7 x86/CET: Add a re-exec test with legacy bitmap
Add a re-exec test with legacy bitmap to verify that legacy bitmap is
properly hanlded by kernel.

	* sysdeps/x86/Makefile (tests): Add tst-cet-legacy-1a.
	(tst-cet-legacy-1a-ARGS): New.
	($(objpfx)tst-cet-legacy-1a): New target.
	* sysdeps/x86/tst-cet-legacy-1a.c: New file.
2018-11-23 07:31:07 -08:00
Joseph Myers 95edd05c75 Combine more conformtest tests into single execution of the compiler.
In <https://sourceware.org/ml/libc-alpha/2018-11/msg00225.html>,
Florian reported that the change from conformtest.pl to conformtest.py
had increased conform/ test time, possibly because of increased
startup overhead for Python scripts.

This patch improves conformtest.py performance by arranging for as
many tests of a (header, standard) pair as possible to use a single
execution of the compiler, so it does not need to initialize and parse
the whole header under test separately for every test assertion.
Specifically, compilation tests that are not marked as "optional" or
"xfail" are combined into a single source file, and are only then run
separately if compilation of that combined file fails.  For me, this
reduces the wall clock time for the conformtest.py tests (not the
whole of the conform/ directory) from two minutes to 15 seconds.

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

	* conform/conformtest.py (CompileSubTest.__init__): Set
	self.run_early to False.
	(ExecuteSubTest.__init__): Likewise.
	(HeaderTests.run): Try running all non-optional, non-XFAILed
	compilation tests in a single execution of the compiler.
2018-11-22 21:21:36 +00:00
Joseph Myers cc6c89faf3 Separate conformtest subtest generation and execution.
This patch continues moving conformtest towards running more tests in
a single compiler execution by separating the generation and execution
of the subtests of each test.

Instead of test classes having a run method that both generates the
text of the programs to be compiled or executed, and compiles or
executes them, they are changed to having a gen_subtests method that
just generates CompileSubTest and ExecuteSubTest objects to store the
subtest names and text, and then a separate loop in HeaderTests.run
deals with actually executing those subtests.

This will allow for future changes to extract the text for all
non-optional, non-xfail compilation subtests to try compiling those
all at once, with separate compilations only if that fails, so
massively reducing the number of separate compiler executions (each of
which needs to parse the entire contents of the header under test, in
addition to the startup cost that applies even for compiling an empty
file).

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

	* conform/conformtest.py (CompileSubTest): New class.
	(ExecuteSubTest): Likewise.
	(ElementTest.run): Rename to gen_subtests.  Append tests to
	self.subtests instead of running them.
	(ConstantTest.run): Likewise.
	(SymbolTest.run): Likewise.
	(TypeTest.run): Likewise.
	(TagTest.run): Likewise.
	(FunctionTest.run): Likewise.
	(VariableTest.run): Likewise.
	(MacroFunctionTest.run): Likewise.
	(MacroStrTest.run): Likewise.
	(HeaderTests.handle_test_line): Generate subtests for tests.
	(HeaderTests.run): Run subtests for tests.
2018-11-22 00:47:20 +00:00
Szabolcs Nagy a502c5294b Remove the error handling wrapper from pow
Introduce new pow symbol version that doesn't do SVID compatible error
handling.  The standard errno and fp exception based error handling is
inline in the new code and does not have significant overhead.

The wrapper is disabled for sysdeps/ieee754/dbl-64 by using empty
w_pow.c and enabled for targets with their own pow implementation or
ifunc dispatch on __ieee754_pow by including math/w_pow.c.

The compatibility symbol version still uses the wrapper with SVID error
handling around the new code.  There is no new symbol version nor
compatibility code on !LIBM_SVID_COMPAT targets (e.g. riscv).

On targets where previously powl was an alias of pow, now it points to
the compatibility symbol with the wrapper, because it still need the
SVID compatible error handling.  This affects NO_LONG_DOUBLE (e.g. arm)
and LONG_DOUBLE_COMPAT (e.g. alpha) targets as well.

The __pow_finite symbol is now an alias of pow.  Both __pow_finite and
pow set errno and thus not const functions.

The ia64 asm is changed so the compat and new symbol versions map to the
same address.

On x86_64 #include <math.h> was added before macro definitions that
may affect that header.

Tested with build-many-glibcs.py.

	* math/Versions (GLIBC_2.29): Add pow.
	* math/w_pow_compat.c (__pow_compat): Change to versioned compat
	symbol.
	* math/w_pow.c: New file.
	* sysdeps/i386/fpu/w_pow.c: New file.
	* sysdeps/ia64/fpu/e_pow.S: Add versioned symbols.
	* sysdeps/ieee754/dbl-64/e_pow.c (__ieee754_pow): Rename to __pow
	and add necessary aliases.
	* sysdeps/ieee754/dbl-64/w_pow.c: New file.
	* sysdeps/m68k/m680x0/fpu/w_pow.c: New file.
	* sysdeps/mach/hurd/i386/libm.abilist: Update.
	* sysdeps/unix/sysv/linux/aarch64/libm.abilist: Update.
	* sysdeps/unix/sysv/linux/alpha/libm.abilist: Update.
	* sysdeps/unix/sysv/linux/arm/libm.abilist: Update.
	* sysdeps/unix/sysv/linux/hppa/libm.abilist: Update.
	* sysdeps/unix/sysv/linux/i386/libm.abilist: Update.
	* sysdeps/unix/sysv/linux/ia64/libm.abilist: Update.
	* sysdeps/unix/sysv/linux/m68k/coldfire/libm.abilist: Update.
	* sysdeps/unix/sysv/linux/m68k/m680x0/libm.abilist: Update.
	* sysdeps/unix/sysv/linux/microblaze/libm.abilist: Update.
	* sysdeps/unix/sysv/linux/mips/mips32/libm.abilist: Update.
	* sysdeps/unix/sysv/linux/mips/mips64/libm.abilist: Update.
	* sysdeps/unix/sysv/linux/nios2/libm.abilist: Update.
	* sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libm.abilist: Update.
	* sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libm.abilist: Update.
	* sysdeps/unix/sysv/linux/powerpc/powerpc64/libm-le.abilist: Update.
	* sysdeps/unix/sysv/linux/powerpc/powerpc64/libm.abilist: Update.
	* sysdeps/unix/sysv/linux/s390/s390-32/libm.abilist: Update.
	* sysdeps/unix/sysv/linux/s390/s390-64/libm.abilist: Update.
	* sysdeps/unix/sysv/linux/sh/libm.abilist: Update.
	* sysdeps/unix/sysv/linux/sparc/sparc32/libm.abilist: Update.
	* sysdeps/unix/sysv/linux/sparc/sparc64/libm.abilist: Update.
	* sysdeps/unix/sysv/linux/x86_64/64/libm.abilist: Update.
	* sysdeps/unix/sysv/linux/x86_64/x32/libm.abilist: Update.
	* sysdeps/x86_64/fpu/multiarch/e_pow-fma.c (__ieee754_pow): Rename to
	__pow.
	* sysdeps/x86_64/fpu/multiarch/e_pow-fma4.c (__ieee754_pow): Likewise.
	* sysdeps/x86_64/fpu/multiarch/e_pow.c (__ieee754_pow): Likewise.
	* sysdeps/x86_64/fpu/multiarch/w_pow.c: New file.
2018-11-21 09:58:36 +00:00
Szabolcs Nagy 718d6542f2 Remove the error handling wrapper from log2
Introduce new log2 symbol version that doesn't do SVID compatible error
handling.  The standard errno and fp exception based error handling is
inline in the new code and does not have significant overhead.

The wrapper is disabled for sysdeps/ieee754/dbl-64 by using empty
w_log2.c and enabled for targets with their own log2 implementation by
including math/w_log2.c.

The compatibility symbol version still uses the wrapper with SVID error
handling around the new code.  There is no new symbol version nor
compatibility code on !LIBM_SVID_COMPAT targets (e.g. riscv).

On targets where previously log2l was an alias of log2, now it points to
the compatibility symbol with the wrapper, because it still need the
SVID compatible error handling.  This affects NO_LONG_DOUBLE (e.g. arm)
and LONG_DOUBLE_COMPAT (e.g. alpha) targets as well.

The __log2_finite symbol is now an alias of log2.  Both __log2_finite
and log2 set errno and thus not const functions.

The ia64 asm is changed so the compat and new symbol versions map to the
same address.

Tested with build-many-glibcs.py.

	* math/Versions (GLIBC_2.29): Add log2.
	* math/w_log2_compat.c (__log2_compat): Change to versioned compat
	symbol.
	* math/w_log2.c: New file.
	* sysdeps/i386/fpu/w_log2.c: New file.
	* sysdeps/ia64/fpu/e_log2.S: Add versioned symbols.
	* sysdeps/ieee754/dbl-64/e_log2.c (__ieee754_log2): Rename to __log2
	and add necessary aliases.
	* sysdeps/ieee754/dbl-64/w_log2.c: New file.
	* sysdeps/m68k/m680x0/fpu/w_log2.c: New file.
	* sysdeps/mach/hurd/i386/libm.abilist: Update.
	* sysdeps/unix/sysv/linux/aarch64/libm.abilist: Update.
	* sysdeps/unix/sysv/linux/alpha/libm.abilist: Update.
	* sysdeps/unix/sysv/linux/arm/libm.abilist: Update.
	* sysdeps/unix/sysv/linux/hppa/libm.abilist: Update.
	* sysdeps/unix/sysv/linux/i386/libm.abilist: Update.
	* sysdeps/unix/sysv/linux/ia64/libm.abilist: Update.
	* sysdeps/unix/sysv/linux/m68k/coldfire/libm.abilist: Update.
	* sysdeps/unix/sysv/linux/m68k/m680x0/libm.abilist: Update.
	* sysdeps/unix/sysv/linux/microblaze/libm.abilist: Update.
	* sysdeps/unix/sysv/linux/mips/mips32/libm.abilist: Update.
	* sysdeps/unix/sysv/linux/mips/mips64/libm.abilist: Update.
	* sysdeps/unix/sysv/linux/nios2/libm.abilist: Update.
	* sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libm.abilist: Update.
	* sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libm.abilist: Update.
	* sysdeps/unix/sysv/linux/powerpc/powerpc64/libm-le.abilist: Update.
	* sysdeps/unix/sysv/linux/powerpc/powerpc64/libm.abilist: Update.
	* sysdeps/unix/sysv/linux/s390/s390-32/libm.abilist: Update.
	* sysdeps/unix/sysv/linux/s390/s390-64/libm.abilist: Update.
	* sysdeps/unix/sysv/linux/sh/libm.abilist: Update.
	* sysdeps/unix/sysv/linux/sparc/sparc32/libm.abilist: Update.
	* sysdeps/unix/sysv/linux/sparc/sparc64/libm.abilist: Update.
	* sysdeps/unix/sysv/linux/x86_64/64/libm.abilist: Update.
	* sysdeps/unix/sysv/linux/x86_64/x32/libm.abilist: Update.
2018-11-21 09:57:21 +00:00
Szabolcs Nagy f29b7c492d Remove the error handling wrapper from log
Introduce new log symbol version that doesn't do SVID compatible error
handling.  The standard errno and fp exception based error handling is
inline in the new code and does not have significant overhead.

The wrapper is disabled for sysdeps/ieee754/dbl-64 by using empty
w_log.c and enabled for targets with their own log implementation by
including math/w_log.c.

The compatibility symbol version still uses the wrapper with SVID error
handling around the new code.  There is no new symbol version nor
compatibility code on !LIBM_SVID_COMPAT targets (e.g. riscv).

On targets where previously logl was an alias of log, now it points to
the compatibility symbol with the wrapper, because it still need the
SVID compatible error handling.  This affects NO_LONG_DOUBLE (e.g. arm)
and LONG_DOUBLE_COMPAT (e.g. alpha) targets as well.

The __log_finite symbol is now an alias of log.  Both __log_finite and
log set errno and thus not const functions.

The ia64 asm is changed so the compat and new symbol versions map to the
same address.

On x86_64 #include <math.h> was added before macro definitions that may
affect that header.

Tested with build-many-glibcs.py.

	* math/Versions (GLIBC_2.29): Add log.
	* math/w_log_compat.c (__log_compat): Change to versioned compat
	symbol.
	* math/w_log.c: New file.
	* sysdeps/i386/fpu/w_log.c: New file.
	* sysdeps/ia64/fpu/e_log.S: Update.
	* sysdeps/ieee754/dbl-64/e_log.c (__ieee754_log): Rename to __log
	and add necessary aliases.
	* sysdeps/ieee754/dbl-64/w_log.c: New file.
	* sysdeps/m68k/m680x0/fpu/w_log.c: New file.
	* sysdeps/mach/hurd/i386/libm.abilist: Update.
	* sysdeps/unix/sysv/linux/aarch64/libm.abilist: Update.
	* sysdeps/unix/sysv/linux/alpha/libm.abilist: Update.
	* sysdeps/unix/sysv/linux/arm/libm.abilist: Update.
	* sysdeps/unix/sysv/linux/hppa/libm.abilist: Update.
	* sysdeps/unix/sysv/linux/i386/libm.abilist: Update.
	* sysdeps/unix/sysv/linux/ia64/libm.abilist: Update.
	* sysdeps/unix/sysv/linux/m68k/coldfire/libm.abilist: Update.
	* sysdeps/unix/sysv/linux/m68k/m680x0/libm.abilist: Update.
	* sysdeps/unix/sysv/linux/microblaze/libm.abilist: Update.
	* sysdeps/unix/sysv/linux/mips/mips32/libm.abilist: Update.
	* sysdeps/unix/sysv/linux/mips/mips64/libm.abilist: Update.
	* sysdeps/unix/sysv/linux/nios2/libm.abilist: Update.
	* sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libm.abilist: Update.
	* sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libm.abilist: Update.
	* sysdeps/unix/sysv/linux/powerpc/powerpc64/libm-le.abilist: Update.
	* sysdeps/unix/sysv/linux/powerpc/powerpc64/libm.abilist: Update.
	* sysdeps/unix/sysv/linux/s390/s390-32/libm.abilist: Update.
	* sysdeps/unix/sysv/linux/s390/s390-64/libm.abilist: Update.
	* sysdeps/unix/sysv/linux/sh/libm.abilist: Update.
	* sysdeps/unix/sysv/linux/sparc/sparc32/libm.abilist: Update.
	* sysdeps/unix/sysv/linux/sparc/sparc64/libm.abilist: Update.
	* sysdeps/unix/sysv/linux/x86_64/64/libm.abilist: Update.
	* sysdeps/unix/sysv/linux/x86_64/x32/libm.abilist: Update.
	* sysdeps/x86_64/fpu/multiarch/e_log-avx.c (__ieee754_log): Rename to
	__log.
	* sysdeps/x86_64/fpu/multiarch/e_log-fma.c (__ieee754_log): Likewise.
	* sysdeps/x86_64/fpu/multiarch/e_log-fma4.c (__ieee754_log): Likewise.
	* sysdeps/x86_64/fpu/multiarch/e_log.c (__ieee754_log): Likewise.
	* sysdeps/x86_64/fpu/multiarch/w_log.c: New file.
2018-11-21 09:56:27 +00:00
Szabolcs Nagy c20a10561a Remove the error handling wrapper from exp and exp2
Introduce new exp and exp2 symbol version that don't do SVID compatible
error handling.  The standard errno and fp exception based error handling
is inline in the new code and does not have significant overhead.

The double precision wrappers are disabled for sysdeps/ieee754/dbl-64
by using empty w_exp.c and w_exp2.c files, the math/w_exp.c and
math/w_exp2.c files use the wrapper template and can be included by
targets that have their own exp and exp2 implementations or use ifunc
on the glibc internal __ieee754_exp symbol.

The compatibility symbol versions still use the wrapper with SVID error
handling around the new code.  There is no new symbol version nor
compatibility code on !LIBM_SVID_COMPAT targets (e.g. riscv).

On targets where previously expl and exp2l were aliases of exp and exp2,
now they point to the compatibility symbols with the wrapper, because
they still need the SVID compatible error handling.  This affects
NO_LONG_DOUBLE (e.g arm) and LONG_DOUBLE_COMPAT (e.g. alpha) targets
as well.

The _finite symbols are now aliases of the standard symbols (they have
no performance advantage anymore).  Both the standard symbols and
_finite symbols set errno and thus not const functions.

The ia64 asm is changed so the compat and new symbol versions map to the
same address.

On x86_64 #include <math.h> was added before macro definitions that may
affect that header (the new macro name is __exp instead of __ieee754_exp
which breaks some math.h macros).

Tested with build-many-glibcs.py.

	* math/Versions (GLIBC_2.29): Add exp and exp2.
	* math/w_exp2_compat.c (__exp2_compat): Change to versioned compat
	symbol, handle NO_LONG_DOUBLE and LONG_DOUBLE_COMPAT explicitly.
	* math/w_exp_compat.c (__exp_compat): Likewise.
	* math/w_exp.c: New file.
	* math/w_exp2.c: New file.
	* sysdeps/i386/fpu/w_exp.c: New file.
	* sysdeps/i386/fpu/w_exp2.c: New file.
	* sysdeps/ia64/fpu/e_exp.S: Add versioned symbols.
	* sysdeps/ia64/fpu/e_exp2.S: Likewise.
	* sysdeps/ieee754/dbl-64/e_exp.c (__ieee754_exp): Rename to __exp
	and add necessary aliases.
	* sysdeps/ieee754/dbl-64/e_exp2.c (__ieee754_exp2): Rename to __exp2
	and add necessary aliases.
	* sysdeps/ieee754/dbl-64/w_exp.c: New file.
	* sysdeps/ieee754/dbl-64/w_exp2.c: New file.
	* sysdeps/m68k/m680x0/fpu/w_exp.c: New file.
	* sysdeps/m68k/m680x0/fpu/w_exp2.c: New file.
	* sysdeps/mach/hurd/i386/libm.abilist: Update.
	* sysdeps/unix/sysv/linux/aarch64/libm.abilist: Update.
	* sysdeps/unix/sysv/linux/alpha/libm.abilist: Update.
	* sysdeps/unix/sysv/linux/arm/libm.abilist: Update.
	* sysdeps/unix/sysv/linux/hppa/libm.abilist: Update.
	* sysdeps/unix/sysv/linux/i386/libm.abilist: Update.
	* sysdeps/unix/sysv/linux/ia64/libm.abilist: Update.
	* sysdeps/unix/sysv/linux/m68k/coldfire/libm.abilist: Update.
	* sysdeps/unix/sysv/linux/m68k/m680x0/libm.abilist: Update.
	* sysdeps/unix/sysv/linux/microblaze/libm.abilist: Update.
	* sysdeps/unix/sysv/linux/mips/mips32/libm.abilist: Update.
	* sysdeps/unix/sysv/linux/mips/mips64/libm.abilist: Update.
	* sysdeps/unix/sysv/linux/nios2/libm.abilist: Update.
	* sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libm.abilist: Update.
	* sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libm.abilist: Update.
	* sysdeps/unix/sysv/linux/powerpc/powerpc64/libm-le.abilist: Update.
	* sysdeps/unix/sysv/linux/powerpc/powerpc64/libm.abilist: Update.
	* sysdeps/unix/sysv/linux/s390/s390-32/libm.abilist: Update.
	* sysdeps/unix/sysv/linux/s390/s390-64/libm.abilist: Update.
	* sysdeps/unix/sysv/linux/sh/libm.abilist: Update.
	* sysdeps/unix/sysv/linux/sparc/sparc32/libm.abilist: Update.
	* sysdeps/unix/sysv/linux/sparc/sparc64/libm.abilist: Update.
	* sysdeps/unix/sysv/linux/x86_64/64/libm.abilist: Update.
	* sysdeps/unix/sysv/linux/x86_64/x32/libm.abilist: Update.
	* sysdeps/x86_64/fpu/multiarch/e_exp-avx.c (__exp1): Remove.
	(__ieee754_exp): Rename to __exp.
	* sysdeps/x86_64/fpu/multiarch/e_exp-fma.c (__exp1): Remove.
	(__ieee754_exp): Rename to __exp.
	* sysdeps/x86_64/fpu/multiarch/e_exp-fma4.c (__exp1): Remove.
	(__ieee754_exp): Rename to __exp.
	* sysdeps/x86_64/fpu/multiarch/e_exp.c (__ieee754_exp): Rename to
	__exp.
	* sysdeps/x86_64/fpu/multiarch/w_exp.c: New file.
2018-11-21 09:55:02 +00:00
DJ Delorie bcdaad21d4 malloc: tcache double free check
* malloc/malloc.c (tcache_entry): Add key field.
(tcache_put): Set it.
(tcache_get): Likewise.
(_int_free): Check for double free in tcache.
* malloc/tst-tcfree1.c: New.
* malloc/tst-tcfree2.c: New.
* malloc/Makefile: Run the new tests.
* manual/probes.texi: Document memory_tcache_double_free probe.

* dlfcn/dlerror.c (check_free): Prevent double frees.
2018-11-20 13:24:09 -05:00
Wilco Dijkstra 5770c0ad1e [AArch64] Adjust writeback in non-zero memset
This fixes an ineffiency in the non-zero memset.  Delaying the writeback
until the end of the loop is slightly faster on some cores - this shows
~5% performance gain on Cortex-A53 when doing large non-zero memsets.

	* sysdeps/aarch64/memset.S (MEMSET): Improve non-zero memset loop.
2018-11-20 12:37:00 +00:00
Joseph Myers 9a62a9397d Use unique identifiers in conformtest.
This patch makes tests in conformtest use unique identifiers, in
preparation for trying to cover more tests in a single compilation to
speed up these tests as suggested in
<https://sourceware.org/ml/libc-alpha/2018-11/msg00229.html>.

Tests are assigned a number, used in generating identifiers; where a
single call to a run method does multiple compilations (sharing that
number), identifiers are changed as needed to avoid duplication
between those compilations, so they can be combined in future.

Large numbers of positional arguments to format strings make the code
harder to follow, and using the test numbers serves to increase the
number of arguments to such format strings, so the code is generally
changed to use %(name)s where all the arguments come from attributes
of the test object and so vars(self) is sufficient to provide all
those names for the format string.  Cases where some arguments aren't
attributes of self still use positional format arguments.

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

	* conform/conformtest.py (ElementTest.run): Use unique identifiers
	in tests.  Use names for format arguments.
	(ConstantTest.run): Likewise.
	(SymbolTest.run): Likewise.
	(TypeTest.run): Likewise.
	(TagTest.run): Likewise.
	(FunctionTest.run): Likewise.
	(VariableTest.run): Likewise.
	(MacroFunctionTest.run): Likewise.
	(MacroStrTest.run): Likewise.
	(HeaderTests.__init__): Set self.num_tests.
	(HeaderTests.handle_test_line): Set test.num.  Increment
	self.num_tests.
2018-11-20 03:54:53 +00:00
Samuel Thibault b15b1a9590 hurd: Support lockf at offset 0 with size 0 or 1.
* sysdeps/mach/hurd/f_setlk.c: Include <unistd.h>.
	(__f_setlk): When whence is SEEK_CUR, use __lseek64 to convert it to
	SEEK_SET.
2018-11-19 20:22:30 +01:00
Mao Han 0c7f97aead Update config.guess and config.sub to current versions.
* scripts/config.guess: Update to version 2018-08-29.
	* scripts/config.sub: Update to version 2018-08-29.
2018-11-19 16:51:42 +00:00
Florian Weimer 35e3fbc451 support: Print timestamps in timeout handler
This is sometimes useful to determine if a test truly got stuck, or if
it was making progress (logging information to standard output) and
was merely slow to finish.
2018-11-19 15:35:03 +01:00
Zack Weinberg c75772e3f0 Use STRFMON_LDBL_IS_DBL instead of __ldbl_is_dbl.
On platforms where long double used to have the same format as double,
but later switched to a different format (alpha, s390, sparc, and
powerpc), accessing the older behavior is possible and it happens via
__nldbl_* functions (not on the API, but accessible from header
redirection and from compat symbols).  These functions write to the
global flag __ldbl_is_dbl, which tells other functions that long double
variables should be handled as double.  This patch takes the first step
towards removing this global flag and creates __vstrfmon_l_internal,
which takes an explicit flags parameter.

This change arguably makes the generated code slightly worse on
architectures where __ldbl_is_dbl is never true; right now, on those
architectures, it's a compile-time constant; after this change, the
compiler could theoretically prove that __vstrfmon_l_internal was
never called with a nonzero flags argument, but it would probably need
LTO to do it.  This is not performance critical code and I tend to
think that the maintainability benefits of removing action at a
distance are worth it.  However, we _could_ wrap the runtime flag
check with a macro that was defined to ignore its argument and always
return false on architectures where __ldbl_is_dbl is never true, if
people think the codegen benefits are important.

Tested for powerpc and powerpc64le.
2018-11-16 09:21:14 -02:00
Samuel Thibault 346ef23f19 hurd: Fix F_*LK* fcntl with __USE_FILE_OFFSET64
struct flock64 uses 64bit values. This introduces other values for F_GETLK,
F_SETLK, F_SETLKW to distinguish between both.

	* sysdeps/mach/hurd/bits/fcntl.h (F_GETLK64, F_SETLK64, F_SETLKW64): New
	macros
	[__USE_FILE_OFFSET64] (F_GETLK, F_SETLK, F_SETLKW): Define to F_GETLK64,
	F_SETLK64, F_SETLKW64, respectively.
	* sysdeps/mach/hurd/f_setlk.c: New file.
	* sysdeps/mach/hurd/f_setlk.h: New file.
	* sysdeps/mach/hurd/Makefile [$(subdir) = io] (sysdeps_routines): Add
	f_setlk.
	* sysdeps/mach/hurd/fcntl.c: Include "f_setlk.h".h".
	(__libc_fcntl): Move non-flock operations to...
	* sysdeps/mach/hurd/vfcntl.c (__libc_vfcntl): ... New file.
	* sysdeps/mach/hurd/fcntl.c (fcntl64): Add missing alias.
2018-11-16 09:41:05 +01:00
Paul Eggert 5d8af1566b mktime: DEBUG_MKTIME cleanup
The DEBUG_MKTIME code no longer works in glibc or in Gnulib.
And it’s no longer needed now that glibc and Gnulib both have
their own testing mechanisms for mktime.
* time/mktime.c (DEBUG_MKTIME): Remove.  All uses removed.
2018-11-15 22:59:33 +01:00
Paul Eggert 86aece3bfb mktime: fix non-EOVERFLOW errno handling
[BZ#23789]
mktime was not properly reporting failures when the underlying
localtime_r fails with errno != EOVERFLOW; it incorrectly treated
them like EOVERFLOW failures, and set errno to EOVERFLOW.
The problem could happen on non-glibc platforms, with Gnulib.
* time/mktime.c (guess_time_tm): Remove, replacing with ...
(tm_diff): ... this simpler function, which does not change errno.
All callers changed to deal with errno themselves.
(ranged_convert, __mktime_internal): Return failure immediately if
the underlying function reports any failure other than EOVERFLOW.
(__mktime_internal): Set errno to EOVERFLOW if the spring-forward
gap code fails.
2018-11-15 22:59:33 +01:00
Paul Eggert f6b3331bba mktime: fix bug with Y2038 DST transition
[BZ#23789]
* time/mktime.c (ranged_convert): On 32-bit platforms, don’t
mishandle a DST transition that jumps over the Y2038 boundary.
No such DST transitions are known so this is only a theoretical
bug, but we might as well do things right.
2018-11-15 22:59:33 +01:00
Paul Eggert efbdddc381 mktime: make more room for overflow
[BZ#23789]
* time/mktime.c (long_int): Now 4⨯ int, not just 3⨯.
This is so that we can add tm_diff results to a previous guess,
which will be useful in a later patch.
2018-11-15 22:59:33 +01:00
Paul Eggert 6c90d759f6 mktime: simplify offset guess
[BZ#23789]
* time/mktime.c (__mktime_internal): Omit excess precision.
2018-11-15 22:59:33 +01:00
Paul Eggert 32c12f3f7a mktime: new test for mktime failure
[BZ#23789]
Based on a test suggested by Albert Aribaud in:
https://www.sourceware.org/ml/libc-alpha/2018-10/msg00662.html
* time/Makefile (tests): Add bug-mktime4.
* time/bug-mktime4.c: New file.
2018-11-15 22:59:33 +01:00
Paul Eggert de20b81a03 mktime: fix EOVERFLOW bug
[BZ#23789]
* time/mktime.c [!_LIBC && !DEBUG_MKTIME]:
Include libc-config.h, not config.h, for __set_errno.
(guess_time_tm, __mktime_internal): Set errno to EOVERFLOW on overflow.
2018-11-15 22:59:33 +01:00
Samuel Thibault 8c6c3fb0bc hurd: Fix build with GCC 9
* sysdeps/mach/hurd/dl-sysdep.c (check_no_hidden): Use
	__attribute_copy__ to copy attributes from name. Drop static qualifier
	to avoid warnings about leaf attribute not having effect on static
	functions.
2018-11-14 01:36:44 +01:00
Florian Weimer 6923f6db1e malloc: Use current (C11-style) atomics for fastbin access 2018-11-13 10:36:10 +01:00
Joseph Myers 0c096dcf14 Fix mips build with GCC 9.
This patch fixes the build for MIPS (o32) with GCC 9 by stopping MIPS
__longjmp from using strong_alias, instead defining the alias
manually, so that the intended effect of not copying the nomips16
attribute is achieved, as explained in the included comment.

Tested with build-many-glibcs.py compilers build for mips64-linux-gnu
(which includes glibc builds for all three ABIs).

	* sysdeps/mips/__longjmp.c (__longjmp): Define alias manually with
	alias attribute, not with strong_alias.
2018-11-13 01:55:15 +00:00
Joseph Myers 9c4b457e1b Add hidden_tls_def macros, fix powerpc-soft build with GCC 9.
Soft-float powerpc fails to build with current GCC mainline because of
use of libc_hidden_data_def for TLS variables, resulting in a non-TLS
alias being defined, to which the tls_model attribute is now copied,
resulting in a warning about it being ignored.

The problem here appears to be the non-TLS alias.  This patch adds a
hidden_tls_def macro family, corresponding to the hidden_tls_proto
macros, to define TLS aliases properly in such a case, and uses it for
those powerpc soft-float variables.

Tested with build-many-glibcs.py compilers build for powerpc-linux-gnu
soft-float.  Also tested for x86_64.

	* include/libc-symbols.h [SHARED && !NO_HIDDEN && !__ASSEMBLER__]
	(__hidden_ver2): New macro.  Use old definition of __hidden_ver1
	with additional parameter thread.
	[SHARED && !NO_HIDDEN && !__ASSEMBLER__] (__hidden_ver1): Define
	in terms of __hidden_ver2.
	(hidden_tls_def): New macro.
	(libc_hidden_tls_def): Likewise.
	(rtld_hidden_tls_def): Likewise.
	(libm_hidden_tls_def): Likewise.
	(libmvec_hidden_tls_def): Likewise.
	(libresolv_hidden_tls_def): Likewise.
	(librt_hidden_tls_def): Likewise.
	(libdl_hidden_tls_def): Likewise.
	(libnss_files_hidden_tls_def): Likewise.
	(libnsl_hidden_tls_def): Likewise.
	(libnss_nisplus_hidden_tls_def): Likewise.
	(libutil_hidden_tls_def): Likewise.
	(libutil_hidden_tls_def): Likweise.
	* sysdeps/powerpc/nofpu/sim-full.c (__sim_exceptions_thread): Use
	libc_hidden_tls_def.
	(__sim_disabled_exceptions_thread): Likewise.
	(__sim_round_mode_thread): Likewise.
2018-11-13 01:53:53 +00:00
Joseph Myers 53f5c65914 Fix sparc64 build with GCC 9.
Similar to the x86_64 and armv7 build issues, glibc fails to build for
sparc64 with current mainline GCC because of aliases declared in the
course of defining IFUNCs, which copy their attributes from a header
declaration, ending up with fewer attributes than the (built-in)
string function they alias.  This patch fixes the issue similarly to
the fixes for those other architectures.

Tested with build-many-glibcs.py compilers build for
sparc64-linux-gnu.

	* sysdeps/sparc/sparc-ifunc.h [SHARED]
	(sparc_ifunc_redirected_hidden_def): Use __attribute_copy__ to
	copy attributes from name.
2018-11-13 00:27:06 +00:00
Joseph Myers f578f97b97 Fix armv7 build with GCC 9.
Similar to the x86_64 build issues, glibc fails to build for armv7
with current mainline GCC because of aliases declared in the course of
defining IFUNCs, which copy their attributes from a header
declaration, ending up with fewer attributes than the (built-in)
string function they alias: the relevant attributes (nonnull, leaf)
are present on the header declaration, but elided therefrom when glibc
itself if being built (whatever the reasons are for disabling the
nonnull and leaf attributes in that case, and whether or not those
reasons are actually still valid).  This patch fixes the issue
similarly to the x86_64 fix, by adding an addition __attribute_copy__
use (in this case, on the definition of arm_libc_ifunc_hidden_def).

Tested with build-many-glibcs.py build for armeb-linux-gnueabi-be8.

	* sysdeps/arm/arm-ifunc.h [SHARED] (arm_libc_ifunc_hidden_def):
	Use __attribute_copy__ to copy attributes from name.
2018-11-12 23:59:29 +00:00