diff options
author | Florian Weimer <fweimer@redhat.com> | 2017-04-19 07:44:48 +0200 |
---|---|---|
committer | Florian Weimer <fweimer@redhat.com> | 2017-04-19 07:44:48 +0200 |
commit | e92030239abb4038d4f915d47021d6c037239309 (patch) | |
tree | 1c8c4877f35df78b7441a5736d8551b9b4877231 /sysdeps | |
parent | 62f71aad7e0d9df95578846134f1738ddf0e7844 (diff) | |
download | glibc-e92030239abb4038d4f915d47021d6c037239309.zip glibc-e92030239abb4038d4f915d47021d6c037239309.tar.gz glibc-e92030239abb4038d4f915d47021d6c037239309.tar.bz2 |
Assume that accept4 is always available and works
Simplify the Linux accept4 implementation based on the assumption
that it is available in some way. __ASSUME_ACCEPT4_SOCKETCALL was
previously unused, so remove it.
For ia64, the accept4 system call (and socket call) were backported
in kernel version 3.2.18. Reflect this in the installation
instructions.
Diffstat (limited to 'sysdeps')
-rw-r--r-- | sysdeps/mach/hurd/kernel-features.h | 2 | ||||
-rw-r--r-- | sysdeps/nacl/kernel-features.h | 4 | ||||
-rw-r--r-- | sysdeps/unix/sysv/linux/accept4.c | 69 | ||||
-rw-r--r-- | sysdeps/unix/sysv/linux/ia64/configure | 4 | ||||
-rw-r--r-- | sysdeps/unix/sysv/linux/ia64/configure.ac | 4 | ||||
-rw-r--r-- | sysdeps/unix/sysv/linux/ia64/kernel-features.h | 7 | ||||
-rw-r--r-- | sysdeps/unix/sysv/linux/kernel-features.h | 11 |
7 files changed, 18 insertions, 83 deletions
diff --git a/sysdeps/mach/hurd/kernel-features.h b/sysdeps/mach/hurd/kernel-features.h index 20cb3ba..1966388 100644 --- a/sysdeps/mach/hurd/kernel-features.h +++ b/sysdeps/mach/hurd/kernel-features.h @@ -19,5 +19,3 @@ /* This file can define __ASSUME_* macros checked by certain source files. Almost none of these are used outside of sysdeps/unix/sysv/linux code. But those referring to POSIX-level features like O_* flags can be. */ - -#define __ASSUME_ACCEPT4 1 diff --git a/sysdeps/nacl/kernel-features.h b/sysdeps/nacl/kernel-features.h index 32834fd..ba315b6 100644 --- a/sysdeps/nacl/kernel-features.h +++ b/sysdeps/nacl/kernel-features.h @@ -19,7 +19,3 @@ /* This file can define __ASSUME_* macros checked by certain source files. Almost none of these are used outside of sysdeps/unix/sysv/linux code. But those referring to POSIX-level features like O_* flags can be. */ - -/* -#define __ASSUME_ACCEPT4 1 -*/ diff --git a/sysdeps/unix/sysv/linux/accept4.c b/sysdeps/unix/sysv/linux/accept4.c index 53afd7a..0592f43 100644 --- a/sysdeps/unix/sysv/linux/accept4.c +++ b/sysdeps/unix/sysv/linux/accept4.c @@ -22,75 +22,20 @@ #include <sysdep-cancel.h> #include <sys/syscall.h> +#include <socketcall.h> #include <kernel-features.h> +int +accept4 (int fd, __SOCKADDR_ARG addr, socklen_t *addr_len, int flags) +{ /* Do not use the accept4 syscall on socketcall architectures unless it was added at the same time as the socketcall support or can be assumed to be present. */ #if defined __ASSUME_SOCKETCALL \ && !defined __ASSUME_ACCEPT4_SYSCALL_WITH_SOCKETCALL \ && !defined __ASSUME_ACCEPT4_SYSCALL -# undef __NR_accept4 -#endif - -#ifdef __NR_accept4 -int -accept4 (int fd, __SOCKADDR_ARG addr, socklen_t *addr_len, int flags) -{ - return SYSCALL_CANCEL (accept4, fd, addr.__sockaddr__, addr_len, flags); -} -#elif defined __NR_socketcall -# include <socketcall.h> -# ifdef __ASSUME_ACCEPT4_SOCKETCALL -int -accept4 (int fd, __SOCKADDR_ARG addr, socklen_t *addr_len, int flags) -{ return SOCKETCALL_CANCEL (accept4, fd, addr.__sockaddr__, addr_len, flags); -} -# else -static int have_accept4; - -int -accept4 (int fd, __SOCKADDR_ARG addr, socklen_t *addr_len, int flags) -{ - if (__glibc_likely (have_accept4 >= 0)) - { - int ret = SOCKETCALL_CANCEL (accept4, fd, addr.__sockaddr__, addr_len, - flags); - /* The kernel returns -EINVAL for unknown socket operations. - We need to convert that error to an ENOSYS error. */ - if (__builtin_expect (ret < 0, 0) - && have_accept4 == 0 - && errno == EINVAL) - { - /* Try another call, this time with the FLAGS parameter - cleared and an invalid file descriptor. This call will not - cause any harm and it will return immediately. */ - ret = SOCKETCALL_CANCEL (invalid, -1); - if (errno == EINVAL) - { - have_accept4 = -1; - __set_errno (ENOSYS); - } - else - { - have_accept4 = 1; - __set_errno (EINVAL); - } - return -1; - } - return ret; - } - __set_errno (ENOSYS); - return -1; -} -# endif /* __ASSUME_ACCEPT4_SOCKETCALL */ -#else /* __NR_socketcall */ -int -accept4 (int fd, __SOCKADDR_ARG addr, socklen_t *addr_len, int flags) -{ - __set_errno (ENOSYS); - return -1; -} -stub_warning (accept4) +#else + return SYSCALL_CANCEL (accept4, fd, addr.__sockaddr__, addr_len, flags); #endif +} diff --git a/sysdeps/unix/sysv/linux/ia64/configure b/sysdeps/unix/sysv/linux/ia64/configure index 1d4e5d1..3cf7237 100644 --- a/sysdeps/unix/sysv/linux/ia64/configure +++ b/sysdeps/unix/sysv/linux/ia64/configure @@ -2,3 +2,7 @@ # Local configure fragment for sysdeps/unix/sysv/linux/ia64 ldd_rewrite_script=$dir/ldd-rewrite.sed + +# First version with support for the accept4 system call. +# Linux 3.3 includes it as well. +arch_minimum_kernel=3.2.18 diff --git a/sysdeps/unix/sysv/linux/ia64/configure.ac b/sysdeps/unix/sysv/linux/ia64/configure.ac index 4fb5647..94a578c 100644 --- a/sysdeps/unix/sysv/linux/ia64/configure.ac +++ b/sysdeps/unix/sysv/linux/ia64/configure.ac @@ -2,3 +2,7 @@ GLIBC_PROVIDES dnl See aclocal.m4 in the top level source directory. # Local configure fragment for sysdeps/unix/sysv/linux/ia64 ldd_rewrite_script=$dir/ldd-rewrite.sed + +# First version with support for the accept4 system call. +# Linux 3.3 includes it as well. +arch_minimum_kernel=3.2.18 diff --git a/sysdeps/unix/sysv/linux/ia64/kernel-features.h b/sysdeps/unix/sysv/linux/ia64/kernel-features.h index ac9403e..cda0ad6 100644 --- a/sysdeps/unix/sysv/linux/ia64/kernel-features.h +++ b/sysdeps/unix/sysv/linux/ia64/kernel-features.h @@ -22,13 +22,8 @@ #include_next <kernel-features.h> -/* Support for the accept4 syscall was added in 3.3. */ -#if __LINUX_KERNEL_VERSION < 0x030300 -# undef __ASSUME_ACCEPT4_SYSCALL -# undef __ASSUME_ACCEPT4 -#endif - #define __ASSUME_RECV_SYSCALL 1 #define __ASSUME_SEND_SYSCALL 1 +#define __ASSUME_ACCEPT4_SYSCALL 1 #endif /* _KERNEL_FEATURES_H */ diff --git a/sysdeps/unix/sysv/linux/kernel-features.h b/sysdeps/unix/sysv/linux/kernel-features.h index fd936c5..b981466 100644 --- a/sysdeps/unix/sysv/linux/kernel-features.h +++ b/sysdeps/unix/sysv/linux/kernel-features.h @@ -75,18 +75,11 @@ architectures using a separate syscall rather than socketcall that syscall was only added later, and some architectures first had socketcall support then a separate syscall. Define - __ASSUME_ACCEPT4_SOCKETCALL if glibc uses socketcall on this - architecture and accept4 is available through socketcall, __ASSUME_ACCEPT4_SYSCALL if it is available through a separate - syscall, __ASSUME_ACCEPT4_SYSCALL_WITH_SOCKETCALL if it became + syscall, and __ASSUME_ACCEPT4_SYSCALL_WITH_SOCKETCALL if it became available through a separate syscall at the same time as through - socketcall, and __ASSUME_ACCEPT4 if the accept4 function is known - to work. */ -#ifdef __ASSUME_SOCKETCALL -# define __ASSUME_ACCEPT4_SOCKETCALL 1 -#endif + socketcall. */ #define __ASSUME_ACCEPT4_SYSCALL 1 -#define __ASSUME_ACCEPT4 1 /* Support for the FUTEX_CLOCK_REALTIME flag was added in 2.6.29. */ #define __ASSUME_FUTEX_CLOCK_REALTIME 1 |