Commit Graph

5061 Commits

Author SHA1 Message Date
Florian Weimer 3a3fb75572 posix: New function posix_spawn_file_actions_addfchdir_np [BZ #17405]
Along with posix_spawn_file_actions_addchdir,
posix_spawn_file_actions_addfchdir is the subject of a change proposal
for POSIX: <http://austingroupbugs.net/view.php?id=1208>
2018-12-07 16:04:05 +01:00
Rafael Ávila de Espíndola 6af956e5c0 Enable VDSO for static linking on arm
I have tested that this builds and the resulting program still work.
The kernel in gcc117 (which I ussed for testing) seems to be missing
https://patchwork.kernel.org/patch/10060431/, so the vdso is never used.

	[BZ #19767]
	* sysdeps/unix/sysv/linux/arm/init-first.c: Remove #ifdef SHARED.
	* sysdeps/unix/sysv/linux/arm/libc-vdso.h: Remove #ifdef SHARED.
	* sysdeps/unix/sysv/linux/arm/sysdep.h: Define
	ALWAYS_USE_VSYSCALL.
2018-12-03 20:59:22 +00:00
Rafael Ávila de Espíndola 15b8d67e29 Enable VDSO on i386 statically linked programs
[BZ #19767]
	* sysdeps/unix/sysv/linux/i386/init-first.c: Don't check SHARED.
	* sysdeps/unix/sysv/linux/i386/sysdep.h (ALWAYS_USE_VSYSCALL):
	New.
2018-11-30 14:32:35 -08:00
Adhemerval Zanella 5fb7fc9635 posix: Use posix_spawn on system
This patch uses posix_spawn on system implementation.  On Linux this has
the advantage of much lower memory consumption (usually 32 Kb minimum for
the mmap stack area).

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

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

	* sysdeps/unix/sysv/linux/spawni.c (__spawni_child): Use
	__sigismember instead of sigismember.
	* sysdeps/posix/system.c [SIGCANCEL] (cancel_handler_args,
	cancel_handler): New definitions.
	(CLEANUP_HANDLER, CLEANUP_RESET): Likewise.
	(DO_LOCK, DO_UNLOCK, INIT_LOCK, ADD_REF, SUB_REF): Remove.
	(do_system): Use posix_spawn instead of fork and execl and remove
	reentracy code.
	* sysdeps/generic/not-errno.h (__kill_noerrno): New prototype.
	* sysdeps/unix/sysv/linux/not-errno.h (__kill_noerrno): Likewise.
	* sysdeps/unix/sysv/linux/ia64/system.c: Remove file.
	* sysdeps/unix/sysv/linux/s390/system.c: Likewise.
	* sysdeps/unix/sysv/linux/sparc/system.c: Likewise.
	* sysdeps/unix/sysv/linux/system.c: Likewise.
2018-11-30 18:42:05 -02:00
Florian Weimer d527c860f5 CVE-2018-19591: if_nametoindex: Fix descriptor for overlong name [BZ #23927] 2018-11-27 18:12:49 +01:00
Rafael Ávila de Espíndola 979cfed05d Enable VDSO for static linking on aarch64
[BZ #19767]
	* sysdeps/unix/sysv/linux/aarch64/init-first.c: Remove #ifdef SHARED.
	* sysdeps/unix/sysv/linux/aarch64/libc-vdso.h: Remove #ifdef SHARED.
	* sysdeps/unix/sysv/linux/aarch64/sysdep.h (ALWAYS_USE_VSYSCALL):
	Define.
2018-11-27 12:27:39 +00:00
Rafael Ávila de Espíndola 8ae74eadb6 Enable VDSO on powerpc statically linked programs (bug 19767)
[BZ #19767]
	* sysdeps/unix/sysv/linux/powerpc/init-first.c: Remove #ifdef SHARED.
	* sysdeps/unix/sysv/linux/powerpc/libc-vdso.h: Remove #ifdef
	SHARED.  Include sysdep.h.
	* sysdeps/unix/sysv/linux/powerpc/powerpc32/sysdep.h: Define
	ALWAYS_USE_VSYSCALL.
	* sysdeps/unix/sysv/linux/powerpc/powerpc64/sysdep.h: Define
	ALWAYS_USE_VSYSCALL.

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

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

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

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

	[BZ #23915]
	* sysdeps/unix/sysv/linux/arm/kernel-features.h
	[__LINUX_KERNEL_VERSION < 0x040700] (__ASSUME_COPY_FILE_RANGE):
	Undefine.
2018-11-23 17:53:50 +00:00
Szabolcs Nagy a502c5294b Remove the error handling wrapper from pow
Introduce new pow symbol version that doesn't do SVID compatible error
handling.  The standard errno and fp exception based error handling is
inline in the new code and does not have significant overhead.

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

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

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

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

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

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

Tested with build-many-glibcs.py.

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

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

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

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

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

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

Tested with build-many-glibcs.py.

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

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

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

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

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

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

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

Tested with build-many-glibcs.py.

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

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

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

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

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

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

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

Tested with build-many-glibcs.py.

	* math/Versions (GLIBC_2.29): Add exp and exp2.
	* math/w_exp2_compat.c (__exp2_compat): Change to versioned compat
	symbol, handle NO_LONG_DOUBLE and LONG_DOUBLE_COMPAT explicitly.
	* math/w_exp_compat.c (__exp_compat): Likewise.
	* math/w_exp.c: New file.
	* math/w_exp2.c: New file.
	* sysdeps/i386/fpu/w_exp.c: New file.
	* sysdeps/i386/fpu/w_exp2.c: New file.
	* sysdeps/ia64/fpu/e_exp.S: Add versioned symbols.
	* sysdeps/ia64/fpu/e_exp2.S: Likewise.
	* sysdeps/ieee754/dbl-64/e_exp.c (__ieee754_exp): Rename to __exp
	and add necessary aliases.
	* sysdeps/ieee754/dbl-64/e_exp2.c (__ieee754_exp2): Rename to __exp2
	and add necessary aliases.
	* sysdeps/ieee754/dbl-64/w_exp.c: New file.
	* sysdeps/ieee754/dbl-64/w_exp2.c: New file.
	* sysdeps/m68k/m680x0/fpu/w_exp.c: New file.
	* sysdeps/m68k/m680x0/fpu/w_exp2.c: New file.
	* sysdeps/mach/hurd/i386/libm.abilist: Update.
	* sysdeps/unix/sysv/linux/aarch64/libm.abilist: Update.
	* sysdeps/unix/sysv/linux/alpha/libm.abilist: Update.
	* sysdeps/unix/sysv/linux/arm/libm.abilist: Update.
	* sysdeps/unix/sysv/linux/hppa/libm.abilist: Update.
	* sysdeps/unix/sysv/linux/i386/libm.abilist: Update.
	* sysdeps/unix/sysv/linux/ia64/libm.abilist: Update.
	* sysdeps/unix/sysv/linux/m68k/coldfire/libm.abilist: Update.
	* sysdeps/unix/sysv/linux/m68k/m680x0/libm.abilist: Update.
	* sysdeps/unix/sysv/linux/microblaze/libm.abilist: Update.
	* sysdeps/unix/sysv/linux/mips/mips32/libm.abilist: Update.
	* sysdeps/unix/sysv/linux/mips/mips64/libm.abilist: Update.
	* sysdeps/unix/sysv/linux/nios2/libm.abilist: Update.
	* sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libm.abilist: Update.
	* sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libm.abilist: Update.
	* sysdeps/unix/sysv/linux/powerpc/powerpc64/libm-le.abilist: Update.
	* sysdeps/unix/sysv/linux/powerpc/powerpc64/libm.abilist: Update.
	* sysdeps/unix/sysv/linux/s390/s390-32/libm.abilist: Update.
	* sysdeps/unix/sysv/linux/s390/s390-64/libm.abilist: Update.
	* sysdeps/unix/sysv/linux/sh/libm.abilist: Update.
	* sysdeps/unix/sysv/linux/sparc/sparc32/libm.abilist: Update.
	* sysdeps/unix/sysv/linux/sparc/sparc64/libm.abilist: Update.
	* sysdeps/unix/sysv/linux/x86_64/64/libm.abilist: Update.
	* sysdeps/unix/sysv/linux/x86_64/x32/libm.abilist: Update.
	* sysdeps/x86_64/fpu/multiarch/e_exp-avx.c (__exp1): Remove.
	(__ieee754_exp): Rename to __exp.
	* sysdeps/x86_64/fpu/multiarch/e_exp-fma.c (__exp1): Remove.
	(__ieee754_exp): Rename to __exp.
	* sysdeps/x86_64/fpu/multiarch/e_exp-fma4.c (__exp1): Remove.
	(__ieee754_exp): Rename to __exp.
	* sysdeps/x86_64/fpu/multiarch/e_exp.c (__ieee754_exp): Rename to
	__exp.
	* sysdeps/x86_64/fpu/multiarch/w_exp.c: New file.
2018-11-21 09:55:02 +00:00
Joseph Myers e5de3b5b72 Remove __ASSUME_SOCKETCALL.
The __ASSUME_SOCKETCALL macro in kernel-features.h is no longer used
for anything.  (It used to be used in defining other macros related to
accept4 / recvmmsg / sendmmsg availability, but the code in that area
was simplified once we could assume a kernel with those features,
whether through a syscall or through socketcall, so allowing those
functions to be handled much like other socket operations, without
requring __ASSUME_SOCKETCALL.)  This patch removes that unused macro.

(Note: once we can assume a Linux 4.4 or later kernel, much of the
support for using socketcall at all can be removed from glibc,
although a few functions may need that support in glibc for longer.)

Tested with build-many-glibcs.py.

	* sysdeps/unix/sysv/linux/kernel-features.h: Remove comment about
	__ASSUME_SOCKETCALL.
	* sysdeps/unix/sysv/linux/i386/kernel-features.h
	(__ASSUME_SOCKETCALL): Remove.
	* sysdeps/unix/sysv/linux/m68k/kernel-features.h
	(__ASSUME_SOCKETCALL): Likewise.
	* sysdeps/unix/sysv/linux/microblaze/kernel-features.h
	(__ASSUME_SOCKETCALL): Likewise.
	* sysdeps/unix/sysv/linux/powerpc/kernel-features.h
	(__ASSUME_SOCKETCALL): Likewise.
	* sysdeps/unix/sysv/linux/s390/kernel-features.h
	(__ASSUME_SOCKETCALL): Likewise.
	* sysdeps/unix/sysv/linux/sh/kernel-features.h
	(__ASSUME_SOCKETCALL): Likewise.
	* sysdeps/unix/sysv/linux/sparc/kernel-features.h
	(__ASSUME_SOCKETCALL): Likewise.
2018-11-08 20:28:07 +00:00
Joseph Myers 596cc360aa Fix __ASSUME_MLOCK2 for ARM, MicroBlaze (bug 23867).
The generic kernel-features.h defines __ASSUME_MLOCK2 for 4.4 and
later kernels.  However, for 32-bit ARM binaries running on 64-bit ARM
kernels, and for MicroBlaze, the syscall was only wired up in the 4.7
kernel.  (32-bit ARM kernels did have the syscall from 4.4 onwards.)
This patch duly arranges for the macro to be undefined for those
architectures for kernels before 4.7.

Tested with build-many-glibcs.py for its ARM and MicroBlaze
configurations.

	[BZ #23867]
	* sysdeps/unix/sysv/linux/arm/kernel-features.h
	[__LINUX_KERNEL_VERSION < 0x040700] (__ASSUME_MLOCK2): Undefine.
	* sysdeps/unix/sysv/linux/microblaze/kernel-features.h
	[__LINUX_KERNEL_VERSION < 0x040700] (__ASSUME_MLOCK2): Undefine.
2018-11-07 16:27:35 +00:00
Andreas Schwab 295132ff05 RISC-V: don't assume PI mutexes and robust futexes before 4.20 (bug 23864)
Support for futex_cmpxchg as only been added to 4.20-rc1.
2018-11-07 09:37:48 +01:00
Joseph Myers e143ceba56 Correct SH kernel-features.h undefines (bug 23862).
The SH kernel-features.h undefines __ASSUME_RENAMEAT2 for kernel
versions before 4.8, but fails to undefine __ASSUME_EXECVEAT,
__ASSUME_MLOCK2 and __ASSUME_COPY_FILE_RANGE, although all those
syscalls (and several others) were added for SH in the same Linux
kernel commit (first released in 4.8).  This patch adds the proper
undefines of those macros.

Tested with build-many-glibcs.py for its SH configurations.

	[BZ #23862]
	* sysdeps/unix/sysv/linux/sh/kernel-features.h
	[__LINUX_KERNEL_VERSION < 0x040800] (__ASSUME_EXECVEAT): Undefine.
	[__LINUX_KERNEL_VERSION < 0x040800] (__ASSUME_MLOCK2): Likewise.
	[__LINUX_KERNEL_VERSION < 0x040800] (__ASSUME_COPY_FILE_RANGE):
	Likewise.
2018-11-06 17:22:50 +00:00
Florian Weimer 4a938cb273 posix: New function posix_spawn_file_actions_addchdir_np [BZ #17405] 2018-11-06 16:08:12 +01:00
Joseph Myers daea71c2e4 Update and correct SPARC configuration for supported socket syscalls (bug 23848).
Looking at kernel-features.h files, I saw that SPARC was missing full
information on when it gained separate socket syscalls.

This patch adds such information to the SPARC kernel-features.h.  It
also corrects what appear to be bugs in the existing code (that would
cause syscalls to be assumed to be present when not actually present).
Various __ASSUME_* macros, defined by default, were not undefined for
32-bit despite those syscalls only being added for 32-bit in Linux
4.4.  Some syscalls were used in the SPARC64 syscalls.list but only
added in 4.4; this was harmless before the __NR_* macros were defined
at all, but once the macros were defined it means a build with
post-4.4 headers would assume the syscalls to be present regardless of
--enable-kernel version.  Then, various __ASSUME_* macros were
previously not defined in cases where they could be defined (this part
of the patch is just an optimization, not a bug fix).

Note the observation in a comment in the patch that even the latest
Linux kernel for SPARC does not have getpeername and getsockname
syscalls in the compat syscall table for 32-bit binaries on 64-bit
kernels (so glibc can't assume those syscalls to be present for 32-bit
at all, although the 32-bit syscall table gained them in 4.4).

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

	[BZ #23848]
	* sysdeps/unix/sysv/linux/sparc/kernel-features.h [!__arch64__ &&
	__LINUX_KERNEL_VERSION < 0x040400] (__ASSUME_SENDMSG_SYSCALL):
	Undefine.
	[!__arch64__ && __LINUX_KERNEL_VERSION < 0x040400]
	(__ASSUME_RECVMSG_SYSCALL): Likewise.
	[!__arch64__ && __LINUX_KERNEL_VERSION < 0x040400]
	(__ASSUME_SENDTO_SYSCALL): Likewise.
	[!__arch64__ && __LINUX_KERNEL_VERSION < 0x040400]
	(__ASSUME_ACCEPT_SYSCALL): Undefine under this condition, not just
	[!__arch64__].
	[!__arch64__ && __LINUX_KERNEL_VERSION < 0x040400]
	(__ASSUME_CONNECT_SYSCALL): Likewise.
	[!__arch64__ && __LINUX_KERNEL_VERSION < 0x040400]
	(__ASSUME_RECVFROM_SYSCALL): Likewise.
	[__LINUX_KERNEL_VERSION >= 0x040400] (__ASSUME_BIND_SYSCALL):
	Define.
	[__LINUX_KERNEL_VERSION >= 0x040400] (__ASSUME_LISTEN_SYSCALL):
	Likewise.
	[__LINUX_KERNEL_VERSION >= 0x040400]
	(__ASSUME_SETSOCKOPT_SYSCALL): Likewise.
	* sysdeps/unix/sysv/linux/sparc/sparc64/syscalls.list (bind):
	Remove.
	(listen): Likewise.
	(setsockopt): Likewise.
2018-11-01 16:30:15 +00:00
Rafael Avila de Espindola 9c3dbdbe29 Simplify an #if #else #endif
The #else of two nested #if clauses were identical.

	* sysdeps/unix/sysv/linux/sysdep-vdso.h: Simplify an #if #else
	#endif.

Reviewed-by: Szabolcs Nagy <szabolcs.nagy@arm.com>
2018-10-31 10:32:40 -07:00
Joseph Myers fe61f17cfc Add IN_MASK_CREATE from Linux 4.19 to sys/inotify.h.
This patch adds the IN_MASK_CREATE macro from Linux 4.19 to
sys/inotify.h.

Tested for x86_64.

	* sysdeps/unix/sysv/linux/sys/inotify.h (IN_MASK_CREATE): New
	macro.
2018-10-25 15:57:23 +00:00
Florian Weimer 7c5e34d7f1 conform: XFAIL siginfo_t si_band test on sparc64
We can use long int on sparcv9, but on sparc64, we must match the int
type used by the kernel (and not long int, as in POSIX).
2018-10-25 14:36:57 +02:00
Albert ARIBAUD (3ADEV) a27a4f4721 Y2038: provide size of default time_t for target architecture
To determine whether the default time_t interfaces are 32-bit
    and so need conversions, or are 64-bit and so are compatible
    with the internal 64-bit type without conversions, a macro
    giving the size of the  default time_t is also required.
    This macro is called __TIMESIZE.

    This macro can then be used instead of __WORDSIZE in msq-pad.h
    and shm-pad.h files, which in turn allows removing their x86
    variants, and in sem-pad.h files but keeping the x86 variant.

    This patch was tested by running 'make check' on branch master
    then applying this patch and running 'make check' again, and
    checking that both 'make check' yield identical results.
    This was done on x86_64-linux-gnu and i686-linux-gnu.

	* bits/timesize.h: New file.
	* stdlib/Makefile (headers): Add bits/timesize.h.
	* sysdeps/unix/sysv/linux/bits/msq-pad.h
	(__MSQ_PAD_AFTER_TIME): Use __TIMESIZE instead of __WORDSIZE.
	* sysdeps/unix/sysv/linux/bits/sem-pad.h
	(__SEM_PAD_AFTER_TIME): Likewise.
	* sysdeps/unix/sysv/linux/bits/shm-pad.h
	(__SHM_PAD_AFTER_TIME): Likewise.
	* sysdeps/unix/sysv/linux/hppa/bits/msq-pad.h
	(__MSQ_PAD_BEFORE_TIME): Likewise.
	* sysdeps/unix/sysv/linux/hppa/bits/sem-pad.h
	(__SEM_PAD_BEFORE_TIME): Likewise.
	* sysdeps/unix/sysv/linux/hppa/bits/shm-pad.h
	(__SHM_PAD_BEFORE_TIME, __SHM_PAD_BETWEEN_TIME_AND_SEGSZ): Likewise.
	* sysdeps/unix/sysv/linux/mips/bits/msq-pad.h
        (__MSQ_PAD_AFTER_TIME, __MSQ_PAD_BEFORE_TIME): Likewise.
        * sysdeps/unix/sysv/linux/powerpc/bits/msq-pad.h
        (__MSQ_PAD_BEFORE_TIME): Likewise.
	* sysdeps/unix/sysv/linux/powerpc/bits/sem-pad.h
	(__SEM_PAD_BEFORE_TIME): Likewise.
	* sysdeps/unix/sysv/linux/powerpc/bits/shm-pad.h
	(__SHM_PAD_BEFORE_TIME, __SHM_PAD_BETWEEN_TIME_AND_SEGSZ): Likewise.
	* sysdeps/unix/sysv/linux/sparc/bits/msq-pad.h
	(__MSQ_PAD_BEFORE_TIME): Likewise.
	* sysdeps/unix/sysv/linux/sparc/bits/sem-pad.h
	(__SEM_PAD_BEFORE_TIME): Likewise.
	* sysdeps/unix/sysv/linux/sparc/bits/shm-pad.h
	(__SHM_PAD_BEFORE_TIME): Likewise.
	* sysdeps/unix/sysv/linux/x86/bits/msq-pad.h: Delete file.
	* sysdeps/unix/sysv/linux/x86/bits/shm-pad.h: Likewise.
	* sysdeps/unix/sysv/linux/x86/bits/timesize.h: New file.
2018-10-24 11:37:09 +02:00
Andreas Schwab 367d7cc2cb Don't use PSEUDO_END for non-PSEUDO function 2018-10-23 09:41:43 +02:00
Joseph Myers 029ad711b8 Update kernel version in syscall-names.list to 4.19.
Linux 4.19 does not add any new syscalls (some existing ones are added
to more architectures); this patch updates the version number in
syscall-names.list to reflect that it's still current for 4.19.

Tested with build-many-glibcs.py.

	* sysdeps/unix/sysv/linux/syscall-names.list: Update kernel
	version to 4.19.
2018-10-22 23:26:37 +00:00
Ilya Yu. Malakhov f997b4be18 signal: Use correct type for si_band in siginfo_t [BZ #23562] 2018-10-19 18:06:32 +02:00
David S. Miller 94a3a27f5d Add VDSO support to sparc.
* sysdeps/unix/sysv/linux/sparc/init-first.c: New file.
	* sysdeps/unix/sysv/linux/sparc/libc-vdso.h: New file.
	* sysdeps/unix/sysv/linux/sparc/Makefile: Add dl-vdso to
	sysdep_routines in subdir elf.
	* sysdeps/unix/sysv/linux/sparc/Versions: Add GLIBC_PRIVATE
	version for __vdso_clock_gettime.
	* sysdeps/unix/sysv/linux/sparc/sysdep.h (INTERNAL_VSYSCALL_CALL):
	Define.
	(HAVE_CLOCK_GETTIME_VSYSCALL): Define.
	(HAVE_GETTIMEOFDAY_VSYSCALL): Define.
2018-10-18 11:44:32 -07:00
Joseph Myers 729f34028a Use single bits/shm.h for all architectures.
After my patch to move SHMLBA to its own header, the bits/shm.h
headers for architectures using the Linux kernel still vary in a few
ways: the use of __syscall_ulong_t; whether padding for 32-bit systems
is present before or after time fields, or missing altogether (mips,
x32); whether shm_segsz is before or after the time fields; whether,
if after time fields, there is extra padding before shm_segsz.

This patch arranges for a single header to be used.  __syscall_ulong_t
is safe to use everywhere, while bits/shm-pad.h is added with new
macros __SHM_PAD_AFTER_TIME, __SHM_PAD_BEFORE_TIME,
__SHM_SEGSZ_AFTER_TIME and __SHM_PAD_BETWEEN_TIME_AND_SEGSZ to
describe the differences.

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

	* sysdeps/unix/sysv/linux/Makefile (sysdep_headers): Add
	bits/shm-pad.h.
	* sysdeps/unix/sysv/linux/bits/shm.h: Include <bits/shm-pad.h>.
	(shmatt_t): Define as __syscall_ulong_t.
	(__SHM_PAD_TIME): New macro, depending on [__SHM_PAD_BEFORE_TIME]
	and [__SHM_PAD_AFTER_TIME].
	(struct shmid_ds): Define time fields using __SHM_PAD_TIME.
	Define shm_segsz and associated padding based on
	[__SHM_SEGSZ_AFTER_TIME] and [__SHM_PAD_BETWEEN_TIME_AND_SEGSZ].
	Use __syscall_ulong_t instead of unsigned long int.
	[__USE_MISC] (struct shminfo): Use __syscall_ulong_t instead of
	unsigned long int.
	[__USE_MISC] (struct shm_info): Likewise.
	* sysdeps/unix/sysv/linux/bits/shm-pad.h: New file.
	* sysdeps/unix/sysv/linux/hppa/bits/shm-pad.h: Likewise.
	* sysdeps/unix/sysv/linux/mips/bits/shm-pad.h: Likewise.
	* sysdeps/unix/sysv/linux/powerpc/bits/shm-pad.h: Likewise.
	* sysdeps/unix/sysv/linux/sparc/bits/shm-pad.h: Likewise.
	* sysdeps/unix/sysv/linux/x86/bits/shm-pad.h: Likewise.
	* sysdeps/unix/sysv/linux/hppa/bits/shm.h: Remove.
	* sysdeps/unix/sysv/linux/mips/bits/shm.h: Likewise.
	* sysdeps/unix/sysv/linux/powerpc/bits/shm.h: Likewise.
	* sysdeps/unix/sysv/linux/sparc/bits/shm.h: Likewise.
	* sysdeps/unix/sysv/linux/x86/bits/shm.h: Likewise.
2018-10-17 11:56:28 +00:00
Joseph Myers 8c8d2a8aff Move SHMLBA to its own header.
One difference between bits/shm.h headers for architectures using the
Linux kernel is the definition of SHMLBA.  This was noted in
<https://sourceware.org/ml/libc-alpha/2018-09/msg00175.html> as a
reason why even a new architecture (C-SKY) might need its own
bits/shm.h; thus, splitting it out of bits/shm.h can allow less
duplication of headers for new architectures.

This patch moves that definition to its own header, bits/shmlba.h, to
allow more sharing of headers between architectures.  That move allows
the arm, ia64 and sh variants of bits/shm.h to be removed, as they had
no other significant differences from the generic bits/shm.h; powerpc
and x86 have their own bits/shm.h but do not need to get their own
bits/shmlba.h because they use the same SHMLBA as the generic header.
Other architectures with their own bits/shm.h get their own
bits/shmlba.h without being able to remove their own bits/shm.h until
the generic one has been adapted to be able to handle more
architectures (where, in addition to the differences seen for
bits/msq.h and bits/sem.h, the position of shm_segsz in struct
shmid_ds also depends on the architecture).

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

	* sysdeps/unix/sysv/linux/Makefile (sysdep_headers): Add
	bits/shmlba.h.
	* sysdeps/unix/sysv/linux/bits/shm.h: Include <bits/shmlba.h>.
	(SHMLBA): Remove macro.
	(__getpagesize): Remove function declaration.
	* sysdeps/unix/sysv/linux/hppa/bits/shm.h: Include
	<bits/shmlba.h>.
	(SHMLBA): Remove macro.
	* sysdeps/unix/sysv/linux/mips/bits/shm.h: Include
	<bits/shmlba.h>.
	(SHMLBA): Remove macro.
	* sysdeps/unix/sysv/linux/powerpc/bits/shm.h: Include
	<bits/shmlba.h>.
	(SHMLBA): Remove macro.
	(__getpagesize): Remove function declaration.
	* sysdeps/unix/sysv/linux/sparc/bits/shm.h: Include
	<bits/shmlba.h>.
	(SHMLBA): Remove macro.
	(__getshmlba): Remove function declaration.
	* sysdeps/unix/sysv/linux/x86/bits/shm.h: Include <bits/shmlba.h>.
	(SHMLBA): Remove macro.
	(__getpagesize): Remove function declaration.
	* sysdeps/unix/sysv/linux/arm/bits/shm.h: Remove file.
	* sysdeps/unix/sysv/linux/ia64/bits/shm.h: Likewise.
	* sysdeps/unix/sysv/linux/sh/bits/shm.h: Likewise.
	* sysdeps/unix/sysv/linux/bits/shmlba.h: New file.
	* sysdeps/unix/sysv/linux/arm/bits/shmlba.h: Likewise.
	* sysdeps/unix/sysv/linux/hppa/bits/shmlba.h: Likewise.
	* sysdeps/unix/sysv/linux/ia64/bits/shmlba.h: Likewise.
	* sysdeps/unix/sysv/linux/mips/bits/shmlba.h: Likewise.
	* sysdeps/unix/sysv/linux/sh/bits/shmlba.h: Likewise.
	* sysdeps/unix/sysv/linux/sparc/bits/shmlba.h: Likewise.
2018-10-17 11:55:10 +00:00
Stefan Liebler 403b4feb22 Fix race in pthread_mutex_lock while promoting to PTHREAD_MUTEX_ELISION_NP [BZ #23275]
The race leads either to pthread_mutex_destroy returning EBUSY
or triggering an assertion (See description in bugzilla).

This patch is fixing the race by ensuring that the elision path is
used in all cases if elision is enabled by the GLIBC_TUNABLES framework.

The __kind variable in struct __pthread_mutex_s is accessed concurrently.
Therefore we are now using the atomic macros.

The new testcase tst-mutex10 is triggering the race on s390x and intel.
Presumably also on power, but I don't have access to a power machine
with lock-elision. At least the code for power is the same as on the other
two architectures.

ChangeLog:

	[BZ #23275]
	* nptl/tst-mutex10.c: New File.
	* nptl/Makefile (tests): Add tst-mutex10.
	(tst-mutex10-ENV): New variable.
	* sysdeps/unix/sysv/linux/s390/force-elision.h: (FORCE_ELISION):
	Ensure that elision path is used if elision is available.
	* sysdeps/unix/sysv/linux/powerpc/force-elision.h (FORCE_ELISION):
	Likewise.
	* sysdeps/unix/sysv/linux/x86/force-elision.h: (FORCE_ELISION):
	Likewise.
	* nptl/pthreadP.h (PTHREAD_MUTEX_TYPE, PTHREAD_MUTEX_TYPE_ELISION)
	(PTHREAD_MUTEX_PSHARED): Use atomic_load_relaxed.
	* nptl/pthread_mutex_consistent.c (pthread_mutex_consistent): Likewise.
	* nptl/pthread_mutex_getprioceiling.c (pthread_mutex_getprioceiling):
	Likewise.
	* nptl/pthread_mutex_lock.c (__pthread_mutex_lock_full)
	(__pthread_mutex_cond_lock_adjust): Likewise.
	* nptl/pthread_mutex_setprioceiling.c (pthread_mutex_setprioceiling):
	Likewise.
	* nptl/pthread_mutex_timedlock.c (__pthread_mutex_timedlock): Likewise.
	* nptl/pthread_mutex_trylock.c (__pthread_mutex_trylock): Likewise.
	* nptl/pthread_mutex_unlock.c (__pthread_mutex_unlock_full): Likewise.
	* sysdeps/nptl/bits/thread-shared-types.h (struct __pthread_mutex_s):
	Add comments.
	* nptl/pthread_mutex_destroy.c (__pthread_mutex_destroy):
	Use atomic_load_relaxed and atomic_store_relaxed.
	* nptl/pthread_mutex_init.c (__pthread_mutex_init):
	Use atomic_store_relaxed.
2018-10-17 12:23:04 +02:00
Joseph Myers bcdb1bfa0c Use single bits/sem.h for all architectures.
The bits/sem.h headers for architectures using the Linux kernel vary
in a few ways:

* x32 uses __syscall_ulong_t instead of unsigned long int.

* The x86 header uses padding after time fields unconditionally
  (including for both x86_64 ABIs), not just for 32-bit time (unlike
  in msqid_ds where there is only padding for 32-bit time).  Because
  this padding is present for x32, and is __syscall_ulong_t there, it
  does have to be __syscall_ulong_t, not unsigned long int.

* The MIPS header never uses padding around time fields, even when
  32-bit (unlike in msqid_ds where it has endian-dependent padding for
  32-bit time).

* Some older 32-bit big-endian architectures have padding before
  rather than after time fields, although the preferred generic
  approach is padding after the time fields independent of endianness.

(There are also insubstantial differences such as use of unsigned int
for padding instead of unsigned long int, which makes no difference to
layout since the padding fields using unsigned int are only present on
32-bit architectures.)

For the first, __syscall_ulong_t can be used in the generic version as
it's the same as unsigned long int everywhere except x32.  For the
other differences, this patch adds macros __SEM_PAD_BEFORE_TIME and
__SEM_PAD_AFTER_TIME in a new bits/sem-pad.h header, so that header is
the only one needing to be provided on architectures with differences
in this area, and everything else can go in a single common bits/sem.h
header.

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

	* sysdeps/unix/sysv/linux/Makefile (sysdep_headers): Add
	bits/sem-pad.h.
	* sysdeps/unix/sysv/linux/bits/sem.h: Include <bits/sem-pad.h>
	instead of <bits/wordsize.h>.
	(__SEM_PAD_TIME): New macro, depending on [__SEM_PAD_BEFORE_TIME]
	and [__SEM_PAD_AFTER_TIME].
	(struct semid_ds): Define time fields using __SEM_PAD_TIME.  Use
	__syscall_ulong_t instead of unsigned long int.
	* sysdeps/unix/sysv/linux/bits/sem-pad.h: New file.
	* sysdeps/unix/sysv/linux/hppa/bits/sem-pad.h: Likewise.
	* sysdeps/unix/sysv/linux/mips/bits/sem-pad.h: Likewise.
	* sysdeps/unix/sysv/linux/powerpc/bits/sem-pad.h: Likewise.
	* sysdeps/unix/sysv/linux/sparc/bits/sem-pad.h: Likewise.
	* sysdeps/unix/sysv/linux/x86/bits/sem-pad.h: Likewise.
	* sysdeps/unix/sysv/linux/hppa/bits/sem.h: Remove.
	* sysdeps/unix/sysv/linux/mips/bits/sem.h: Likewise.
	* sysdeps/unix/sysv/linux/powerpc/bits/sem.h: Likewise.
	* sysdeps/unix/sysv/linux/sparc/bits/sem.h: Likewise.
	* sysdeps/unix/sysv/linux/x86/bits/sem.h: Likewise.
2018-10-15 19:28:04 +00:00
Joseph Myers 9f9feb6d5d Use single bits/msq.h for all architectures.
The bits/msq.h headers for architectures using the Linux kernel vary
in a few ways:

* x32 uses __syscall_ulong_t instead of unsigned long int.

* x32 has 64-bit time_t, so no padding around time fields despite
  __WORDSIZE == 32.

* Some older 32-bit big-endian architectures have padding before
  rather than after time fields, although the preferred generic
  approach is padding after the time fields independent of endianness.

(There are also insubstantial differences such as use of unsigned int
for padding instead of unsigned long int, which makes no difference to
layout since the padding fields using unsigned int are only present on
32-bit architectures.)

For the first, __syscall_ulong_t can be used in the generic version as
it's the same as unsigned long int everywhere except x32.  For the
other two differences, this patch adds macros __MSQ_PAD_BEFORE_TIME
and __MSQ_PAD_AFTER_TIME in a new bits/msq-pad.h header, so that
header is the only one needing to be provided on architectures with
differences in this area, and everything else can go in a single
common bits/msq.h header.  Once we have __TIMESIZE, the generic
bits/msq-pad.h can change to use that instead of __WORDSIZE, at which
point the x86 version of bits/msq-pad.h won't be needed either.

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

	* sysdeps/unix/sysv/linux/Makefile (sysdep_headers): Add
	bits/msq-pad.h.
	* sysdeps/unix/sysv/linux/bits/msq.h: Include <bits/msq-pad.h>
	instead of <bits/wordsize.h>.
	(msgqnum_t): Define as __syscall_ulong_t.
	(msglen_t): Likewise.
	(__MSQ_PAD_TIME): New macro, depending on [__MSQ_PAD_BEFORE_TIME]
	and [__MSQ_PAD_AFTER_TIME].
	(struct msqid_ds): Define time fields using __MSQ_PAD_TIME.  Use
	__syscall_ulong_t instead of unsigned long int.
	* sysdeps/unix/sysv/linux/bits/msq-pad.h: New file.
	* sysdeps/unix/sysv/linux/hppa/bits/msq-pad.h: Likewise.
	* sysdeps/unix/sysv/linux/mips/bits/msq-pad.h: Likewise.
	* sysdeps/unix/sysv/linux/powerpc/bits/msq-pad.h: Likewise.
	* sysdeps/unix/sysv/linux/sparc/bits/msq-pad.h: Likewise.
	* sysdeps/unix/sysv/linux/x86/bits/msq-pad.h: Likewise.
	* sysdeps/unix/sysv/linux/hppa/bits/msq.h: Remove.
	* sysdeps/unix/sysv/linux/mips/bits/msq.h: Likewise.
	* sysdeps/unix/sysv/linux/powerpc/bits/msq.h: Likewise.
	* sysdeps/unix/sysv/linux/sparc/bits/msq.h: Likewise.
	* sysdeps/unix/sysv/linux/x86/bits/msq.h: Likewise.
2018-10-11 12:07:27 +00:00
Joseph Myers 2a4b25fad8 Use common bits/shm.h for more architectures.
sysdeps/unix/sysv/linux/bits/shm.h has padding after time fields in
struct shmid_ds unconditionally, and thus is only suitable for 32-bit
architectures (no 64-bit configurations use this file);
sysdeps/unix/sysv/linux/generic/bits/shm.h is substantively the same,
except that the padding is conditioned on __WORDSIZE == 32, and so it
can be used for 64-bit architectures as well.

This patch adds the conditionals to
sysdeps/unix/sysv/linux/bits/shm.h.  The linux/generic/ version is
then no longer needed and so is removed, as are the alpha and s390
versions which are also no longer needed.  The other
architecture-specific versions have different padding, layout, types
or SHMLBA definitions and so are still needed after this change.

This is essentially the same change for bits/shm.h as the bits/msq.h
patch and the bits/sem.h patch.  However, the details of the padding
variations for the architectures that aren't changed are not all the
same between msqid_ds, shmid_ds and semid_ds.

Tested with build-many-glibcs.py.

	* sysdeps/unix/sysv/linux/bits/shm.h: Include <bits/wordsize.h>.
	(struct shmid_ds): Condition padding after time fields on
	[__WORDSIZE == 32].
	* sysdeps/unix/sysv/linux/alpha/bits/shm.h: Remove file.
	* sysdeps/unix/sysv/linux/generic/bits/shm.h: Likewise.
	* sysdeps/unix/sysv/linux/s390/bits/shm.h: Likewise.
2018-10-10 00:56:17 +00:00
Joseph Myers 19e62f2690 Use common bits/sem.h for more architectures.
sysdeps/unix/sysv/linux/bits/sem.h has padding after time fields in
struct semid_ds unconditionally, and thus is only suitable for 32-bit
architectures (no 64-bit configurations use this file);
sysdeps/unix/sysv/linux/generic/bits/sem.h is substantively the same,
except that the padding is conditioned on __WORDSIZE == 32, and so it
can be used for 64-bit architectures as well.

This patch adds the conditionals to
sysdeps/unix/sysv/linux/bits/sem.h.  The linux/generic/ version is
then no longer needed and so is removed, as are the alpha, ia64 and
s390 versions which are also no longer needed.  The other
architecture-specific versions have different padding or types and so
are still needed after this change.

This is essentially the same change for bits/sem.h as the bits/msq.h
patch.  However, the details of the padding variations for the
architectures that aren't changed are not all the same between
msqid_ds and semid_ds.

Tested with build-many-glibcs.py.

	* sysdeps/unix/sysv/linux/bits/sem.h: Include <bits/wordsize.h>.
	(struct semid_ds): Condition padding after time fields on
	[__WORDSIZE == 32].
	* sysdeps/unix/sysv/linux/alpha/bits/sem.h: Remove file.
	* sysdeps/unix/sysv/linux/generic/bits/sem.h: Likewise.
	* sysdeps/unix/sysv/linux/ia64/bits/sem.h: Likewise.
	* sysdeps/unix/sysv/linux/s390/bits/sem.h: Likewise.
2018-10-10 00:54:27 +00:00
Joseph Myers b9c0f6c11a Use common bits/msq.h for more architectures.
sysdeps/unix/sysv/linux/bits/msq.h has padding after time fields in
struct msqid_ds unconditionally, and thus is only suitable for 32-bit
architectures (no 64-bit configurations use this file);
sysdeps/unix/sysv/linux/generic/bits/msq.h is substantively the same,
except that the padding is conditioned on __WORDSIZE == 32, and so it
can be used for 64-bit architectures as well.

This patch adds the conditionals to
sysdeps/unix/sysv/linux/bits/msq.h.  The linux/generic/ version is
then no longer needed and so is removed, as are the alpha, ia64 and
s390 versions which are also no longer needed.  The other
architecture-specific versions have different padding or types and so
are still needed after this change.

Tested with build-many-glibcs.py.

	* sysdeps/unix/sysv/linux/bits/msq.h: Include <bits/wordsize.h>.
	(struct msqid_ds): Condition padding after time fields on
	[__WORDSIZE == 32].
	* sysdeps/unix/sysv/linux/alpha/bits/msq.h: Remove file.
	* sysdeps/unix/sysv/linux/generic/bits/msq.h: Likewise.
	* sysdeps/unix/sysv/linux/ia64/bits/msq.h: Likewise.
	* sysdeps/unix/sysv/linux/s390/bits/msq.h: Likewise.
2018-10-10 00:52:47 +00:00
Joseph Myers 47c49251d5 Use bits/mman-linux.h for hppa.
hppa currently has a bits/mman.h that does not include
bits/mman-linux.h, unlike all other architectures using the Linux
kernel.  This sort of variation between architectures is generally
unhelpful when making global changes for new constants added to new
Linux kernel releases.

This patch changes hppa to use bits/mman-linux.h, overriding constants
with different values as necessary (including with #undef after
bits/mman.h inclusion when needed, as already done for alpha).  While
there could possibly be further improvements through e.g. splitting
more sets of definitions into separate bits/ headers, I think this is
still an improvement on the current state.  diffstat shows 27 lines
added, 51 deleted (and some of that is actually existing lines moving
to a different place in the file).

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

	* sysdeps/unix/sysv/linux/hppa/bits/mman.h: Include
	<bits/mman-linux.h>.
	(PROT_READ): Don't define here.
	(PROT_WRITE): Likewise.
	(PROT_EXEC): Likewise.
	(PROT_NONE): Likewise.
	(PROT_GROWSDOWN): Likewise.
	(PROT_GROWSUP): Likewise.
	(MAP_SHARED): Likewise.
	(MAP_PRIVATE): Likewise.
	[__USE_MISC] (MAP_SHARED_VALIDATE): Likewise.
	[__USE_MISC] (MAP_FILE): Likewise.
	[__USE_MISC] (MAP_ANONYMOUS): Likewise.
	[__USE_MISC] (MAP_ANON): Likewise.
	[__USE_MISC] (MAP_HUGE_SHIFT): Likewise.
	[__USE_MISC] (MAP_HUGE_MASK): Likewise.
	(MCL_CURRENT): Likewise.
	(MCL_FUTURE): Likewise.
	(MCL_ONFAULT): Likewise.
	[__USE_MISC] (MADV_NORMAL): Likewise.
	[__USE_MISC] (MADV_RANDOM): Likewise.
	[__USE_MISC] (MADV_SEQUENTIAL): Likewise.
	[__USE_MISC] (MADV_WILLNEED): Likewise.
	[__USE_MISC] (MADV_DONTNEED): Likewise.
	[__USE_MISC] (MADV_FREE): Likewise.
	[__USE_MISC] (MADV_REMOVE): Likewise.
	[__USE_MISC] (MADV_DONTFORK): Likewise.
	[__USE_MISC] (MADV_DOFORK): Likewise.
	[__USE_MISC] (MADV_HWPOISON): Likewise.
	[__USE_XOPEN2K] (POSIX_MADV_NORMAL): Likewise.
	[__USE_XOPEN2K] (POSIX_MADV_RANDOM): Likewise.
	[__USE_XOPEN2K] (POSIX_MADV_SEQUENTIAL): Likewise.
	[__USE_XOPEN2K] (POSIX_MADV_WILLNEED): Likewise.
	[__USE_XOPEN2K] (POSIX_MADV_DONTNEED): Likewise.
	(__MAP_ANONYMOUS): New macro.
	[__USE_MISC] (MAP_TYPE): Undefine and redefine after
	<bits/mman-linux.h> inclusion.
	(MAP_FIXED): Likewise.
	(MS_SYNC): Likewise.
	(MS_ASYNC): Likewise.
	(MS_INVALIDATE): Likewise.
	[__USE_MISC] (MADV_MERGEABLE): Likewise.
	[__USE_MISC] (MADV_UNMERGEABLE): Likewise.
	[__USE_MISC] (MADV_HUGEPAGE): Likewise.
	[__USE_MISC] (MADV_NOHUGEPAGE): Likewise.
	[__USE_MISC] (MADV_DONTDUMP): Likewise.
	[__USE_MISC] (MADV_DODUMP): Likewise.
	[__USE_MISC] (MADV_WIPEONFORK): Likewise.
	[__USE_MISC] (MADV_KEEPONFORK): Likewise.
2018-10-04 19:47:23 +00:00
Adhemerval Zanella a06fc4a533 Fix build from commit 0b727ed
* sysdeps/unix/sysv/linux/fd_to_filename.h: Add missing includes.
2018-10-02 12:29:02 -03:00
H.J. Lu a1ccc0654b x86: Use RTM intrinsics in pthread mutex lock elision
Since RTM intrinsics are supported in GCC 4.9, we can use them in
pthread mutex lock elision.

	* sysdeps/unix/sysv/linux/x86/Makefile (CFLAGS-elision-lock.c):
	Add -mrtm.
	(CFLAGS-elision-unlock.c): Likewise.
	(CFLAGS-elision-timed.c): Likewise.
	(CFLAGS-elision-trylock.c): Likewise.
	* sysdeps/unix/sysv/linux/x86/hle.h: Rewritten.
2018-10-02 07:51:57 -07:00
Adhemerval Zanella 0b727ed4d6 libio: Flush stream at freopen (BZ#21037)
As POSIX states [1] a freopen call should first flush the stream as if by a
call fflush.  C99 (n1256) and C11 (n1570) only states the function should
first close any file associated with the specific stream.  Although current
implementation only follow C specification, current BSD and other libc
implementation (musl) are in sync with POSIX and fflush the stream.

This patch change freopen{64} to fflush the stream before actually reopening
it (or returning if the stream does not support reopen).  It also changes the
Linux implementation to avoid a dynamic allocation on 'fd_to_filename'.

Checked on x86_64-linux-gnu.

	[BZ #21037]
	* libio/Makefile (tests): Add tst-memstream4 and tst-wmemstream4.
	* libio/freopen.c (freopen): Sync stream before reopen and adjust to
	new fd_to_filename interface.
	* libio/freopen64.c (freopen64): Likewise.
	* libio/tst-memstream.h: New file.
	* libio/tst-memstream4.c: Likewise.
	* libio/tst-wmemstream4.c: Likewise.
	* sysdeps/generic/fd_to_filename.h (fd_to_filename): Change signature.
	* sysdeps/unix/sysv/linux/fd_to_filename.h (fd_to_filename): Likewise
	and remove internal dynamic allocation.

[1] http://pubs.opengroup.org/onlinepubs/9699919799/
2018-10-02 10:01:56 -03:00
Joseph Myers d0e91e8c4e Move MREMAP_* to bits/mman-shared.h.
The MREMAP_* flags are identical between bits/mman-linux.h and the
hppa bits/mman.h; thus, they should be in bits/mman-shared.h instead
to avoid unnecessary duplication.  This patch moves them there.

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

	* sysdeps/unix/sysv/linux/bits/mman-linux.h [__USE_GNU]
	(MREMAP_MAYMOVE): Do not define here.
	[__USE_GNU] (MREMAP_FIXED): Likewise.
	* sysdeps/unix/sysv/linux/bits/mman-shared.h [__USE_GNU]
	(MREMAP_MAYMOVE): Define here instead.
	[__USE_GNU] (MREMAP_FIXED): Likewise.
	* sysdeps/unix/sysv/linux/hppa/bits/mman.h [__USE_GNU]
	(MREMAP_MAYMOVE): Remove.
	[__USE_GNU] (MREMAP_FIXED): Likewise.
2018-10-01 20:30:57 +00:00
Adhemerval Zanella 7a16bdbb9f Fix misreported errno on preadv2/pwritev2 (BZ#23579)
The fallback code of Linux wrapper for preadv2/pwritev2 executes
regardless of the errno code for preadv2, instead of the case where
the syscall is not supported.

This fixes it by calling the fallback code iff errno is ENOSYS. The
patch also adds tests for both invalid file descriptor and invalid
iov_len and vector count.

The only discrepancy between preadv2 and fallback code regarding
error reporting is when an invalid flags are used.  The fallback code
bails out earlier with ENOTSUP instead of EINVAL/EBADF when the syscall
is used.

Checked on x86_64-linux-gnu on a 4.4.0 and 4.15.0 kernel.

	[BZ #23579]
	* misc/tst-preadvwritev2-common.c (do_test_with_invalid_fd): New
	test.
	* misc/tst-preadvwritev2.c, misc/tst-preadvwritev64v2.c (do_test):
	Call do_test_with_invalid_fd.
	* sysdeps/unix/sysv/linux/preadv2.c (preadv2): Use fallback code iff
	errno is ENOSYS.
	* sysdeps/unix/sysv/linux/preadv64v2.c (preadv64v2): Likewise.
	* sysdeps/unix/sysv/linux/pwritev2.c (pwritev2): Likewise.
	* sysdeps/unix/sysv/linux/pwritev64v2.c (pwritev64v2): Likewise.
2018-09-28 10:08:09 -03:00
Joseph Myers 61d8b5feee Share MAP_* flags between more architectures.
Continuing bits/mman.h unification between architectures using the
Linux kernel, this patch arranges for the common set of MAP_* flags to
be used by two more architectures.  That common set is moved to
bits/mman-map-flags-generic.h, which is included by bits/mman.h, to
allow architectures to use that common set even if they also have
architecture-specific additions to it.  As well as the generic
bits/mman.h, the versions for x86 and ia64 are also then made to
include bits/mman-map-flags-generic.h, so while they still need
architecture-specific bits/mman.h (for MAP_32BIT and MAP_GROWSUP
respectively), they do not need to duplicate the generic flag
definitions in there.

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

	* sysdeps/unix/sysv/linux/bits/mman-map-flags-generic.h: New
	file.  Most contents moved from ....
	* sysdeps/unix/sysv/linux/bits/mman.h: ... here.  Move contents to
	and include <bits/mman-map-flags-generic.h>.
	* sysdeps/unix/sysv/linux/Makefile [$(subdir) = misc]
	(sysdep_headers): Add bits/mman-map-flags-generic.h.
	* sysdeps/unix/sysv/linux/ia64/bits/mman.h: Include
	<bits/mman-map-flags-generic.h>.
	[__USE_MISC] (MAP_GROWSUP): Only define this macro, not other
	macros defined in <bits/mman-map-flags-generic.h>.
	* sysdeps/unix/sysv/linux/x86/bits/mman.h: Include
	<bits/mman-map-flags-generic.h>.
	[__USE_MISC] (MAP_32BIT): Only define this macro, not other macros
	defined in <bits/mman-map-flags-generic.h>.
2018-09-26 12:33:14 +00:00
Joseph Myers d62f9ec0cc Complete sys/procfs.h unification.
This patch completes the process of unifying sys/procfs.h headers for
architectures using the Linux kernel by making alpha use the generic
version.

That was previously deferred because alpha has different definitions
of prgregset_t and prfpregset_t from other architectures, so changing
to the common definitions would change C++ name mangling.  To avoid
such a change, a header bits/procfs-prregset.h is added, and alpha
gets its own version of that header.

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

	* sysdeps/unix/sysv/linux/sys/procfs.h: Include
	<bits/procfs-prregset.h>.
	(prgregset_t): Define using __prgregset_t.
	(prfpregset_t): Define using __prfpregset_t.
	* sysdeps/unix/sysv/linux/Makefile [$(subdir) = misc]
	(sysdep_headers): Add bits/procfs-prregset.h.
	* sysdeps/unix/sysv/linux/bits/procfs-prregset.h: New file.
	* sysdeps/unix/sysv/linux/alpha/bits/procfs-prregset.h: Likewise.
	* sysdeps/unix/sysv/linux/alpha/bits/procfs.h: Likewise.
	* sysdeps/unix/sysv/linux/alpha/sys/procfs.h: Remove file.
2018-09-25 16:50:30 +00:00
Joseph Myers d0d8eb4328 Unify more sys/procfs.h headers.
This patch continues the process of unifying sys/procfs.h headers for
architectures using the Linux kernel.

A bits/procfs-id.h header is added to define __pr_uid_t and __pr_gid_t
for the types of pr_uid and pr_gid; the default version of this header
uses unsigned int.  On some architectures, sys/procfs.h has copies of
32-bit structures for 64-bit builds; those move into a
bits/procfs-extra.h header (they can't go in bits/procfs.h because
they have to come *after* other declarations from sys/procfs.h).
Given appropriate versions of these headers, six more architectures
can then move to providing only bits/procfs*.h without duplicating the
rest of the contents of sys/procfs.h.  Only alpha needs a further
bits/ header to be added before it can stop having its own
sys/procfs.h.

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

	* sysdeps/unix/sysv/linux/sys/procfs.h: Include
	<bits/procfs-id.h> and <bits/procfs-extra.h>.
	(struct elf_prpsinfo): Use __pr_uid_t and __pr_gid_t as types of
	pr_uid and pr_gid.
	* sysdeps/unix/sysv/linux/Makefile [$(subdir) = misc]
	(sysdep_headers): Add bits/procfs-id.h and bits/procfs-extra.h.
	* sysdeps/unix/sysv/linux/bits/procfs-extra.h: New file.
	* sysdeps/unix/sysv/linux/bits/procfs-id.h: Likewise.
	* sysdeps/unix/sysv/linux/arm/bits/procfs-id.h: Likewise.
	* sysdeps/unix/sysv/linux/arm/bits/procfs.h: Likewise.
	* sysdeps/unix/sysv/linux/m68k/bits/procfs-id.h: Likewise.
	* sysdeps/unix/sysv/linux/m68k/bits/procfs.h: Likewise.
	* sysdeps/unix/sysv/linux/s390/bits/procfs-extra.h: Likewise.
	* sysdeps/unix/sysv/linux/s390/bits/procfs-id.h: Likewise.
	* sysdeps/unix/sysv/linux/s390/bits/procfs.h: Likewise.
	* sysdeps/unix/sysv/linux/sh/bits/procfs-id.h: Likewise.
	* sysdeps/unix/sysv/linux/sh/bits/procfs.h: Likewise.
	* sysdeps/unix/sysv/linux/sparc/bits/procfs-extra.h: Likewise.
	* sysdeps/unix/sysv/linux/sparc/bits/procfs-id.h: Likewise.
	* sysdeps/unix/sysv/linux/sparc/bits/procfs.h: Likewise.
	* sysdeps/unix/sysv/linux/x86/bits/procfs-id.h: Likewise.
	* sysdeps/unix/sysv/linux/x86/bits/procfs.h: Likewise.
	* sysdeps/unix/sysv/linux/arm/sys/procfs.h: Remove file.
	* sysdeps/unix/sysv/linux/m68k/sys/procfs.h: Likewise.
	* sysdeps/unix/sysv/linux/s390/sys/procfs.h: Likewise.
	* sysdeps/unix/sysv/linux/sh/sys/procfs.h: Likewise.
	* sysdeps/unix/sysv/linux/sparc/sys/procfs.h: Likewise.
	* sysdeps/unix/sysv/linux/x86/sys/procfs.h: Likewise.
2018-09-25 16:49:25 +00:00
Joseph Myers 8ea4d2b7d1 Unify some sys/procfs.h headers.
As per recent discussions, this patch unifies some of the sys/procfs.h
headers for architectures using the Linux kernel, producing a generic
version that can hopefully be used by all new architectures as well.

The new generic version is based on the AArch64 one.  The register
definitions, the only part that generally needs to vary by
architecture, go in a new bits/procfs.h header (which each
architecture using the generic version needs to provide); that header
also has any #includes that were in the architecture-specific
sys/procfs.h, where those includes went beyond the generic set.

The generic version is used for eight architectures where the generic
definitions were the same as the architecture-specific ones.  (Some of
those architectures had #if 0 fields, now removed; some defined types
or fields using different type names which were typedefs for the same
underlying types.)

Six of the remaining architectures with their own sys/procfs.h use
unsigned short for pr_uid / pr_gid in some cases; moving those to the
generic header will require a bits/ header to define a typedef for the
type of those fields.  In the case of alpha, the generic sys/procfs.h
uses elf_gregset_t (= unsigned long int[33]) to define prgregset_t and
elf_fpregset_t (= double[32]) to define prfpregset_t, but the alpha
version uses gregset_t (= long int[33]) and fpregset_t (= long
int[32]), so avoiding unnecessarily changing the underlying types (and
thus C++ name mangling) again means a bits/ header will need to be
able to define a different choice for those typedefs.

bits/procfs.h is included outside the __BEGIN_DECLS / __END_DECLS pair
(whereas the definitions it contains were previously inside that pair
in various sys/procfs.h headers), because it sometimes includes other
headers and putting those other #includes inside that pair seems
risky.  Because none of the declarations in bits/procfs.h are of
functions or variables or involve function types, I don't think it
makes any difference whether they are inside or outside an extern "C"
context.

Tested with build-many-glibcs.py (again, that does not provide much
validation for the correctness of this patch).

	* sysdeps/unix/sysv/linux/sys/procfs.h: Replace with file based on
	AArch64 version.  Include <bits/procfs.h>.
	* sysdeps/unix/sysv/linux/Makefile [$(subdir) = misc]
	(sysdep_headers): Add bits/procfs.h.
	* sysdeps/unix/sysv/linux/bits/procfs.h: New file.
	* sysdeps/unix/sysv/linux/aarch64/bits/procfs.h: Likewise.
	* sysdeps/unix/sysv/linux/hppa/bits/procfs.h: Likewise.
	* sysdeps/unix/sysv/linux/ia64/bits/procfs.h: Likewise.
	* sysdeps/unix/sysv/linux/microblaze/bits/procfs.h: Likewise.
	* sysdeps/unix/sysv/linux/mips/bits/procfs.h: Likewise.
	* sysdeps/unix/sysv/linux/nios2/bits/procfs.h: Likewise.
	* sysdeps/unix/sysv/linux/powerpc/bits/procfs.h: Likewise.
	* sysdeps/unix/sysv/linux/riscv/bits/procfs.h: Likewise.
	* sysdeps/unix/sysv/linux/aarch64/sys/procfs.h: Remove file.
	* sysdeps/unix/sysv/linux/hppa/sys/procfs.h: Likewise.
	* sysdeps/unix/sysv/linux/ia64/sys/procfs.h: Likewise.
	* sysdeps/unix/sysv/linux/microblaze/sys/procfs.h: Likewise.
	* sysdeps/unix/sysv/linux/mips/sys/procfs.h: Likewise.
	* sysdeps/unix/sysv/linux/nios2/sys/procfs.h: Likewise.
	* sysdeps/unix/sysv/linux/powerpc/sys/procfs.h: Likewise.
	* sysdeps/unix/sysv/linux/riscv/sys/procfs.h: Likewise.
2018-09-25 16:48:15 +00:00
Adhemerval Zanella f0458cf4f9 powerpc: Only enable TLE with PPC_FEATURE2_HTM_NOSC
Linux from 3.9 through 4.2 does not abort HTM transaction on syscalls,
instead it suspend and resume it when leaving the kernel.  The
side-effects of the syscall will always remain visible, even if the
transaction is aborted.  This is an issue when transaction is used along
with futex syscall, on pthread_cond_wait for instance, where the futex
call might succeed but the transaction is rolled back leading the
pthread_cond object in an inconsistent state.

Glibc used to prevent it by always aborting a transaction before issuing
a syscall.  Linux 4.2 also decided to abort active transaction in
syscalls which makes the glibc workaround superfluous.  Worse, glibc
transaction abortion leads to a performance issue on recent kernels
where the HTM state is saved/restore lazily (v4.9).  By aborting a
transaction on every syscalls, regardless whether a transaction has being
initiated before, GLIBS makes the kernel always save/restore HTM state
(it can not even lazily disable it after a certain number of syscall
iterations).

Because of this shortcoming, Transactional Lock Elision is just enabled
when it has been explicitly set (either by tunables of by a configure
switch) and if kernel aborts HTM transactions on syscalls
(PPC_FEATURE2_HTM_NOSC).  It is reported that using simple benchmark [1],
the context-switch is about 5% faster by not issuing a tabort in every
syscall in newer kernels.

Checked on powerpc64le-linux-gnu with 4.4.0 kernel (Ubuntu 16.04).

	* NEWS: Add note about new TLE support on powerpc64le.
	* sysdeps/powerpc/nptl/tcb-offsets.sym (TM_CAPABLE): Remove.
	* sysdeps/powerpc/nptl/tls.h (tcbhead_t): Rename tm_capable to
	__ununsed1.
	(TLS_INIT_TP, TLS_DEFINE_INIT_TP): Remove tm_capable setup.
	(THREAD_GET_TM_CAPABLE, THREAD_SET_TM_CAPABLE): Remove macros.
	* sysdeps/powerpc/powerpc32/sysdep.h,
	sysdeps/powerpc/powerpc64/sysdep.h (ABORT_TRANSACTION_IMPL,
	ABORT_TRANSACTION): Remove macros.
	* sysdeps/powerpc/sysdep.h (ABORT_TRANSACTION): Likewise.
	* sysdeps/unix/sysv/linux/powerpc/elision-conf.c (elision_init): Set
	__pthread_force_elision iff PPC_FEATURE2_HTM_NOSC is set.
	* sysdeps/unix/sysv/linux/powerpc/powerpc32/sysdep.h,
	sysdeps/unix/sysv/linux/powerpc/powerpc64/sysdep.h
	sysdeps/unix/sysv/linux/powerpc/syscall.S (ABORT_TRANSACTION): Remove
	usage.
	* sysdeps/unix/sysv/linux/powerpc/not-errno.h: Remove file.

Reported-by: Breno Leitão <leitao@debian.org>
2018-09-21 10:18:03 -07:00
Mingli Yu 1214ba06e6 Linux gethostid: Check for NULL value from gethostbyname_r [BZ #23679]
A NULL value can happen with certain gethostbyname_r failures.
2018-09-20 12:02:48 +02:00
Joseph Myers d3a43e49f3 Unify many bits/mman.h headers.
Many bits/mman.h headers for Linux architectures have exactly the same
contents, up to whitespace, comments and the number of leading 0s on
constants.  Specifically, this applies to architectures that, in the
Linux kernel, either have no uapi/asm/mman.h, or have one that
includes asm-generic/mman.h without any changes or additions relevant
to glibc (this last case is the one that applies to Arm).

It's not useful to have to duplicate the set of MAP_* constants in
glibc for all such architectures and any new architectures with that
property.  Thus, this patch creates a generic
sysdeps/unix/sysv/linux/bits/mman.h and removes all the
architecture-specific versions that become unnecessary.

Further unification remains possible after this patch.  For example,
the new bits/mman.h could become bits/mman-map-flags-generic.h so that
it could also be used by architecture-specific bits/mman.h headers on
architectures that use the generic flags but add architecture-specific
ones to them.  That would allow this common set of MAP_* definitions
to be used on ia64 and x86 as well (architectures that include
asm-generic/mman.h from their own uapi/asm/mman.h but define
additional MAP_* values of their own).

Tested with build-many-glibcs.py.

	* sysdeps/unix/sysv/linux/bits/mman.h: New file.
	* sysdeps/unix/sysv/linux/aarch64/bits/mman.h: Remove.
	* sysdeps/unix/sysv/linux/arm/bits/mman.h: Likewise.
	* sysdeps/unix/sysv/linux/m68k/bits/mman.h: Likewise.
	* sysdeps/unix/sysv/linux/microblaze/bits/mman.h: Likewise.
	* sysdeps/unix/sysv/linux/nios2/bits/mman.h: Likewise.
	* sysdeps/unix/sysv/linux/riscv/bits/mman.h: Likewise.
	* sysdeps/unix/sysv/linux/s390/bits/mman.h: Likewise.
	* sysdeps/unix/sysv/linux/sh/bits/mman.h: Likewise.
2018-09-18 16:12:56 +00:00
Joseph Myers 89983cb37c Update siginfo constants from Linux kernel (bug 21286).
As of Linux 4.17, siginfo headers in the Linux kernel have been
largely unified across architectures (so various constants are defined
with common values in include/uapi/asm-generic/siginfo.h even if not
all architectures can generate those particular constants).

This patch makes glibc reflect that unification and the current set of
constants in that header as of Linux 4.18.  Various constants are
added to bits/siginfo-consts.h (under the same feature test macro
conditions as the other constants with the same prefix), and removed
from the ia64 bits/siginfo-consts-arch.h where they were previously
there - this is not limited to constants added by the unification.
Nothing is done about macros that are defined in
include/uapi/asm-generic/siginfo.h with names with leading '__' (some
of those are ia64-specific ones that remain in the ia64
bits/siginfo-consts-arch.h without the leading '__' there).

A consequence of these changes is that TRAP_HWBKPT becomes available
on AArch64 and all other architectures as requested in bug 21286.

Tested for x86_64; tested with build-many-glibcs.py for ia64.

	[BZ #21286]
	* sysdeps/unix/sysv/linux/bits/siginfo-consts.h (SI_DETHREAD): New
	constant.
	[__USE_XOPEN_EXTENDED || __USE_XOPEN2K8] (ILL_BADIADDR): Likewise.
	[__USE_XOPEN_EXTENDED || __USE_XOPEN2K8] (FPE_FLTUNK): Likewise.
	[__USE_XOPEN_EXTENDED || __USE_XOPEN2K8] (FPE_CONDTRAP): Likewise.
	[__USE_XOPEN_EXTENDED || __USE_XOPEN2K8] (SEGV_ACCADI): Likewise.
	[__USE_XOPEN_EXTENDED || __USE_XOPEN2K8] (SEGV_ADIDERR): Likewise.
	[__USE_XOPEN_EXTENDED || __USE_XOPEN2K8] (SEGV_ADIPERR): Likewise.
	[__USE_XOPEN_EXTENDED] (TRAP_BRANCH): Likewise.
	[__USE_XOPEN_EXTENDED] (TRAP_HWBKPT): Likewise.
	[__USE_XOPEN_EXTENDED] (TRAP_UNK): Likweise.
	* sysdeps/unix/sysv/linux/ia64/bits/siginfo-consts-arch.h
	(ILL_BADIADDR): Remove constant.
	(TRAP_BRANCH): Likewise.
	(TRAP_HWBKPT): Likewise.
2018-09-17 12:41:14 +00:00
Joseph Myers 3f7f1d180d Fix MIPS n32 pr_sigpend, pr_sighold, pr_flag type (bug 23656).
As discussed at
<https://sourceware.org/ml/libc-alpha/2018-09/msg00191.html> and
followup discussions, the MIPS n32 definitions of pr_sigpend and
pr_sighold in struct elf_prstatus, and pr_flag in struct elf_prpsinfo,
are wrong to use unsigned long long int; actual n32 core dumps use a
32-bit type there, so userspace unsigned long int is correct for all
MIPS ABIs.  This patch removes the conditionals (also thereby aligning
the structures with other architectures and so facilitating future
unification of different versions of this header).

Tested with build-many-glibcs.py for its MIPS configurations.

	[BZ #23656]
	* sysdeps/unix/sysv/linux/mips/sys/procfs.h (struct elf_prstatus):
	Remove [_MIPS_SIM = _ABIN32] conditional case.
	(struct elf_prpsinfo): Likewise.
2018-09-14 16:02:57 +00:00