Commit Graph

12189 Commits

Author SHA1 Message Date
Samuel Thibault 346ef23f19 hurd: Fix F_*LK* fcntl with __USE_FILE_OFFSET64
struct flock64 uses 64bit values. This introduces other values for F_GETLK,
F_SETLK, F_SETLKW to distinguish between both.

	* sysdeps/mach/hurd/bits/fcntl.h (F_GETLK64, F_SETLK64, F_SETLKW64): New
	macros
	[__USE_FILE_OFFSET64] (F_GETLK, F_SETLK, F_SETLKW): Define to F_GETLK64,
	F_SETLK64, F_SETLKW64, respectively.
	* sysdeps/mach/hurd/f_setlk.c: New file.
	* sysdeps/mach/hurd/f_setlk.h: New file.
	* sysdeps/mach/hurd/Makefile [$(subdir) = io] (sysdeps_routines): Add
	f_setlk.
	* sysdeps/mach/hurd/fcntl.c: Include "f_setlk.h".h".
	(__libc_fcntl): Move non-flock operations to...
	* sysdeps/mach/hurd/vfcntl.c (__libc_vfcntl): ... New file.
	* sysdeps/mach/hurd/fcntl.c (fcntl64): Add missing alias.
2018-11-16 09:41:05 +01:00
Samuel Thibault 8c6c3fb0bc hurd: Fix build with GCC 9
* sysdeps/mach/hurd/dl-sysdep.c (check_no_hidden): Use
	__attribute_copy__ to copy attributes from name. Drop static qualifier
	to avoid warnings about leaf attribute not having effect on static
	functions.
2018-11-14 01:36:44 +01:00
Joseph Myers 0c096dcf14 Fix mips build with GCC 9.
This patch fixes the build for MIPS (o32) with GCC 9 by stopping MIPS
__longjmp from using strong_alias, instead defining the alias
manually, so that the intended effect of not copying the nomips16
attribute is achieved, as explained in the included comment.

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

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

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

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

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

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

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

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

	* sysdeps/arm/arm-ifunc.h [SHARED] (arm_libc_ifunc_hidden_def):
	Use __attribute_copy__ to copy attributes from name.
2018-11-12 23:59:29 +00:00
Joseph Myers 9a7c643ac2 Fix i686 build with GCC 9.
This patch fixes the glibc build for i686 with current mainline GCC,
where there are warnings about inconsistent attributes for aliases in
certain files defining libm IFUNCs.

In three of the files, the aliases were defined in terms of internal
symbols such as __sinf, and copied attributes from file-local
declarations of those functions which lacked the nothrow attribute.
Since the nothrow attribute is present on the declarations from
<math.h> (which include declarations of those __-prefixed functions),
the natural fix was to include <math.h> in those files, replacing the
local declarations.

In the other three files, a more complicated __hidden_ver1 call was
involved in the warnings.  <math.h> has not been included at this
point and, furthermore, it is included indirectly only later in the
source file after macros have been defined to remap a function name
therein.  So there isn't an obvious declaration from which to copy the
attribute and it seems simplest and safest just to add __THROW to the
hidden_ver1 calls.

Tested for i686 (build-many-glibcs.py compilers build for
x86_64-linux-gnu with GCC mainline; full testsuite run with GCC 7).

	* sysdeps/i386/i686/fpu/multiarch/e_expf.c [SHARED]: Use __THROW
	with __hidden_ver1 call.
	* sysdeps/i386/i686/fpu/multiarch/e_log2f.c [SHARED]: Likewise.
	* sysdeps/i386/i686/fpu/multiarch/e_logf.c [SHARED]: Likewise.
	* sysdeps/i386/i686/fpu/multiarch/s_cosf.c: Include <math.h>.
	(__cosf): Do not declare here.
	* sysdeps/i386/i686/fpu/multiarch/s_sincosf.c: Include <math.h>.
	(__sincosf): Do not declare here.
	* sysdeps/i386/i686/fpu/multiarch/s_sinf.c: Include <math.h>.
	(__sinf): Do not declare here.
2018-11-12 18:47:05 +00:00
Joseph Myers 092dfde68f Remove redundant macro definitions from ia64 sfp-machine.h.
After the changes to use the copy attribute, building glibc for ia64
fails, even with older compilers, because
sysdeps/ia64/fpu/sfp-machine.h has a definition of _strong_alias that
now differs from the one in libc-symbols.h.

That definition is a relic of this file coming from libgcc, as are
some other such macro definitions in this file; in the glibc context,
there is no need for those macros, and this patch removes them to fix
the build.

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

	* sysdeps/ia64/fpu/sfp-machine.h (__LITTLE_ENDIAN): Remove.
	(__BIG_ENDIAN): Likewise.
	(__BYTE_ORDER): Likewise.
	(strong_alias): Likewise.
	(_strong_alias): Likewise.
2018-11-12 14:37:45 +00:00
Samuel Thibault 58bb655acb hurd: Document dtable_cloexec size convention.
* sysdeps/mach/hurd/spawni.c (__spawni): Use orig_dtablesize instead
	of dtablesize for allocating dtable_cloexec.
2018-11-11 18:55:24 +01:00
Samuel Thibault 88b26b7e91 Hurd: export _hurd_port_move
* hurd/Versions (_hurd_port_move): Export function.
	* sysdeps/mach/hurd/i386/libc.abilist (_hurd_port_move): Expect
	symbol.
2018-11-10 13:13:12 +00:00
Samuel Thibault 7fa495cdf7 Hurd: Fix ulinks in fd table reallocation
* hurd/hurd/userlink.h (_hurd_userlink_move): New function.
	* hurd/hurd/port.h (_hurd_port_move): New function.
	* sysdeps/mach/hurd/spawni.c (NEW_ULINK_TABLE): New macro.
	(EXPAND_DTABLE): Use NEW_ULINK_TABLE macro for ulink_dtable.
2018-11-10 11:20:12 +00:00
Samuel Thibault 434c34bd8e Hurd: Implement chdir support in posix_spawn
This fixes build-many-glibcs.py on i686-gnu.

Thanks Florian Weimer for the initial version.

* sysdeps/mach/hurd/spawni.c (__spawni): Add ccwdir port. Test and use
it, free it if needed.
(reauthenticate): Test and use ccwdir.
(child_init_port): In non-resetids case, test and use ccwdir.
(child_chdir): New nested function to set ccwdir.
2018-11-10 10:45:13 +00:00
Martin Sebor 1626a1cfcd Add support for GCC 9 attribute copy.
GCC 9 has gained an enhancement to help detect attribute mismatches
between alias declarations and their targets.  It consists of a new
warning, -Wattribute-alias, an enhancement to an existing warning,
-Wmissing-attributes, and a new attribute called copy.

The purpose of the warnings is to help identify either possible bugs
(an alias declared with more restrictive attributes than its target
promises) or optimization or diagnostic opportunities (an alias target
missing some attributes that it could be declared with that might
benefit analysis and code generation).  The purpose of the new
attribute is to easily apply (almost) the same set of attributes
to one declaration as those already present on another.

As expected (and intended) the enhancement triggers warnings for
many alias declarations in Glibc code.  This change, tested on
x86_64-linux, avoids all instances of the new warnings by making
use of the attribute where appropriate.  To fully benefit from
the enhancement Glibc will need to be compiled with
 -Wattribute-alias=2 and remaining warnings reviewed and dealt with
(there are a couple of thousand but most should be straightforward
to deal with).

ChangeLog:

	* include/libc-symbols.h (__attribute_copy__): Define macro unless
	it's already defined.
	(_strong_alias): Use __attribute_copy__.
	(_weak_alias,  __hidden_ver1,  __hidden_nolink2): Same.
	* misc/sys/cdefs.h (__attribute_copy__): New macro.
	* sysdeps/x86_64/multiarch/memchr.c (memchr): Use __attribute_copy__.
	* sysdeps/x86_64/multiarch/memcmp.c (memcmp): Same.
	* sysdeps/x86_64/multiarch/mempcpy.c (mempcpy): Same.
	* sysdeps/x86_64/multiarch/memset.c (memset): Same.
	* sysdeps/x86_64/multiarch/stpcpy.c (stpcpy): Same.
	* sysdeps/x86_64/multiarch/strcat.c (strcat): Same.
	* sysdeps/x86_64/multiarch/strchr.c (strchr): Same.
	* sysdeps/x86_64/multiarch/strcmp.c (strcmp): Same.
	* sysdeps/x86_64/multiarch/strcpy.c (strcpy): Same.
	* sysdeps/x86_64/multiarch/strcspn.c (strcspn): Same.
	* sysdeps/x86_64/multiarch/strlen.c (strlen): Same.
	* sysdeps/x86_64/multiarch/strncmp.c (strncmp): Same.
	* sysdeps/x86_64/multiarch/strncpy.c (strncpy): Same.
	* sysdeps/x86_64/multiarch/strnlen.c (strnlen): Same.
	* sysdeps/x86_64/multiarch/strpbrk.c (strpbrk): Same.
	* sysdeps/x86_64/multiarch/strrchr.c (strrchr): Same.
	* sysdeps/x86_64/multiarch/strspn.c (strspn): Same.
2018-11-09 17:24:12 -07: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
H.J. Lu d524fa6c35 Check multiple NT_GNU_PROPERTY_TYPE_0 notes [BZ #23509]
Linkers group input note sections with the same name into one output
note section with the same name.  One output note section is placed in
one PT_NOTE segment.  Since new linkers merge input .note.gnu.property
sections into one output .note.gnu.property section, there is only
one NT_GNU_PROPERTY_TYPE_0 note in one PT_NOTE segment with new linkers.
Since older linkers treat input .note.gnu.property section as a generic
note section and just concatenate all input .note.gnu.property sections
into one output .note.gnu.property section without merging them, we may
see multiple NT_GNU_PROPERTY_TYPE_0 notes in one PT_NOTE segment with
older linkers.

When an older linker is used to created the program on CET-enabled OS,
the linker output has a single .note.gnu.property section with multiple
NT_GNU_PROPERTY_TYPE_0 notes, some of which have IBT and SHSTK enable
bits set even if the program isn't CET enabled.  Such programs will
crash on CET-enabled machines.  This patch updates the note parser:

1. Skip note parsing if a NT_GNU_PROPERTY_TYPE_0 note has been processed.
2. Check multiple NT_GNU_PROPERTY_TYPE_0 notes.

	[BZ #23509]
	* sysdeps/x86/dl-prop.h (_dl_process_cet_property_note): Skip
	note parsing if a NT_GNU_PROPERTY_TYPE_0 note has been processed.
	Update the l_cet field when processing NT_GNU_PROPERTY_TYPE_0 note.
	Check multiple NT_GNU_PROPERTY_TYPE_0 notes.
	* sysdeps/x86/link_map.h (l_cet): Expand to 3 bits,  Add
	lc_unknown.
2018-11-08 10:07:10 -08: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
Samuel Thibault fc1c7bdc6d hurd: Fix last-minute refactoring
* sysdeps/mach/hurd/msync.c (msync): Fix syntax.
2018-11-04 02:11:16 +01:00
Samuel Thibault 2e96e9808e hurd: Support msync
* sysdeps/mach/hurd/msync.c: New file.
2018-11-03 22:47:57 +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
Fredrik Noring 8e3c00db16 MIPS: Use `.set mips2' to emulate LL/SC for the R5900 too
GAS treats the R5900 as MIPS III, with some modifications.  The MIPS III
designation means that the GNU C Library will try to assemble the LL and
SC instructions, even though they are not implemented in the R5900.  GAS
will therefore produce the following errors:

Error: opcode not supported on this processor: r5900 (mips3) `ll $2,0($4)'
Error: opcode not supported on this processor: r5900 (mips3) `sc $6,0($4)'

The MIPS II ISA override as used here enables the kernel to trap and
emulate the LL and SC instructions, as required.

This change has been tested by compiling the GNU C Library 2.27 with a
GCC 8.2.0 cross-compiler for mipsr5900el-unknown-linux-gnu under Gentoo.

	* sysdeps/mips/sys/tas.h (_test_and_set): Handle the R5900 CPU
	with the ISA override.
2018-11-01 14:36:48 +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
Samuel Thibault a67377e7f7 hurd: Fix errno* generation
* sysdeps/mach/hurd/errnos.awk: Avoid printing errnos.d.
	* sysdeps/gnu/errlist.c (EIEIO): Move text to...
	* manual/errno.texi (EIEIO): ... here.
	* sysdeps/gnu/errlist.c (EIEIO): Regenerate.
	* sysdeps/mach/hurd/bits/errno.h: Regenerate.
2018-10-31 10:32:39 +01:00
Samuel Thibault 3ed7c33fa2 hurd: Fix build
* sysdeps/gnu/errlist.c (EIEIO): Fix comment marker.
2018-10-31 09:17:05 +01:00
Samuel Thibault e3a88b3e9d hurd: Document how to translate EIEIO error message
* sysdeps/gnu/errlist.c (EIEIO): Document how translators should
	translate the error message.
2018-10-31 01:49:43 +01:00
Andreas Schwab 2dd12baa04 RISC-V: properly terminate call chain (bug 23125)
Mark the ra register as undefined in _start, so that unwinding through
main works correctly.  Also, don't use a tail call so that ra points after
the call to __libc_start_main, not after the previous call.
2018-10-30 12:07:25 +01:00
Samuel Thibault 5c81be5340 hurd: Fix race between calling RPC and handling a signal
* sysdeps/mach/hurd/i386/intr-msg.h (INTR_MSG_TRAP): Make
	_hurd_intr_rpc_msg_about_to global point to start of controlled
	assembly snippet. Make it check canceled flag.
	* hurd/hurdsig.c (_hurdsig_abort_rpcs): Only mutate thread if it passed
	the _hurd_intr_rpc_msg_about_to point.
	* hurd/intr-msg.c (_hurd_intr_rpc_mach_msg): Remove comment on mutation
	issue, remove cancel flag check.
2018-10-28 13:41:51 +01:00
Szabolcs Nagy ba5b14c761 i64: fix missing exp2f, log2f and powf symbols in libm.a [BZ #23822]
When new symbol versions were introduced without SVID compatible
error handling the exp2f, log2f and powf symbols were accidentally
removed from the ia64 lim.a.  The regression was introduced by
the commits

f5f0f52651
New expf and exp2f version without SVID compat wrapper

72d3d28108
New symbol version for logf, log2f and powf without SVID compat

With WEAK_LIBM_ENTRY(foo), there is a hidden __foo and weak foo
symbol definition in both SHARED and !SHARED build.

	[BZ #23822]
	* sysdeps/ia64/fpu/e_exp2f.S (exp2f): Use WEAK_LIBM_ENTRY.
	* sysdeps/ia64/fpu/e_log2f.S (log2f): Likewise.
	* sysdeps/ia64/fpu/e_exp2f.S (powf): Likewise.
2018-10-26 14:39:42 +01: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
Samuel Thibault d026efea0f hurd: XFAIL absence of C11 threads implementation
* sysdeps/mach/hurd/i386/Makefile [$(subdir) = conform]
	(test-xfail-ISO11/threads.h/linknamespace,
	test-xfail-ISO11/threads.h/conform): Add.
2018-10-25 01:31:09 +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
H.J. Lu 7cc65773f0 x86: Support RDTSCP for benchtests
RDTSCP waits until all previous instructions have executed and all
previous loads are globally visible before reading the counter.  RDTSC
doesn't wait until all previous instructions have been executed before
reading the counter.  All x86 processors since 2010 support RDTSCP
instruction.  This patch adds RDTSCP support to benchtests.

	* benchtests/Makefile (CPPFLAGS-nonlib): Add -DUSE_RDTSCP if
	USE_RDTSCP is defined.
	* sysdeps/x86/hp-timing.h (HP_TIMING_NOW): Use RDTSCP if
	USE_RDTSCP is defined.
2018-10-24 02:19:34 -07:00
Adhemerval Zanella c3d8dc45c9 x86: Fix Haswell strong flags (BZ#23709)
Th commit 'Disable TSX on some Haswell processors.' (2702856bf4) changed the
default flags for Haswell models.  Previously, new models were handled by the
default switch path, which assumed a Core i3/i5/i7 if AVX is available. After
the patch, Haswell models (0x3f, 0x3c, 0x45, 0x46) do not set the flags
Fast_Rep_String, Fast_Unaligned_Load, Fast_Unaligned_Copy, and
Prefer_PMINUB_for_stringop (only the TSX one).

This patch fixes it by disentangle the TSX flag handling from the memory
optimization ones.  The strstr case cited on patch now selects the
__strstr_sse2_unaligned as expected for the Haswell cpu.

Checked on x86_64-linux-gnu.

	[BZ #23709]
	* sysdeps/x86/cpu-features.c (init_cpu_features): Set TSX bits
	independently of other flags.
2018-10-23 14:57:02 -03: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
H.J. Lu 2dd8e58cc5 x86: Don't include <x86intrin.h>
Use __builtin_ia32_rdtsc directly since including <x86intrin.h> makes
building glibc very slow.  On Intel Core i5-6260U, this patch reduces
x86-64 build time from 8 minutes 33 seconds to 3 minutes 48 seconds
with "make -j4" and GCC 8.2.1.

	* sysdeps/x86/hp-timing.h: Don't include <x86intrin.h>.
	(HP_TIMING_NOW): Replace _rdtsc with __builtin_ia32_rdtsc.
2018-10-21 00:37:29 -07: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
David S. Miller 0a271c8f25 Regenerate sparc ulps.
* sysdeps/sparc/fpu/libm-test-ulps: Regenerated.
2018-10-18 11:43:56 -07:00
H.J. Lu 72771e5375 x86: Use _rdtsc intrinsic for HP_TIMING_NOW
Since _rdtsc intrinsic is supported in GCC 4.9, we can use it for
HP_TIMING_NOW.  This patch

1. Create x86 hp-timing.h to replace i686 and x86_64 hp-timing.h.
2. Move MINIMUM_ISA from init-arch.h to isa.h so that x86 hp-timing.h
can check minimum x86 ISA to decide if _rdtsc can be used.

NB: Checking if __i686__ isn't sufficient since __i686__ may not be
defined when building for i686 class processors.

	* sysdeps/i386/init-arch.h: Removed.
	* sysdeps/i386/i586/init-arch.h: Likewise.
	* sysdeps/i386/i686/init-arch.h: Likewise.
	* sysdeps/i386/i686/hp-timing.h: Likewise.
	* sysdeps/x86_64/hp-timing.h: Likewise.
	* sysdeps/i386/isa.h: New file.
	* sysdeps/i386/i586/isa.h: Likewise.
	* sysdeps/i386/i686/isa.h: Likewise.
	* sysdeps/x86_64/isa.h: Likewise.
	* sysdeps/x86/hp-timing.h: New file.
	* sysdeps/x86/init-arch.h: Include <isa.h>.
2018-10-17 15:16:45 -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
Andreas Schwab ce5a7de6cd Don't reduce test timeout to less than default
This removes all overrides of TIMEOUT that are less than or equal to the
default timeout.
2018-10-17 09:34:13 +02:00
Steve Ellcey f0da0bcf8b Remove extra space at end of line. 2018-10-16 11:02:03 -07:00
Anton Youdkevitch 75c1aee500 aarch64: optimized memcpy implementation for thunderx2
Since aligned loads and stores are huge performance
advantage the implementation always tries to do aligned
access. Among the cases when src and dst addresses are
aligned or unaligned evenly there are cases of not evenly
unaligned src and dst. For such cases (if the length is
big enough) ext instruction is used to merge-and-shift
two memory chunks loaded from two adjacent aligned
locations and then the adjusted chunk gets stored to
aligned address.

Performance gain against the current T2 implementation:
     memcpy-large: 65K-32M: +40% - +10%
     memcpy-walk:  128-32M: +20% - +2%
2018-10-16 11:00:27 -07: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