From patchwork Fri Jan 13 17:37:00 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 91479 Delivered-To: patch@linaro.org Received: by 10.140.20.99 with SMTP id 90csp301119qgi; Fri, 13 Jan 2017 09:37:34 -0800 (PST) X-Received: by 10.98.30.1 with SMTP id e1mr23923876pfe.28.1484329054734; Fri, 13 Jan 2017 09:37:34 -0800 (PST) Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id 33si13297082pld.258.2017.01.13.09.37.34 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 13 Jan 2017 09:37:34 -0800 (PST) Received-SPF: pass (google.com: domain of libc-alpha-return-76778-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-76778-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-76778-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; q=dns; s= default; b=Xbh4pPswVmjB7urRsUujBn0kl6T9V5uWtOUQ9PYKB98+7wCFPxLJi DU9byglk8WrpejP9zSSfGi3nOR0ywKQNlj9jdVK+hQPsCPqs0GSqwN5B6MNOW5Bc DcFypmkwoKV9s+lPtX8SigBSOPvCnZYChRXJz5H7nKOw/PRMpnTlgM= 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; s=default; bh=5kXwxpQGRlDOe2e1OCK39QehFZE=; b=F9ggpEf7qLuO45qhC7dVV2FJolAY EjxCBEjSo86PB9c4jVXfRsfXsqH1jsf7N48+ItCBmelp0Qs+ckVcLtXlo9N/T5pn S6TOzJH7CFSApXJuJCHz2n9JsNyhJXykN9vUA7tcreAePwo9rOfhfM2YAMCfykNd VAQg3VsVjFE2DIg= Received: (qmail 34458 invoked by alias); 13 Jan 2017 17:37:21 -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 34443 invoked by uid 89); 13 Jan 2017 17:37:20 -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=sk:15d72d4 X-HELO: mail-vk0-f41.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; bh=B86BA1HgZwhz0+UwEVjsIpcHcEZcqAfyt9tP2Fcv9yM=; b=K5bN9q4NuL4/v+MKtVuz/a8YF5+Qn2XtXr8DGV19eVgP07lr7vLZ1KPX2R9Ij0nrMW cgqgfqrNDP3gcFTSkF0Stes6Tp6CqTWhvE69OSx0p7Tvq3BphhUBfJNvFCNdjQJtUTcq HGcb3J3dgih2npNGaP/rb4BaJT8M5a04MsFCBX8sRzW8luI+iF07WFGjjJ7m8lemgmBG 8aY/iQTjjs3EEzSZvp8Y/abkF1/VVHChuhGmRvVVgxhPvYUvkUnoMtmRVE++zGnbdl3W B9QyOuaq1DdEHy4hGH0cwuWgPgUnA54nxDGe/FdzgJwmia/g8o1YnAW3A2lZiDTsjNFO hgeQ== X-Gm-Message-State: AIkVDXKplfVqbtB1K6Qt9ogbwBBJCOxHzqfQXit9FV5ZH0tfOYZofeioVLrRtAj7trX87Djm X-Received: by 10.31.151.13 with SMTP id z13mr10434179vkd.41.1484329027441; Fri, 13 Jan 2017 09:37:07 -0800 (PST) From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH] Consolidate arm and mips posix_fadvise implementations Date: Fri, 13 Jan 2017 15:37:00 -0200 Message-Id: <1484329020-6130-1-git-send-email-adhemerval.zanella@linaro.org> As noted by c1f0601389db64d9, previous posix_fadvise consolidation broke on mips o32. As stated in commit message, MIPS o32 only defines __NR_fadvise64 and it is behaves like __NR_fadvise64_64. This patches consolidates both ARM and mips o32 version by fixing the ARM used option (__NR_fadvise64_64 withouth the alignment required by abi) and added another option, __ASSUME_FADVISE64_AS_64_64, which is used on mips o32. When this option is used, posix_fadvise will use __NR_fadvise64_64 behavior (by defining or not __ASSUME_FADVISE64_64_6ARG). For mips, if __NR_fadvise64_64 is not defined, __NR_fadvise will be used. I also updated the posix_fadvise comments to explain better the different kernel abi used in the supported architectures. I checked with a mips o32 and verified that posix_fadvise.o is indeed using 7 argument syscall with the expected argument position. I also checked on i686-linux-gnu and arm-gnu-eabihf. * sysdeps/unix/sysv/linux/arm/posix_fadvise.c: Remove file. * sysdeps/unix/sysv/linux/mips/mips32/posix_fadvise.c: Likewise. * sysdeps/unix/sysv/linux/mips/kernel-features.h (__ASSUME_FADVISE64_AS_64_64): Define. * sysdeps/unix/sysv/linux/posix_fadvise.c [__NR_fadvise64]: Add !defined __ASSUME_FADVISE64_AS_64_64 to use syscall issue. [!__NR_fadvise64 && __ASSUME_FADVISE64_64_6ARG]: Remove __ALIGNMENT_ARG usage. [!__NR_fadvise64 && !__ASSUME_FADVISE64_64_6ARG]: Define __NR_fadvise64_64 if it is not defined. --- ChangeLog | 13 ++++++++++ sysdeps/unix/sysv/linux/arm/posix_fadvise.c | 30 ---------------------- sysdeps/unix/sysv/linux/mips/kernel-features.h | 3 +++ .../unix/sysv/linux/mips/mips32/posix_fadvise.c | 4 --- sysdeps/unix/sysv/linux/posix_fadvise.c | 23 +++++++++++------ 5 files changed, 31 insertions(+), 42 deletions(-) delete mode 100644 sysdeps/unix/sysv/linux/arm/posix_fadvise.c delete mode 100644 sysdeps/unix/sysv/linux/mips/mips32/posix_fadvise.c -- 2.7.4 diff --git a/sysdeps/unix/sysv/linux/arm/posix_fadvise.c b/sysdeps/unix/sysv/linux/arm/posix_fadvise.c deleted file mode 100644 index fafcde59..0000000 --- a/sysdeps/unix/sysv/linux/arm/posix_fadvise.c +++ /dev/null @@ -1,30 +0,0 @@ -/* Copyright (C) 2005-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 - -int __posix_fadvise64_l64 (int fd, off64_t offset, off64_t len, int advise); - -/* Advice the system about the expected behaviour of the application with - respect to the file associated with FD. */ - -int -posix_fadvise (int fd, off_t offset, off_t len, int advise) -{ - /* ARM only has a syscall for fadvise64_64. */ - return __posix_fadvise64_l64 (fd, offset, len, advise); -} diff --git a/sysdeps/unix/sysv/linux/mips/kernel-features.h b/sysdeps/unix/sysv/linux/mips/kernel-features.h index 83a5c8f..7db5338 100644 --- a/sysdeps/unix/sysv/linux/mips/kernel-features.h +++ b/sysdeps/unix/sysv/linux/mips/kernel-features.h @@ -34,6 +34,9 @@ # define __ASSUME_ALIGNED_REGISTER_PAIRS 1 /* mips32 only supports ipc syscall. */ # undef __ASSUME_DIRECT_SYSVIPC_SYSCALLS + +/* The o32 MIPS fadvise64 syscall behaves as fadvise64_64. */ +# define __ASSUME_FADVISE64_AS_64_64 1 #endif /* Define that mips64-n32 is a ILP32 ABI to set the correct interface to diff --git a/sysdeps/unix/sysv/linux/mips/mips32/posix_fadvise.c b/sysdeps/unix/sysv/linux/mips/mips32/posix_fadvise.c deleted file mode 100644 index 6e9c3f9..0000000 --- a/sysdeps/unix/sysv/linux/mips/mips32/posix_fadvise.c +++ /dev/null @@ -1,4 +0,0 @@ -/* The o32 MIPS fadvise64 syscall behaves as fadvise64_64. The ARM - implementation of posix_fadvise works correctly for this case; the - generic implementation mishandles it. */ -#include diff --git a/sysdeps/unix/sysv/linux/posix_fadvise.c b/sysdeps/unix/sysv/linux/posix_fadvise.c index 15d72d4..222ac97 100644 --- a/sysdeps/unix/sysv/linux/posix_fadvise.c +++ b/sysdeps/unix/sysv/linux/posix_fadvise.c @@ -24,12 +24,16 @@ #ifndef __OFF_T_MATCHES_OFF64_T -/* Both arm and powerpc implements fadvise64_64 with last 'advise' argument - just after 'fd' to avoid the requirement of implementing 7-arg syscalls. - ARM also defines __NR_fadvise64_64 as __NR_arm_fadvise64_64. +/* Default implementation will use __NR_fadvise64 with expected argument + positions (for instance i386 and powerpc32 that uses __ALIGNMENT_ARG). - tile requires __ASSUME_ALIGNED_REGISTER_PAIRS but implements the 32-bit - fadvise64_64 without the padding 0 after fd. + Second option will be used by arm which define __NR_arm_fadvise64_64 + (redefined to __NR_fadvise64_64 in kernel-features.h) that behaves as + __NR_fadvise64_64 (without the aligment argument required for the ABI). + + Third option will be used by both tile 32-bits and mips o32. Tile + will set __ASSUME_FADVISE64_64_NO_ALIGN to issue a 6 argument syscall, + while mips will use a 7 argument one with __NR_fadvise64. s390 implements fadvice64_64 using a specific struct with arguments packed inside. This is the only implementation handled in arch-specific @@ -39,15 +43,14 @@ int posix_fadvise (int fd, off_t offset, off_t len, int advise) { INTERNAL_SYSCALL_DECL (err); -# ifdef __NR_fadvise64 +# if defined (__NR_fadvise64) && !defined (__ASSUME_FADVISE64_AS_64_64) int ret = INTERNAL_SYSCALL_CALL (fadvise64, err, fd, __ALIGNMENT_ARG SYSCALL_LL (offset), len, advise); # else # ifdef __ASSUME_FADVISE64_64_6ARG int ret = INTERNAL_SYSCALL_CALL (fadvise64_64, err, fd, advise, - __ALIGNMENT_ARG SYSCALL_LL (offset), - SYSCALL_LL (len)); + SYSCALL_LL (offset), SYSCALL_LL (len)); # else # ifdef __ASSUME_FADVISE64_64_NO_ALIGN @@ -55,6 +58,10 @@ posix_fadvise (int fd, off_t offset, off_t len, int advise) # define __ALIGNMENT_ARG # endif +# ifndef __NR_fadvise64_64 +# define __NR_fadvise64_64 __NR_fadvise64 +# endif + int ret = INTERNAL_SYSCALL_CALL (fadvise64_64, err, fd, __ALIGNMENT_ARG SYSCALL_LL (offset), SYSCALL_LL (len), advise);