Commit Graph

10 Commits

Author SHA1 Message Date
Joseph Myers 35ade9f11b Adjust kernel-features.h defaults for socket syscalls.
This patch adjusts the defaults for kernel-features.h macros relating
to availability of accept4, recvmmsg and sendmmsg.  It is not intended
to affect which macros end up getting defined in any configuration.

At present, all architectures with syscalls for those functions need
to define __ASSUME_*_SYSCALL macros; in particular, any new
architecture needs its own kernel-features.h file for that purpose,
though it may not otherwise need such a header.  Those macros are then
used together with __ASSUME_SOCKETCALL to define macros for whether
the functions in question are available.

This patch changes the defaults so that the syscalls are assumed to be
available by default with recent-enough kernels, and it is the
responsibility of architecture headers to undefine the macros if they
are unavailable in supported kernels at least as recent as the version
where the architecture-independent functionality was introduced.  The
__ASSUME_<function> macros are defaulted similarly instead of being
defined based on other macros (defining based on other macros would no
longer work because the #undefs appear after the generic header is
included), so where the syscall being unavailable means the function
is unavailable this means the architecture header has to undefine the
__ASSUME_<function> macro; this only affects __ASSUME_ACCEPT4 for
ia64, as other cases where the syscalls were added late enough to be
relevant with current kernel version requirements are all on
socketcall architectures.

As a consequence, the AArch64 and Nios II kernel-features.h header
files are removed, and others simplified.  When the minimum kernel
version becomes 4.3 or later on all architectures, the syscalls in
question can just be assumed unconditionally, permitting further
simplification.

Tested for x86_64, x86 and powerpc (that installed shared libraries
are unchanged by the patch, and testsuite for x86_64 and x86).

	* sysdeps/unix/sysv/linux/kernel-features.h
	(__ASSUME_ACCEPT4_SYSCALL): Define unconditionally.
	(__ASSUME_ACCEPT4): Likewise.
	[__LINUX_KERNEL_VERSION >= 0x020621] (__ASSUME_RECVMMSG_SYSCALL):
	Define.
	[__LINUX_KERNEL_VERSION >= 0x020621] (__ASSUME_RECVMMSG):
	Likewise.
	[__LINUX_KERNEL_VERSION >= 0x030000] (__ASSUME_SENDMMSG_SYSCALL):
	Likewise.
	[__LINUX_KERNEL_VERSION >= 0x030000] (__ASSUME_SENDMMSG):
	Likewise.
	* sysdeps/unix/sysv/linux/aarch64/kernel-features.h: Remove file.
	* sysdeps/unix/sysv/linux/nios2/kernel-features.h: Likewise.
	* sysdeps/unix/sysv/linux/alpha/kernel-features.h
	(__ASSUME_RECVMMSG_SYSCALL): Do not define.
	(__ASSUME_ACCEPT4_SYSCALL): Likewise.
	(__ASSUME_SENDMMSG_SYSCALL): Likewise.
	* sysdeps/unix/sysv/linux/arm/kernel-features.h
	(__ASSUME_RECVMMSG_SYSCALL): Likewise.
	(__ASSUME_ACCEPT4_SYSCALL): Likewise.
	(__ASSUME_SENDMMSG_SYSCALL): Likewise.
	* sysdeps/unix/sysv/linux/hppa/kernel-features.h
	(__ASSUME_ACCEPT4_SYSCALL): Likewise.
	(__ASSUME_RECVMMSG_SYSCALL): Likewise.
	(__ASSUME_SENDMMSG_SYSCALL): Likewise.
	* sysdeps/unix/sysv/linux/i386/kernel-features.h
	[__LINUX_KERNEL_VERSION >= 0x020621] (__ASSUME_RECVMMSG_SYSCALL):
	Likewise.
	[__LINUX_KERNEL_VERSION >= 0x030000] (__ASSUME_SENDMMSG_SYSCALL):
	Likewise.
	(__ASSUME_ACCEPT4_SYSCALL): Undefine if [__LINUX_KERNEL_VERSION <
	0x040300] instead of defining if [__LINUX_KERNEL_VERSION >=
	0x040300].
	* sysdeps/unix/sysv/linux/ia64/kernel-features.h
	(__ASSUME_RECVMMSG_SYSCALL): Do not define.
	(__ASSUME_SENDMMSG_SYSCALL): Likewise.
	(__ASSUME_ACCEPT4_SYSCALL): Undefine if [__LINUX_KERNEL_VERSION <
	0x030300] instead of defining if [__LINUX_KERNEL_VERSION >=
	0x030300].
	[__LINUX_KERNEL_VERSION < 0x030300] (__ASSUME_ACCEPT4): Undefine.
	* sysdeps/unix/sysv/linux/m68k/kernel-features.h
	(__ASSUME_ACCEPT4_SYSCALL): Undefine if [__LINUX_KERNEL_VERSION <
	0x040300] instead of defining if [__LINUX_KERNEL_VERSION >=
	0x040300].
	(__ASSUME_RECVMMSG_SYSCALL): Likewise.
	(__ASSUME_SENDMMSG_SYSCALL): Likewise.
	* sysdeps/unix/sysv/linux/microblaze/kernel-features.h
	(__ASSUME_ACCEPT4_SYSCALL): Do not define.
	(__ASSUME_RECVMMSG_SYSCALL): Likewise.
	(__ASSUME_SENDMMSG_SYSCALL): Undefine if [__LINUX_KERNEL_VERSION <
	0x030300] instead of defining if [__LINUX_KERNEL_VERSION >=
	0x030300].
	* sysdeps/unix/sysv/linux/mips/kernel-features.h
	(__ASSUME_ACCEPT4_SYSCALL): Do not define.
	(__ASSUME_RECVMMSG_SYSCALL): Likewise.
	(__ASSUME_SENDMMSG_SYSCALL): Likewise.
	* sysdeps/unix/sysv/linux/powerpc/kernel-features.h
	(__ASSUME_ACCEPT4_SYSCALL): Likewise.
	(__ASSUME_RECVMMSG_SYSCALL): Likewise.
	(__ASSUME_SENDMMSG_SYSCALL): Likewise.
	* sysdeps/unix/sysv/linux/s390/kernel-features.h
	(__ASSUME_ACCEPT4_SYSCALL): Undefine if [__LINUX_KERNEL_VERSION <
	0x040300] instead of defining if [__LINUX_KERNEL_VERSION >=
	0x040300].
	(__ASSUME_RECVMMSG_SYSCALL): Likewise.
	(__ASSUME_SENDMMSG_SYSCALL): Likewise.
	* sysdeps/unix/sysv/linux/sh/kernel-features.h
	(__ASSUME_ACCEPT4_SYSCALL): Do not define.
	(__ASSUME_RECVMMSG_SYSCALL): Likewise.
	(__ASSUME_SENDMMSG_SYSCALL): Likewise.
	* sysdeps/unix/sysv/linux/sparc/kernel-features.h
	(__ASSUME_ACCEPT4_SYSCALL): Likewise.
	(__ASSUME_RECVMMSG_SYSCALL): Likewise.
	(__ASSUME_SENDMMSG_SYSCALL): Likewise.
	* sysdeps/unix/sysv/linux/tile/kernel-features.h
	(__ASSUME_ACCEPT4_SYSCALL): Likewise.
	(__ASSUME_RECVMMSG_SYSCALL): Likewise.
	(__ASSUME_SENDMMSG_SYSCALL): Likewise.
	* sysdeps/unix/sysv/linux/x86_64/kernel-features.h
	(__ASSUME_ACCEPT4_SYSCALL): Likewise.
	[__LINUX_KERNEL_VERSION >= 0x020621] (__ASSUME_RECVMMSG_SYSCALL):
	Likewise.
	[__LINUX_KERNEL_VERSION >= 0x030000] (__ASSUME_SENDMMSG_SYSCALL):
	Likewise.
2016-03-15 21:09:33 +00:00
Joseph Myers ad1b6d85ba Remove kernel-features.h conditionals on pre-3.2 kernels.
This patch follows up on the increase in minimum kernel version by
removing conditionals in non-x86, non-x86_64 kernel-features.h headers
that are now constant for all supported kernel versions.

	* sysdeps/unix/sysv/linux/alpha/kernel-features.h
	[__LINUX_KERNEL_VERSION >= 0x020621]: Make code unconditional.
	[__LINUX_KERNEL_VERSION >= 0x030200]: Likewise.
	[__LINUX_KERNEL_VERSION < 0x020621]: Remove conditional code.
	* sysdeps/unix/sysv/linux/arm/kernel-features.h
	[__LINUX_KERNEL_VERSION >= 0x020621]: Make code unconditional.
	[__LINUX_KERNEL_VERSION >= 0x020624]: Likewise.
	[__LINUX_KERNEL_VERSION >= 0x030000]: Likewise.
	* sysdeps/unix/sysv/linux/hppa/kernel-features.h
	[__LINUX_KERNEL_VERSION >= 0x020622]: Likewise.
	[__LINUX_KERNEL_VERSION >= 0x030100]: Likewise.
	[__LINUX_KERNEL_VERSION < 0x020625]: Remove conditional code.
	* sysdeps/unix/sysv/linux/ia64/kernel-features.h
	[__LINUX_KERNEL_VERSION >= 0x020621]: Make code unconditional.
	[__LINUX_KERNEL_VERSION >= 0x030000]: Likewise.
	* sysdeps/unix/sysv/linux/m68k/kernel-features.h
	[__LINUX_KERNEL_VERSION < 0x030000]: Remove conditional code.
	* sysdeps/unix/sysv/linux/microblaze/kernel-features.h
	[__LINUX_KERNEL_VERSION >= 0x020621]: Make code unconditional.
	[__LINUX_KERNEL_VERSION < 0x020621]: Remove conditional code.
	[__LINUX_KERNEL_VERSION < 0x020625]: Likewise.
	* sysdeps/unix/sysv/linux/mips/kernel-features.h
	[__LINUX_KERNEL_VERSION >= 0x020621]: Make code unconditional.
	[__LINUX_KERNEL_VERSION >= 0x030100]: Likewise.
	[_MIPS_SIM == _ABIN32 && __LINUX_KERNEL_VERSION < 0x020623]:
	Remove conditional code.
	* sysdeps/unix/sysv/linux/powerpc/kernel-features.h
	[__LINUX_KERNEL_VERSION >= 0x020625]: Make code unconditional.
	[__LINUX_KERNEL_VERSION >= 0x030000]: Likewise.
	* sysdeps/unix/sysv/linux/sh/kernel-features.h
	[__LINUX_KERNEL_VERSION >= 0x020625]: Likewise.
	[__LINUX_KERNEL_VERSION >= 0x030000]: Likewise.
	[__LINUX_KERNEL_VERSION < 0x020625]: Remove conditional code.
	* sysdeps/unix/sysv/linux/sparc/kernel-features.h
	[__LINUX_KERNEL_VERSION >= 0x020621]: Make code unconditional.
	[__LINUX_KERNEL_VERSION >= 0x030000]: Likewise.
	* sysdeps/unix/sysv/linux/tile/kernel-features.h
	[__LINUX_KERNEL_VERSION >= 0x030000]: Likewise.
2016-02-26 16:17:25 +00:00
Joseph Myers f7a9f785e5 Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
Joseph Myers e5a5315e2d Use direct socket syscalls for new kernels on i386, m68k, microblaze, sh.
Now that we have __ASSUME_* macros for direct socket syscalls to use
them instead of socketcall when they can be assumed to be available on
socketcall architectures, this patch defines those macros when
appropriate for i386, m68k, microblaze and sh (for 4.3, 4.3, all
supported kernels and 2.6.37, respectively; the only use of socketcall
support on microblaze is it allows accept4 and sendmmsg to be
supported on a wider range of kernel versions).

David, it seems that 32-bit SPARC is the only architecture supported
by glibc that still lacks these direct syscalls.  It would be good to
get them added to the SPARC kernel so we can eventually eliminate
socketcall support in glibc (and thereby just use entries in
sysdeps/unix/syscalls.list for most of these functions) when we can
assume new-enough kernels.

Tested for i386 (testsuite, and that installed shared libraries are
unchanged by this patch - not using a new enough kernel, so this
doesn't actually test much, but the i386 and m68k code is essentially
the same as that already in use for s390).

	* sysdeps/unix/sysv/linux/i386/kernel-features.h
	[__LINUX_KERNEL_VERSION >= 0x040300] (__ASSUME_SOCKET_SYSCALL):
	New macro.
	[__LINUX_KERNEL_VERSION >= 0x040300]
	(__ASSUME_SOCKETPAIR_SYSCALL): Likewise.
	[__LINUX_KERNEL_VERSION >= 0x040300] (__ASSUME_BIND_SYSCALL):
	Likewise.
	[__LINUX_KERNEL_VERSION >= 0x040300] (__ASSUME_CONNECT_SYSCALL):
	Likewise.
	[__LINUX_KERNEL_VERSION >= 0x040300] (__ASSUME_LISTEN_SYSCALL):
	Likewise.
	[__LINUX_KERNEL_VERSION >= 0x040300] (__ASSUME_ACCEPT4_SYSCALL):
	Likewise.
	[__LINUX_KERNEL_VERSION >= 0x040300]
	(__ASSUME_ACCEPT4_FOR_ACCEPT_SYSCALL): Likewise.
	[__LINUX_KERNEL_VERSION >= 0x040300]
	(__ASSUME_GETSOCKOPT_SYSCALL): Likewise.
	[__LINUX_KERNEL_VERSION >= 0x040300]
	(__ASSUME_SETSOCKOPT_SYSCALL): Likewise.
	[__LINUX_KERNEL_VERSION >= 0x040300]
	(__ASSUME_GETSOCKNAME_SYSCALL): Likewise.
	[__LINUX_KERNEL_VERSION >= 0x040300]
	(__ASSUME_GETPEERNAME_SYSCALL): Likewise.
	[__LINUX_KERNEL_VERSION >= 0x040300] (__ASSUME_SENDTO_SYSCALL):
	Likewise.
	[__LINUX_KERNEL_VERSION >= 0x040300]
	(__ASSUME_SENDTO_FOR_SEND_SYSCALL): Likewise.
	[__LINUX_KERNEL_VERSION >= 0x040300] (__ASSUME_SENDMSG_SYSCALL):
	Likewise.
	[__LINUX_KERNEL_VERSION >= 0x040300] (__ASSUME_RECVFROM_SYSCALL):
	Likewise.
	[__LINUX_KERNEL_VERSION >= 0x040300]
	(__ASSUME_RECVFROM_FOR_RECV_SYSCALL): Likewise.
	[__LINUX_KERNEL_VERSION >= 0x040300] (__ASSUME_RECVMSG_SYSCALL):
	Likewise.
	[__LINUX_KERNEL_VERSION >= 0x040300] (__ASSUME_SHUTDOWN_SYSCALL):
	Likewise.
	* sysdeps/unix/sysv/linux/m68k/kernel-features.h
	[__LINUX_KERNEL_VERSION >= 0x040300] (__ASSUME_RECVMMSG_SYSCALL):
	Likewise.
	[__LINUX_KERNEL_VERSION >= 0x040300] (__ASSUME_SENDMMSG_SYSCALL):
	Likewise.
	[__LINUX_KERNEL_VERSION >= 0x040300] (__ASSUME_SOCKET_SYSCALL):
	Likewise.
	[__LINUX_KERNEL_VERSION >= 0x040300]
	(__ASSUME_SOCKETPAIR_SYSCALL): Likewise.
	[__LINUX_KERNEL_VERSION >= 0x040300] (__ASSUME_BIND_SYSCALL):
	Likewise.
	[__LINUX_KERNEL_VERSION >= 0x040300] (__ASSUME_CONNECT_SYSCALL):
	Likewise.
	[__LINUX_KERNEL_VERSION >= 0x040300] (__ASSUME_LISTEN_SYSCALL):
	Likewise.
	[__LINUX_KERNEL_VERSION >= 0x040300] (__ASSUME_ACCEPT4_SYSCALL):
	Likewise.
	[__LINUX_KERNEL_VERSION >= 0x040300]
	(__ASSUME_ACCEPT4_FOR_ACCEPT_SYSCALL): Likewise.
	[__LINUX_KERNEL_VERSION >= 0x040300]
	(__ASSUME_GETSOCKOPT_SYSCALL): Likewise.
	[__LINUX_KERNEL_VERSION >= 0x040300]
	(__ASSUME_SETSOCKOPT_SYSCALL): Likewise.
	[__LINUX_KERNEL_VERSION >= 0x040300]
	(__ASSUME_GETSOCKNAME_SYSCALL): Likewise.
	[__LINUX_KERNEL_VERSION >= 0x040300]
	(__ASSUME_GETPEERNAME_SYSCALL): Likewise.
	[__LINUX_KERNEL_VERSION >= 0x040300] (__ASSUME_SENDTO_SYSCALL):
	Likewise.
	[__LINUX_KERNEL_VERSION >= 0x040300]
	(__ASSUME_SENDTO_FOR_SEND_SYSCALL): Likewise.
	[__LINUX_KERNEL_VERSION >= 0x040300] (__ASSUME_SENDMSG_SYSCALL):
	Likewise.
	[__LINUX_KERNEL_VERSION >= 0x040300] (__ASSUME_RECVFROM_SYSCALL):
	Likewise.
	[__LINUX_KERNEL_VERSION >= 0x040300]
	(__ASSUME_RECVFROM_FOR_RECV_SYSCALL): Likewise.
	[__LINUX_KERNEL_VERSION >= 0x040300] (__ASSUME_RECVMSG_SYSCALL):
	Likewise.
	[__LINUX_KERNEL_VERSION >= 0x040300] (__ASSUME_SHUTDOWN_SYSCALL):
	Likewise.
	* sysdeps/unix/sysv/linux/microblaze/kernel-features.h
	(__ASSUME_SOCKET_SYSCALL): Likewise.
	(__ASSUME_BIND_SYSCALL): Likewise.
	(__ASSUME_CONNECT_SYSCALL): Likewise.
	(__ASSUME_LISTEN_SYSCALL): Likewise.
	(__ASSUME_ACCEPT_SYSCALL): Likewise.
	(__ASSUME_GETSOCKNAME_SYSCALL): Likewise.
	(__ASSUME_GETPEERNAME_SYSCALL): Likewise.
	(__ASSUME_SOCKETPAIR_SYSCALL): Likewise.
	(__ASSUME_SEND_SYSCALL): Likewise.
	(__ASSUME_SENDTO_SYSCALL): Likewise.
	(__ASSUME_RECV_SYSCALL): Likewise.
	(__ASSUME_RECVFROM_SYSCALL): Likewise.
	(__ASSUME_SHUTDOWN_SYSCALL): Likewise.
	(__ASSUME_GETSOCKOPT_SYSCALL): Likewise.
	(__ASSUME_SETSOCKOPT_SYSCALL): Likewise.
	(__ASSUME_SENDMSG_SYSCALL): Likewise.
	(__ASSUME_RECVMSG_SYSCALL): Likewise.
	* sysdeps/unix/sysv/linux/sh/kernel-features.h
	[__LINUX_KERNEL_VERSION >= 0x020625] (__ASSUME_SOCKET_SYSCALL):
	Likewise.
	[__LINUX_KERNEL_VERSION >= 0x020625] (__ASSUME_BIND_SYSCALL):
	Likewise.
	[__LINUX_KERNEL_VERSION >= 0x020625] (__ASSUME_CONNECT_SYSCALL):
	Likewise.
	[__LINUX_KERNEL_VERSION >= 0x020625] (__ASSUME_LISTEN_SYSCALL):
	Likewise.
	[__LINUX_KERNEL_VERSION >= 0x020625] (__ASSUME_ACCEPT_SYSCALL):
	Likewise.
	[__LINUX_KERNEL_VERSION >= 0x020625]
	(__ASSUME_GETSOCKNAME_SYSCALL): Likewise.
	[__LINUX_KERNEL_VERSION >= 0x020625]
	(__ASSUME_GETPEERNAME_SYSCALL): Likewise.
	[__LINUX_KERNEL_VERSION >= 0x020625]
	(__ASSUME_SOCKETPAIR_SYSCALL): Likewise.
	[__LINUX_KERNEL_VERSION >= 0x020625] (__ASSUME_SEND_SYSCALL):
	Likewise.
	[__LINUX_KERNEL_VERSION >= 0x020625] (__ASSUME_SENDTO_SYSCALL):
	Likewise.
	[__LINUX_KERNEL_VERSION >= 0x020625] (__ASSUME_RECV_SYSCALL):
	Likewise.
	[__LINUX_KERNEL_VERSION >= 0x020625] (__ASSUME_RECVFROM_SYSCALL):
	Likewise.
	[__LINUX_KERNEL_VERSION >= 0x020625] (__ASSUME_SHUTDOWN_SYSCALL):
	Likewise.
	[__LINUX_KERNEL_VERSION >= 0x020625]
	(__ASSUME_GETSOCKOPT_SYSCALL): Likewise.
	[__LINUX_KERNEL_VERSION >= 0x020625]
	(__ASSUME_SETSOCKOPT_SYSCALL): Likewise.
	[__LINUX_KERNEL_VERSION >= 0x020625] (__ASSUME_SENDMSG_SYSCALL):
	Likewise.
	[__LINUX_KERNEL_VERSION >= 0x020625] (__ASSUME_RECVMSG_SYSCALL):
	Likewise.
2015-12-09 20:59:43 +00:00
Joseph Myers b168057aaa Update copyright dates with scripts/update-copyrights. 2015-01-02 16:29:47 +00:00
Joseph Myers 5e7698c6f1 Reduce kernel-features.h duplication.
This patch reduces duplication between different architectures'
kernel-features.h files by making the architecture-independent file
define various macros unconditionally (instead of only for a
particular list of architectures), with the architecture-specific
files then undefining the macros if necessary.

Specifically, __ASSUME_O_CLOEXEC (O_CLOEXEC flag to open) and
__ASSUME_SOCK_CLOEXEC (SOCK_NONBLOCK and SOCK_CLOEXEC flags to socket)
are supported on all architectures as of 2.6.32 or the minimum kernel
version for the architecture if later.  For __ASSUME_IN_NONBLOCK,
__ASSUME_PIPE2, __ASSUME_EVENTFD2, __ASSUME_SIGNALFD4 and
__ASSUME_DUP3, the relevant syscalls were added for alpha in 2.6.33
but otherwise the features are available as of 2.6.32.  For
__ASSUME_UTIMES, support is everywhere in 2.6.32 except for
asm-generic architectures and hppa.

Although those were the main cases of duplication among
kernel-features.h files, some other cases of unnecessary definitions
were also cleaned up: the hppa file defined various macros that were
either no longer used at all, or defined by the main file by default
anyway, the ia64 file had duplicative definitions of __ASSUME_PSELECT
and __ASSUME_PPOLL, while mips had such a definition of
__ASSUME_IPC64.

Really, rather than being defined in the main file then undefined for
asm-generic architectures, __ASSUME_UTIMES should become an
hppa-specific macro.  Given that __ASSUME_ATFCTS and
__ASSUME_UTIMENSAT are now always true, the only live __ASSUME_UTIMES
conditional is in sysdeps/unix/sysv/linux/utimes.c, which is not used
for asm-generic architectures.  I think the desired state would be an
hppa-specific file (that includes sysdeps/unix/sysv/linux/utimes.c if
__ASSUME_UTIMES, and otherwise has fallback code), with the fallback
code being removed from the main utimes.c.  But I think that's most
reasonably a separate cleanup once __ASSUME_ATFCTS and
__ASSUME_UTIMESAT have both had conditional code cleaned up.

Given this patch, I think it's straightforward to move non-ex-ports
architectures to having their own kernel-features.h files, like
ex-ports architectures, rather than conditionals in the main file
(i.e., such a move won't require the architecture-specific file to
contain anything that isn't genuinely architecture-specific), and
would encourage architecture maintainers to do so.

Tested x86_64 that the installed shared libraries are unchanged by
this patch.  Note that on some architectures this *will* cause
__ASSUME_* macros to be defined in cases where they weren't previously
but should have been (but this is just optimization, not a fix to a
user-visible bug, so doesn't need a bug report in Bugzilla).

	* sysdeps/unix/sysv/linux/kernel-features.h (__ASSUME_UTIMES):
	Define unconditionally.
	(__ASSUME_O_CLOEXEC): Likewise.
	(__ASSUME_SOCK_CLOEXEC): Likewise.
	(__ASSUME_IN_NONBLOCK): Likewise.
	(__ASSUME_PIPE2): Likewise.
	(__ASSUME_EVENTFD2): Likewise.
	(__ASSUME_SIGNALFD4): Likewise.
	(__ASSUME_DUP3): Likewise.
	* sysdeps/unix/sysv/linux/aarch64/kernel-features.h
	(__ASSUME_DUP3): Do not define.
	(__ASSUME_EVENTFD2): Likewise.
	(__ASSUME_IN_NONBLOCK): Likewise.
	(__ASSUME_O_CLOEXEC): Likewise.
	(__ASSUME_PIPE2): Likewise.
	(__ASSUME_SIGNALFD4): Likewise.
	(__ASSUME_SOCK_CLOEXEC): Likewise.
	(__ASSUME_UTIMES): Undefine.
	* sysdeps/unix/sysv/linux/alpha/kernel-features.h
	(__ASSUME_UTIMES): Do not define.
	(__ASSUME_O_CLOEXEC): Likewise.
	(__ASSUME_SOCK_CLOEXEC): Likewise.
	(__ASSUME_IN_NONBLOCK): Undefine if [__LINUX_KERNEL_VERSION <
	0x020621] instead of defining if [__LINUX_KERNEL_VERSION >=
	0x020621].
	(__ASSUME_PIPE2): Likewise.
	(__ASSUME_EVENTFD2): Likewise.
	(__ASSUME_SIGNALFD4): Likewise.
	[__LINUX_KERNEL_VERSION < 0x020621] (__ASSUME_DUP3): Undefine.
	* sysdeps/unix/sysv/linux/arm/kernel-features.h (__ASSUME_UTIMES):
	Do not define.
	(__ASSUME_EVENTFD2): Likewise.
	(__ASSUME_SIGNALFD4): Likewise.
	* sysdeps/unix/sysv/linux/hppa/kernel-features.h
	(__ASSUME_32BITUIDS): Likewise.
	(__ASSUME_TRUNCATE64_SYSCALL): Likewise.
	(__ASSUME_IPC64): Likewise.
	(__ASSUME_ST_INO_64_BIT): Likewise.
	(__ASSUME_GETDENTS64_SYSCALL): Likewise.
	[__LINUX_KERNEL_VERSION < 0x030e00] (__ASSUME_UTIMES): Undefine.
	* sysdeps/unix/sysv/linux/ia64/kernel-features.h
	(__ASSUME_UTIMES): Do not define.
	(__ASSUME_PSELECT): Likewise.
	(__ASSUME_PPOLL): Likewise.
	(__ASSUME_O_CLOEXEC): Likewise.
	(__ASSUME_SOCK_CLOEXEC): Likewise.
	(__ASSUME_IN_NONBLOCK): Likewise.
	(__ASSUME_PIPE2): Likewise.
	(__ASSUME_EVENTFD2): Likewise.
	(__ASSUME_SIGNALFD4): Likewise.
	(__ASSUME_DUP3): Likewise.
	* sysdeps/unix/sysv/linux/m68k/kernel-features.h
	(__ASSUME_UTIMES): Likewise.
	(__ASSUME_O_CLOEXEC): Likewise.
	(__ASSUME_SOCK_CLOEXEC): Likewise.
	(__ASSUME_IN_NONBLOCK): Likewise.
	(__ASSUME_PIPE2): Likewise.
	(__ASSUME_EVENTFD2): Likewise.
	(__ASSUME_SIGNALFD4): Likewise.
	(__ASSUME_DUP3): Likewise.
	* sysdeps/unix/sysv/linux/microblaze/kernel-features.h
	(__ASSUME_UTIMES): Likewise.
	(__ASSUME_O_CLOEXEC): Likewise.
	(__ASSUME_SOCK_CLOEXEC): Likewise.
	(__ASSUME_IN_NONBLOCK): Likewise.
	(__ASSUME_PIPE2): Likewise.
	(__ASSUME_EVENTFD2): Likewise.
	(__ASSUME_SIGNALFD4): Likewise.
	(__ASSUME_DUP3): Likewise.
	* sysdeps/unix/sysv/linux/mips/kernel-features.h (__ASSUME_IPC64):
	Likewise.
	(__ASSUME_UTIMES): Likewise.
	(__ASSUME_EVENTFD2): Likewise.
	(__ASSUME_SIGNALFD4): Likewise.
	* sysdeps/unix/sysv/linux/tile/kernel-features.h
	(__ASSUME_O_CLOEXEC): Likewise.
	(__ASSUME_SOCK_CLOEXEC): Likewise.
	(__ASSUME_IN_NONBLOCK): Likewise.
	(__ASSUME_PIPE2): Likewise.
	(__ASSUME_EVENTFD2): Likewise.
	(__ASSUME_SIGNALFD4): Likewise.
	(__ASSUME_DUP3): Likewise.
	(__ASSUME_UTIMES): Undefine.
2014-05-14 00:45:19 +00:00
Joseph Myers 637461d965 Clean up kernel version conditionals for pre-2.6.32 kernels.
This patch does some initial cleanup, following the move to 2.6.32
minimum kernel version, by removing __LINUX_KERNEL_VERSION
conditionals that are now always-true or always-false.  In the case of
__ASSUME_ARG_MAX_STACK_BASED, where the conditional used a kernel
version that was itself in a macro, the associated sysconf.c code is
also cleaned up and __ASSUME_ARG_MAX_STACK_BASED removed completely.

Tested x86_64 that disassembly of installed shared libraries is
unchanged by the patch.

	* sysdeps/unix/sysv/linux/kernel-features.h [__s390__]
	(__ASSUME_UTIMES): Do not condition on kernel version.
	(__ASSUME_PSELECT): Define unconditionally.
	(__ASSUME_PPOLL): Likewise.
	(__ASSUME_ATFCTS): Likewise.
	(__ASSUME_SET_ROBUST_LIST): Do not condition on kernel version.
	(__ASSUME_COMPLETE_READV_WRITEV): Define unconditionally.
	(__ASSUME_FUTEX_LOCK_PI): Do not condition on kernel version.
	(__ASSUME_UTIMENSAT): Define unconditionally.
	(__ASSUME_PRIVATE_FUTEX): Likewise.
	(__ASSUME_FALLOCATE): Likewise.
	(__ASSUME_O_CLOEXEC): Likewise.
	(__LINUX_ARG_MAX_STACK_BASED_MIN_KERNEL): Remove.
	(__ASSUME_ARG_MAX_STACK_BASED): Likewise.
	(__ASSUME_ADJ_OFFSET_SS_READ): Define unconditionally.
	(__ASSUME_SOCK_CLOEXEC): Do not condition on kernel version.
	(__ASSUME_IN_NONBLOCK): Likewise.
	(__ASSUME_PIPE2): Likewise.
	(__ASSUME_EVENTFD2): Likewise.
	(__ASSUME_SIGNALFD4): Likewise.
	(__ASSUME_DUP3): Likewise.
	[__x86_64__ || __sparc__] (__ASSUME_ACCEPT4_SYSCALL): Likewise.
	(__ASSUME_FUTEX_CLOCK_REALTIME): Define unconditionally.
	(__ASSUME_AT_RANDOM): Likewise.
	(__ASSUME_PREADV): Likewise.
	(__ASSUME_PWRITEV): Likewise.
	(__ASSUME_REQUEUE_PI): Do not condition on kernel version.
	(__ASSUME_F_GETOWN_EX): Define unconditionally.
	(__ASSUME_XFS_RESTRICTED_CHOWN): Likewise.
	* sysdeps/unix/sysv/linux/sysconf.c (__sysconf)
	[!__ASSUME_ARG_MAX_STACK_BASED]: Remove conditional code.
	* sysdeps/unix/sysv/linux/alpha/kernel-features.h
	(__ASSUME_O_CLOEXEC): Define unconditionally.
	(__ASSUME_PSELECT): Do not undefine conditionally.
	(__ASSUME_PPOLL): Likewise.
	(__ASSUME_ATFCTS): Likewise.
	(__ASSUME_SET_ROBUST_LIST): Likewise.
	(__ASSUME_UTIMENSAT): Likewise.
	(__ASSUME_FDATASYNC): Define unconditionally.
	* sysdeps/unix/sysv/linux/arm/kernel-features.h
	(__ASSUME_SIGFRAME_V2): Likewise.
	)__ASSUME_EVENTFD2): Likewise.
	(__ASSUME_SIGNALFD4): Likewise.
	(__ASSUME_PSELECT): Do not undefine conditionally.
	(__ASSUME_PPOLL): Likewise.
	* sysdeps/unix/sysv/linux/ia64/kernel-features.h
	(__ASSUME_PSELECT): Define unconditionally.
	(__ASSUME_PPOLL): Likewise.
	(__ASSUME_O_CLOEXEC): Likewise.
	(__ASSUME_SOCK_CLOEXEC): Likewise.
	(__ASSUME_IN_NONBLOCK): Likewise.
	(__ASSUME_PIPE2): Likewise.
	(__ASSUME_EVENTFD2): Likewise.
	(__ASSUME_SIGNALFD4): Likewise.
	(__ASSUME_DUP3): Likewise.
	* sysdeps/unix/sysv/linux/m68k/kernel-features.h
	(__ASSUME_O_CLOEXEC): Likewise.
	(__ASSUME_SOCK_CLOEXEC): Likewise.
	(__ASSUME_IN_NONBLOCK): Likewise.
	(__ASSUME_PIPE2): Likewise.
	(__ASSUME_EVENTFD2): Likewise.
	(__ASSUME_SIGNALFD4): Likewise.
	(__ASSUME_DUP3): Likewise.
	* sysdeps/unix/sysv/linux/mips/kernel-features.h
	(__ASSUME_EVENTFD2): Likewise.
	(__ASSUME_SIGNALFD4): Likewise.
	(__ASSUME_ACCEPT4_SYSCALL): Likewise.
2014-05-12 22:48:25 +00:00
Joseph Myers 47c5adebd2 Correct robust mutex / PI futex kernel assumptions (bug 9894).
This patch continues fixing __ASSUME_* issues in preparation for
moving to a 2.6.32 minimum kernel version by addressing assumptions on
robust mutex and PI futex support availability.  Those assumptions are
bug 9894, but to be clear this patch does not address all the issues
from that bug about wrong version assumptions, only those still
applicable for --enable-kernel=2.6.32 or later (with the expectation
that the move to that minimum kernel will obsolete the other parts of
the bug).  The patch is independent of
<https://sourceware.org/ml/libc-alpha/2014-03/msg00585.html>, my other
pending-review patch preparing for the kernel version change; the two
together complete all the changes I believe are needed in preparation
regarding any macro in sysdeps/unix/sysv/linux/kernel-features.h that
would be affected by such a change.  (I have not checked the
correctness of macros whose conditions are unaffected by such a
change, or macros only defined in other kernel-features.h files.)

As discussed in that bug, robust mutexes and PI futexes need
futex_atomic_cmpxchg_inatomic to be implemented, in addition to
certain syscalls needed for robust mutexes (and
architecture-independent kernel pieces for all the features in
question).  That is, as I understand it, they need
futex_atomic_cmpxchg_inatomic to *work* (not return an ENOSYS error).

The issues identified in my analysis relate to ARM, M68K, MicroBlaze,
MIPS and SPARC.

On ARM, whether futex_atomic_cmpxchg_inatomic works depends on the
kernel configuration.  As of 3.13, the condition for *not* working is
CONFIG_CPU_USE_DOMAINS && CONFIG_SMP.  As of 2.6.32 it was simply
CONFIG_SMP that meant the feature was not implemented.  I don't know
if there are any circumstances in which we can say "we can assume a
userspace glibc binary built with these options will never run on a
kernel with the problematic configuration", but at least for now I'm
just undefining the relevant __ASSUME_* macros for ARM.

On M68K, two of the three macros are undefined for kernels before
3.10, but as far as I can see __ASSUME_FUTEX_LOCK_PI is in the same
group needing futex_atomic_cmpxchg_inatomic support and so should be
undefined as well.

On MicroBlaze the required support was added in 2.6.33.

On MIPS, the support depends on cpu_has_llsc in the kernel - that is,
actual hardware LL/SC support (GCC and glibc for MIPS GNU/Linux rely
on the instructions being supported in some way, but it may be kernel
emulation; futex_atomic_cmpxchg_inatomic doesn't work with that
emulation).  The same condition as in GCC for indicating LL/SC support
may not be available is used for undefining the macros in glibc,
__mips == 1 || defined _MIPS_ARCH_R5900.  (Maybe we could in fact
desupport MIPS processors without the hardware support in glibc.)

On SPARC, 32-bit kernels don't support futex_atomic_cmpxchg_inatomic;
__arch64__ || __sparc_v9__ is used as the condition for binaries that
won't run on 32-bit kernels.

This patch is not tested beyond the sanity check of an x86_64 build.

	[BZ #9894]
	* sysdeps/unix/sysv/linux/kernel-features.h
	[__sparc__ && !__arch64__ && !__sparc_v9__]
	(__ASSUME_SET_ROBUST_LIST): Do not define.
	[__sparc__ && !__arch64__ && !__sparc_v9__]
	(__ASSUME_FUTEX_LOCK_PI): Likewise.
	[__sparc__ && !__arch64__ && !__sparc_v9__] (__ASSUME_REQUEUE_PI):
	Likewise.
	* sysdeps/unix/sysv/linux/arm/kernel-features.h
	(__ASSUME_FUTEX_LOCK_PI): Undefine.
	(__ASSUME_REQUEUE_PI): Likewise.
	(__ASSUME_SET_ROBUST_LIST): Likewise.
	* sysdeps/unix/sysv/linux/m68k/kernel-features.h
	[__LINUX_KERNEL_VERSION < 0x030a00] (__ASSUME_FUTEX_LOCK_PI):
	Undefine.
	* sysdeps/unix/sysv/linux/microblaze/kernel-features.h
	[__LINUX_KERNEL_VERSION < 0x020621] (__ASSUME_FUTEX_LOCK_PI):
	Likewise.
	[__LINUX_KERNEL_VERSION < 0x020621] (__ASSUME_REQUEUE_PI):
	Likewise.
	[__LINUX_KERNEL_VERSION < 0x020621] (__ASSUME_SET_ROBUST_LIST):
	Likewise.
	* sysdeps/unix/sysv/linux/mips/kernel-features.h
	[__mips == 1 || _MIPS_ARCH_R5900] (__ASSUME_FUTEX_LOCK_PI):
	Undefine.
	[__mips == 1 || _MIPS_ARCH_R5900] (__ASSUME_REQUEUE_PI): Likewise.
	[__mips == 1 || _MIPS_ARCH_R5900] (__ASSUME_SET_ROBUST_LIST):
	Likewise.
2014-03-31 12:55:18 +00:00
Joseph Myers dd481ccffd Fix __ASSUME_ACCEPT4 issues (bug 16609).
In <https://sourceware.org/ml/libc-alpha/2013-12/msg00008.html>,
Aurelien noted issues with the definition of __ASSUME_ACCEPT4, which I
discussed in more detail in
<https://sourceware.org/ml/libc-alpha/2013-12/msg00014.html>; these
are now bug 16609.

As previously noted, __ASSUME_ACCEPT4 is used in two ways:

* In OS-independent code, to mean "accept4 can be assumed to work
  rather than fail with ENOSYS".  It doesn't matter whether it's
  implemented with socketcall or a separate syscall.

* In Linux-specific code, to mean "the socketcall multiplex syscall
  can be assumed to handle the accept4 operation.  When used in
  Linux-specific code, it *never* refers to anything relating to the
  accept4 syscall, only to the socketcall multiplexer.

This patch splits the macro into separate __ASSUME_ACCEPT4_SOCKETCALL,
__ASSUME_ACCEPT4_SYSCALL and __ASSUME_ACCEPT4 to clarify the different
cases involved.  A macro __ASSUME_SOCKETCALL is added for convenience
in writing logic relating to all socketcall architectures.  In
addition, to address the issue of architectures where socketcall
support for accept4 was added before a separate syscall was added (and
so the separate syscall should not be used unless known to be present
or fallback to socketcall is available), a fourth macro
__ASSUME_ACCEPT4_SYSCALL_WITH_SOCKETCALL is added to indicate that the
syscall became available at the same time as socketcall support.  This
is then used in the relevant places in a conditional determining
whether to undefine __NR_accept4 (the simple approach to avoiding the
syscall's presence causing problems; I didn't try to implement runtime
fallback from the syscall to socketcall).

Architecture-specific note: alpha defined __ASSUME_ACCEPT4 for 2.6.33
and later, but actually the syscall was added for alpha in 3.2, so
this patch uses the correct condition for __ASSUME_ACCEPT4_SYSCALL
there.

Tested x86_64, including that disassembly of the installed shared
libraries is unchanged by this patch.

	[BZ #16609]
	* sysdeps/unix/sysv/linux/kernel-features.h [__i386__ ||
	__powerpc__ || __s390__ || __sh__ || __sparc__]
	(__ASSUME_SOCKETCALL): Define.
	[__LINUX_KERNEL_VERSION && __ASSUME_SOCKETCALL]
	(__ASSUME_ACCEPT4_SOCKETCALL): Likewise.
	[(__LINUX_KERNEL_VERSION >= 0x02061c && (__x86_64__ || __sparc__))
	|| (__LINUX_KERNEL_VERSION >= 0x020625 && (__powerpc__ ||
	__sh__))] (__ASSUME_ACCEPT4_SYSCALL): Likewise.
	[__sparc__] (__ASSUME_ACCEPT4_SYSCALL_WITH_SOCKETCALL): Likewise.
	[__ASSUME_ACCEPT4_SOCKETCALL || __ASSUME_ACCEPT4_SYSCALL]
	(__ASSUME_ACCEPT4): Define instead of using previous
	[__LINUX_KERNEL_VERSION >= 0x02061c && (__i386__ || __x86_64__ ||
	__powerpc__ || __sparc__ || __s390__)] condition.
	* sysdeps/unix/sysv/linux/aarch64/kernel-features.h
	(__ASSUME_ACCEPT4): Change to __ASSUME_ACCEPT4_SYSCALL.
	* sysdeps/unix/sysv/linux/accept4.c [__ASSUME_SOCKETCALL &&
	!__ASSUME_ACCEPT4_SYSCALL_WITH_SOCKETCALL &&
	!__ASSUME_ACCEPT4_SYSCALL] (__NR_accept4): Undefine.
	[!__ASSUME_ACCEPT4]: Change condition to
	[!__ASSUME_ACCEPT4_SOCKETCALL].
	* sysdeps/unix/sysv/linux/alpha/kernel-features.h
	(__ASSUME_ACCEPT4): Change to __ASSUME_ACCEPT4_SYSCALL.  Correct
	condition to [__LINUX_KERNEL_VERSION >= 0x030200].
	* sysdeps/unix/sysv/linux/arm/kernel-features.h
	[__LINUX_KERNEL_VERSION >= 0x020624] (__ASSUME_ACCEPT4): Change to
	__ASSUME_ACCEPT4_SYSCALL.
	* sysdeps/unix/sysv/linux/i386/accept4.S [__ASSUME_ACCEPT4]:
	Change conditions to [__ASSUME_ACCEPT4_SOCKETCALL].
	* sysdeps/unix/sysv/linux/ia64/kernel-features.h
	[__LINUX_KERNEL_VERSION >= 0x030300] (__ASSUME_ACCEPT4): Change to
	__ASSUME_ACCEPT4_SYSCALL.
	* sysdeps/unix/sysv/linux/internal_accept4.S [__ASSUME_SOCKETCALL
	&& !__ASSUME_ACCEPT4_SYSCALL_WITH_SOCKETCALL &&
	!__ASSUME_ACCEPT4_SYSCALL] (__NR_accept4): Undefine.
	[__ASSUME_ACCEPT4]: Change condition to
	[__ASSUME_ACCEPT4_SOCKETCALL].
	* sysdeps/unix/sysv/linux/m68k/kernel-features.h
	(__ASSUME_SOCKETCALL): Define.
	[__LINUX_KERNEL_VERSION >= 0x02061c] (__ASSUME_ACCEPT4): Remove.
	* sysdeps/unix/sysv/linux/microblaze/kernel-features.h
	(__ASSUME_SOCKETCALL): Define.
	(__ASSUME_ACCEPT4): Remove.
	[__LINUX_KERNEL_VERSION >= 0x020621] (__ASSUME_ACCEPT4_SYSCALL):
	Define.
	* sysdeps/unix/sysv/linux/mips/kernel-features.h
	[__LINUX_KERNEL_VERSION >= 0x02061f] (__ASSUME_ACCEPT4_SYSCALL):
	Likewise.
	* sysdeps/unix/sysv/linux/tile/kernel-features.h
	(__ASSUME_ACCEPT4): Change to __ASSUME_ACCEPT4_SYSCALL.

	* sysdeps/unix/sysv/linux/hppa/kernel-features.h
	[__LINUX_KERNEL_VERSION >= 0x020622] (__ASSUME_ACCEPT4_SYSCALL):
	Define.
2014-02-20 17:50:31 +00:00
Andreas Schwab 73588a7223 Move m68k from ports to libc 2014-02-10 20:22:40 +01:00