Commit Graph

11054 Commits

Author SHA1 Message Date
Zack Weinberg 37f802f864 Remove __need_IOV_MAX and __need_FOPEN_MAX.
__need_FOPEN_MAX wasn't being used anywhere.  __need_IOV_MAX was more
complicated; the basic deal is that sys/uio.h wants to define a
constant named UIO_MAXIOV and bits/xopen_lim.h wants to define a
constant named IOV_MAX, with the same meaning.  For no apparent reason
this was being handled via bits/stdio_lim.h -- stdio.h is NOT supposed
to define IOV_MAX -- and some mess in Makerules.  Also, bits/uio.h on
Linux was being used as a dumping ground for extension functions.

So now we have bits/uio_lim.h, which defines __IOV_MAX.
bits/xopen_lim.h and sys/uio.h use that to define their respective
constants.  We also now have bits/uio-ext.h, which is the official
Proper Home for extensions to sys/uio.h.  bits/uio.h is removed, and
stdio_lim.h doesn't define IOV_MAX at all.

	* bits/uio_lim.h, sysdeps/unix/sysv/linux/bits/uio_lim.h
	* bits/uio-ext.h, sysdeps/unix/sysv/linux/bits/uio-ext.h: New file.
	* bits/uio.h, sysdeps/unix/sysv/linux/bits/uio.h: Delete file.

	* include/bits/xopen_lim.h: Use bits/uio_lim.h to get the value
	for IOV_MAX.
	* misc/Makefile: Install bits/uio-ext.h and bits/uio_lim.h.
	Don't install bits/uio.h.
	* misc/sys/uio.h: Don't include bits/uio.h.  Do include
	bits/types/struct_iovec.h and bits/uio_lim.h.  Set UIO_MAXIOV
	based on __IOV_MAX. Under __USE_GNU, also include bits/uio-ext.h.

	* stdio-common/stdio_lim.h.in: Remove logic for __need_FOPEN_MAX
	and __need_IOV_MAX.  Don't define IOV_MAX at all.
	* Makerules (stdio_lim.h): Remove logic for setting IOV_MAX.

	* sysdeps/unix/sysv/linux/bits/fcntl-linux.h:
	Include bits/types/struct_iovec.h, not bits/uio.h.
	Use __ssize_t, not ssize_t, in function prototypes.
	Don't use hard TAB for double space after period in comments.
2017-06-14 07:51:30 -04:00
Alan Modra 0572433b5b PowerPC64 ELFv2 PPC64_OPT_LOCALENTRY
ELFv2 functions with localentry:0 are those with a single entry point,
ie. global entry == local entry, that have no requirement on r2 or
r12 and guarantee r2 is unchanged on return.  Such an external
function can be called via the PLT without saving r2 or restoring it
on return, avoiding a common load-hit-store for small functions.

This patch implements the ld.so changes necessary for this
optimization.  ld.so needs to check that an optimized plt call
sequence is in fact calling a function implemented with localentry:0,
end emit a fatal error otherwise.

The elf/testobj6.c change is to stop "error while loading shared
libraries: expected localentry:0 `preload'" when running
elf/preloadtest, which we'd get otherwise.

	* elf/elf.h (PPC64_OPT_LOCALENTRY): Define.
	* sysdeps/alpha/dl-machine.h (elf_machine_fixup_plt): Add
	refsym and sym parameters.  Adjust callers.
	* sysdeps/aarch64/dl-machine.h (elf_machine_fixup_plt): Likewise.
	* sysdeps/arm/dl-machine.h (elf_machine_fixup_plt): Likewise.
	* sysdeps/generic/dl-machine.h (elf_machine_fixup_plt): Likewise.
	* sysdeps/hppa/dl-machine.h (elf_machine_fixup_plt): Likewise.
	* sysdeps/i386/dl-machine.h (elf_machine_fixup_plt): Likewise.
	* sysdeps/ia64/dl-machine.h (elf_machine_fixup_plt): Likewise.
	* sysdeps/m68k/dl-machine.h (elf_machine_fixup_plt): Likewise.
	* sysdeps/microblaze/dl-machine.h (elf_machine_fixup_plt): Likewise.
	* sysdeps/mips/dl-machine.h (elf_machine_fixup_plt): Likewise.
	* sysdeps/nios2/dl-machine.h (elf_machine_fixup_plt): Likewise.
	* sysdeps/powerpc/powerpc32/dl-machine.h (elf_machine_fixup_plt):
	Likewise.
	* sysdeps/s390/s390-32/dl-machine.h (elf_machine_fixup_plt): Likewise.
	* sysdeps/s390/s390-64/dl-machine.h (elf_machine_fixup_plt): Likewise.
	* sysdeps/sh/dl-machine.h (elf_machine_fixup_plt): Likewise.
	* sysdeps/sparc/sparc32/dl-machine.h (elf_machine_fixup_plt): Likewise.
	* sysdeps/sparc/sparc64/dl-machine.h (elf_machine_fixup_plt): Likewise.
	* sysdeps/tile/dl-machine.h (elf_machine_fixup_plt): Likewise.
	* sysdeps/x86_64/dl-machine.h (elf_machine_fixup_plt): Likewise.
	* sysdeps/powerpc/powerpc64/dl-machine.c (_dl_error_localentry): New.
	(_dl_reloc_overflow): Increase buffser size.  Formatting.
	* sysdeps/powerpc/powerpc64/dl-machine.h (ppc64_local_entry_offset):
	Delete reloc param, add refsym and sym.  Check optimized plt
	call stubs for localentry:0 functions.  Adjust callers.
	(elf_machine_fixup_plt, elf_machine_plt_conflict): Add refsym
	and sym parameters.  Adjust callers.
	(_dl_reloc_overflow): Move attribute.
	(_dl_error_localentry): Declare.
	* elf/dl-runtime.c (_dl_fixup): Save original sym.  Pass
	refsym and sym to elf_machine_fixup_plt.
	* elf/testobj6.c (preload): Call printf.
2017-06-14 10:47:25 +09:30
Alan Modra d5b411854f PowerPC64 ENTRY_TOCLESS
A number of functions in the sysdeps/powerpc/powerpc64/ tree don't use
or change r2, yet declare a global entry that sets up r2.  This patch
fixes that problem, and consolidates the ENTRY and EALIGN macros.

	* sysdeps/powerpc/powerpc64/sysdep.h: Formatting.
	(NOPS, ENTRY_3): New macros.
	(ENTRY): Rewrite.
	(ENTRY_TOCLESS): Define.
	(EALIGN, EALIGN_W_0, EALIGN_W_1, EALIGN_W_2, EALIGN_W_4, EALIGN_W_5,
	EALIGN_W_6, EALIGN_W_7, EALIGN_W_8): Delete.
	* sysdeps/powerpc/powerpc64/a2/memcpy.S: Replace EALIGN with ENTRY.
	* sysdeps/powerpc/powerpc64/dl-trampoline.S: Likewise.
	* sysdeps/powerpc/powerpc64/fpu/s_ceil.S: Likewise.
	* sysdeps/powerpc/powerpc64/fpu/s_ceilf.S: Likewise.
	* sysdeps/powerpc/powerpc64/fpu/s_floor.S: Likewise.
	* sysdeps/powerpc/powerpc64/fpu/s_floorf.S: Likewise.
	* sysdeps/powerpc/powerpc64/fpu/s_nearbyint.S: Likewise.
	* sysdeps/powerpc/powerpc64/fpu/s_nearbyintf.S: Likewise.
	* sysdeps/powerpc/powerpc64/fpu/s_rint.S: Likewise.
	* sysdeps/powerpc/powerpc64/fpu/s_rintf.S: Likewise.
	* sysdeps/powerpc/powerpc64/fpu/s_round.S: Likewise.
	* sysdeps/powerpc/powerpc64/fpu/s_roundf.S: Likewise.
	* sysdeps/powerpc/powerpc64/fpu/s_trunc.S: Likewise.
	* sysdeps/powerpc/powerpc64/fpu/s_truncf.S: Likewise.
	* sysdeps/powerpc/powerpc64/memset.S: Likewise.
	* sysdeps/powerpc/powerpc64/power7/fpu/s_finite.S: Likewise.
	* sysdeps/powerpc/powerpc64/power7/fpu/s_isinf.S: Likewise.
	* sysdeps/powerpc/powerpc64/power7/fpu/s_isnan.S: Likewise.
	* sysdeps/powerpc/powerpc64/power7/strstr.S: Likewise.
	* sysdeps/powerpc/powerpc64/power8/fpu/e_expf.S: Likewise.
	* sysdeps/powerpc/powerpc64/power8/fpu/s_cosf.S: Likewise.
	* sysdeps/powerpc/powerpc64/power8/fpu/s_sinf.S: Likewise.
	* sysdeps/powerpc/powerpc64/power8/strcasestr.S: Likewise.
	* sysdeps/powerpc/powerpc64/addmul_1.S: Use ENTRY_TOCLESS.
	* sysdeps/powerpc/powerpc64/cell/memcpy.S: Likewise.
	* sysdeps/powerpc/powerpc64/fpu/s_copysign.S: Likewise.
	* sysdeps/powerpc/powerpc64/fpu/s_copysignl.S: Likewise.
	* sysdeps/powerpc/powerpc64/fpu/s_fabsl.S: Likewise.
	* sysdeps/powerpc/powerpc64/fpu/s_isnan.S: Likewise.
	* sysdeps/powerpc/powerpc64/fpu/s_llrint.S: Likewise.
	* sysdeps/powerpc/powerpc64/fpu/s_llrintf.S: Likewise.
	* sysdeps/powerpc/powerpc64/lshift.S: Likewise.
	* sysdeps/powerpc/powerpc64/memcpy.S: Likewise.
	* sysdeps/powerpc/powerpc64/mul_1.S: Likewise.
	* sysdeps/powerpc/powerpc64/power4/memcmp.S: Likewise.
	* sysdeps/powerpc/powerpc64/power4/memcpy.S: Likewise.
	* sysdeps/powerpc/powerpc64/power4/memset.S: Likewise.
	* sysdeps/powerpc/powerpc64/power4/strncmp.S: Likewise.
	* sysdeps/powerpc/powerpc64/power5+/fpu/s_ceil.S: Likewise.
	* sysdeps/powerpc/powerpc64/power5+/fpu/s_ceilf.S: Likewise.
	* sysdeps/powerpc/powerpc64/power5+/fpu/s_floor.S: Likewise.
	* sysdeps/powerpc/powerpc64/power5+/fpu/s_floorf.S: Likewise.
	* sysdeps/powerpc/powerpc64/power5+/fpu/s_llround.S: Likewise.
	* sysdeps/powerpc/powerpc64/power5+/fpu/s_round.S: Likewise.
	* sysdeps/powerpc/powerpc64/power5+/fpu/s_roundf.S: Likewise.
	* sysdeps/powerpc/powerpc64/power5+/fpu/s_trunc.S: Likewise.
	* sysdeps/powerpc/powerpc64/power5+/fpu/s_truncf.S: Likewise.
	* sysdeps/powerpc/powerpc64/power5/fpu/s_isnan.S: Likewise.
	* sysdeps/powerpc/powerpc64/power6/fpu/s_copysign.S: Likewise.
	* sysdeps/powerpc/powerpc64/power6/fpu/s_isnan.S: Likewise.
	* sysdeps/powerpc/powerpc64/power6/memcpy.S: Likewise.
	* sysdeps/powerpc/powerpc64/power6/memset.S: Likewise.
	* sysdeps/powerpc/powerpc64/power6x/fpu/s_isnan.S: Likewise.
	* sysdeps/powerpc/powerpc64/power6x/fpu/s_llrint.S: Likewise.
	* sysdeps/powerpc/powerpc64/power6x/fpu/s_llround.S: Likewise.
	* sysdeps/powerpc/powerpc64/power7/add_n.S: Likewise.
	* sysdeps/powerpc/powerpc64/power7/memchr.S: Likewise.
	* sysdeps/powerpc/powerpc64/power7/memcmp.S: Likewise.
	* sysdeps/powerpc/powerpc64/power7/memcpy.S: Likewise.
	* sysdeps/powerpc/powerpc64/power7/memmove.S: Likewise.
	* sysdeps/powerpc/powerpc64/power7/mempcpy.S: Likewise.
	* sysdeps/powerpc/powerpc64/power7/memrchr.S: Likewise.
	* sysdeps/powerpc/powerpc64/power7/memset.S: Likewise.
	* sysdeps/powerpc/powerpc64/power7/rawmemchr.S: Likewise.
	* sysdeps/powerpc/powerpc64/power7/strcasecmp.S (strcasecmp_l):
	Likewise.
	* sysdeps/powerpc/powerpc64/power7/strchr.S: Likewise.
	* sysdeps/powerpc/powerpc64/power7/strchrnul.S: Likewise.
	* sysdeps/powerpc/powerpc64/power7/strcmp.S: Likewise.
	* sysdeps/powerpc/powerpc64/power7/strlen.S: Likewise.
	* sysdeps/powerpc/powerpc64/power7/strncmp.S: Likewise.
	* sysdeps/powerpc/powerpc64/power7/strncpy.S: Likewise.
	* sysdeps/powerpc/powerpc64/power7/strnlen.S: Likewise.
	* sysdeps/powerpc/powerpc64/power7/strrchr.S: Likewise.
	* sysdeps/powerpc/powerpc64/power8/fpu/s_finite.S: Likewise.
	* sysdeps/powerpc/powerpc64/power8/fpu/s_isinf.S: Likewise.
	* sysdeps/powerpc/powerpc64/power8/fpu/s_isnan.S: Likewise.
	* sysdeps/powerpc/powerpc64/power8/fpu/s_llrint.S: Likewise.
	* sysdeps/powerpc/powerpc64/power8/fpu/s_llround.S: Likewise.
	* sysdeps/powerpc/powerpc64/power8/memcmp.S: Likewise.
	* sysdeps/powerpc/powerpc64/power8/memset.S: Likewise.
	* sysdeps/powerpc/powerpc64/power8/strchr.S: Likewise.
	* sysdeps/powerpc/powerpc64/power8/strcmp.S: Likewise.
	* sysdeps/powerpc/powerpc64/power8/strcpy.S: Likewise.
	* sysdeps/powerpc/powerpc64/power8/strlen.S: Likewise.
	* sysdeps/powerpc/powerpc64/power8/strncmp.S: Likewise.
	* sysdeps/powerpc/powerpc64/power8/strncpy.S: Likewise.
	* sysdeps/powerpc/powerpc64/power8/strnlen.S: Likewise.
	* sysdeps/powerpc/powerpc64/power8/strrchr.S: Likewise.
	* sysdeps/powerpc/powerpc64/power8/strspn.S: Likewise.
	* sysdeps/powerpc/powerpc64/power9/strcmp.S: Likewise.
	* sysdeps/powerpc/powerpc64/power9/strncmp.S: Likewise.
	* sysdeps/powerpc/powerpc64/strchr.S: Likewise.
	* sysdeps/powerpc/powerpc64/strcmp.S: Likewise.
	* sysdeps/powerpc/powerpc64/strlen.S: Likewise.
	* sysdeps/powerpc/powerpc64/strncmp.S: Likewise.
	* sysdeps/powerpc/powerpc64/ppc-mcount.S: Store LR earlier.  Don't
	add nop when SHARED.
	* sysdeps/powerpc/powerpc64/start.S: Fix comment.
	* sysdeps/powerpc/powerpc64/multiarch/strrchr-power8.S (ENTRY): Don't
	define.
	(ENTRY_TOCLESS): Define.
	* sysdeps/powerpc/powerpc32/sysdep.h (ENTRY_TOCLESS): Define.
	* sysdeps/powerpc/fpu/s_fma.S: Use ENTRY_TOCLESS.
	* sysdeps/powerpc/fpu/s_fmaf.S: Likewise.
2017-06-14 10:45:50 +09:30
Alan Modra de7ee73d6f PowerPC64 strncpy, stpncpy and strstr fixes
Makes __stpncpy_power8 call __memset_power8 directly rather than via an
IFUNC.  Fixes a missing _mcount, and removes some redundant NOPS.  The
*_is_local defines are also used in a followup patch.

	* sysdeps/powerpc/powerpc64/multiarch/strncpy-power7.S: Define
	MEMSET_is_local.
	* sysdeps/powerpc/powerpc64/multiarch/strncpy-power8.S: Likewise.
	* sysdeps/powerpc/powerpc64/multiarch/stpncpy-power7.S: Likewise.
	* sysdeps/powerpc/powerpc64/multiarch/stpncpy-power8.S: Likewise.
	Define MEMSET.
	* sysdeps/powerpc/powerpc64/multiarch/strstr-power7.S: Define
	STRLEN_is_local, STRNLEN_is_local, and STRCHR_is_local.
	* sysdeps/powerpc/powerpc64/power7/strstr.S: Likewise.  Don't add
	nop after local calls.
	* sysdeps/powerpc/powerpc64/power7/strncpy.S: Define MEMSET_is_local.
	Don't add nop after local call.
	* sysdeps/powerpc/powerpc64/power8/strncpy.S: Likewise.  Add missing
	CALL_MCOUNT.
2017-06-14 10:44:59 +09:30
Alan Modra 4b6e7667db PowerPC64 sysdep.h tidy
.align on some targets takes a byte alignment, on others like powerpc,
log2 of the byte alignment.  It's a good idea to avoid .align,
particularly since x86 and powerpc are different.  This patch fixes
the occurrences of .align in powerpc64/sysdep.h, renames DOT_LABEL
since the macro doesn't have anything to do with adding dots, removes
extraneous semicolons, and fixes some formatting.

	* sysdeps/powerpc/powerpc64/sysdep.h: Formatting.
	(FUNC_LABEL): Rename from DOT_LABEL.
	(ENTRY_1): Use FUNC_LABEL and remove leading space from label.
	Use .p2align rather than .align.
	(TRACEBACK, TRACEBACK_MASK): Use .p2align rather than .align.
	(ABORT_TRANSACTION): Likewise.
	(ENTRY_1, ENTRY_2, END_2, LOCALENTRY): Remove unnecessary semicolons,
	particularly at end.  Add semicolon at invocation as necessary.
	(TRACEBACK, TRACEBACK_MASK, PSEUDO, PSEUDO_NOERRNO): Likewise.
	(PSEUDO_ERRVAL, PPC64_LOAD_FUNCPTR, OPD_ENT): Likewise.
	* sysdeps/powerpc/powerpc64/multiarch/strrchr-power8.S (ENTRY,
	END): Adjust to suit.
2017-06-14 10:44:03 +09:30
Alan Modra fb499eb04e PowerPC64 FRAME_PARM_SAVE
I think FRAME_PARM[1-9]_SAVE confuse the code, particularly
FRAME_PARM9_SAVE.  There are only 8 parameter save slots!

	* sysdeps/powerpc/powerpc64/sysdep.h: (FRAME_BACKCHAIN,
	FRAME_CR_SAVE, FRAME_LR_SAVE): Move out of conditional.
	(FRAME_PARM1_SAVE, FRAME_PARM2_SAVE, FRAME_PARM3_SAVE,
	FRAME_PARM4_SAVE, FRAME_PARM5_SAVE, FRAME_PARM6_SAVE,
	FRAME_PARM7_SAVE, FRAME_PARM8_SAVE, FRAME_PARM9_SAVE): Delete.
	* sysdeps/unix/sysv/linux/powerpc/powerpc64/makecontext.S: Replace
	uses of FRAME_PARM[1-9]_SAVE with FRAME_PARM_SAVE plus offset.
2017-06-14 10:43:33 +09:30
Alan Modra dd8854361b PowerPC64, fix calls to _mcount
The macros used in assembly were broken on powerpc64 ELFv1.

	* sysdeps/powerpc/powerpc64/sysdep.h: (call_mcount_parm_offset): Delete.
	(SAVE_ARG, REST_ARG, CFI_SAVE_ARG): Correct.
2017-06-14 10:42:42 +09:30
Gordana Cmiljanovic b309f058cf mips: Fix store/load gp registers to/from ucontext_t
General purpose registers in mcontext_t structure
are 8 bytes long for both MIPS32/MIPS64.

get/set/make/swap context implementations for MIPS O32
incorrectly assume that general purpose registers
in this structure are 4 bytes long.

This patch is fixing that.

Tested for MIPS O32 LE and BE.
Compared objdump of modified functions for mips n32 and mips n64.

	[BZ #21548]
	* sysdeps/unix/sysv/linux/mips/getcontext.S: Define MCONTEXT_SZGREG as
	8 and use it when copying general purpose registers.
	* sysdeps/unix/sysv/linux/mips/makecontext.S: Likewise.
	* sysdeps/unix/sysv/linux/mips/mips32/Makefile: Include new test for
	mips o32.
	* sysdeps/unix/sysv/linux/mips/mips32/bug-getcontext-mips-gp.c: Added
	new test for mips o32.
	* sysdeps/unix/sysv/linux/mips/setcontext.S: Define MCONTEXT_SZGREG as
	8 and use it when copying general purpose registers.
	* sysdeps/unix/sysv/linux/mips/swapcontext.S: Likewise.
2017-06-13 21:34:45 +00:00
Zack Weinberg 46ee3da55e Remove __need_schedparam and __cpu_set_t_defined.
bits/sched.h has logic to expose only an impl-namespace variant of
struct sched_param (i.e. struct __sched_param), but nothing uses it,
and the only header that includes bits/sched.h is sched.h.  The
__need_schedparam logic can therefore be removed.

bits/sched.h also has a great deal of code relating to cpu_set_t
objects that was *almost* the same between the two versions of
bits/sched.h in the tree; a little spelunking indicated that this is
because some bug fixes got applied to the Linux-specific bits/sched.h
but not the generic one.  Introduce a new header, bits/cpu-set.h,
containing the version of that code with the bugfixes, have sched.h
include it directly, and delete all of the code from both versions of
bits/sched.h.

Also remove the unnecessary name mangling in the definition of struct
sched_param -- POSIX specifies a field 'sched_priority', so there is
no reason to define it as '__sched_priority' and then paper over that
with a macro.  (Just in case someone was using the internal name,
'sched_priority' remains a macro defined to expand to itself, and
'__sched_priority' now expands to 'sched_priority'.)

Finally, as long as I'm touching these files anyway, merge new
constants from linux/sched.h into the Linux bits/sched.h.

	* bits/sched.h: Remove __need_schedparam logic and replace with a
	normal multiple-include guard.  Change field name in struct
	sched_param from __sched_priority to sched_priority.  Delete
	everything under #ifndef __cpu_set_t_defined.
	* sysdeps/unix/sysv/linux/bits/sched.h: Likewise.  Also sync with
	kernel sched.h, adding SCHED_ISO and SCHED_DEADLINE constants.

	* posix/sched.h: Include bits/cpu-set.h as well as bits/sched.h.
	For compatibility, #define sched_priority to itself, and #define
	__sched_priority as sched_priority.
	* posix/bits/cpu-set.h: New file containing, verbatim, the code
	that was under #ifndef __cpu_set_t_defined in
	sysdeps/unix/sysv/linux/bits/sched.h.
	* include/bits/cpu-set.h: New wrapper.
	* posix/Makefile: Install bits/cpu-set.h.
2017-06-12 17:11:36 -04:00
Paul E. Murphy 45f39d4588 float128: Add strtof128, wcstof128, and related functions.
The implementations are contained with sysdeps/ieee754/float128 as
they are only built when _Float128 is enabled within libc/m.

	* include/gmp.h (__mpn_construct_float128): New declaration.
	* include/stdlib.h: Include bits/floatn.h for _Float128 tests.
	(__strtof128_l): New declaration.
	(__strtof128_nan): Likewise.
	(__wcstof128_nan): Likewise.
	(__strtof128_internal): Likewise.
	(____strtof128_l_internal): Likewise.
	* include/wchar.h: Include bits/floatn.h for _Float128 tests.
	(__wcstof128_l): New declaration.
	(__wcstof128_internal): Likewise.

	* stdlib/Makefile (bug-strtod2): Link libm too.

	* stdlib/stdlib.h (strtof128): New declaration.
	(strtof128_l): Likewise.

	* stdlib/tst-strtod-nan-locale-main.c: Updated to use
	tst-strtod.h macros to ensure float128 gets tested too.

	* stdlib/tst-strtod-round-skeleton.c (CHOOSE_f128): New macro.

	* stdlib/tst-strtod.h: Include bits/floatn.h for _Float128
	tests.
	(IF_FLOAT128): New macro.
	(GEN_TEST_STRTOD): Update to optionally include _Float128 in
	the tests.
	(STRTOD_TEST_FOREACH): Likewise.

	* sysdeps/ieee754/float128/Makefile: Insert new strtof128 and
	wcstof128 functions into libc.

	* sysdeps/ieee754/float128/Versions: Add exports for the above
	new functions.

	* sysdeps/ieee754/float128/mpn2float128.c: New file.
	* sysdeps/ieee754/float128/strtod_nan_float128.h: New file.
	* sysdeps/ieee754/float128/strtof128.c: New file.
	* sysdeps/ieee754/float128/strtof128_l.c: New file.
	* sysdeps/ieee754/float128/strtof128_nan.c: New file.
	* sysdeps/ieee754/float128/wcstof128.c: New file.
	* sysdeps/ieee754/float128/wcstof128_l.c: New file.
	* sysdeps/ieee754/float128/wcstof128_nan.c: New fike.
	* wcsmbs/Makefile: (CFLAGS-wcstof128.c): Append strtox-CFLAGS.
	(CFLAGS-wcstof128_l): Likewise.

	* wcsmbs/wchar.h: Include bits/floatn.h for _Float128 tests.
	(wcstof128): New declaration.
	(wcstof128_l): Likewise.
2017-06-12 14:48:53 -03:00
H.J. Lu 5a103908c0 x86-64: Implement strcpy family IFUNC selectors in C
Implement strcpy 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 strcpy family functions within libc.

	* sysdeps/x86_64/multiarch/Makefile (sysdep_routines): Add
	strcpy-sse2 and stpcpy-sse2.
	* sysdeps/x86_64/multiarch/ifunc-unaligned-ssse3.h: New file.
	* sysdeps/x86_64/multiarch/stpcpy-sse2.S: Likewise.
	* sysdeps/x86_64/multiarch/stpcpy.c: Likewise.
	* sysdeps/x86_64/multiarch/stpncpy.c: Likewise.
	* sysdeps/x86_64/multiarch/strcpy-sse2.S: Likewise.
	* sysdeps/x86_64/multiarch/strcpy.c: Likewise.
	* sysdeps/x86_64/multiarch/strncpy.c: Likewise.
	* sysdeps/x86_64/multiarch/stpcpy.S: Removed.
	* sysdeps/x86_64/multiarch/stpncpy.S: Likewise.
	* sysdeps/x86_64/multiarch/strcpy.S: Likewise.
	* sysdeps/x86_64/multiarch/strncpy.S: Likewise.
	* sysdeps/x86_64/multiarch/stpncpy-c.c (weak_alias): New.
	(libc_hidden_def): Always defined as empty.
	* sysdeps/x86_64/multiarch/strncpy-c.c (libc_hidden_builtin_def):
	Always Defined as empty.
2017-06-12 09:06:09 -07:00
Wilco Dijkstra d99431e519 Replace all internal uses of __bzero with memset. This removes the need
to redirect it to a builtin and means memset is inlined whenever possible,
including with -Os.

	* sunrpc/bindrsvprt.c (bindresvport): Change __bzero to memset.
	* sunrpc/clnt_gen.c (clnt_create): Likewise.
	* sunrpc/des_impl.c (_des_crypt): Likewise.
	* sunrpc/key_call.c (key_gendes): Likewise.
	* sunrpc/pmap_rmt.c (clnt_broadcast): Likewise.
	* sunrpc/svc_simple.c (universal): Likewise.
	* sunrpc/svc_tcp.c (svctcp_create): Likewise.
	* sunrpc/svc_udp.c (svcudp_bufcreate): Likewise.
	* sysdeps/arm/aeabi_memclr.c (__aeabi_memclr): Likewise.
2017-06-12 14:56:53 +01:00
Paul Clarke cdfbe5037f powerpc: add sysconf support for cache geometries
There is currently no "cross-platform" (x86 and POWER) support for
determining the cacheline size.

This patch adds support to sysconf() to correctly report cacheline sizes
based on the information in the auxilliary vector.

Thus, using sysconf() is a cross-platform (x86 and POWER) solution for
determining cacheline sizes.

Support is added (on powerpc) for:
_SC_LEVEL1_ICACHE_SIZE _SC_LEVEL1_ICACHE_ASSOC _SC_LEVEL1_ICACHE_LINESIZE
_SC_LEVEL1_DCACHE_SIZE _SC_LEVEL1_DCACHE_ASSOC _SC_LEVEL1_DCACHE_LINESIZE
_SC_LEVEL2_CACHE_SIZE  _SC_LEVEL2_CACHE_ASSOC  _SC_LEVEL2_CACHE_LINESIZE
_SC_LEVEL3_CACHE_SIZE  _SC_LEVEL3_CACHE_ASSOC  _SC_LEVEL3_CACHE_LINESIZE

	* sysdeps/unix/sysv/linux/powerpc/sysconf.c: New file.
	Add powerpc-specific overrides for L1, L2, L3 CACHE_SIZEs,
	CACHE_ASSOCs, and CACHE_LINESIZEs, retrieving from auxv.
	* sysdeps/unix/sysv/linux/powerpc/test-powerpc-linux-sysconf.c:
	New file.  Invoke newly supported sysconf values for powerpc,
	and report results.  If none are supported, report so.
	* sysdeps/unix/sysv/linux/powerpc/Makefile (tests):  Add new test,
	tst-sysconf.
2017-06-09 14:36:22 -03:00
Joseph Myers a17973efc6 Fix waitid namespace (bug 21561).
In sys/wait.h, waitid and associated constants and types are UX-shaded
in XPG4.2 (so not in XPG4), and XSI-shaded in POSIX before 2008, so
should be appropriately conditional in the headers.  This patch fixes
the conditionals accordingly.  (WCONTINUED is actually still
XSI-shaded in POSIX.1:2008, but W* is also reserved there without
XSI-shading, so nothing special needs to be done about the
conditionals on WCONTINUED to conform to POSIX.1:2008 namespace
rules.)

Tested for x86_64.

	[BZ #21561]
	* posix/sys/wait.h (idtype_t): Change [__USE_XOPEN] condition to
	[__USE_XOPEN_EXTENDED].
	(id_t): Likewise.
	(include of <bits/types/siginfo_t.h): Likewise.
	(waitid): Likewise.
	* sysdeps/unix/sysv/linux/bits/waitflags.h (WSTOPPED): Condition
	on [__USE_XOPEN_EXTENDED || __USE_XOPEN2K8].
	(WEXITED): Likewise.
	(WCONTINUED): Likewise.
	(WNOWAIT): Likewise.
	* conform/Makefile (test-xfail-XPG4/stdlib.h/conform): Remove.
	(test-xfail-XPG4/sys/wait.h/conform): Likewise.
	(test-xfail-POSIX/sys/wait.h/conform): Likewise.
2017-06-09 16:28:07 +00:00
Joseph Myers 10d33c5a86 Update nios2, sparc32 localplt.data files for recent GCC change.
A recent GCC change to expand floating-point classification built-in
functions inline using integer rather than floating-point arithmetic
in some cases resulted in localplt test failures for nios2 and sparc32
<https://sourceware.org/ml/libc-testresults/2017-q2/msg00320.html>.
This patch updates the localplt.data files in question to mark the
relevant symbols as optional / add a new optional symbol.  (The GCC
patch has been reverted because of other problems it caused, but one
can assume it will be applied again, without changes that would affect
the PLT entries generated, once those issues have been resolved.)

Tested with build-many-glibcs.py.

	* sysdeps/unix/sysv/linux/nios2/localplt.data (__gtdf2): Mark
	libc.so PLT entry optional.
	(__gtsf2): Likewise.
	(__unorddf2): Likewise.
	(__unordsf2): Likewise.
	* sysdeps/unix/sysv/linux/sparc/sparc32/localplt.data (_Q_fgt):
	New optional libc.so PLT entry.
2017-06-09 16:26:06 +00:00
H.J. Lu 6b6710e55b x86-64: Correct comments in ifunc-impl-list.c
* sysdeps/x86_64/multiarch/ifunc-impl-list.c: Correct comments.
2017-06-09 05:53:45 -07:00
H.J. Lu d2538b9156 x86-64: Optimize strrchr/wcsrchr with AVX2
Optimize strrchr/wcsrchr with AVX2 to check 32 bytes with vector
instructions.  It is as fast as SSE2 version for small data sizes
and up to 1X faster for large data sizes on Haswell.  Select AVX2
version on AVX2 machines where vzeroupper is preferred and AVX
unaligned load is fast.

	* sysdeps/x86_64/multiarch/Makefile (sysdep_routines): Add
	strrchr-sse2, strrchr-avx2, wcsrchr-sse2 and wcsrchr-avx2.
	* sysdeps/x86_64/multiarch/ifunc-impl-list.c
	(__libc_ifunc_impl_list): Add tests for __strrchr_avx2,
	__strrchr_sse2, __wcsrchr_avx2 and __wcsrchr_sse2.
	* sysdeps/x86_64/multiarch/strrchr-avx2.S: New file.
	* sysdeps/x86_64/multiarch/strrchr-sse2.S: Likewise.
	* sysdeps/x86_64/multiarch/strrchr.c: Likewise.
	* sysdeps/x86_64/multiarch/wcsrchr-avx2.S: Likewise.
	* sysdeps/x86_64/multiarch/wcsrchr-sse2.S: Likewise.
	* sysdeps/x86_64/multiarch/wcsrchr.c: Likewise.
2017-06-09 05:45:52 -07:00
H.J. Lu 5ac7aa1d7c x86-64: Optimize memrchr with AVX2
Optimize memrchr with AVX2 to search 32 bytes with a single vector
compare instruction.  It is as fast as SSE2 memrchr for small data
sizes and up to 1X faster for large data sizes on Haswell.  Select
AVX2 memrchr on AVX2 machines where vzeroupper is preferred and AVX
unaligned load is fast.

	* sysdeps/x86_64/multiarch/Makefile (sysdep_routines): Add
	memrchr-sse2 and memrchr-avx2.
	* sysdeps/x86_64/multiarch/ifunc-impl-list.c
	(__libc_ifunc_impl_list): Add tests for __memrchr_avx2 and
	__memrchr_sse2.
	* sysdeps/x86_64/multiarch/memrchr-avx2.S: New file.
	* sysdeps/x86_64/multiarch/memrchr-sse2.S: Likewise.
	* sysdeps/x86_64/multiarch/memrchr.c: Likewise.
2017-06-09 05:44:41 -07:00
H.J. Lu 8fe57365bf x86-64: Optimize strchr/strchrnul/wcschr with AVX2
Optimize strchr/strchrnul/wcschr with AVX2 to search 32 bytes with vector
instructions.  It is as fast as SSE2 versions for size <= 16 bytes and up
to 1X faster for or size > 16 bytes on Haswell.  Select AVX2 version on
AVX2 machines where vzeroupper is preferred and AVX unaligned load is fast.

NB: It uses TZCNT instead of BSF since TZCNT produces the same result
as BSF for non-zero input.  TZCNT is faster than BSF and is executed
as BSF if machine doesn't support TZCNT.

	* sysdeps/x86_64/multiarch/Makefile (sysdep_routines): Add
	strchr-sse2, strchrnul-sse2, strchr-avx2, strchrnul-avx2,
	wcschr-sse2 and wcschr-avx2.
	* sysdeps/x86_64/multiarch/ifunc-impl-list.c
	(__libc_ifunc_impl_list): Add tests for __strchr_avx2,
	__strchrnul_avx2, __strchrnul_sse2, __wcschr_avx2 and
	__wcschr_sse2.
	* sysdeps/x86_64/multiarch/strchr-avx2.S: New file.
	* sysdeps/x86_64/multiarch/strchr-sse2.S: Likewise.
	* sysdeps/x86_64/multiarch/strchr.c: Likewise.
	* sysdeps/x86_64/multiarch/strchrnul-avx2.S: Likewise.
	* sysdeps/x86_64/multiarch/strchrnul-sse2.S: Likewise.
	* sysdeps/x86_64/multiarch/strchrnul.c: Likewise.
	* sysdeps/x86_64/multiarch/wcschr-avx2.S: Likewise.
	* sysdeps/x86_64/multiarch/wcschr-sse2.S: Likewise.
	* sysdeps/x86_64/multiarch/wcschr.c: Likewise.
	* sysdeps/x86_64/multiarch/strchr.S: Removed.
2017-06-09 05:42:29 -07:00
H.J. Lu dc485ceb2a x86-64: Optimize strlen/strnlen/wcslen/wcsnlen with AVX2
Optimize strlen/strnlen/wcslen/wcsnlen with AVX2 to check 32 bytes with
a single vector compare instruction.  It is as fast as SSE2 versions for
size <= 16 bytes and up to 1X faster for or size > 16 bytes on Haswell.
Select AVX2 version on AVX2 machines where vzeroupper is preferred and
AVX unaligned load is fast.

NB: It uses TZCNT instead of BSF since TZCNT produces the same result
as BSF for non-zero input.  TZCNT is faster than BSF and is executed
as BSF if machine doesn't support TZCNT.

	* sysdeps/x86_64/multiarch/Makefile (sysdep_routines): Add
	strlen-sse2, strnlen-sse2, strlen-avx2, strnlen-avx2,
	wcslen-sse2, wcslen-avx2 and wcsnlen-avx2.
	* sysdeps/x86_64/multiarch/ifunc-impl-list.c
	(__libc_ifunc_impl_list): Add tests for __strlen_avx2,
	__strlen_sse2, __strnlen_avx2, __strnlen_sse2, __wcslen_avx2,
	__wcslen_sse2 and __wcsnlen_avx2.
	* sysdeps/x86_64/multiarch/strlen-avx2.S: New file.
	* sysdeps/x86_64/multiarch/strlen-sse2.S: Likewise.
	* sysdeps/x86_64/multiarch/strlen.c: Likewise.
	* sysdeps/x86_64/multiarch/strnlen-avx2.S: Likewise.
	* sysdeps/x86_64/multiarch/strnlen-sse2.S: Likewise.
	* sysdeps/x86_64/multiarch/strnlen.c: Likewise.
	* sysdeps/x86_64/multiarch/wcslen-avx2.S: Likewise.
	* sysdeps/x86_64/multiarch/wcslen-sse2.S: Likewise.
	* sysdeps/x86_64/multiarch/wcslen.c: Likewise.
	* sysdeps/x86_64/multiarch/wcsnlen-avx2.S: Likewise.
	* sysdeps/x86_64/multiarch/wcsnlen.c (OPTIMIZE (avx2)): New.
	(IFUNC_SELECTOR): Return OPTIMIZE (avx2) on AVX2 machines where
	vzeroupper is preferred and AVX unaligned load is fast.
2017-06-09 05:18:18 -07:00
H.J. Lu 2f5d20ac99 x86-64: Optimize memchr/rawmemchr/wmemchr with SSE2/AVX2
SSE2 memchr is extended to support wmemchr.  AVX2 memchr/rawmemchr/wmemchr
are added to search 32 bytes with a single vector compare instruction.
AVX2 memchr/rawmemchr/wmemchr are as fast as SSE2 memchr/rawmemchr/wmemchr
for small sizes and up to 1.5X faster for larger sizes on Haswell and
Skylake.  Select AVX2 memchr/rawmemchr/wmemchr on AVX2 machines where
vzeroupper is preferred and AVX unaligned load is fast.

NB: It uses TZCNT instead of BSF since TZCNT produces the same result
as BSF for non-zero input.  TZCNT is faster than BSF and is executed
as BSF if machine doesn't support TZCNT.

	* sysdeps/x86_64/memchr.S (MEMCHR): New.  Depending on if
	USE_AS_WMEMCHR is defined.
	(PCMPEQ): Likewise.
	(memchr): Renamed to ...
	(MEMCHR): This.  Support wmemchr if USE_AS_WMEMCHR is defined.
	Replace pcmpeqb with PCMPEQ.
	* sysdeps/x86_64/multiarch/Makefile (sysdep_routines): Add
	memchr-sse2, rawmemchr-sse2, memchr-avx2, rawmemchr-avx2,
	wmemchr-sse4_1, wmemchr-avx2 and wmemchr-c.
	* sysdeps/x86_64/multiarch/ifunc-avx2.h: New file.
	* sysdeps/x86_64/multiarch/memchr-avx2.S: Likewise.
	* sysdeps/x86_64/multiarch/memchr-sse2.S: Likewise.
	* sysdeps/x86_64/multiarch/memchr.c: Likewise.
	* sysdeps/x86_64/multiarch/rawmemchr-avx2.S: Likewise.
	* sysdeps/x86_64/multiarch/rawmemchr-sse2.S: Likewise.
	* sysdeps/x86_64/multiarch/rawmemchr.c: Likewise.
	* sysdeps/x86_64/multiarch/wmemchr-avx2.S: Likewise.
	* sysdeps/x86_64/multiarch/wmemchr-sse2.S: Likewise.
	* sysdeps/x86_64/multiarch/wmemchr.c: Likewise.
	* sysdeps/x86_64/multiarch/ifunc-impl-list.c
	(__libc_ifunc_impl_list): Test __memchr_avx2, __memchr_sse2,
	__rawmemchr_avx2, __rawmemchr_sse2, __wmemchr_avx2 and
	__wmemchr_sse2.
2017-06-09 05:13:31 -07:00
Siddhesh Poyarekar 6c85cc2852 aarch64: Fix undefined behavior in _dl_procinfo
1 << 31 is undefined, so replace it with a cleaner check.  Also remove
magic numbers in comments.

	* sysdeps/unix/sysv/linux/aarch64/dl-procinfo.h: Remove
	mention of magic numbers in comments.
	(_dl_procinfo): Fix undefined behavior
2017-06-09 14:18:12 +05:30
H.J. Lu 37b66c0b1a ld.so: Consolidate 2 strtouls into _dl_strtoul [BZ #21528]
There are 2 minimal strtoul implementations in ld.so:

1. __strtoul_internal in elf/dl-minimal.c.
2. tunables_strtoul in elf/dl-tunables.c.

This patch adds _dl_strtoul to replace them.  Tested builds with and
without --enable-tunables.

	[BZ #21528]
	* elf/dl-minimal.c (__strtoul_internal): Removed.
	(strtoul): Likewise.
	* elf/dl-misc.c (_dl_strtoul): New function.
	* elf/dl-tunables.c (tunables_strtoul): Removed.
	(tunable_initialize): Replace tunables_strtoul with _dl_strtoul.
	* elf/rtld.c (process_envvars): Likewise.
	* sysdeps/unix/sysv/linux/dl-librecon.h (_dl_osversion_init):
	Likewise.
	* sysdeps/generic/ldsodefs.h (_dl_strtoul): New prototype.
2017-06-08 12:52:42 -07:00
Zack Weinberg 199fc19d3a Remove __need macros from stdio.h and wchar.h.
wint_t is a little finicky because it might be defined by stddef.h, which
belongs to the compiler.

In addition to the _types_, a bunch of other declarations shared between
wctype.h and wchar.h are factored out to their own header.

	* libio/bits/types/FILE.h, libio/bits/types/__FILE.h
	* wcsmbs/bits/types/mbstate_t.h, wcsmbs/bits/types/__mbstate_t.h
	* wcsmbs/bits/types/wint_t.h: New single-type definition files.
	* wctype/bits/wctype-wchar.h: New file holding declarations shared
	between wctype.h and wchar.h.

	* libio/Makefile, wcsmbs/Makefile, wctype/Makefile:
	Install them.

	* include/bits/types/FILE.h, include/bits/types/__FILE.h
	* include/bits/types/mbstate_t.h, include/bits/types/__mbstate_t.h
	* include/bits/types/wint_t.h, include/bits/wcsmbs-wchar.h:
	New wrappers.
	* include/stdio.h, include/wchar.h, include/wctype.h:
	No need to handle __need macros.

	* grp/grp.h, gshadow/gshadow.h, hurd/hurd.h, iconv/gconv.h
	* libio/stdio.h, mach/mach.h, misc/mntent.h, pwd/pwd.h
	* shadow/shadow.h, stdio-common/printf.h, wcsmbs/uchar.h
	* wcsmbs/wchar.h, wctype/wctype.h
	* sysdeps/generic/_G_config.h, sysdeps/unix/sysv/linux/_G_config.h
	Use the new files instead of __need macros.
2017-06-08 13:58:17 -04:00
H.J. Lu 5e1122827a x86-64: Rename wmemset.h to ifunc-wmemset.h
No code changes.

	* sysdeps/x86_64/multiarch/wmemset.c: Include ifunc-wmemset.h
	instead of wmemset.h.
	* sysdeps/x86_64/multiarch/wmemset_chk.c: Likewise.
	* sysdeps/x86_64/multiarch/wmemset.h: Renamed to ...
	* sysdeps/x86_64/multiarch/ifunc-wmemset.h: This.
2017-06-07 14:48:34 -07:00
Gabriel F. T. Gomes cf2046ec7d float128: Add strfromf128
Add strfromf128 to stdlib when _Float128 support is enabled.

	* stdio-common/printf-parsemb.c (__parse_one_specmb): Initialize
	spec->info.is_binary128 to zero.
	* stdio-common/printf.h (printf_info): Add new member is_binary128
	to indicate that the number being converted to string is compatible
	with the IEC 60559 binary128 format.
	* stdio-common/printf_fp.c (__printf_fp_l): Add code to deal with
	_Float128 numbers.
	* stdio-common/printf_fphex.c: Include ieee754_float128.h and
	ldbl-128/printf_fphex_macros.h
	(__printf_fphex): Add code to deal with _Float128 numbers.
	* stdio-common/printf_size.c (__printf_size): Likewise.
	* stdio-common/vfprintf.c (process_arg): Initialize member
	info.is_binary128 to zero.
	* stdlib/fpioconst.h (FLT128_MAX_10_EXP_LOG): New macro.
	* stdlib/stdlib.h: Include bits/floatn.h for _Float128 support.
	(strfromf128): New declaration.
	* stdlib/strfrom-skeleton.c (STRFROM): Set member info.is_binary128
	to one.
	* sysdeps/ieee754/float128/Makefile: Add strfromf128.
	* sysdeps/ieee754/float128/Versions: Likewise.
	* sysdeps/ieee754/float128/strfromf128.c: New file.
2017-06-07 17:08:21 -03:00
Gabriel F. T. Gomes 2bc646c9e9 Refactor PRINT_FPHEX_LONG_DOUBLE into a reusable macro
This patch refactors the macro PRINT_FPHEX_LONG_DOUBLE from the file
sysdeps/ieee754/ldbl-128/printf_fphex.c into a function-like macro to
enable its use for both long double and _Float128, when they are
ABI-distinct.

	* sysdeps/ieee754/ldbl-128/printf_fphex.c: Include
	ldbl-128/printf_fphex_macros.h for the definition of PRINT_FPHEX.
	(PRINT_FPHEX_LONG_DOUBLE): Define based on PRINT_FPHEX.
	* sysdeps/ieee754/ldbl-128/printf_fphex_macros.h
	(PRINT_FPHEX): New function-like macro that can be used for long
	double, as well as for _Float128
2017-06-07 17:06:31 -03:00
Gabriel F. T. Gomes 32bf1d09da float128: Add conversion from float128 to mpn
Reuse the code for __mpn_extract_long_double to implement
__mpn_extract_float128.

	* include/gmp.h: Include bits/floatn.h
	(__mpn_extract_float128): Declare when __HAVE_DISTINCT_FLOAT128 is 1.
	* stdlib/gmp-impl.h: Also check if alloca is not defined before
	including stack-alloc.h.  It could have been defined by other header
	which not necessarily defines HAVE_ALLOCA.
	* sysdeps/ieee754/float128/Makefile: New file.
	* sysdeps/ieee754/float128/float1282mpn.c: New file.
	* sysdeps/ieee754/float128/float128_private.h: Include gmp.h before
	redefining __mpn_extract_long_double to __mpn_extract_float128, then
	redefine __mpn_extract_long_double to __mpn_extract_float128.
	* sysdeps/ieee754/ldbl-128/ldbl2mpn.c: Replace long double with
	_Float128 to allow float128_private.h overrides.
2017-06-07 17:03:43 -03:00
H.J. Lu 2e87c7d158 x86-64: Fold ifunc-sse4_1.h into wcsnlen.c
Since ifunc-sse4_1.h is included only by wcsnlen.c, we can fold it
into wcsnlen.c.  No code changes in wcsnlen.o.

2017-06-07  H.J. Lu  <hongjiu.lu@intel.com>

	* sysdeps/x86_64/multiarch/ifunc-sse4_1.h: Removed and folded
	into ...
	* sysdeps/x86_64/multiarch/wcsnlen.c: Here.  Don't include
	ifunc-sse4_1.h.
2017-06-07 09:04:40 -07:00
Arjun Shankar 8f0a947cf5 Remove check for NULL buffer passed to `ptsname_r'
`ptsname_r' is declared in stdlib.h to only accept a `nonnull'
second argument and therefore GCC may choose to make optimizations
based on the assumption that this argument is NULL. This means
that potentially, GCC can optimize away the NULL check at some
point in the future. Since this is a programming interface, we
might as well remove the NULL check ourselves.

This also warrants a change to the `ptsname_r' manual page that
must be submitted to the corresponding mailing list.

In addition, remove the NULL buffer test in login/tst-ptsname.c.
2017-06-07 17:37:59 +02:00
Arjun Shankar fdc543919a Use test-driver in sysdeps/unix/sysv/linux/tst-clone2.c 2017-06-07 14:05:42 +02:00
Siddhesh Poyarekar ea01a4da21 aarch64: Add hwcap string routines
Add support for routines in dl-procinfo.h to show string versions of
HWCAP entries when a program is invoked with the LD_SHOW_AUXV
environment variable set and also to aid in path resolution for
ldconfig.

	* sysdeps/unix/sysv/linux/aarch64/dl-procinfo.c
	(_dl_aarch64_cap_flags): New array.
	* sysdeps/unix/sysv/linux/aarch64/dl-procinfo.h
	(_dl_hwcap_string, _dl_string_hwcap, _dl_procinfo): Implement
	functions.
2017-06-07 11:11:40 +05:30
Siddhesh Poyarekar 511c5a1087 Make LD_HWCAP_MASK usable for static binaries
The LD_HWCAP_MASK environment variable was ignored in static binaries,
which is inconsistent with the behaviour of dynamically linked
binaries.  This seems to have been because of the inability of
ld_hwcap_mask being read early enough to influence anything but now
that it is in tunables, the mask is usable in static binaries as well.

This feature is important for aarch64, which relies on HWCAP_CPUID
being masked out to disable multiarch.  A sanity test on x86_64 shows
that there are no failures.  Likewise for aarch64.

	* elf/dl-hwcaps.h [HAVE_TUNABLES]: Always read hwcap_mask.
	* sysdeps/sparc/sparc32/dl-machine.h [HAVE_TUNABLES]:
	Likewise.
	* sysdeps/x86/cpu-features.c (init_cpu_features): Always set
	up hwcap and hwcap_mask.
2017-06-07 11:11:40 +05:30
Siddhesh Poyarekar f82e9672ad aarch64: Allow overriding HWCAP_CPUID feature check using HWCAP_MASK
Now that LD_HWCAP_MASK (or glibc.tune.hwcap_mask) is read early enough
to influence cpu feature check in aarch64, use it to influence
multiarch selection.  Setting LD_HWCAP_MASK such that it clears
HWCAP_CPUID will now disable multiarch for the binary.

HWCAP_CPUID is also now set in HWCAP_IMPORTANT so that it is set by
default.  With this patch, this feature is only usable with
dyanmically linked binaries because LD_HWCAP_MASK is not read for
static binaries.  A future patch fixes that.

	* sysdeps/unix/sysv/linux/aarch64/cpu-features.c
	(init_cpu_features): Use glibc.tune.hwcap_mask.
	* sysdeps/unix/sysv/linux/aarch64/dl-procinfo.h: New file.
2017-06-07 11:11:39 +05:30
Siddhesh Poyarekar ff08fc59e3 tunables: Use glibc.tune.hwcap_mask tunable instead of _dl_hwcap_mask
Drop _dl_hwcap_mask when building with tunables.  This completes the
transition of hwcap_mask reading from _dl_hwcap_mask to tunables.

	* elf/dl-hwcaps.h: New file.
	* elf/dl-hwcaps.c: Include it.
	(_dl_important_hwcaps)[HAVE_TUNABLES]: Read and update
	glibc.tune.hwcap_mask.
	* elf/dl-cache.c: Include dl-hwcaps.h.
	(_dl_load_cache_lookup)[HAVE_TUNABLES]: Read
	glibc.tune.hwcap_mask.
	* sysdeps/sparc/sparc32/dl-machine.h: Likewise.
	* elf/dl-support.c (_dl_hwcap2)[HAVE_TUNABLES]: Drop
	_dl_hwcap_mask.
	* elf/rtld.c (rtld_global_ro)[HAVE_TUNABLES]: Drop
	_dl_hwcap_mask.
	(process_envvars)[HAVE_TUNABLES]: Likewise.
	* sysdeps/generic/ldsodefs.h (rtld_global_ro)[HAVE_TUNABLES]:
	Likewise.
	* sysdeps/x86/cpu-features.c (init_cpu_features): Don't
	initialize dl_hwcap_mask when tunables are enabled.
2017-06-07 11:11:38 +05:30
Siddhesh Poyarekar 6482e63403 Add include guards to dl-procinfo.h
The dl-procinfo.h for linux/s390 and linux/i386 don't have include
guards, which causes them to fail since addition of LD_HWCAP_MASK to
tunables.  Add _DL_I386_PROCINFO_H guard to avoid redefining
_dl_procinfo on multiple includes and also allow the subsequent
include of another dl-procinfo.h to work.

Verified with a build test on i686.

	* sysdeps/unix/sysv/linux/i386/dl-procinfo.h: Add include
	guard.
	* sysdeps/unix/sysv/linux/s390/dl-procinfo.h: Likewise.
2017-06-07 11:11:38 +05:30
H.J. Lu d4cc385c6e x86-64: Move wcsnlen.S to multiarch/wcsnlen-sse4_1.S
Since wcsnlen.S uses pminud which is the part of SSE4.1, move wcsnlen.S
to multiarch/wcsnlen-sse4_1.S.

	* sysdeps/x86_64/multiarch/Makefile (sysdep_routines): Add
	wcsnlen-sse4_1 and wcsnlen-c.
	* sysdeps/x86_64/multiarch/ifunc-impl-list.c
	(__libc_ifunc_impl_list): Test __wcsnlen_sse4_1 and
	__wcsnlen_sse2.
	* sysdeps/x86_64/multiarch/ifunc-sse4_1.h: New file.
	* sysdeps/x86_64/multiarch/wcsnlen-c.c: Likewise.
	* sysdeps/x86_64/multiarch/wcsnlen-sse4_1.S: Likewise.
	* sysdeps/x86_64/multiarch/wcsnlen.c: Likewise.
	* sysdeps/x86_64/wcsnlen.S: Removed.
2017-06-06 06:12:32 -07:00
Stefan Liebler 4bf7abaeb3 S390: Use generic spinlock code.
This patch removes the s390 specific implementation of spinlock code
and is now using the generic one.

ChangeLog:

	* sysdeps/s390/nptl/pthread_spin_init.c: Delete File.
	* sysdeps/s390/nptl/pthread_spin_lock.c: Likewise.
	* sysdeps/s390/nptl/pthread_spin_trylock.c: Likewise.
	* sysdeps/s390/nptl/pthread_spin_unlock.c: Likewise.
2017-06-06 09:41:56 +02:00
Stefan Liebler 12d2dd7060 Optimize generic spinlock code and use C11 like atomic macros.
This patch optimizes the generic spinlock code.

The type pthread_spinlock_t is a typedef to volatile int on all archs.
Passing a volatile pointer to the atomic macros which are not mapped to the
C11 atomic builtins can lead to extra stores and loads to stack if such
a macro creates a temporary variable by using "__typeof (*(mem)) tmp;".
Thus, those macros which are used by spinlock code - atomic_exchange_acquire,
atomic_load_relaxed, atomic_compare_exchange_weak - have to be adjusted.
According to the comment from  Szabolcs Nagy, the type of a cast expression is
unqualified (see http://www.open-std.org/jtc1/sc22/wg14/www/docs/dr_423.htm):
__typeof ((__typeof (*(mem)) *(mem)) tmp;
Thus from spinlock perspective the variable tmp is of type int instead of
type volatile int.  This patch adjusts those macros in include/atomic.h.
With this construct GCC >= 5 omits the extra stores and loads.

The atomic macros are replaced by the C11 like atomic macros and thus
the code is aligned to it.  The pthread_spin_unlock implementation is now
using release memory order instead of sequentially consistent memory order.
The issue with passed volatile int pointers applies to the C11 like atomic
macros as well as the ones used before.

I've added a glibc_likely hint to the first atomic exchange in
pthread_spin_lock in order to return immediately to the caller if the lock is
free.  Without the hint, there is an additional jump if the lock is free.

I've added the atomic_spin_nop macro within the loop of plain reads.
The plain reads are also realized by C11 like atomic_load_relaxed macro.

The new define ATOMIC_EXCHANGE_USES_CAS determines if the first try to acquire
the spinlock in pthread_spin_lock or pthread_spin_trylock is an exchange
or a CAS.  This is defined in atomic-machine.h for all architectures.

The define SPIN_LOCK_READS_BETWEEN_CMPXCHG is now removed.
There is no technical reason for throwing in a CAS every now and then,
and so far we have no evidence that it can improve performance.
If that would be the case, we have to adjust other spin-waiting loops
elsewhere, too!  Using a CAS loop without plain reads is not a good idea
on many targets and wasn't used by one.  Thus there is now no option to
do so.

Architectures are now using the generic spinlock automatically if they
do not provide an own implementation.  Thus the pthread_spin_lock.c files
in sysdeps folder are deleted.

ChangeLog:

	* NEWS: Mention new spinlock implementation.
	* include/atomic.h:
	(__atomic_val_bysize): Cast type to omit volatile qualifier.
	(atomic_exchange_acq): Likewise.
	(atomic_load_relaxed): Likewise.
	(ATOMIC_EXCHANGE_USES_CAS): Check definition.
	* nptl/pthread_spin_init.c (pthread_spin_init):
	Use atomic_store_relaxed.
	* nptl/pthread_spin_lock.c (pthread_spin_lock):
	Use C11-like atomic macros.
	* nptl/pthread_spin_trylock.c (pthread_spin_trylock):
	Likewise.
	* nptl/pthread_spin_unlock.c (pthread_spin_unlock):
	Use atomic_store_release.
	* sysdeps/aarch64/nptl/pthread_spin_lock.c: Delete File.
	* sysdeps/arm/nptl/pthread_spin_lock.c: Likewise.
	* sysdeps/hppa/nptl/pthread_spin_lock.c: Likewise.
	* sysdeps/m68k/nptl/pthread_spin_lock.c: Likewise.
	* sysdeps/microblaze/nptl/pthread_spin_lock.c: Likewise.
	* sysdeps/mips/nptl/pthread_spin_lock.c: Likewise.
	* sysdeps/nios2/nptl/pthread_spin_lock.c: Likewise.
	* sysdeps/aarch64/atomic-machine.h (ATOMIC_EXCHANGE_USES_CAS): Define.
	* sysdeps/alpha/atomic-machine.h: Likewise.
	* sysdeps/arm/atomic-machine.h: Likewise.
	* sysdeps/i386/atomic-machine.h: Likewise.
	* sysdeps/ia64/atomic-machine.h: Likewise.
	* sysdeps/m68k/coldfire/atomic-machine.h: Likewise.
	* sysdeps/m68k/m680x0/m68020/atomic-machine.h: Likewise.
	* sysdeps/microblaze/atomic-machine.h: Likewise.
	* sysdeps/mips/atomic-machine.h: Likewise.
	* sysdeps/powerpc/powerpc32/atomic-machine.h: Likewise.
	* sysdeps/powerpc/powerpc64/atomic-machine.h: Likewise.
	* sysdeps/s390/atomic-machine.h: Likewise.
	* sysdeps/sparc/sparc32/atomic-machine.h: Likewise.
	* sysdeps/sparc/sparc32/sparcv9/atomic-machine.h: Likewise.
	* sysdeps/sparc/sparc64/atomic-machine.h: Likewise.
	* sysdeps/tile/tilegx/atomic-machine.h: Likewise.
	* sysdeps/tile/tilepro/atomic-machine.h: Likewise.
	* sysdeps/unix/sysv/linux/hppa/atomic-machine.h: Likewise.
	* sysdeps/unix/sysv/linux/m68k/coldfire/atomic-machine.h: Likewise.
	* sysdeps/unix/sysv/linux/nios2/atomic-machine.h: Likewise.
	* sysdeps/unix/sysv/linux/sh/atomic-machine.h: Likewise.
	* sysdeps/x86_64/atomic-machine.h: Likewise.
2017-06-06 09:41:56 +02:00
H.J. Lu 48e7bc7a55 x86: Don't use dl_x86_cpu_features in cacheinfo.c
Since cpu_features is available, use it instead of dl_x86_cpu_features.

	* sysdeps/x86/cacheinfo.c (intel_check_word): Accept cpu_features
	and use it instead of dl_x86_cpu_features.
	(handle_intel): Replace maxidx with cpu_features.  Pass
	cpu_features to intel_check_word.
	(__cache_sysconf): Pass cpu_features to handle_intel.
	(init_cacheinfo): Likewise.  Use cpu_features instead of
	dl_x86_cpu_features.
2017-06-05 16:20:11 -07:00
H.J. Lu 935971ba6b x86-64: Optimize memcmp/wmemcmp with AVX2 and MOVBE
Optimize x86-64 memcmp/wmemcmp with AVX2.  It uses vector compare as
much as possible.  It is as fast as SSE4 memcmp for size <= 16 bytes
and up to 2X faster for size > 16 bytes on Haswell and Skylake.  Select
AVX2 memcmp/wmemcmp on AVX2 machines where vzeroupper is preferred and
AVX unaligned load is fast.

NB: It uses TZCNT instead of BSF since TZCNT produces the same result
as BSF for non-zero input.  TZCNT is faster than BSF and is executed
as BSF if machine doesn't support TZCNT.

Key features:

1. For size from 2 to 7 bytes, load as big endian with movbe and bswap
   to avoid branches.
2. Use overlapping compare to avoid branch.
3. Use vector compare when size >= 4 bytes for memcmp or size >= 8
   bytes for wmemcmp.
4. If size is 8 * VEC_SIZE or less, unroll the loop.
5. Compare 4 * VEC_SIZE at a time with the aligned first memory area.
6. Use 2 vector compares when size is 2 * VEC_SIZE or less.
7. Use 4 vector compares when size is 4 * VEC_SIZE or less.
8. Use 8 vector compares when size is 8 * VEC_SIZE or less.

	* sysdeps/x86/cpu-features.h (index_cpu_MOVBE): New.
	* sysdeps/x86_64/multiarch/Makefile (sysdep_routines): Add
	memcmp-avx2 and wmemcmp-avx2.
	* sysdeps/x86_64/multiarch/ifunc-impl-list.c
	(__libc_ifunc_impl_list): Test __memcmp_avx2 and __wmemcmp_avx2.
	* sysdeps/x86_64/multiarch/memcmp-avx2.S: New file.
	* sysdeps/x86_64/multiarch/wmemcmp-avx2.S: Likewise.
	* sysdeps/x86_64/multiarch/memcmp.S: Use __memcmp_avx2 on AVX
	2 machines if AVX unaligned load is fast and vzeroupper is
	preferred.
	* sysdeps/x86_64/multiarch/wmemcmp.S: Use __wmemcmp_avx2 on AVX
	2 machines if AVX unaligned load is fast and vzeroupper is
	preferred.
2017-06-05 12:52:55 -07:00
H.J. Lu ef9c4cb6c7 x86-64: Optimize wmemset with SSE2/AVX2/AVX512
The difference between memset and wmemset is byte vs int.  Add stubs
to SSE2/AVX2/AVX512 memset for wmemset with updated constant and size:

SSE2 wmemset:
	shl    $0x2,%rdx
	movd   %esi,%xmm0
	mov    %rdi,%rax
	pshufd $0x0,%xmm0,%xmm0
	jmp	entry_from_wmemset

SSE2 memset:
	movd   %esi,%xmm0
	mov    %rdi,%rax
	punpcklbw %xmm0,%xmm0
	punpcklwd %xmm0,%xmm0
	pshufd $0x0,%xmm0,%xmm0
entry_from_wmemset:

Since the ERMS versions of wmemset requires "rep stosl" instead of
"rep stosb", only the vector store stubs of SSE2/AVX2/AVX512 wmemset
are added.  The SSE2 wmemset is about 3X faster and the AVX2 wmemset
is about 6X faster on Haswell.

	* include/wchar.h (__wmemset_chk): New.
	* sysdeps/x86_64/memset.S (VDUP_TO_VEC0_AND_SET_RETURN): Renamed
	to MEMSET_VDUP_TO_VEC0_AND_SET_RETURN.
	(WMEMSET_VDUP_TO_VEC0_AND_SET_RETURN): New.
	(WMEMSET_CHK_SYMBOL): Likewise.
	(WMEMSET_SYMBOL): Likewise.
	(__wmemset): Add hidden definition.
	(wmemset): Add weak hidden definition.
	* sysdeps/x86_64/multiarch/Makefile (sysdep_routines): Add
	wmemset_chk-nonshared.
	* sysdeps/x86_64/multiarch/ifunc-impl-list.c
	(__libc_ifunc_impl_list): Add __wmemset_sse2_unaligned,
	__wmemset_avx2_unaligned, __wmemset_avx512_unaligned,
	__wmemset_chk_sse2_unaligned, __wmemset_chk_avx2_unaligned
	and __wmemset_chk_avx512_unaligned.
	* sysdeps/x86_64/multiarch/memset-avx2-unaligned-erms.S
	(VDUP_TO_VEC0_AND_SET_RETURN): Renamed to ...
	(MEMSET_VDUP_TO_VEC0_AND_SET_RETURN): This.
	(WMEMSET_VDUP_TO_VEC0_AND_SET_RETURN): New.
	(WMEMSET_SYMBOL): Likewise.
	* sysdeps/x86_64/multiarch/memset-avx512-unaligned-erms.S
	(VDUP_TO_VEC0_AND_SET_RETURN): Renamed to ...
	(MEMSET_VDUP_TO_VEC0_AND_SET_RETURN): This.
	(WMEMSET_VDUP_TO_VEC0_AND_SET_RETURN): New.
	(WMEMSET_SYMBOL): Likewise.
	* sysdeps/x86_64/multiarch/memset-vec-unaligned-erms.S: Updated.
	(WMEMSET_CHK_SYMBOL): New.
	(WMEMSET_CHK_SYMBOL (__wmemset_chk, unaligned)): Likewise.
	(WMEMSET_SYMBOL (__wmemset, unaligned)): Likewise.
	* sysdeps/x86_64/multiarch/memset.S (WMEMSET_SYMBOL): New.
	(libc_hidden_builtin_def): Also define __GI_wmemset and
	__GI___wmemset.
	(weak_alias): New.
	* sysdeps/x86_64/multiarch/wmemset.c: New file.
	* sysdeps/x86_64/multiarch/wmemset.h: Likewise.
	* sysdeps/x86_64/multiarch/wmemset_chk-nonshared.S: Likewise.
	* sysdeps/x86_64/multiarch/wmemset_chk.c: Likewise.
	* sysdeps/x86_64/wmemset.c: Likewise.
	* sysdeps/x86_64/wmemset_chk.c: Likewise.
2017-06-05 11:09:59 -07:00
H.J. Lu 9cd30491dd x86: Add macros to implement ifunce selection in C
These macros are used to implement ifunc selection in C.  To implement
an ifunc function, foo, which returns the address of __foo_sse2 or
__foo_avx2:

   __foo_avx2:

   #define foo __redirect_foo
   #define __foo __redirect___foo
   #include <foo.h>
   #undef foo
   #undef __foo
   #define SYMBOL_NAME foo
   #include <init-arch.h>

   extern __typeof (REDIRECT_NAME) OPTIMIZE (sse2) attribute_hidden;
   extern __typeof (REDIRECT_NAME) OPTIMIZE (avx2) attribute_hidden;

   static inline void *
   foo_selector (void)
   {
     if (use AVX2)
      return OPTIMIZE (avx2);

     return OPTIMIZE (sse2);
   }

   libc_ifunc_redirected (__redirect_foo, foo, foo_selector ());

	* sysdeps/x86/init-arch.h (PASTER1): New.
	(EVALUATOR1): Likewise.
	(PASTER2): Likewise.
	(EVALUATOR2): Likewise.
	(REDIRECT_NAME): Likewise.
	(OPTIMIZE): Likewise.
	(IFUNC_SELECTOR): Likewise.
2017-06-05 08:28:13 -07:00
H.J. Lu 30cb625a21 x86-64: Update strlen.S to support wcslen/wcsnlen
The difference between strlen and wcslen is byte vs int.  We can
replace pminub and pcmpeqb with pminud and pcmpeqd to turn strlen
into wcslen.

	* sysdeps/x86_64/strlen.S (PMINU): New.
	(PCMPEQ): Likewise.
	(SHIFT_RETURN): Likewise.
	(FIND_ZERO): Replace pcmpeqb with PCMPEQ.
	(strlen): Add SHIFT_RETURN before ret.  Replace pcmpeqb and
	pminub with PCMPEQ and PMINU.
	* sysdeps/x86_64/wcsnlen.S: New file.
2017-06-05 07:58:23 -07:00
H.J. Lu 7395928b95 x86_64: Remove redundant REX bytes from memrchr.S
By x86-64 specification, 32-bit destination registers are zero-extended
to 64 bits.  There is no need to use 64-bit registers when only the lower
32 bits are non-zero.  Also 2 instructions in:

	mov	%rdi, %rcx
	and	$15, %rcx
	jz	L(length_less16_offset0)

	mov	%rdi, %rcx		<<< redundant
	and	$15, %rcx		<<< redundant

are redundant.

	* sysdeps/x86_64/memrchr.S (__memrchr): Use 32-bit registers for
	the lower 32 bits.  Remove redundant instructions.
2017-06-05 07:41:26 -07:00
H.J. Lu d8a7d10324 x86-64: Update LO_HI_LONG for p{readv,writev}{64}v2
The kernel interface for p{readv,writev}{64}v is

(unsigned long fd, {const }struct iovec *iov, unsigned long vlen,
 unsigned long pos_l, unsigned long pos_h)

Except for targets which define __ARCH_WANT_COMPAT_SYS_PREADV64 and
__ARCH_WANT_COMPAT_SYS_PWRITEV64,

(unsigned long fd, {const }struct iovec *iov, unsigned long vlen,
 off64_t pos)

is used for p{readv,writev}{64}v.  X32 is the only such target.  The
LO_HI_LONG macro is used to pass offset to the pos_l and pos_h pair.
Since pos_h is ignored when size of offset == sizeof of pos_l, x86-64
has

 #define LO_HI_LONG(val) (val)

But the kernel interface for p{readv,writev}{64}v2 is

(unsigned long fd, {const }struct iovec *iov, unsigned long vlen,
 unsigned long pos_l, unsigned long pos_h, int flags)

Except for targets which define __ARCH_WANT_COMPAT_SYS_PREADV64V2 and
__ARCH_WANT_COMPAT_SYS_PWRITEV64V2,

(unsigned long fd, {const }struct iovec *iov, unsigned long vlen,
 off64_t pos, int flags)

is used for p{readv,writev}{64}v2.  X32 is the only such target.  Update
x86-64 LO_HI_LONG to pass 0 as the high part of the offset argument for
p{readv,writev}{64}v2 and define a different LO_HI_LONG for x32 to only
pass one argument for offset.

Tested on x32 and x86-64.

	* sysdeps/unix/sysv/linux/x86_64/sysdep.h (LO_HI_LONG): Pass
	0 as the high part of offset.
	* sysdeps/unix/sysv/linux/x86_64/x32/sysdep.h (LO_HI_LONG): New.
2017-06-05 07:21:57 -07:00
Joseph Myers c4c96f92f7 Define SIG_HOLD for XPG4 (bug 21538).
Various bits/signum.h headers define SIG_HOLD if __USE_UNIX98.  That
should be __USE_XOPEN, as this macro is in XPG4.  This patch fixes the
conditionals accordingly.  Because of other header bugs, this does not
allow any XFAILs to be removed (however, the XPG4/signal.h/conform
XFAIL only depends on a few such straightforward header bugs, not on
the more complicated to fix ucontext_t issues, as ucontext_t isn't
included in signal.h in XPG4).

Tested for x86_64.

	[BZ #21538]
	* bits/signum.h (SIG_HOLD): Define if [__USE_XOPEN], not
	[__USE_UNIX98].
	* sysdeps/unix/bsd/bits/signum.h (SIG_HOLD): Likewise.
	* sysdeps/unix/sysv/linux/alpha/bits/signum.h (SIG_HOLD):
	Likewise.
	* sysdeps/unix/sysv/linux/bits/signum.h (SIG_HOLD): Likewise.
	* sysdeps/unix/sysv/linux/hppa/bits/signum.h (SIG_HOLD): Likewise.
	* sysdeps/unix/sysv/linux/mips/bits/signum.h (SIG_HOLD): Likewise.
	* sysdeps/unix/sysv/linux/sparc/bits/signum.h (SIG_HOLD):
	Likewise.
2017-06-05 10:19:03 +00:00
Joseph Myers 7553131847 Fix struct sigaltstack namespace (bug 21517).
glibc defines the stack_t type with the tag struct sigaltstack.  This
is not permitted by POSIX; sigaltstack is only reserved with file
scope in the namespace of ordinary identifiers, not the tag namespace,
and in the case where stack_t is obtained from ucontext.h rather than
signal.h, it's not reserved with file scope at all.

This patch removes the tag accordingly and updates uses in glibc of
struct sigaltstack.  This is similar to the removal of the "struct
siginfo" tag a few years ago: C++ name mangling changes are an
unavoidable consequence.  A NEWS item is added to note the changed
mangling.  There is inevitably some risk of breaking builds of
anything that relies on the struct sigaltstack name (though the first
few hits I looked at from codesearch.debian.net generally seemed to
involve code that could use the stack_t name conditionally, so
depending on how they determine the conditionals they may work with
glibc not defining the struct tag anyway).

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

	[BZ #21517]
	* bits/types/stack_t.h (stack_t): Remove struct tag.
	* sysdeps/unix/sysv/linux/bits/types/stack_t.h (stack_t):
	Likewise.
	* sysdeps/unix/sysv/linux/mips/bits/types/stack_t.h (stack_t):
	Likewise.
	* debug/segfault.c (install_handler): Use stack_t instead of
	struct sigaltstack.
	* hurd/hurd/signal.h (struct hurd_sigstate): Likewise.
	* hurd/trampoline.c (_hurd_setup_sighandler): Likewise.
	* include/signal.h (__sigaltstack): Likwise.
	* signal/sigaltstack.c (__sigaltstack): Likewise.
	* signal/signal.h (sigaltstack): Likewise.
	* sysdeps/mach/hurd/i386/signal-defines.sym
	(SIGALTSTACK__SS_SP__OFFSET): Likewise.
	(SIGALTSTACK__SS_SIZE__OFFSET): Likewise.
	(SIGALTSTACK__SS_FLAGS__OFFSET): Likewise.
	* sysdeps/mach/hurd/sigaltstack.c (__sigaltstack): Likewise.
	* sysdeps/mach/hurd/sigstack.c (sigstack): Likewise.
	* sysdeps/unix/sysv/linux/alpha/sys/procfs.h (struct
	elf_prstatus): Likewise.
	* sysdeps/unix/sysv/linux/hppa/____longjmp_chk.c (CHECK_SP):
	Likewise.
	* sysdeps/unix/sysv/linux/ia64/sys/procfs.h (struct elf_prstatus):
	Likewise.
	* sysdeps/unix/sysv/linux/m68k/____longjmp_chk.c (CHECK_SP):
	Likewise.
	* sysdeps/unix/sysv/linux/powerpc/sys/procfs.h (struct
	elf_prstatus): Likewise.
	* sysdeps/unix/sysv/linux/sh/sys/procfs.h (struct elf_prstatus):
	Likewise.
	* sysdeps/unix/sysv/linux/sys/procfs.h (struct elf_prstatus):
	Likewise.
2017-06-05 10:17:46 +00:00
Zack Weinberg 8951dd0b14 Regenerate sysdeps/gnu/errlist.c.
This file needs to be regenerated whenever errno.texi changes.
2017-06-04 15:27:14 -04:00
Florian Weimer 363911ce13 getaddrinfo: Eliminate another strdup call 2017-06-03 08:37:31 +02:00
H.J. Lu 808fd9e6fe x86: Update __x86_shared_non_temporal_threshold
__x86_shared_non_temporal_threshold was set to 6 times of per-core
shared cache size, based on the large memcpy micro benchmark in glibc
on a 8-core processor.  For a processor with more than 8 cores, the
threshold is too low.  Set __x86_shared_non_temporal_threshold to the
3/4 of the total shared cache size so that it is unchanged on 8-core
processors.  On processors with less than 8 cores, the threshold is
lower.

	* sysdeps/x86/cacheinfo.c (__x86_shared_non_temporal_threshold):
	Set to the 3/4 of the total shared cache size.
2017-06-02 17:32:37 -07:00
Florian Weimer 6257fcfd58 getaddrinfo: Fix localplt failure involving strdup 2017-06-02 16:35:13 +02:00
Florian Weimer 673cb072a4 getaddrinfo: Always allocate canonical name on the heap
A further simplification could eliminate the canon variable in
gaih_inet and replace it with canonbuf.  However, canonbuf is
used as a flag in the nscd code, which makes this somewhat
non-straightforward.
2017-06-02 14:54:56 +02:00
Zack Weinberg 72b81552a1 Add shim header for bits/syscall.h.
On Linux-based configurations, bits/syscall.h is a generated file.
To avoid build-ordering problems, the Linux sys/syscall.h only includes
bits/syscall.h if _LIBC is not defined.  After the _ISOMAC-testsuite
changes, this means any test case that includes sys/syscall.h tries to
pull in bits/syscall.h.  This would be fine, because it'll definitely
have been generated by the time we start compiling tests, except that
the generated <builddir>/misc/bits/syscall.h is not visible in the
include path, because nothing needed it till now.  So we either get
the bits/syscall.h from the host system, or the build fails.

The fix is simple: add a shim header for bits/syscall.h.  I put it in
sysdeps/unix/sysv/linux/include instead of the top-level include/
because bits/syscall.h doesn't exist at all on other configurations as
far as I can tell.

This is known to affect nptl/tst-cond2[45].  Thanks to John David
Anglin for noticing the problem.

	[BZ #21514]
	* sysdeps/unix/sysv/linux/include/bits/syscall.h: New shim header
	pointing to the generated file in <builddir>/misc/bits/syscall.h.
2017-06-01 10:56:10 -04:00
Joseph Myers 139904b7e4 Fix more namespace issues in sys/ucontext.h (bug 21457).
Continuing the fixes for namespace issues in sys/ucontext.h, this
patch moves various symbols into the implementation namespace in the
absence of __USE_MISC.  As with previous changes, it is nonexhaustive,
just covering more straightforward cases.

Structure fields are generally changed to have a prefix __ in the
absence of __USE_MISC, via a macro __ctx (used without a space before
the open parenthesis, since the result is a single identifier).
Various macros such as NGREG also have leading __ added.  No changes
are made to structure tags (and thus to C++ name mangling), except
that in the (unused) file sysdeps/i386/sys/ucontext.h, structures
defined inside other structures as the type for a field have their
tags removed in the non-__USE_MISC case (those structure tags would
not in any case have been visible in C++, because in C++ the scope of
such a tag is limited to the containing structure).  No changes are
made to the contents of bits/sigcontext.h, or to whether it is
included.  Because of remaining namespace issues, this patch does not
yet fix the bug or allow any XFAILs to be removed.

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

	[BZ #21457]
	* sysdeps/arm/sys/ucontext.h (NGREG): Rename to __NGREG and define
	NGREG to __NGREG if [__USE_MISC].
	(gregset_t): Define using __NGREG.
	(__ctx): New macro.
	(mcontext_t): Use __ctx in defining fields.
	* sysdeps/i386/sys/ucontext.h (NGREG): Rename to __NGREG and
	define NGREG to __NGREG if [__USE_MISC].
	(gregset_t): Define using __NGREG.
	(__ctx): New macro.
	(__ctxt): Likewise.
	(fpregset_t): Use __ctx and __ctxt in defining fields.
	(mcontext_t): Likewise.
	* sysdeps/m68k/sys/ucontext.h (NGREG): Rename to __NGREG and
	define NGREG to __NGREG if [__USE_MISC].
	(gregset_t): Define using __NGREG.
	(__ctx): New macro.
	(mcontext_t): Use __ctx in defining fields.
	* sysdeps/mips/sys/ucontext.h (NGREG): Rename to __NGREG and
	define NGREG to __NGREG if [__USE_MISC].
	(gregset_t): Define using __NGREG.
	(__ctx): New macro.
	(fpregset_t): Use __ctx in defining fields.
	(mcontext_t): Likewise.
	* sysdeps/unix/sysv/linux/alpha/sys/ucontext.h (NGREG): Rename to
	__NGREG and define NGREG to __NGREG if [__USE_MISC].
	(gregset_t): Define using __NGREG.
	(NFPREG): Rename to __NFPREG and define NFPREG to __NFPREG if
	[__USE_MISC].
	(fpregset_t): Define using __NFPREG.
	* sysdeps/unix/sysv/linux/m68k/sys/ucontext.h (NGREG): Rename to
	__NGREG and define NGREG to __NGREG if [__USE_MISC].
	(gregset_t): Define using __NGREG.
	(__ctx): New macro.
	(fpregset_t): Use __ctx in defining fields.
	(mcontext_t): Likewise.
	* sysdeps/unix/sysv/linux/mips/sys/ucontext.h (NGREG): Rename to
	__NGREG and define NGREG to __NGREG if [__USE_MISC].
	(NFPREG): Rename to __NFPREG and define NFPREG to __NFPREG if
	[__USE_MISC].
	(gregset_t): Define using __NGREG.
	(__ctx): New macro.
	(fpregset_t): Use __ctx in defining fields.
	(mcontext_t): Likewise.
	* sysdeps/unix/sysv/linux/nios2/sys/ucontext.h (__ctx): New macro.
	(mcontext_t): Use __ctx in defining fields.
	* sysdeps/unix/sysv/linux/powerpc/sys/ucontext.h (__ctx): New
	macro.
	[__WORDSIZE == 32] (NGREG): Rename to __NGREG and define NGREG to
	__NGREG if [__USE_MISC].
	[__WORDSIZE == 32] (gregset_t): Define using __NGREG.
	[__WORDSIZE == 32] (fpregset_t): Use __ctx in defining fields.
	(mcontext_t): Likewise.
	[__WORDSIZE != 32] (NGREG): Rename to __NGREG and define NGREG to
	__NGREG if [__USE_MISC].
	[__WORDSIZE != 32] (NFPREG): Rename to __NFPREG and define NFPREG
	to __NFPREG if [__USE_MISC].
	[__WORDSIZE != 32] (NVRREG): Rename to __NVRREG and define NVRREG
	to __NVRREG if [__USE_MISC].
	[__WORDSIZE != 32] (gregset_t): Define using __NGREG.
	[__WORDSIZE != 32] (fpregset_t): Define using __NFPREG.
	[__WORDSIZE != 32] (vscr_t): Use __ctx in defining fields.
	[__WORDSIZE != 32] (vrregset_t): Likewise.
	[__WORDSIZE != 32] (mcontext_t): Likewise.
	* sysdeps/unix/sysv/linux/s390/sys/ucontext.h (__ctx): New macro.
	(__psw_t): Use __ctx in defining fields.
	(NGREG): Rename to __NGREG and define NGREG to __NGREG if
	[__USE_MISC].
	(gregset_t): Define using __NGREG.
	(fpreg_t): Use __ctx in defining fields.
	(fpregset_t): Likewise.
	(mcontext_t): Likewise.
	* sysdeps/unix/sysv/linux/sh/sys/ucontext.h (NGREG): Rename to
	__NGREG and define NGREG to __NGREG if [__USE_MISC].
	(gregset_t): Define using __NGREG.
	(NFPREG): Rename to __NFPREG and define NFPREG to __NFPREG if
	[__USE_MISC].
	(fpregset_t): Define using __NFPREG.
	(__ctx): New macro.
	(mcontext_t): Use __ctx in defining fields.
	* sysdeps/unix/sysv/linux/x86/sys/ucontext.h (__ctx): New macro.
	[__x86_64__] (NGREG): Rename to __NGREG and define NGREG to
	__NGREG if [__USE_MISC].
	[__x86_64__] (gregset_t): Define using __NGREG.
	[__x86_64__] (struct _libc_fpxreg): Use __ctx in defining fields.
	[__x86_64__] (struct _libc_fpstate): Likewise.
	[__x86_64__] (mcontext_t): Likewise.
	[!__x86_64__] (NGREG): Rename to __NGREG and define NGREG to
	__NGREG if [__USE_MISC].
	[!__x86_64__] (gregset_t): Define using __NGREG.
	[!__x86_64__] (struct _libc_fpreg): Use __ctx in defining fields.
	[!__x86_64__] (struct _libc_fpstate): Likewise.
	[!__x86_64__] (mcontext_t): Likewise.
2017-06-01 14:07:40 +00:00
Zack Weinberg 491bb0858e Avoid tickling a linker bug from microblaze pt-vfork.S.
libpthread used to have its own vfork implementation that differed
from libc's only in having a pointless micro-optimization.  There is
no longer any use to having a separate copy in libpthread, but the
historical ABI requires a compatibility shim.  microblaze was trying
to be slightly too clever about how it did this, and tickled a linker
bug.  The linker bug should get fixed eventually, but there's no
reason for us to keep tickling it in the meantime.

This doesn't reuse the generic pt-vfork.c because microblaze doesn't
have IFUNC support yet, and it doesn't reuse aarch64/pt-vfork.c
because that fails to generate a tailcall (with GCC 7.1.1).

	* sysdeps/unix/sysv/linux/microblaze/pt-vfork.S: Don't include
	alpha/pt-vfork.S.  Provide own compat shim for vfork and __vfork.
	* sysdeps/unix/sysv/linux/microblaze/vfork.S: Add __libc_vfork alias.
	* sysdeps/unix/sysv/linux/microblaze/localplt.data:
	libpthread.so no longer references __errno_location.
2017-06-01 08:53:56 -04:00
Adhemerval Zanella 52bd938169 posix: Implement preadv2 and pwritev2
This patch adds support of preadv2 and pwritev2 which are similar to
preadv/pwritev but with an extra flag argument.  As for preadv/pwritev
both interfaces are added a non-standard GNU API.

For default 'posix' implementation trying to emulate the Linux supported
flags is troublesome:

   * We can not temporary change the file state of the O_DSYNC and O_SYNC
     flags to emulate RWF_{D}SYNC (attempts to change the state of using
     fcntl are silently ignored).

   * IOCB_HIPRI requires the file opened in O_DIRECT and uses an internal
     semantic not provided by any other flag (O_NONBLOCK for instance).

So default sysdeps/posix implementations fails with EOPNOTSUPP for any non
supported flag (which are none currently) calls generic preadv/pwritev.
Basically this implementation supports only preadv2 called as preadv (with
flags sets to 0).

The Linux one uses the preadv2/pwritev2 syscall if defined, otherwise it
call preadv/writev.  Instead of using the previous __ASSUME_* to
unconditionally issue the syscall (and avoid building the fallback routine),
it call pread/write if the preadv2/pwritev2 syscalls fails.  The idea
is just avoid adding another __ASSUME_* and checking each architecture
on every kernel bump and simplify code conditionals.

Checked on x86_64-linux-gnu and on i686-linux-gnu and a check with
run-built-tests=no on aarch64-linux-gnu, alpha-linux-gnu, arm-linux-gnueabihf,
ia64-linux-gnu, m68k-linux-gnu, microblaze-linux-gnu, mips{64,64n32}-linux-gnu,
nios2-linux-gnu, powerpc{64,64le}-linux-gnu, s390{x}-linux-gnu,
sparc{64,v9}-linux-gnu, tile{gx,pro}-linux-gnu, and sh4-linux-gnu (all using
gcc 6.3).

	* NEWS: Add note about pwritev2 and preadv2 inclusion.
	* misc/Makefile (routines): Add preadv2, preadv64v2, pwritev2, and
	pwritev64v2.
	(tests): Add tst-preadvwritev2 and tst-preadvwritev64v2.
	* misc/Versions (GLIBC_2.26): Add preadv2, preadv64v2, pwritev2, and
	pwritev64v2.
	* misc/preadv2.c: New file.
	* misc/preadv64v2.c: Likewise.
	* misc/pwritev2.c: Likewise.
	* misc/pwritev64v2.c: Likewise.
	* misc/tst-preadvwritev2.c: Likewise.
	* misc/tst-preadvwritev64v2.c: Likewise.
	* manual/llio.texi: Add preadv2 and pwritev2 documentation.
	* misc/sys/uio.h [__USE_GNU && !__USE_FILE_OFFSET64] (preadv2): New
	prototype.
	[__USE_GNU && !__USE_FILE_OFFSET64] (pwritev2):	Likewise.
	[__USE_GNU && __USE_FILE_OFFSET64] (preadv64v2): Likewise.
	[__USE_GNU && __USE_FILE_OFFSET64] (pwritev64v2): Likewise.
	* misc/tst-preadvwritev-common.c (PREADV): Define if not defined.
	(PWRITEV): Likewise.
	(do_test_with_offset): Use PREADV and PWRITEV macros and check for
	ENOSYS.
	* nptl/tst-cancel4.c (tf_pwritev2): New test.
	(tf_preadv2): Likewise.
	(tf_fsync): Add tf_pwritev2 and tf_preadv2.
	* sysdeps/posix/preadv2.c: Likewise.
	* sysdeps/posix/preadv64v2.c: Likewise.
	* sysdeps/posix/pwritev2.c: Likewise.
	* sysdeps/posix/pwritev64v2.c: Likewise.
	* sysdeps/unix/sysv/linux/kernel-features.h: Add comment for syscall
	support in kernel.
	* sysdeps/unix/sysv/linux/preadv2.c: Likewise.
	* sysdeps/unix/sysv/linux/preadv64v2.c: Likewise.
	* sysdeps/unix/sysv/linux/pwritev2.c: Likewise.
	* sysdeps/unix/sysv/linux/pwritev64v2.c: Likewise.
	* sysdeps/unix/sysv/linux/preadv.c (preadv): Add libc_hidden_def.
	* sysdeps/unix/sysv/linux/preadv64.c (preadv64): Likewise.
	* sysdeps/unix/sysv/linux/pwritev.c (pwritev): Likewise.
	* sysdeps/unix/sysv/linux/pwritev64.c (pwritev64): Likewise.
	* sysdeps/unix/sysv/linux/bits/uio.h: Add supported preadv2/pwritev2
	support flags on Linux.
	* sysdeps/unix/sysv/linux/aarch64/libc.abilist (GLIBC_2.26): Add
	preadv2, preadv64v2, pwritev2, pwritev64v2.
	* sysdeps/unix/sysv/linux/alpha/libc.abilist (GLIBC_2.26): Likewise.
	* sysdeps/unix/sysv/linux/arm/libc.abilist (GLIBC_2.26): Likewise.
	* sysdeps/unix/sysv/linux/hppa/libc.abilist (GLIBC_2.26): Likewise.
	* sysdeps/unix/sysv/linux/i386/libc.abilist (GLIBC_2.26): Likewise.
	* sysdeps/unix/sysv/linux/ia64/libc.abilist (GLIBC_2.26): Likewise.
	* sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist (GLIBC_2.26):
	Likewise.
	* sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist (GLIBC_2.26):
	Likewise.
	* sysdeps/unix/sysv/linux/microblaze/libc.abilist (GLIBC_2.26):
	Likewise.
	* sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist (GLIBC_2.26):
	Likewise.
	* sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist (GLIBC_2.26):
	Likewise.
	* sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist (GLIBC_2.26):
	Likewise.
	* sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist (GLIBC_2.26):
	Likewise.
	* sysdeps/unix/sysv/linux/nios2/libc.abilist (GLIBC_2.26): Likewise.
	* sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist
	(GLIBC_2.26): Likewise.
	* sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist
	(GLIBC_2.26): Likewise.
	* sysdeps/unix/sysv/linux/powerpc/powerpc64/libc.abilist (GLIBC_2.26):
	Likewise.
	* sysdeps/unix/sysv/linux/powerpc/powerpc64/libc-le.abilist
	(GLIBC_2.26): Likewise.
	* sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist (GLIBC_2.26):
	Likewise.
	* sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist (GLIBC_2.26):
	Likewise.
	* sysdeps/unix/sysv/linux/sh/libc.abilist (GLIBC_2.26): Likewise.
	* sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist (GLIBC_2.26):
	Likewise.
	* sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist (GLIBC_2.26):
	Likewise.
	* sysdeps/sysv/linux/tile/tilegx/tilegx32/libc.abilist (GLIBC_2.26):
	Likewise.
	* sysdeps/sysv/linux/tile/tilegx/tilegx64/libc.abilist (GLIBC_2.26):
	Likewise.
	* sysdeps/unix/sysv/linux/tile/tilepro/libc.abilist (GLIBC_2.26):
	Likewise.
	* sysdeps/unix/sysv/linux/x86_64/64/libc.abilist (GLIBC_2.26):
	Likewise.
	* sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist (GLIBC_2.26):
	Likewise.
2017-05-31 17:35:46 -03:00
Siddhesh Poyarekar 4158ba082c Delay initialization of CPU features struct in static binaries
Allow the CPU features structure set up to be overridden by tunables
by delaying it to until after tunables are initialized.  The
initialization is already delayed in dynamically linked glibc, it is
only in static binaries that the initialization is set early to allow
it to influence IFUNC relocations that happen in libc-start.  It is a
bit too early however and there is a good place between tunables
initialization and IFUNC relocations where this can be done.

Verified that this does not regress the testsuite.

	* csu/libc-start.c [!ARCH_INIT_CPU_FEATURES]: Define
	ARCH_INIT_CPU_FEATURES.
	(LIBC_START_MAIN): Call it.
	* sysdeps/unix/sysv/linux/aarch64/libc-start.c
	(__libc_start_main): Remove.
	(ARCH_INIT_CPU_FEATURES): New macro.
	* sysdeps/x86/libc-start.c (__libc_start_main): Remove.
	(ARCH_INIT_CPU_FEATURES): New macro.
2017-05-31 06:38:33 +05:30
Dennis Wölfing 2e0bbbfbf9 Add reallocarray function
The reallocarray function is an extension from OpenBSD.  It is an
integer-overflow-safe replacement for realloc(p, X*Y) and
malloc(X*Y) (realloc(NULL, X*Y)).  It can therefore help in preventing
certain security issues in code.

This is an updated version of a patch originally submitted by Rüdiger
Sonderfeld in May 2014 [1].

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

[1] <https://sourceware.org/ml/libc-alpha/2014-05/msg00481.html>.

2017-05-30  Dennis Wölfing  <denniswoelfing@gmx.de>
            Rüdiger Sonderfeld  <ruediger@c-plusplus.de>

	* include/stdlib.h (__libc_reallocarray): New declaration.
	* malloc/Makefile (routines): Add reallocarray.
	(tests): Add tst-reallocarray.c.
	* malloc/Versions: Add reallocarray and __libc_reallocarray.
	* malloc/malloc-internal.h (check_mul_overflow_size_t): New inline
	function.
	* malloc/malloc.h (reallocarray): New declaration.
	* stdlib/stdlib.h (reallocarray): Likewise.
	* malloc/reallocarray.c: New file.
	* malloc/tst-reallocarray.c: New test file.
	* manual/memory.texi: Document reallocarray.
	* sysdeps/unix/sysv/linux/aarch64/libc.abilist: Add reallocarray.
	* sysdeps/unix/sysv/linux/alpha/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/arm/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/hppa/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/i386/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/ia64/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/microblaze/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/nios2/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist:
	Likewise.
	* sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist:
	Likewise.
	* sysdeps/unix/sysv/linux/powerpc/powerpc64/libc-le.abilist: Likewise.
	* sysdeps/unix/sysv/linux/powerpc/powerpc64/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/sh/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/tile/tilegx/tilegx32/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/tile/tilegx/tilegx64/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/tilepro/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/x86_64/64/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist: Likewise.
2017-05-30 18:27:57 -03:00
H.J. Lu 4f26ef1b67 x86_64: Remove redundant REX bytes from memchr.S
By x86-64 specification, 32-bit destination registers are zero-extended
to 64 bits.  There is no need to use 64-bit registers when only the lower
32 bits are non-zero.

	* sysdeps/x86_64/memchr.S (MEMCHR): Use 32-bit registers for
	the lower 32 bits.
2017-05-30 12:39:14 -07:00
Andreas Schwab 542a34783c m68k: handle default PIE 2017-05-29 08:41:50 +02:00
Paul E. Murphy 302bb1a3c3 float128: Add wrappers to override ldbl-128 as float128.
This change defines float128_private.h which contains
macros used to override long double naming conventions
when building a ldbl file.

	* math/math.h [__HAVE_FLOAT128 && __GLIBC_USE (IEC_60559_TYPES_EXT)]
	(SNANF128): New macro.
	* math/e_sqrtf128.c: New file.
	* math/s_fmaxmag_template.c: Include math_private.h in order to
	make inline expansion of fabs128().
	* math/s_fminmag_template.c: Likewise.

	* sysdeps/ieee754/float128/e_acosf128.c: New file.
	* sysdeps/ieee754/float128/e_acoshf128.c: New file.
	* sysdeps/ieee754/float128/e_asinf128.c: New file.
	* sysdeps/ieee754/float128/e_atan2f128.c: New file.
	* sysdeps/ieee754/float128/e_atanhf128.c: New file.
	* sysdeps/ieee754/float128/e_coshf128.c: New file.
	* sysdeps/ieee754/float128/e_exp10f128.c: New file.
	* sysdeps/ieee754/float128/e_expf128.c: New file.
	* sysdeps/ieee754/float128/e_fmodf128.c: New file.
	* sysdeps/ieee754/float128/e_gammaf128_r.c: New file.
	* sysdeps/ieee754/float128/e_hypotf128.c: New file.
	* sysdeps/ieee754/float128/e_ilogbf128.c: New file.
	* sysdeps/ieee754/float128/e_j0f128.c: New file.
	* sysdeps/ieee754/float128/e_j1f128.c: New file.
	* sysdeps/ieee754/float128/e_jnf128.c: New file.
	* sysdeps/ieee754/float128/e_lgammaf128_r.c: New file.
	* sysdeps/ieee754/float128/e_log10f128.c: New file.
	* sysdeps/ieee754/float128/e_log2f128.c: New file.
	* sysdeps/ieee754/float128/e_logf128.c: New file.
	* sysdeps/ieee754/float128/e_powf128.c: New file.
	* sysdeps/ieee754/float128/e_rem_pio2f128.c: New file.
	* sysdeps/ieee754/float128/e_remainderf128.c: New file.
	* sysdeps/ieee754/float128/e_scalbf128.c: New file.
	* sysdeps/ieee754/float128/e_sinhf128.c: New file.
	* sysdeps/ieee754/float128/float128_private.h: New file.
	* sysdeps/ieee754/float128/gamma_productf128.c: New file.
	* sysdeps/ieee754/float128/ieee754_float128.h: New file.
	* sysdeps/ieee754/float128/k_cosf128.c: New file.
	* sysdeps/ieee754/float128/k_sincosf128.c: New file.
	* sysdeps/ieee754/float128/k_sinf128.c: New file.
	* sysdeps/ieee754/float128/k_tanf128.c: New file.
	* sysdeps/ieee754/float128/lgamma_negf128.c: New file.
	* sysdeps/ieee754/float128/lgamma_productf128.c: New file.
	* sysdeps/ieee754/float128/s_asinhf128.c: New file.
	* sysdeps/ieee754/float128/s_atanf128.c: New file.
	* sysdeps/ieee754/float128/s_cbrtf128.c: New file.
	* sysdeps/ieee754/float128/s_ceilf128.c: New file.
	* sysdeps/ieee754/float128/s_copysignf128.c: New file.
	* sysdeps/ieee754/float128/s_cosf128.c: New file.
	* sysdeps/ieee754/float128/s_erff128.c: New file.
	* sysdeps/ieee754/float128/s_expm1f128.c: New file.
	* sysdeps/ieee754/float128/s_fabsf128.c: New file.
	* sysdeps/ieee754/float128/s_finitef128.c: New file.
	* sysdeps/ieee754/float128/s_floorf128.c: New file.
	* sysdeps/ieee754/float128/s_fmaf128.c: New file.
	* sysdeps/ieee754/float128/s_fpclassifyf128.c: New file.
	* sysdeps/ieee754/float128/s_frexpf128.c: New file.
	* sysdeps/ieee754/float128/s_fromfpf128.c: New file.
	* sysdeps/ieee754/float128/s_fromfpxf128.c: New file.
	* sysdeps/ieee754/float128/s_getpayloadf128.c: New file.
	* sysdeps/ieee754/float128/s_isinff128.c: New file.
	* sysdeps/ieee754/float128/s_isnanf128.c: New file.
	* sysdeps/ieee754/float128/s_issignalingf128.c: New file.
	* sysdeps/ieee754/float128/s_llrintf128.c: New file.
	* sysdeps/ieee754/float128/s_llroundf128.c: New file.
	* sysdeps/ieee754/float128/s_log1pf128.c: New file.
	* sysdeps/ieee754/float128/s_logbf128.c: New file.
	* sysdeps/ieee754/float128/s_lrintf128.c: New file.
	* sysdeps/ieee754/float128/s_lroundf128.c: New file.
	* sysdeps/ieee754/float128/s_modff128.c: New file.
	* sysdeps/ieee754/float128/s_nearbyintf128.c: New file.
	* sysdeps/ieee754/float128/s_nextafterf128.c: New file.
	* sysdeps/ieee754/float128/s_nexttowardf128.c: New file.
	* sysdeps/ieee754/float128/s_nextupf128.c: New file.
	* sysdeps/ieee754/float128/s_remquof128.c: New file.
	* sysdeps/ieee754/float128/s_rintf128.c: New file.
	* sysdeps/ieee754/float128/s_roundevenf128.c: New file.
	* sysdeps/ieee754/float128/s_roundf128.c: New file.
	* sysdeps/ieee754/float128/s_scalblnf128.c: New file.
	* sysdeps/ieee754/float128/s_scalbnf128.c: New file.
	* sysdeps/ieee754/float128/s_setpayloadf128.c: New file.
	* sysdeps/ieee754/float128/s_setpayloadsigf128.c: New file.
	* sysdeps/ieee754/float128/s_signbitf128.c: New file.
	* sysdeps/ieee754/float128/s_significandf128.c: New file.
	* sysdeps/ieee754/float128/s_sincosf128.c: New file.
	* sysdeps/ieee754/float128/s_sinf128.c: New file.
	* sysdeps/ieee754/float128/s_tanf128.c: New file.
	* sysdeps/ieee754/float128/s_tanhf128.c: New file.
	* sysdeps/ieee754/float128/s_totalorderf128.c: New file.
	* sysdeps/ieee754/float128/s_totalordermagf128.c: New file.
	* sysdeps/ieee754/float128/s_truncf128.c: New file.
	* sysdeps/ieee754/float128/s_ufromfpf128.c: New file.
	* sysdeps/ieee754/float128/s_ufromfpxf128.c: New file.
	* sysdeps/ieee754/float128/t_sincosf128.c: New file.
	* sysdeps/ieee754/float128/x2y2m1f128.c: New file.

	* sysdeps/ieee754/ldbl-128ibm/bits/iscanonical.h:
	(__iscanonicalf128): Define as a macro.
2017-05-25 09:01:37 -03:00
Steve Ellcey 6a2c695266 aarch64: Thunderx specific memcpy and memmove
* sysdeps/aarch64/memcpy.S (MEMMOVE, MEMCPY): New macros.
	(memmove): Use MEMMOVE for name.
	(memcpy): Use MEMCPY for name.  Change internal labels
	to external labels.
	* sysdeps/aarch64/multiarch/Makefile: New file.
	* sysdeps/aarch64/multiarch/ifunc-impl-list.c: Likewise.
	* sysdeps/aarch64/multiarch/init-arch.h: Likewise.
	* sysdeps/aarch64/multiarch/memcpy.c: Likewise.
	* sysdeps/aarch64/multiarch/memcpy_generic.S: Likewise.
	* sysdeps/aarch64/multiarch/memcpy_thunderx.S: Likewise.
	* sysdeps/aarch64/multiarch/memmove.c: Likewise.
2017-05-24 16:46:48 -07:00
Siddhesh Poyarekar 6edbe546d6 arm: Fix typo in array count
I just noticed that the array count for the hwcap flags list in ARM is
off by 10, i.e. 37 instead of 27.  Following patch fixes this.

	* sysdeps/unix/sysv/linux/arm/dl-procinfo.c
	(_dl_arm_cap_flags): Fix array subscript.
	* sysdeps/unix/sysv/linux/arm/dl-procinfo.h (_DL_HWCAP_COUNT):
	Fix count.
2017-05-24 22:26:37 +05:30
H.J. Lu 9c450f6f6f x86: Don't include cacheinfo.c in ld.so
Since cacheinfo.c isn't used by ld.so, there is no need to include it
in ld.so.

	* sysdeps/x86/cacheinfo.c: Skip if not in libc.
2017-05-24 06:33:43 -07:00
H.J. Lu 7c1d722554 x86: Use __get_cpu_features to get cpu_features
Remove is_intel, is_amd and max_cpuid macros.  Use __get_cpu_features
to get cpu_features instead.

	* sysdeps/x86/cacheinfo.c (is_intel): Removed.
	(is_amd): Likewise.
	(max_cpuid): Likewise.
	(__cache_sysconf): Use __get_cpu_features to get cpu_features.
	(init_cacheinfo): Likewise.
2017-05-24 06:28:52 -07:00
Joseph Myers cfed8ece79 Fix sys/ucontext.h namespace from signal.h etc. inclusion (bug 21457).
The various sys/ucontext.h headers include <signal.h> and all the
headers split out of <bits/sigstack.h>.  (Except that the powerpc
version does not include <signal.h>.)

None of the standard versions defining ucontext.h require or permit
such inclusions; rather, they all say that the stack_t and sigset_t
types from signal.h are defined.  This patch fixes the headers to
include just the bits/ headers for those types (and the existing
includes of bits/sigcontext.h).  Since bits/types/sigset_t.h is now
being included instead of bits/types/__sigset_t.h, __sigset_t uses in
the headers are replaced by direct use of the public sigset_t type.
sysdeps/unix/sysv/linux/x86/bits/sigcontext.h was relying on the prior
inclusion of <signal.h> to define types such as __uint32_t, so gets a
bits/types.h include added to provide those types.

Although one could keep some or all of the includes under a __USE_MISC
conditional, that seems unnecessary to me, especially given the lack
of a <signal.h> include in the powerpc version meaning that portable
programs already cannot rely on such an include.

Tested for x86_64 and x86, and with build-many-glibcs.py.  As with
other such fixes, more namespace issues remain so this does not permit
any XFAILs to be removed or bugs to be closed.

	[BZ #21457]
	* sysdeps/arm/sys/ucontext.h: Do not include <signal.h>,
	<bits/sigstack.h>, <bits/types/struct_sigstack.h> or
	<bits/ss_flags.h>.  Include <bits/types/sigset_t.h> instead of
	<bits/types/__sigset_t.h>.
	(ucontext_t): Use sigset_t instead of __sigset_t.
	* sysdeps/generic/sys/ucontext.h: Do not include <signal.h>,
	<bits/sigstack.h>, <bits/types/struct_sigstack.h> or
	<bits/ss_flags.h>.  Include <bits/types/sigset_t.h> instead of
	<bits/types/__sigset_t.h>.
	(ucontext_t): Use sigset_t instead of __sigset_t.
	* sysdeps/i386/sys/ucontext.h: Do not include <signal.h>,
	<bits/sigstack.h>, <bits/types/struct_sigstack.h> or
	<bits/ss_flags.h>.  Include <bits/types/sigset_t.h> instead of
	<bits/types/__sigset_t.h>.
	(ucontext_t): Use sigset_t instead of __sigset_t.
	* sysdeps/m68k/sys/ucontext.h: Do not include <signal.h>,
	<bits/sigstack.h>, <bits/types/struct_sigstack.h> or
	<bits/ss_flags.h>.  Include <bits/types/sigset_t.h> instead of
	<bits/types/__sigset_t.h>.
	(ucontext_t): Use sigset_t instead of __sigset_t.
	* sysdeps/mips/sys/ucontext.h: Do not include <signal.h>,
	<bits/sigstack.h>, <bits/types/struct_sigstack.h> or
	<bits/ss_flags.h>.  Include <bits/types/sigset_t.h> instead of
	<bits/types/__sigset_t.h>.
	(ucontext_t): Use sigset_t instead of __sigset_t.
	* sysdeps/unix/sysv/linux/aarch64/sys/ucontext.h: Do not include
	<signal.h>, <bits/sigstack.h>, <bits/types/struct_sigstack.h> or
	<bits/ss_flags.h>.  Include <bits/types/sigset_t.h> instead of
	<bits/types/__sigset_t.h>.
	(ucontext_t): Use sigset_t instead of __sigset_t.
	* sysdeps/unix/sysv/linux/alpha/sys/ucontext.h: Do not include
	<signal.h>, <bits/sigstack.h>, <bits/types/struct_sigstack.h> or
	<bits/ss_flags.h>.  Include <bits/types/sigset_t.h> instead of
	<bits/types/__sigset_t.h>.
	(ucontext_t): Use sigset_t instead of __sigset_t.
	* sysdeps/unix/sysv/linux/arm/sys/ucontext.h: Do not include
	<signal.h>, <bits/sigstack.h>, <bits/types/struct_sigstack.h> or
	<bits/ss_flags.h>.  Include <bits/types/sigset_t.h> instead of
	<bits/types/__sigset_t.h>.
	(ucontext_t): Use sigset_t instead of __sigset_t.
	* sysdeps/unix/sysv/linux/hppa/sys/ucontext.h: Do not include
	<signal.h>, <bits/sigstack.h>, <bits/types/struct_sigstack.h> or
	<bits/ss_flags.h>.  Include <bits/types/sigset_t.h> instead of
	<bits/types/__sigset_t.h>.
	(ucontext_t): Use sigset_t instead of __sigset_t.
	* sysdeps/unix/sysv/linux/ia64/sys/ucontext.h: Do not include
	<signal.h>, <bits/sigstack.h>, <bits/types/struct_sigstack.h> or
	<bits/ss_flags.h>.  Include <bits/types/sigset_t.h>.
	* sysdeps/unix/sysv/linux/m68k/sys/ucontext.h: Do not include
	<signal.h>, <bits/sigstack.h>, <bits/types/struct_sigstack.h> or
	<bits/ss_flags.h>.  Include <bits/types/sigset_t.h> instead of
	<bits/types/__sigset_t.h>.
	(ucontext_t): Use sigset_t instead of __sigset_t.
	* sysdeps/unix/sysv/linux/mips/sys/ucontext.h: Do not include
	<signal.h>, <bits/sigstack.h>, <bits/types/struct_sigstack.h> or
	<bits/ss_flags.h>.  Include <bits/types/sigset_t.h> instead of
	<bits/types/__sigset_t.h>.
	(ucontext_t): Use sigset_t instead of __sigset_t.
	* sysdeps/unix/sysv/linux/nios2/sys/ucontext.h: Do not include
	<signal.h>, <bits/sigstack.h>, <bits/types/struct_sigstack.h> or
	<bits/ss_flags.h>.  Include <bits/types/sigset_t.h> instead of
	<bits/types/__sigset_t.h>.
	(ucontext_t): Use sigset_t instead of __sigset_t.
	* sysdeps/unix/sysv/linux/powerpc/sys/ucontext.h: Do not include
	<bits/sigstack.h>, <bits/types/struct_sigstack.h> or
	<bits/ss_flags.h>.
	* sysdeps/unix/sysv/linux/s390/sys/ucontext.h: Do not include
	<signal.h>, <bits/sigstack.h>, <bits/types/struct_sigstack.h> or
	<bits/ss_flags.h>.  Include <bits/types/sigset_t.h> instead of
	<bits/types/__sigset_t.h>.
	(ucontext_t): Use sigset_t instead of __sigset_t.
	* sysdeps/unix/sysv/linux/sh/sys/ucontext.h: Do not include
	<signal.h>, <bits/sigstack.h>, <bits/types/struct_sigstack.h> or
	<bits/ss_flags.h>.  Include <bits/types/sigset_t.h> instead of
	<bits/types/__sigset_t.h>.
	(ucontext_t): Use sigset_t instead of __sigset_t.
	* sysdeps/unix/sysv/linux/sparc/sys/ucontext.h: Do not include
	<signal.h>, <bits/sigstack.h>, <bits/types/struct_sigstack.h> or
	<bits/ss_flags.h>.  Include <bits/types/sigset_t.h> instead of
	<bits/types/__sigset_t.h>.
	(ucontext_t): Use sigset_t instead of __sigset_t.
	* sysdeps/unix/sysv/linux/tile/sys/ucontext.h: Do not include
	<signal.h>, <bits/sigstack.h>, <bits/types/struct_sigstack.h> or
	<bits/ss_flags.h>.  Include <bits/types/sigset_t.h> instead of
	<bits/types/__sigset_t.h>.
	(ucontext_t): Use sigset_t instead of __sigset_t.
	* sysdeps/unix/sysv/linux/x86/bits/sigcontext.h: Include
	<bits/types.h>.
	* sysdeps/unix/sysv/linux/x86/sys/ucontext.h: Do not include
	<signal.h>, <bits/sigstack.h>, <bits/types/struct_sigstack.h> or
	<bits/ss_flags.h>.  Include <bits/types/sigset_t.h> instead of
	<bits/types/__sigset_t.h>.
	(ucontext_t): Use sigset_t instead of __sigset_t.
2017-05-23 11:49:48 +00:00
Zack Weinberg 231a59ce2c Fix a bug in 'Remove __need macros from signal.h' (a992f506)
siginfo-arch.h is included in two different places, so the default
definitions of the macros that it might or might not define need to
be done conditionally afterward, not unconditionally beforehand.

	* sysdeps/unix/sysv/linux/bits/siginfo-consts.h
	(__SI_ASYNCIO_AFTER_SIGIO): Define default after including
	bits/siginfo-arch.h, only if not already defined.
	* sysdeps/unix/sysv/linux/bits/types/siginfo_t.h
	(__SI_ALIGNMENT, __SI_BAND_TYPE, __SI_CLOCK_T)
	(__SI_ERRNO_THEN_CODE, __SI_HAVE_SIGSYS, __SI_SEGFAULT_ADDL):
	Likewise.

	* sysdeps/unix/sysv/linux/ia64/bits/siginfo-arch.h
	* sysdeps/unix/sysv/linux/mips/bits/siginfo-arch.h
	* sysdeps/unix/sysv/linux/sparc/bits/siginfo-arch.h
	* sysdeps/unix/sysv/linux/tile/bits/siginfo-arch.h
	* sysdeps/unix/sysv/linux/x86/bits/siginfo-arch.h:
	Unconditionally define __SI_* macros.
2017-05-22 22:32:09 -04:00
Siddhesh Poyarekar d26db8fbb4 Remove useless comment from sysdeps/sparc/sparc32/dl-machine.h
David Miller has not been shot yet AFAIK (yes, I googled for any news
that may seem relevant and I poked him on twitter some days ago) so
either nobody uses SPARC or the code is correct or nobody read the
instructions in the comment to shoot him.  In all of those cases the
comment is clearly not useful, so getting rid of it.
2017-05-23 01:10:29 +05:30
Zack Weinberg a992f506ff Remove __need macros from signal.h.
The types affected are __sig_atomic_t, sig_atomic_t, __sigset_t,
sigset_t, sigval_t, sigevent_t, and siginfo_t. __sig_atomic_t is a
scalar, so it's now directly available from bits/types.h.  The others
get bits/types/ headers.

Side effects include: There have been small changes to which
non-signal headers expose which subset of the signal-related types.
A couple of architectures' nested siginfo_t fields had to be renamed
to prevent undesired macro expansion.  Internal code that wants to
manipulate signal masks must now include <sigsetops.h> (which is not
installed) and should be aware that __sigaddset, __sigandset,
__sigdelset, __sigemptyset, and __sigorset no longer return a value
(unlike the public API).  Relatedly, the public signal.h no longer
declares any of those functions.  The obsolete sigmask() macro no
longer has a system-specific definition -- in the cases where it
matters, it didn't work anyway.

New Linux architectures should create bits/siginfo-arch.h and/or
bits/siginfo-consts-arch.h to customize their siginfo_t, rather than
duplicating everything in bits/siginfo.h (which no longer exists).
Add new __SI_* macros if necessary.  Ports to other operating systems
are strongly encouraged to generalize this scheme further.

	* bits/sigevent-consts.h
	* bits/siginfo-consts.h
	* bits/types/__sigset_t.h
	* bits/types/sigevent_t.h
	* bits/types/siginfo_t.h
	* sysdeps/unix/sysv/linux/bits/sigevent-consts.h
	* sysdeps/unix/sysv/linux/bits/siginfo-consts.h
	* sysdeps/unix/sysv/linux/bits/types/__sigset_t.h
	* sysdeps/unix/sysv/linux/bits/types/sigevent_t.h
	* sysdeps/unix/sysv/linux/bits/types/siginfo_t.h:
	New system-dependent bits headers.

	* sysdeps/unix/sysv/linux/bits/siginfo-arch.h
	* sysdeps/unix/sysv/linux/bits/siginfo-consts-arch.h
	* sysdeps/unix/sysv/linux/ia64/bits/siginfo-arch.h
	* sysdeps/unix/sysv/linux/ia64/bits/siginfo-consts-arch.h
	* sysdeps/unix/sysv/linux/mips/bits/siginfo-arch.h
	* sysdeps/unix/sysv/linux/sparc/bits/siginfo-arch.h
	* sysdeps/unix/sysv/linux/tile/bits/siginfo-arch.h
	* sysdeps/unix/sysv/linux/tile/bits/siginfo-consts-arch.h
	* sysdeps/unix/sysv/linux/x86/bits/siginfo-arch.h:
	New Linux-only system-dependent bits headers.

	* signal/bits/types/sig_atomic_t.h
	* signal/bits/types/sigset_t.h
	* signal/bits/types/sigval_t.h:
	New non-system-dependent bits headers.

	* sysdeps/generic/sigsetops.h
	* sysdeps/unix/sysv/linux/sigsetops.h:
	New internal headers.

	* include/bits/types/sig_atomic_t.h
	* include/bits/types/sigset_t.h
	* include/bits/types/sigval_t.h:
	New wrappers.

	* signal/sigsetops.h
	* bits/siginfo.h
	* bits/sigset.h
	* sysdeps/unix/sysv/linux/bits/siginfo.h
	* sysdeps/unix/sysv/linux/bits/sigset.h
	* sysdeps/unix/sysv/linux/ia64/bits/siginfo.h
	* sysdeps/unix/sysv/linux/mips/bits/siginfo.h
	* sysdeps/unix/sysv/linux/s390/bits/siginfo.h
	* sysdeps/unix/sysv/linux/sparc/bits/siginfo.h
	* sysdeps/unix/sysv/linux/tile/bits/siginfo.h
	* sysdeps/unix/sysv/linux/x86/bits/siginfo.h:
	Deleted.

	* signal/Makefile, sysdeps/unix/sysv/linux/Makefile:
	Update lists of installed headers.

	* posix/bits/types.h: Define __sig_atomic_t here.
	* signal/signal.h: Use the new bits headers; no need to handle
	__need_sig_atomic_t nor __need_sigset_t.  Don't use __sigmask
	to define sigmask.
	* include/signal.h: No need to handle __need_sig_atomic_t
	nor __need_sigset_t.  Don't define __sigemptyset.

	* io/sys/poll.h, setjmp/setjmp.h
	* sysdeps/arm/sys/ucontext.h, sysdeps/generic/sys/ucontext.h
	* sysdeps/i386/sys/ucontext.h, sysdeps/m68k/sys/ucontext.h
	* sysdeps/mach/hurd/i386/bits/sigcontext.h
	* sysdeps/mips/sys/ucontext.h, sysdeps/powerpc/novmxsetjmp.h
	* sysdeps/pthread/bits/sigthread.h
	* sysdeps/unix/sysv/linux/hppa/sys/ucontext.h
	* sysdeps/unix/sysv/linux/m68k/sys/ucontext.h
	* sysdeps/unix/sysv/linux/mips/sys/ucontext.h
	* sysdeps/unix/sysv/linux/nios2/sys/ucontext.h
	* sysdeps/unix/sysv/linux/powerpc/sys/ucontext.h
	* sysdeps/unix/sysv/linux/s390/sys/ucontext.h
	* sysdeps/unix/sysv/linux/sh/sys/ucontext.h
	* sysdeps/unix/sysv/linux/sparc/sys/ucontext.h
	* sysdeps/unix/sysv/linux/tile/sys/ucontext.h
	* sysdeps/unix/sysv/linux/x86/sys/ucontext.h:
	Use bits/types/__sigset_t.h.

	* misc/sys/select.h, posix/spawn.h
	* sysdeps/unix/sysv/linux/powerpc/sys/ucontext.h
	* sysdeps/unix/sysv/linux/sys/epoll.h
	* sysdeps/unix/sysv/linux/sys/signalfd.h:
	Use bits/types/sigset_t.h.

	* resolv/netdb.h, rt/mqueue.h: Use bits/types/sigevent_t.h.
	* rt/aio.h: Use bits/types/sigevent_t.h and bits/sigevent-consts.h.
	* socket/sys/socket.h: Don't include bits/sigset.h.

	* login/utmp_file.c, shadow/lckpwdf.c, signal/sigandset.c
	* signal/sigisempty.c, stdlib/abort.c, sysdeps/posix/profil.c
	* sysdeps/posix/sigignore.c, sysdeps/posix/sigintr.c
	* sysdeps/posix/signal.c, sysdeps/posix/sigset.c
	* sysdeps/posix/sprofil.c, sysdeps/posix/sysv_signal.c
	* sysdeps/unix/sysv/linux/nptl-signals.h:
	Include sigsetops.h.

	* signal/sigaddset.c, signal/sigandset.c, signal/sigdelset.c
	* signal/sigorset.c, stdlib/abort.c, sysdeps/posix/sigignore.c
	* sysdeps/posix/signal.c, sysdeps/posix/sigset.c:
	__sigaddset, __sigandset, __sigdelset, __sigemptyset, __sigorset
	now return no value.

	* signal/sigaddset.c, signal/sigdelset.c, signal/sigismem.c
	Include <errno.h>, <signal.h>, and <sigsetops.h> instead of
	"sigsetops.h".

	* signal/sigsetops.c: Explicitly define __sigismember,
	__sigaddset, and __sigdelset as compatibility symbols.

	* signal/Versions: Correct commentary on __sigpause,
	__sigaddset, __sigdelset, __sigismember.

	* inet/rcmd.c: Include sigsetops.h.  Convert old code using
	__sigblock/__sigsetmask to use __sigprocmask and friends.
2017-05-20 19:04:43 -04:00
H.J. Lu 1f655beb08 x86_64: Remove L(return_null) from rawmemchr.S
L(return_null) is unused.

	* sysdeps/x86_64/rawmemchr.S (L(return_null)): Removed.
2017-05-20 06:13:38 -07:00
Zack Weinberg 81cb7a0b2b Remove sfi_* annotations from ARM assembly files.
This semi-mechanical patch removes all uses and definitions of the
sfi_breg, sfi_pld, and sfi_sp macros from various ARM-specific
assembly files.  These were only used by NaCl.

	* sysdeps/arm/sysdep.h
        (ARM_SFI_MACROS, sfi_breg, sfi_pld, sfi_sp): Delete definitions.

	* sysdeps/arm/__longjmp.S, sysdeps/arm/add_n.S
	* sysdeps/arm/addmul_1.S, sysdeps/arm/arm-mcount.S
	* sysdeps/arm/armv6/rawmemchr.S, sysdeps/arm/armv6/strchr.S
	* sysdeps/arm/armv6/strcpy.S, sysdeps/arm/armv6/strlen.S
	* sysdeps/arm/armv6/strrchr.S, sysdeps/arm/armv6t2/memchr.S
	* sysdeps/arm/armv6t2/strlen.S
	* sysdeps/arm/armv7/multiarch/memcpy_impl.S
	* sysdeps/arm/armv7/strcmp.S, sysdeps/arm/dl-tlsdesc.S
	* sysdeps/arm/memcpy.S, sysdeps/arm/memmove.S
	* sysdeps/arm/memset.S, sysdeps/arm/setjmp.S
	* sysdeps/arm/strlen.S, sysdeps/arm/submul_1.S:
        Remove all uses of sfi_breg, sfi_pld, and sfi_sp.
2017-05-20 08:12:11 -04:00
Zack Weinberg 42a844c6a2 Remove the bulk of the NaCl port.
The NaCl port has not been actively maintained since before the 2.25
release.  The complementary GCC back-end was never contributed to GCC,
and we are given to understand that the current NaCl SDK has switched
to Clang and therefore cannot be used to build glibc anymore, so we
doubt that the port remains useful.

This commit simply removes the sysdeps/arm/nacl and sysdeps/nacl
directories and the abi-tags entry.

	Remove the NaCl port.
	* abi-tags: Remove .*-.*-nacl.* entry.
	* sysdeps/arm/nacl: Remove directory and contents.
	* sysdeps/nacl: Likewise.
2017-05-20 08:09:10 -04:00
Rical Jasan a429d2ff07 manual: Convert errno @comments to new @errno macro.
errno.texi documents error macros, their values, and error strings in
Texinfo @comments, some of which are also used for @standards.  The
purpose of this commit is to separate the standards from the error
strings so that both the @standards conversion script picks up clean
@standards and the errno documentation framework is improved.

The error names, values, and messages are consolidated in a new custom
macro, @errno.  It is not clear that scripts within the sources rely
on the special Texinfo @comment-based format to generate files used
throughout the library, so the definition of @errno in macros.texi now
provides a comment indicating the dependency.  The dependent scripts
are updated to use @errno, which also simplifies them a bit.  The
files those scripts generate were verified to be unchanged.

The @errno macro is not visibly rendered in any way at this time, but
it does use an @cindex command to add the error string to the Concept
Index, to facilitate searching on error messages.

	* manual/errno.texi: Convert @comment-based errno
	documentation to @errno.
	* manual/macros.texi (@errno): New macro.  Consolidate errors,
	their values, and messages, adding the error string to the
	Concept Index.  Provide a warning in the comment about
	external (to the manual) dependencies.
	* sysdeps/gnu/errlist.awk: Use @errno instead of @comments.
	* sysdeps/mach/hurd/errnos.awk: Likewise.
2017-05-19 22:47:53 -07:00
Joseph Myers 0bcec5321f Split up bits/sigstack.h.
bits/sigstack.h contains four things: the legacy struct sigstack type,
the preferred stack_t type, the SS_* enum values and macros for signal
stack sizes.

These vary in different ways between glibc configurations; in
particular, the stack sizes vary much more than any of the other
pieces.  Furthermore, these pieces have different standard namespace
rules for when they should be visible (not currently visible in
conform/ results both because the relevant tests are XFAILed for
sys/ucontext.h namespace issues, and because some of the expectations
are incorrect in the same way as the headers, e.g. neither
expectations nor headers reflect that current POSIX no longer has
either the sigstack function or the sigstack structure).

To reduce duplication of identical definitions, and facilitate
namespace fixes without requiring the same feature test macro
conditions to be repeated in many versions of the same header, this
patch splits bits/sigstack.h up into four headers.  It keeps the stack
size macros, while new bits/types/struct_sigstack.h,
bits/types/stack_t.h and bits/ss_flags.h are added for the other
pieces.  bits/types/struct_sigstack.h is the same everywhere,
bits/types/stack_t.h has three variants different in the order of the
structure elements (generic = MIPS Linux, and other Linux), and
bits/ss_flags.h has generic and Linux variants.

This patch includes the new headers everywhere that included
<bits/sigstack.h>, so should cause no difference to what any public
header defines.  Subsequent namespace fixes would then remove or
condition some of those includes.

There should be no conflicts with Zack's changes to signal.h types,
beyond the trivial conflict of both making additions to
signal/Makefile's headers list; the two patches affect disjoint sets
of types and other definitions.

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

	* bits/ss_flags.h: New file.
	* bits/types/stack_t.h: Likewise.
	* include/bits/types/struct_sigstack.h: Likewise.
	* signal/bits/types/struct_sigstack.h: Likewise.
	* sysdeps/unix/sysv/linux/bits/ss_flags.h: Likewise.
	* sysdeps/unix/sysv/linux/bits/types/stack_t.h: Likewise.
	* sysdeps/unix/sysv/linux/mips/bits/types/stack_t.h: Likewise.
	* signal/Makefile (headers): Add bits/types/struct_sigstack.h,
	bits/types/stack_t.h and bits/ss_flags.h.
	* signal/signal.h [__USE_XOPEN_EXTENDED || __USE_XOPEN2K8]:
	Include <bits/types/struct_sigstack.h>, <bits/types/stack_t.h> and
	<bits/ss_flags.h>.
	* bits/sigstack.h (struct sigstack): Remove.
	(stack_t): Likewise.
	(SS_ONSTACK): Likewise.
	(SS_DISABLE): Likewise.
	* sysdeps/unix/sysv/linux/aarch64/bits/sigstack.h
	(struct sigstack): Likewise.
	(stack_t): Likewise.
	(SS_ONSTACK): Likewise.
	(SS_DISABLE): Likewise.
	* sysdeps/unix/sysv/linux/alpha/bits/sigstack.h (struct sigstack):
	Likewise.
	(stack_t): Likewise.
	(SS_ONSTACK): Likewise.
	(SS_DISABLE): Likewise.
	* sysdeps/unix/sysv/linux/bits/sigstack.h (struct sigstack):
	Likewise.
	(stack_t): Likewise.
	(SS_ONSTACK): Likewise.
	(SS_DISABLE): Likewise.
	* sysdeps/unix/sysv/linux/mips/bits/sigstack.h: Likewise.
	* sysdeps/unix/sysv/linux/ia64/bits/sigstack.h (struct sigstack):
	Likewise.
	(stack_t): Likewise.
	(SS_ONSTACK): Likewise.
	(SS_DISABLE): Likewise.
	* sysdeps/unix/sysv/linux/powerpc/bits/sigstack.h
	(struct sigstack): Likewise.
	(stack_t): Likewise.
	(SS_ONSTACK): Likewise.
	(SS_DISABLE): Likewise.
	* sysdeps/unix/sysv/linux/sparc/bits/sigstack.h (struct sigstack):
	Likewise.
	(stack_t): Likewise.
	(SS_ONSTACK): Likewise.
	(SS_DISABLE): Likewise.
	* sysdeps/arm/sys/ucontext.h: Include
	<bits/types/struct_sigstack.h>, <bits/types/stack_t.h> and
	<bits/ss_flags.h>.
	* sysdeps/generic/sys/ucontext.h: Likewise.
	* sysdeps/i386/sys/ucontext.h: Likewise.
	* sysdeps/m68k/sys/ucontext.h: Likewise.
	* sysdeps/mips/sys/ucontext.h: Likewise.
	* sysdeps/unix/sysv/linux/aarch64/sys/ucontext.h: Likewise.
	* sysdeps/unix/sysv/linux/alpha/sys/ucontext.h: Likewise.
	* sysdeps/unix/sysv/linux/arm/sys/ucontext.h: Likewise.
	* sysdeps/unix/sysv/linux/hppa/sys/ucontext.h: Likewise.
	* sysdeps/unix/sysv/linux/ia64/bits/sigcontext.h: Likewise.
	* sysdeps/unix/sysv/linux/ia64/sys/ucontext.h: Likewise.
	* sysdeps/unix/sysv/linux/m68k/sys/ucontext.h: Likewise.
	* sysdeps/unix/sysv/linux/mips/sys/ucontext.h: Likewise.
	* sysdeps/unix/sysv/linux/nios2/sys/ucontext.h: Likewise.
	* sysdeps/unix/sysv/linux/powerpc/sys/ucontext.h: Likewise.
	* sysdeps/unix/sysv/linux/s390/sys/ucontext.h: Likewise.
	* sysdeps/unix/sysv/linux/sh/sys/ucontext.h: Likewise.
	* sysdeps/unix/sysv/linux/sparc/sys/ucontext.h: Likewise.
	* sysdeps/unix/sysv/linux/tile/sys/ucontext.h: Likewise.
	* sysdeps/unix/sysv/linux/x86/sys/ucontext.h: Likewise.
2017-05-19 20:35:07 +00:00
H.J. Lu 402bf06952 x86: Optimize SSE2 memchr overflow calculation
SSE2 memchr computes "edx + ecx - 16" where ecx is less than 16.  Use
"edx - (16 - ecx)", instead of satured math, to avoid possible addition
overflow.  This replaces

	add	%ecx, %edx
	sbb	%eax, %eax
	or	%eax, %edx
	sub	$16, %edx

with

	neg	%ecx
	add	$16, %ecx
	sub	%ecx, %edx

It is the same for x86_64, except for rcx/rdx, instead of ecx/edx.

	* sysdeps/i386/i686/multiarch/memchr-sse2.S (MEMCHR): Use
	"edx + ecx - 16" to avoid possible addition overflow.
	* sysdeps/x86_64/memchr.S (memchr): Likewise.
2017-05-19 10:48:45 -07:00
Adhemerval Zanella 1d71a63153 Fix makefile rules for vmsplice, splice, and open_by_handle_at
Commits ecade1c, afbbc18, and a5a34d2 added compiler flags for
vmsplice, splice, and open_by_handle_at respectively on default
misc/Makefile.  However such symbols are build only for Linux and
the rules should on linux Makefile only.

Checked on x86_64-linux-gnu.

	* misc/Makefile (CFLAGS-vmsplice.c): Remove rule.
	(CFLAGS-splice.c): Likewise.
	(CFLAGS-open_by_handle_at.c): Likewise.
	* sysdeps/unix/sysv/linux/Makefile (CFLAGS-vmsplice.c): New rule.
	(CFLAGS-splice.c): Likewise.
	(CFLAGS-open_by_handle_at.c): Likewise.
2017-05-19 09:37:00 -03:00
Joseph Myers 9aa4965cdf Also create and use ldbl-compat-choose.h.
This patch makes the glibc build generate an additional header
ldbl-compat-choose.h that defines LONG_DOUBLE_COMPAT_CHOOSE_* macros
for each libc and libm symbol, which select one or the other of their
arguments based on whether the symbol was added before a change to
long double != double.

The effect of this is that it is then possible to define a macro
maybe_long_double_symbol that automatically acts as either
long_double_symbol or weak_alias depending on when the symbol being
defined was added.  This can be used when building long double
functions from type-generic templates.  Thus, with this patch ldbl-opt
no longer needs special long double implementations of each new libm
function added using such a template, and the existing such
implementations are removed.

This is a step towards being able more generally to use common macros
to create all the aliases needed for a libm function, so reducing the
amount of special-case code needed in ldbl-opt and ldbl-64-128, and
facilitating subsequently adding *f32 / *f64 / *f128 / *f32x / *f64x
aliases to existing functions (where the set of aliases that a
function should have may depend on the architecture in various ways).

Tested with build-many-glibcs.py.  Except for on
powerpc64le-linux-gnu, installed stripped shared libraries are
unchanged by the patch.  powerpc64le-linux-gnu is the unique
configuration which used ldbl-opt from the start rather than adding a
new long double choice after originally only having had long double =
double.  The effect of the patch there is that various cases that
previously used long_double_symbol unconditionally now use weak_alias
instead, so .os files contain e.g. a symbol cabsl instead of
cabsl@@GLIBC_2.17.  The final dynamic symbols and versions in the
resulting shared libraries are unchanged (ABI tests pass), as is the
disassembly of the shared libraries, but the differences in the .os
files still result in different .gnu_hash contents in libm.so; the
differences are of no significance and logically using weak_alias is
what's most appropriate in those cases.

	* scripts/versions.awk: Generate ldbl-compat-choose.h.
	* sysdeps/ieee754/ldbl-opt/math-type-macros-ldouble.h: Include
	<ldbl-compat-choose.h>.
	(maybe_long_double_symbol): New macro.
	[!declare_mgen_alias] (declare_mgen_alias): Use
	maybe_long_double_symbol.
	* sysdeps/ieee754/ldbl-opt/s_canonicalizel.c: Remove.
	* sysdeps/ieee754/ldbl-opt/s_fmaxmagl.c: Likewise.
	* sysdeps/ieee754/ldbl-opt/s_fminmagl.c: Likewise.
	* sysdeps/ieee754/ldbl-opt/s_nextdownl.c: Likewise.
	* sysdeps/ieee754/ldbl-opt/w_llogbl.c: Likewise.
	* Makerules [$(build-shared) = yes && !avoid-generated]
	(before-compile): Add $(common-objpfx)ldbl-compat-choose.h.
	[$(build-shared) = yes && !avoid-generated]
	($(common-objpfx)ldbl-compat-choose.h): New target.
2017-05-19 11:30:26 +00:00
Joseph Myers 8f2e1830f2 Create and use first-versions.h with macros for function symbol versions.
This patch arranges for the glibc build to generate a header
first-versions.h that defines macros for the earliest symbol version
in which each public symbol (GLIBC_[0-9]* symbol version, name only
uses C identifier characters) is available.

This is used in sysdeps/ieee754/ldbl-opt/math-type-macros-double.h to
replace the manually defined LDOUBLE_*_libm_version macros for various
functions defined using type-generic templates, the purpose of which
is to use in LONG_DOUBLE_COMPAT tests "was this function originally
added before glibc supported long double != double on this platform?".
As discussed in
<https://sourceware.org/ml/libc-alpha/2016-12/msg00246.html>, I expect
this to be useful more generally in reducing the amount of
special-case code needed in ldbl-opt and ldbl-64-128.

Tested with build-many-glibcs.py that installed stripped shared
libraries are unchanged by this patch.

	* scripts/versions.awk: Generate first-versions.h.
	* sysdeps/ieee754/ldbl-opt/math-type-macros-double.h: Include
	<first-versions.h>.
	(LDOUBLE_cabsl_libm_version): Remove macro.
	(LDOUBLE_cargl_libm_version): Likewise.
	(LDOUBLE_cimagl_libm_version): Likewise.
	(LDOUBLE_conjl_libm_version): Likewise.
	(LDOUBLE_creall_libm_version): Likewise.
	(LDOUBLE_cacosl_libm_version): Likewise.
	(LDOUBLE_cacoshl_libm_version): Likewise.
	(LDOUBLE_ccosl_libm_version): Likewise.
	(LDOUBLE_ccoshl_libm_version): Likewise.
	(LDOUBLE_casinl_libm_version): Likewise.
	(LDOUBLE_csinl_libm_version): Likewise.
	(LDOUBLE_casinhl_libm_version): Likewise.
	(LDOUBLE_csinhl_libm_version): Likewise.
	(LDOUBLE_catanl_libm_version): Likewise.
	(LDOUBLE_catanhl_libm_version): Likewise.
	(LDOUBLE_ctanl_libm_version): Likewise.
	(LDOUBLE_ctanhl_libm_version): Likewise.
	(LDOUBLE_cexpl_libm_version): Likewise.
	(LDOUBLE_clogl_libm_version): Likewise.
	(LDOUBLE_cprojl_libm_version): Likewise.
	(LDOUBLE_csqrtl_libm_version): Likewise.
	(LDOUBLE_cpowl_libm_version): Likewise.
	(LDOUBLE_clog10l_libm_version): Likewise.
	(LDOUBLE___clog10l_libm_version): Likewise.
	(LDOUBLE_fdiml_libm_version): Likewise.
	(LDOUBLE_fmaxl_libm_version): Likewise.
	(LDOUBLE_fminl_libm_version): Likewise.
	(LDOUBLE_ilogbl_libm_version): Likewise.
	(LDOUBLE_nanl_libm_version): Likewise.
	[!M_LIBM_NEED_COMPAT] (M_LIBM_NEED_COMPAT): Use
	FIRST_VERSION_libm_* macros.
	[!declare_mgen_libm_compat] (declare_mgen_libm_compat): Likewise.
	* Makerules [$(build-shared) = yes && !avoid-generated]
	(before-compile): Add $(common-objpfx)first-versions.h.
	[$(build-shared) = yes && !avoid-generated]
	($(common-objpfx)first-versions.h): New target.
	($(common-objpfx)sysd-versions): Depend on and change to rule for
	building $(common-objpfx)versions.stmp.
2017-05-19 11:26:00 +00:00
Adhemerval Zanella 332e01c627 posix: Consolidate Linux mq_timedsend syscall
This patch consolidates the mq_timedsend Linux syscall generation
on sysdeps/unix/sysv/linux/mq_timedsend.c.  It basically removes it
from architecture auto-generation list.

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

	* rt/Makefile (CFLAGS-mq_timedsend.c): New flag.
	* sysdeps/unix/sysv/linux/mq_timedsend.c: New file.
	* sysdeps/unix/sysv/linux/syscalls.list (mq_timedsend): Remove from
	auto-generation list.
2017-05-18 18:06:47 -03:00
Adhemerval Zanella a5fdd30597 posix: Consolidate Linux mq_timedreceive syscall
This patch consolidates the mq_timedreceive Linux syscall generation
on sysdeps/unix/sysv/linux/mq_timedreceive.c.  It basically removes it
from architecture auto-generation list.

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

	* rt/Makefile (CFLAGS-mq_timedreceive.c): New flag.
	* sysdeps/unix/sysv/linux/mq_timedreceive.c: New file.
	* sysdeps/unix/sysv/linux/syscalls.list (mq_timedreceive): Remove
	from auto-generation list.
2017-05-18 18:06:47 -03:00
Adhemerval Zanella a5a34d2eaf linux: Consolidate Linux open_by_handle_at syscall
This patch consolidates the open_by_handle_at Linux syscall generation on
sysdeps/unix/sysv/linux/open_by_handle_at.c.  It basically removes it from
architectures auto-generation list.

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

	* sysdeps/unix/sysv/linux/Makefile (sysdep_routines): Add
	open_by_handle_at.
	(CFLAGS-open_by_handle_at.c): New flag.
	* sysdeps/unix/sysv/linux/open_by_handle_at.c: New file.
	* sysdeps/unix/sysv/linux/syscalls.list (open_by_handle_at): New
	file.
	* misc/Makefile (CFLAGS-open_by_handle_at.c): New rule.
2017-05-18 18:06:47 -03:00
Adhemerval Zanella afbbc18f9e linux: Consolidate Linux splice syscall
This patch consolidates the splice Linux syscall generation on
sysdeps/unix/sysv/linux/splice.c.  It basically removes it from
architectures auto-generation list.

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

	* sysdeps/unix/sysv/linux/Makefile (sysdep_routines): Add splice.
	(CFLAGS-splice.c): New flag.
	* sysdeps/unix/sysv/linux/splice.c: New file.
	* sysdeps/unix/sysv/linux/syscalls.list (splice): Remove from
	auto-generation syscall list.
	* misc/Makefile (CFLAGS-splice.c): New rule.
2017-05-18 18:06:47 -03:00
Adhemerval Zanella ecade1cb0b linux: Consolidate Linux vmsplice syscall
This patch consolidates the vmsplice Linux syscall generation on
sysdeps/unix/sysv/linux/vmsplice.c.  It basically removes it from
architectures auto-generation list.

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

	* sysdeps/unix/sysv/linux/Makefile (CFLAGS-vmsplice.c): New flag.
	* sysdeps/unix/sysv/linux/syscalls.list (vmsplice): Remove from
	auto-generation syscall list.
	* sysdeps/unix/sysv/linux/vmsplice.c: New file.
	* misc/Makefile (CFLAGS-vmsplice.c): New rule.
2017-05-18 18:06:47 -03:00
Adhemerval Zanella fdbb0d98ba posix: Consolidate Linux fsync syscall
This patch consolidates the fsync Linux syscall generation on
sysdeps/unix/sysv/linux/fsync.c.  It basically removes it from
architectures auto-generation list.

For arm it also removes the __errno_location call since fsync
is not called with SYSCALL_CANCEL with call arch-specific
INLINE_SYSCALL macro which in turn will call __set_errno macro
(and setting errno directly).

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

	* misc/Makefile (CFLAGS-fsync.c): New flag.
	* nptl/Makefile (CFLAGS-fsync.c): Likewise.
	* sysdeps/unix/syscalls.list (fsync): Remove from auto-generation
	syscall list.
	* sysdeps/unix/sysv/linux/fsync.c: New file.
	* sysdeps/unix/sysv/linux/arm/localplt.data [libpthread.so]
	(__errno_location): Remove.
2017-05-18 18:06:47 -03:00
Adhemerval Zanella 51209cbf51 posix: Consolidate Linux fdatasync syscall
This patch consolidates the fdatasync Linux syscall generation on
sysdeps/unix/sysv/linux/fdatasync.c.  It basically removes it from
architectures auto-generation list.

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

	* misc/makefile (CFLAGS-datasync.c): New flag.
	* nptl/makefile (CFLAGS-datasync.c): Likewise.
	* sysdeps/unix/sysv/linux/syscalls.list (fdatasync): Remove from
	auto-generation syscall list.
	* sysdeps/unix/sysv/linux/fdatasync.c: New file.
2017-05-18 18:06:47 -03:00
Adhemerval Zanella 3c9399f507 posix: Consolidate Linux msync syscall
This patch consolidates the msync Linux syscall generation on
sysdeps/unix/sysv/linux/msync.c.  It basically removes it from
architectures auto-generation list.

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

	* misc/Makefile (CFLAGS-msync.c): New rule.
	* nptl/Makefile (CFLAGS-msync.c): Likewise.
	* sysdeps/unix/syscalls.list: Remove msync from auto-generation list.
	* sysdeps/unix/sysv/linux/msync.c: New file.
2017-05-18 18:06:47 -03:00
Adhemerval Zanella b3b00aa8b0 posix: Consolidate Linux sigsuspend implementation
This patch consolidates the sigsuspend Linux syscall generation on
sysdeps/unix/sysv/linux/sigsuspend.c.  It basically removes the alpha
assembly version which call the old sigsusped interface using only
the first doubleword from sigset. Current minimum supported kernel
on alpha (3.2) enforces rt_sigsuspend on the architecture
(__ARCH_WANT_SYS_RT_SIGSUSPEND option on kernel), so it is possible
to use the default implementation.

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

	* sysdeps/unix/sysv/linux/alpha/sigsuspend.S: Remove file.
	* sysdeps/unix/sysv/linux/sigsuspend.c: Simplify include list.
	* nptl/Makefile (CFLAGS-sigsuspend.c): New rule.
	* sysdeps/unix/sysv/linux/sparc/sparc64/Makefile
	(CFLAGS-sigsuspend.c): Remove rule.
2017-05-18 18:06:47 -03:00
Adhemerval Zanella 2de15b61e9 linux: Consolidate Linux tee implementation
This patch consolidates the tee Linux syscall generation on
sysdeps/unix/sysv/linux/tee.c.  It basically removes it from
architectures auto-generation list.

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

	* sysdeps/unix/sysv/linux/Makefile (sysdeps_routines): Add tee.
	(CFLAGS-tee.c): New rule.
	* sysdeps/unix/sysv/linux/syscalls.list: Remove tee from
	auto-generated list.
	* sysdeps/unix/sysv/linux/tee.c: New file.
2017-05-18 18:06:47 -03:00
Adhemerval Zanella 3d0ad5a8df posix: Consolidate Linux nanosleep syscall
This patch consolidates the nanosleep Linux syscall generation on
sysdeps/unix/sysv/linux/nanosleep.c.  It basically removes it from
architectures auto-generation list.

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

	* nptl/Makefile (CFLAGS-nanosleep.c): New rule.
	* posix/Makefile (CFLAGS-nanosleep.c): Likewise.
	* sysdeps/unix/sysv/linux/nanosleep.c: New file.
	* sysdeps/unix/sysv/linux/syscalls.list: Remove nanosleep from
	auto-generated list.
2017-05-18 18:06:47 -03:00
Adhemerval Zanella ebfdb12bf0 posix: Consolidate Linux waitpid syscall
This patch consolidates the waitpid Linux syscall generation on
sysdeps/unix/sysv/linux/waitpid.c.  It basically removes it from
architecture auto-generation list and also remove arch specific
implementations.

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/sh/syscalls.list: Remove waitpid from
	auto-generated list.
	* sysdeps/unix/sysv/linux/m68k/syscalls.list: Likewise.
	* sysdeps/unix/sysv/linux/i386/syscalls.list: Likewise.
	* sysdeps/unix/sysv/linux/sparc/syscalls.list: Remove file.
	* sysdeps/unix/sysv/linux/tile/waitpid.S: Likewise.
	* sysdeps/unix/sysv/linux/powerpc/syscalls.list: Likewise.
2017-05-18 18:06:47 -03:00
Adhemerval Zanella 88499a87ce posix: Consolidate Linux pause syscall
This patch consolidates the pause Linux implementation on
sysdeps/unix/sysv/linux/pause.c.  If defined the pause syscall
(__NR_pause) will be used, other ppoll with 0 arguments will be
used instead.

It has the small advantage of generic pause implementation with
uses rt_sigprocmask plus rt_sigsuspend because it requires only
one syscall and the pause is done atomically regarding signal
handling (for instance, pause may not be interrupted if the
signal arrives between the rt_sigprocmask and rt_sigsuspend
syscall).

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

	* sysdeps/unix/sysv/linux/generic/pause.c: Remove file.
	* sysdeps/unix/sysv/linux/sparc/sparc64/pause.c: Likewise.
	* sysdeps/unix/sysv/linux/sparc/kernel-features.h [__arch64__]
	(__NR_pause): Undefine.
	* sysdeps/unix/sysv/linux/pause.c: New file.
	* sysdeps/unix/sysv/linux/syscalls.list: Remove pause from
	auto-generation list.
2017-05-18 18:06:47 -03:00
H.J. Lu a7fbedff76 Correct comments in x86_64/multiarch/memcmp.S
* sysdeps/x86_64/multiarch/memcmp.S (__GI_memcmp): Correct
	comments.
2017-05-18 14:02:02 -07:00
Rajalakshmi Srinivasaraghavan dec4a7105e powerpc: Improve memcmp performance for POWER8
Vectorization improves performance over the current implementation.
Tested on powerpc64 and powerpc64le.
2017-05-18 11:21:20 +05:30
Paul Clarke b2980e3c54 powerpc: Add a POWER8-optimized version of cosf()
This implementation is based on the one already used at
sysdeps/powerpc/powerpc64/fpu/multiarch/s_sinf-power8.S.

	* sysdeps/powerpc/powerpc64/fpu/multiarch/Makefile
	[$(subdir) = math] (libm-sysdep_routines): Add s_cosf-power8 and
	s_cosf-ppc64.
	* sysdeps/powerpc/powerpc64/fpu/multiarch/s_cosf-power8.S: New file.
	* sysdeps/powerpc/powerpc64/fpu/multiarch/s_cosf-ppc64.c: Likewise.
	* sysdeps/powerpc/powerpc64/fpu/multiarch/s_cosf.c: Likewise.
	* sysdeps/powerpc/powerpc64/power8/fpu/s_cosf.S: Likewise.
2017-05-17 18:37:48 -03:00
Gabriel F. T. Gomes 7620dc1235 Convert e_exp2l.c into a template
This patch converts the implementation of exp2l in math/e_exp2l.c into
a template in math/e_exp2_template.c, then adjusts Makefile to use
this template for long double (the implementations for float and
double in sysdeps have higher precedence and are not used).  This
template can also be used for float128, thus reducing the amount of
duplicated code that gets added when adding support the new type.

Tested for powerpc64le and s390x.

	* math/Makefile (libm-calls): Move e_exp2F to gen-libm-calls.
	(gen-libm-calls): Add e_exp2F to use the template.
	* math/e_exp2l.c: Rename to math/e_exp2_template.c.
	* math/e_exp2_template.c: New file, renamed from
	math/e_exp2l.c, and made into a template.
	* sysdeps/generic/math-type-macros.h (M_MIN_EXP): New macro.
2017-05-17 14:44:08 -03:00
Adhemerval Zanella c79a72aa5c posix: Fix and simplify default p{read,write}v implementation
Currently all architectures but microblaze use wire-up syscall for
p{readv,write}v.  Microblaze still uses the syscall emulation using
sysdep/posix/p{readv,writev}.c and it was reported in some ocasions
[1] [2] that it might have some issues with some linux specific
usage (mainly with O_DIRECT and the alignment requirement).

Although it is not an issue for virtually all the system, this
patch refactors the sysdeps/posix p{read,write}v syscall to avoid
such issue (by using posix_memalign on the buffer used on
p{read,write} call) and by refactoring it common files to avoid
the need check on defines to correct set the alias and internal
symbols.

Checked on microblaze-linux-gnu check with run-built-tests=no and
by using the sysdeps/posix implementation on x86_64-linux-gnu (just
for sanity test where it shown no regression).

	* sysdeps/posix/preadv.c: Use sysdeps/posix/preadv_common.c.
	* sysdeps/posix/preadv64.c: Likewise.
	* sysdeps/unix/sysv/linux/preadv.c: Likewise.
	* sysdeps/unix/sysv/linux/preadv64.c: Likewise.
	* sysdeps/posix/pwritev.c: Use sysdeps/posix/pwritev_common.c.
	* sysdeps/posix/pwritev64.c: Likewise.
	* sysdeps/unix/sysv/linux/pwritev.c: Likewise.
	* sysdeps/unix/sysv/linux/pwritev64.c: Likewise.
	* sysdeps/posix/preadv_common.c: New file.
	* sysdeps/posix/pwritev_common.c: Likewise.

[1] http://www.mail-archive.com/qemu-devel@nongnu.org/msg25282.html
[2] https://bugzilla.redhat.com/show_bug.cgi?id=563103#c8
2017-05-15 16:33:45 -03:00
Gabriel F. T. Gomes cdd45522b6 float128: Enable use of IEEE wrapper templates
The templates for the IEEE functions wrappers implement wrappers that
do not rely on _LIB_VERSION / matherr / __kernel_standard
functionality to set errno and fix the return value of the functions.
The wrappers are ready to be used by all floating-point types, however
they will first be used by float128, since the old wrappers for float,
double, and long double need to be first deprecated and versioned.

This commits defines __USE_WRAPPER_TEMPLATE to 1 for float128 files,
so that the new wrapper templates are used for this type.

	* sysdeps/generic/math-type-macros-float128.h
	(__USE_WRAPPER_TEMPLATE): Define to 1 to enable use of the
	wrapper templates.
2017-05-15 10:24:14 -03:00
Paul E. Murphy 81f26b53b5 float128: Add private _Float128 declarations for libm.
Add the necessary bits to the private headers to support
building the _Float128 libm functions.

A local override for float.h is provided to include the
missing *FLT128 macros implied by TS 18661-3 for this
type when compiling prior to GCC 7.

	* include/complex.h (__kernel_casinhf128): New declaration.
	* include/float.h: New file.
	* include/math.h (__finitef128): Add a hidden def.
	(__isinff128): Likewise.
	(__isnanf128): Likewise.
	(__fpclassify): Likewise.
	(__issignalling): Likewise.
	(__expf128): Likewise.
	(__expm1f128): Likewise.

	* sysdeps/generic/fix-fp-int-convert-overflow.h:
	(FIX_FLT128_LONG_CONVERT_OVERFLOW): New macro.
	(FIX_FLT128_LLONG_CONVERT_OVERFLOW): Likewise.

	* sysdeps/generic/math-type-macros-float128.h: New file.

	* sysdeps/generic/math_private.h: Include bits/floatn.h and
	math_private_calls.h for _Float128.
	(__isinff128): New inline implementation used when GCC < 7.0,
	since in this case __builtin_isinf_sign is broken.
	(fabsf128): New inline implementation that calls the builtin.
	(__EXPR_FLT128): New macro.
	(min_of_type): Optionally include _Float128 types too.

	* sysdeps/generic/math_private_calls.h (__kernel_sincos):
	Declare for _Float128.
	(__kernel_rem_pio2): Likewise.

	* sysdeps/ieee754/ldbl-opt/s_sin.c:
	(__DECL_SIMD_sincos_disablef128): New macro.
2017-05-15 10:23:28 -03:00
Joseph Myers e1d6e08dd6 Remove useless SPARC signbit aliases.
The SPARC implementations of __signbit* functions have aliases
signbit, signbitf, signbitl.  These are useless, as they aren't
exported from the shared libraries (only the __signbit* functions are
exported, to be used by the type-generic signbit macro with older
compilers).  This patch removes the useless aliases.

Tested (compilation only) with build-many-glibcs.py for
sparc64-linux-gnu and sparcv9-linux-gnu.

	* sysdeps/sparc/sparc32/fpu/s_signbit.S (signbit): Remove alias.
	(signbitf): Likewise.
	* sysdeps/sparc/sparc64/fpu/multiarch/s_signbit.S (signbit):
	Likewise.
	(signbitl): Likewise.
	* sysdeps/sparc/sparc64/fpu/multiarch/s_signbitf.S (signbitf):
	Likewise.
	* sysdeps/sparc/sparc64/fpu/s_signbit.S (signbit): Likewise.
	(signbitl): Likewise.
	* sysdeps/sparc/sparc64/fpu/s_signbitf.S (signbitf): Likewise.
2017-05-12 16:37:12 +00:00
Florian Weimer 1d2bc2eae9 fork: Remove bogus parent PID assertions [BZ #21386] 2017-05-12 16:04:16 +02:00
Joseph Myers e8f1225ca4 Remove __ASSUME_STATFS_F_FLAGS.
Now that 3.2 is the minimum Linux kernel version for glibc, this patch
removes __ASSUME_STATFS_F_FLAGS and associated conditional code.

Tested for x86_64.

	* sysdeps/unix/sysv/linux/kernel-features.h
	(__ASSUME_STATFS_F_FLAGS): Remove macro.
	* sysdeps/unix/sysv/linux/internal_statvfs.c
	[!__ASSUME_STATFS_F_FLAGS]: Remove conditional code.
2017-05-12 11:48:37 +00:00
Zack Weinberg 7c3018f9e4 Suppress internal declarations for most of the testsuite.
This patch adds a new build module called 'testsuite'.
IS_IN (testsuite) implies _ISOMAC, as do IS_IN_build and __cplusplus
(which means several ad-hoc tests for __cplusplus can go away).
libc-symbols.h now suppresses almost all of *itself* when _ISOMAC is
defined; in particular, _ISOMAC mode does not get config.h
automatically anymore.

There are still quite a few tests that need to see internal gunk of
one variety or another.  For them, we now have 'tests-internal' and
'test-internal-extras'; files in this category will still be compiled
with MODULE_NAME=nonlib, and everything proceeds as it always has.
The bulk of this patch is moving tests from 'tests' to
'tests-internal'.  There is also 'tests-static-internal', which has
the same effect on files in 'tests-static', and 'modules-names-tests',
which has the *inverse* effect on files in 'modules-names' (it's
inverted because most of the things in modules-names are *not* tests).
For both of these, the file must appear in *both* the new variable and
the old one.

There is also now a special case for when libc-symbols.h is included
without MODULE_NAME being defined at all.  (This happens during the
creation of libc-modules.h, and also when preprocessing Versions
files.)  When this happens, IS_IN is set to be always false and
_ISOMAC is *not* defined, which was the status quo, but now it's
explicit.

The remaining changes to C source files in this patch seemed likely to
cause problems in the absence of the main change.  They should be
relatively self-explanatory.  In a few cases I duplicated a definition
from an internal header rather than move the test to tests-internal;
this was a judgement call each time and I'm happy to change those
however reviewers feel is more appropriate.

	* Makerules: New subdir configuration variables 'tests-internal'
	and 'test-internal-extras'.  Test files in these categories will
	still be compiled with MODULE_NAME=nonlib.  Test files in the
	existing categories (tests, xtests, test-srcs, test-extras) are
	now compiled with MODULE_NAME=testsuite.
	New subdir configuration variable 'modules-names-tests'.  Files
	which are in both 'modules-names' and 'modules-names-tests' will
	be compiled with MODULE_NAME=testsuite instead of
	MODULE_NAME=extramodules.
	(gen-as-const-headers): Move to tests-internal.
	(do-tests-clean, common-mostlyclean): Support tests-internal.
	* Makeconfig (built-modules): Add testsuite.
	* Makefile: Change libof-check-installed-headers-c and
	libof-check-installed-headers-cxx to 'testsuite'.
	* Rules: Likewise.  Support tests-internal.
	* benchtests/strcoll-inputs/filelist#en_US.UTF-8:
	Remove extra-modules.mk.

	* config.h.in: Don't check for __OPTIMIZE__ or __FAST_MATH__ here.
	* include/libc-symbols.h: Move definitions of _GNU_SOURCE,
	PASTE_NAME, PASTE_NAME1, IN_MODULE, IS_IN, and IS_IN_LIB to the
	very top of the file and rationalize their order.
	If MODULE_NAME is not defined at all, define IS_IN to always be
	false, and don't define _ISOMAC.
	If any of IS_IN (testsuite), IS_IN_build, or __cplusplus are
	true, define _ISOMAC and suppress everything else in this file,
	starting with the inclusion of config.h.
	Do check for inappropriate definitions of __OPTIMIZE__ and
	__FAST_MATH__ here, but only if _ISOMAC is not defined.
        Correct some out-of-date commentary.

	* include/math.h: If _ISOMAC is defined, undefine NO_LONG_DOUBLE
	and _Mlong_double_ before including math.h.
	* include/string.h: If _ISOMAC is defined, don't expose
	_STRING_ARCH_unaligned. Move a comment to a more appropriate
	location.

	* include/errno.h, include/stdio.h, include/stdlib.h, include/string.h
	* include/time.h, include/unistd.h, include/wchar.h: No need to
	check __cplusplus nor use __BEGIN_DECLS/__END_DECLS.

	* misc/sys/cdefs.h (__NTHNL): New macro.
	* sysdeps/m68k/m680x0/fpu/bits/mathinline.h
	(__m81_defun): Use __NTHNL to avoid errors with GCC 6.

	* elf/tst-env-setuid-tunables.c: Include config.h with _LIBC
	defined, for HAVE_TUNABLES.
	* inet/tst-checks-posix.c: No need to define _ISOMAC.
	* intl/tst-gettext2.c: Provide own definition of N_.
	* math/test-signgam-finite-c99.c: No need to define _ISOMAC.
	* math/test-signgam-main.c: No need to define _ISOMAC.
	* stdlib/tst-strtod.c: Convert to test-driver. Split locale_test to...
	* stdlib/tst-strtod1i.c: ...this new file.
	* stdlib/tst-strtod5.c: Convert to test-driver and add copyright notice.
        Split tests of __strtod_internal to...
	* stdlib/tst-strtod5i.c: ...this new file.
	* string/test-string.h: Include stdint.h. Duplicate definition of
	inhibit_loop_to_libcall here (from libc-symbols.h).
	* string/test-strstr.c: Provide dummy definition of
	libc_hidden_builtin_def when including strstr.c.
	* sysdeps/ia64/fpu/libm-symbols.h: Suppress entire file in _ISOMAC
	mode; no need to test __STRICT_ANSI__ nor __cplusplus as well.
	* sysdeps/x86_64/fpu/math-tests-arch.h: Include cpu-features.h.
	Don't include init-arch.h.
	* sysdeps/x86_64/multiarch/test-multiarch.h: Include cpu-features.h.
	Don't include init-arch.h.

	* elf/Makefile: Move tst-ptrguard1-static, tst-stackguard1-static,
	tst-tls1-static, tst-tls2-static, tst-tls3-static, loadtest,
	unload, unload2, circleload1, neededtest, neededtest2,
	neededtest3, neededtest4, tst-tls1, tst-tls2, tst-tls3,
	tst-tls6, tst-tls7, tst-tls8, tst-dlmopen2, tst-ptrguard1,
	tst-stackguard1, tst-_dl_addr_inside_object, and all of the
	ifunc tests to tests-internal.
	Don't add $(modules-names) to test-extras.
	* inet/Makefile: Move tst-inet6_scopeid_pton to tests-internal.
	Add tst-deadline to tests-static-internal.
	* malloc/Makefile: Move tst-mallocstate and tst-scratch_buffer to
	tests-internal.
	* misc/Makefile: Move tst-atomic and tst-atomic-long to tests-internal.
	* nptl/Makefile: Move tst-typesizes, tst-rwlock19, tst-sem11,
	tst-sem12, tst-sem13, tst-barrier5, tst-signal7, tst-tls3,
	tst-tls3-malloc, tst-tls5, tst-stackguard1, tst-sem11-static,
	tst-sem12-static, and tst-stackguard1-static to tests-internal.
        Link tests-internal with libpthread also.
	Don't add $(modules-names) to test-extras.
	* nss/Makefile: Move tst-field to tests-internal.
	* posix/Makefile: Move bug-regex5, bug-regex20, bug-regex33,
	tst-rfc3484, tst-rfc3484-2, and tst-rfc3484-3 to tests-internal.
	* stdlib/Makefile: Move tst-strtod1i, tst-strtod3, tst-strtod4,
	tst-strtod5i, tst-tls-atexit, and tst-tls-atexit-nodelete to
	tests-internal.
        * sunrpc/Makefile: Move tst-svc_register to tests-internal.
	* sysdeps/powerpc/Makefile: Move test-get_hwcap and
	test-get_hwcap-static to tests-internal.
	* sysdeps/unix/sysv/linux/Makefile: Move tst-setgetname to
	tests-internal.
	* sysdeps/x86_64/fpu/Makefile: Add all libmvec test modules to
	modules-names-tests.
2017-05-11 19:27:59 -04:00
Zack Weinberg 1711991592 Remove _IO_MTSAFE_IO from public headers.
_IO_MTSAFE_IO controls whether stdio is *built* with support for
multithreading.  In the distant past it might also have worked as a
feature selection macro, allowing library *users* to select
thread-safe or lock-free stdio at application build time, I haven't
done the archaeology.  Nowadays, defining _IO_MTSAFE_IO while using
the installed headers, or in _ISOMAC mode, will cause libio.h to throw
syntax errors.

This patch removes _IO_MTSAFE_IO from the public headers
(specifically, from libio/libio.h).  The most important thing it
controlled in there was whether libio.h defines _IO_lock_t itself or
expects stdio-lock.h to have done it, and we do still need a
inter-header communication macro for that, because stdio-lock.h can
only define _IO_lock_t as a typedef.  I've invented
_IO_lock_t_defined, which is defined by both versions of stdio-lock.h.

_IO_MTSAFE_IO also controlled the definitions of a handful of macros
that _might_ count as part of the public libio.h interface.  They are
now unconditionally given their non-_IO_MTSAFE_IO definition in
libio/libio.h, and include/libio.h redefines them with the
_IO_MTSAFE_IO definition.  This should minimize the odds of breaking
old software that actually uses those macros.

I suspect that this entire mechanism is vestigial, and that glibc
won't build anymore if you *don't* define _IO_MTSAFE_IO, but that's
another patchset.  The bulk of libio.h is internal-use-only stuff that
no longer makes sense to expose (libstdc++ gave up on making a FILE
the same object as a C++ filebuf *decades* ago) but that, too, is
another patchset.

	* libio/libio.h: Condition dummy definition of _IO_lock_t on
	_IO_lock_t_defined, not _IO_MTSAFE_IO. Unconditionally use the
	non-_IO_MTSAFE_IO definitions for _IO_peekc, _IO_flockfile,
	_IO_funlockfile, and _IO_ftrylockfile.  Only define
	_IO_cleanup_region_start and _IO_cleanup_region_end if not
	already defined.
	* include/libio.h: If _IO_MTSAFE_IO is defined, redefine
        _IO_peekc, _IO_flockfile, _IO_funlockfile, and _IO_ftrylockfile
        appropriately.
	* sysdeps/generic/stdio-lock.h, sysdeps/nptl/stdio-lock.h:
	Define _IO_lock_t_defined after defining _IO_lock_t.
2017-05-11 19:14:11 -04:00
Adhemerval Zanella 31073a53d8 powerpc: Fix signal handling in backtrace
Now with read consolidation which uses SYSCALL_CANCEL macro, a frame
pointer is created in the syscall code and this makes the powerpc
backtrace obtain a bogus entry for the signal handling patch.

It is because it does not setup the correct frame pointer register
(r1) based on the saved value from the kernel sigreturn.  It was not
failing because the syscall frame pointer register was the same one
for the next frame (the function that actually called the syscall).

This patch fixes it by setup the next stack frame using the saved
one by the kernel sigreturn.  It fixes tst-backtrace{5,6} from
the read consolidation patch.

Checked on powerpc-linux-gnu and powerpc64le-linux-gnu.

	* sysdeps/powerpc/powerpc32/backtrace.c (is_sigtramp_address): Use
	void* for argument type and use VDSO_SYMBOL macro.
	(is_sigtramp_address_rt): Likewise.
	(__backtrace): Setup expected frame pointer address for signal
	handling.
	* sysdeps/powerpc/powerpc64/backtrace.c (is_sigtramp_address): Use
	void* for argumetn type and use VSDO_SYMBOL macro.
	(__backtrace): Setup expected frame pointer address for signal
	handling.
2017-05-11 17:27:31 -03:00
Adhemerval Zanella 488e08b600 Consolidate Linux writev implementation
This patch consolidates the writev Linux syscall implementation on
sysdeps/unix/sysv/linux/writev.c.

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/writev.c: New file.
2017-05-11 17:27:31 -03:00
Adhemerval Zanella 679e979bf3 Consolidate Linux readv implementation
This patch consolidates the readv Linux syscall implementation on
sysdeps/unix/sysv/linux/readv.c.

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/readv.c: New file.
2017-05-11 17:27:31 -03:00
Adhemerval Zanella dfaaee33ba Consolidate Linux write syscall
This patch consolidates the write Linux syscall implementation on
sysdeps/unix/sysv/linux/write.c.

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

	* include/unistd.h (write): Add hidden proto.
	* io/Makefile (CFLAGS-write.c): New rule.
	* nptl/Makefile (CFLAGS-write.c): Likewise.
	* sysdeps/unix/sysv/linux/write.c: New file.
2017-05-11 17:27:30 -03:00
Adhemerval Zanella f6a191a6ee Consolidate Linux read syscall
This patch consolidates the read Linux syscall implementation on
sysdeps/unix/sysv/linux/read.c.  This leads to a different frame
pointer creation on some architectures:

  * It fixes BZ#21428 on aarch64, since now the returned address
    for the read syscall can be correctly found out by
    backtrace_symbols.

  * It makes tst-backtrace{5,6} fails on powerpc due an issue on
    its custom backtrace implementation.  It is fixed on subsequent
    patch from this set.

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

	[BZ #21428]
	* include/unistd.h (read): Add hidden proto.
	* io/Makefile (CFLAGS-read.c): New rule.
	* nptl/Makefile (CFLAGS-read.c): New rule.
	* sysdeps/unix/sysv/linux/read.c: New file.
2017-05-11 17:27:30 -03:00
Adhemerval Zanella cab6e5af9d Consolidate Linux creat implementation
This patch consolidates the creat Linux syscall implementation on
sysdeps/unix/sysv/linux/creat{64}.c.  The changes are:

  1. Remove creat{64} from auto-generation syscalls.list.
  2. Add a new creat{64}.c implementation.  For architectures that
     define __OFF_T_MATCHES_OFF64_T the default creat64 will create
     alias to required creat symbols.
  3. Use __NR_creat where possible, otherwise use internal open{64}
     call with expected flags.

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

	* io/Makefile (CFLAGS-creat.c): New rule.
	(CFLAGS-creat64.c): Likewise.
	* sysdeps/unix/sysv/linux/alpha/creat.c: Remove file.
	* sysdeps/unix/sysv/linux/generic/creat.c: Likewise.
	* sysdeps/unix/sysv/linux/wordsize-64/creat64.c: Likewise.
	* sysdeps/unix/sysv/linux/creat.c: New file.
	* sysdeps/unix/sysv/linux/creat64.c: Likewise.
	* sysdeps/unix/sysv/linux/syscalls.list: Remove create from
	auto-generated list.
	* sysdeps/unix/sysv/linux/wordsize-64/syscalls.list: Likewise.
2017-05-11 17:27:27 -03:00
Adhemerval Zanella b41152d716 Consolidate Linux open implementation
This patch consolidates the open Linux syscall implementation on
sysdeps/unix/sysv/linux/open{64}.c.  The changes are:

  1. Remove open{64} from auto-generation syscalls.list.
  2. Add a new open{64}.c implementation.  For architectures that
     define __OFF_T_MATCHES_OFF64_T the default open64 will create
     alias to required open symbols.
  3. Use __NR_openat as default syscall for open{64}.

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/generic/open.c: Remove file.
	* sysdeps/unix/sysv/linux/generic/open64.c: Likewise.
	* sysdeps/unix/sysv/linux/wordsize-64/open64.c: Likewise.
	* sysdeps/unix/sysv/linux/open.c: New file.
	* sysdeps/unix/sysv/linux/open64.c (__libc_open64): Use O_LARGEFILE
	only for __OFF_T_MATCHES_OFF64_T and add alias to open if the case.
	* sysdeps/unix/sysv/linux/wordsize-64/syscalls.list: Remove open
	from auto-generated list.
2017-05-11 15:49:10 -03:00
Adhemerval Zanella 0f01acb340 Consolidate Linux close syscall generation
This patch consolidates the close Linux syscall generation on
sysdeps/unix/sysv/linux/close.c.

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

	* nptl/Makefile (CFLAGS-close.c): New flag.
	* sysdeps/unix/sysv/linux/close.c: New file.
2017-05-11 15:49:10 -03:00
Joseph Myers 5df4854ed2 Condition some sys/ucontext.h contents on __USE_MISC (bug 21457).
Continuing the fixes for namespace issues arising from sys/ucontext.h,
this patch conditions various definitions, that are not needed for
defining mcontext_t / ucontext_t, on __USE_MISC, so they do not appear
in strict POSIX modes.

This patch is non-exhaustive; that is, it only conditions
straightforward cases and there may be more such definitions that can
be conditioned for these and other architectures, to be dealt with
later in separate patches.  Also, using __USE_MISC is the minimum
change for these definitions where they conflict with POSIX; some
headers already have __USE_GNU conditionals on similar definitions of
names for registers.  The patch specifically does not do anything with
definitions in bits/sigcontext.h, and nor does it condition any
inclusions of bits/sigcontext.h even where in fact that is not needed
on some architectures for the definitions of mcontext_t / ucontext_t.

As other namespace issues in these headers remain, this patch does not
fix bug 21457, nor allow any XFAILs to be removed.

Tested with build-many-glibcs.py.

	[BZ #21457]
	* sysdeps/arm/sys/ucontext.h (R0): Condition on [__USE_MISC].
	(R1): Likewise.
	(R2): Likewise.
	(R3): Likewise.
	(R4): Likewise.
	(R5): Likewise.
	(R6): Likewise.
	(R7): Likewise.
	(R8): Likewise.
	(R9): Likewise.
	(R10): Likewise.
	(R11): Likewise.
	(R12): Likewise.
	(R13): Likewise.
	(R14): Likewise.
	(R15): Likewise.
	* sysdeps/i386/sys/ucontext.h (REG_GS): Likewise.
	(REG_FS): Likewise.
	(REG_ES): Likewise.
	(REG_DS): Likewise.
	(REG_EDI): Likewise.
	(REG_ESI): Likewise.
	(REG_EBP): Likewise.
	(REG_ESP): Likewise.
	(REG_EBX): Likewise.
	(REG_EDX): Likewise.
	(REG_ECX): Likewise.
	(REG_EAX): Likewise.
	(REG_TRAPNO): Likewise.
	(REG_ERR): Likewise.
	(REG_EIP): Likewise.
	(REG_CS): Likewise.
	(REG_EFL): Likewise.
	(REG_UESP): Likewise.
	(REG_SS): Likewise.
	* sysdeps/m68k/sys/ucontext.h (R_D0): Likewise.
	(R_D1): Likewise.
	(R_D2): Likewise.
	(R_D3): Likewise.
	(R_D4): Likewise.
	(R_D5): Likewise.
	(R_D6): Likewise.
	(R_D7): Likewise.
	(R_A0): Likewise.
	(R_A1): Likewise.
	(R_A2): Likewise.
	(R_A3): Likewise.
	(R_A4): Likewise.
	(R_A5): Likewise.
	(R_A6): Likewise.
	(R_A7): Likewise.
	(R_SP): Likewise.
	(R_PC): Likewise.
	(R_PS): Likewise.
	(fpregset_t): Likewise.
	(MCONTEXT_VERSION): Likewise.
	* sysdeps/mips/sys/ucontext.h (CTX_R0): Likewise.
	(CTX_AT): Likewise.
	(CTX_V0): Likewise.
	(CTX_V1): Likewise.
	(CTX_A0): Likewise.
	(CTX_A1): Likewise.
	(CTX_A2): Likewise.
	(CTX_A3): Likewise.
	(CTX_T0): Likewise.
	(CTX_T1): Likewise.
	(CTX_T2): Likewise.
	(CTX_T3): Likewise.
	(CTX_T4): Likewise.
	(CTX_T5): Likewise.
	(CTX_T6): Likewise.
	(CTX_T7): Likewise.
	(CTX_S0): Likewise.
	(CTX_S1): Likewise.
	(CTX_S2): Likewise.
	(CTX_S3): Likewise.
	(CTX_S4): Likewise.
	(CTX_S5): Likewise.
	(CTX_S6): Likewise.
	(CTX_S7): Likewise.
	(CTX_T8): Likewise.
	(CTX_T9): Likewise.
	(CTX_K0): Likewise.
	(CTX_K1): Likewise.
	(CTX_GP): Likewise.
	(CTX_SP): Likewise.
	(CTX_S8): Likewise.
	(CTX_RA): Likewise.
	(CTX_MDLO): Likewise.
	(CTX_MDHI): Likewise.
	(CTX_CAUSE): Likewise.
	(CTX_EPC): Likewise.
	* sysdeps/unix/sysv/linux/aarch64/sys/ucontext.h: Condition
	inclusion of <sys/procfs.h> on [__USE_MISC].
	(greg_t): Condition on [__USE_MISC].
	(gregset_t): Likewise.
	(fpregset_t): Likewise.
	* sysdeps/unix/sysv/linux/arm/sys/ucontext.h (greg_t): Likewise.
	(NGREG): Likewise.
	(gregset_t): Likewise.
	(REG_R0): Likewise.
	(REG_R1): Likewise.
	(REG_R2): Likewise.
	(REG_R3): Likewise.
	(REG_R4): Likewise.
	(REG_R5): Likewise.
	(REG_R6): Likewise.
	(REG_R7): Likewise.
	(REG_R8): Likewise.
	(REG_R9): Likewise.
	(REG_R10): Likewise.
	(REG_R11): Likewise.
	(REG_R12): Likewise.
	(REG_R13): Likewise.
	(REG_R14): Likewise.
	(REG_R15): Likewise.
	(struct _libc_fpstate): Likewise.
	(fpregset_t): Likewise.
	* sysdeps/unix/sysv/linux/hppa/sys/ucontext.h (NGREG): Likewise.
	(NFPREG): Likewise.
	(gregset_t): Likewise.
	(fpregset_t): Likewise.
	* sysdeps/unix/sysv/linux/m68k/sys/ucontext.h (R_D0): Likewise.
	(R_D1): Likewise.
	(R_D2): Likewise.
	(R_D3): Likewise.
	(R_D4): Likewise.
	(R_D5): Likewise.
	(R_D6): Likewise.
	(R_D7): Likewise.
	(R_A0): Likewise.
	(R_A1): Likewise.
	(R_A2): Likewise.
	(R_A3): Likewise.
	(R_A4): Likewise.
	(R_A5): Likewise.
	(R_A6): Likewise.
	(R_A7): Likewise.
	(R_SP): Likewise.
	(R_PC): Likewise.
	(R_PS): Likewise.
	(fpregset_t): Likewise.
	(MCONTEXT_VERSION): Likewise.
	* sysdeps/unix/sysv/linux/nios2/sys/ucontext.h (MCONTEXT_VERSION):
	Likewise.
	* sysdeps/unix/sysv/linux/sh/sys/ucontext.h (REG_R0): Likewise.
	(REG_R1): Likewise.
	(REG_R2): Likewise.
	(REG_R3): Likewise.
	(REG_R4): Likewise.
	(REG_R5): Likewise.
	(REG_R6): Likewise.
	(REG_R7): Likewise.
	(REG_R8): Likewise.
	(REG_R9): Likewise.
	(REG_R10): Likewise.
	(REG_R11): Likewise.
	(REG_R12): Likewise.
	(REG_R13): Likewise.
	(REG_R14): Likewise.
	(REG_R15): Likewise.
	* sysdeps/unix/sysv/linux/tile/sys/ucontext.h: Condition inclusion
	of <arch/abi.h> on [__USE_MISC].
	(greg_t): Condition on [__USE_MISC].
	(NGREG): Likewise.
	(gregset_t): Likewise.
2017-05-11 14:15:26 +00:00
Adhemerval Zanella 0a19a91896 Remove wrong definitions from pthread header refactor
This patch removes wrong struct definition from eab380d (Move shared
pthread definitions to common headers) on ARM and hppa.

Checked on arm-linux-gnueabihf.

	* sysdeps/arm/nptl/bits/pthreadtypes-arch.h
	(__pthread_rwlock_arch_t): Remove __data definition.
	* sysdeps/hppa/nptl/bits/pthreadtypes-arch.h
	(__pthread_rwlock_arch_t): Likewise.
2017-05-11 10:46:03 -03:00
Florian Weimer 46ce8881ad getaddrinfo: Unconditionally use malloc for address list
getaddrinfo has to call malloc eventually anyway, so the complexity
of avoiding malloc calls is not worth potential savings.
2017-05-11 10:01:49 +02:00
Joseph Myers d08a482bc2 Remove MIPS32 accept4, recvmmsg, sendmmsg implementations.
MIPS32 has its own implementations of accept4, recvmmsg and sendmmsg
because at one point it needed to avoid socketcall being used for
those functions (MIPS32 has socketcall, but has never used it in
glibc, and so never had socket.S at the time when socketcall used such
a per-architecture file instead of C code).  The current code no
longer uses socketcall based on __NR_socketcall being defined, and the
syscalls are always present on MIPS for supported kernels so the
socketcall case in the code is dead for MIPS; this patch removes the
implementations that are, as Adhemerval noted, no longer needed.

Tested compilation for mips-linux-gnu with build-many-glibcs.py.

	* sysdeps/unix/sysv/linux/mips/mips32/accept4.c: Remove file.
	* sysdeps/unix/sysv/linux/mips/mips32/recvmmsg.c: Likewise.
	* sysdeps/unix/sysv/linux/mips/mips32/sendmmsg.c: Likewise.
2017-05-09 23:16:19 +00:00
Joseph Myers e3b0580d0d Simplify accept4, recvmmsg, sendmmsg code.
The accept4, recvmmsg and sendmmsg functions had macros
__ASSUME_*_SYSCALL_WITH_SOCKETCALL.  Before we could assume kernels
with the relevant functionality, these macros represented the
conditions under which, on a socketcall architecture, glibc could just
call the syscall unconditionally and not have to deal with socketcall
at all for those functions, because if the syscall didn't work for
them the socketcall call wouldn't either.

Now we can assume kernels with the relevant functionality, the only
question is whether we can assume the syscall is present; if not, we
are on a socketcall architecture and just use socketcall instead.
Thus, this patch removes the macros that are no longer necessary, and
simplifies the code for accept4, recvmmsg and sendmmsg to use the same
logic as the other C implementations of socket functions that may use
a syscall or socketcall depending on kernel support.

Tested for x86_64 and x86.

	* sysdeps/unix/sysv/linux/accept4.c (accept4): Use syscall if
	[__ASSUME_ACCEPT4_SYSCALL], otherwise socketcall.
	* sysdeps/unix/sysv/linux/recvmmsg.c (recvmmsg): Use syscall if
	[__ASSUME_RECVMMSG_SYSCALL], otherwise socketcall.
	* sysdeps/unix/sysv/linux/sendmmsg.c (__sendmmsg): Use syscall if
	[__ASSUME_SENDMMSG_SYSCALL], otherwise socketcall.
	* sysdeps/unix/sysv/linux/kernel-features.h
	(__ASSUME_ACCEPT4_SYSCALL): Move to general list of macros for
	socket syscalls.
	(__ASSUME_RECVMMSG_SYSCALL): Likewise.
	(__ASSUME_SENDMMSG_SYSCALL): Likewise.
	* sysdeps/unix/sysv/linux/i386/kernel-features.h
	(__ASSUME_RECVMMSG_SYSCALL_WITH_SOCKETCALL): Remove.
	(__ASSUME_SENDMMSG_SYSCALL_WITH_SOCKETCALL): Likewise.
	* sysdeps/unix/sysv/linux/microblaze/kernel-features.h
	(__ASSUME_RECVMMSG_SYSCALL_WITH_SOCKETCALL): Remove.
	* sysdeps/unix/sysv/linux/powerpc/kernel-features.h
	(__ASSUME_SENDMMSG_SYSCALL_WITH_SOCKETCALL): Likewise.
	* sysdeps/unix/sysv/linux/sh/kernel-features.h
	(__ASSUME_SENDMMSG_SYSCALL_WITH_SOCKETCALL): Likewise.
	* sysdeps/unix/sysv/linux/sparc/kernel-features.h
	(__ASSUME_ACCEPT4_SYSCALL_WITH_SOCKETCALL): Likewise.
	(__ASSUME_RECVMMSG_SYSCALL_WITH_SOCKETCALL): Likewise.
	(__ASSUME_SENDMMSG_SYSCALL_WITH_SOCKETCALL): Likewise.
2017-05-09 21:59:36 +00:00
Adhemerval Zanella eab380d8ec Move shared pthread definitions to common headers
This patch removes all the replicated pthread definition accross the
architectures and consolidates it on shared headers.  The new
organization is as follow:

  * Architecture specific definition (such as pthread types sizes) are
    place in the new pthreadtypes-arch.h header in arch specific path.

  * All shared structure definition are moved to a common NPTL header
    at sysdeps/nptl/bits/pthreadtypes.h (with now includes the arch
    specific one for internal definitions).

  * Also, for C11 future thread support, both mutex and condition
    definition are placed in a common header at
    sysdeps/nptl/bits/thread-shared-types.h.

It is also a refactor patch without expected functional changes.
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, 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).

	* posix/Makefile (headers): Add pthreadtypes-arch.h and
	thread-shared-types.h.
	* sysdeps/aarch64/nptl/bits/pthreadtypes-arch.h: New file: arch
	specific thread definition.
	* sysdeps/alpha/nptl/bits/pthreadtypes-arch.h: Likewise.
	* sysdeps/arm/nptl/bits/pthreadtypes-arch.h: Likewise.
	* sysdeps/hppa/nptl/bits/pthreadtypes-arch.h: Likewise.
	* sysdeps/ia64/nptl/bits/pthreadtypes-arch.h: Likewise.
	* sysdeps/m68k/nptl/bits/pthreadtypes-arch.h: Likewise.
	* sysdeps/microblaze/nptl/bits/pthreadtypes-arch.h: Likewise.
	* sysdeps/mips/nptl/bits/pthreadtypes-arch.h: Likewise.
	* sysdeps/nios2/nptl/bits/pthreadtypes-arch.h: Likewise.
	* sysdeps/powerpc/nptl/bits/pthreadtypes-arch.h: Likewise.
	* sysdeps/s390/nptl/bits/pthreadtypes-arch.h: Likewise.
	* sysdeps/sh/nptl/bits/pthreadtypes-arch.h: Likewise.
	* sysdeps/sparc/nptl/bits/pthreadtypes-arch.h: Likewise.
	* sysdeps/tile/nptl/bits/pthreadtypes-arch.h: Likewise.
	* sysdeps/x86/nptl/bits/pthreadtypes-arch.h: Likewise.
	* sysdeps/nptl/bits/thread-shared-types.h: New file: shared
	thread definition between POSIX and C11.
	* sysdeps/aarch64/nptl/bits/pthreadtypes.h.: Remove file.
	* sysdeps/alpha/nptl/bits/pthreadtypes.h: Likewise.
	* sysdeps/arm/nptl/bits/pthreadtypes.h: Likewise.
	* sysdeps/hppa/nptl/bits/pthreadtypes.h: Likewise.
	* sysdeps/m68k/nptl/bits/pthreadtypes.h: Likewise.
	* sysdeps/microblaze/nptl/bits/pthreadtypes.h: Likewise.
	* sysdeps/mips/nptl/bits/pthreadtypes.h: Likewise.
	* sysdeps/nios2/nptl/bits/pthreadtypes.h: Likewise.
	* sysdeps/ia64/nptl/bits/pthreadtypes.h: Likewise.
	* sysdeps/powerpc/nptl/bits/pthreadtypes.h: Likewise.
	* sysdeps/s390/nptl/bits/pthreadtypes.h: Likewise.
	* sysdeps/sh/nptl/bits/pthreadtypes.h: Likewise.
	* sysdeps/sparc/nptl/bits/pthreadtypes.h: Likewise.
	* sysdeps/tile/nptl/bits/pthreadtypes.h: Likewise.
	* sysdeps/x86/nptl/bits/pthreadtypes.h: Likewise.
	* sysdeps/nptl/bits/pthreadtypes.h: New file: common thread
	definitions shared across all architectures.
2017-05-09 17:49:17 -03:00
Joseph Myers 0cb5da5c09 Simplify sendmmsg code.
Now we can assume a kernel with sendmmsg support, this patch
simplifies the implementation to be similar to that for accept4:
either using socketcall or the syscall according to whether the
syscall is known to be available, without further fallback
implementations.  The __ASSUME_SENDMMSG macro is kept (now defined
unconditionally), since it's used in resolv/res_send.c.

Tested for x86_64 and x86.

	* sysdeps/unix/sysv/linux/kernel-features.h
	(__ASSUME_SENDMMSG_SYSCALL): Define unconditionally.
	(__ASSUME_SENDMMSG): Likewise.
	(__ASSUME_SENDMMSG_SOCKETCALL): Remove macro.
	* sysdeps/unix/sysv/linux/sendmmsg.c (__sendmmsg): Define using
	sendmmsg syscall if that can be assumed to be present, socketcall
	otherwise, with no fallback for runtime failure.
2017-05-09 20:01:52 +00:00
Joseph Myers 9a45f54310 Simplify recvmmsg code.
Now we can assume a kernel with recvmmsg support, this patch
simplifies the implementation to be similar to that for accept4:
either using socketcall or the syscall according to whether the
syscall is known to be available, without further fallback
implementations.

(In fact further simplification is possible, getting rid of the
__ASSUME_*_SYSCALL_WITH_SOCKETCALL macros now that the minimum kernel
is guaranteed support for all of accept4, recvmmsg, sendmmsg, whether
through syscalls or through socketcall.  I intend to do that for all
of accept4 / recvmmsg / sendmmsg together - so making their
implementations just like those for older socket functions - once the
basic cleanup for 3.2 minimum kernel is done for sendmmsg as well as
recvmmsg.)

Tested for x86_64 and x86.

	* sysdeps/unix/sysv/linux/kernel-features.h
	(__ASSUME_RECVMMSG_SYSCALL): Define unconditionally.
	(__ASSUME_RECVMMSG_SOCKETCALL): Remove macro.
	(__ASSUME_RECVMMSG): Likewise.
	* sysdeps/unix/sysv/linux/recvmmsg.c (recvmmsg): Define using
	recvmmsg syscall if it can be assumed to be present, socketcall
	otherwise, with no fallback for runtime failure.
2017-05-09 20:01:01 +00:00
Paul E. Murphy 26265c3bce float128: Add _Float128 make bits to libm.
This adds the appropriate common bits for a platform to
enable float128 and expose ABI.

	* math/Makefile:
	(type-float128-suffix): New variable
	(type-float128-routines): Likewise
	(type-float128-yes): Likewise
	(types): Append float128 if supported
	(types-basic): New variable to control the use of templates for
	float, double, and long double, but not for float128 or newer types.
	(type-basic-foreach): Likewise.

	* sysdeps/ieee754/float128/Makeconfig: New file.
	* sysdeps/ieee754/float128/Versions: New file.
2017-05-09 11:40:28 -03:00
Joseph Myers 695d7d138e Assume prlimit64 is available.
This patch makes sysdeps/unix/sysv/linux code assume the prlimit64
syscall is always available, given the minimum of a 3.2 kernel.

__ASSUME_PRLIMIT64, which in fact was no longer used, is removed.
Code conditional on __NR_prlimit64 being defined is made
unconditional.  Fallback code for the case where prlimit64 produces an
ENOSYS error is removed, substantially simplifying some functions.

Tested for x86_64 and x86.

	* sysdeps/unix/sysv/linux/kernel-features.h (__ASSUME_PRLIMIT64):
	Remove macro.
	* sysdeps/unix/sysv/linux/getrlimit64.c (__getrlimit64): Assume
	prlimit64 is always available and does not give an ENOSYS error.
	* sysdeps/unix/sysv/linux/prlimit.c [__NR_prlimit64]: Make code
	unconditional.
	[!__NR_prlimit64]: Remove conditional code.
	* sysdeps/unix/sysv/linux/setrlimit.c (__setrlimit): Assume
	prlimit64 is always available and does not give an ENOSYS error.
	* sysdeps/unix/sysv/linux/setrlimit64.c (__setrlimit64): Likewise.
2017-05-09 14:05:09 +00:00
Zack Weinberg 2bfdaeddaa Rename cppflags-iterator.mk to libof-iterator.mk, remove extra-modules.mk.
cppflags-iterator.mk no longer has anything to do with CPPFLAGS; all
it does is set libof-$(foo) for a list of files.  extra-modules.mk
does the same thing, but with a different input variable, and doesn't
let the caller control the module.  Therefore, this patch gives
cppflags-iterator.mk a better name, removes extra-modules.mk, and
updates all uses of both.

	* extra-modules.mk: Delete file.
	* cppflags-iterator.mk: Rename to ...
	* libof-iterator.mk: ...this.  Adjust comments.

	* Makerules, extra-lib.mk, benchtests/Makefile, elf/Makefile
	* elf/rtld-Rules, iconv/Makefile, locale/Makefile, malloc/Makefile
	* nscd/Makefile, sunrpc/Makefile, sysdeps/s390/Makefile:
	Use libof-iterator.mk instead of cppflags-iterator.mk or
	extra-modules.mk.

	* benchtests/strcoll-inputs/filelist#en_US.UTF-8: Remove
	extra-modules.mk and cppflags-iterator.mk, add libof-iterator.mk.
2017-05-09 07:06:29 -04:00
Stefan Liebler 61f4fa7fd7 S390: Regenerate ULPs
Updated ulps file - Needed if build with GCC 7.

ChangeLog:

	* sysdeps/s390/fpu/libm-test-ulps: Regenerated.
2017-05-09 09:18:09 +02:00
Joseph Myers 1721145f03 Remove __ASSUME_PROC_PID_TASK_COMM.
This patch removes the __ASSUME_PROC_PID_TASK_COMM macro, and
associated conditional code (in a testcase), now that 3.2 is the
global minimum Linux kernel version supported.

Tested for x86_64.

	* sysdeps/unix/sysv/linux/kernel-features.h
	(__ASSUME_PROC_PID_TASK_COMM): Remove macro.
	* sysdeps/unix/sysv/linux/tst-setgetname.c: Do not include
	<kernel-features.h>.
	(do_test) [!__ASSUME_PROC_PID_TASK_COMM]: Remove conditional code.
2017-05-08 16:44:54 +00:00
Joseph Myers 1278ed2c64 Remove __ASSUME_GETCPU_SYSCALL.
This patch removes the definition of __ASSUME_GETCPU_SYSCALL.  In fact
this macro is unused, probably since:

commit dd26c44403
Author: Adhemerval Zanella <adhemerval.zanella@linaro.com>
Date:   Wed Apr 22 14:21:39 2015 -0300

    Consolidate sched_getcpu

so it could have been removed even without the move to 3.2 as minimum
kernel version on x86_64.

Tested for x86_64.

	* sysdeps/unix/sysv/linux/x86_64/kernel-features.h
	(__ASSUME_GETCPU_SYSCALL): Remove macro.
2017-05-08 14:36:42 +00:00
Florian Weimer cd354a3849 Remove <sys/ultrasound.h>
This header was once used for constants related to the Gravis
Ultrasound sound card.
2017-05-08 14:59:21 +02:00
Joseph Myers 139ace9575 Require Linux kernel 3.2 or later on x86 / x86_64.
As per the recent discussion, this patch implements a requirement for
Linux 3.2 or later for x86 and x86_64.  This is only the initial
change to increase the configured minimum; it's expected that followup
patches would deal with associated removal of conditionals that are no
longer needed.  If we remove the start-up test on the kernel version,
of course the NEWS and README text should then be revised (to reflect
that this version is just one such that glibc does not intend to
include compatibility code for any older kernel version, rather than
older kernels necessarily failing to work or glibc necessarily having
compatibility code for newer interfaces).

The followups would be able to assume presence of getcpu (x86_64),
recvmmsg (not always through its own syscall, sometimes only through
socketcall), sendmmsg (likewise), /proc/$pid/task/$tid/comm, f_flags
from statfs, prlimit64.

Tested for x86_64 and x86.

	* sysdeps/unix/sysv/linux/i386/configure.ac (arch_minimum_kernel):
	Remove.
	* sysdeps/unix/sysv/linux/i386/configure: Regenerated.
	* sysdeps/unix/sysv/linux/x86_64/64/configure.ac
	(arch_minimum_kernel): Remove.
	* sysdeps/unix/sysv/linux/x86_64/64/configure: Regenerated.
	* README: Update statement about Linux kernel requirements.
2017-05-08 10:45:20 +00:00
Joseph Myers 176804300b Fix network headers stdint.h namespace (bug 21455).
conform/ namespace tests of arpa/inet.h, netdb.h and netinet/in.h fail
for UNIX98 and XPG42 because of inclusion of stdint.h, which defines
macros not permitted in those headers for those standards.  UNIX98
allows them to include inttypes.h, but (predating C99) has restricted
inttypes.h contents (not yet tested in the conform/ tests) not
including those macros; XPG4.2 has no such permission and no
inttypes.h / stdint.h at all.

This patch rearranges the headers to avoid this issue.  intN_t
definitions move to bits/stdint-intn.h, and uintN_t definitions to
bits/stdint-uintn.h.  (These are not bits/types/ headers because they
each define four types.  They are separate rather than just a single
header because sys/types.h defines intN_t but u_intN_t rather than
uintN_t - and while sys/types.h could define uintN_t because of the
POSIX reservation of *_t, existing practice there is largely to
condition types on appropriate feature test macros, and indeed there
is at least one open bug report (14553) about a type that's not
so-conditioned, so maybe types there should actually have conditions
added where appropriate.)  The affected network headers are then made
to include bits/stdint-uintn.h instead of stdint.h.  This allows six
XFAILs to be removed.

This doesn't do anything about inttypes.h defining more than it should
for UNIX98, but we don't have conformtest expectations for that case
at present (and my inclination is that a fix for that should be as
local as possible - affecting only inttypes.h, not stdint.h, only for
the case of __USE_UNIX98 && !__USE_ISOC99).

Tested for x86_64.

	[BZ #21455]
	* bits/stdint-intn.h: New file.
	* bits/stdint-uintn.h: Likewise.
	* stdlib/Makefile (headers): Add bits/stdint-intn.h and
	bits/stdint-uintn.h.
	* inet/netinet/in.h: Include <bits/stdint-uintn.h> instead of
	<stdint.h>.
	* posix/sys/types.h: Include <bits/stdint-intn.h>.
	(__int8_t_defined): Do not define here.
	(int8_t): Likewise.
	(int16_t): Likewise.
	(int32_t): Likewise.
	(int64_t): Likewise.
	[__GNUC_PREREQ (2, 7)] (__intN_t): Likewise.
	* resolv/netdb.h: Include <bits/stdint-uintn.h> instead of
	<stdint.h>.
	* include/netdb.h [_ISOMAC]: Do not include <stdint.h>.
	* sysdeps/generic/stdint.h: Include <bits/stdint-intn.h> and
	<bits/stdint-uintn.h>.
	(int8_t): Do not define here.
	(int16_t): Likewise.
	(int32_t): Likewise.
	(int64_t): Likewise.
	(uint8_t): Likewise.
	(uint16_t): Likewise.
	(uint32_t): Likewise.
	(uint64_t): Likewise.
	* conform/Makefile (test-xfail-XPG42/arpa/inet.h/conform): Remove
	variable.
	(test-xfail-XPG42/netdb.h/conform): Likewise.
	(test-xfail-XPG42/netinet/in.h/conform): Likewise.
	(test-xfail-UNIX98/arpa/inet.h/conform): Likewise.
	(test-xfail-UNIX98/netdb.h/conform): Likewise.
	(test-xfail-UNIX98/netinet/in.h/conform): Likewise.
2017-05-04 20:36:42 +00:00
Paul E. Murphy 593bf7189a ldbl-128: Use mathx_hidden_def inplace of hidden_def
This provides a extra macro expansion before invoking
the hidden_def macro.  This is necessary to build the
ldbl-128 files as float128 correctly.

	* sysdeps/generic/math_private.h:
	(mathx_hidden_def): New macro.
	* sysdeps/ieee754/ldbl-128/s_finitel.c: Replace hidden_def with
	the above.
	* sysdeps/ieee754/ldbl-128/s_isinfl.c: Likewise.
	* sysdeps/ieee754/ldbl-128/s_isnanl.c: Likewise.
2017-05-04 14:47:27 -03:00
Joseph Myers fd9f30f6f9 Use __glibc_reserved convention in mcontext, sigcontext (bug 21457).
This patch implements the most straightforward part of fixing
namespace issues for sys/ucontext.h and related headers: where fields
in sys/ucontext.h or bits/sigcontext.h are named "reserved", "padding"
or similar, they are renamed to use the __glibc_reserved* naming
convention.  It does not change fields with a leading underscore, or
even those with a prefix such as uc_ or sc_.  It only fixes a small
part of bug 21457, so no XFAILs are removed.

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

	[BZ #21457]
	* sysdeps/unix/sysv/linux/mips/sys/ucontext.h
	[_MIPS_SIM != _ABIO32] (mcontext_t): Rename field reserved to
	__glibc_reserved1.
	* sysdeps/unix/sysv/linux/x86/bits/sigcontext.h
	(struct _fpx_sw_bytes): Rename field padding to __glibc_reserved1.
	(struct _fpxreg): Likewise.
	[!__x86_64__] (struct _fpstate): Rename field reserved to
	__glibc_reserved1.  Rename field padding to __glibc_reserved2.
	[__x86_64__] (struct _fpstate): Rename field padding to
	__glibc_reserved1.
	(struct _xsave_hdr): Rename field reserved1 to __glibc_reserved1.
	Rename field reserved2 to __glibc_reserved2.
	* sysdeps/unix/sysv/linux/x86/sys/ucontext.h
	[__x86_64__] (struct _libc_fpxreg): Rename field padding to
	__glibc_reserved1.
	[__x86_64__] (struct _libc_fpstate): Rename field padding to
	__glibc_reserved1.
2017-05-04 11:26:33 +00:00
Rajalakshmi Srinivasaraghavan 808befbf9e powerpc: Fix strncat ifunc selection
Correct hwcap usage in strncat introduced by commit
249dcdb71b.
Tested on power7 and power8 systems
2017-05-04 12:35:56 +05:30
H.J. Lu 1432d38ea0 x86: Set dl_platform and dl_hwcap from CPU features [BZ #21391]
dl_platform and dl_hwcap are set from AT_PLATFORM and AT_HWCAP very
early during startup.  They are used by dynamic linker to determine
platform and build an array of hardware capability names, which are
added to search path when loading shared object.  dl_platform and
dl_hwcap are unused on x86-64.  On i386, i386, i486, i586 and i686
platforms were supported and only SSE2 capability was used.

On x86, usage of AT_PLATFORM and AT_HWCAP to determine platform and
processor capabilities is obsolete since all information is available
in dl_x86_cpu_features.  This patch sets dl_platform and dl_hwcap from
dl_x86_cpu_features in dynamic linker.  On i386, the available plaforms
are changed to i586 and i686 since i386 has been deprecated.  On x86-64,
the available plaforms are haswell, which is for Haswell class processors
with BMI1, BMI2, LZCNT, MOVBE, POPCNT, AVX2 and FMA, and xeon_phi, which
is for Xeon Phi class processors with AVX512F, AVX512CD, AVX512ER and
AVX512PF.  A capability, avx512_1, is also added to x86-64 for AVX512
ISAs: AVX512F, AVX512CD, AVX512BW, AVX512DQ and AVX512VL.

	[BZ #21391]
	* sysdeps/i386/dl-machine.h (dl_platform_init) [IS_IN (rtld)]:
	Only call init_cpu_features.
	[!IS_IN (rtld)]: Only set GLRO(dl_platform) to NULL if needed.
	* sysdeps/x86_64/dl-machine.h (dl_platform_init): Likewise.
	* sysdeps/i386/dl-procinfo.h: Removed.
	* sysdeps/unix/sysv/linux/i386/dl-procinfo.h: Don't include
	<sysdeps/i386/dl-procinfo.h> nor <ldsodefs.h>.  Include
	<sysdeps/x86/dl-procinfo.h>.
	(_dl_procinfo): Replace _DL_HWCAP_COUNT with 32.
	* sysdeps/unix/sysv/linux/x86_64/dl-procinfo.h [!IS_IN (ldconfig)]:
	Include <sysdeps/x86/dl-procinfo.h> instead of
	 <sysdeps/generic/dl-procinfo.h>.
	* sysdeps/x86/cpu-features.c: Include <dl-hwcap.h>.
	(init_cpu_features): Set dl_platform, dl_hwcap and dl_hwcap_mask.
	* sysdeps/x86/cpu-features.h (bit_cpu_LZCNT): New.
	(bit_cpu_MOVBE): Likewise.
	(bit_cpu_BMI1): Likewise.
	(bit_cpu_BMI2): Likewise.
	(index_cpu_BMI1): Likewise.
	(index_cpu_BMI2): Likewise.
	(index_cpu_LZCNT): Likewise.
	(index_cpu_MOVBE): Likewise.
	(index_cpu_POPCNT): Likewise.
	(reg_BMI1): Likewise.
	(reg_BMI2): Likewise.
	(reg_LZCNT): Likewise.
	(reg_MOVBE): Likewise.
	(reg_POPCNT): Likewise.
	* sysdeps/x86/dl-hwcap.h: New file.
	* sysdeps/x86/dl-procinfo.h: Likewise.
	* sysdeps/x86/dl-procinfo.c (_dl_x86_hwcap_flags): New.
	(_dl_x86_platforms): Likewise.
2017-05-03 13:44:35 -07:00
Adhemerval Zanella b62c381591 Consolidate Linux epoll_wait syscall
This patch consolidates the epoll_wait Linux syscall generation on
sysdeps/unix/sysv/linux/epoll_wait.c.  The implementation tries to
use __NR_epoll_wait if defined, otherwise calls epoll_pwait.

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/epoll_wait.c: New file.
	* sysdeps/unix/sysv/linux/generic/epoll_wait.c: Remove file.
	* sysdeps/unix/sysv/linux/syscalls.list: Remove epoll_wait from
	auto-generation list.
2017-05-03 10:36:43 -03:00
Adhemerval Zanella 26f28fd73d Consolidate Linux select implementation
This patch consolidates the select Linux syscall implementation on
sysdeps/unix/sysv/linux/select.c.  The changes are:

  1. Remove select from auto-generation syscalls.list on the architecture
     that uses __NR_select.
  2. Remove generic implementation add a default one that handle all
     current cases (with the expection of alpha)
     The new default implementation will either use __NR_select if
     available of fallback to __NR_pselect6 otherwise.
  3. Add a alpha outlier implementation which requires old compatibility
     symbols.

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/alpha/Makefile (sysdep_routines): Add
	osf_select.
	* sysdeps/unix/sysv/linux/alpha/select.c: New file.
	* sysdeps/unix/sysv/linux/alpha/syscalls.list: Remove select and
	osf_select from auto-generation list.
	* sysdeps/unix/sysv/linux/syscalls.list: Likewise.
	* sysdeps/unix/sysv/linux/sparc/sparc64/syscalls.list: Likewise.
	* sysdeps/unix/sysv/linux/generic/select.c: Remove file.
	* sysdeps/unix/sysv/linux/select.c: New file.
2017-05-03 10:36:36 -03:00
Adhemerval Zanella b5eede9730 Consolidate Linux poll implementation
This patch consolidates the poll Linux syscall implementation on
sysdeps/unix/sysv/linux/poll.c.  It basically removes poll from
auto-generation list and add a default implementation that either
call __NR_poll directly (if the kernel headers defines it) or
ppoll adjusting the timeout argument (as the generic implementation).

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/generic/poll.c: Remove file.
	* sysdeps/unix/sysv/linux/poll.c: New file.
	* sysdeps/unix/sysv/linux/syscalls.list: Remove poll from
	auto-generation list.
2017-05-03 10:36:01 -03:00
Joseph Myers 14ea415d04 Add HWCAP_ASIMDRDM from Linux 4.11 to AArch64 bits/hwcap.h.
This patch adds the HWCAP_ASIMDRDM macro from Linux 4.11 to the
AArch64 bits/hwcap.h.

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

	* sysdeps/unix/sysv/linux/aarch64/bits/hwcap.h (HWCAP_ASIMDRDM):
	New macro.
2017-05-03 11:04:07 +00:00
Vladimir Mezentsev b3d9c9a20c sparc: handle R_SPARC_DISP64 and R_SPARC_REGISTER relocs
The Studio compiler generates relocation types which are not supported
in glibc. Handle these relocs.

Tested in sparc64-linux-gnu. No regressions.

	BZ #21179]
	* sysdeps/sparc/sparc64/dl-machine.h: Handle R_SPARC_DISP64 and
	R_SPARC_REGISTER relocations.
2017-05-02 16:57:31 -03:00
Adhemerval Zanella 827b823783 posix: Fix internal p{read,write} plt usage
This patch adds internal alias for __pread, __pread64, and __pwrite
following the already in place one for __pwrite64.  This is not used
in any implementation but on microblaze on preadv/pwritev fallback
(since it does not define __ASSUME_PREADV).

In fact it was signaled by commit c35db50ff5 which update the expected
localptl.data for the architecture based on resulted value.  This patch
updates the plt for microblaze now that p{read,write}{64} are correctly
routed to use internal alias.

Checked on x86_64-linux-gnu and a build for all supported architectures
(no all variants although).

	* include/unistd.h (__pread): Add libc_hidden_proto.
	(__pread64): Likewise.
	(__pwrite): Likewise.
	* sysdeps/unix/sysv/linux/microblaze/localplt.data [libc.so]
	(__pread64): Remove.
	* sysdeps/unix/sysv/linux/pread.c (__pread64): Add libc_hidden_weak.
	* sysdeps/unix/sysv/linux/pread64.c (__pread64): Likewise.
	* sysdeps/unix/sysv/linux/pwrite.c (__pwrite): Likewise.
2017-05-02 14:57:40 -03:00
Tulio Magno Quites Machado Filho 24a10cfb3e powerpc: Update powerpc-fpu libm-test-ulps
* sysdeps/powerpc/fpu/libm-test-ulps: Update.
2017-05-02 13:40:11 -03:00
Joseph Myers 25e39b4229 Add TCP_FASTOPEN_CONNECT from Linux 4.11 to netinet/tcp.h.
This patch adds the TCP_FASTOPEN_CONNECT macro from Linux 4.11 to
sysdeps/gnu/netinet/tcp.h.

Tested for x86-64.

	* sysdeps/gnu/netinet/tcp.h (TCP_FASTOPEN_CONNECT): New macro.
2017-05-01 16:18:31 +00:00
Joseph Myers ef0e5f2f5c Add PF_SMC, AF_SMC from Linux 4.11 to bits/socket.h.
This patch adds the PF_SMC / AF_SMC macros from Linux 4.11 to
sysdeps/unix/sysv/linux/bits/socket.h.

Tested for x86_64.

	* sysdeps/unix/sysv/linux/bits/socket.h (PF_SMC): New macro.
	(PF_MAX): Set to 44.
	(AF_SMC): New macro.
2017-05-01 15:11:33 +00:00
Tulio Magno Quites Machado Filho c064f6a613 powerpc: Fix logbl on power7 [BZ# 21280]
1. Fix the results for negative subnormals by ignoring the signal when
    normalizing the value.
 2. Fix the output when the high part is a power of 2 and the low part
    is a nonzero number with opposite sign.  This fix is based on commit
    380bd0fd24.

After applying this patch, logbl() tests pass cleanly on POWER >= 7.

Tested on powerpc, powerpc64 and powerpc64le

	[BZ #21280]
	* sysdeps/powerpc/power7/fpu/s_logbl.c (__logbl): Ignore the
	signal of subnormals and adjust the exponent of power of 2 down
	when low part has opposite sign.
2017-04-28 19:45:52 -03:00
Paul E. Murphy 2f7f3cd8cd powerpc64le: Create divergent sysdep directory for powerpc64le.
float128 on powerpc64le requires the addition of the ieee754/float128
sysdep, whereas powerpc64 doesn't.  This requires creating a bunch of
submachine and cpu directories and Implies files which just point
towards their powerpc64 equivalent.

Tested on P7, P8, and generic powerpc64le targets with and without
multiarch.

	* sysdeps/powerpc/powerpc64le/Implies: New file.
	* sysdeps/powerpc/powerpc64le/fpu/Implies: New file.
	* sysdeps/powerpc/powerpc64le/fpu/multiarch/Implies: New file.
	* sysdeps/powerpc/powerpc64le/multiarch/Implies: New file.
	* sysdeps/powerpc/powerpc64le/power7/Implies: New file.
	* sysdeps/powerpc/powerpc64le/power7/fpu/Implies: New file.
	* sysdeps/powerpc/powerpc64le/power7/fpu/multiarch/Implies: New file.
	* sysdeps/powerpc/powerpc64le/power7/multiarch/Implies: New file.
	* sysdeps/powerpc/powerpc64le/power8/Implies: New file.
	* sysdeps/powerpc/powerpc64le/power8/fpu/Implies: New file.
	* sysdeps/powerpc/powerpc64le/power8/fpu/multiarch/Implies: New file.
	* sysdeps/powerpc/powerpc64le/power8/multiarch/Implies: New file.
	* sysdeps/powerpc/powerpc64le/power9/Implies: New file.
	* sysdeps/powerpc/powerpc64le/power9/fpu/Implies: New file.
	* sysdeps/powerpc/powerpc64le/power9/fpu/multiarch/Implies: New file.
	* sysdeps/powerpc/powerpc64le/power9/multiarch/Implies: New file.
	* sysdeps/powerpc/preconfigure: New file.
	* sysdeps/unix/sysv/linux/powerpc/powerpc64le/Implies: New file.
	* sysdeps/unix/sysv/linux/powerpc/powerpc64le/fpu/Implies: New file.
2017-04-28 14:17:57 -03:00
Uros Bizjak 1e1f44de64 Add earlyclobber to sqrtt/sqrtf insns.
When using software completions, we have to prevent assembler to match
input and output operands of sqrtt/sqrtf insn. Add earlyclobber to
output operand to avoid unwanted operand matching.

2017-04-14  Uros Bizjak  <ubizjak@gmail.com>

    * sysdeps/alpha/fpu/math_private.h (__ieee754_sqrt): Add
    earlyclobber to output operand of sqrt insn.
    (__ieee754_sqrtf): Ditto.
2017-04-26 04:21:59 -07:00
Joseph Myers 9fe3c80c7c Fix sys/socket.h namespace issues from sys/uio.h inclusion (bug 21426).
sys/socket.h includes sys/uio.h to get the definition of the iovec
structure.

POSIX allows sys/socket.h to make all sys/uio.h symbols visible.
However, all of sys/uio.h is XSI-shaded, so for non-XSI POSIX this
results in conformtest failures (for sys/socket.h and other headers
that include it):

    Namespace violation: "UIO_MAXIOV"
    Namespace violation: "readv"
    Namespace violation: "writev"

Now, there is some ambiguity in POSIX about what namespace
reservations apply in this case - see
http://austingroupbugs.net/view.php?id=1127 - but glibc convention
would still avoid declaring readv and writev, for example, for feature
test macros that don't include them (if only headers from the relevant
standard are included), even if such declarations are permitted, so
there is a bug here according to glibc conventions.

This patch moves the struct iovec definition to a new
bits/types/struct_iovec.h header and includes that from sys/socket.h
instead of including the whole of sys/uio.h.  This fixes the namespace
issue; however, three files in glibc that were relying on the implicit
inclusion needed to be updated to include sys/uio.h explicitly.  So
there is a question of whether sys/socket.h should continue to include
sys/uio.h under some conditions, such as __USE_XOPEN or __USE_MISC or
__USE_XOPEN || __USE_MISC, for greater compatibility with code that
(wrongly) expects this optional inclusion to be present there.  (I
think the three affected files in glibc should still have explicit
sys/uio.h inclusions added in any case, however.)

Tested for x86_64.

	[BZ #21426]
	* misc/bits/types/struct_iovec.h: New file.
	* misc/Makefile (headers): Add bits/types/struct_iovec.h.
	* include/bits/types/struct_iovec.h: New file.
	* bits/uio.h (struct iovec): Replace by inclusion of
	<bits/types/struct_iovec.h>.
	* sysdeps/unix/sysv/linux/bits/uio.h (struct iovec): Likewise.
	* socket/sys/socket.h: Include <bits/types/struct_iovec.h> instead
	of <sys/uio.h>.
	* nptl/tst-cancel4.c: Include <sys/uio.h>
	* posix/test-errno.c: Likewise.
	* support/resolv_test.c: Likewise.
	* conform/Makefile (test-xfail-POSIX2008/arpa/inet.h/conform):
	Remove.
	(test-xfail-POSIX2008/netdb.h/conform): Likewise.
	(test-xfail-POSIX2008/netinet/in.h/conform): Likewise.
	(test-xfail-POSIX2008/sys/socket.h/conform): Likewise.
2017-04-25 17:52:47 +00:00
Adhemerval Zanella 249548e476 posix: Remove ununsed posix_spawn internal assignment
The internal 'ret' variable in '__spawni_child' function is not
used after assignment in most cases.

Checked on x86_64-linux-gnu.

	* sysdeps/unix/sysv/linux/spawni.c (__spawni_child): Remove ununsed
	assignment.
2017-04-25 08:51:21 -03:00
Adhemerval Zanella daeb1fa2e1 [BZ 21340] add support for POSIX_SPAWN_SETSID
This patch adds support for the POSIX_SPAWN_SETSID flag.

It was recently accepted by the Austin Group:
http://austingroupbugs.net/view.php?id=1044

Checked on x86_64

	Daurnimator  <quae@daurnimator.com>
	Adhemerval Zanella  <adhemerval.zanella@linaro.org>

	[BZ #21340]
	* posix/Makefile (tests): Add tst-posix_spawn-setsid to list of tests.
	* posix/spawn.h: define POSIX_SPAWN_SETSID flag.
	* posix/spawnattr_setflags.c (ALL_FLAGS): Add POSIX_SPAWN_SETSID to
	valid flags.
	* posix/tst-posix_spawn-setsid.c: Add test for POSIX_SPAWN_SETSID.
	* sysdeps/mach/hurd/spawni.c (__spawni): Implementation of
	POSIX_SPAWN_SETSID.
	* sysdeps/posix/spawni.c (__spawni): Likewise.
	* sysdeps/unix/sysv/linux/spawni.c (__spawni_child): Likewise.
	* NEWS: Add note about POSIX_SPAWN_SETSID support.
2017-04-25 08:51:12 -03:00
Gabriel F. T. Gomes 9581e76dbb Macroize function declarations in math_private.h
This patch moves the declaration of many floating-point functions from
math_private.h to math_private_calls.h and macroize the declaration to
be dependent on floating-point type.  For each of float, double, and
long double, the new header file is included once.  This reduces the
amount of repetitive boilerplate that will be required when adding
float128 versions of these functions.

Tested for powerpc64le and s390x.

	* sysdeps/generic/math_private.h: Move the declaration of many
	functions to sysdeps/generic/math_private_calls.h.
	* sysdeps/generic/math_private_calls.h: New file with the
	declarations of the functions removed from math_private.h
	macroized by floating-point type.
2017-04-24 09:30:56 -03:00
Stefan Liebler 5ea9ce3749 S390: Move utf8-utf32-z9.c to multiarch folder and use s390_libc_ifunc_expr macro.
The utf8-utf32-z9.c iconv module is using ifunc and thus the ifunc part should
be in multiarch folder.  Otherwise ifunc is used even if you configure
with --disable-multi-arch.

This patch moves the ifunc resolvers to the new file
sysdeps/s390/multiarch/utf8-utf32-z9.c. The resolvers are now implemented
with s390_libc_ifunc_expr macro instead of using gcc attribute ifunc directly.

The ifunc versions are implemented in sysdeps/s390/utf8-utf32-z9.c.
Each version is only implemented if needed or supported.  Therefore there is
a block at beginning of the file which selects the versions which should be
defined depending on support for multiarch, vector-support and used minimum
architecture level.  This block defines HAVE_[FROM|TO]_[C|CU|VX] to 1 or 0.
The code below is rearranged and surrounded
by #if HAVE_[FROM|TO]_[C|CU|VX] == 1.  There is no functional change.

The cu instructions are z9 zarch instructions.  As the major distros are
already using the newer z196 as architecture level set, those instructions
can be used as fallback version instead of the c-code.  This behaviour is
decided at compile time via HAVE_S390_MIN_Z196_ZARCH_ASM_SUPPORT.

ChangeLog:

	* sysdeps/s390/multiarch/utf8-utf32-z9.c: New File.
	* sysdeps/s390/utf8-utf32-z9.c: Move ifunc resolvers to multiarch
	folder and define ifunc versions depending on HAVE_[FROM|TO]_[C|CU|VX].
	(HAVE_FROM_C, HAVE_FROM_CU, HAVE_FROM_VX, HAVE_TO_C, HAVE_TO_VX,
	FROM_LOOP_DEFAULT, FROM_LOOP_C, FROM_LOOP_CU, FROM_LOOP_VX,
	TO_LOOP_DEFAULT, TO_LOOP_C, TO_LOOP_VX): New Define.
2017-04-21 15:30:00 +02:00
Stefan Liebler 85286aaf1d S390: Move utf16-utf32-z9.c to multiarch folder and use s390_libc_ifunc_expr macro.
The utf16-utf32-z9.c iconv module is using ifunc and thus the ifunc part should
be in multiarch folder.  Otherwise ifunc is used even if you configure
with --disable-multi-arch.

This patch moves the ifunc resolvers to the new file
sysdeps/s390/multiarch/utf16-utf32-z9.c. The resolvers are now implemented
with s390_libc_ifunc_expr macro instead of using gcc attribute ifunc directly.

The ifunc versions are implemented in sysdeps/s390/utf16-utf32-z9.c.
Each version is only implemented if needed or supported.  Therefore there is
a block at beginning of the file which selects the versions which should be
defined depending on support for multiarch, vector-support and used minimum
architecture level.  This block defines HAVE_[FROM|TO]_[C|VX] to 1 or 0.
The code below is rearranged and surrounded
by #if HAVE_[FROM|TO]_[C|VX] == 1.  There is no functional change.

ChangeLog:

	* sysdeps/s390/multiarch/utf16-utf32-z9.c: New File.
	* sysdeps/s390/utf16-utf32-z9.c: Move ifunc resolvers to multiarch
	folder and define ifunc versions depending on HAVE_[FROM|TO]_[C|VX].
	(HAVE_FROM_C, HAVE_FROM_VX, HAVE_TO_C, HAVE_TO_VX, FROM_LOOP_DEFAULT,
	FROM_LOOP_C, FROM_LOOP_VX, TO_LOOP_DEFAULT, TO_LOOP_C, TO_LOOP_VX):
	New Define.
2017-04-21 15:30:00 +02:00
Stefan Liebler df6cc7ee3b S390: Move utf8-utf16-z9.c to multiarch folder and use s390_libc_ifunc_expr macro.
The utf8-utf16-z9.c iconv module is using ifunc and thus the ifunc part should
be in multiarch folder.  Otherwise ifunc is used even if you configure
with --disable-multi-arch.

This patch moves the ifunc resolvers to the new file
sysdeps/s390/multiarch/utf8-utf16-z9.c. The resolvers are now implemented
with s390_libc_ifunc_expr macro instead of using gcc attribute ifunc directly.

The ifunc versions are implemented in sysdeps/s390/utf8-utf16-z9.c.
Each version is only implemented if needed or supported.  Therefore there is
a block at beginning of the file which selects the versions which should be
defined depending on support for multiarch, vector-support and used minimum
architecture level.  This block defines HAVE_[FROM|TO]_[C|CU|VX] to 1 or 0.
The code below is rearranged and surrounded
by #if HAVE_[FROM|TO]_[C|CU|VX] == 1.  There is no functional change.

The cu instructions are z9 zarch instructions.  As the major distros are
already using the newer z196 as architecture level set, those instructions
can be used as fallback version instead of the c-code.  This behaviour is
decided at compile time via HAVE_S390_MIN_Z196_ZARCH_ASM_SUPPORT.

ChangeLog:

	* sysdeps/s390/multiarch/utf8-utf16-z9.c: New File.
	* sysdeps/s390/utf8-utf16-z9.c: Move ifunc resolvers to multiarch
	folder and define ifunc versions depending on HAVE_[FROM|TO]_[C|CU|VX].
	(HAVE_FROM_C, HAVE_FROM_CU, HAVE_FROM_VX, HAVE_TO_C, HAVE_TO_VX,
	FROM_LOOP_DEFAULT, FROM_LOOP_C, FROM_LOOP_CU, FROM_LOOP_VX,
	TO_LOOP_DEFAULT, TO_LOOP_C, TO_LOOP_VX): New Define.
2017-04-21 15:30:00 +02:00
Stefan Liebler 51213e2b8d S390: Use new s390_libc_ifunc_expr macro in s390 8bit-generic.c.
This patch adds s390_libc_ifunc_expr macro which uses the __ifunc base macro
in include/libc-symbols.h and lets the user define a generic expression to
choose the correct ifunc variant.  Furthermore as the base macro is used,
the ifunc resolver functions are now also using inhibit_stack_protector.
S390 needs its own version due to the hwcap argument of the ifunc resolver.

This new macro is now used in iconv code in 8bit-generic.c instead of using
gcc attribute ifunc directly.

ChangeLog:

	* sysdeps/s390/multiarch/ifunc-resolve.h
	(s390_libc_ifunc_expr_init, s390_libc_ifunc_expr): New Define.
	* sysdeps/s390/multiarch/8bit-generic.c
	(__to_generic, __from_generic): Use s390_libc_ifunc_expr to
	define ifunc resolvers.
2017-04-21 15:30:00 +02:00
Florian Weimer 2f83a7294d Create more sockets with SOCK_CLOEXEC [BZ #15722] 2017-04-19 07:45:04 +02:00
Florian Weimer e92030239a Assume that accept4 is always available and works
Simplify the Linux accept4 implementation based on the assumption
that it is available in some way.  __ASSUME_ACCEPT4_SOCKETCALL was
previously unused, so remove it.

For ia64, the accept4 system call (and socket call) were backported
in kernel version 3.2.18.  Reflect this in the installation
instructions.
2017-04-19 07:44:48 +02:00
Joseph Myers 2288c2674d Fix bits/socket.h IOC* namespace issues (bug 21267).
sysdeps/unix/sysv/linux/bits/socket.h includes asm/socket.h.  That
includes asm/sockios.h, which on MIPS includes asm/ioctl.h, resulting
in namespace violations from IOC* macros.

bits/socket.h already has code to handle asm/socket.h unconditionally
defining macros that are only wanted for __USE_MISC.  This patch
extends it to handle the IOC* macros as well (always undefining them
if not defined when bits/socket.h was included, as I don't think they
are part of the intended API even for __USE_MISC).

It's possible there should also be a kernel fix - it's not clear to me
that IOC* belong in the uapi headers, and even if they do they might
best be split out into another header to avoid getting defined by this
particular path.  But since glibc needs to deal with existing kernel
headers, it also seems appropriate to extend the existing workaround
to these macros.

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

	[BZ #21267]
	* sysdeps/unix/sysv/linux/bits/socket.h (IOCSIZE_MASK): Undefine
	if defined by <asm/socket.h> and not previously defined.
	(IOCSIZE_SHIFT): Likewise.
	(IOC_IN): Likewise.
	(IOC_INOUT): Likewise.
	(IOC_OUT): Likewise.
2017-04-18 21:22:51 +00:00
H.J. Lu 4cb334c4d6 x86: Use AVX2 memcpy/memset on Skylake server [BZ #21396]
On Skylake server, AVX512 load/store instructions in memcpy/memset may
lead to lower CPU turbo frequency in certain situations.  Use of AVX2
in memcpy/memset has been observed to have improved overall performance
in many workloads due to the higher frequency.

Since AVX512ER is unique to Xeon Phi, this patch sets Prefer_No_AVX512
if AVX512ER isn't available so that AVX2 versions of memcpy/memset are
used on Skylake server.

	[BZ #21396]
	* sysdeps/x86/cpu-features.c (init_cpu_features): Set
	Prefer_No_AVX512 if AVX512ER isn't available.
	* sysdeps/x86/cpu-features.h (bit_arch_Prefer_No_AVX512): New.
	(index_arch_Prefer_No_AVX512): Likewise.
	* sysdeps/x86_64/multiarch/memcpy.S (__new_memcpy): Don't use
	AVX512 version if Prefer_No_AVX512 is set.
	* sysdeps/x86_64/multiarch/memcpy_chk.S (__memcpy_chk):
	Likewise.
	* sysdeps/x86_64/multiarch/memmove.S (__libc_memmove): Likewise.
	* sysdeps/x86_64/multiarch/memmove_chk.S (__memmove_chk):
	Likewise.
	* sysdeps/x86_64/multiarch/mempcpy.S (__mempcpy): Likewise.
	* sysdeps/x86_64/multiarch/mempcpy_chk.S (__mempcpy_chk):
	Likewise.
	* sysdeps/x86_64/multiarch/memset.S (memset): Likewise.
	* sysdeps/x86_64/multiarch/memset_chk.S (__memset_chk):
	Likewise.
2017-04-18 14:01:45 -07:00
H.J. Lu 1c53cb49de x86: Set Prefer_No_VZEROUPPER if AVX512ER is available
AVX512ER won't be implemented in any Xeon processors and will be in
all Xeon Phi processors.  Don't check CPU model number when setting
Prefer_No_VZEROUPPER for Xeon Phi.  Instead, set Prefer_No_VZEROUPPER
if AVX512ER is available.  It works with current and future Xeon Phi
and non-Xeon Phi processors.

	* sysdeps/x86/cpu-features.c (init_cpu_features): Set
	Prefer_No_VZEROUPPER if AVX512ER is available.
	* sysdeps/x86/cpu-features.h
	(bit_cpu_AVX512PF): New.
	(bit_cpu_AVX512ER): Likewise.
	(bit_cpu_AVX512CD): Likewise.
	(bit_cpu_AVX512BW): Likewise.
	(bit_cpu_AVX512VL): Likewise.
	(index_cpu_AVX512PF): Likewise.
	(index_cpu_AVX512ER): Likewise.
	(index_cpu_AVX512CD): Likewise.
	(index_cpu_AVX512BW): Likewise.
	(index_cpu_AVX512VL): Likewise.
	(reg_AVX512PF): Likewise.
	(reg_AVX512ER): Likewise.
	(reg_AVX512CD): Likewise.
	(reg_AVX512BW): Likewise.
	(reg_AVX512VL): Likewise.
2017-04-18 08:27:32 -07:00
Florian Weimer cef9b65376 Assume that O_CLOEXEC is always defined and works 2017-04-18 14:56:51 +02:00
Florian Weimer b48061e1a5 Assume that dup3 is available 2017-04-18 14:42:19 +02:00
Florian Weimer 46d8874d5b Assume that pipe2 is always available
The Debian patches for Hurd (which are already required to build
glibc before this commit) contain an implementation of pipe2.
2017-04-18 14:09:01 +02:00
Rajalakshmi Srinivasaraghavan 6c6ab1fc49 powerpc64: strrchr optimization for power8
P7 code is used for <=32B strings and for > 32B vectorized loops are used.
This shows as an average 25% improvement depending on the position of search
character.  The performance is same for shorter strings.
Tested on ppc64 and ppc64le.
2017-04-18 11:28:56 +05:30
Rabin Vincent 2604882cef [BZ 21357] unwind-dw2-fde: Call free() outside of unwind mutex
__deregister_frame_info_bases() calls free() while holding a mutex which
is also used from _Unwind_Find_FDE().  This leads to a deadlock if
AddressSanitizer uses _Unwind_Backtrace() from its free()
implementation.

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

	[BZ #21357]
	* sysdeps/generic/unwind-dw2-fde.c (__deregister_frame_info_bases):
	Call free() outside of mutex.
2017-04-17 12:03:44 -03:00
Florian Weimer a12ae89f86 Assume that O_NOFOLLOW is always defined 2017-04-13 21:28:18 +02:00
Rajalakshmi Srinivasaraghavan 249dcdb71b powerpc: Optimized strncat for POWER8
With new optimized strnlen for POWER8 [1], this patch adds
strncat for power8 to make use of optimized strlen and strnlen.
This is faster than POWER7 current implementation for larger strings.

Tested on powerpc64 and powerpc64le.

[1] https://sourceware.org/ml/libc-alpha/2017-03/msg00491.html

	* sysdeps/powerpc/powerpc64/multiarch/Makefile (sysdep_routines): Add
	strncat-power8.
	* sysdeps/powerpc/powerpc64/multiarch/strncat.c (strncat): Add
	__strncat_power8 to ifunc list.
	* sysdeps/powerpc/powerpc64/multiarch/ifunc-impl-list.c
	(strncat): Add __strncat_power8 to list of strncat functions.
	* sysdeps/powerpc/powerpc64/multiarch/strncat-power8.c: New file.
2017-04-13 11:29:20 +05:30
Adhemerval Zanella 158d5fa0e1 Consolidate Linux mmap implementation (BZ#21270)
This patch consolidates all Linux mmap implementations on default
sysdeps/unix/sysv/linux/mmap{64}.c one.  To accomodate all required
architecture specific requeriments a new internal header is created
(mmap_internal.h) where each architecture add its specific code
requirements.  Currently only x86_64 (to define MMAP_PREPARE to add
MAP_32BITS), s390 (which have a different kernel ABI for mmap), m68k
(which have variable minimum page sizes), and MIPS n32 (which zero
extend the offset to handle negative one correctly) redefine the new
header.

The patch also fixes BZ#21270 where default mmap64 on architectures
which uses mmap2 silent truncates large offsets value (larger than
1 << (page shift + 8 * sizeof (off_t)) or 1<<44 on architectures with
4096 bytes page size).  The new consolidate implementation returns
EINVAL as allowed by POSIX.

It also adds a tests for on current tst-mmap-offset one.  I have run
a full make check on x86_64, x86_64-32, i686, aarch64, armhf, powerpc,
powerpc64le, sparc64, and sparcv9 without any regressions.  I also ran
some basic tests (tst-mmap-offset) on sh4, m68k, and on qemu simulated
MIPS32 and MIPS64.

	[BZ #21270]
	* posix/tst-mmap-offset.c (do_prepare): New function.
	(do_test): Rename to do_test_bz18877 and use FAIL_RET.
	(do_test_bz21270): New function.
	* sysdeps/unix/sysv/linux/aarch64/mmap.c: Remove file.
	* sysdeps/unix/sysv/linux/arm/mmap.c: Remove file.
	* sysdeps/unix/sysv/linux/generic/wordsize-32/mmap.c: Likewise.
	* sysdeps/unix/sysv/linux/hppa/mmap.c: Likewise.
	* sysdeps/unix/sysv/linux/i386/mmap.c: Likewise.
	* sysdeps/unix/sysv/linux/m68k/mmap.S: Likewise.
	* sysdeps/unix/sysv/linux/m68k/mmap64.c: Likewise.
	* sysdeps/unix/sysv/linux/microblaze/mmap.S: Likewise.
	* sysdeps/unix/sysv/linux/mips/mips32/mmap.c: Likewise.
	* sysdeps/unix/sysv/linux/mips/mips64/n32/mmap.c: Likewise.
	* sysdeps/unix/sysv/linux/mips/mips64/n64/mmap64.c: Likewise.
	* sysdeps/unix/sysv/linux/s390/s390-32/mmap.S: Likewise.
	* sysdeps/unix/sysv/linux/s390/s390-32/mmap64.S: Likewise.
	* sysdeps/unix/sysv/linux/s390/s390-64/mmap.S: Likewise.
	* sysdeps/unix/sysv/linux/wordsize-64/mmap.c: Likewise.
	* sysdeps/unix/sysv/linux/wordsize-64/mmap64.c: Likewise.
	* sysdeps/unix/sysv/linux/x86_64/64/mmap.c: Likewise.
	* sysdeps/unix/sysv/linux/mmap_internal.h: New file.
	* sysdeps/unix/sysv/linux/m68k/mmap_internal.h: Likewise.
	* sysdeps/unix/sysv/linux/mips/mips64/n32/mmap_internal.h: Likewise.
	* sysdeps/unix/sysv/linux/s390/mmap_internal.h: Likewise.
	* sysdeps/unix/sysv/linux/x86_64/64/mmap_internal.h: Likewise.
	* sysdeps/unix/sysv/linux/mips/mips64/n64/syscalls.list: Remove mmap
	from auto-generation list.
	* sysdeps/unix/sysv/linux/mips/mips64/n32/syscalls.list: Likewise.
	* sysdeps/unix/sysv/linux/wordsize-64/syscalls.list: Likewise.
	* sysdeps/unix/sysv/linux/mmap.c: New file.
	* sysdeps/unix/sysv/linux/mmap64.c (__mmap64): Add check for invalid
	offsets and support for mmap2 syscall.
2017-04-12 11:04:28 -03:00
Wainer dos Santos Moschetta b6a6622209 powerpc: refactor memcmp and memmove IFUNC.
Clean up the IFUNC implementations for powerpc in order to remove
unneeded macro definitions.

Tested on ppc64le with and without --disable-multi-arch flag.

	* sysdeps/powerpc/powerpc64/multiarch/memcmp-power4.S: Define the
	implementation-specific function name and remove unneeded
	macros definition.
	* sysdeps/powerpc/powerpc64/multiarch/memcmp-power7.S: Likewise.
	* sysdeps/powerpc/powerpc64/multiarch/memmove-power7.S: Likewise.
	* sysdeps/powerpc/powerpc64/power4/memcmp.S: Set a default function
	name if not defined and pass as parameter to macros accordingly.
	* sysdeps/powerpc/powerpc64/power7/memcmp.S: Likewise.
	* sysdeps/powerpc/powerpc64/power7/memmove.S: Likewise.
2017-04-11 17:13:56 -03:00
Wainer dos Santos Moschetta 72fd128a08 powerpc: refactor memcpy and mempcpy IFUNC.
Clean up the IFUNC implementations for powerpc in order to remove
unneeded macro definitions.

Tested on ppc64le with and without --disable-multi-arch flag.

	* sysdeps/powerpc/powerpc64/multiarch/memcpy-a2.S: Define the
	implementation-specific function name and remove unneeded
	macros definition.
	* sysdeps/powerpc/powerpc64/multiarch/memcpy-cell.S: Likewise.
	* sysdeps/powerpc/powerpc64/multiarch/memcpy-power4.S: Likewise.
	* sysdeps/powerpc/powerpc64/multiarch/memcpy-power6.S: Likewise.
	* sysdeps/powerpc/powerpc64/multiarch/memcpy-power7.S: Likewise.
	* sysdeps/powerpc/powerpc64/multiarch/memcpy-ppc64.S: Likewise.
	* sysdeps/powerpc/powerpc64/multiarch/mempcpy-power7.S: Likewise.
	* sysdeps/powerpc/powerpc64/a2/memcpy.S: Set a default function
	name if not defined and pass as parameter to macros accordingly.
	* sysdeps/powerpc/powerpc64/cell/memcpy.S: Likewise.
	* sysdeps/powerpc/powerpc64/memcpy.S: Likewise.
	* sysdeps/powerpc/powerpc64/power4/memcpy.S: Likewise.
	* sysdeps/powerpc/powerpc64/power6/memcpy.S: Likewise.
	* sysdeps/powerpc/powerpc64/power7/memcpy.S: Likewise.
	* sysdeps/powerpc/powerpc64/power7/mempcpy.S: Likewise.
2017-04-11 17:13:56 -03:00
Wainer dos Santos Moschetta ff06a55aef powerpc: refactor memchr, memrchr, and rawmemchr IFUNC.
Clean up the IFUNC implementations for powerpc in order to remove
unneeded macro definitions.

Tested on ppc64le with and without --disable-multi-arch flag.

	* sysdeps/powerpc/powerpc64/multiarch/memchr-power7.S: Define the
	implementation-specific function name and remove unneeded macros
	definition.
	* sysdeps/powerpc/powerpc64/multiarch/memrchr-power7.S: Likewise.
	* sysdeps/powerpc/powerpc64/multiarch/rawmemchr-power7.S: Likewise.
	* sysdeps/powerpc/powerpc64/power7/memchr.S: Set a default
	function name if not defined and pass as parameter to macros
	accordingly.
	* sysdeps/powerpc/powerpc64/power7/memrchr.S: Likewise.
	* sysdeps/powerpc/powerpc64/power7/rawmemchr.S: Likewise.
2017-04-11 17:13:55 -03:00
Wainer dos Santos Moschetta 18e0054bf7 powerpc: refactor memset IFUNC.
Clean up the IFUNC implementations for powerpc in order to remove
unneeded macro definitions.

Tested on ppc64le with and without --disable-multi-arch flag.

	* sysdeps/powerpc/powerpc64/multiarch/memset-power4.S: Define the
	implementation-specific function name and remove unneeded macros
	definition.
	* sysdeps/powerpc/powerpc64/multiarch/memset-power6.S: Likewise.
	* sysdeps/powerpc/powerpc64/multiarch/memset-power7.S: Likewise.
	* sysdeps/powerpc/powerpc64/multiarch/memset-power8.S: Likewise.
	* sysdeps/powerpc/powerpc64/multiarch/memset-ppc64.S: Likewise.
	* sysdeps/powerpc/powerpc64/memset.S: Set a default function name if
	not defined and pass as parameter to macros accordingly.
	* sysdeps/powerpc/powerpc64/power4/memset.S: Likewise.
	* sysdeps/powerpc/powerpc64/power6/memset.S: Likewise.
	* sysdeps/powerpc/powerpc64/power7/memset.S: Likewise.
	* sysdeps/powerpc/powerpc64/power8/memset.S: Likewise.
2017-04-11 17:13:55 -03:00
Wainer dos Santos Moschetta f0748b70a8 powerpc: refactor strcasestr and strstr IFUNC.
Clean up the IFUNC implementations for powerpc in order to remove
unneeded macro definitions.

Tested on ppc64le with and without --disable-multi-arch flag.

	* sysdeps/powerpc/powerpc64/multiarch/strcasestr-power8.S: Define the
	strcasestr implementation name and remove unneeded macros definition.
	* sysdeps/powerpc/powerpc64/multiarch/strstr-power7.S: Define
	strstr implementation name and remove unneeded macros definition.
	* sysdeps/powerpc/powerpc64/power7/strstr.S: Set a default function
	name if not defined and pass as parameter to macros accordingly.
	* sysdeps/powerpc/powerpc64/power8/strcasestr.S: Likewise.
2017-04-11 17:13:55 -03:00
Wainer dos Santos Moschetta 6d15a5c2e9 powerpc: refactor strchr, strchrnul, and strrchr IFUNC.
Clean up the IFUNC implementations for powerpc in order to remove
unneeded macro definitions.

Tested on ppc64le with and without --disable-multi-arch flag.

	* sysdeps/powerpc/powerpc64/multiarch/strchr-power7.S: Define the
	implementation-specific function name and remove unneeded macros
	definition.
	* sysdeps/powerpc/powerpc64/multiarch/strchr-power8.S: Likewise.
	* sysdeps/powerpc/powerpc64/multiarch/strchr-ppc64.S: Likewise.
	* sysdeps/powerpc/powerpc64/multiarch/strchrnul-power7.S: Likewise.
	* sysdeps/powerpc/powerpc64/multiarch/strchrnul-power8.S: Likewise.
	* sysdeps/powerpc/powerpc64/multiarch/strrchr-power7.S: Likewise.
	* sysdeps/powerpc/powerpc64/power7/strchr.S: Set a default
	function name if not defined and pass as parameter to macros
	accordingly.
	* sysdeps/powerpc/powerpc64/power7/strchrnul.S: Likewise.
	* sysdeps/powerpc/powerpc64/power7/strrchr.S: Likewise.
	* sysdeps/powerpc/powerpc64/power8/strchr.S: Likewise.
	* sysdeps/powerpc/powerpc64/strchr.S: Likewise.
2017-04-11 17:13:54 -03:00
Wainer dos Santos Moschetta 001649fd18 powerpc: refactor strnlen and strlen IFUNC.
Clean up the IFUNC implementations for powerpc in order to remove
unneeded macro definitions.

Tested on ppc64le with and without --disable-multi-arch flag.

	* sysdeps/powerpc/powerpc64/multiarch/strlen-power7.S: Define
	the strlen implementation name and remove unneeded macros definition.
	* sysdeps/powerpc/powerpc64/multiarch/strlen-power8.S: Likewise.
	* sysdeps/powerpc/powerpc64/multiarch/strlen-ppc64.S: Likewise.
	* sysdeps/powerpc/powerpc64/multiarch/strnlen-power7.S: Define
	the strnlen implementation name and remove unneeded macros definition.
	* sysdeps/powerpc/powerpc64/power7/strlen.S: Set a default function
	name if not defined and pass as parameter to macros accordingly.
	* sysdeps/powerpc/powerpc64/power7/strnlen.S: Likewise.
	* sysdeps/powerpc/powerpc64/power8/strlen.S: Likewise.
	* sysdeps/powerpc/powerpc64/strlen.S: Likewise.
2017-04-11 17:13:54 -03:00
Wainer dos Santos Moschetta 3bc426e156 powerpc: refactor strcasecmp, strcmp, and strncmp IFUNC.
Clean up the IFUNC implementations for powerpc in order to remove
unneeded macro definitions.

Tested on ppc64le with and without --disable-multi-arch flag.

	* sysdeps/powerpc/powerpc64/multiarch/strcasecmp_l-power7.S: Define
	the implementation-specific function name and remove unneeded
	macros definition.
	* sysdeps/powerpc/powerpc64/multiarch/strcmp-power7.S: Likewise.
	* sysdeps/powerpc/powerpc64/multiarch/strcmp-power8.S Likewise.
	* sysdeps/powerpc/powerpc64/multiarch/strcmp-power9.S: Likewise.
	* sysdeps/powerpc/powerpc64/multiarch/strcmp-ppc64.S: Likewise.
	* sysdeps/powerpc/powerpc64/multiarch/strncmp-power4.S: Likewise.
	* sysdeps/powerpc/powerpc64/multiarch/strncmp-power7.S: Likewise.
	* sysdeps/powerpc/powerpc64/multiarch/strncmp-power8.S: Likewise.
	* sysdeps/powerpc/powerpc64/multiarch/strncmp-power9.S: Likewise.
	* sysdeps/powerpc/powerpc64/multiarch/strncmp-ppc64.S: Likewise.
	* sysdeps/powerpc/powerpc64/power4/strncmp.S: Set a default function
	name if not defined and pass as parameter to macros accordingly.
	* sysdeps/powerpc/powerpc64/power7/strcmp.S: Likewise.
	* sysdeps/powerpc/powerpc64/power7/strncmp.S: Likewise.
	* sysdeps/powerpc/powerpc64/power8/strcmp.S: Likewise.
	* sysdeps/powerpc/powerpc64/power8/strncmp.S: Likewise.
	* sysdeps/powerpc/powerpc64/power9/strcmp.S: Likewise.
	* sysdeps/powerpc/powerpc64/power9/strncmp.S: Likewise.
	* sysdeps/powerpc/powerpc64/strcmp.S: Likewise.
	* sysdeps/powerpc/powerpc64/strncmp.S: Likewise.
2017-04-11 17:13:54 -03:00
Wainer dos Santos Moschetta dbcc7d0893 powerpc: refactor stpcpy, stpncpy, strcpy, and strncpy IFUNC.
Clean up the IFUNC implementations for powerpc in order to remove
unneeded macro definitions.

Tested on ppc64le with and without --disable-multi-arch flag.

	* sysdeps/powerpc/powerpc64/multiarch/stpcpy-power8.S: Define the
	implementation-specific function name and remove unneeded macros
	definition.
	* sysdeps/powerpc/powerpc64/multiarch/stpncpy-power7.S: Likewise.
	* sysdeps/powerpc/powerpc64/multiarch/stpncpy-power8.S: Likewise.
	* sysdeps/powerpc/powerpc64/multiarch/strcpy-power8.S: Likewise.
	* sysdeps/powerpc/powerpc64/multiarch/strncpy-power7.S: Likewise.
	* sysdeps/powerpc/powerpc64/multiarch/strncpy-power8.S: Likewise.
	* sysdeps/powerpc/powerpc64/power7/strncpy.S: Set a default
	function name if not defined.
	* sysdeps/powerpc/powerpc64/power8/strcpy.S: Likewise.
	* sysdeps/powerpc/powerpc64/power8/strncpy.S: Likewise.
2017-04-11 17:13:31 -03:00
Adhemerval Zanella 38efe8c5a5 Consolidate pthreadtype.h placementConsolidate pthreadtype.h placement
This patch moves all arch specific pthreadtypes.h to a similar path
for all architectures (sysdeps/unix/sysv/<arch>/bits).  No functional
or build change is expected.  The idea is mainly to organize the
header placement for all architectures.

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).

	* sysdeps/unix/sysv/linux/x86/Implies: New file.
	* sysdeps/unix/sysv/linux/alpha/bits/pthreadtypes.h: Move to ...
	* sysdeps/alpha/nptl/bits/pthreadtypes.h: ... here.
	* sysdeps/unix/sysv/linux/powerpc/bits/pthreadtypes.h: Move to ...
	* sysdeps/powerpc/nptl/bits/pthreadtypes.h: ... here.
	* sysdeps/x86/bits/pthreadtypes.h: Move to ...
	* sysdeps/x86/nptl/bits/pthreadtypes.h: ... here.
2017-04-10 17:33:10 -03:00
H.J. Lu fda19e0438 Add sysdeps/x86/dl-procinfo.c
Add sysdeps/x86/dl-procinfo.c for x86 version of processor capability
information to reduce duplication between i386 and x86_64 dl-procinfo.c.

	* sysdeps/i386/dl-procinfo.c: Include
	<sysdeps/x86/dl-procinfo.c>.
	* sysdeps/x86_64/dl-procinfo.c: Likewise.
	* sysdeps/x86/dl-procinfo.c: New file.
2017-04-10 12:01:45 -07:00
Gabriel F. T. Gomes 6d4adeb700 Remove unneeded declarations from math_private.h
The declarations of many functions in math_private.h are not required
since __MATHDECL and __MATHDECLX, in math.h, already provide the
declarations for these functions.  This patch removes the declarations
from math_private.h. It also adds the inclusion of math.h to the files
which depended on the declaration of functions in math_private.h.

Tested for powerpc64le and s390x.

	* sysdeps/generic/math_private.h: Remove declarations of
	many functions that are already declared in math.h.
	* sysdeps/ieee754/ldbl-128/e_logl.c: Include math.h to get the
	declaration for __frexpl.
	* sysdeps/ieee754/ldbl-128ibm/e_logl.c: Include math.h to get
	the declarations for __scalbnl and fabsl.
2017-04-10 12:20:47 -03:00
H.J. Lu bf7730194f Check if SSE is available with HAS_CPU_FEATURE
Similar to other CPU feature checks, check if SSE is available with
HAS_CPU_FEATURE.

	* sysdeps/i386/fpu/fclrexcpt.c (__feclearexcept): Use
	HAS_CPU_FEATURE to check for SSE.
	* sysdeps/i386/fpu/fedisblxcpt.c (fedisableexcept): Likewise.
	* sysdeps/i386/fpu/feenablxcpt.c (feenableexcept): Likewise.
	* sysdeps/i386/fpu/fegetenv.c (__fegetenv): Likewise.
	* sysdeps/i386/fpu/fegetmode.c (fegetmode): Likewise.
	* sysdeps/i386/fpu/feholdexcpt.c (__feholdexcept): Likewise.
	* sysdeps/i386/fpu/fesetenv.c (__fesetenv): Likewise.
	* sysdeps/i386/fpu/fesetmode.c (fesetmode): Likewise.
	* sysdeps/i386/fpu/fesetround.c (__fesetround): Likewise.
	* sysdeps/i386/fpu/feupdateenv.c (__feupdateenv): Likewise.
	* sysdeps/i386/fpu/fgetexcptflg.c (__fegetexceptflag): Likewise.
	* sysdeps/i386/fpu/fsetexcptflg.c (__fesetexceptflag): Likewise.
	* sysdeps/i386/fpu/ftestexcept.c (fetestexcept): Likewise.
	* sysdeps/i386/setfpucw.c (__setfpucw): Likewise.
	* sysdeps/x86/cpu-features.h (bit_cpu_SSE): New.
	(index_cpu_SSE): Likewise.
	(reg_SSE): Likewise.
2017-04-07 07:44:59 -07:00
Zack Weinberg bf079e19f5 getopt: remove USE_NONOPTION_FLAGS
glibc's implementation of getopt includes code to parse an environment
variable named _XXX_GNU_nonoption_argv_flags_ (where XXX is the
current process's PID in decimal); but all of it has been #ifdefed out
since 2001, with no official way to turn it back on.

According to commentary in our config.h.in, bash version 2.0 set this
environment variable to indicate argv elements that were the result of
glob expansion and therefore should not be treated as options, but the
feature was "disabled later" because "it caused problems".  According
to bash's CHANGES file, "later" was release 2.01; it gives no more
detail about what the problems were.

Version 2.0 of bash was released on the last day of 1996, and version
2.01 in June of 1997.  Twenty years later, I think it is safe to
assume that this environment variable isn't coming back.

	* config.h.in (USE_NONOPTION_FLAGS): Remove.
	* csu/init-first.c: Remove all #ifdef USE_NONOPTION_FLAGS blocks.
	* sysdeps/mach/hurd/i386/init-first.c: Likewise.
	* posix/getopt_int.h: Likewise.
	* posix/getopt.c: Likewise. Also remove SWAP_FLAGS and the
	__libc_argc and __libc_argv externs, which were only used by
	#ifdef USE_NONOPTION_FLAGS blocks.
	* posix/getopt_init.c: Remove file.
	* posix/Makefile (routines): Remove getopt_init.
	* include/getopt.h: Don't declare __getopt_initialize_environment.
	* manual/getopt.texi: Remove mention of USE_NONOPTION_FLAGS in
	a comment.
2017-04-07 07:45:53 -04:00
Adhemerval Zanella bdc543e338 sparc: Fix .udiv plt on libc
With the removal of divdi3 object from sparcv9-linux-gnu build, its
definition came from libgcc and its functions internall calls .udiv.
Since glibc also exports these symbols for compatibility reasons, it
will end up creating PLT calls internally in libc.so.

To avoid it, this patch uses the linker option --wrap to replace all
the internal libc.so .udiv calls to the wrapper __wrap_.udiv. Along
with strong alias in the udiv implementations, it makes linker do
local calls.

Checked on sparcv9-linux-gnu.

	* sysdeps/sparc/sparc32/Makefile (libc.so-gnulib): New rule.
	* sysdeps/sparc/sparc32/sparcv8/udiv.S (.udiv): Make a strong_alias
	to __wrap_.udiv.
	* sysdeps/sparc/sparc32/sparcv9/udiv.S (.udiv): Likewise.
	* sysdeps/sparc/sparc32/udiv.S (.udiv): Likewise.
2017-04-06 15:14:44 -03:00
Adhemerval Zanella db3d848e15 Build divdi3 only for architecture that required it
As noted in [1], divdi3 object is only exported in a handful ABIs
(i386, m68k, powerpc32, s390-32, and ia64), however it is built
for all current architectures regardless.

This patch refact the make rules for this object to so only the
aforementioned architectures that actually require it builds it.

Also, to avoid internal PLT calls to the exported symbol from the
module, glibc uses an internal header (symbol-hacks.h) which is
unrequired (and in fact breaks the build for architectures that
intend to get symbol definitions from libgcc.a).  The patch also
changes it to create its own header (divdi3-symbol-hacks.h) and
adjust the architectures that require it accordingly.

I checked the build/check (with run-built-tests=no) on the
following architectures (which I think must cover all supported
ABI/builds) using GCC 6.3:

aarch64-linux-gnu
alpha-linux-gnu
arm-linux-gnueabihf
hppa-linux-gnu
ia64-linux-gnu
m68k-linux-gnu
microblaze-linux-gnu
mips64-n32-linux-gnu
mips-linux-gnu
mips64-linux-gnu
nios2-linux-gnu
powerpc-linux-gnu
powerpc-linux-gnu-power4
powerpc64-linux-gnu
powerpc64le-linux-gnu
s390x-linux-gnu
s390-linux-gnu
sh4-linux-gnu
sh4-linux-gnu-soft
sparc64-linux-gnu
sparcv9-linux-gnu
tilegx-linux-gnu
tilegx-linux-gnu-32
tilepro-linux-gnu
x86_64-linux-gnu
x86_64-linux-gnu-x32
i686-linux-gnu

I only saw one regression on sparcv9-linux-gnu (extra PLT call to
.udiv) which I address in next patch in the set.  It also correctly
build SH with GCC 7.0.1 (without any regression from c89721e25d).

[1] https://sourceware.org/ml/libc-alpha/2017-03/msg00243.html

	* sysdeps/i386/symbol-hacks.h: New file.
	* sysdeps/m68k/symbol-hacks.h: New file.
	* sysdeps/powerpc/powerpc32/symbol-hacks.h: New file.
	* sysdeps/s390/s390-32/symbol-hacks.h: New file.
	* sysdeps/unix/sysv/linux/i386/Makefile
	[$(subdir) = csu] (sysdep_routines): New rule: divdi3 object.
	[$(subdir) = csu] (sysdep-only-routines): Likewise.
	[$(subdir) = csu] (CFLAGS-divdi3.c): Likewise.
	* sysdeps/unix/sysv/linux/m68k/Makefile
	[$(subdir) = csu] (sysdep_routines): Likewise.
	[$(subdir) = csu] (sysdep-only-routines): Likewise.
	[$(subdir) = csu] (CFLAGS-divdi3.c): Likewise.
	* sysdeps/unix/sysv/linux/powerpc/powerpc32/Makefile
	[$(subdir) = csu] (sysdep_routines): Likewise.
	[$(subdir) = csu] (sysdep-only-routines): Likewise.
	[$(subdir) = csu] (CFLAGS-divdi3.c): Likewise.
	* sysdeps/unix/sysv/linux/s390/s390-32/Makefile
	[$(subdir) = csu] (sysdep_routines): Likewise.
	[$(subdir) = csu] (sysdep-only-routines): Likewise.
	[$(subdir) = csu] (CFLAGS-divdi3.c): Likewise.
	* sysdeps/wordsize-32/Makefile: Remove file.
	* sysdeps/wordsize-32/symbol-hacks.h: Definitions move to ...
	* sysdeps/wordsize-32/divdi3-symbol-hacks.h: ... here.
2017-04-06 15:14:34 -03:00
Wainer dos Santos Moschetta 18b6e2c86c powerpc64: Add POWER8 strnlen
Added strnlen POWER8 otimized for long strings. It delivers
same performance as POWER7 implementation for short strings.

This takes advantage of reasonably performing unaligned loads
and bit permutes to check the first 1-16 bytes until
quadword aligned, then checks in 64 bytes strides until unsafe,
then 16 bytes, truncating the count if need be.

Likewise, the POWER7 code is recycled for less than 32 bytes strings.

Tested on ppc64 and ppc64le.

	* sysdeps/powerpc/powerpc64/multiarch/Makefile
	(sysdep_routines): Add strnlen-power8.
	* sysdeps/powerpc/powerpc64/multiarch/ifunc-impl-list.c
	(strnlen): Add __strnlen_power8 to list of strnlen functions.
	* sysdeps/powerpc/powerpc64/multiarch/strnlen-power8.S:
	New file.
	* sysdeps/powerpc/powerpc64/multiarch/strnlen.c
	(__strnlen): Add __strnlen_power8 to ifunc list.
	* sysdeps/powerpc/powerpc64/power8/strnlen.S: New file.
2017-04-05 10:26:58 -03:00
Adhemerval Zanella a358c80530 Remove CALL_THREAD_FCT macro
This patch removes CALL_THREAD_FCT macro usage and its defition for
x86.  For 32 bits it usage is only for force 16 stack alignment,
however stack is already explicit aligned in clone syscall.  For
64 bits and x32 it just a function call and there is no need to
code it with inline assembly.

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

	* nptl/pthread_create.c (START_THREAD_DEFN): Remove
	CALL_THREAD_FCT macro usage.
	* sysdeps/i386/nptl/tls.h (CALL_THREAD_FCT): Remove definition.
	* sysdeps/x86_64/nptl/tls.h (CALL_THREAD_FCT): Likewise.
	* sysdeps/x86_64/32/nptl/tls.h: Remove file.
2017-04-04 18:03:35 -03:00
Adhemerval Zanella 2e4cf77897 Remove __ASSUME_REQUEUE_PI
The new cond var implementation (ed19993b5b) removed all the
__ASSUME_{REQUEUE_PI,FUTEX_LOCK_PI} internal usage so there is no
need to keep defining it.  This patch removes all USE_REQUEUE_PI
and __ASSUME_REQUEUE_PI.  It is as follow up from BZ#18463.

Checked with a build for x86_64-linux-gnu, arm-linux-gnueabhf,
m68-linux-gnu, mips64-linux-gnu, and sparc64-linux-gnu.

	* nptl/pthreadP.h (USE_REQUEUE_PI): Remove ununsed macro.
	* sysdeps/unix/sysv/linux/arm/kernel-features.h
	(__ASSUME_REQUEUE_PI): Likewise.
	* sysdeps/unix/sysv/linux/kernel-features.h
	(__ASSUME_REQUEUE_PI): Likewise.
	* sysdeps/unix/sysv/linux/m68k/kernel-features.h
	(__ASSUME_REQUEUE_PI): Likewise.
	* sysdeps/unix/sysv/linux/mips/kernel-features.h
	(__ASSUME_REQUEUE_PI): Likewise.
	* sysdeps/unix/sysv/linux/sparc/kernel-features.h
	(__ASSUME_REQUEUE_PI): Likewise.
2017-04-04 18:02:02 -03:00
Stefan Liebler fce3da82e5 S390: Clobber also r14 in TLS_LD, TLS_GD macros on 31bit.
This patch also clobbers r14 in TLS_LD, TLS_GD macros on 31bit.
This ensures that r14 isn't used to save and restore r12 while
r14 is clobbered by the bas-instruction.

As note:
r12 can't be added to clobber list as gcc would fail with:
error: PIC register clobbered by ‘12’ in ‘asm’

For 64bit this fix was already done in 2004 in the
commit b80af23ac6.

ChangeLog:

	* sysdeps/s390/s390-32/tls-macros.h (TLS_LD, TLS_GD):
	Clobber also r14.
2017-04-04 13:16:28 +02:00
Mike Frysinger 21f042c804 posix_spawn: use a larger min stack for -fstack-check [BZ #21253]
When glibc is built with -fstack-check, trying to use posix_spawn can
lead to segfaults due to gcc internally probing stack memory too far.
The new spawn API will allocate a minimum of 1 page, but the stack
checking logic might probe a couple of pages.  When it tries to walk
them, everything falls apart.

The gcc internal docs [1] state the default interval checking is one
page.  Which means we need two pages (the current one, and the next
probed).  No target currently defines it larger.

Further, it mentions that the default minimum stack size needed to
recover from an overflow is 4/8KiB for sjlj or 8/12KiB for others.
But some Linux targets (like mips and ppc) go up to 16KiB (and some
non-Linux targets go up to 24KiB).

Let's create each child with a minimum of 32KiB slack space to support
them all, and give us future breathing room.

No test is added as existing ones crash.  Even a simple call is
enough to trigger the problem:
	char *argv[] = { "/bin/ls", NULL };
	posix_spawn(NULL, "/bin/ls", NULL, NULL, argv, NULL);

[1] https://gcc.gnu.org/onlinedocs/gcc-6.3.0/gccint/Stack-Checking.html
2017-04-03 15:15:41 -04:00
Adhemerval Zanella 2183741fdc Fix more test-errno issues
This patch fixes some test-errno-linux unexpected returns for the
tested syscalls on some older kernels (I saw it on a Linux 3.8 on
armv7l).  Basically:

   - inotify_add_watch: Linux v3.8 (676a0675c) removed the test to
     check at least one valid bit in flags (to return EINVAL).  It
     was later added back in v3.9 (04df32fa1).

   - quotactl: returns ENOSYS for kernels not configured with
     CONFIG_QUOTA.

Checked on x86_64-linux-gnu and armv7l-linux-gnueabihf.

	* sysdeps/unix/sysv/linux/test-errno-linux.c (do_test): Handle
	non expected inotify_add_watch and quotactl return.
2017-03-30 18:23:43 -03:00
Gabriel F. T. Gomes 10614335d1 Change return type in the declaration of __ieee754_rem_pio2l
The implementation of __ieee754_rem_pio2l in ldbl-128, ldbl-128ibm,
and ldbl-96 return the type int32_t, whereas math_private.h declares
it as returning int.  This patch changes the declaration to match the
declaration in thoses directories, as well as it changes the stub
implementation in math/e_rem_pio2l.c, similarly.

	* math/e_rem_pio2l.c (__ieee754_rem_pio2l): Change return type
	to int32_t.
	* sysdeps/generic/math_private.h: Declare __ieee754_rem_pio2l
	as returning int32_t.
2017-03-30 15:22:27 -03:00
Adhemerval Zanella 3abeeec5f4 Fix i686 memchr overflow calculation (BZ#21182)
This patch fixes the regression added by 23d2770 for final address
overflow calculation.  The subtraction of the considered size (16)
at line 120 is at wrong place, for sizes less than 16 subsequent
overflow check will not take in consideration an invalid size (since
the subtraction will be negative).  Also, the lea instruction also
does not raise the carry flag (CF) that is used in subsequent jbe
to check for overflow.

The fix is to follow x86_64 logic from 3daef2c where the overflow
is first check and a sub instruction is issued.  In case of resulting
negative size, CF will be set by the sub instruction and a NULL
result will be returned.  The patch also add similar tests reported
in bug report.

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

	* string/test-memchr.c (do_test): Add BZ#21182 checks for address
	near end of a page.
	* sysdeps/i386/i686/multiarch/memchr-sse2.S (__memchr): Fix
	overflow calculation.
2017-03-29 09:54:14 -03:00
Adhemerval Zanella dd5905de03 Consolidate set* Linux implementation
This patch consolidates the Linux setegid, seteuid, setgid, setgroups,
setregid, setresgid, setresuid, setreuid, and setuid implementation on
default sysdeps/unix/sysv/linux/set*.c implementation.  It basically
removes all the architecture define implementations and add support for
__NR_set*32 syscall on Linux default implementation.

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/setegid.c: Remove file.
	* sysdeps/unix/sysv/linux/arm/seteuid.c: Likewise.
	* sysdeps/unix/sysv/linux/arm/setgid.c: Likewise.
	* sysdeps/unix/sysv/linux/arm/setgroups.c: Likewise.
	* sysdeps/unix/sysv/linux/arm/setregid.c: Likewise.
	* sysdeps/unix/sysv/linux/arm/setresgid.c: Likewise.
	* sysdeps/unix/sysv/linux/arm/setresuid.c: Likewise.
	* sysdeps/unix/sysv/linux/arm/setreuid.c: Likewise.
	* sysdeps/unix/sysv/linux/arm/setuid.c: Likewise.
	* sysdeps/unix/sysv/linux/i386/setegid.c: Likewise.
	* sysdeps/unix/sysv/linux/i386/seteuid.c: Likewise.
	* sysdeps/unix/sysv/linux/i386/setgid.c: Likewise.
	* sysdeps/unix/sysv/linux/i386/setgroups.c: Likewise.
	* sysdeps/unix/sysv/linux/i386/setregid.c: Likewise.
	* sysdeps/unix/sysv/linux/i386/setresgid.c: Likewise.
	* sysdeps/unix/sysv/linux/i386/setresuid.c: Likewise.
	* sysdeps/unix/sysv/linux/i386/setreuid.c: Likewise.
	* sysdeps/unix/sysv/linux/i386/setuid.c: Likewise.
	* sysdeps/unix/sysv/linux/m68k/setegid.c: Likewise.
	* sysdeps/unix/sysv/linux/m68k/seteuid.c: Likewise.
	* sysdeps/unix/sysv/linux/m68k/setgid.c: Likewise.
	* sysdeps/unix/sysv/linux/m68k/setgroups.c: Likewise.
	* sysdeps/unix/sysv/linux/m68k/setregid.c: Likewise.
	* sysdeps/unix/sysv/linux/m68k/setresgid.c: Likewise.
	* sysdeps/unix/sysv/linux/m68k/setresuid.c: Likewise.
	* sysdeps/unix/sysv/linux/m68k/setreuid.c: Likewise.
	* sysdeps/unix/sysv/linux/m68k/setuid.c: Likewise.
	* sysdeps/unix/sysv/linux/microblaze/setgroups.c: Likewise.
	* sysdeps/unix/sysv/linux/s390/s390-32/setegid.c: Likewise.
	* sysdeps/unix/sysv/linux/s390/s390-32/seteuid.c: Likewise.
	* sysdeps/unix/sysv/linux/s390/s390-32/setgid.c: Likewise.
	* sysdeps/unix/sysv/linux/s390/s390-32/setgroups.c: Likewise.
	* sysdeps/unix/sysv/linux/s390/s390-32/setregid.c: Likewise.
	* sysdeps/unix/sysv/linux/s390/s390-32/setresgid.c: Likewise.
	* sysdeps/unix/sysv/linux/s390/s390-32/setresuid.c: Likewise.
	* sysdeps/unix/sysv/linux/s390/s390-32/setreuid.c: Likewise.
	* sysdeps/unix/sysv/linux/s390/s390-32/setuid.c: Likewise.
	* sysdeps/unix/sysv/linux/sh/setegid.c: Likewise.
	* sysdeps/unix/sysv/linux/sh/seteuid.c: Likewise.
	* sysdeps/unix/sysv/linux/sh/setgid.c: Likewise.
	* sysdeps/unix/sysv/linux/sh/setgroups.c: Likewise.
	* sysdeps/unix/sysv/linux/sh/setregid.c: Likewise.
	* sysdeps/unix/sysv/linux/sh/setresgid.c: Likewise.
	* sysdeps/unix/sysv/linux/sh/setresuid.c: Likewise.
	* sysdeps/unix/sysv/linux/sh/setreuid.c: Likewise.
	* sysdeps/unix/sysv/linux/sh/setuid.c: Likewise.
	* sysdeps/unix/sysv/linux/sparc/sparc32/setegid.c: Likewise.
	* sysdeps/unix/sysv/linux/sparc/sparc32/seteuid.c: Likewise.
	* sysdeps/unix/sysv/linux/sparc/sparc32/setgid.c: Likewise.
	* sysdeps/unix/sysv/linux/sparc/sparc32/setgroups.c: Likewise.
	* sysdeps/unix/sysv/linux/sparc/sparc32/setregid.c: Likewise.
	* sysdeps/unix/sysv/linux/sparc/sparc32/setresgid.c: Likewise.
	* sysdeps/unix/sysv/linux/sparc/sparc32/setresuid.c: Likewise.
	* sysdeps/unix/sysv/linux/sparc/sparc32/setreuid.c: Likewise.
	* sysdeps/unix/sysv/linux/sparc/sparc32/setuid.c: Likewise.
	* sysdeps/unix/sysv/linux/setegid.c (setegid): Use
	INLINE_SYSCALL_ERROR_RETURN_VALUE.
	* sysdeps/unix/sysv/linux/seteuid.c (seteuid): Likewise.
	* sysdeps/unix/sysv/linux/setgid.c (setgid): Use __NR_setgid32 if
	defined.
	* sysdeps/unix/sysv/linux/setgroups.c (setgroups): Use
	__NR_setgroups32 if defined.
	* sysdeps/unix/sysv/linux/setregid.c (__setregid): Use __NR_setregid32
	if defined.
	* sysdeps/unix/sysv/linux/setresgid.c (__setresgid): Use
	__NR_setresgid32 is defined.
	* sysdeps/unix/sysv/linux/setresuid.c (__setresuid): Use
	__NR_setresuid32 if defined.
	* sysdeps/unix/sysv/linux/setreuid.c (__setreuid): Use
	__NR_setreuid32 if defined.
	* sysdeps/unix/sysv/linux/setuid.c (__setuid): Use __NR_setuid32 if
	defined.
2017-03-28 12:29:27 -03:00
Joseph Myers 78c0581432 Define more termios.h macros unconditionally for alpha (bug 21277).
termios.h should define IUCLC for UNIX98 and older XSI standards.  The
sysdeps/unix/sysv/linux/alpha version defines it only if __USE_MISC,
so causing some conform/ tests to fail.

Other versions define it unconditionally (I* being a reserved
namespace for this header); the API should be consistent between
architectures in the absence of a clear reason for it to differ (and
given that a symbol is part of the API on two architectures, I don't
see any reason for the feature test macros required ever to differ
between those architectures), so this patch makes the alpha version
define it unconditionally as well.  Two non-POSIX macros alongside it,
IMAXBEL and IUTF8, are also defined unconditionally on other
architectures, so this patch makes them consistent by defining them
unconditionally on alpha as well.

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

	[BZ #21277]
	* sysdeps/unix/sysv/linux/alpha/bits/termios.h (IUCLC): Define
	unconditionally.
	(IMAXBEL): Likewise.
	(IUTF8): Likewise.
2017-03-27 15:07:38 +00:00
Szabolcs Nagy b737847f87 [AArch64] Update libm-test-ulps
* sysdeps/aarch64/libm-test-ulps: Update.
2017-03-27 12:02:47 +01:00
H.J. Lu c15f8eb50c x86-64: Improve branch predication in _dl_runtime_resolve_avx512_opt [BZ #21258]
On Skylake server, _dl_runtime_resolve_avx512_opt is used to preserve
the first 8 vector registers.  The code layout is

  if only %xmm0 - %xmm7 registers are used
     preserve %xmm0 - %xmm7 registers
  if only %ymm0 - %ymm7 registers are used
     preserve %ymm0 - %ymm7 registers
  preserve %zmm0 - %zmm7 registers

Branch predication always executes the fallthrough code path to preserve
%zmm0 - %zmm7 registers speculatively, even though only %xmm0 - %xmm7
registers are used.  This leads to lower CPU frequency on Skylake
server.  This patch changes the fallthrough code path to preserve
%xmm0 - %xmm7 registers instead:

  if whole %zmm0 - %zmm7 registers are used
    preserve %zmm0 - %zmm7 registers
  if only %ymm0 - %ymm7 registers are used
     preserve %ymm0 - %ymm7 registers
  preserve %xmm0 - %xmm7 registers

Tested on Skylake server.

	[BZ #21258]
	* sysdeps/x86_64/dl-trampoline.S (_dl_runtime_resolve_opt):
	Define only if _dl_runtime_resolve is defined to
	_dl_runtime_resolve_sse_vex.
	* sysdeps/x86_64/dl-trampoline.h (_dl_runtime_resolve_opt):
	Fallthrough to _dl_runtime_resolve_sse_vex.
2017-03-21 11:00:12 -07:00
Joseph Myers 76b2c32a16 conformtest: Add x32 XFAILs for mq_attr element types (bug 21279).
POSIX specifies long as the type of elements of struct mq_attr.  For
x32, they are __syscall_slong_t (i.e. long long).  This patch XFAILs
the corresponding tests for x32 in the conformtest expectations (the
bug should not be closed without an actual fix).

Tested with build-many-glibcs.py.

	[BZ #21279]
	* sysdeps/unix/sysv/linux/x86_64/x32/Makefile
	[$(subdir) = conform] (conformtest-xfail-conds): Update comment.
	* conform/data/mqueue.h-data (mq_attr.mq_flags): XFAIL for
	x86_64-x32-linux.
	(mq_attr.mq_maxmsg): Likewise.
	(mq_attr.mq_msgsize): Likewise.
	(mq_attr.mq_curmsgs): Likewise.
2017-03-20 21:30:28 +00:00
Joseph Myers 112039611c conformtest: Add mips XFAIL for struct stat st_rdev type (bug 21278).
MIPS o32 struct stat has the wrong type of st_rdev.  This patch XFAILs
that test in the conformtest expectations for this case (the bug
should not be closed without an actual fix, however).

Tested with build-many-glibcs.py.

	[BZ #21278]
	* sysdeps/unix/sysv/linux/mips/mips32/Makefile
	[$(subdir) = conform] (conformtest-xfail-conds): Update comment.
	* conform/data/sys/stat.h-data (stat.st_rdev): XFAIL for
	mips-o32-linux.
2017-03-20 21:28:16 +00:00
Joseph Myers ba7fe6906d Fix alpha termios.h NL2, NL3 namespace (bug 21268).
sysdeps/unix/sysv/linux/alpha/bits/termios.h defines NL2 and NL3 for
__USE_MISC || __USE_XOPEN.  These should only be defined for
__USE_MISC as they are not part of any standard namespace.  This patch
conditions them accordingly, matching the powerpc version of the
header (the only other one in glibc that defines these macros).

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

	[BZ #21268]
	* sysdeps/unix/sysv/linux/alpha/bits/termios.h (NL2): Define only
	if [__USE_MISC]
	(NL3): Likewise.
2017-03-20 17:32:19 +00:00
Mike Frysinger ddc3fb3334 posix_spawn: fix stack setup on ia64 [BZ #21275]
The ia64-specific clone2 call expects the base of the stack mapping and
the stack size as sep arguments, not an initial stack value as on other
stack-grows-down architectures.  Reuse the stack-grows-up macro so we
pass in the right stack base.

Reported-by: Matt Turner <mattst88@gentoo.org>
2017-03-20 10:42:34 -04:00
Christian Brauner 15e9a4f378 linux ttyname and ttyname_r: do not return wrong results
If a link (say /proc/self/fd/0) pointing to a device, say /dev/pts/2, in a
parent mount namespace is passed to ttyname, and a /dev/pts/2 exists (in a
different devpts) in the current namespace, then it returns /dev/pts/2.
But /dev/pts/2 is NOT the current tty, it is a different file and device.

Detect this case and return ENODEV.  Userspace can choose to take this as a hint
that the fd points to a tty device but to act on the fd rather than the link.

Signed-off-by: Serge Hallyn <serge@hallyn.com>
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2017-03-19 17:36:13 +00:00
Joseph Myers 345118d7f5 conformtest: XFAIL tv_nsec tests for x32 (bug 16437).
This patch XFAILs the conformtest tv_nsec tests for x32 so that the
incorrect type does not potentially hide other failures.  As this is
not a fix for the bug, it should remain open in Bugzilla.

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

	[BZ #16437]
	* sysdeps/unix/sysv/linux/x86_64/x32/Makefile
	[$(subdir) = conform] (conformtest-xfail-conds): New variable.
	* conform/data/signal.h-data (timespec.tv_nsec): XFAIL for
	x86_64-x32-linux.
	* conform/data/sys/select.h-data (timespec.tv_nsec): Likewise.
	* conform/data/sys/stat.h-data (timespec.tv_nsec): Likewise.
	* conform/data/time.h-data (timespec.tv_nsec): Likewise.
2017-03-18 00:24:13 +00:00