From patchwork Fri Apr 24 11:50:18 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Weimer X-Patchwork-Id: 464215 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 769CB140150 for ; Fri, 24 Apr 2015 23:45:53 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass reason="1024-bit key; unprotected key" header.d=sourceware.org header.i=@sourceware.org header.b=qatEyR7z; dkim-adsp=none (unprotected policy); 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:date:subject:to:message-id; q=dns; s= default; b=gm41h1MqgpOnDIEUz+NX/A912E/m4zf04lfo1KqLWva8rGL8NLMZ+ Rz3yC3qrqHh8Pf6tCUjIolylmEzzEyfERKkwhargia4HfNVvNHHCaiOnRhn/x85n QVQt9HJXjo2XLp8Wx2KJ1ndCyl87ydAMOtv3uZERI+1P5DgKweyrkk= 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:date:subject:to:message-id; s=default; bh=KJ9fDXAei9/Uz7Pd5Aeo8uort4U=; b=qatEyR7z+asUzGQz7fC7W2eUkehp n513nZKpDOPtZ8ay2Z1MOuazfz+/os3ny/dV52c2SQEgHbMEuttaohz8d3O2v0iX oml8UVnikEM/adU15eyZE7GDJ+KQh0JlhNGKvnUuDembNQyW3h8Q/e9Z0B3opnUF bEL+MAwxe4A7S5o= Received: (qmail 115762 invoked by alias); 24 Apr 2015 13:45:20 -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 115706 invoked by uid 89); 24 Apr 2015 13:45:20 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.8 required=5.0 tests=AWL, BAYES_00, SPF_HELO_PASS, SPF_PASS, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com From: Florian Weimer Date: Fri, 24 Apr 2015 13:50:18 +0200 Subject: [PATCH 3/4] __ASSUME_FALLOCATE is always true on 32-bit architectures To: libc-alpha@sourceware.org Message-Id: <20150424134514.627ED41F484D0@oldenburg.str.redhat.com> This means we can clean up the generic code a bit. The 64-bit variant still needs to support !__ASSUME_FALLOCATE for alpha. --- ChangeLog | 13 +++++++ .../sysv/linux/mips/mips64/n32/posix_fallocate.c | 32 +++------------- .../sysv/linux/mips/mips64/n32/posix_fallocate64.c | 33 +++-------------- sysdeps/unix/sysv/linux/posix_fallocate.c | 38 +++++-------------- sysdeps/unix/sysv/linux/posix_fallocate64.c | 43 ++++++---------------- .../unix/sysv/linux/wordsize-64/posix_fallocate.c | 2 + 6 files changed, 47 insertions(+), 114 deletions(-) diff --git a/ChangeLog b/ChangeLog index 75c430b..b927022 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,18 @@ 2015-04-24 Florian Weimer + * sysdeps/unix/sysv/linux/posix_fallocate.c (posix_fallocate): + Assume __ASSUME_FALLOCATE is always true. + * sysdeps/unix/sysv/linux/posix_fallocate64.c + (__posix_fallocate64_l64): Likweise. + * sysdeps/unix/sysv/linux/mips/mips64/n32/posix_fallocate.c + (posix_fallocate): Likewise. + * sysdeps/unix/sysv/linux/mips/mips64/n32/posix_fallocate64.c + (__posix_fallocate64_l64): Likewise. + * sysdeps/unix/sysv/linux/wordsize-64/posix_fallocate.c + [!__ASSUME_FALLOCATE]: Add comment. + +2015-04-24 Florian Weimer + * sysdeps/unix/sysv/linux/i386/Makefile (sysdep_routines) [misc]: Remove call_fallocate. (sysdep_routines) [io]: Add libc-do-syscall. diff --git a/sysdeps/unix/sysv/linux/mips/mips64/n32/posix_fallocate.c b/sysdeps/unix/sysv/linux/mips/mips64/n32/posix_fallocate.c index be08323..a9c8d73 100644 --- a/sysdeps/unix/sysv/linux/mips/mips64/n32/posix_fallocate.c +++ b/sysdeps/unix/sysv/linux/mips/mips64/n32/posix_fallocate.c @@ -16,42 +16,22 @@ . */ #include -#include #include #define posix_fallocate static internal_fallocate #include #undef posix_fallocate -#if !defined __ASSUME_FALLOCATE && defined __NR_fallocate -int __have_fallocate attribute_hidden; -#endif - - /* Reserve storage for the data of the file associated with FD. */ int posix_fallocate (int fd, __off_t offset, __off_t len) { -#ifdef __NR_fallocate -# ifndef __ASSUME_FALLOCATE - if (__builtin_expect (__have_fallocate >= 0, 1)) -# endif - { - INTERNAL_SYSCALL_DECL (err); - int res = INTERNAL_SYSCALL (fallocate, err, 4, fd, 0, offset, len); - - if (! INTERNAL_SYSCALL_ERROR_P (res, err)) - return 0; - -# ifndef __ASSUME_FALLOCATE - if (__builtin_expect (INTERNAL_SYSCALL_ERRNO (res, err) == ENOSYS, 0)) - __have_fallocate = -1; - else -# endif - if (INTERNAL_SYSCALL_ERRNO (res, err) != EOPNOTSUPP) - return INTERNAL_SYSCALL_ERRNO (res, err); - } -#endif + 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 index 0934550..503e918 100644 --- a/sysdeps/unix/sysv/linux/mips/mips64/n32/posix_fallocate64.c +++ b/sysdeps/unix/sysv/linux/mips/mips64/n32/posix_fallocate64.c @@ -16,7 +16,6 @@ . */ #include -#include #include extern int __posix_fallocate64_l64 (int fd, __off64_t offset, __off64_t len); @@ -24,36 +23,16 @@ extern int __posix_fallocate64_l64 (int fd, __off64_t offset, __off64_t len); #include #undef __posix_fallocate64_l64 -#if !defined __ASSUME_FALLOCATE && defined __NR_fallocate -/* Defined in posix_fallocate.c. */ -extern int __have_fallocate attribute_hidden; -#endif - - /* Reserve storage for the data of the file associated with FD. */ int __posix_fallocate64_l64 (int fd, __off64_t offset, __off64_t len) { -#ifdef __NR_fallocate -# ifndef __ASSUME_FALLOCATE - if (__builtin_expect (__have_fallocate >= 0, 1)) -# endif - { - INTERNAL_SYSCALL_DECL (err); - int res = INTERNAL_SYSCALL (fallocate, err, 4, fd, 0, offset, len); - - if (! INTERNAL_SYSCALL_ERROR_P (res, err)) - return 0; - -# ifndef __ASSUME_FALLOCATE - if (__builtin_expect (INTERNAL_SYSCALL_ERRNO (res, err) == ENOSYS, 0)) - __have_fallocate = -1; - else -# endif - if (INTERNAL_SYSCALL_ERRNO (res, err) != EOPNOTSUPP) - return INTERNAL_SYSCALL_ERRNO (res, err); - } -#endif + 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/posix_fallocate.c b/sysdeps/unix/sysv/linux/posix_fallocate.c index 13d4afd..4587029 100644 --- a/sysdeps/unix/sysv/linux/posix_fallocate.c +++ b/sysdeps/unix/sysv/linux/posix_fallocate.c @@ -16,44 +16,24 @@ . */ #include -#include #include #define posix_fallocate static internal_fallocate #include #undef posix_fallocate -#if !defined __ASSUME_FALLOCATE && defined __NR_fallocate -int __have_fallocate attribute_hidden; -#endif - - /* Reserve storage for the data of the file associated with FD. */ int posix_fallocate (int fd, __off_t offset, __off_t len) { -#ifdef __NR_fallocate -# ifndef __ASSUME_FALLOCATE - if (__glibc_likely (__have_fallocate >= 0)) -# endif - { - INTERNAL_SYSCALL_DECL (err); - int res = INTERNAL_SYSCALL (fallocate, err, 6, fd, 0, - __LONG_LONG_PAIR (offset >> 31, offset), - __LONG_LONG_PAIR (len >> 31, len)); - - if (! INTERNAL_SYSCALL_ERROR_P (res, err)) - return 0; - -# ifndef __ASSUME_FALLOCATE - if (__glibc_unlikely (INTERNAL_SYSCALL_ERRNO (res, err) == ENOSYS)) - __have_fallocate = -1; - else -# endif - if (INTERNAL_SYSCALL_ERRNO (res, err) != EOPNOTSUPP) - return INTERNAL_SYSCALL_ERRNO (res, err); - } -#endif - + INTERNAL_SYSCALL_DECL (err); + int res = INTERNAL_SYSCALL (fallocate, err, 6, fd, 0, + __LONG_LONG_PAIR (offset >> 31, offset), + __LONG_LONG_PAIR (len >> 31, 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/posix_fallocate64.c b/sysdeps/unix/sysv/linux/posix_fallocate64.c index 9545459..771e59c 100644 --- a/sysdeps/unix/sysv/linux/posix_fallocate64.c +++ b/sysdeps/unix/sysv/linux/posix_fallocate64.c @@ -16,7 +16,6 @@ . */ #include -#include #include extern int __posix_fallocate64_l64 (int fd, __off64_t offset, __off64_t len); @@ -24,40 +23,20 @@ extern int __posix_fallocate64_l64 (int fd, __off64_t offset, __off64_t len); #include #undef __posix_fallocate64_l64 -#if !defined __ASSUME_FALLOCATE && defined __NR_fallocate -/* Defined in posix_fallocate.c. */ -extern int __have_fallocate attribute_hidden; -#endif - - /* Reserve storage for the data of the file associated with FD. */ int __posix_fallocate64_l64 (int fd, __off64_t offset, __off64_t len) { -#ifdef __NR_fallocate -# ifndef __ASSUME_FALLOCATE - if (__glibc_likely (__have_fallocate >= 0)) -# endif - { - INTERNAL_SYSCALL_DECL (err); - 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)); - - if (! INTERNAL_SYSCALL_ERROR_P (res, err)) - return 0; - -# ifndef __ASSUME_FALLOCATE - if (__glibc_unlikely (INTERNAL_SYSCALL_ERRNO (res, err) == ENOSYS)) - __have_fallocate = -1; - else -# endif - if (INTERNAL_SYSCALL_ERRNO (res, err) != EOPNOTSUPP) - return INTERNAL_SYSCALL_ERRNO (res, err); - } -#endif - + INTERNAL_SYSCALL_DECL (err); + 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)); + + 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/wordsize-64/posix_fallocate.c b/sysdeps/unix/sysv/linux/wordsize-64/posix_fallocate.c index ecc6505..8ae8a29 100644 --- a/sysdeps/unix/sysv/linux/wordsize-64/posix_fallocate.c +++ b/sysdeps/unix/sysv/linux/wordsize-64/posix_fallocate.c @@ -23,6 +23,8 @@ #include #undef posix_fallocate +/* The alpha architecture introduced the fallocate system call in + 2.6.33-rc1, so we still need the fallback code. */ #if !defined __ASSUME_FALLOCATE && defined __NR_fallocate static int __have_fallocate; #endif