From patchwork Tue Jun 28 19:04:14 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 13450 Received: (qmail 41589 invoked by alias); 28 Jun 2016 19:04: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 41340 invoked by uid 89); 28 Jun 2016 19:04:33 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 spammy=H*m:5335 X-HELO: mail-qk0-f169.google.com X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=H1hDL779AzUkT+1yDhtLV0c2K3rlY4KzWQJpyNdNs8Y=; b=BgFegDIFNxlqsr2+hxunbGGBRkMYMqg2AVXiT8OWs6GHTlwRXzSNdPtmug9TkOf/qZ dAHxLQ2/DwLo2E3hvrzyrHnl/lxFNR6GW2mkAJDioanhRnAP+33Rnqs3ebQAeTsi4oPe WavWZLtjIxEMJlYKyMzLrMxgcbLx9zC16UuiH3JovYXvuzEqRjuCwr3XPo52NHUQ38p6 YaDOpc1DTokzkVqd8FI+HnRw0kQkXW9VWdb00vVD3tlH0ExUbDWzlRN9Gw0fCETaKkjt 6604BWEIQFRfdRbirByOB0HgL2txIskpSnn9aVg+T9lOQNRErKv03SoN2DFJNYms7Hyr Hn1A== X-Gm-Message-State: ALyK8tJI9nY5FO/iBsbOnmIM2GIbgnV6IytcE5UeiKq0X1Eq6Fj/Nq2/xes4AgbvJEKmjkN4 X-Received: by 10.13.231.67 with SMTP id q64mr1766006ywe.21.1467140661573; Tue, 28 Jun 2016 12:04:21 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH 3/3] Consolidate posix_fallocate{64} implementations Date: Tue, 28 Jun 2016 16:04:14 -0300 Message-Id: <1467140654-5335-3-git-send-email-adhemerval.zanella@linaro.org> In-Reply-To: <1467140654-5335-1-git-send-email-adhemerval.zanella@linaro.org> References: <1467140654-5335-1-git-send-email-adhemerval.zanella@linaro.org> This patch consolidates all the posix_fallocate{64} implementation for Linux in only one (sysdeps/unix/sysv/linux/posix_fallocate{64}.c). It also removes the syscall from the auto-generation using assembly macros. The new macro SYSCALL_LL{64} is used to handle the offset argument. For INTERNAL_SYSCALL it would require pass to correct number of expect arguments for macro call, so the same conditions that define SYSCALL_LL{64} is used to set the correct argument number. This could be a future cleanup in {INTERNAL,INLINE}_SYSCALL (to avoid pass the argument number). Tested on x86_64, i686, x32, and armhf. * sysdeps/unix/sysv/linux/mips/mips64/n32/posix_fallocate.c: Remove file. * sysdeps/unix/sysv/linux/mips/mips64/n32/posix_fallocate64.c: Likewise. * sysdeps/unix/sysv/linux/mips/mips64/n64/posix_fallocate.c: Likewise. * sysdeps/unix/sysv/linux/mips/mips64/n64/posix_fallocate64.c: Likewise. * sysdeps/unix/sysv/linux/wordsize-64/posix_fallocate.c: Likewise. * sysdeps/unix/sysv/linux/wordsize-64/posix_fallocate64.c: Likewise. * sysdeps/unix/sysv/linux/posix_fallocate.c (posix_fallocate): Use SYSCALL_LL to pass both offset and len arguments. * sysdeps/unix/sysv/linux/posix_fallocate64.c (posix_fallocate64): Likewise. --- ChangeLog | 14 +++++++ .../sysv/linux/mips/mips64/n32/posix_fallocate.c | 37 ----------------- .../sysv/linux/mips/mips64/n32/posix_fallocate64.c | 38 ------------------ .../sysv/linux/mips/mips64/n64/posix_fallocate.c | 1 - .../sysv/linux/mips/mips64/n64/posix_fallocate64.c | 1 - sysdeps/unix/sysv/linux/posix_fallocate.c | 8 +++- sysdeps/unix/sysv/linux/posix_fallocate64.c | 10 +++-- .../unix/sysv/linux/wordsize-64/posix_fallocate.c | 46 ---------------------- .../sysv/linux/wordsize-64/posix_fallocate64.c | 1 - 9 files changed, 26 insertions(+), 130 deletions(-) delete mode 100644 sysdeps/unix/sysv/linux/mips/mips64/n32/posix_fallocate.c delete mode 100644 sysdeps/unix/sysv/linux/mips/mips64/n32/posix_fallocate64.c delete mode 100644 sysdeps/unix/sysv/linux/mips/mips64/n64/posix_fallocate.c delete mode 100644 sysdeps/unix/sysv/linux/mips/mips64/n64/posix_fallocate64.c delete mode 100644 sysdeps/unix/sysv/linux/wordsize-64/posix_fallocate.c delete mode 100644 sysdeps/unix/sysv/linux/wordsize-64/posix_fallocate64.c diff --git a/ChangeLog b/ChangeLog index e2954e5..cac1d1d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,19 @@ 2016-06-28 Adhemerval Zanella + * sysdeps/unix/sysv/linux/mips/mips64/n32/posix_fallocate.c: Remove + file. + * sysdeps/unix/sysv/linux/mips/mips64/n32/posix_fallocate64.c: + Likewise. + * sysdeps/unix/sysv/linux/mips/mips64/n64/posix_fallocate.c: Likewise. + * sysdeps/unix/sysv/linux/mips/mips64/n64/posix_fallocate64.c: + Likewise. + * sysdeps/unix/sysv/linux/wordsize-64/posix_fallocate.c: Likewise. + * sysdeps/unix/sysv/linux/wordsize-64/posix_fallocate64.c: Likewise. + * sysdeps/unix/sysv/linux/posix_fallocate.c (posix_fallocate): Use + SYSCALL_LL to pass both offset and len arguments. + * sysdeps/unix/sysv/linux/posix_fallocate64.c (posix_fallocate64): + Likewise. + * sysdeps/unix/sysv/linux/fallocate.c (fallocate): Use SYSCALL_LL macro on offset argument. * sysdeps/unix/sysv/linux/fallocate64.c (fallocate64): Use diff --git a/sysdeps/unix/sysv/linux/mips/mips64/n32/posix_fallocate.c b/sysdeps/unix/sysv/linux/mips/mips64/n32/posix_fallocate.c deleted file mode 100644 index e652e5b..0000000 --- a/sysdeps/unix/sysv/linux/mips/mips64/n32/posix_fallocate.c +++ /dev/null @@ -1,37 +0,0 @@ -/* Copyright (C) 2007-2016 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 - -#define posix_fallocate static internal_fallocate -#include -#undef posix_fallocate - -/* Reserve storage for the data of the file associated with FD. */ -int -posix_fallocate (int fd, __off_t offset, __off_t len) -{ - INTERNAL_SYSCALL_DECL (err); - int res = INTERNAL_SYSCALL (fallocate, err, 4, fd, 0, offset, len); - - if (! INTERNAL_SYSCALL_ERROR_P (res, err)) - return 0; - if (INTERNAL_SYSCALL_ERRNO (res, err) != EOPNOTSUPP) - return INTERNAL_SYSCALL_ERRNO (res, err); - return internal_fallocate (fd, offset, len); -} diff --git a/sysdeps/unix/sysv/linux/mips/mips64/n32/posix_fallocate64.c b/sysdeps/unix/sysv/linux/mips/mips64/n32/posix_fallocate64.c deleted file mode 100644 index d5659e0..0000000 --- a/sysdeps/unix/sysv/linux/mips/mips64/n32/posix_fallocate64.c +++ /dev/null @@ -1,38 +0,0 @@ -/* Copyright (C) 2007-2016 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 - -extern int __posix_fallocate64_l64 (int fd, __off64_t offset, __off64_t len); -#define __posix_fallocate64_l64 static internal_fallocate64 -#include -#undef __posix_fallocate64_l64 - -/* Reserve storage for the data of the file associated with FD. */ -int -__posix_fallocate64_l64 (int fd, __off64_t offset, __off64_t len) -{ - INTERNAL_SYSCALL_DECL (err); - int res = INTERNAL_SYSCALL (fallocate, err, 4, fd, 0, offset, len); - - if (! INTERNAL_SYSCALL_ERROR_P (res, err)) - return 0; - if (INTERNAL_SYSCALL_ERRNO (res, err) != EOPNOTSUPP) - return INTERNAL_SYSCALL_ERRNO (res, err); - return internal_fallocate64 (fd, offset, len); -} diff --git a/sysdeps/unix/sysv/linux/mips/mips64/n64/posix_fallocate.c b/sysdeps/unix/sysv/linux/mips/mips64/n64/posix_fallocate.c deleted file mode 100644 index b3fe81b..0000000 --- a/sysdeps/unix/sysv/linux/mips/mips64/n64/posix_fallocate.c +++ /dev/null @@ -1 +0,0 @@ -#include diff --git a/sysdeps/unix/sysv/linux/mips/mips64/n64/posix_fallocate64.c b/sysdeps/unix/sysv/linux/mips/mips64/n64/posix_fallocate64.c deleted file mode 100644 index f466f13..0000000 --- a/sysdeps/unix/sysv/linux/mips/mips64/n64/posix_fallocate64.c +++ /dev/null @@ -1 +0,0 @@ -/* posix_fallocate64 is in posix_fallocate.c */ diff --git a/sysdeps/unix/sysv/linux/posix_fallocate.c b/sysdeps/unix/sysv/linux/posix_fallocate.c index fc9ac37..de9d706 100644 --- a/sysdeps/unix/sysv/linux/posix_fallocate.c +++ b/sysdeps/unix/sysv/linux/posix_fallocate.c @@ -27,9 +27,13 @@ int posix_fallocate (int fd, __off_t offset, __off_t len) { INTERNAL_SYSCALL_DECL (err); +#if __WORDSIZE == 64 || defined __ASSUME_WORDSIZE64_ILP32 + int res = INTERNAL_SYSCALL (fallocate, err, 4, fd, 0, + SYSCALL_LL (offset), SYSCALL_LL (len)); +# else int res = INTERNAL_SYSCALL (fallocate, err, 6, fd, 0, - __LONG_LONG_PAIR (offset >> 31, offset), - __LONG_LONG_PAIR (len >> 31, len)); + SYSCALL_LL (offset), SYSCALL_LL (len)); +# endif if (! INTERNAL_SYSCALL_ERROR_P (res, err)) return 0; diff --git a/sysdeps/unix/sysv/linux/posix_fallocate64.c b/sysdeps/unix/sysv/linux/posix_fallocate64.c index 4a0a722..c85125a 100644 --- a/sysdeps/unix/sysv/linux/posix_fallocate64.c +++ b/sysdeps/unix/sysv/linux/posix_fallocate64.c @@ -28,11 +28,13 @@ int __posix_fallocate64_l64 (int fd, __off64_t offset, __off64_t len) { INTERNAL_SYSCALL_DECL (err); +#if __WORDSIZE == 64 || defined __ASSUME_WORDSIZE64_ILP32 + int res = INTERNAL_SYSCALL (fallocate, err, 4, fd, 0, + SYSCALL_LL64 (offset), SYSCALL_LL64 (len)); +#else int res = INTERNAL_SYSCALL (fallocate, err, 6, fd, 0, - __LONG_LONG_PAIR ((long int) (offset >> 32), - (long int) offset), - __LONG_LONG_PAIR ((long int) (len >> 32), - (long int) len)); + SYSCALL_LL64 (offset), SYSCALL_LL64 (len)); +#endif if (! INTERNAL_SYSCALL_ERROR_P (res, err)) return 0; diff --git a/sysdeps/unix/sysv/linux/wordsize-64/posix_fallocate.c b/sysdeps/unix/sysv/linux/wordsize-64/posix_fallocate.c deleted file mode 100644 index 8caee31..0000000 --- a/sysdeps/unix/sysv/linux/wordsize-64/posix_fallocate.c +++ /dev/null @@ -1,46 +0,0 @@ -/* Copyright (C) 2007-2016 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 - -#define posix_fallocate static internal_fallocate -#include -#undef posix_fallocate - -/* Reserve storage for the data of the file associated with FD. */ -int -posix_fallocate (int fd, __off_t offset, __off_t len) -{ - INTERNAL_SYSCALL_DECL (err); -#ifdef INTERNAL_SYSCALL_TYPES - int res = INTERNAL_SYSCALL_TYPES (fallocate, err, 4, int, fd, - int, 0, off_t, offset, - off_t, len); -#else - int res = INTERNAL_SYSCALL (fallocate, err, 4, fd, 0, offset, len); -#endif - - if (! INTERNAL_SYSCALL_ERROR_P (res, err)) - return 0; - - if (INTERNAL_SYSCALL_ERRNO (res, err) != EOPNOTSUPP) - return INTERNAL_SYSCALL_ERRNO (res, err); - - return internal_fallocate (fd, offset, len); -} -weak_alias (posix_fallocate, posix_fallocate64) diff --git a/sysdeps/unix/sysv/linux/wordsize-64/posix_fallocate64.c b/sysdeps/unix/sysv/linux/wordsize-64/posix_fallocate64.c deleted file mode 100644 index f466f13..0000000 --- a/sysdeps/unix/sysv/linux/wordsize-64/posix_fallocate64.c +++ /dev/null @@ -1 +0,0 @@ -/* posix_fallocate64 is in posix_fallocate.c */