Simplify accept4, recvmmsg, sendmmsg code
Adhemerval Zanella
adhemerval.zanella@linaro.org
Tue May 9 21:37:00 GMT 2017
On 09/05/2017 17:46, Joseph Myers wrote:
> The accept4, recvmmsg and sendmmsg functions had macros
> __ASSUME_*_SYSCALL_WITH_SOCKETCALL. Before we could assume kernels
> with the relevant functionality, these macros represented the
> conditions under which, on a socketcall architecture, glibc could just
> call the syscall unconditionally and not have to deal with socketcall
> at all for those functions, because if the syscall didn't work for
> them the socketcall call wouldn't either.
>
> Now we can assume kernels with the relevant functionality, the only
> question is whether we can assume the syscall is present; if not, we
> are on a socketcall architecture and just use socketcall instead.
> Thus, this patch removes the macros that are no longer necessary, and
> simplifies the code for accept4, recvmmsg and sendmmsg to use the same
> logic as the other C implementations of socket functions that may use
> a syscall or socketcall depending on kernel support.
>
> Tested for x86_64 and x86.
I think we can also now remove mips sendmmsg and recvmmsg implementations
(it does not define __ASSUME_SOCKETCALL, so it should use wire-up calls
as well).
>
> 2017-05-09 Joseph Myers <joseph@codesourcery.com>
>
> * sysdeps/unix/sysv/linux/accept4.c (accept4): Use syscall if
> [__ASSUME_ACCEPT4_SYSCALL], otherwise socketcall.
> * sysdeps/unix/sysv/linux/recvmmsg.c (recvmmsg): Use syscall if
> [__ASSUME_RECVMMSG_SYSCALL], otherwise socketcall.
> * sysdeps/unix/sysv/linux/sendmmsg.c (__sendmmsg): Use syscall if
> [__ASSUME_SENDMMSG_SYSCALL], otherwise socketcall.
> * sysdeps/unix/sysv/linux/kernel-features.h
> (__ASSUME_ACCEPT4_SYSCALL): Move to general list of macros for
> socket syscalls.
> (__ASSUME_RECVMMSG_SYSCALL): Likewise.
> (__ASSUME_SENDMMSG_SYSCALL): Likewise.
> * sysdeps/unix/sysv/linux/i386/kernel-features.h
> (__ASSUME_RECVMMSG_SYSCALL_WITH_SOCKETCALL): Remove.
> (__ASSUME_SENDMMSG_SYSCALL_WITH_SOCKETCALL): Likewise.
> * sysdeps/unix/sysv/linux/microblaze/kernel-features.h
> (__ASSUME_RECVMMSG_SYSCALL_WITH_SOCKETCALL): Remove.
> * sysdeps/unix/sysv/linux/powerpc/kernel-features.h
> (__ASSUME_SENDMMSG_SYSCALL_WITH_SOCKETCALL): Likewise.
> * sysdeps/unix/sysv/linux/sh/kernel-features.h
> (__ASSUME_SENDMMSG_SYSCALL_WITH_SOCKETCALL): Likewise.
> * sysdeps/unix/sysv/linux/sparc/kernel-features.h
> (__ASSUME_ACCEPT4_SYSCALL_WITH_SOCKETCALL): Likewise.
> (__ASSUME_RECVMMSG_SYSCALL_WITH_SOCKETCALL): Likewise.
> (__ASSUME_SENDMMSG_SYSCALL_WITH_SOCKETCALL): Likewise.
LGTM with some one comment remark.
> diff --git a/sysdeps/unix/sysv/linux/kernel-features.h b/sysdeps/unix/sysv/linux/kernel-features.h
> index 7728565..76053b5 100644
> --- a/sysdeps/unix/sysv/linux/kernel-features.h
> +++ b/sysdeps/unix/sysv/linux/kernel-features.h
> @@ -71,16 +71,6 @@
> 2.6.27. */
> #define __ASSUME_IN_NONBLOCK 1
>
> -/* Support for accept4 functionality was added in 2.6.28, but for some
> - 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_SYSCALL if it is available through a separate
> - syscall, and __ASSUME_ACCEPT4_SYSCALL_WITH_SOCKETCALL if it became
> - available through a separate syscall at the same time as through
> - socketcall. */
> -#define __ASSUME_ACCEPT4_SYSCALL 1
> -
> /* Support for the FUTEX_CLOCK_REALTIME flag was added in 2.6.29. */
> #define __ASSUME_FUTEX_CLOCK_REALTIME 1
>
> @@ -88,18 +78,12 @@
> #define __ASSUME_PREADV 1
> #define __ASSUME_PWRITEV 1
>
> -/* Support for recvmmsg functionality was added in 2.6.33. The macros
> - defined correspond to those for accept4. */
> -#define __ASSUME_RECVMMSG_SYSCALL 1
> -
> /* statfs fills in f_flags since 2.6.36. */
> #if __LINUX_KERNEL_VERSION >= 0x020624
> # define __ASSUME_STATFS_F_FLAGS 1
> #endif
>
> -/* Support for sendmmsg functionality was added in 3.0. The macros
> - defined correspond to those for accept4 and recvmmsg. */
> -#define __ASSUME_SENDMMSG_SYSCALL 1
> +/* Support for sendmmsg functionality was added in 3.0. */
> #define __ASSUME_SENDMMSG 1
Since you are there, wouldn't be better to add a comment that we
kept __ASSUME_SENDMMSG because of resolv code instead of kernel
support?
More information about the Libc-alpha
mailing list