]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
Consolidate Linux send implementation
authorAdhemerval Zanella <adhemerval.zanella@linaro.com>
Mon, 6 Mar 2017 14:13:03 +0000 (15:13 +0100)
committerAdhemerval Zanella <adhemerval.zanella@linaro.com>
Thu, 9 Mar 2017 14:22:06 +0000 (15:22 +0100)
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.

23 files changed:
ChangeLog
sysdeps/unix/sysv/linux/aarch64/sysdep.h
sysdeps/unix/sysv/linux/alpha/kernel-features.h
sysdeps/unix/sysv/linux/alpha/syscalls.list
sysdeps/unix/sysv/linux/arm/kernel-features.h
sysdeps/unix/sysv/linux/arm/syscalls.list
sysdeps/unix/sysv/linux/generic/send.c [deleted file]
sysdeps/unix/sysv/linux/hppa/kernel-features.h
sysdeps/unix/sysv/linux/hppa/syscalls.list
sysdeps/unix/sysv/linux/i386/kernel-features.h
sysdeps/unix/sysv/linux/ia64/kernel-features.h
sysdeps/unix/sysv/linux/ia64/syscalls.list
sysdeps/unix/sysv/linux/m68k/kernel-features.h
sysdeps/unix/sysv/linux/mips/kernel-features.h
sysdeps/unix/sysv/linux/mips/mips64/send.c [deleted file]
sysdeps/unix/sysv/linux/mips/syscalls.list
sysdeps/unix/sysv/linux/nios2/sysdep.h
sysdeps/unix/sysv/linux/s390/kernel-features.h
sysdeps/unix/sysv/linux/send.c
sysdeps/unix/sysv/linux/sparc/sparc64/syscalls.list
sysdeps/unix/sysv/linux/sysdep.h
sysdeps/unix/sysv/linux/tile/sysdep.h
sysdeps/unix/sysv/linux/x86_64/send.c [deleted file]

index 581ad979de1acaeeb8b5f3398f6183a113aa6cc9..6b5c65c9fb02e165818dde5cf6b05f0d731b0975 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,43 @@
 2016-03-08  Adhemerval Zanella  <adhemerval.zanella@linaro.org>
 
+       * 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.
+
        * sysdeps/unix/sysv/linux/alpha/syscalls.list: Remove sendto from
        auto-generation list.
        * sysdeps/unix/sysv/linux/arm/syscalls.list: Likewise.
index f301638a818811565a7abff017d265d4ec6ed1ae..4bb9112d62d58c20b749385395eccced67e00beb 100644 (file)
 # 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
index 3383a989486235c1ab109bb1f3aa6f3558c94d4c..93ba14a7bf857dd931d7239167d8bf0db816304d 100644 (file)
@@ -32,6 +32,7 @@
 /* Alpha defines SysV ipc shmat syscall with a different name.  */
 #define __NR_shmat __NR_osf_shmat
 
+#define __ASSUME_RECV_SYSCALL  1
 #define __ASSUME_RECV_SYSCALL  1
 
 #endif /* _KERNEL_FEATURES_H */
index 304e97ef6f73ef8042221b6b3a20d5e3ab236ab1..aa21b10a25a010c9dc457e6dc2e2dcf6bacb48b0 100644 (file)
@@ -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
index 104c9f9f1727689c927a34ab3c939503cb48412b..4923dfd85ba9b84db23a020ed5b1e42ff0141151 100644 (file)
@@ -39,3 +39,4 @@
 #define __NR_fadvise64_64 __NR_arm_fadvise64_64
 
 #define __ASSUME_RECV_SYSCALL   1
+#define __ASSUME_SEND_SYSCALL  1
index 4ca4f81f1a3dc199a051b2ebd68ceee55ae316dd..13441f7eb42be2185b96ee520dc9646fe5773bfd 100644 (file)
@@ -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 (file)
index d0cb035..0000000
+++ /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)
index 1fd73982644346ba550528045d591f7f4eb6de3c..0e73a5c0df56b429ffd929ceff03ddde076d77ca 100644 (file)
@@ -26,3 +26,4 @@
 #include_next <kernel-features.h>
 
 #define __ASSUME_RECV_SYSCALL   1
+#define __ASSUME_SEND_SYSCALL  1
index eaa20b35bb660fffe9400213e9e18045428dc31f..cd37573b89e8eead46e66bf6725873e866a340fc 100644 (file)
@@ -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
index 63920340f0eec71dcb367aea68ef7480a024b9f2..96a8e3bc1ddf8eb1082e0b1ebe9ffd49fd690060 100644 (file)
@@ -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
 
index 80e41b68af8be7b28c89874ae7d81e08e76d9c73..ac9403e869dcc52eb8a6f6b1c84f0b03b8df1461 100644 (file)
@@ -29,5 +29,6 @@
 #endif
 
 #define __ASSUME_RECV_SYSCALL          1
+#define __ASSUME_SEND_SYSCALL          1
 
 #endif /* _KERNEL_FEATURES_H */
index 64d47f4d49b512c05e26fd80711f2b0ab63d4964..56f4138c4327e8508cd1db1dc4311c04b528f868 100644 (file)
@@ -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
index 0f590fd7682ba641f9725355a6947b8acc0a701a..55c80d732bf3d9c7ba6f230f398feaef0c52ff26 100644 (file)
@@ -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
 
index 632c860dbb271fc7148311f234b0c69853aa667f..e0a49942791e0cdca78c665dae1bfb0485458f7c 100644 (file)
@@ -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 (file)
index d2c2996..0000000
+++ /dev/null
@@ -1 +0,0 @@
-#include <sysdeps/unix/sysv/linux/x86_64/send.c>
index 0f0ecc1ef5180aad297ca4107b106948f91c5eb1..f3621cdd517f4b017c804e08a2675c981fd8c4eb 100644 (file)
@@ -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
index b1c04cd37b8c61e725b04609829b8edc7415f34a..c7b065bd8a04a068207cdd17bbedec51d1a0fa33 100644 (file)
 /* 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
index e79191ac84e77dfa8988f19531820d7cfb7b5b36..f44d429365d7fcabf1b255c83e917613947edc28 100644 (file)
@@ -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
 
index 4c02c8ba22d914a9126e87e340f4acd138a8b997..c2e3b37b1782877d692e79c4837145afa845273d 100644 (file)
    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
index 4cfc2afcdad06b1e294524886a48f1debdb98f27..1e85118e361bc180c392a0b95ad55a6769d0574d 100644 (file)
@@ -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
index 02c957eb2f24a69530e6c391567767205010b83b..1c24766e481a9486baa5a489cdebe186f654516d 100644 (file)
@@ -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
index 70ff6b95e749fa545932f9372f07d8c834b8a399..fb1b89c28042f3f43d6bb016c467e019c9f53275 100644 (file)
 #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 (file)
index c4af9cd..0000000
+++ /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)