From patchwork Tue Mar 7 10:51:53 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 736119 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3vctn31DZPz9s73 for ; Tue, 7 Mar 2017 21:53:42 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="t4Jcm/bu"; dkim-atps=neutral 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:cc:subject:date:message-id:in-reply-to :references; q=dns; s=default; b=YIJg+YbSPAxoh+H+S1uPQcSWdHZn3Ob PKM+i7OcSq7sIH67citv1ukOBnrXxnPsWBW/zILUHQky5GB6bjNjuwgEHGkrKLQ5 falwp1x2giV/bGF+UwByweBRWFtEUsJ+TXIv+b/lZmUJlBdC0inAJu/twcsopwVi CzGCnA5ZkUgE= 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:cc:subject:date:message-id:in-reply-to :references; s=default; bh=T6sfQfI1zwIB+/HlMe1qvqE8Ing=; b=t4Jcm /buDRUEKUOwPVQyRxI+SlDVliEXQ6hOOlbiuEurhHa3QCQbqh8NnlL9MVoutTfZV Yfb8tKwJRc8ATyX6sAQJpU9HAXUr7ySYGGS1/NL+lpyNf9GjNaZX5km4fFhJ4mGs CZHfVnvSTBRP0TfY5Pezys8LMP8RGtdY+YBQgg= Received: (qmail 86013 invoked by alias); 7 Mar 2017 10:52:11 -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 85961 invoked by uid 89); 7 Mar 2017 10:52:11 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.3 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=284, Alpha X-HELO: mail-wr0-f180.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:cc:subject:date:message-id:in-reply-to :references; bh=MlkCVJJUVsLEFCdex9Vj7OK9MZEc6j3PByMoXKL9Y7g=; b=ZO2UlaFQyjOaf3TZmrND77iu8LPTi589DdOocFEpvZ87l1ZQnxIoWUQakynD3F1Eae 57hCkhionD4vfOU0BHhrjQv/tXKngsKglse1yoE2kxxUyCEMK13LVlvb1bs0fg0CgVbq po7WFPJal2IP40ZX4buegT/02ZPF74mTHrFbNAkAaLjuLpkuKIW2MZ37IB9zwPb8YN1O CHfCeW+Sh+s/pvPWLV23TAGZvWpqLZnZ7f+fnsxkML4sTn7M/KPCznSqbu88vSwruuhr 49rGJ+SAKkGF4XiWJ71pVbLiIlB+1+XqqdmOg7ZipWwWzLZg0VKpMxH4HfzL1l0T/u/k UM5g== X-Gm-Message-State: AMke39mfoIoV7ch+lRb1NWdm1ZX257Ilb2Z5v7LF1atvXC8w+FOtqunne/0uDJ+xzjsyiQ0g X-Received: by 10.223.154.50 with SMTP id z47mr18469992wrb.76.1488883923423; Tue, 07 Mar 2017 02:52:03 -0800 (PST) From: Adhemerval Zanella X-Google-Original-From: Adhemerval Zanella To: libc-alpha@sourceware.org Cc: Adhemerval Zanella Subject: [PATCH 4/6] Consolidate Linux recv implementation Date: Tue, 7 Mar 2017 11:51:53 +0100 Message-Id: <1488883915-29716-5-git-send-email-adhemerval.zanella@linaro.com> In-Reply-To: <1488883915-29716-1-git-send-email-adhemerval.zanella@linaro.com> References: <1488883915-29716-1-git-send-email-adhemerval.zanella@linaro.com> From: Adhemerval Zanella This patch consolidates the recv Linux syscall implementation on sysdeps/unix/sysv/linux/recv.c. The changes are: 1. Remove recv from auto-generation syscalls.list on the architecture that uses __NR_recv. 2. Define __NR_recv for architectures that supports it. It was done instead of defining in default kernel-features.h because current Linux practice for new ports is to implement only __NR_recvfrom [1] and it will require adding new kernel-features for ports that do not require it (aarch64 for instance). 3. Remove __ASSUME_RECVFROM_FOR_RECV_SYSCALL and decide to use __NR_recvfrom for recv generation based on __ASSUME_RECVFROM_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/alpha/syscalls.list: Remove recv 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: Likewise. * sysdeps/unix/sysv/linux/mips/syscalls.list: Likewise. * sysdeps/unix/sysv/linux/sparc/sparc64/syscalls.list: Likewise. * sysdeps/unix/sysv/linux/alpha/kernel-features.h (__ASSUME_RECV_SYSCALL): New 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_RECVFROM_FOR_RECV_SYSCALL): Remove define. * sysdeps/unix/sysv/linux/m68k/kernel-features.h (__ASSUME_RECVFROM_FOR_RECV_SYSCALL): Remove define. * sysdeps/unix/sysv/linux/s390/kernel-features.h (__ASSUME_RECVFROM_FOR_RECV_SYSCALL): Remove define. * sysdeps/unix/sysv/linux/generic/recv.c: Remove file. * sysdeps/unix/sysv/linux/mips/mips64/recv.c: Likewise. * sysdeps/unix/sysv/linux/x86_64/recv.c: Likewise. * sysdeps/unix/sysv/linux/recv.c: Simplify includes. (__libc_recv): Use __ASSUME_RECVFROM_SYSCALL instead of __ASSUME_RECVFROM_FOR_RECV_SYSCALL to issue recvfrom syscall. [1] include/asm-generic/unistd.h (__ARCH_WANT_SYSCALL_DEPRECATED) --- ChangeLog | 30 ++++++++++++++++++++ sysdeps/unix/sysv/linux/alpha/kernel-features.h | 2 ++ sysdeps/unix/sysv/linux/alpha/syscalls.list | 1 - sysdeps/unix/sysv/linux/arm/kernel-features.h | 2 ++ sysdeps/unix/sysv/linux/arm/syscalls.list | 1 - sysdeps/unix/sysv/linux/generic/recv.c | 32 --------------------- sysdeps/unix/sysv/linux/hppa/kernel-features.h | 2 ++ sysdeps/unix/sysv/linux/hppa/syscalls.list | 1 - sysdeps/unix/sysv/linux/i386/kernel-features.h | 1 - sysdeps/unix/sysv/linux/ia64/kernel-features.h | 2 ++ sysdeps/unix/sysv/linux/ia64/syscalls.list | 1 - sysdeps/unix/sysv/linux/m68k/kernel-features.h | 1 - sysdeps/unix/sysv/linux/mips/kernel-features.h | 3 ++ sysdeps/unix/sysv/linux/mips/mips64/recv.c | 1 - sysdeps/unix/sysv/linux/mips/syscalls.list | 1 - sysdeps/unix/sysv/linux/recv.c | 7 +---- sysdeps/unix/sysv/linux/s390/kernel-features.h | 1 - .../unix/sysv/linux/sparc/sparc64/syscalls.list | 1 - sysdeps/unix/sysv/linux/x86_64/recv.c | 33 ---------------------- 19 files changed, 42 insertions(+), 81 deletions(-) delete mode 100644 sysdeps/unix/sysv/linux/generic/recv.c delete mode 100644 sysdeps/unix/sysv/linux/mips/mips64/recv.c delete mode 100644 sysdeps/unix/sysv/linux/x86_64/recv.c diff --git a/sysdeps/unix/sysv/linux/alpha/kernel-features.h b/sysdeps/unix/sysv/linux/alpha/kernel-features.h index 0614c78..3383a98 100644 --- a/sysdeps/unix/sysv/linux/alpha/kernel-features.h +++ b/sysdeps/unix/sysv/linux/alpha/kernel-features.h @@ -32,4 +32,6 @@ /* Alpha defines SysV ipc shmat syscall with a different name. */ #define __NR_shmat __NR_osf_shmat +#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 9cb44c1..8a62b6e 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 -recv - recv Ci:ibni __libc_recv __recv recv send - send Ci:ibni __libc_send __send send sendto - sendto Ci:ibnibn __libc_sendto __sendto sendto setsockopt - setsockopt i:iiibn __setsockopt setsockopt diff --git a/sysdeps/unix/sysv/linux/arm/kernel-features.h b/sysdeps/unix/sysv/linux/arm/kernel-features.h index a3c0d9a..104c9f9 100644 --- a/sysdeps/unix/sysv/linux/arm/kernel-features.h +++ b/sysdeps/unix/sysv/linux/arm/kernel-features.h @@ -37,3 +37,5 @@ /* ARM only has a syscall for fadvise64{_64} and it is defined with a non-standard name. */ #define __NR_fadvise64_64 __NR_arm_fadvise64_64 + +#define __ASSUME_RECV_SYSCALL 1 diff --git a/sysdeps/unix/sysv/linux/arm/syscalls.list b/sysdeps/unix/sysv/linux/arm/syscalls.list index dc4f52a..9f445e6 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 -recv - recv Ci:ibni __libc_recv __recv recv send - send Ci:ibni __libc_send __send send sendto - sendto Ci:ibnibn __libc_sendto __sendto sendto setsockopt - setsockopt i:iiibn __setsockopt setsockopt diff --git a/sysdeps/unix/sysv/linux/generic/recv.c b/sysdeps/unix/sysv/linux/generic/recv.c deleted file mode 100644 index c1aebd7..0000000 --- a/sysdeps/unix/sysv/linux/generic/recv.c +++ /dev/null @@ -1,32 +0,0 @@ -/* Copyright (C) 2011-2017 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Chris Metcalf , 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 - . */ - -#include -#include -#include -#include - -ssize_t -__libc_recv (int sockfd, void *buffer, size_t len, int flags) -{ - return SYSCALL_CANCEL (recvfrom, sockfd, buffer, len, flags, - NULL, NULL); -} -strong_alias (__libc_recv, __recv) -libc_hidden_def (__recv) -weak_alias (__libc_recv, recv) diff --git a/sysdeps/unix/sysv/linux/hppa/kernel-features.h b/sysdeps/unix/sysv/linux/hppa/kernel-features.h index 7ff5434..1fd7398 100644 --- a/sysdeps/unix/sysv/linux/hppa/kernel-features.h +++ b/sysdeps/unix/sysv/linux/hppa/kernel-features.h @@ -24,3 +24,5 @@ #endif #include_next + +#define __ASSUME_RECV_SYSCALL 1 diff --git a/sysdeps/unix/sysv/linux/hppa/syscalls.list b/sysdeps/unix/sysv/linux/hppa/syscalls.list index 8834115..1248877 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 -recv - recv Ci:ibni __libc_recv __recv recv send - send Ci:ibni __libc_send __send send sendto - sendto Ci:ibnibn __libc_sendto __sendto sendto setsockopt - setsockopt i:iiibn __setsockopt setsockopt diff --git a/sysdeps/unix/sysv/linux/i386/kernel-features.h b/sysdeps/unix/sysv/linux/i386/kernel-features.h index 4ccab5d..a886442 100644 --- a/sysdeps/unix/sysv/linux/i386/kernel-features.h +++ b/sysdeps/unix/sysv/linux/i386/kernel-features.h @@ -38,7 +38,6 @@ # define __ASSUME_GETPEERNAME_SYSCALL 1 # define __ASSUME_SENDTO_SYSCALL 1 # define __ASSUME_SENDTO_FOR_SEND_SYSCALL 1 -# define __ASSUME_RECVFROM_FOR_RECV_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 d13e403..80e41b6 100644 --- a/sysdeps/unix/sysv/linux/ia64/kernel-features.h +++ b/sysdeps/unix/sysv/linux/ia64/kernel-features.h @@ -28,4 +28,6 @@ # undef __ASSUME_ACCEPT4 #endif +#define __ASSUME_RECV_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 57020a9..24e9c98 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 -recv - recv Ci:ibni __libc_recv __recv recv send - send Ci:ibni __libc_send __send send sendto - sendto Ci:ibnibn __libc_sendto __sendto sendto setsockopt - setsockopt i:iiibn __setsockopt setsockopt diff --git a/sysdeps/unix/sysv/linux/m68k/kernel-features.h b/sysdeps/unix/sysv/linux/m68k/kernel-features.h index fa874b3..f2b4958 100644 --- a/sysdeps/unix/sysv/linux/m68k/kernel-features.h +++ b/sysdeps/unix/sysv/linux/m68k/kernel-features.h @@ -32,7 +32,6 @@ # define __ASSUME_GETPEERNAME_SYSCALL 1 # define __ASSUME_SENDTO_SYSCALL 1 # define __ASSUME_SENDTO_FOR_SEND_SYSCALL 1 -# define __ASSUME_RECVFROM_FOR_RECV_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 7db5338..632c860 100644 --- a/sysdeps/unix/sysv/linux/mips/kernel-features.h +++ b/sysdeps/unix/sysv/linux/mips/kernel-features.h @@ -37,6 +37,9 @@ /* The o32 MIPS fadvise64 syscall behaves as fadvise64_64. */ # define __ASSUME_FADVISE64_AS_64_64 1 + +/* mips32 support wire-up network syscalls. */ +# define __ASSUME_RECV_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/recv.c b/sysdeps/unix/sysv/linux/mips/mips64/recv.c deleted file mode 100644 index b910525..0000000 --- a/sysdeps/unix/sysv/linux/mips/mips64/recv.c +++ /dev/null @@ -1 +0,0 @@ -#include diff --git a/sysdeps/unix/sysv/linux/mips/syscalls.list b/sysdeps/unix/sysv/linux/mips/syscalls.list index 053574e..48a33bb 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 -recv - recv Ci:ibni __libc_recv __recv recv send - send Ci:ibni __libc_send __send send sendto - sendto Ci:ibnibn __libc_sendto __sendto sendto setsockopt - setsockopt i:iiibn __setsockopt setsockopt diff --git a/sysdeps/unix/sysv/linux/recv.c b/sysdeps/unix/sysv/linux/recv.c index 6d62cf8..2467d99 100644 --- a/sysdeps/unix/sysv/linux/recv.c +++ b/sysdeps/unix/sysv/linux/recv.c @@ -15,21 +15,16 @@ License along with the GNU C Library; if not, see . */ -#include -#include #include - #include #include -#include -#include ssize_t __libc_recv (int fd, void *buf, size_t len, int flags) { #ifdef __ASSUME_RECV_SYSCALL return SYSCALL_CANCEL (recv, fd, buf, len, flags); -#elif defined __ASSUME_RECVFROM_FOR_RECV_SYSCALL +#elif defined __ASSUME_RECVFROM_SYSCALL return SYSCALL_CANCEL (recvfrom, fd, buf, len, flags, NULL, NULL); #else return SOCKETCALL_CANCEL (recv, fd, buf, len, flags); diff --git a/sysdeps/unix/sysv/linux/s390/kernel-features.h b/sysdeps/unix/sysv/linux/s390/kernel-features.h index 29738af..59bc434 100644 --- a/sysdeps/unix/sysv/linux/s390/kernel-features.h +++ b/sysdeps/unix/sysv/linux/s390/kernel-features.h @@ -32,7 +32,6 @@ # define __ASSUME_GETPEERNAME_SYSCALL 1 # define __ASSUME_SENDTO_SYSCALL 1 # define __ASSUME_SENDTO_FOR_SEND_SYSCALL 1 -# define __ASSUME_RECVFROM_FOR_RECV_SYSCALL 1 # define __ASSUME_SHUTDOWN_SYSCALL 1 #endif diff --git a/sysdeps/unix/sysv/linux/sparc/sparc64/syscalls.list b/sysdeps/unix/sysv/linux/sparc/sparc64/syscalls.list index f73b519..bf2cfdc 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 -recv - recv C:4 __libc_recv __recv recv send - send C:4 __libc_send __send send sendto - sendto C:6 __libc_sendto __sendto sendto setsockopt - setsockopt 5 __setsockopt setsockopt diff --git a/sysdeps/unix/sysv/linux/x86_64/recv.c b/sysdeps/unix/sysv/linux/x86_64/recv.c deleted file mode 100644 index 10be5d5..0000000 --- a/sysdeps/unix/sysv/linux/x86_64/recv.c +++ /dev/null @@ -1,33 +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 - . */ - -#include -#include -#include - -/* Read N bytes into BUF from socket FD. - Returns the number read or -1 for errors. */ - -ssize_t -__libc_recv (int fd, void *buf, size_t n, int flags) -{ - return SYSCALL_CANCEL (recvfrom, fd, buf, n, flags, NULL, NULL); -} - -weak_alias (__libc_recv, __recv) -libc_hidden_weak (__recv) -weak_alias (__recv, recv)