diff options
author | Joseph Myers <joseph@codesourcery.com> | 2017-05-09 21:59:36 +0000 |
---|---|---|
committer | Joseph Myers <joseph@codesourcery.com> | 2017-05-09 21:59:36 +0000 |
commit | e3b0580d0d66fbdfc2086c20304c0129f9a5297e (patch) | |
tree | 03e1a6ebdbd8a1362126d9e1fced9c5eda7d9640 /sysdeps/unix | |
parent | eab380d8ec9884e90232dceba24161e63ddd26b8 (diff) | |
download | glibc-e3b0580d0d66fbdfc2086c20304c0129f9a5297e.tar.gz glibc-e3b0580d0d66fbdfc2086c20304c0129f9a5297e.tar.xz glibc-e3b0580d0d66fbdfc2086c20304c0129f9a5297e.zip |
Simplify accept4, recvmmsg, sendmmsg code.
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. * 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.
Diffstat (limited to 'sysdeps/unix')
-rw-r--r-- | sysdeps/unix/sysv/linux/accept4.c | 11 | ||||
-rw-r--r-- | sysdeps/unix/sysv/linux/i386/kernel-features.h | 6 | ||||
-rw-r--r-- | sysdeps/unix/sysv/linux/kernel-features.h | 21 | ||||
-rw-r--r-- | sysdeps/unix/sysv/linux/microblaze/kernel-features.h | 3 | ||||
-rw-r--r-- | sysdeps/unix/sysv/linux/powerpc/kernel-features.h | 3 | ||||
-rw-r--r-- | sysdeps/unix/sysv/linux/recvmmsg.c | 11 | ||||
-rw-r--r-- | sysdeps/unix/sysv/linux/sendmmsg.c | 11 | ||||
-rw-r--r-- | sysdeps/unix/sysv/linux/sh/kernel-features.h | 3 | ||||
-rw-r--r-- | sysdeps/unix/sysv/linux/sparc/kernel-features.h | 9 |
9 files changed, 13 insertions, 65 deletions
diff --git a/sysdeps/unix/sysv/linux/accept4.c b/sysdeps/unix/sysv/linux/accept4.c index 0592f43dd6..1590c021ad 100644 --- a/sysdeps/unix/sysv/linux/accept4.c +++ b/sysdeps/unix/sysv/linux/accept4.c @@ -28,14 +28,9 @@ 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 - return SOCKETCALL_CANCEL (accept4, fd, addr.__sockaddr__, addr_len, flags); -#else +#ifdef __ASSUME_ACCEPT4_SYSCALL return SYSCALL_CANCEL (accept4, fd, addr.__sockaddr__, addr_len, flags); +#else + return SOCKETCALL_CANCEL (accept4, fd, addr.__sockaddr__, addr_len, flags); #endif } diff --git a/sysdeps/unix/sysv/linux/i386/kernel-features.h b/sysdeps/unix/sysv/linux/i386/kernel-features.h index 96a8e3bc1d..c6eb20f360 100644 --- a/sysdeps/unix/sysv/linux/i386/kernel-features.h +++ b/sysdeps/unix/sysv/linux/i386/kernel-features.h @@ -20,12 +20,6 @@ /* i386 uses socketcall. */ #define __ASSUME_SOCKETCALL 1 -/* The recvmmsg syscall was added for i386 in 2.6.33. */ -#define __ASSUME_RECVMMSG_SYSCALL_WITH_SOCKETCALL 1 - -/* The sendmmsg syscall was added for i386 in 3.0. */ -#define __ASSUME_SENDMMSG_SYSCALL_WITH_SOCKETCALL 1 - /* Direct socketcalls available with kernel 4.3. */ #if __LINUX_KERNEL_VERSION >= 0x040300 # define __ASSUME_SOCKET_SYSCALL 1 diff --git a/sysdeps/unix/sysv/linux/kernel-features.h b/sysdeps/unix/sysv/linux/kernel-features.h index 77285656cd..76053b5451 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 /* On most architectures, most socket syscalls are supported for all @@ -111,6 +95,9 @@ #define __ASSUME_CONNECT_SYSCALL 1 #define __ASSUME_RECVFROM_SYSCALL 1 #define __ASSUME_SENDTO_SYSCALL 1 +#define __ASSUME_ACCEPT4_SYSCALL 1 +#define __ASSUME_RECVMMSG_SYSCALL 1 +#define __ASSUME_SENDMMSG_SYSCALL 1 /* Support for SysV IPC through wired syscalls. All supported architectures either support ipc syscall and/or all the ipc correspondent syscalls. */ diff --git a/sysdeps/unix/sysv/linux/microblaze/kernel-features.h b/sysdeps/unix/sysv/linux/microblaze/kernel-features.h index fe170a0987..0257524777 100644 --- a/sysdeps/unix/sysv/linux/microblaze/kernel-features.h +++ b/sysdeps/unix/sysv/linux/microblaze/kernel-features.h @@ -33,9 +33,6 @@ #define __ASSUME_GETSOCKOPT_SYSCALL 1 #define __ASSUME_SETSOCKOPT_SYSCALL 1 -/* Support for the accept4 and recvmmsg syscalls was added in 2.6.33. */ -#define __ASSUME_RECVMMSG_SYSCALL_WITH_SOCKETCALL 1 - #include_next <kernel-features.h> /* Support for the pselect6, preadv and pwritev syscalls was added in diff --git a/sysdeps/unix/sysv/linux/powerpc/kernel-features.h b/sysdeps/unix/sysv/linux/powerpc/kernel-features.h index dc9ad941f7..e026394422 100644 --- a/sysdeps/unix/sysv/linux/powerpc/kernel-features.h +++ b/sysdeps/unix/sysv/linux/powerpc/kernel-features.h @@ -34,9 +34,6 @@ #define __ASSUME_GETSOCKOPT_SYSCALL 1 #define __ASSUME_SETSOCKOPT_SYSCALL 1 -/* The sendmmsg syscall was added for PowerPC in 3.0. */ -#define __ASSUME_SENDMMSG_SYSCALL_WITH_SOCKETCALL 1 - /* Define this if your 32-bit syscall API requires 64-bit register pairs to start with an even-number register. */ #ifndef __powerpc64__ diff --git a/sysdeps/unix/sysv/linux/recvmmsg.c b/sysdeps/unix/sysv/linux/recvmmsg.c index de4412972b..60e06b7754 100644 --- a/sysdeps/unix/sysv/linux/recvmmsg.c +++ b/sysdeps/unix/sysv/linux/recvmmsg.c @@ -28,14 +28,9 @@ int recvmmsg (int fd, struct mmsghdr *vmessages, unsigned int vlen, int flags, struct timespec *tmo) { - /* Do not use the recvmmsg 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_RECVMMSG_SYSCALL_WITH_SOCKETCALL \ - && !defined __ASSUME_RECVMMSG_SYSCALL - return SOCKETCALL_CANCEL (recvmmsg, fd, vmessages, vlen, flags, tmo); -#else +#ifdef __ASSUME_RECVMMSG_SYSCALL return SYSCALL_CANCEL (recvmmsg, fd, vmessages, vlen, flags, tmo); +#else + return SOCKETCALL_CANCEL (recvmmsg, fd, vmessages, vlen, flags, tmo); #endif } diff --git a/sysdeps/unix/sysv/linux/sendmmsg.c b/sysdeps/unix/sysv/linux/sendmmsg.c index c559623c12..e0c2556309 100644 --- a/sysdeps/unix/sysv/linux/sendmmsg.c +++ b/sysdeps/unix/sysv/linux/sendmmsg.c @@ -27,15 +27,10 @@ int __sendmmsg (int fd, struct mmsghdr *vmessages, unsigned int vlen, int flags) { - /* Do not use the sendmmsg 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_SENDMMSG_SYSCALL_WITH_SOCKETCALL \ - && !defined __ASSUME_SENDMMSG_SYSCALL - return SOCKETCALL_CANCEL (sendmmsg, fd, vmessages, vlen, flags); -#else +#ifdef __ASSUME_SENDMMSG_SYSCALL return SYSCALL_CANCEL (sendmmsg, fd, vmessages, vlen, flags); +#else + return SOCKETCALL_CANCEL (sendmmsg, fd, vmessages, vlen, flags); #endif } libc_hidden_def (__sendmmsg) diff --git a/sysdeps/unix/sysv/linux/sh/kernel-features.h b/sysdeps/unix/sysv/linux/sh/kernel-features.h index b0b321576c..175b4f5433 100644 --- a/sysdeps/unix/sysv/linux/sh/kernel-features.h +++ b/sysdeps/unix/sysv/linux/sh/kernel-features.h @@ -37,9 +37,6 @@ #define __ASSUME_GETSOCKOPT_SYSCALL 1 #define __ASSUME_SETSOCKOPT_SYSCALL 1 -/* The sendmmsg syscall was added for SH in 3.0. */ -#define __ASSUME_SENDMMSG_SYSCALL_WITH_SOCKETCALL 1 - #include_next <kernel-features.h> /* SH does not have a 64-bit inode field. */ diff --git a/sysdeps/unix/sysv/linux/sparc/kernel-features.h b/sysdeps/unix/sysv/linux/sparc/kernel-features.h index c833201767..72065a0248 100644 --- a/sysdeps/unix/sysv/linux/sparc/kernel-features.h +++ b/sysdeps/unix/sysv/linux/sparc/kernel-features.h @@ -20,15 +20,6 @@ /* SPARC uses socketcall. */ #define __ASSUME_SOCKETCALL 1 -/* The accept4 syscall was added for SPARC in 2.6.28. */ -#define __ASSUME_ACCEPT4_SYSCALL_WITH_SOCKETCALL 1 - -/* The recvmmsg syscall was added for SPARC in 2.6.33. */ -#define __ASSUME_RECVMMSG_SYSCALL_WITH_SOCKETCALL 1 - -/* The sendmmsg syscall was added for SPARC in 3.0. */ -#define __ASSUME_SENDMMSG_SYSCALL_WITH_SOCKETCALL 1 - #include_next <kernel-features.h> /* 32-bit SPARC kernels do not support |