diff options
author | Adhemerval Zanella <adhemerval.zanella@linaro.com> | 2017-03-06 15:13:03 +0100 |
---|---|---|
committer | Adhemerval Zanella <adhemerval.zanella@linaro.com> | 2017-03-09 15:22:06 +0100 |
commit | 60f9423b6b02d79f8fef65552ecd21e0fd097774 (patch) | |
tree | b4bdcf27f2c3b709e1e3afcc09a32b8aec3e9a5d /sysdeps/unix/sysv/linux | |
parent | 06cf371e978cde2df19efa1474791bd2532f529b (diff) | |
download | glibc-60f9423b6b02d79f8fef65552ecd21e0fd097774.tar.gz glibc-60f9423b6b02d79f8fef65552ecd21e0fd097774.tar.xz glibc-60f9423b6b02d79f8fef65552ecd21e0fd097774.zip |
Consolidate Linux send implementation
This patch consolidates the send Linux syscall implementation on sysdeps/unix/sysv/linux/send{to}.c. The changes are: 1. Remove send from auto-generation syscalls.list on the architecture that uses __NR_send. 2. Define __NR_send for architectures that supports it. It was done instead of defining in default kernel-features.h because current Linux practice for new ports are to implement only __NR_sendto [1] and it will require adding new kernel-features for ports that do not require it (aarch64 for instance). 3. Remove __ASSUME_SENDTO_FOR_SEND_SYSCALL and decide to use __NR_sendto for send generation based on __ASSUME_SENDTO_SYSCALL. Checked on i686-linux-gnu, x86_64-linux-gnu, x86_64-linux-gnux32, aarch64-linux-gnu, arm-linux-gnueabihf, and powerpc64le-linux-gnu. * sysdeps/unix/sysv/linux/sysdep.h (HAVE_INTERNAL_SEND_SYMBOL): Define. * sysdeps/unix/sysv/linux/aarch64/sysdep.h (HAVE_INTERNAL_SEND_SYMBOL): Undefine. * sysdeps/unix/sysv/linux/nios2/sysdep.h (HAVE_INTERNAL_SEND_SYMBOL): Likewise. * sysdeps/unix/sysv/linux/tile/sysdep.h (HAVE_INTERNAL_SEND_SYMBOL): Likewise. * sysdeps/unix/sysv/linux/alpha/kernel-features.h (__ASSUME_RECV_SYSCALL): Define. * sysdeps/unix/sysv/linux/arm/kernel-features.h (__ASSUME_RECV_SYSCALL): Likewise. * sysdeps/unix/sysv/linux/hppa/kernel-features.h (__ASSUME_RECV_SYSCALL): Likewise. * sysdeps/unix/sysv/linux/ia64/kernel-features.h (__ASSUME_RECV_SYSCALL): Likewise. * sysdeps/unix/sysv/linux/mips/kernel-features.h (__ASSUME_RECV_SYSCALL): Likewise. * sysdeps/unix/sysv/linux/i386/kernel-features.h (__ASSUME_SENDTO_FOR_SEND_SYSCALL): Remove define. * sysdeps/unix/sysv/linux/m68k/kernel-features.h (__ASSUME_SENDTO_FOR_SEND_SYSCALL): Likewise. * sysdeps/unix/sysv/linux/s390/kernel-features.h (__ASSUME_SENDTO_FOR_SEND_SYSCALL): Likewise. * sysdeps/unix/sysv/linux/alpha/syscalls.list: Remove send from auto-generation list. * sysdeps/unix/sysv/linux/arm/syscalls.list: Likewise. * sysdeps/unix/sysv/linux/hppa/syscalls.list: Likewise. * sysdeps/unix/sysv/linux/ia64/syscalls.list: Likewike. * sysdeps/unix/sysv/linux/mips/syscalls.list: Likewise. * sysdeps/unix/sysv/linux/sparc/sparc64/syscalls.list: Likewise. * sysdeps/unix/sysv/linux/send.c: Simplify includes. (__ASSUME_SENDTO_FOR_SEND_SYSCALL): Replace by __ASSUME_SENDTO_SYSCALL. * sysdeps/unix/sysv/linux/x86_64/send.c: Remove file. * sysdeps/unix/sysv/linux/mips/mips64/send.c: Likewise. * sysdeps/unix/sysv/linux/generic/send.c: Likewise.
Diffstat (limited to 'sysdeps/unix/sysv/linux')
22 files changed, 24 insertions, 77 deletions
diff --git a/sysdeps/unix/sysv/linux/aarch64/sysdep.h b/sysdeps/unix/sysv/linux/aarch64/sysdep.h index f301638a81..4bb9112d62 100644 --- a/sysdeps/unix/sysv/linux/aarch64/sysdep.h +++ b/sysdeps/unix/sysv/linux/aarch64/sysdep.h @@ -157,6 +157,10 @@ # define HAVE_CLOCK_GETTIME_VSYSCALL 1 # define HAVE_GETTIMEOFDAY_VSYSCALL 1 +/* Previously AArch64 used the generic version without the libc_hidden_def + which lead in a non existent __send symbol in libc.so. */ +# undef HAVE_INTERNAL_SEND_SYMBOL + /* Define a macro which expands into the inline wrapper code for a system call. */ # undef INLINE_SYSCALL diff --git a/sysdeps/unix/sysv/linux/alpha/kernel-features.h b/sysdeps/unix/sysv/linux/alpha/kernel-features.h index 3383a98948..93ba14a7bf 100644 --- a/sysdeps/unix/sysv/linux/alpha/kernel-features.h +++ b/sysdeps/unix/sysv/linux/alpha/kernel-features.h @@ -33,5 +33,6 @@ #define __NR_shmat __NR_osf_shmat #define __ASSUME_RECV_SYSCALL 1 +#define __ASSUME_RECV_SYSCALL 1 #endif /* _KERNEL_FEATURES_H */ diff --git a/sysdeps/unix/sysv/linux/alpha/syscalls.list b/sysdeps/unix/sysv/linux/alpha/syscalls.list index 304e97ef6f..aa21b10a25 100644 --- a/sysdeps/unix/sysv/linux/alpha/syscalls.list +++ b/sysdeps/unix/sysv/linux/alpha/syscalls.list @@ -10,7 +10,6 @@ getpeername - getpeername i:ipp __getpeername getpeername getsockname - getsockname i:ipp __getsockname getsockname getsockopt - getsockopt i:iiiBN __getsockopt getsockopt listen - listen i:ii __listen listen -send - send Ci:ibni __libc_send __send send setsockopt - setsockopt i:iiibn __setsockopt setsockopt shutdown - shutdown i:ii __shutdown shutdown socket - socket i:iii __socket socket diff --git a/sysdeps/unix/sysv/linux/arm/kernel-features.h b/sysdeps/unix/sysv/linux/arm/kernel-features.h index 104c9f9f17..4923dfd85b 100644 --- a/sysdeps/unix/sysv/linux/arm/kernel-features.h +++ b/sysdeps/unix/sysv/linux/arm/kernel-features.h @@ -39,3 +39,4 @@ #define __NR_fadvise64_64 __NR_arm_fadvise64_64 #define __ASSUME_RECV_SYSCALL 1 +#define __ASSUME_SEND_SYSCALL 1 diff --git a/sysdeps/unix/sysv/linux/arm/syscalls.list b/sysdeps/unix/sysv/linux/arm/syscalls.list index 4ca4f81f1a..13441f7eb4 100644 --- a/sysdeps/unix/sysv/linux/arm/syscalls.list +++ b/sysdeps/unix/sysv/linux/arm/syscalls.list @@ -27,7 +27,6 @@ getpeername - getpeername i:ipp __getpeername getpeername getsockname - getsockname i:ipp __getsockname getsockname getsockopt - getsockopt i:iiiBN __getsockopt getsockopt listen - listen i:ii __listen listen -send - send Ci:ibni __libc_send __send send setsockopt - setsockopt i:iiibn __setsockopt setsockopt shutdown - shutdown i:ii __shutdown shutdown socket - socket i:iii __socket socket diff --git a/sysdeps/unix/sysv/linux/generic/send.c b/sysdeps/unix/sysv/linux/generic/send.c deleted file mode 100644 index d0cb0355db..0000000000 --- a/sysdeps/unix/sysv/linux/generic/send.c +++ /dev/null @@ -1,30 +0,0 @@ -/* Copyright (C) 2011-2017 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Chris Metcalf <cmetcalf@tilera.com>, 2011. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library. If not, see - <http://www.gnu.org/licenses/>. */ - -#include <stdlib.h> -#include <sys/types.h> -#include <sysdep-cancel.h> -#include <libc-symbols.h> - -ssize_t -__libc_send (int sockfd, const void *buffer, size_t len, int flags) -{ - return SYSCALL_CANCEL (sendto, sockfd, buffer, len, flags, NULL, 0); -} -strong_alias (__libc_send, __send) -weak_alias (__libc_send, send) diff --git a/sysdeps/unix/sysv/linux/hppa/kernel-features.h b/sysdeps/unix/sysv/linux/hppa/kernel-features.h index 1fd7398264..0e73a5c0df 100644 --- a/sysdeps/unix/sysv/linux/hppa/kernel-features.h +++ b/sysdeps/unix/sysv/linux/hppa/kernel-features.h @@ -26,3 +26,4 @@ #include_next <kernel-features.h> #define __ASSUME_RECV_SYSCALL 1 +#define __ASSUME_SEND_SYSCALL 1 diff --git a/sysdeps/unix/sysv/linux/hppa/syscalls.list b/sysdeps/unix/sysv/linux/hppa/syscalls.list index eaa20b35bb..cd37573b89 100644 --- a/sysdeps/unix/sysv/linux/hppa/syscalls.list +++ b/sysdeps/unix/sysv/linux/hppa/syscalls.list @@ -6,7 +6,6 @@ getpeername - getpeername i:ipp __getpeername getpeername getsockname - getsockname i:ipp __getsockname getsockname getsockopt - getsockopt i:iiiBN __getsockopt getsockopt listen - listen i:ii __listen listen -send - send Ci:ibni __libc_send __send send setsockopt - setsockopt i:iiibn __setsockopt setsockopt shutdown - shutdown i:ii __shutdown shutdown socket - socket i:iii __socket socket diff --git a/sysdeps/unix/sysv/linux/i386/kernel-features.h b/sysdeps/unix/sysv/linux/i386/kernel-features.h index 63920340f0..96a8e3bc1d 100644 --- a/sysdeps/unix/sysv/linux/i386/kernel-features.h +++ b/sysdeps/unix/sysv/linux/i386/kernel-features.h @@ -36,7 +36,6 @@ # define __ASSUME_SETSOCKOPT_SYSCALL 1 # define __ASSUME_GETSOCKNAME_SYSCALL 1 # define __ASSUME_GETPEERNAME_SYSCALL 1 -# define __ASSUME_SENDTO_FOR_SEND_SYSCALL 1 # define __ASSUME_SHUTDOWN_SYSCALL 1 #endif diff --git a/sysdeps/unix/sysv/linux/ia64/kernel-features.h b/sysdeps/unix/sysv/linux/ia64/kernel-features.h index 80e41b68af..ac9403e869 100644 --- a/sysdeps/unix/sysv/linux/ia64/kernel-features.h +++ b/sysdeps/unix/sysv/linux/ia64/kernel-features.h @@ -29,5 +29,6 @@ #endif #define __ASSUME_RECV_SYSCALL 1 +#define __ASSUME_SEND_SYSCALL 1 #endif /* _KERNEL_FEATURES_H */ diff --git a/sysdeps/unix/sysv/linux/ia64/syscalls.list b/sysdeps/unix/sysv/linux/ia64/syscalls.list index 64d47f4d49..56f4138c43 100644 --- a/sysdeps/unix/sysv/linux/ia64/syscalls.list +++ b/sysdeps/unix/sysv/linux/ia64/syscalls.list @@ -10,7 +10,6 @@ getpeername - getpeername i:ipp __getpeername getpeername getsockname - getsockname i:ipp __getsockname getsockname getsockopt - getsockopt i:iiiBN __getsockopt getsockopt listen - listen i:ii __listen listen -send - send Ci:ibni __libc_send __send send setsockopt - setsockopt i:iiibn __setsockopt setsockopt shutdown - shutdown i:ii __shutdown shutdown socket - socket i:iii __socket socket diff --git a/sysdeps/unix/sysv/linux/m68k/kernel-features.h b/sysdeps/unix/sysv/linux/m68k/kernel-features.h index 0f590fd768..55c80d732b 100644 --- a/sysdeps/unix/sysv/linux/m68k/kernel-features.h +++ b/sysdeps/unix/sysv/linux/m68k/kernel-features.h @@ -30,7 +30,6 @@ # define __ASSUME_SETSOCKOPT_SYSCALL 1 # define __ASSUME_GETSOCKNAME_SYSCALL 1 # define __ASSUME_GETPEERNAME_SYSCALL 1 -# define __ASSUME_SENDTO_FOR_SEND_SYSCALL 1 # define __ASSUME_SHUTDOWN_SYSCALL 1 #endif diff --git a/sysdeps/unix/sysv/linux/mips/kernel-features.h b/sysdeps/unix/sysv/linux/mips/kernel-features.h index 632c860dbb..e0a4994279 100644 --- a/sysdeps/unix/sysv/linux/mips/kernel-features.h +++ b/sysdeps/unix/sysv/linux/mips/kernel-features.h @@ -40,6 +40,7 @@ /* mips32 support wire-up network syscalls. */ # define __ASSUME_RECV_SYSCALL 1 +# define __ASSUME_SEND_SYSCALL 1 #endif /* Define that mips64-n32 is a ILP32 ABI to set the correct interface to diff --git a/sysdeps/unix/sysv/linux/mips/mips64/send.c b/sysdeps/unix/sysv/linux/mips/mips64/send.c deleted file mode 100644 index d2c2996a21..0000000000 --- a/sysdeps/unix/sysv/linux/mips/mips64/send.c +++ /dev/null @@ -1 +0,0 @@ -#include <sysdeps/unix/sysv/linux/x86_64/send.c> diff --git a/sysdeps/unix/sysv/linux/mips/syscalls.list b/sysdeps/unix/sysv/linux/mips/syscalls.list index 0f0ecc1ef5..f3621cdd51 100644 --- a/sysdeps/unix/sysv/linux/mips/syscalls.list +++ b/sysdeps/unix/sysv/linux/mips/syscalls.list @@ -17,7 +17,6 @@ getpeername - getpeername i:ipp __getpeername getpeername getsockname - getsockname i:ipp __getsockname getsockname getsockopt - getsockopt i:iiiBN __getsockopt getsockopt listen - listen i:ii __listen listen -send - send Ci:ibni __libc_send __send send setsockopt - setsockopt i:iiibn __setsockopt setsockopt shutdown - shutdown i:ii __shutdown shutdown socket - socket i:iii __socket socket diff --git a/sysdeps/unix/sysv/linux/nios2/sysdep.h b/sysdeps/unix/sysv/linux/nios2/sysdep.h index b1c04cd37b..c7b065bd8a 100644 --- a/sysdeps/unix/sysv/linux/nios2/sysdep.h +++ b/sysdeps/unix/sysv/linux/nios2/sysdep.h @@ -140,6 +140,10 @@ /* In order to get __set_errno() definition in INLINE_SYSCALL. */ #include <errno.h> +/* Previously Nios2 used the generic version without the libc_hidden_def + which lead in a non existent __send symbol in libc.so. */ +# undef HAVE_INTERNAL_SEND_SYMBOL + /* Define a macro which expands into the inline wrapper code for a system call. */ #undef INLINE_SYSCALL diff --git a/sysdeps/unix/sysv/linux/s390/kernel-features.h b/sysdeps/unix/sysv/linux/s390/kernel-features.h index e79191ac84..f44d429365 100644 --- a/sysdeps/unix/sysv/linux/s390/kernel-features.h +++ b/sysdeps/unix/sysv/linux/s390/kernel-features.h @@ -30,7 +30,6 @@ # define __ASSUME_SETSOCKOPT_SYSCALL 1 # define __ASSUME_GETSOCKNAME_SYSCALL 1 # define __ASSUME_GETPEERNAME_SYSCALL 1 -# define __ASSUME_SENDTO_FOR_SEND_SYSCALL 1 # define __ASSUME_SHUTDOWN_SYSCALL 1 #endif diff --git a/sysdeps/unix/sysv/linux/send.c b/sysdeps/unix/sysv/linux/send.c index 4c02c8ba22..c2e3b37b17 100644 --- a/sysdeps/unix/sysv/linux/send.c +++ b/sysdeps/unix/sysv/linux/send.c @@ -15,21 +15,16 @@ License along with the GNU C Library; if not, see <http://www.gnu.org/licenses/>. */ -#include <errno.h> -#include <signal.h> #include <sys/socket.h> - #include <sysdep-cancel.h> #include <socketcall.h> -#include <kernel-features.h> -#include <sys/syscall.h> ssize_t __libc_send (int fd, const void *buf, size_t len, int flags) { #ifdef __ASSUME_SEND_SYSCALL return SYSCALL_CANCEL (send, fd, buf, len, flags); -#elif defined __ASSUME_SENDTO_FOR_SEND_SYSCALL +#elif defined __ASSUME_SENDTO_SYSCALL return SYSCALL_CANCEL (sendto, fd, buf, len, flags, NULL, 0); #else return SOCKETCALL_CANCEL (send, fd, buf, len, flags); @@ -37,4 +32,6 @@ __libc_send (int fd, const void *buf, size_t len, int flags) } weak_alias (__libc_send, send) weak_alias (__libc_send, __send) +#ifdef HAVE_INTERNAL_SEND_SYMBOL libc_hidden_def (__send) +#endif diff --git a/sysdeps/unix/sysv/linux/sparc/sparc64/syscalls.list b/sysdeps/unix/sysv/linux/sparc/sparc64/syscalls.list index 4cfc2afcda..1e85118e36 100644 --- a/sysdeps/unix/sysv/linux/sparc/sparc64/syscalls.list +++ b/sysdeps/unix/sysv/linux/sparc/sparc64/syscalls.list @@ -7,7 +7,6 @@ getpeername - getpeername 3 __getpeername getpeername getsockname - getsockname 3 __getsockname getsockname getsockopt - getsockopt 5 __getsockopt getsockopt listen - listen 2 __listen listen -send - send C:4 __libc_send __send send setsockopt - setsockopt 5 __setsockopt setsockopt shutdown - shutdown 2 __shutdown shutdown socketpair - socketpair 4 __socketpair socketpair diff --git a/sysdeps/unix/sysv/linux/sysdep.h b/sysdeps/unix/sysv/linux/sysdep.h index 02c957eb2f..1c24766e48 100644 --- a/sysdeps/unix/sysv/linux/sysdep.h +++ b/sysdeps/unix/sysv/linux/sysdep.h @@ -62,3 +62,7 @@ #define LO_HI_LONG(val) \ (long) (val), \ (long) (((uint64_t) (val)) >> 32) + +/* Exports the __send symbol on send.c linux implementation (some ABI have + it missing due the usage of a old generic version without it). */ +#define HAVE_INTERNAL_SEND_SYMBOL 1 diff --git a/sysdeps/unix/sysv/linux/tile/sysdep.h b/sysdeps/unix/sysv/linux/tile/sysdep.h index 70ff6b95e7..fb1b89c280 100644 --- a/sysdeps/unix/sysv/linux/tile/sysdep.h +++ b/sysdeps/unix/sysv/linux/tile/sysdep.h @@ -218,6 +218,10 @@ #define HAVE_CLOCK_GETTIME_VSYSCALL 1 #define HAVE_GETTIMEOFDAY_VSYSCALL 1 +/* Previously tile used the generic version without the libc_hidden_def + which lead in a non existent __send symbol in libc.so. */ +#undef HAVE_INTERNAL_SEND_SYMBOL + #endif /* __ASSEMBLER__ */ /* Pointer mangling support. */ diff --git a/sysdeps/unix/sysv/linux/x86_64/send.c b/sysdeps/unix/sysv/linux/x86_64/send.c deleted file mode 100644 index c4af9cdc0c..0000000000 --- a/sysdeps/unix/sysv/linux/x86_64/send.c +++ /dev/null @@ -1,31 +0,0 @@ -/* Copyright (C) 2001-2017 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ - -#include <errno.h> -#include <sys/socket.h> -#include <sysdep-cancel.h> - -/* Send N bytes of BUF to socket FD. Returns the number sent or -1. */ -ssize_t -__libc_send (int fd, const void *buf, size_t n, int flags) -{ - return SYSCALL_CANCEL (sendto, fd, buf, n, flags, NULL, (size_t) 0); -} - -weak_alias (__libc_send, __send) -libc_hidden_weak (__send) -weak_alias (__send, send) |