Commit Graph

11054 Commits

Author SHA1 Message Date
John David Anglin 2759a2c1d8 Fix failing sNaN tests on hppa. 2017-07-15 12:18:03 -04:00
Jiong Wang 5ba6405338 [ARM] Fix ld.so crash when built using Binutils 2.29
There is bug report that ld.so in GLIBC 2.24 built by Binutils 2.29 will crash
on arm-linux-gnueabihf.  This is confirmed, and the details is at:

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

As analyzed in the PR, the old code was with the assumption that assembler
won't set bit0 of thumb function address if it comes from PC-relative
instructions and the calculation can be finished during assembling.  This
assumption however does not hold after PR gas/21458.

	* sysdeps/arm/dl-machine.h (elf_machine_load_address):  Also strip bit 0
	of pcrel_address under Thumb mode.
2017-07-13 15:48:41 +01:00
John David Anglin 27f29b2dad Fix type in sysdeps/hppa/dl-machine.h. 2017-07-12 20:02:45 -04:00
Gabriel F. T. Gomes 4de0cb2e9a powerpc64le: Iterate over all object suffixes when appending -mfloat128
On powerpc64le, the compilation of the files related to float128 support
requires the option -mfloat128 to be passed to gcc.  However, not all
possible object suffixes were covered in the Makefile.  This patch uses
$(all-object-suffixes) in all remaining rules.

Tested for powerpc64le.

	* sysdeps/powerpc/powerpc64le/Makefile: Use $(all-object-suffixes)
	to iterate over all possible object suffixes.  Add a comment
	explaining the use of sysdep-CFLAGS instead of CFLAGS.
2017-07-11 14:02:10 -03:00
H.J. Lu ed421fca42 Avoid backtrace from __stack_chk_fail [BZ #12189]
__stack_chk_fail is called on corrupted stack.  Stack backtrace is very
unreliable against corrupted stack.  __libc_message is changed to accept
enum __libc_message_action and call BEFORE_ABORT only if action includes
do_backtrace.  __fortify_fail_abort is added to avoid backtrace from
__stack_chk_fail.

	[BZ #12189]
	* debug/Makefile (CFLAGS-tst-ssp-1.c): New.
	(tests): Add tst-ssp-1 if -fstack-protector works.
	* debug/fortify_fail.c: Include <stdbool.h>.
	(_fortify_fail_abort): New function.
	(__fortify_fail): Call _fortify_fail_abort.
	(__fortify_fail_abort): Add a hidden definition.
	* debug/stack_chk_fail.c: Include <stdbool.h>.
	(__stack_chk_fail): Call __fortify_fail_abort, instead of
	__fortify_fail.
	* debug/tst-ssp-1.c: New file.
	* include/stdio.h (__libc_message_action): New enum.
	(__libc_message): Replace int with enum __libc_message_action.
	(__fortify_fail_abort): New hidden prototype.
	* malloc/malloc.c (malloc_printerr): Update __libc_message calls.
	* sysdeps/posix/libc_fatal.c (__libc_message): Replace int
	with enum __libc_message_action.  Call BEFORE_ABORT only if
	action includes do_backtrace.
	(__libc_fatal): Update __libc_message call.
2017-07-11 07:44:14 -07:00
Adhemerval Zanella 94070f86c0 posix: Add p{read,write}v2 RWF_NOWAIT flag (BZ#21738)
Linux 4.12 (b745fafaf70c0a98a2e1e7ac8cb14542889ceb0e) adds a new
p{read,write}v2 flag RWF_NOWAIT.  This patch adds it for linux
uio-ext.h header.

Checked on x86_64-linux-gnu (on a 4.10 kernel).

	[BZ #21738]
	* manual/llio.texi (RWF_NOWAIT): New item.
	* misc/tst-preadvwritev2-common.c (do_test_with_invalid_flags):
	Add RWF_NOWAIT check.
	* sysdeps/unix/sysv/linux/bits/uio-ext.h (RWF_NOWAIT): New flag.
2017-07-11 11:06:44 -03:00
Stefan Liebler 2c80445787 S390: Fix tst-ptrace-singleblock if kernel does not support PTRACE_SINGLEBLOCK.
The request PTRACE_SINGLEBLOCK was introduced in Linux 3.15.  Thus the ptrace call
will fail on older kernels.
Thus the test is now testing PTRACE_SINGLEBLOCK with data argument pointing to a
buffer on stack which is assumed to fail.  If the request would be interpreted as
PTRACE_GETREGS, then the ptrace call will not fail and the regs are written to buf.

If we run with a kernel with support for PTRACE_SINGLEBLOCK a ptrace call with
data=NULL, returns zero with no error.  If we run with a kernel without support for
PTRACE_SINGLEBLOCK a ptrace call with data=NULL reports an error.
In the latter case, the test is just continuing with PTRACE_CONT.

ChangeLog:

	* sysdeps/unix/sysv/linux/s390/tst-ptrace-singleblock.c:
	Support running on kernels without PTRACE_SINGLEBLOCK.
2017-07-11 10:38:44 +02:00
H.J. Lu 7a499756ab x86-64: Test memmove_chk and memset_chk only in libc.so [BZ #21741]
Since there are no multiarch versions of memmove_chk and memset_chk,
test multiarch versions of memmove_chk and memset_chk only in libc.so.

	[BZ #21741]
	* sysdeps/x86_64/multiarch/ifunc-impl-list.c
	(__libc_ifunc_impl_list): Test memmove_chk and memset_chk only
	in libc.so.
2017-07-10 04:44:38 -07:00
John David Anglin 2e783eb905 Update hppa ulps. 2017-07-09 15:22:41 -04:00
John David Anglin c5f70682a5 Use generic pthread support on hppa. 2017-07-09 15:01:11 -04:00
H.J. Lu 58d021c836 x86-64: Update comments in IFUNC selectors
* sysdeps/x86_64/multiarch/memcmp.c: Update comments.
	* sysdeps/x86_64/multiarch/memmove.c: Likewise.
	* sysdeps/x86_64/multiarch/memrchr.c: Likewise.
	* sysdeps/x86_64/multiarch/memset.c: Likewise.
	* sysdeps/x86_64/multiarch/rawmemchr.c: Likewise.
	* sysdeps/x86_64/multiarch/strchrnul.c: Likewise.
	* sysdeps/x86_64/multiarch/strlen.c: Likewise.
	* sysdeps/x86_64/multiarch/strnlen.c: Likewise.
	* sysdeps/x86_64/multiarch/wcschr.c: Likewise.
	* sysdeps/x86_64/multiarch/wcscpy.c: Likewise.
	* sysdeps/x86_64/multiarch/wcslen.c: Likewise.
	* sysdeps/x86_64/multiarch/wcsnlen.c: Likewise.
	* sysdeps/x86_64/multiarch/wmemchr.c: Likewise.
	* sysdeps/x86_64/multiarch/wmemcmp.c: Likewise.
	* sysdeps/x86_64/multiarch/wmemset.c: Likewise.
	* sysdeps/x86_64/multiarch/wmemset_chk.c: Likewise.
2017-07-09 11:43:20 -07:00
H.J. Lu 4df54c89bb x86-64: Update comments in ifunc-impl-list.c
All x86-64 IFUNC selectors are written in C now.  Update comments to
reflect it.

	* sysdeps/x86_64/multiarch/ifunc-impl-list.c: Update comments.
2017-07-09 11:38:37 -07:00
John David Anglin 7023e6db99 Fix BZ #21049. 2017-07-09 13:48:04 -04:00
Matthew Krupcale 3adfef7eaa nptl: Fix typo on __have_pthread_attr_t (BZ#21715)
This patch fixes some build issues when including types/sigevent_t.h
along with bits/pthreadtypes.h.

Checked on x86_64-linux-gnu and on a build on supported major ABIs.

	[BZ #21715]
	* sysdeps/nptl/bits/pthreadtypes.h (__have_pthread_attr_t): Fix typo
	on definition.
2017-07-06 10:27:24 -03:00
H.J. Lu 031e519c95 x86-64: Align the stack in __tls_get_addr [BZ #21609]
This change forces realignment of the stack pointer in __tls_get_addr, so
that binaries compiled by GCCs older than GCC 4.9:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58066

continue to work even if vector instructions are used in glibc which
require the ABI stack realignment.

__tls_get_addr_slow is added to handle the slow paths in the default
implementation of__tls_get_addr in elf/dl-tls.c.  The new __tls_get_addr
calls __tls_get_addr_slow after realigning the stack.  Internal calls
within ld.so go directly to the default implementation of __tls_get_addr
because they do not need stack realignment.

	[BZ #21609]
	* sysdeps/x86_64/Makefile (sysdep-dl-routines): Add tls_get_addr.
	(gen-as-const-headers): Add rtld-offsets.sym.
	* sysdeps/x86_64/dl-tls.c: New file.
	* sysdeps/x86_64/rtld-offsets.sym: Likwise.
	* sysdeps/x86_64/tls_get_addr.S: Likewise.
	* sysdeps/x86_64/dl-tls.h: Add multiple inclusion guards.
	* sysdeps/x86_64/tlsdesc.sym (TI_MODULE_OFFSET): New.
	(TI_OFFSET_OFFSET): Likwise.
2017-07-06 04:43:20 -07:00
Adhemerval Zanella db6b2f2522 posix: Fix default posix_spawn return value
This patch fix the return value for error conditions for default
posix_spawn (where the errno is expected).  It also avoid clobber
errno on fork call.

Checked on x86_64 (with Linux implementation removed).

	[BZ# 21697]
	* sysdeps/posix/spawni.c (__spawni_child): Fix return value.
	(__spawnix): Do not clober errno.
2017-07-05 15:58:31 -03:00
Szabolcs Nagy d2e0491883 Single threaded stdio optimization
Locking overhead can be significant in some stdio operations
that are common in single threaded applications.

This patch adds the _IO_FLAGS2_NEED_LOCK flag to indicate if
an _IO_FILE object needs to be locked and some of the stdio
functions just jump to their _unlocked variant when not.  The
flag is set on all _IO_FILE objects when the first thread is
created.  A new GLIBC_PRIVATE libc symbol, _IO_enable_locks,
was added to do this from libpthread.

The optimization can be applied to more stdio functions,
currently it is only applied to single flag check or single
non-wide-char standard operations.  The flag should probably
be never set for files with _IO_USER_LOCK, but that's just a
further optimization, not a correctness requirement.

The optimization is valid in a single thread because stdio
operations are non-as-safe (so lock state is not observable
from a signal handler) and stdio locks are recursive (so lock
state is not observable via deadlock).  The optimization is not
valid if a thread may be created while an stdio lock is taken
and thus it should be disabled if any user code may run during
an stdio operation (interposed malloc, printf hooks, etc).
This makes the optimization more complicated for some stdio
operations (e.g. printf), but those are bigger and thus less
important to optimize so this patch does not try to do that.

	* libio/libio.h (_IO_FLAGS2_NEED_LOCK, _IO_need_lock): Define.
	* libio/libioP.h (_IO_enable_locks): Declare.
	* libio/Versions (_IO_enable_locks): New symbol.
	* libio/genops.c (_IO_enable_locks): Define.
	(_IO_old_init): Initialize flags2.
	* libio/feof.c.c (_IO_feof): Avoid locking when not needed.
	* libio/ferror.c (_IO_ferror): Likewise.
	* libio/fputc.c (fputc): Likewise.
	* libio/putc.c (_IO_putc): Likewise.
	* libio/getc.c (_IO_getc): Likewise.
	* libio/getchar.c (getchar): Likewise.
	* libio/ioungetc.c (_IO_ungetc): Likewise.
	* nptl/pthread_create.c (__pthread_create_2_1): Enable stdio locks.
	* libio/iofopncook.c (_IO_fopencookie): Enable locking for the file.
	* sysdeps/pthread/flockfile.c (__flockfile): Likewise.
2017-07-04 16:05:12 +01:00
Florian Weimer 1ff6c67a25 sysconf: Use conservative default for _SC_NPROCESSORS_ONLN [BZ #21542] 2017-07-04 16:12:46 +02:00
Florian Weimer 352f4ff9a2 resolv: Introduce struct resolv_context [BZ #21668]
struct resolv_context objects provide a temporary resolver context
which does not change during a name lookup operation.  Only when the
outmost context is created, the stub resolver configuration is
verified to be current (at present, only against previous res_init
calls).  Subsequent attempts to obtain the context will reuse the
result of the initial verification operation.

struct resolv_context can also be extended in the future to store
data which needs to be deallocated during thread cancellation.
2017-07-03 20:52:59 +02:00
Rajalakshmi Srinivasaraghavan 2572f356b1 powerpc: Clean up strlen and strnlen for power8
To align a quadword aligned address to 64 bytes, maximum of three
16 bytes load is needed for worst case instead of loading four times.
2017-07-03 10:46:13 +05:30
Siddhesh Poyarekar 47ea614b9a Fix typo in glibc.tune.cpu name 2017-07-01 19:51:44 +05:30
Gabriel F. T. Gomes 8466ee1cb7 float128: Add signbit alternative for old compilers
In math/math.h, __MATH_TG will expand signbit to __builtin_signbit*,
e.g.: __builtin_signbitf128, before GCC 6.  However, there has never
been a __builtin_signbitf128 in GCC and the type-generic builtin is
only available since GCC 6.  For older GCC, this patch defines
__builtin_signbitf128 to __signbitf128, so that the internal function
is used instead of the non-existent builtin.

This patch also changes the implementation of __signbitf128, because
it was reusing the implementation of __signbitl from ldbl-128, which
calls __builtin_signbitl.  Using the long double version of the
builtin is not correct on machines where _Float128 is ABI-distinct
from long double (i.e.: ia64, powerpc64le, x86, x86_84).  The new
implementation does not rely on builtins when being built with GCC
versions older than 6.0.

The new code does not currently affect powerpc64le builds, because
only GCC 6.2 fulfills the requirements from configure.  It might
affect powerpc64le builds if those requirements are backported to
older versions of the compiler.  The new code affects x86_64 builds,
since glibc is supposed to build correctly with older versions of GCC.

Tested for powerpc64le and x86_64.

	* include/math.h (__signbitf128): Define as hidden.
	* sysdeps/ieee754/float128/s_signbitf128.c (__signbitf128):
	Reimplement without builtins.
	* sysdeps/ia64/bits/floatn.h [!__GNUC_PREREQ (6, 0)]
	(__builtin_signbitf128): Define to __signbitf128.
	* sysdeps/powerpc/bits/floatn.h: Likewise.
	* sysdeps/x86/bits/floatn.h: Likewise.
2017-06-30 18:34:29 -03:00
Adhemerval Zanella 9b8f8593e5 Consolidate Linux fcntl implementation
This patch consolidates the fcntl Linux syscall generation on
sysdeps/unix/sysv/linux/fcntl.c.  It basically removes all the
architecture specific implementations.

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

	* sysdeps/unix/sysv/linux/arm/fcntl.c: Remove file.
	* sysdeps/unix/sysv/linux/generic/wordsize-32/fcntl.c: Likewise.
	* sysdeps/unix/sysv/linux/hppa/fcntl.c: Likewise.
	* sysdeps/unix/sysv/linux/i386/fcntl.c: Likewise.
	* sysdeps/unix/sysv/linux/m68k/fcntl.c: Likewise.
	* sysdeps/unix/sysv/linux/microblaze/fcntl.c: Likewise.
	* sysdeps/unix/sysv/linux/mips/mips32/fcntl.c: Likewise.
	* sysdeps/unix/sysv/linux/mips/mips64/n32/fcntl.c: Likewise.
	* sysdeps/unix/sysv/linux/powerpc/powerpc32/fcntl.c: Likewise.
	* sysdeps/unix/sysv/linux/s390/s390-32/fcntl.c: Likewise.
	* sysdeps/unix/sysv/linux/sh/fcntl.c: Likewise.
	* sysdeps/unix/sysv/linux/sparc/sparc32/fcntl.c: Likewise.
	* sysdeps/unix/sysv/linux/fcntl.c: New file.
	* sysdeps/unix/sysv/linux/powerpc/powerpc64/fcntl.c: Refactor to
	use default implementation.
2017-06-30 15:17:26 -03:00
Siddhesh Poyarekar 28cfa3a48e tunables, aarch64: New tunable to override cpu
Add a new tunable (glibc.tune.cpu) to override CPU identification on
aarch64.  This is useful in two cases: one where it is desirable to
pretend to be another CPU for purposes of testing or because routines
written for that CPU are beneficial for specific workloads and second
where the underlying kernel does not support emulation of MRS to get
the MIDR of the CPU.

	* elf/dl-tunables.h (tunable_is_name): Move from...
	* elf/dl-tunables.c (is_name): ... here.
	(parse_tunables, __tunables_init): Adjust.
	* manual/tunables.texi: Document glibc.tune.cpu.
	* sysdeps/aarch64/dl-tunables.list: New file.
	* sysdeps/unix/sysv/linux/aarch64/cpu-features.c (struct
	cpu_list): New type.
	(cpu_list): New list of CPU names and their MIDR.
	(get_midr_from_mcpu): New function.
	(init_cpu_features): Override MIDR if necessary.
2017-06-30 22:58:39 +05:30
Siddhesh Poyarekar ab85da1530 aarch64: Call all string function implementations in tests
The string function implementations implemented so far do not use any
instructions that may deviate from standard aarch64, so it is possible
for all routines to run on all armv8 hardware.  Select all
implementations in the benchmarks and tests.

	* sysdeps/aarch64/multiarch/ifunc-impl-list.c
	(__libc_ifunc_impl_list): Unconditionally select thunderx
	routine for testing.
2017-06-30 22:57:12 +05:30
H.J. Lu 4e61a6be44 i386: Increase MALLOC_ALIGNMENT to 16 [BZ #21120]
GCC 7 changed the definition of max_align_t on i386:

https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff;h=9b5c49ef97e63cc63f1ffa13baf771368105ebe2

As a result, glibc malloc no longer returns memory blocks which are as
aligned as max_align_t requires.

This causes malloc/tst-malloc-thread-fail to fail with an error like this
one:

error: allocation function 0, size 144 not aligned to 16

This patch moves the MALLOC_ALIGNMENT definition to <malloc-alignment.h>
and increases the malloc alignment to 16 for i386.

	[BZ #21120]
	* malloc/malloc-internal.h (MALLOC_ALIGNMENT): Moved to ...
	* sysdeps/generic/malloc-alignment.h: Here.  New file.
	* sysdeps/i386/malloc-alignment.h: Likewise.
	* sysdeps/generic/malloc-machine.h: Include <malloc-alignment.h>.
2017-06-30 09:11:24 -07:00
Joseph Myers e78dc67889 SPARC sys/ucontext.h namespace fixes (bug 21457).
This patch fixes various miscellaneous namespace issues in the SPARC
sys/ucontext.h header.  These are similar to changes made previous to
other sys/ucontext.h headers, where the SPARC header was excluded from
those previous patches because of its complexity.

Tested for SPARC with build-many-glibcs.py.

	[BZ #21457]
	* sysdeps/unix/sysv/linux/sparc/sys/ucontext.h (__ctx): New macro.
	[__WORDSIZE == 64] (MC_TSTATE): Define only for [__USE_MISC].
	[__WORDSIZE == 64] (MC_PC): Likewise.
	[__WORDSIZE == 64] (MC_NPC): Likewise.
	[__WORDSIZE == 64] (MC_Y): Likewise.
	[__WORDSIZE == 64] (MC_G1): Likewise.
	[__WORDSIZE == 64] (MC_G2): Likewise.
	[__WORDSIZE == 64] (MC_G3): Likewise.
	[__WORDSIZE == 64] (MC_G4): Likewise.
	[__WORDSIZE == 64] (MC_G5): Likewise.
	[__WORDSIZE == 64] (MC_G6): Likewise.
	[__WORDSIZE == 64] (MC_G7): Likewise.
	[__WORDSIZE == 64] (MC_O0): Likewise.
	[__WORDSIZE == 64] (MC_O1): Likewise.
	[__WORDSIZE == 64] (MC_O2): Likewise.
	[__WORDSIZE == 64] (MC_O3): Likewise.
	[__WORDSIZE == 64] (MC_O4): Likewise.
	[__WORDSIZE == 64] (MC_O5): Likewise.
	[__WORDSIZE == 64] (MC_O6): Likewise.
	[__WORDSIZE == 64] (MC_O7): Likewise.
	[__WORDSIZE == 64] (MC_NGREG): Rename to __MC_NGREG and define to
	__MC_NGREG if [__USE_MISC].
	[__WORDSIZE == 64] (MC_MAXFPQ): Define only for [__USE_MISC].
	[__WORDSIZE == 64] (mc_gregset_t): Define using __MC_NGREG.
	[__WORDSIZE == 64] (struct mc_fq): Rename to struct __mc_fq.
	Define fields using __ctx.
	[__WORDSIZE == 64] (mc_fpu_t): Remove struct tag.  Define fields
	using __ctx.
	[__WORDSIZE == 64] (mcontext_t): Define fields using __ctx.
	(REG_PSR): Define only for [__USE_MISC].
	(REG_PC): Likewise.
	(REG_nPC): Likewise.
	(REG_Y): Likewise.
	(REG_G1): Likewise.
	(REG_G2): Likewise.
	(REG_G3): Likewise.
	(REG_G4): Likewise.
	(REG_G5): Likewise.
	(REG_G6): Likewise.
	(REG_G7): Likewise.
	(REG_O0): Likewise.
	(REG_O1): Likewise.
	(REG_O2): Likewise.
	(REG_O3): Likewise.
	(REG_O4): Likewise.
	(REG_O5): Likewise.
	(REG_O6): Likewise.
	(REG_O7): Likewise.
	[__WORDSIZE == 64] (REG_ASI): Define only for [__USE_MISC].
	[__WORDSIZE == 64] (REG_FPRS): Likewise.
	(NGREG): Rename to __NGREG and define to __NGREG if [__USE_MISC].
	(gregset_t): Define using __NGREG.
	(SPARC_MAXREGWINDOW): Rename to __SPARC_MAXREGWINDOW and define to
	__SPARC_MAXREGWINDOW if [__USE_MISC].
	(struct rwindow): Rename to struct __rwindow.  Define fields using
	__ctx.
	(rw_fp): Define only for [__USE_MISC].
	(rw_rtn): Likewise.
	(gwindows_t): Remove struct tag.  Define fields using __ctx and
	__SPARC_MAXREGWINDOW.
	(MAXFPQ): Define only for [__USE_MISC].
	(struct fpq): Rename to struct __fpq.  Define fields using __ctx.
	(struct fq): Rename to struct __fq.  Define fields using __ctx.
	(FPU_REGS_TYPE): Define only for [__USE_MISC].
	(FPU_DREGS_TYPE): Likewise.
	(V7_FPU_FSR_TYPE): Likewise.
	(V9_FPU_FSR_TYPE): Likewise.
	(V9_FPU_FPRS_TYPE): Likewise.
	[__WORDSIZE == 64] (fpregset_t): Remove struct tag.  Define fields
	using __ctx.
	[__WORDSIZE != 64] (fpregset_t): Likewise.
	[__WORDSIZE != 64] (xrs_t): Define fields using __ctx.
	[__WORDSIZE != 64] (XRS_ID): Define only for [__USE_MISC].
	[__WORDSIZE != 64] (mcontext_t): Define fields using __ctx.
	Rename field filler to __glibc_reserved1.
	* sysdeps/unix/sysv/linux/sparc/sparc32/ucontext_i.sym
	(MC_FILLER): Remove.
2017-06-29 19:44:43 +00:00
Adhemerval Zanella ccfb296472 posix: Improve default posix_spawn implementation
This patch improves the default posix implementation of posix_spawn{p}
and align with Linux one.  The main idea is to fix some issues already
fixed in Linux code, and deprecated vfork internal usage (source of
various bug reports).  In a short:

   - It moves POSIX_SPAWN_USEVFORK usage and sets it a no-op.  Since
     the process that actually spawn the new process do not share
     memory with parent (with vfork), it fixes BZ#14750 for this
     implementation.

   - It uses a pipe to correctly obtain the return upon failure
     of execution (BZ#18433).

   - It correctly enable/disable asynchronous cancellation (checked
     on ptl/tst-exec5.c).

   - It correctly disable/enable signal handling.

Using this version instead of Linux shows only one regression,
posix/tst-spawn3, because of pipe2 usage which increase total
number of file descriptor.

	* sysdeps/posix/spawni.c (__spawni_child): New function.
	(__spawni): Rename to __spawnix.
2017-06-29 10:59:07 -03:00
Joseph Myers 073e8fa773 Require binutils 2.25 or later to build glibc.
This patch implements a requirement of binutils >= 2.25 (up from 2.22)
to build glibc.  Tests for 2.24 or later on x86_64 and s390 are
removed.  It was already the case, as indicated by buildbot results,
that 2.24 was too old for building tests for 32-bit x86 (produced
internal linker errors linking elf/tst-gnu2-tls1mod.so).  I don't know
if any configure tests for binutils features are obsolete given the
increased version requirement.

Tested for x86_64.

	* configure.ac (AS): Require binutils 2.25 or later.
	(LD): Likewise.
	* configure: Regenerated.
	* sysdeps/s390/configure.ac (AS): Remove version check.
	* sysdeps/s390/configure: Regenerated.
	* sysdeps/x86_64/configure.ac (AS): Remove version check.
	* sysdeps/x86_64/configure: Regenerated.
	* manual/install.texi (Tools for Compilation): Document
	requirement for binutils 2.25 or later.
	* INSTALL: Regenerated.
2017-06-28 11:31:50 +00:00
Joseph Myers d57cb31910 Miscellaneous sys/ucontext.h namespace fixes (bug 21457).
This patch fixes various miscellaneous namespace issues in
sys/ucontext.h headers.

Some struct tags are removed where the structs also have *_t typedef
names, while other struct tags without such names are renamed to start
__; the changes are noted in NEWS as they can affect C++ name mangling
(although there seems to be little if any external use of these types,
at least based on checking codesearch.debian.net).  For powerpc,
pointers to struct pt_regs (not defined in this header) are changed to
point to struct __ctx(pt_regs), so in the __USE_MISC case those struct
fields continue to point to the existing struct pt_regs type for
maximum compatibility, while when that's a namespace issue they point
to a struct __pt_regs type which is always an incomplete struct.

Tested for affected architectures with build-many-glibcs.py.

	[BZ #21457]
	* sysdeps/unix/sysv/linux/m68k/sys/ucontext.h (fpregset_t): Remove
	struct tag.
	* sysdeps/unix/sysv/linux/mips/sys/ucontext.h (fpregset_t):
	Likewise.
	* sysdeps/unix/sysv/linux/nios2/sys/ucontext.h (mcontext_t):
	Likewise.
	* sysdeps/unix/sysv/linux/powerpc/sys/ucontext.h (pt_regs):
	Declare struct type with __ctx.
	[__WORDSIZE != 32] (mcontext_t): Use __ctx with pt_regs struct
	tag.
	(ucontext_t) [__WORDSIZE == 32]: Use __ctx with pt_regs struct tag
	and regs field name.
2017-06-28 10:33:23 +00:00
Prakhar Bahuguna f8f72bc0c3 [ARM] Optimise memchr for NEON-enabled processors
This patch provides an optimised implementation of memchr using NEON
instructions to improve its performance, especially with longer search regions.
This gave an improvement in performance against the Thumb2+DSP optimised code,
with more significant gains for larger inputs. The NEON code also wins in cases
where the input is small (less than 8 bytes) by defaulting to a simple
byte-by-byte search. This avoids the overhead imposed by filling two quadword
registers from memory.

	* sysdeps/arm/armv7/multiarch/Makefile: Add memchr_neon to
	sysdep_routines.
	* sysdeps/arm/armv7/multiarch/ifunc-impl-list.c: Add define for
	__memchr_neon.
	Add ifunc definitions for __memchr_neon and __memchr_noneon.
	* sysdeps/arm/armv7/multiarch/memchr.S: New file.
	* sysdeps/arm/armv7/multiarch/memchr_impl.S: Likewise.
	* sysdeps/arm/armv7/multiarch/memchr_neon.S: Likewise.

Testing done: Ran regression tests for arm-none-linux-gnueabihf as well as a
full toolchain bootstrap. Benchmark tests were ran on ARMv7-A and ARMv8-A
hardware targets.
2017-06-27 15:43:50 +00:00
Stefan Liebler a37b5daa6b S390: Use cu21 instruction for converting from utf16 to utf8.
This patch adds an ifunc variant to use the cu instruction on arch12 CPUs.
This new ifunc variant can be built if binutils support z13 vector
instructions.  At runtime, HWCAP_S390_VXE decides if we can use the
cu21 instruction.

ChangeLog:

	* sysdeps/s390/utf8-utf16-z9.c (__to_utf8_loop_vx_cu):
	Use vector and cu21 instruction.
	* sysdeps/s390/multiarch/utf8-utf16-z9.c:
	Add __to_utf8_loop_vx_cu in ifunc resolver.
2017-06-27 17:09:43 +02:00
Stefan Liebler f0137ff31d S390: Use cu24 instruction for converting from utf16 to utf32.
This patch adds an ifunc variant to use the cu instruction on arch12 CPUs.
This new ifunc variant can be built if binutils support z13 vector
instructions.  At runtime, HWCAP_S390_VXE decides if we can use the
cu24 instruction.

ChangeLog:

	* sysdeps/s390/utf16-utf32-z9.c (__from_utf16_loop_vx_cu):
	Use vector and cu24 instruction.
    	* sysdeps/s390/multiarch/utf16-utf32-z9.c:
    	Add __from_utf16_loop_vx_cu in ifunc resolver.
2017-06-27 17:09:43 +02:00
Stefan Liebler 593e4da186 S390: Use cu42 instruction for converting from utf32 to utf16.
This patch adds an ifunc variant to use the cu instruction on arch12 CPUs.
This new ifunc variant can be built if binutils support z13 vector
instructions.  At runtime, HWCAP_S390_VXE decides if we can use the
cu42 instruction.

ChangeLog:

	* sysdeps/s390/utf16-utf32-z9.c (__to_utf16_loop_vx_cu):
	Use vector and cu42 instruction.
	* sysdeps/s390/multiarch/utf16-utf32-z9.c:
	Add __to_utf16_loop_vx_cu in ifunc resolver.
2017-06-27 17:09:43 +02:00
Stefan Liebler 23ea69a9d6 S390: Use cu41 instruction for converting from utf32 to utf8.
This patch adds an ifunc variant to use the cu instruction on arch12 CPUs.
This new ifunc variant can be built if binutils support z13 vector
instructions.  At runtime, HWCAP_S390_VXE decides if we can use the
cu41 instruction.

ChangeLog:

	* sysdeps/s390/utf8-utf32-z9.c (__to_utf8_loop_vx_cu):
	Use vector and cu41 instruction.
	* sysdeps/s390/multiarch/utf8-utf32-z9.c: Add __to_utf8_loop_vx_cu
	in ifunc resolver.
2017-06-27 17:09:42 +02:00
Stefan Liebler f21f59124d S390: Add new hwcap values for new cpu architecture - arch12.
The new hwcap values indicate support for:
- Vector packed decimal facility
- Vector enhancements facility 1
- Guarded storage facility

Note: arch12 is NOT the official name of the new CPU.
It refers to the edition number of the Principle of Operations manual.

ChangeLog:

	* sysdeps/s390/dl-procinfo.c (_dl_s390_cap_flags):
	Add vxd, vxe, gs flag.
	* sysdeps/s390/dl-procinfo.h: Add HWCAP_S390_VXD, HWCAP_S390_VXE,
	HWCAP_S390_GS capability.
	* sysdeps/unix/sysv/linux/s390/bits/hwcap.h
	(HWCAP_S390_VXD, HWCAP_S390_VXE, HWCAP_S390_GS): Define.
2017-06-27 17:09:42 +02:00
H.J. Lu e94c310357 x86-64: Optimize memcmp-avx2-movbe.S for short difference
Check the first 32 bytes before checking size when size >= 32 bytes
to avoid unnecessary branch if the difference is in the first 32 bytes.
Replace vpmovmskb/subl/jnz with vptest/jnc.

On Haswell, the new version is as fast as the previous one.  On Skylake,
the new version is a little bit faster.

	* sysdeps/x86_64/multiarch/memcmp-avx2-movbe.S (MEMCMP): Check
	the first 32 bytes before checking size when size >= 32 bytes.
	Replace vpmovmskb/subl/jnz with vptest/jnc.
2017-06-27 07:55:00 -07:00
Stefan Liebler 83653f804d S390: Save and restore r12 in TLS_IE macro.
The testcases elf/tst-tls1-static and elf/tst-tls2-static
are failing on s390 if gcc is configured with --enable-default-pie.

According to binutils, there are only four valid cases for IE -> LE transition:
lg %rx,(0,%ry)    -> sllg %rx,%ry,0
lg %rx,(%ry,0)    -> sllg %rx,%ry,0
lg %rx,(%ry,%r12) -> sllg %rx,%ry,0
lg %rx,(%r12,%ry) -> sllg %rx,%ry,0

Thus I've adjusted the TLS_IE macro in s390 tls-macros.h files in PIC case
in order to use r12 for the address of global offset table.
The adjusted macro definition is not used if gcc is not configured with
--enable-default-pie.

ChangeLog:

	* sysdeps/s390/s390-32/tls-macros.h (TLS_IE): Use r12 for GOT address.
	* sysdeps/s390/s390-64/tls-macros.h (TLS_IE): Likewise.
2017-06-27 15:23:43 +02:00
Florian Weimer e6b4e2de6d resolv: Call _res_hconf_init from __res_vinit
Many callers of __res_maybe_init also call _res_hconf_init.
Additional calls to the latter do not hurt because the function
does its work only once.  (/etc/hosts.conf is not reloaded or
even checked for changes.)  This means that we can simplify the
code by calling _res_hconf_init directly from __res_vinit.
2017-06-27 09:26:46 +02:00
Joseph Myers 034e738021 Add float128 support for ia64.
This patch enables float128 support for ia64, so that all the
configurations where GCC supports _Float128 / __float128 as an
ABI-distinct type now have glibc support as well.  bits/floatn.h
declares the support to be available for GCC 4.4 and later, which is
when the libgcc support was added.  The removal of
sysdeps/ia64/fpu/k_rem_pio2.c is because the generic k_rem_pio2.c
defines a function required by the float128 code.

Tested (compilation only) with build-many-glibcs.py for ia64 (GCC 6
and GCC 7).

Given how long it is since libm-test-ulps has been updated for ia64, I
think truncating the file and regenerating it from scratch would be a
good idea when doing a regeneration to add float128 ulps.  I expect
various ia64 libm issues (at least some already filed in Bugzilla) to
result in test failures even after ulps regeneration, but hopefully
the float128 code will pass tests as it's the same as used on other
architectures.

	* sysdeps/ia64/Implies: Add ieee754/float128.
	* sysdeps/ia64/bits/floatn.h: New file.
	* sysdeps/ia64/float128-abi.h: Likewise.
	* manual/math.texi (Mathematics): Document support for _Float128
	on ia64.
	* sysdeps/ia64/Makefile [$(subdir) = math] (CPPFLAGS): Append to
	Makefile variable.
	* sysdeps/ia64/fpu/e_sqrtf128.c: New file.
	* sysdeps/ia64/fpu/k_rem_pio2.c: Remove file.
	* sysdeps/ia64/fpu/sfp-machine.h: New file.  Based on libgcc.
	* sysdeps/ia64/math-tests.h: New file.
	* math/libm-test-support.h (XFAIL_FLOAT128_PAYLOAD): Also define
	based on TEST_COND_binary128 for [__ia64__].
	* sysdeps/unix/sysv/linux/ia64/libc.abilist: Update.
	* sysdeps/unix/sysv/linux/ia64/libm.abilist: Likewise,
2017-06-26 22:50:45 +00:00
Joseph Myers 251287734e Rename struct ucontext tag (bug 21457).
The ucontext_t type has a tag struct ucontext.  As with previous such
issues for siginfo_t and stack_t, this tag is not permitted by POSIX
(is not in a reserved namespace), and so namespace conformance means
breaking C++ name mangling for this type.

In this case, the type does need to have some tag rather than just a
typedef name, because it includes a pointer to itself.  This patch
uses struct ucontext_t as the new tag, so the type is mangled as
ucontext_t (the POSIX *_t reservation applies in all namespaces, not
just the namespace of ordinary identifiers).  Another reserved name
such as struct __ucontext could of course be used.

Because of other namespace issues, this patch does not by itself fix
bug 21457 or allow any XFAILs to be removed.

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

	[BZ #21457]
	* sysdeps/arm/sys/ucontext.h (struct ucontext): Rename to struct
	ucontext_t.
	* sysdeps/generic/sys/ucontext.h (struct ucontext): Likewise.
	* sysdeps/i386/sys/ucontext.h (struct ucontext): Likewise.
	* sysdeps/m68k/sys/ucontext.h (struct ucontext): Likewise.
	* sysdeps/mips/sys/ucontext.h (struct ucontext): Likewise.
	* sysdeps/unix/sysv/linux/aarch64/sys/ucontext.h (struct
	ucontext): Likewise.
	* sysdeps/unix/sysv/linux/alpha/sys/ucontext.h (struct ucontext):
	Likewise.
	* sysdeps/unix/sysv/linux/arm/sys/ucontext.h (struct ucontext):
	Likewise.
	* sysdeps/unix/sysv/linux/hppa/sys/ucontext.h (struct ucontext):
	Likewise.
	* sysdeps/unix/sysv/linux/ia64/sys/ucontext.h (struct ucontext):
	Likewise.
	* sysdeps/unix/sysv/linux/m68k/sys/ucontext.h (struct ucontext):
	Likewise.
	* sysdeps/unix/sysv/linux/mips/sys/ucontext.h (struct ucontext):
	Likewise.
	* sysdeps/unix/sysv/linux/nios2/sys/ucontext.h (struct ucontext):
	Likewise.
	* sysdeps/unix/sysv/linux/powerpc/sys/ucontext.h (struct
	ucontext): Likewise.
	* sysdeps/unix/sysv/linux/s390/sys/ucontext.h (struct ucontext):
	Likewise.
	* sysdeps/unix/sysv/linux/sh/sys/ucontext.h (struct ucontext):
	Likewise.
	* sysdeps/unix/sysv/linux/sparc/sys/ucontext.h (struct ucontext):
	Likewise.
	* sysdeps/unix/sysv/linux/tile/sys/ucontext.h (struct ucontext):
	Likewise.
	* sysdeps/unix/sysv/linux/x86/sys/ucontext.h (struct ucontext):
	Likewise.
	* sysdeps/powerpc/powerpc32/backtrace.c (struct
	rt_signal_frame_32): Likewise.
	* sysdeps/powerpc/powerpc64/backtrace.c (struct signal_frame_64):
	Likewise.
	* sysdeps/unix/sysv/linux/aarch64/kernel_rt_sigframe.h (struct
	kernel_rt_sigframe): Likewise.
	* sysdeps/unix/sysv/linux/aarch64/sigcontextinfo.h (SIGCONTEXT):
	Likewise.
	* sysdeps/unix/sysv/linux/arm/register-dump.h (register_dump):
	Likewise.
	* sysdeps/unix/sysv/linux/arm/sigcontextinfo.h (SIGCONTEXT):
	Likewise.
	* sysdeps/unix/sysv/linux/hppa/profil-counter.h
	(__profil_counter): Likewise.
	* sysdeps/unix/sysv/linux/microblaze/sigcontextinfo.h
	(SIGCONTEXT): Likewise.
	* sysdeps/unix/sysv/linux/mips/kernel_rt_sigframe.h (struct
	kernel_rt_sigframe): Likewise.
	* sysdeps/unix/sysv/linux/nios2/kernel_rt_sigframe.h (struct
	kernel_rt_sigframe): Likewise.
	* sysdeps/unix/sysv/linux/nios2/sigcontextinfo.h (SIGCONTEXT):
	Likewise.
	* sysdeps/unix/sysv/linux/sh/makecontext.S (__makecontext):
	Likewise.
	* sysdeps/unix/sysv/linux/sparc/sparc64/makecontext.c
	(__start_context): Likewise.
	* sysdeps/unix/sysv/linux/tile/sigcontextinfo.h (SIGCONTEXT):
	Likewise.
	* sysdeps/unix/sysv/linux/x86_64/register-dump.h (register_dump):
	Likewise.
	* sysdeps/unix/sysv/linux/x86_64/sigcontextinfo.h (SIGCONTEXT):
	Likewise.
2017-06-26 22:03:58 +00:00
Joseph Myers c86ed71d63 Add float128 support for x86_64, x86.
This patch enables float128 support for x86_64 and x86.  All GCC
versions that can build glibc provide the required support, but since
GCC 6 and before don't provide __builtin_nanq / __builtin_nansq, sNaN
tests and some tests of NaN payloads need to be disabled with such
compilers (this does not affect the generated glibc binaries at all,
just the tests).  bits/floatn.h declares float128 support to be
available for GCC versions that provide the required libgcc support
(4.3 for x86_64, 4.4 for i386 GNU/Linux, 4.5 for i386 GNU/Hurd);
compilation-only support was present some time before then, but not
really useful without the libgcc functions.

fenv_private.h needed updating to avoid trying to put _Float128 values
in registers.  I make no assertion of optimality of the
math_opt_barrier / math_force_eval definitions for this case; they are
simply intended to be sufficient to work correctly.

Tested for x86_64 and x86, with GCC 7 and GCC 6.  (Testing for x32 was
compilation tests only with build-many-glibcs.py to verify the ABI
baseline updates.  I have not done any testing for Hurd, although the
float128 support is enabled there as for GNU/Linux.)

	* sysdeps/i386/Implies: Add ieee754/float128.
	* sysdeps/x86_64/Implies: Likewise.
	* sysdeps/x86/bits/floatn.h: New file.
	* sysdeps/x86/float128-abi.h: Likewise.
	* manual/math.texi (Mathematics): Document support for _Float128
	on x86_64 and x86.
	* sysdeps/i386/fpu/fenv_private.h: Include <bits/floatn.h>.
	(math_opt_barrier): Do not put _Float128 values in floating-point
	registers.
	(math_force_eval): Likewise.
	[__x86_64__] (SET_RESTORE_ROUNDF128): New macro.
	* sysdeps/x86/fpu/Makefile [$(subdir) = math] (CPPFLAGS): Append
	to Makefile variable.
	* sysdeps/x86/fpu/e_sqrtf128.c: New file.
	* sysdeps/x86/fpu/sfp-machine.h: Likewise.  Based on libgcc.
	* sysdeps/x86/math-tests.h: New file.
	* math/libm-test-support.h (XFAIL_FLOAT128_PAYLOAD): New macro.
	* math/libm-test-getpayload.inc (getpayload_test_data): Use
	XFAIL_FLOAT128_PAYLOAD.
	* math/libm-test-setpayload.inc (setpayload_test_data): Likewise.
	* math/libm-test-totalorder.inc (totalorder_test_data): Likewise.
	* math/libm-test-totalordermag.inc (totalordermag_test_data):
	Likewise.
	* sysdeps/unix/sysv/linux/i386/libc.abilist: Update.
	* sysdeps/unix/sysv/linux/i386/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/x86_64/64/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/x86_64/64/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/x86_64/x32/libm.abilist: Likewise.
	* sysdeps/i386/fpu/libm-test-ulps: Likewise.
	* sysdeps/i386/i686/fpu/multiarch/libm-test-ulps: Likewise.
	* sysdeps/x86_64/fpu/libm-test-ulps: Likewise.
2017-06-26 22:02:24 +00:00
Adhemerval Zanella 3f823e87cc Call exit directly in clone (BZ #21512)
On aarch64, alpha, arm, hppa, mips, nios2, powerpc, sh, sparc, tile,
and x86_64 the clone syscall jumps to _exit after the child execution
and the function ends the process execution by calling exit_group.
This behavior have a small issue where threads created with
CLONE_THREAD using clone syscall directly will eventually exit the
whole group altogether instead of just the thread created.  Also,
s390, microblaze, ia64, i386, and m68k differs by calling exit
syscall directly.

This patch changes all architectures to call the exit syscall
directly, as for s390, microblaze, ia64, i386, and m68k.  This do not
have change glibc internal behavior in any sort, since the only
usage of clone implementation in posix_spawn calls _exit directly
in the created child (fork uses a direct call to clone).

Checked on x86_64-linux-gnu, i686-linux-gnu, aarch64-linux-gnu,
powerpc-linux-gnu, powerpc64le-linux-gnu, sparc64-linux-gnu,
and sparcv9-linux-gnu.

	[BZ #21512]
	* sysdeps/unix/sysv/linux/aarch64/clone.S (__clone): Call exit
	syscall instead of jump to _exit.
	(CLONE_VM_BIT): Remove unused define.
	(CLONE_VM): Likewise.
	(CLONE_THREAD_BIT): Likewise.
	(CLONE_THREAD): Likewise.
	* sysdeps/unix/sysv/linux/alpha/clone.S (__clone): Likewise.
	(CLONE_VM): Remove unused define.
	* sysdeps/unix/sysv/linux/arm/clone.S (__clone): Likewise.
	(CLONE_VM): Remove unused define.
	(CLONE_THREAD): Likewise.
	* sysdeps/unix/sysv/linux/i386/clone.S (CLONE_VM): Likewise.
	* sysdeps/unix/sysv/linux/ia64/clone2.S (__clone2): Call exit
	syscall instead of jump to _exit.
	* sysdeps/unix/sysv/linux/hppa/clone.S (__clone): Likewise.
	* sysdeps/unix/sysv/linux/mips/clone.S (__clone): Likewise.
	(CLONE_VM): Remove unused define.
	(CLONE_THREAD): Likewise.
	* sysdeps/unix/sysv/linux/nios2/clone.S (__clone): Likewise.
	(CLONE_VM): Remove unused define.
	* sysdeps/unix/sysv/linux/powerpc/powerpc32/clone.S (__clone):
	Likewise.
	(CLONE_VM): Remove unused define.
	(CLONE_THREAD): Likewise.
	* sysdeps/unix/sysv/linux/powerpc/powerpc64/clone.S (__clone):
	Likewise.
	(CLONE_VM): Remove unused define.
	(CLONE_THREAD): Likewise.
	* sysdeps/unix/sysv/linux/sh/clone.S  (__clone): Likewise.
	* sysdeps/unix/sysv/linux/sparc/sparc32/clone.S (__clone): Likewise.
	(CLONE_VM): Remove unused define.
	* sysdeps/unix/sysv/linux/sparc/sparc64/clone.S (__clone): Likewise.
	(CLONE_VM): Remove unused define.
	* sysdeps/unix/sysv/linux/tile/clone.S (__clone): Likewise.
	* sysdeps/unix/sysv/linux/x86_64/clone.S (__clone): Likewise.
	(CLONE_VM): Remove unused define.
	* sysdeps/unix/sysv/linux/Makefile (tests): Add tst-clone3.
	* sysdeps/unix/sysv/linux/tst-clone3.c: New file.

Fix
2017-06-26 17:52:20 -03:00
Paul E. Murphy f819dbea0a powerpc64le: Enable float128
This patch adds ULPs for the float128 type, updates the abilist for libc
and libm, and adds the files bits/floatn.h and float128-abi.h, in order to
enable the new type for powerpc64le.

This patch also adds the implementation of sqrtf128 for powerpc64le, since
it is not implemented in libgcc.  The sfp-machine.h header is taken from
libgcc.

Tested for powerpc64le (GCC 6.2 and GCC 7.1), powerpc64 and s390x.

	* manual/math.texi (Mathematics): Mention the enabling of float128
	for powerpc64le.
	* sysdeps/powerpc/bits/floatn.h: New file.
	* sysdeps/powerpc/fpu/libm-test-ulps: Regenerated.
	* sysdeps/powerpc/fpu/math_private.h:
	(__ieee754_sqrtf128): New inline override.
	* sysdeps/powerpc/powerpc64le/Implies-before: New file.
	* sysdeps/powerpc/powerpc64le/Makefile: New file.
	* sysdeps/powerpc/powerpc64le/fpu/e_sqrtf128.c: New file.
	* sysdeps/powerpc/powerpc64le/fpu/sfp-machine.h: New file.
	* sysdeps/powerpc/powerpc64le/power9/fpu/e_sqrtf128.c: New file.
	* sysdeps/unix/sysv/linux/powerpc/powerpc64/libc-le.abilist:
	Updated.
	* sysdeps/unix/sysv/linux/powerpc/powerpc64/libm-le.abilist:
	Likewise.
	* sysdeps/unix/sysv/linux/powerpc/powerpc64le/float128-abi.h:
	New file.
2017-06-26 15:04:47 -03:00
Gabriel F. T. Gomes a27d2c1935 powerpc64le: Require at least POWER8 for powerpc64le
Support for powerpc64le requires POWER8 or newer processors.  Builds for
older processors are not tested.  Require at least POWER8 to avoid
unintentional builds.

	* sysdeps/powerpc/powerpc64le/configure.ac: Check for POWER8.
	* sysdeps/powerpc/powerpc64le/configure: Update.
2017-06-26 15:00:34 -03:00
Gabriel F. T. Gomes 4efe3ce400 powerpc64le: Check for compiler features for float128
On powerpc64le, support for float128 will be enabled, which requires some
compiler features to be present.  This patch adds a configure test to check
for such features, which are provided for powerpc64le since GCC 6.2.

Tested for powerpc64 and powerpc64le.

	* INSTALL: Regenerate.
	* manual/install.texi (Recommended Tools for Compilation): Mention
	the powerpc64le-specific requirement in the manual.
	* sysdeps/powerpc/powerpc64le/configure.ac: New file with checks
	for the compiler features required for building float128.
	* sysdeps/powerpc/powerpc64le/configure: New, auto-generated file.
2017-06-26 14:58:47 -03:00
Dmitry Bilunov 5cf88a83f2 getaddrinfo: Merge IPv6 addresses and IPv4 addresses [BZ #21295] 2017-06-24 16:50:42 +02:00
Adhemerval Zanella fa872e1b62 Clean pthread functions namespaces for C11 threads
This patch adds internal definition (through {libc_}hidden_{proto,def}) and
also change some strong to weak alias for symbols that might be used by C11
threads implementations.

The patchset should not change libc/libpthread functional, although object
changes are expected (since now internal symbols are used instead) and final
exported symbols through GLIBC_PRIVATE is also expanded (to cover libpthread
usage of __mmap{64}, __munmap, __mprotect).

Checked with a build for all major ABI (aarch64-linux-gnu, alpha-linux-gnu,
arm-linux-gnueabi, i386-linux-gnu, ia64-linux-gnu, m68k-linux-gnu,
microblaze-linux-gnu [1], mips{64}-linux-gnu, nios2-linux-gnu,
powerpc{64le}-linux-gnu, s390{x}-linux-gnu, sparc{64}-linux-gnu,
tile{pro,gx}-linux-gnu, and x86_64-linux-gnu).

	* include/sched.h (__sched_get_priority_max): Add libc hidden proto.
	(__sched_get_prioriry_min): Likewise.
	* include/sys/mman.h (__mmap): Likewise.
	(__mmap64): Likewise.
	(__munmap): Likewise.
	(__mprotect): Likewise.
	* include/termios.h (__tcsetattr): Likewise.
	* include/time.h (__nanosleep): Use hidden_proto instead of
	libc_hidden_proto.
	* posix/nanosleep.c (__nanosleep): Likewise.
	* misc/Versions (libc): Export __mmap, __munmap, __mprotect,
	__sched_get_priority_min, and __sched_get_priority_max under
	GLIBC_PRIVATE.
	* nptl/allocatestack.c (__free_stacks): Use internal definition for
	libc symbols.
	(change_stack_perm): Likewise.
	(allocate_stack): Likewise.
	* sysdeps/posix/gethostname.c: Likewise.
	* nptl/tpp.c (__init_sched_fifo_prio): Likewise.
	* sysdeps/unix/sysv/linux/i386/smp.h (is_smp_system): Likewise.
	* sysdeps/unix/sysv/linux/powerpc/ioctl.c (__ioctl): Likewise.
	* nptl/pthreadP.h (__pthread_mutex_timedlock): Add definition.
	(__pthread_key_delete): Likewise.
	(__pthread_detach): Likewise.
	(__pthread_cancel): Likewise.
	(__pthread_mutex_trylock): Likewise.
	(__pthread_mutexattr_init): Likewise.
	(__pthread_mutexattr_settype): Likewise.
	* nptl/pthread_cancel.c (pthread_cancel): Change to internal name and
	create alias for exported one.
	* nptl/pthread_join.c (pthread_join): Likewise.
	* nptl/pthread_detach.c (pthread_detach): Likewise.
	* nptl/pthread_key_delete.c (pthread_key_delete): Likewise.
	* nptl/pthread_mutex_timedlock.c (pthread_mutex_timedlock): Likewise.
	* nptl/pthread_create.c: Change static requirements for pthread
	symbols.
	* nptl/pthread_equal.c (__pthread_equal): Change strong alias to weak
	for internal definition.
	* nptl/pthread_exit.c (__pthread_exit): Likewise.
	* nptl/pthread_getspecific.c (__pthread_getspecific): Likewise.
	* nptl/pthread_key_create.c (__pthread_key_create): Likewise.
	* nptl/pthread_mutex_destroy.c (__pthread_mutex_destroy): Likewise.
	* nptl/pthread_mutex_init.c (__pthread_mutex_init): Likewise.
	* nptl/pthread_mutex_lock.c (__pthread_mutex_lock): Likewise.
	* nptl/pthread_mutex_trylock.c (__pthread_mutex_trylock): Likewise.
	* nptl/pthread_mutex_unlock.c (__pthread_mutex_unlock): Likewise.
	* nptl/pthread_mutexattr_init.c (__pthread_mutexattr_init): Likwise.
	* nptl/pthread_mutexattr_settype.c (__pthread_mutexattr_settype):
	Likewise.
	* nptl/pthread_self.c (__pthread_self): Likewise.
	* nptl/pthread_setspecific.c (__pthread_setspecific): Likewise.
	* sysdeps/unix/sysv/linux/tcsetattr.c (tcsetattr): Likewise.
	* misc/mmap.c (__mmap): Add internal symbol definition.
	* misc/mmap.c (__mmap64): Likewise.
	* sysdeps/unix/sysv/linux/mmap.c (__mmap): Likewise.
	* sysdeps/unix/sysv/linux/mmap64.c (__mmap): Likewise.
	(__mmap64): Likewise.
	* sysdeps/unix/sysv/linux/i386/Versions (libc) [GLIBC_PRIVATE):
	Add __uname.
2017-06-23 17:38:17 -03:00
Joseph Myers 06a5b8f799 Update x86 ulps for GCC 7.
Testing with GCC 7 for 32-bit x86 showed some ulps differences,
presumably from variation in when values with excess precision get
spilled to the stack and so lose that precision.  This patch updates
the libm-test-ulps files accordingly.

	* sysdeps/i386/fpu/libm-test-ulps: Update.
	* sysdeps/i386/i686/fpu/multiarch/libm-test-ulps: Likewise.
2017-06-23 20:23:26 +00:00
Joseph Myers 16000c8d04 Avoid localplt issues from x86 fereaiseexcept inline.
Building for x86_64 with float128 support, I get a localplt test
failure from lrintf128 calling feraiseexcept.

The problem is that an inline optimized version of feraiseexcept calls
__feraiseexcept_renamed in cases where it doesn't completely expand
inline, and that in turn is redirected to feraiseexcept for a library
call, so meaning the redirection of feraiseexcept to
__GI_feraiseexcept inside libm is lost for that call.

This patch fixes the problem by moving the redirect to an internal
header in the _LIBC case, with the internal header using
__GI_feraiseexcept where appropriate.

Tested for x86_64 (in conjunction with float128 patches).

	* sysdeps/x86/fpu/bits/fenv.h [_LIBC] (__feraiseexcept_renamed):
	Do not declare.
	* sysdeps/x86/fpu/include/bits/fenv.h [_LIBC &&
	__USE_EXTERN_INLINES] (__feraiseexcept_renamed): Declare here,
	redirected to __GI_feraiseexcept if [SHARED && IS_IN (libm)].
2017-06-23 20:04:23 +00:00
H.J. Lu 049816c3be x86-64: Optimize L(between_2_3) in memcmp-avx2-movbe.S
Turn

	movzbl	-1(%rdi, %rdx), %edi
	movzbl	-1(%rsi, %rdx), %esi
	orl	%edi, %eax
	orl	%esi, %ecx

into

	movb	-1(%rdi, %rdx), %al
	movb	-1(%rsi, %rdx), %cl

	* sysdeps/x86_64/multiarch/memcmp-avx2-movbe.S (between_2_3):
	Replace movzbl and orl with movb.
2017-06-23 12:46:12 -07:00
Florian Weimer bc0382ae90 x86-64: Fix comment typo in memcmp-avx2-movbe.S 2017-06-23 19:00:58 +02:00
Florian Weimer 3ec7c02cc3 x86-64: memcmp-avx2-movbe.S needs saturating subtraction [BZ #21662]
This code:

L(between_2_3):
	/* Load as big endian with overlapping loads and bswap to avoid
	   branches.  */
	movzwl	-2(%rdi, %rdx), %eax
	movzwl	-2(%rsi, %rdx), %ecx
	shll	$16, %eax
	shll	$16, %ecx
	movzwl	(%rdi), %edi
	movzwl	(%rsi), %esi
	orl	%edi, %eax
	orl	%esi, %ecx
	bswap	%eax
	bswap	%ecx
	subl	%ecx, %eax
	ret

needs a saturating subtract because the full register is used.
With this commit, only the lower 24 bits of the register are used,
so a regular subtraction suffices.

The test case change adds coverage for these kinds of bugs.
2017-06-23 17:24:40 +02:00
Gabriel F. T. Gomes 7fa1d9462b Add libio-mtsafe flags to the build of strfromf128
Similar to the other functions in the strfrom class, strfromf128 calls
__printf_fp in order to convert the floating-point value to characters.
This requires the value of IO_MTSAFE_IO.

Tested for powerpc64le and s390x.

	* sysdeps/ieee754/float128/Makefile (CFLAGS-strfromf128.c): Add
	$(libio-mtsafe) to get the value of IO_MTSAFE_IO.
2017-06-23 10:31:49 -03:00
Paul Clarke c340290de8 Optimized version of powf()
Most significant changes are code simplification and use of doubles for
intermediate values.  Also, some rearrangement to move early
non-dependent code later, out of the faster paths.

	* sysdeps/ieee754/flt-32/e_powf.c: Optimized implementation utilizing
	rearranged code and doubles float types.
2017-06-23 09:19:17 -03:00
Rogerio A. Cardoso 76c4c838e7 powerpc: Fix sinf() IFUNC fallback.
sysdeps/powerpc/powerpc64/fpu/multiarch/s_sinf-ppc64.c should fall back to
sysdeps/powerpc/fpu/s_sinf.c not to sysdeps/ieee754/flt-32/s_sinf.c.

	* sysdeps/powerpc/powerpc64/fpu/multiarch/s_sinf-ppc64.c: Change
	s_sinf.c from sysdeps/ieee754/flt-32/ to sysdeps/powerpc/fpu/.
2017-06-23 09:19:00 -03:00
Paul Clarke 1301c20f6c powerpc: fix sysconf support for cache geometries
Commit cdfbe5037f added sysconf support
for cache geometries on powerpc, but mishandled errno.  For valid input
parameters, sysconf() should not set errno.

	* sysdeps/unix/sysv/linux/powerpc/sysconf.c: Remove references
	to errno, and simplify remaining related code.
2017-06-23 09:10:32 -03:00
Tulio Magno Quites Machado Filho 7dcdfbcf67 powerpc: Update AT_HWCAP[2] bits
Linux commit ID a4700a26107241cc7b9ac8528b2c6714ff99983d reserved 2 more
bits for the instructions darn (Deliver a Random Number) and scv (System
Call Vectored).

Linux commit ID 6997e57d693b07289694239e52a10d2f02c3a46f reserved
another bit for internal usage.

	* sysdeps/powerpc/bits/hwcap.h: Add PPC_FEATURE2_DARN and
	PPC_FEATURE2_SCV.
	* sysdeps/powerpc/dl-procinfo.c (_dl_powerpc_cap_flags): Add scv
	and darn.
2017-06-23 09:10:32 -03:00
Rajalakshmi Srinivasaraghavan 12f50337ae powerpc: refactor strrchr IFUNC
As done in commit 6d15a5c2e9
clean up IFUNC implementation for power8 in order to remove
unneeded macro definitions.
2017-06-23 11:24:30 +05:30
Rajalakshmi Srinivasaraghavan 001b09a6a2 powerpc: Add optimized version of [l]lroundf
This patch makes use of optimized double version of llround for single
precision as both the versions return [long] long type.
2017-06-23 10:43:31 +05:30
Joseph Myers c271ff9469 Support _Float128 in ldbl-96 bits/iscanonical.h.
This patch adds _Float128 support to the ldbl-96 bits/iscanonical.h,
as needed for x86_64 / x86 / ia64 support of _Float128.

Tested for x86_64 (in conjunction with float128 patches).

	* sysdeps/ieee754/ldbl-96/bits/iscanonical.h
	[__HAVE_DISTINCT_FLOAT128] (__iscanonicalf128): New macro.
2017-06-22 23:06:41 +00:00
Joseph Myers 8d375dafe2 Support _Float128 in math-tests.h.
This patch makes math-tests.h, as used to describe support of given
floating-point types for sNaNs, rounding modes and exceptions, handle
distinguishing _Float128 from long double.  This is needed for x86_64,
where if building with GCC 6 or earlier there is no __builtin_nansq,
so no way to get a signaling NaN of _Float128 type, so associated
tests cannot be run (although glibc itself works fine, as there is
never any need to create such an sNaN with a built-in function inside
glibc).

Tested for x86_64 (in conjunction with float128 patches).

	* sysdeps/generic/math-tests.h: Include <bits/floatn.h>.
	(MATH_TESTS_TG): New macro.
	(SNAN_TESTS_float128): Likewise.
	(ROUNDING_TESTS_float128): Likewise.
	(EXCEPTION_TESTS_float128): Likewise.
	(SNAN_TESTS): Define using MATH_TESTS_TG.
	(ROUNDING_TESTS): Likewise.
	(EXCEPTION_TESTS): Likewise.
2017-06-22 23:03:38 +00:00
Joseph Myers f20079d219 Fix float128_private.h redefinition of SET_RESTORE_ROUNDL.
As with other long double identifiers, float128_private.h has a
redefinition of SET_RESTORE_ROUNDL.  However, that redefinition is
broken, since this is a macro with one argument being defined to take
no arguments.  This patch fixes the redefinition.  (x86_64 needs the
redefinition because SET_RESTORE_ROUNDL only changes the x87 rounding
mode, whereas _Float128 arithmetic uses the SSE rounding mode instead
on x86_64.)

Tested for x86_64 (in conjunction with float128 patches).

	* sysdeps/ieee754/float128/float128_private.h
	[SET_RESTORE_ROUNDF128] (SET_RESTORE_ROUNDL): Take an argument and
	pass it to SET_RESTORE_ROUNDF128.
2017-06-22 22:57:28 +00:00
Joseph Myers db7a548d02 Make float128_private.h work with generic ieee754.h.
float128_private.h redefines ieee754.h identifiers ieee854_long_double
and IEEE854_LONG_DOUBLE_BIAS to map them to identifiers from
ieee754_float128.h.

This causes problems when ieee754.h is included after
float128_private.h and it's a version of ieee754.h that also defines
those identifiers; specifically, sysdeps/ieee754/ieee754.h, which
defines those identifiers for the x86 extended format.  This patch
fixes this by ensuring an include of ieee754.h from float128_private.h
before the redefinitions.

Tested for x86_64 (in conjunction with float128 patches).

	* sysdeps/ieee754/float128/float128_private.h: Include
	<ieee754.h>.
2017-06-22 22:53:01 +00:00
Joseph Myers d08cdabdd0 Correct min_of_type handling of _Float128.
The math_private.h macro min_of_type has broken _Float128 handling:
instead of passing its type argument to the key __EXPR_FLT128 macro,
it passes x, which is not a macro argument but whatever variable
called x happens to be visible in the calling function.  If that
variable has the wrong type, the wrong one of long double and
_Float128 can get chosen.  In particular, this applies to some
_Complex long double functions (where x happens to have type _Complex
long double, resulting in min_of_type returning a _Float128 value when
it should return a long double value).  For some reason, this only
caused test failures for me on x86_64 with GCC 6 but not GCC 7 (I
suspect it triggers known bugs in conversions from x86 long double to
_Float128 that are present in GCC 6's soft-fp).

Tested for x86_64 (in conjunction with float128 patches).

	* sysdeps/generic/math_private.h (__EXPR_FLT128): Do not apply
	typeof to argument passed to __builtin_types_compatible_p.
	(min_of_type): Pass type argument, not x, to __EXPR_FLT128.
2017-06-22 22:46:27 +00:00
Joseph Myers 33711da4e9 Fix float128 uses of xlocale.h.
Three float128 files still include xlocale.h after it was removed.  I
don't know why this didn't cause problems for powerpc64le float128
testing; it did cause problems for my x86_64 float128 testing.  This
patch changes the includes to use bits/types/locale_t.h.

Tested for x86_64 (in conjunction with float128 patches).

	* sysdeps/ieee754/float128/strtof128_l.c: Include
	<bits/types/locale_t.h> instead of <xlocale.h>.
	* sysdeps/ieee754/float128/wcstof128.c: Likewise.
	* sysdeps/ieee754/float128/wcstof128_l.c: Likewise.
2017-06-22 22:34:49 +00:00
H.J. Lu 11ffcacb64 x86-64: Implement strcmp family IFUNC selectors in C
Implement strcmp family IFUNC selectors in C.

All internal calls within libc.so can use IFUNC on x86-64 since unlike
x86, x86-64 supports PC-relative addressing to access the GOT entry so
that it can call via PLT without using an extra register.  For libc.a,
we can't use IFUNC for functions which are called before IFUNC has been
initialized.  Use IFUNC internally reduces the icache footprint since
libc.so and other codes in the process use the same implementations.
This patch uses IFUNC for strcmp family functions within libc.

	* sysdeps/x86_64/multiarch/Makefile (sysdep_routines): Add
	strcmp-sse2, strcmp-sse4_2, strncmp-sse2, strncmp-sse4_2,
	strcasecmp_l-sse2, strcasecmp_l-sse4_2, strcasecmp_l-avx,
	strncase_l-sse2, strncase_l-sse4_2 and strncase_l-avx.
	* sysdeps/x86_64/multiarch/ifunc-strcasecmp.h: New file.
	* sysdeps/x86_64/multiarch/strcasecmp.c: Likewise.
	* sysdeps/x86_64/multiarch/strcasecmp_l-avx.S: Likewise.
	* sysdeps/x86_64/multiarch/strcasecmp_l-sse2.S: Likewise.
	* sysdeps/x86_64/multiarch/strcasecmp_l-sse4_2.S: Likewise.
	* sysdeps/x86_64/multiarch/strcasecmp_l.c: Likewise.
	* sysdeps/x86_64/multiarch/strcmp-sse2.S: Likewise.
	* sysdeps/x86_64/multiarch/strcmp-sse4_2.S: Likewise.
	* sysdeps/x86_64/multiarch/strcmp.c: Likewise.
	* sysdeps/x86_64/multiarch/strncase.c: Likewise.
	* sysdeps/x86_64/multiarch/strncase_l-avx.S : Likewise.
	* sysdeps/x86_64/multiarch/strncase_l-sse2.S: Likewise.
	* sysdeps/x86_64/multiarch/strncase_l-sse4_2.S: Likewise.
	* sysdeps/x86_64/multiarch/strncase_l.c: Likewise.
	* sysdeps/x86_64/multiarch/strncmp-sse2.S: Likewise.
	* sysdeps/x86_64/multiarch/strncmp-sse4_2.S: Likewise.
	* sysdeps/x86_64/multiarch/strncmp.c: Likewise.
	* sysdeps/x86_64/multiarch/strcasecmp_l.S: Removed.
	* sysdeps/x86_64/multiarch/strcmp.S: Likewise.
	* sysdeps/x86_64/multiarch/strncase_l.S: Likewise.
	* sysdeps/x86_64/multiarch/strncmp.S: Likewise.
	* sysdeps/x86_64/multiarch/strcmp-sse42.S: Include <sysdep.h>.
	(STRCMP_SSE42): New.  Defined to __strcmp_sse42 if not defined.
	[USE_AS_STRCASECMP_L || USE_AS_STRNCASECMP_L]: Include
	"locale-defines.h".
	(UPDATE_STRNCMP_COUNTER): New.
	(SECTION): Likewise.
	(GLABEL): Likewise.
	(LABEL): Likewise.
	* sysdeps/x86_64/multiarch/strncmp-ssse3.S: Rewrite and enable
	for libc.a.
2017-06-21 12:11:06 -07:00
Joseph Myers 9649350d2e Fix tile SA_* conditions for POSIX.1:2008 (bug 21622).
As shown by conform/ tests once the remaining namespace issues are
fixed, the tile bits/sigaction.h fails to declare SA_RESETHAND,
SA_RESTART and SA_NODEFER for non-XSI POSIX.1:2008 as other versions
do.  Those constants were moved from XSI to Base in the 2008 edition
of POSIX.  This patch fixes the conditions to match other versions of
this header.

Tested (compilation only) for tilegx-linux-gnu with
build-many-glibcs.py.

	[BZ #21622]
	* sysdeps/unix/sysv/linux/tile/bits/sigaction.h (SA_RESTART):
	Define for [__USE_UNIX98 || __USE_XOPEN2K8], not [__USE_UNIX98 ||
	__USE_MISC].
	(SA_NODEFER): Likewise.
	(SA_RESETHAND): Likewise.
2017-06-21 17:35:24 +00:00
H.J. Lu 03feacb562 x86: Rename glibc.tune.ifunc to glibc.tune.hwcaps
Rename glibc.tune.ifunc to glibc.tune.hwcaps and move it to
sysdeps/x86/dl-tunables.list since it is x86 specicifc.  Also
change type of data_cache_size, data_cache_size and
non_temporal_threshold to unsigned long int to match size_t.
Remove usage DEFAULT_STRLEN from cpu-tunables.c.

	* elf/dl-tunables.list (glibc.tune.ifunc): Removed.
	* sysdeps/x86/dl-tunables.list (glibc.tune.hwcaps): New.
	Remove security_level on all fields.
	* manual/tunables.texi: Replace ifunc with hwcaps.
	* sysdeps/x86/cpu-features.c (TUNABLE_CALLBACK (set_ifunc)):
	Renamed to ..
	(TUNABLE_CALLBACK (set_hwcaps)): This.
	(init_cpu_features): Updated.
	* sysdeps/x86/cpu-features.h (cpu_features): Change type of
	data_cache_size, data_cache_size and non_temporal_threshold to
	unsigned long int.
	* sysdeps/x86/cpu-tunables.c (DEFAULT_STRLEN): Removed.
	(TUNABLE_CALLBACK (set_ifunc)): Renamed to ...
	(TUNABLE_CALLBACK (set_hwcaps)): This.  Update comments.  Don't
	use DEFAULT_STRLEN.
2017-06-21 10:21:37 -07:00
Szabolcs Nagy e535139e82 [AArch64] Add more cfi annotations to tlsdesc entry points
Backtrace through _dl_tlsdesc_resolve_rela was broken because the offset
of x30 from cfa was not in the debug info.

Add enough annotation so backtracing from the dynamic linker through
tlsdesc entry points works and the debugger shows registers correctly.
2017-06-21 15:04:37 +01:00
Szabolcs Nagy e9177fba13 [AArch64] Use hidden __GI__dl_argv in rtld startup code
We rely on the symbol being locally defined so using extern symbol
is not correct and the linker may complain about the relocations.
2017-06-21 14:54:11 +01:00
Florian Weimer 76b8266f99 getaddrinfo: Avoid stack copy of IPv6 address 2017-06-21 13:35:37 +02:00
Rajalakshmi Srinivasaraghavan 43e0ac24c8 powerpc: Optimize memchr for power8
Vectorized loops are used for sizes greater than 32B to improve
performance over power7 optimiztion.
2017-06-21 10:55:12 +05:30
Rajalakshmi Srinivasaraghavan 99c3eb0f73 powerpc: Add optimized version of [l]lrintf
This patch makes use of optimized double version of llrint for single
precision as both the versions return [long] long type.
2017-06-21 10:44:18 +05:30
Zack Weinberg 8082d91e1c Factor out shared definitions from bits/signum.h.
Many of the things defined by bits/signum.h are invariant across all
supported operating systems.  This patch factors out all of them to a
new header bits/signum-generic.h, which each bits/signum.h will include
and then override whichever things need adjustment.  Normally that will
mean, at most, adding or changing a few signal numbers.

A user-visible side effect is that the obsolete signal constant SIGUNUSED
(which is an alias for SIGSYS on all platforms that define it) is no
longer exposed by any version of bits/signum.h.

A side effect only relevant to glibc hackers is that _NSIG is now defined
in terms of __SIGRTMAX, instead of the other way around.  This is because
__SIGRTMAX varies from platform to platform, but _NSIG==__SIGRTMAX+1 is
true universally.  If your platform doesn't support realtime signals,
leave __SIGRTMAX equal to __SIGRTMIN.

I also added a Linux-specific test to make sure that our signal constants
match the ones in <asm/signal.h>, since we can't use that header (it's
not even vaguely namespace-clean).

	* bits/signum-generic.h: Renamed from bits/signum.h.
	Add proper multiple include guard and misuse check.
	Define __SIGRTMIN = __SIGRTMAX = 32, and define _NSIG = __SIGRTMAX+1.
	Move definition of SIGIO to "archaic names for compatibility" section.
	* bits/signum.h: New file which just includes bits/signum-generic.h.
	* sysdeps/unix/bsd/bits/signum.h
	* sysdeps/unix/sysv/linux/bits/signum.h
	* sysdeps/unix/sysv/linux/alpha/bits/signum.h
	* sysdeps/unix/sysv/linux/hppa/bits/signum.h
	* sysdeps/unix/sysv/linux/mips/bits/signum.h
	* sysdeps/unix/sysv/linux/sparc/bits/signum.h
	Just include <bits/signum-generic.h> and then add or adjust
	signal constants.  Do not define SIGUNUSED, SIGRTMIN, or SIGRTMAX.

	* signal/Makefile: Install bits/signum-generic.h.
	* signal/signal.h: Define SIGRTMIN and SIGRTMAX here.

	* sysdeps/generic/siglist.h: SIGSYS and SIGWINCH are
	universal.  Prefer SIGPOLL to SIGIO. Simplify #ifdeffage.

	* sysdeps/unix/sysv/linux/tst-signal-numbers.sh: New test.
	* sysdeps/unix/sysv/linux/Makefile: Run it.
2017-06-20 20:32:50 -04:00
Zack Weinberg af85385f31 Use locale_t, not __locale_t, throughout glibc
<locale.h> is specified to define locale_t in POSIX.1-2008, and so are
all of the headers that define functions that take locale_t arguments.
Under _GNU_SOURCE, the additional headers that define such functions
have also always defined locale_t.  Therefore, there is no need to use
__locale_t in public function prototypes, nor in any internal code.

	* ctype/ctype-c99_l.c, ctype/ctype.h, ctype/ctype_l.c
	* include/monetary.h, include/stdlib.h, include/time.h
	* include/wchar.h, locale/duplocale.c, locale/freelocale.c
	* locale/global-locale.c, locale/langinfo.h, locale/locale.h
	* locale/localeinfo.h, locale/newlocale.c
	* locale/nl_langinfo_l.c, locale/uselocale.c
	* localedata/bug-usesetlocale.c, localedata/tst-xlocale2.c
	* stdio-common/vfscanf.c, stdlib/monetary.h, stdlib/stdlib.h
	* stdlib/strfmon_l.c, stdlib/strtod_l.c, stdlib/strtof_l.c
	* stdlib/strtol.c, stdlib/strtol_l.c, stdlib/strtold_l.c
	* stdlib/strtoll_l.c, stdlib/strtoul_l.c, stdlib/strtoull_l.c
	* string/strcasecmp.c, string/strcoll_l.c, string/string.h
	* string/strings.h, string/strncase.c, string/strxfrm_l.c
	* sysdeps/ieee754/float128/strtof128_l.c
	* sysdeps/ieee754/float128/wcstof128.c
	* sysdeps/ieee754/float128/wcstof128_l.c
	* sysdeps/ieee754/ldbl-128ibm/strtold_l.c
	* sysdeps/ieee754/ldbl-64-128/strtold_l.c
	* sysdeps/ieee754/ldbl-opt/nldbl-compat.c
	* sysdeps/ieee754/ldbl-opt/nldbl-strfmon_l.c
	* sysdeps/ieee754/ldbl-opt/nldbl-strtold_l.c
	* sysdeps/ieee754/ldbl-opt/nldbl-wcstold_l.c
	* sysdeps/powerpc/powerpc32/power7/strcasecmp.S
	* sysdeps/powerpc/powerpc64/power7/strcasecmp.S
	* sysdeps/x86_64/strcasecmp_l-nonascii.c
	* sysdeps/x86_64/strncase_l-nonascii.c, time/strftime_l.c
	* time/strptime_l.c, time/time.h, wcsmbs/mbsrtowcs_l.c
	* wcsmbs/wchar.h, wcsmbs/wcscasecmp.c, wcsmbs/wcsncase.c
	* wcsmbs/wcstod.c, wcsmbs/wcstod_l.c, wcsmbs/wcstof.c
	* wcsmbs/wcstof_l.c, wcsmbs/wcstol_l.c, wcsmbs/wcstold.c
	* wcsmbs/wcstold_l.c, wcsmbs/wcstoll_l.c, wcsmbs/wcstoul_l.c
	* wcsmbs/wcstoull_l.c, wctype/iswctype_l.c
	* wctype/towctrans_l.c, wctype/wcfuncs_l.c
	* wctype/wctrans_l.c, wctype/wctype.h, wctype/wctype_l.c:
	Change all uses of __locale_t to locale_t.
2017-06-20 20:30:06 -04:00
Zack Weinberg f0be25b633 Rename xlocale.h to bits/types/__locale_t.h.
xlocale.h is already a single-type micro-header, defining struct
__locale_struct and the typedefs __locale_t and locale_t.  This patch
brings it into the bits/types/ scheme: there are now
bits/types/__locale_t.h which defines only __locale_struct and
__locale_t, and bits/types/locale_t.h which defines locale_t as well
as the other two.  None of *our* headers need __locale_t.h, but it
appears to me that libstdc++ could make use of it.

There are a lot of external uses of xlocale.h, but all the uses I
checked had an autoconf test or equivalent for its existence.  It has
never been available from other C libraries, and it has always
contained a comment reading "This file is not standardized, don't rely
on it, it can go away without warning" so I think dropping it is
pretty safe.

I also took the opportunity to clean up comments in various public
header files that still talk about the *_l interfaces as though they
were completely nonstandard.  There are a few of them, notably the
strtoX_l and wcstoX_l families, that haven't been standardized, but
the bulk are in POSIX.1-2008.

        * locale/xlocale.h: Rename to...
	* locale/bits/types/__locale_t.h: ...here.  Adjust commentary.
	Only define struct __locale_struct and __locale_t, not locale_t.
        * locale/bits/types/locale_t.h: New file; define locale_t here.
        * locale/Makefile (headers): Update to match.

        * include/xlocale.h: Delete wrapper.
        * include/bits/types/__locale_t.h: New wrapper.
        * include/bits/types/locale_t.h: New wrapper.

        * ctype/ctype.h, include/printf.h, include/time.h
        * locale/langinfo.h, locale/locale.h, stdlib/monetary.h
        * stdlib/stdlib.h, string/string.h, string/strings.h, time/time.h
        * wcsmbs/wchar.h, wctype/wctype.h: Use bits/types/locale_t.h.
        Correct outdated comments regarding the standardization status of
        the functions that take locale_t arguments.

        * stdlib/strtod_l.c, stdlib/strtof_l.c, stdlib/strtol_l.c
        * stdlib/strtold_l.c, stdlib/strtoul_l.c, stdlib/strtoull_l.c
        * sysdeps/ieee754/ldbl-128ibm/strtold_l.c
        * sysdeps/ieee754/ldbl-64-128/strtold_l.c
        * wcsmbs/wcstod.c, wcsmbs/wcstod_l.c, wcsmbs/wcstof.c
        * wcsmbs/wcstof_l.c, wcsmbs/wcstold.c, wcsmbs/wcstold_l.c:
        Don't include xlocale.h. If necessary, include locale.h instead.

        * stdlib/strtold_l.c: Unconditionally include wchar.h.
2017-06-20 20:28:11 -04:00
Adhemerval Zanella bafcba22ac Consolidate Linux openat implementation
This patch consolidates the open Linux syscall implementation on
sysdeps/unix/sysv/linux/open{64}.c.  The changes are:

  1. Remove wordsize-64 openat{64}.
  2. For architetures that define __OFF_T_MATCHES_OFF64_T openat64
     will be default one with alias to required symbols.  Otherwise
     openat64 will pass the required O_LARGEFILE flag on syscall.

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

	* sysdeps/unix/sysv/linux/openat.c (__libc_openat): Build only
	for !__OFF_T_MATCHES_OFF64_T.
	* sysdeps/unix/sysv/linux/openat64.c (__libc_openat64): New
	implementation based on open64.
	* sysdeps/unix/sysv/linux/wordsize-64/openat.c: Remove file.
	* sysdeps/unix/sysv/linux/wordsize-64/openat64.c: Likewise.
2017-06-20 18:20:06 -03:00
H.J. Lu da69a35566 Move x86 specific tunables to x86/dl-tunables.list
* elf/dl-tunables.list: Move x86 specific tunables to ...
	* sysdeps/x86/dl-tunables.list: Here.  New file.
2017-06-20 14:03:31 -07:00
Joseph Myers 46ad8909ce conformtest: XFAIL uc_mcontext test for powerpc32 (bug 21635).
This patch XFAILs one test where the powerpc32 ucontext_t has the
wrong type of a field, to allow the conform/ tests as a whole to pass
once the namespace issues are fixed.

Tested with build-many-glibcs.py.

	[BZ #21635]
	* sysdeps/unix/sysv/linux/powerpc/powerpc32/Makefile
	[$(subdir) = conform] (conformtest-xfail-conds): New variable.
	* conform/data/signal.h-data (uc_mcontext): XFAIL for
	powerpc32-linux.
	* conform/data/ucontext.h-data (uc_mcontext): Likewise.
2017-06-20 17:51:36 +00:00
Joseph Myers e0b5a3b654 conformtest: XFAIL uc_sigmask test for ia64 (bug 21634).
This patch XFAILs one test where the ia64 ucontext_t has the wrong
type of a field, to allow the conform/ tests as a whole to pass once
the namespace issues are fixed.

Tested with build-many-glibcs.py.

	[BZ #21634]
	* sysdeps/unix/sysv/linux/ia64/Makefile [$(subdir) = conform]
	(conformtest-xfail-conds): New variable.
	* conform/data/signal.h-data (uc_sigmask): XFAIL for ia64-linux.
	* conform/data/ucontext.h-data (uc_sigmask): Likewise.
2017-06-20 17:47:32 +00:00
H.J. Lu 905947c304 tunables: Add IFUNC selection and cache sizes
The current IFUNC selection is based on microbenchmarks in glibc.  It
should give the best performance for most workloads.  But other choices
may have better performance for a particular workload or on the hardware
which wasn't available at the selection was made.  The environment
variable, GLIBC_TUNABLES=glibc.tune.ifunc=-xxx,yyy,-zzz...., can be used
to enable CPU/ARCH feature yyy, disable CPU/ARCH feature yyy and zzz,
where the feature name is case-sensitive and has to match the ones in
cpu-features.h.  It can be used by glibc developers to override the
IFUNC selection to tune for a new processor or improve performance for
a particular workload.  It isn't intended for normal end users.

NOTE: the IFUNC selection may change over time.  Please check all
multiarch implementations when experimenting.

Also, GLIBC_TUNABLES=glibc.tune.x86_non_temporal_threshold=NUMBER is
provided to set threshold to use non temporal store to NUMBER,
GLIBC_TUNABLES=glibc.tune.x86_data_cache_size=NUMBER to set data cache
size, GLIBC_TUNABLES=glibc.tune.x86_shared_cache_size=NUMBER to set
shared cache size.

	* elf/dl-tunables.list (tune): Add ifunc,
	x86_non_temporal_threshold,
	x86_data_cache_size and x86_shared_cache_size.
	* manual/tunables.texi: Document glibc.tune.ifunc,
	glibc.tune.x86_data_cache_size, glibc.tune.x86_shared_cache_size
	and glibc.tune.x86_non_temporal_threshold.
	* sysdeps/unix/sysv/linux/x86/dl-sysdep.c: New file.
	* sysdeps/x86/cpu-tunables.c: Likewise.
	* sysdeps/x86/cacheinfo.c
	(init_cacheinfo): Check and get data cache size, shared cache
	size and non temporal threshold from cpu_features.
	* sysdeps/x86/cpu-features.c [HAVE_TUNABLES] (TUNABLE_NAMESPACE):
	New.
	[HAVE_TUNABLES] Include <unistd.h>.
	[HAVE_TUNABLES] Include <elf/dl-tunables.h>.
	[HAVE_TUNABLES] (TUNABLE_CALLBACK (set_ifunc)): Likewise.
	[HAVE_TUNABLES] (init_cpu_features): Use TUNABLE_GET to set
	IFUNC selection, data cache size, shared cache size and non
	temporal threshold.
	* sysdeps/x86/cpu-features.h (cpu_features): Add data_cache_size,
	shared_cache_size and non_temporal_threshold.
2017-06-20 08:37:28 -07:00
Zack Weinberg c0b23001a8 Fix fallout from bits/string.h removal.
Remove one more string inline that was defined directly in string.h;
in the absence of the rest of the inlines, it broke the build.

Like other ifunc shims for these functions,
x86_64/multiarch/{mem,st}pcpy.c need to define __NO_STRING_INLINES and
NO_MEMPCPY_STPCPY_REDIRECT.

	* string/string.h (__mempcpy_inline): Delete.
	* sysdeps/x86_64/multiarch/mempcpy.c
	* sysdeps/x86_64/multiarch/stpcpy.c:
	Define NO_MEMPCPY_STPCPY_REDIRECT and __NO_STRING_INLINES
	before including string.h.
2017-06-20 09:39:08 -04:00
Zack Weinberg 09a596cc2c Remove bits/string.h.
These machine-dependent inline string functions have never been on by
default, and even if they were a good idea at the time they were
introduced, they haven't really been touched in ten to fifteen years
and probably aren't a good idea on current-gen processors.  Current
thinking is that this class of optimization is best left to the
compiler.

	* bits/string.h, string/bits/string.h
	* sysdeps/aarch64/bits/string.h
	* sysdeps/m68k/m680x0/m68020/bits/string.h
	* sysdeps/s390/bits/string.h, sysdeps/sparc/bits/string.h
	* sysdeps/x86/bits/string.h: Delete file.

	* string/string.h: Don't include bits/string.h.
	* string/bits/string3.h: Rename to bits/string_fortified.h.
	No need to undef various symbols that the removed headers
	might have defined as macros.
	* string/Makefile (headers): Remove bits/string.h, change
	bits/string3.h to bits/string_fortified.h.
	* string/string-inlines.c: Update commentary.  Remove definitions
	of various macros that nothing looks at anymore.  Don't directly
	include bits/string.h. Set _STRING_INLINE_unaligned here, based on
	compiler-predefined macros.
	* string/strncat.c: If STRNCAT is not defined, or STRNCAT_PRIMARY
	_is_ defined, provide internal hidden alias __strncat.
	* include/string.h: Declare internal hidden alias __strncat.
	Only forward __stpcpy to __builtin_stpcpy if __NO_STRING_INLINES is
	not defined.
	* include/bits/string3.h: Rename to bits/string_fortified.h,
	update to match above.

	* sysdeps/i386/string-inlines.c: Define compat symbols for
	everything formerly defined by sysdeps/x86/bits/string.h.
	Make existing definitions into compat symbols as well.
	Remove some no-longer-necessary messing around with macros.

	* sysdeps/powerpc/powerpc32/power4/multiarch/mempcpy.c
	* sysdeps/powerpc/powerpc64/multiarch/mempcpy.c
	* sysdeps/powerpc/powerpc64/multiarch/stpcpy.c
	* sysdeps/s390/multiarch/mempcpy.c
	No need to define _HAVE_STRING_ARCH_mempcpy.
	Do define __NO_STRING_INLINES and NO_MEMPCPY_STPCPY_REDIRECT.

	* sysdeps/i386/i686/multiarch/strncat-c.c
	* sysdeps/s390/multiarch/strncat-c.c
	* sysdeps/x86_64/multiarch/strncat-c.c
	Define STRNCAT_PRIMARY.  Don't change definition of libc_hidden_def.
2017-06-20 08:21:24 -04:00
Joseph Myers 6c2ec6677b Remove pre-GCC-4.9 MIPS code.
This patch removes some MIPS code in glibc that was conditional on old
GCC versions no longer supported for building glibc.

Tested with build-many-glibcs.py.

	* sysdeps/mips/atomic-machine.h (R10K_BEQZ_INSN): Remove.
	[__GNUC_PREREQ (4, 8) || __mips16]: Make code unconditional.
	[!__GNUC_PREREQ (4, 8) && !__mips16]: Remove conditional code.
	* sysdeps/mips/math-tests.h
	[_MIPS_SIM != _ABIO32 && !__GNUC_PREREQ (4, 9)]: Remove
	conditional code.
2017-06-19 23:24:36 +00:00
Stefan Liebler b08a6a0dea S390: Sync ptrace.h with kernel. [BZ #21539]
This patch removes PTRACE_GETREGS, PTRACE_SETREGS, PTRACE_GETFPREGS
and PTRACE_SETFPREGS as these requests does not exist on s390 kernel.

But the kernel has support for PTRACE_SINGLEBLOCK,
PTRACE_SECCOMP_GET_FILTER, PTRACE_PEEKUSR_AREA, PTRACE_POKEUSR_AREA,
PTRACE_GET_LAST_BREAK, PTRACE_ENABLE_TE, PTRACE_DISABLE_TE and
PTRACE_TE_ABORT_RAND.  Thus those are defined now.

The current kernel s390 specific ptrace.h file also defines
PTRACE_PEEKTEXT_AREA, PTRACE_PEEKDATA_AREA, PTRACE_POKETEXT_AREA,
PTRACE_POKEDATA_AREA, PTRACE_PEEK_SYSTEM_CALL, PTRACE_POKE_SYSTEM_CALL
and PTRACE_PROT, but those requests are not supported.
Thus those defines are skipped in glibc ptrace.h.

There were old includes of ptrace.h in sysdeps/s390/fpu/fesetenv.c.
The ptrace feature isn't used there anymore, thus I removed the includes.

Before this patch, <glibc>/sysdeps/unix/sysv/linux/s390/sys/ptrace.h
uses ptrace-request 12 for PTRACE_GETREGS,
but <kernel>/include/uapi/linux/ptrace.h uses 12 for PTRACE_SINGLEBLOCK.

The s390 kernel has never had support for PTRACE_GETREGS!
Thus glibc ptrace.h is adjusted to match kernel ptrace.h.

The new s390 specific test ensures, that PTRACE_SINGLEBLOCK defined
in glibc works as expected.  If the kernel would interpret it as
PTRACE_GETREGS, then the testcase will not make any progress
and will time out.

ChangeLog:

	[BZ #21539]
	* NEWS: Mention s390 ptrace request changes.
	* sysdeps/unix/sysv/linux/s390/sys/ptrace.h
	(PTRACE_GETREGS, PTRACE_SETREGS, PTRACE_GETFPREGS,
	PTRACE_SETFPREGS): Remove enum constant.
	(PT_GETREGS, PT_SETREGS, PT_GETFPREGS, T_SETFPREGS):
	Remove defines.
	(PTRACE_SINGLEBLOCK): New enum constant.
	(PT_STEPBLOCK): New define.
	(PTRACE_PEEKUSR_AREA, PTRACE_POKEUSR_AREA,
	PTRACE_GET_LAST_BREAK, PTRACE_ENABLE_TE, PTRACE_DISABLE_TE,
	PTRACE_TE_ABORT_RAND): New enum constant and define.
	* sysdeps/s390/fpu/fesetenv.c: Remove ptrace.h includes.
	* sysdeps/unix/sysv/linux/s390/tst-ptrace-singleblock.c:
	New file.
	* sysdeps/unix/sysv/linux/s390/Makefile: Add test.
2017-06-19 16:27:25 +02:00
Joseph Myers 487549c466 Fix another x86 sys/ucontext.h namespace issue (bug 21457).
This patch fixes a namespace issue for one more field in the x86
sys/ucontext.h that I missed in my previous changes.

Tested for x86_64.

	[BZ #21457]
	* sysdeps/unix/sysv/linux/x86/sys/ucontext.h [__x86_64__] (struct
	_libc_xmmreg): Use __ctx in defining field.
2017-06-19 12:21:35 +00:00
Joseph Myers a66bc30d6b Define struct rusage in sys/wait.h when required (bug 21575).
Some older standards (XPG4.2 through POSIX.1:2001, XSI only) require
sys/wait.h to include the definition of struct rusage.  This is
missing in glibc.

This patch adds the required definition.  struct rusage is moved to a
new header bits/types/struct_rusage.h to avoid bringing in the whole
of sys/resource.h (although the standards in question do allow the
whole of sys/resource.h to be brought in).  In the five
bits/resource.h headers, the only variation between the definitions of
struct rusage is that the sysdeps/unix/sysv/linux version is prepared
for x32 (by having anonymous unions with __syscall_slong_t fields) and
the others are not.  Thus, this version is suitable for use
generically (everything other than x32 simply has __syscall_slong_t
the same as long int, so there are no API or ABI changes involved, and
anonymous unions are already a required language feature for glibc
headers elsewhere), and this patch uses it as a base for the single
implementation of bits/types/struct_rusage.h.

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

	[BZ #21575]
	* resource/bits/types/struct_rusage.h: New file.
	* include/bits/types/struct_rusage.h: Likewise.
	* bits/resource.h (struct rusage): Include
	<bits/types/struct_rusage.h> instead of defining here.
	* sysdeps/unix/sysv/linux/bits/resource.h (struct rusage):
	Likewise.
	* sysdeps/unix/sysv/linux/alpha/bits/resource.h (struct rusage):
	Likewise.
	* sysdeps/unix/sysv/linux/mips/bits/resource.h (struct rusage):
	Likewise.
	* sysdeps/unix/sysv/linux/sparc/bits/resource.h (struct rusage):
	Likewise.
	* resource/Makefile (headers): Add bits/types/struct_rusage.h.
	* posix/sys/wait.h [__USE_XOPEN_EXTENDED && !__USE_XOPEN2K8]:
	Include <bits/types/struct_rusage.h>
2017-06-19 11:59:19 +00:00
Siddhesh Poyarekar 629ebc873a Fix typo when undefining weak_alias
The macro directive #undef was miswritten as #undefine.

	* sysdeps/x86_64/multiarch/rawmemchr-sse2.S: Fix typo.
2017-06-19 14:56:40 +05:30
Stefan Liebler 5e5b3b8866 S390: Fix build with gcc configured with --enable-default-pie. [BZ #21537]
Building glibc with gcc configured with --enable-default-pie failed on s390
due to assembler messages:
../sysdeps/unix/sysv/linux/s390/s390-32/__makecontext_ret.S:44:
Error: junk at end of line, first unrecognized character is `@'

HIDDEN_JUMPTARGET was expanded to exit@PLT@GOTOFF.
If SHARED is not defined, HIDDEN_JUMPTARGET is defined to JUMPTARGET
in sysdeps/s390/s390-32/sysdep.h.  There it expanded to exit@PLT
in non SHARED case as PIC is defined if gcc is configured with
--enable-default-pie. Thus I've changed the "ifdef PIC" to "ifdef SHARED"
as we do not want PLTs in the static obj files.  I've also changed this
in sysdeps/s390/s390-64/sysdep.h.

I've also adjusted sysdeps/unix/sysv/linux/s390/s390-32/__makecontext_ret.S.
If glibc is configured with --disable-hidden-plt, then NO_HIDDEN is defined.
In SHARED case HIDDEN_JUMPTARGET would be expanded to exit@PLT@GOTOFF
instead of __GI_exit@GOTOFF.
Now we jump to:
- __GI_exit if SHARED is defined
- exit@PLT if SHARED and NO_HIDDEN is defined
- exit if both are not defined.
On s390 31bit we have to setup GOT pointer in r12 if we use a PLT stub.
Therefore I use SYSCALL_PIC_SETUP from sysdep.h and added the missing semicolons.

ChangeLog:

	[BZ #21537]
	* sysdeps/s390/s390-32/sysdep.h (JUMPTARGET, SYSCALL_PIC_SETUP):
	Check SHARED instead of PIC.
	(SYSCALL_PIC_SETUP): Add missing semicolons.
	* sysdeps/s390/s390-64/sysdep.h (JUMPTARGET, SYSCALL_PIC_SETUP):
	Check SHARED instead of PIC.
	* sysdeps/unix/sysv/linux/s390/s390-32/__makecontext_ret.S
	(__makecontext_ret): Adjust code to jump to exit.
2017-06-19 11:08:58 +02:00
Christian Borntraeger 35810f5ccf s390: optimize syscall function
Since kernel 2.6.0 all Linux version accept the system call number
in register 1 for svc 0. There is no need to have special handling
that uses EX for system calls < 256. This will simplify and speed
up that code.

A microbenchmark doing "syscall(__NR_getpid);" in a loops gets faster
by ~12%.

        * sysdeps/unix/sysv/linux/s390/s390-32/syscall.S: Simplify
        code by always using SVC 0 instead of EX.
        * sysdeps/unix/sysv/linux/s390/s390-64/syscall.S: Likewise.
2017-06-19 10:59:40 +02:00
Adhemerval Zanella 48d966eb35 linux: Consolidate sync_file_range implementation
This patch consolidates Linux sync_file_range at default
sysdeps/unix/sysv/linux/sync_file_range.c implementation.  It also
moves the rules flags from generic io/Makefile to Linux one due the
fact it is a Linux-only symbol.

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

	* io/Makefile (CFLAGS-sync_file_range.c): Remove rule.
	* sysdeps/unix/sysv/linux/Makefile (CFLAGS-sync_file_range.c): New
	rule.
	* sysdeps/unix/sysv/linux/wordsize-64/syscalls.list: Remove
	sync_file_range.
2017-06-15 16:03:37 -03:00
H.J. Lu 70fe2eb794 x86-64: Implement strcspn/strpbrk/strspn IFUNC selectors in C
Implement strcspn/strpbrk/strspn IFUNC selectors in C

All internal calls within libc.so can use IFUNC on x86-64 since unlike
x86, x86-64 supports PC-relative addressing to access the GOT entry so
that it can call via PLT without using an extra register.  For libc.a,
we can't use IFUNC for functions which are called before IFUNC has been
initialized.  Use IFUNC internally reduces the icache footprint since
libc.so and other codes in the process use the same implementations.
This patch uses IFUNC for strcspn/strpbrk/strspn functions within libc.

	* sysdeps/x86_64/multiarch/Makefile (sysdep_routines): Add
	strcspn-sse2, strpbrk-sse2 and strspn-sse2.
	* sysdeps/x86_64/strcspn.S (STRPBRK_P): Removed.
	Check USE_AS_STRPBRK instead of STRPBRK_P.
	* sysdeps/x86_64/strpbrk.S (USE_AS_STRPBRK): New.
	* sysdeps/x86_64/multiarch/ifunc-sse4_2.h: New file.
	* sysdeps/x86_64/multiarch/strcspn-sse2.S: Likewise.
	* sysdeps/x86_64/multiarch/strcspn.c: Likewise.
	* sysdeps/x86_64/multiarch/strpbrk-sse2.S: Likewise.
	* sysdeps/x86_64/multiarch/strpbrk.c: Likewise.
	* sysdeps/x86_64/multiarch/strspn-sse2.S: Likewise.
	* sysdeps/x86_64/multiarch/strspn.c: Likewise.
	* sysdeps/x86_64/multiarch/strcspn.S: Removed.
	* sysdeps/x86_64/multiarch/strpbrk.S: Likewise.
	* sysdeps/x86_64/multiarch/strspn.S: Likewise.
	* sysdeps/x86_64/multiarch/strpbrk-c.c: Remove "#ifdef SHARED"
	and "#endif".
2017-06-15 08:59:05 -07:00
H.J. Lu 9f4254b8bd x86-64: Implement wcscpy IFUNC selector in C
* sysdeps/x86_64/multiarch/wcscpy.S: Removed.
	* sysdeps/x86_64/multiarch/wcscpy.c: New file.
2017-06-15 08:57:52 -07:00
H.J. Lu 9ed0aa15d3 x86-64: Implement strcat family IFUNC selectors in C
Implement strcat family IFUNC selectors in C.

All internal calls within libc.so can use IFUNC on x86-64 since unlike
x86, x86-64 supports PC-relative addressing to access the GOT entry so
that it can call via PLT without using an extra register.  For libc.a,
we can't use IFUNC for functions which are called before IFUNC has been
initialized.  Use IFUNC internally reduces the icache footprint since
libc.so and other codes in the process use the same implementations.
This patch uses IFUNC for strcat family functions within libc.

	* sysdeps/x86_64/multiarch/Makefile (sysdep_routines): Add
	strcat-sse2.
	* sysdeps/x86_64/multiarch/strcat-sse2.S: New file.
	* sysdeps/x86_64/multiarch/strcat.c: Likewise.
	* sysdeps/x86_64/multiarch/strncat.c: Likewise.
	* sysdeps/x86_64/multiarch/strcat.S: Removed.
	* sysdeps/x86_64/multiarch/strncat.S: Likewise.
2017-06-15 08:56:59 -07:00
H.J. Lu b91a52d0d7 x86-64: Implement memcmp family IFUNC selectors in C
Implement memcmp family IFUNC selectors in C.

All internal calls within libc.so can use IFUNC on x86-64 since unlike
x86, x86-64 supports PC-relative addressing to access the GOT entry so
that it can call via PLT without using an extra register.  For libc.a,
we can't use IFUNC for functions which are called before IFUNC has been
initialized.  Use IFUNC internally reduces the icache footprint since
libc.so and other codes in the process use the same implementations.
This patch uses IFUNC for memcmp family functions within libc.

	* sysdeps/x86_64/multiarch/Makefile (sysdep_routines): Add
	memcmp-sse2.
	* sysdeps/x86_64/multiarch/ifunc-memcmp.h: New file.
	* sysdeps/x86_64/multiarch/memcmp-sse2.S: Likewise.
	* sysdeps/x86_64/multiarch/memcmp.c: Likewise.
	* sysdeps/x86_64/multiarch/wmemcmp.c: Likewise.
	* sysdeps/x86_64/multiarch/memcmp.S: Removed.
	* sysdeps/x86_64/multiarch/wmemcmp.S: Likewise.
2017-06-15 08:49:57 -07:00
H.J. Lu 93e46f8773 x86-64: Implement memset family IFUNC selectors in C
Implement memset family IFUNC selectors in C.

All internal calls within libc.so can use IFUNC on x86-64 since unlike
x86, x86-64 supports PC-relative addressing to access the GOT entry so
that it can call via PLT without using an extra register.  For libc.a,
we can't use IFUNC for functions which are called before IFUNC has been
initialized.  Use IFUNC internally reduces the icache footprint since
libc.so and other codes in the process use the same implementations.
This patch uses IFUNC for memset functions within libc.

2017-06-07  H.J. Lu  <hongjiu.lu@intel.com>
	    Erich Elsen  <eriche@google.com>

	* sysdeps/x86_64/multiarch/Makefile (sysdep_routines): Add
	memset-sse2-unaligned-erms, and memset_chk-nonshared.
	* sysdeps/x86_64/multiarch/ifunc-impl-list.c
	(__libc_ifunc_impl_list): Add test for __memset_chk_erms.
	Update comments.
	* sysdeps/x86_64/multiarch/ifunc-memset.h: New file.
	* sysdeps/x86_64/multiarch/memset-sse2-unaligned-erms.S: Likewise.
	* sysdeps/x86_64/multiarch/memset.c: Likewise.
	* sysdeps/x86_64/multiarch/memset_chk-nonshared.S: Likewise.
	* sysdeps/x86_64/multiarch/memset_chk.c: Likewise.
	* sysdeps/x86_64/multiarch/memset.S: Removed.
	* sysdeps/x86_64/multiarch/memset_chk.S: Likewise.
	* sysdeps/x86_64/multiarch/memset-vec-unaligned-erms.S
	(__memset_chk_erms): New function.
2017-06-15 08:33:35 -07:00
H.J. Lu 5c3e322d3b x86-64: Implement memmove family IFUNC selectors in C
Implement memmove family IFUNC selectors in C.

All internal calls within libc.so can use IFUNC on x86-64 since unlike
x86, x86-64 supports PC-relative addressing to access the GOT entry so
that it can call via PLT without using an extra register.  For libc.a,
we can't use IFUNC for functions which are called before IFUNC has been
initialized.  Use IFUNC internally reduces the icache footprint since
libc.so and other codes in the process use the same implementations.
This patch uses IFUNC for memmove family functions within libc.

	* sysdeps/x86_64/multiarch/Makefile (sysdep_routines): Add
	memmove-sse2-unaligned-erms, memcpy_chk-nonshared,
	mempcpy_chk-nonshared and memmove_chk-nonshared.
	* sysdeps/x86_64/multiarch/ifunc-impl-list.c
	(__libc_ifunc_impl_list): Add tests for __memmove_chk_erms,
	__memcpy_chk_erms and __mempcpy_chk_erms.  Update comments.
	* sysdeps/x86_64/multiarch/ifunc-memmove.h: New file.
	* sysdeps/x86_64/multiarch/memcpy.c: Likewise.
	* sysdeps/x86_64/multiarch/memcpy_chk-nonshared.S: Likewise.
	* sysdeps/x86_64/multiarch/memcpy_chk.c: Likewise.
	* sysdeps/x86_64/multiarch/memmove-sse2-unaligned-erms.S: Likewise.
	* sysdeps/x86_64/multiarch/memmove.c: Likewise.
	* sysdeps/x86_64/multiarch/memmove_chk-nonshared.S: Likewise.
	* sysdeps/x86_64/multiarch/memmove_chk.c: Likewise.
	* sysdeps/x86_64/multiarch/mempcpy.c: Likewise.
	* sysdeps/x86_64/multiarch/mempcpy_chk-nonshared.S: Likewise.
	* sysdeps/x86_64/multiarch/mempcpy_chk.c: Likewise.
	* sysdeps/x86_64/multiarch/memcpy.S: Removed.
	* sysdeps/x86_64/multiarch/memcpy_chk.S: Likewise.
	* sysdeps/x86_64/multiarch/memmove.S: Likewise.
	* sysdeps/x86_64/multiarch/memmove_chk.S: Likewise.
	* sysdeps/x86_64/multiarch/mempcpy.S: Likewise.
	* sysdeps/x86_64/multiarch/mempcpy_chk.S: Likewise.
	* sysdeps/x86_64/multiarch/memmove-vec-unaligned-erms.S
	(__mempcpy_chk_erms): New function.
	(__memmove_chk_erms): Likewise.
	(__memcpy_chk_erms): New alias.
2017-06-14 12:11:10 -07:00
Florian Weimer 69052a3a95 i686: Add missing IS_IN (libc) guards to vectorized strcspn
Since commit d957c4d3fa (i386: Compile
rtld-*.os with -mno-sse -mno-mmx -mfpmath=387), vector intrinsics can
no longer be used in ld.so, even if the compiled code never makes it
into the final ld.so link.  This commit adds the missing IS_IN (libc)
guard to the SSE 4.2 strcspn implementation, so that it can be used from
ld.so in the future.
2017-06-14 14:50:11 +02:00
Zack Weinberg fd860eaaa8 Remove __need macros from errno.h (__need_Emath, __need_error_t).
This is fairly complicated, not because the users of __need_Emath and
__need_error_t have complicated requirements, but because the core
changes had a lot of fallout.

__need_error_t exists for gnulib compatibility in argz.h and argp.h.
error_t itself is a Hurdism, an enum containing all the E-constants,
so you can do 'p (error_t) errno' in gdb and get a symbolic value.
argz.h and argp.h use it for function return values, and they want to
fall back to 'int' when that's not available.  There is no reason why
these nonstandard headers cannot just go ahead and include all of
errno.h; so we do that.

__need_Emath is defined only by .S files; what they _really_ need is
for errno.h to avoid declaring anything other than the E-constants
(e.g. 'extern int __errno_location(void);' is a syntax error in
assembly language). This is replaced with a check for __ASSEMBLER__ in
errno.h, plus a carefully documented requirement for bits/errno.h not
to define anything other than macros.  That in turn has the
consequence that bits/errno.h must not define errno - fortunately, all
live ports use the same definition of errno, so I've moved it to
errno.h.  The Hurd bits/errno.h must also take care not to define
error_t when __ASSEMBLER__ is defined, which involves repeating all of
the definitions twice, but it's a generated file so that's okay.

	* stdlib/errno.h: Remove __need_Emath and __need_error_t logic.
	Reorganize file.  Declare errno here.  When __ASSEMBLER__ is
	defined, don't declare anything other than the E-constants.

	* include/errno.h: Change conditional for exposing internal
	declarations to (not _ISOMAC and not __ASSEMBLER__).
	* bits/errno.h: Remove logic for __need_Emath.  Document
	requirements for a port-specific bits/errno.h.

	* sysdeps/unix/sysv/linux/bits/errno.h
	* sysdeps/unix/sysv/linux/alpha/bits/errno.h
	* sysdeps/unix/sysv/linux/hppa/bits/errno.h
	* sysdeps/unix/sysv/linux/mips/bits/errno.h
	* sysdeps/unix/sysv/linux/sparc/bits/errno.h:
	Add multiple-include guard and check against improper inclusion.
	Remove __need_Emath logic.  Don't declare errno here.  Ensure all
	constants are defined as simple integer literals.  Consistent
	formatting.
	* sysdeps/mach/hurd/errnos.awk: Likewise.  Only define error_t and
	enum __error_t_codes if __ASSEMBLER__ is not defined.
	* sysdeps/mach/hurd/bits/errno.h: Regenerate.

	* argp/argp.h, string/argz.h: Don't define __need_error_t before
	including errno.h.
	* sysdeps/i386/i686/fpu/multiarch/s_cosf-sse2.S
	* sysdeps/i386/i686/fpu/multiarch/s_sincosf-sse2.S
	* sysdeps/i386/i686/fpu/multiarch/s_sinf-sse2.S
	* sysdeps/x86_64/fpu/s_cosf.S
	* sysdeps/x86_64/fpu/s_sincosf.S
	* sysdeps/x86_64/fpu/s_sinf.S:
	Just include errno.h; don't define __need_Emath or include
	bits/errno.h directly.
2017-06-14 08:14:34 -04:00