From patchwork Mon Jan 30 14:02:03 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 92864 Delivered-To: patch@linaro.org Received: by 10.182.3.34 with SMTP id 2csp1378029obz; Mon, 30 Jan 2017 06:03:16 -0800 (PST) X-Received: by 10.84.216.86 with SMTP id f22mr32041520plj.117.1485784996210; Mon, 30 Jan 2017 06:03:16 -0800 (PST) Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id i9si8587893pgn.3.2017.01.30.06.03.15 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 30 Jan 2017 06:03:16 -0800 (PST) Received-SPF: pass (google.com: domain of libc-alpha-return-77054-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org; spf=pass (google.com: domain of libc-alpha-return-77054-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-77054-patch=linaro.org@sourceware.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references; q=dns; s=default; b=D3BKCASphKXPXS0rJmpAH8/bv5z0xCF OlVuJpYemPHkK2VJmQsrfL3wNiHj2vNDtQrw6Q/oqjgr7tQw/+V9qyHNhgBLvH+q MMmIgRamaTuRv1i5K14oXnPLYm4W9Repdl1VvbWdhDb854skqQIpZZL8OIZCXe7B HZcCDadbTy9Q= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references; s=default; bh=13HePHSW/U5Y7+dLVrf/D5UdNlY=; b=OZZtk GLr7LmSW4CRfnnSt89nWjpZPN9nRH/0AvGWt/Wd/2Mq+c7j2q+dZnZ5R5h1+ul7W DZGJ+6d931Hy3DTo+aHriWe2M7JUCtbQ9zKO9hbcFb5QgKQcRMt/ZD+XGUOn4dIF Uszu/Jdfs9QXDD1jjk4IiknYF433+8Ga37FS/o= Received: (qmail 46374 invoked by alias); 30 Jan 2017 14:02:35 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 46240 invoked by uid 89); 30 Jan 2017 14:02:34 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.4 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM, SPF_PASS autolearn=no version=3.3.2 spammy=IPC, Strong, correspondent, 15, 16 X-HELO: mail-qt0-f177.google.com X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=HhWLewxmff/2seQ7jVFRv3NRjYbpoocjl+lQjOhk6lU=; b=lneDWQTjQWKaZnPsNN59fskuLM7hDTSVg7XTjHeQtslL1JNfHMkOle8EbBmpw2usAF SN85IrHSmKs0x+PW8tAemYmiSQYVhIr5Kj8GrW7Qia2CyZdzO1G9ir5XCg/Llb0t3rdN 6EzbWh0iWM6HfUmos4R0HR1alNFydTXsn2muKQIexa9GJuOW92N/R6fhLeEL2Yhu7wic UuPf8GG0g/fexzWTHczpllk+d0jLwI7A9Y07H9KKHcsNEfuQhHoyqARvwtlB4UO3iiLo HW6b/KjQ5D/etPmoQnVlZYl+cfvDqiQJ9ZwhcjD4LBwngwmWOAkoNu5UA8KJXyO5qn3v d+Bw== X-Gm-Message-State: AIkVDXIn8zv7m6TF+PcG5g/s3tzYT54/iC8RPKYOzpcPZAdpUxID/zll2fZGzi/bS1DstdZF X-Received: by 10.200.56.164 with SMTP id f33mr21612055qtc.158.1485784942293; Mon, 30 Jan 2017 06:02:22 -0800 (PST) From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH 1/4] Consolidate Linux accept implementation Date: Mon, 30 Jan 2017 12:02:03 -0200 Message-Id: <1485784926-2172-2-git-send-email-adhemerval.zanella@linaro.org> In-Reply-To: <1485784926-2172-1-git-send-email-adhemerval.zanella@linaro.org> References: <1485784926-2172-1-git-send-email-adhemerval.zanella@linaro.org> This patch consolidates the accept Linux syscall implementation on sysdeps/unix/sysv/linux/accept.c. The changes are: 1. Remove accept from auto-generation syscalls.list on the architecture that uses __NR_accept. 2. Define __NR_acccept as default (__ASSUME_ACCEPT_SYSCALL) and undef for architectures that do not support it. 3. Remove __ASSUME_ACCEPT4_FOR_ACCEPT_SYSCALL and decide to use __NR_accept4 for accept generation based on __ASSUME_ACCEPT4_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/accept.c (__libc_accept): Replace __ASSUME_ACCEPT4_FOR_ACCEPT_SYSCALL by __ASSUME_ACCEPT4_SYSCALL. * sysdeps/unix/sysv/linux/alpha/syscalls.list: Remove accept from auto-generation list. * sysdeps/unix/sysv/linux/arm/syscalls.list: Likewise. * sysdeps/unix/sysv/linux/generic/syscalls.list: Likewise. * sysdeps/unix/sysv/linux/hppa/syscalls.list: Likewise. * sysdeps/unix/sysv/linux/ia64/syscalls.list: Likewise. * sysdeps/unix/sysv/linux/mips/syscalls.list: Likewise. * sysdeps/unix/sysv/linux/sparc/sparc64/syscalls.list: Likewise. * sysdeps/unix/sysv/linux/x86_64/syscalls.list: Likewise. * sysdeps/unix/sysv/linux/i386/kernel-features.h (__ASSUME_ACCEPT4_FOR_ACCEPT_SYSCALL): Remove define. (__ASSUME_ACCEPT_SYSCALL): Undefine. * sysdeps/unix/sysv/linux/kernel-features.h (__ASSUME_ACCEPT_SYSCALL): New define. * sysdeps/unix/sysv/linux/m68k/kernel-features.h (__ASSUME_ACCEPT4_FOR_ACCEPT_SYSCALL): Remove define. (__ASSUME_ACCEPT_SYSCALL): Define wheter kernel version supports. * sysdeps/unix/sysv/linux/microblaze/kernel-features.h (__ASSUME_ACCEPT_SYSCALL): Define. * sysdeps/unix/sysv/linux/powerpc/kernel-features.h (__ASSUME_ACCEPT_SYSCALL): Undefine. * sysdeps/unix/sysv/linux/s390/kernel-features.h (__ASSUME_ACCEPT4_FOR_ACCEPT_SYSCALL): Remove define. (__ASSUME_ACCEPT_SYSCALL): Undefine. * sysdeps/unix/sysv/linux/sh/kernel-features.h (__ASSUME_ACCEPT_SYSCALL): Undefine. * sysdeps/unix/sysv/linux/sparc/kernel-features.h (__ASSUME_ACCEPT_SYSCALL): Undefine for 32 bits. --- ChangeLog | 33 ++++++++++++++++++++++ sysdeps/unix/sysv/linux/accept.c | 7 +---- sysdeps/unix/sysv/linux/alpha/syscalls.list | 1 - sysdeps/unix/sysv/linux/arm/syscalls.list | 1 - sysdeps/unix/sysv/linux/generic/syscalls.list | 1 - sysdeps/unix/sysv/linux/hppa/syscalls.list | 1 - sysdeps/unix/sysv/linux/i386/kernel-features.h | 3 +- sysdeps/unix/sysv/linux/ia64/syscalls.list | 1 - sysdeps/unix/sysv/linux/kernel-features.h | 1 + sysdeps/unix/sysv/linux/m68k/kernel-features.h | 4 ++- .../unix/sysv/linux/microblaze/kernel-features.h | 1 - sysdeps/unix/sysv/linux/mips/syscalls.list | 1 - sysdeps/unix/sysv/linux/powerpc/kernel-features.h | 1 - sysdeps/unix/sysv/linux/s390/kernel-features.h | 3 +- sysdeps/unix/sysv/linux/sh/kernel-features.h | 1 - sysdeps/unix/sysv/linux/sparc/kernel-features.h | 4 +++ .../unix/sysv/linux/sparc/sparc64/syscalls.list | 1 - sysdeps/unix/sysv/linux/x86_64/syscalls.list | 1 - 18 files changed, 46 insertions(+), 20 deletions(-) -- 2.7.4 diff --git a/sysdeps/unix/sysv/linux/accept.c b/sysdeps/unix/sysv/linux/accept.c index c5935ab..2fb59b7 100644 --- a/sysdeps/unix/sysv/linux/accept.c +++ b/sysdeps/unix/sysv/linux/accept.c @@ -15,21 +15,16 @@ License along with the GNU C Library; if not, see . */ -#include -#include #include - #include #include -#include -#include int __libc_accept (int fd, __SOCKADDR_ARG addr, socklen_t *len) { #ifdef __ASSUME_ACCEPT_SYSCALL return SYSCALL_CANCEL (accept, fd, addr.__sockaddr__, len); -#elif defined __ASSUME_ACCEPT4_FOR_ACCEPT_SYSCALL +#elif defined __ASSUME_ACCEPT4_SYSCALL return SYSCALL_CANCEL (accept4, fd, addr.__sockaddr__, len, 0); #else return SOCKETCALL_CANCEL (accept, fd, addr.__sockaddr__, len); diff --git a/sysdeps/unix/sysv/linux/alpha/syscalls.list b/sysdeps/unix/sysv/linux/alpha/syscalls.list index 4001020..4cfe19e 100644 --- a/sysdeps/unix/sysv/linux/alpha/syscalls.list +++ b/sysdeps/unix/sysv/linux/alpha/syscalls.list @@ -5,7 +5,6 @@ sigstack - sigstack 2 sigstack getpriority - getpriority i:ii __getpriority getpriority # proper socket implementations: -accept - accept Ci:iBN __libc_accept __accept accept bind - bind i:ipi __bind bind connect - connect Ci:ipi __libc_connect __connect connect getpeername - getpeername i:ipp __getpeername getpeername diff --git a/sysdeps/unix/sysv/linux/arm/syscalls.list b/sysdeps/unix/sysv/linux/arm/syscalls.list index 0263eee..1c4f61f 100644 --- a/sysdeps/unix/sysv/linux/arm/syscalls.list +++ b/sysdeps/unix/sysv/linux/arm/syscalls.list @@ -22,7 +22,6 @@ fanotify_mark EXTRA fanotify_mark i:iiiiis fanotify_mark personality EXTRA personality Ei:i __personality personality # proper socket implementations: -accept - accept Ci:iBN __libc_accept __accept accept bind - bind i:ipi __bind bind connect - connect Ci:ipi __libc_connect __connect connect getpeername - getpeername i:ipp __getpeername getpeername diff --git a/sysdeps/unix/sysv/linux/generic/syscalls.list b/sysdeps/unix/sysv/linux/generic/syscalls.list index 3bb5473..b176a72 100644 --- a/sysdeps/unix/sysv/linux/generic/syscalls.list +++ b/sysdeps/unix/sysv/linux/generic/syscalls.list @@ -5,7 +5,6 @@ socket - socket i:iii __socket socket socketpair - socketpair i:iiif __socketpair socketpair bind - bind i:ipi __bind bind listen - listen i:ii __listen listen -accept - accept Ci:iBN __libc_accept __accept accept connect - connect Ci:ipi __libc_connect __connect connect getsockname - getsockname i:ipp __getsockname getsockname getpeername - getpeername i:ipp __getpeername getpeername diff --git a/sysdeps/unix/sysv/linux/hppa/syscalls.list b/sysdeps/unix/sysv/linux/hppa/syscalls.list index 6d47b11..ee814fb 100644 --- a/sysdeps/unix/sysv/linux/hppa/syscalls.list +++ b/sysdeps/unix/sysv/linux/hppa/syscalls.list @@ -1,7 +1,6 @@ # File name Caller Syscall name # args Strong name Weak names # proper socket implementations: -accept - accept Ci:iBN __libc_accept __accept accept bind - bind i:ipi __bind bind connect - connect Ci:ipi __libc_connect __connect connect getpeername - getpeername i:ipp __getpeername getpeername diff --git a/sysdeps/unix/sysv/linux/i386/kernel-features.h b/sysdeps/unix/sysv/linux/i386/kernel-features.h index 2696d1a..07462f8 100644 --- a/sysdeps/unix/sysv/linux/i386/kernel-features.h +++ b/sysdeps/unix/sysv/linux/i386/kernel-features.h @@ -33,7 +33,6 @@ # define __ASSUME_BIND_SYSCALL 1 # define __ASSUME_CONNECT_SYSCALL 1 # define __ASSUME_LISTEN_SYSCALL 1 -# define __ASSUME_ACCEPT4_FOR_ACCEPT_SYSCALL 1 # define __ASSUME_GETSOCKOPT_SYSCALL 1 # define __ASSUME_SETSOCKOPT_SYSCALL 1 # define __ASSUME_GETSOCKNAME_SYSCALL 1 @@ -47,6 +46,8 @@ #include_next +#undef __ASSUME_ACCEPT_SYSCALL + #if __LINUX_KERNEL_VERSION < 0x040300 # undef __ASSUME_ACCEPT4_SYSCALL # undef __ASSUME_SENDMSG_SYSCALL diff --git a/sysdeps/unix/sysv/linux/ia64/syscalls.list b/sysdeps/unix/sysv/linux/ia64/syscalls.list index dd07db3..96db4c3 100644 --- a/sysdeps/unix/sysv/linux/ia64/syscalls.list +++ b/sysdeps/unix/sysv/linux/ia64/syscalls.list @@ -5,7 +5,6 @@ umount2 - umount 2 __umount2 umount2 getpriority - getpriority i:ii __getpriority getpriority # proper socket implementations: -accept - accept Ci:iBN __libc_accept __accept accept bind - bind i:ipi __bind bind connect - connect Ci:ipi __libc_connect __connect connect getpeername - getpeername i:ipp __getpeername getpeername diff --git a/sysdeps/unix/sysv/linux/kernel-features.h b/sysdeps/unix/sysv/linux/kernel-features.h index 08485cd..78b091b 100644 --- a/sysdeps/unix/sysv/linux/kernel-features.h +++ b/sysdeps/unix/sysv/linux/kernel-features.h @@ -147,6 +147,7 @@ separate syscalls were only added later. */ #define __ASSUME_SENDMSG_SYSCALL 1 #define __ASSUME_RECVMSG_SYSCALL 1 +#define __ASSUME_ACCEPT_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/m68k/kernel-features.h b/sysdeps/unix/sysv/linux/m68k/kernel-features.h index 6811a28..f583ae7 100644 --- a/sysdeps/unix/sysv/linux/m68k/kernel-features.h +++ b/sysdeps/unix/sysv/linux/m68k/kernel-features.h @@ -27,7 +27,6 @@ # define __ASSUME_BIND_SYSCALL 1 # define __ASSUME_CONNECT_SYSCALL 1 # define __ASSUME_LISTEN_SYSCALL 1 -# define __ASSUME_ACCEPT4_FOR_ACCEPT_SYSCALL 1 # define __ASSUME_GETSOCKOPT_SYSCALL 1 # define __ASSUME_SETSOCKOPT_SYSCALL 1 # define __ASSUME_GETSOCKNAME_SYSCALL 1 @@ -41,7 +40,10 @@ #include_next +#undef __ASSUME_ACCEPT_SYSCALL + #if __LINUX_KERNEL_VERSION < 0x040300 +# undef __ASSUME_ACCCEPT_SYSCALL # undef __ASSUME_ACCEPT4_SYSCALL # undef __ASSUME_RECVMMSG_SYSCALL # undef __ASSUME_SENDMMSG_SYSCALL diff --git a/sysdeps/unix/sysv/linux/microblaze/kernel-features.h b/sysdeps/unix/sysv/linux/microblaze/kernel-features.h index f68e8c5..9532d57 100644 --- a/sysdeps/unix/sysv/linux/microblaze/kernel-features.h +++ b/sysdeps/unix/sysv/linux/microblaze/kernel-features.h @@ -24,7 +24,6 @@ #define __ASSUME_BIND_SYSCALL 1 #define __ASSUME_CONNECT_SYSCALL 1 #define __ASSUME_LISTEN_SYSCALL 1 -#define __ASSUME_ACCEPT_SYSCALL 1 #define __ASSUME_GETSOCKNAME_SYSCALL 1 #define __ASSUME_GETPEERNAME_SYSCALL 1 #define __ASSUME_SOCKETPAIR_SYSCALL 1 diff --git a/sysdeps/unix/sysv/linux/mips/syscalls.list b/sysdeps/unix/sysv/linux/mips/syscalls.list index cd946a0..81ea2a7 100644 --- a/sysdeps/unix/sysv/linux/mips/syscalls.list +++ b/sysdeps/unix/sysv/linux/mips/syscalls.list @@ -12,7 +12,6 @@ sysmips - sysmips i:iiii __sysmips sysmips # Socket functions; Linux/MIPS doesn't use the socketcall(2) wrapper; # it's provided for compatibility, though. # -accept - accept Ci:iBN __libc_accept __accept accept bind - bind i:ipi __bind bind connect - connect Ci:ipi __libc_connect __connect connect getpeername - getpeername i:ipp __getpeername getpeername diff --git a/sysdeps/unix/sysv/linux/powerpc/kernel-features.h b/sysdeps/unix/sysv/linux/powerpc/kernel-features.h index 02dadc8..272800c 100644 --- a/sysdeps/unix/sysv/linux/powerpc/kernel-features.h +++ b/sysdeps/unix/sysv/linux/powerpc/kernel-features.h @@ -25,7 +25,6 @@ #define __ASSUME_BIND_SYSCALL 1 #define __ASSUME_CONNECT_SYSCALL 1 #define __ASSUME_LISTEN_SYSCALL 1 -#define __ASSUME_ACCEPT_SYSCALL 1 #define __ASSUME_GETSOCKNAME_SYSCALL 1 #define __ASSUME_GETPEERNAME_SYSCALL 1 #define __ASSUME_SOCKETPAIR_SYSCALL 1 diff --git a/sysdeps/unix/sysv/linux/s390/kernel-features.h b/sysdeps/unix/sysv/linux/s390/kernel-features.h index 4e04d26..ccfb0a2 100644 --- a/sysdeps/unix/sysv/linux/s390/kernel-features.h +++ b/sysdeps/unix/sysv/linux/s390/kernel-features.h @@ -27,7 +27,6 @@ # define __ASSUME_BIND_SYSCALL 1 # define __ASSUME_CONNECT_SYSCALL 1 # define __ASSUME_LISTEN_SYSCALL 1 -# define __ASSUME_ACCEPT4_FOR_ACCEPT_SYSCALL 1 # define __ASSUME_GETSOCKOPT_SYSCALL 1 # define __ASSUME_SETSOCKOPT_SYSCALL 1 # define __ASSUME_GETSOCKNAME_SYSCALL 1 @@ -41,6 +40,8 @@ #include_next +#undef __ASSUME_ACCEPT_SYSCALL + #if __LINUX_KERNEL_VERSION < 0x040300 # undef __ASSUME_ACCEPT4_SYSCALL # undef __ASSUME_RECVMMSG_SYSCALL diff --git a/sysdeps/unix/sysv/linux/sh/kernel-features.h b/sysdeps/unix/sysv/linux/sh/kernel-features.h index 10a669f..7a83211 100644 --- a/sysdeps/unix/sysv/linux/sh/kernel-features.h +++ b/sysdeps/unix/sysv/linux/sh/kernel-features.h @@ -28,7 +28,6 @@ #define __ASSUME_BIND_SYSCALL 1 #define __ASSUME_CONNECT_SYSCALL 1 #define __ASSUME_LISTEN_SYSCALL 1 -#define __ASSUME_ACCEPT_SYSCALL 1 #define __ASSUME_GETSOCKNAME_SYSCALL 1 #define __ASSUME_GETPEERNAME_SYSCALL 1 #define __ASSUME_SOCKETPAIR_SYSCALL 1 diff --git a/sysdeps/unix/sysv/linux/sparc/kernel-features.h b/sysdeps/unix/sysv/linux/sparc/kernel-features.h index f78ae85..3ffa96e 100644 --- a/sysdeps/unix/sysv/linux/sparc/kernel-features.h +++ b/sysdeps/unix/sysv/linux/sparc/kernel-features.h @@ -38,5 +38,9 @@ # undef __ASSUME_SET_ROBUST_LIST #endif +#if !defined __arch64__ +# undef __ASSUME_ACCEPT_SYSCALL +#endif + /* sparc only supports ipc syscall. */ #undef __ASSUME_DIRECT_SYSVIPC_SYSCALLS diff --git a/sysdeps/unix/sysv/linux/sparc/sparc64/syscalls.list b/sysdeps/unix/sysv/linux/sparc/sparc64/syscalls.list index eecd837..27ca5fa 100644 --- a/sysdeps/unix/sysv/linux/sparc/sparc64/syscalls.list +++ b/sysdeps/unix/sysv/linux/sparc/sparc64/syscalls.list @@ -2,7 +2,6 @@ # Override select.S in parent directory: select - select C:5 __select select -accept - accept C:3 __libc_accept __accept accept bind - bind 3 __bind bind connect - connect C:3 __libc_connect __connect connect getpeername - getpeername 3 __getpeername getpeername diff --git a/sysdeps/unix/sysv/linux/x86_64/syscalls.list b/sysdeps/unix/sysv/linux/x86_64/syscalls.list index 45d5ebf..fe7d156 100644 --- a/sysdeps/unix/sysv/linux/x86_64/syscalls.list +++ b/sysdeps/unix/sysv/linux/x86_64/syscalls.list @@ -10,7 +10,6 @@ syscall_clock_gettime EXTRA clock_gettime Ei:ip __syscall_clock_gettime # proper socket implementations: -accept - accept Ci:iBN __libc_accept __accept accept bind - bind i:ipi __bind bind connect - connect Ci:ipi __libc_connect __connect connect getpeername - getpeername i:ipp __getpeername getpeername