From patchwork Wed Feb 5 00:43:30 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Justin Maggard X-Patchwork-Id: 316781 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from silver.osuosl.org (silver.osuosl.org [140.211.166.136]) by ozlabs.org (Postfix) with ESMTP id 5E9102C0091 for ; Wed, 5 Feb 2014 11:43:47 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id 3096326A95; Wed, 5 Feb 2014 00:43:45 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from silver.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id pKy2bGMXQ+9o; Wed, 5 Feb 2014 00:43:41 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by silver.osuosl.org (Postfix) with ESMTP id 1D5DE269B8; Wed, 5 Feb 2014 00:43:41 +0000 (UTC) X-Original-To: uclibc@lists.busybox.net Delivered-To: uclibc@osuosl.org Received: from silver.osuosl.org (silver.osuosl.org [140.211.166.136]) by ash.osuosl.org (Postfix) with ESMTP id 521FF1CE93B for ; Wed, 5 Feb 2014 00:43:40 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id 4AF64269B8 for ; Wed, 5 Feb 2014 00:43:40 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from silver.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id fe9lZuSlY2ir for ; Wed, 5 Feb 2014 00:43:39 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-pd0-f181.google.com (mail-pd0-f181.google.com [209.85.192.181]) by silver.osuosl.org (Postfix) with ESMTPS id 8AAD3266B7 for ; Wed, 5 Feb 2014 00:43:39 +0000 (UTC) Received: by mail-pd0-f181.google.com with SMTP id y10so8916939pdj.40 for ; Tue, 04 Feb 2014 16:43:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=hLeWodnj3ZXzkYTtvV0WbGFL+HHxnpzdXyysd9/YWbI=; b=ckAgkBakaf356PC5cHnNOLYGxCHwuzhDWKHCxBzNNMwDHR0WcZYlpmYICXySMkaZP/ +1EyF3ASWFBRjUPfu11S6MRhnuEMeDc9m9nWw32qxR4GPmMZ1DfPDh8wgWcTaV3+Gwm6 ZX6LjWVE+/4xNB7UrrWSsYAQHPgPnv1OkgfvxfMB0bLrBAR7f/YVxcUKUxJPHKK4UnGI d80s+SeuwkaCacc0Pg/mdQmEG77FUk8rBu3FXSQqjFbvy2R5QNaSDQfJDEhtPKobkOTi xefpUxvwMeAZoq3GOnmnrq2AGSvNYNEUFzTvv20DphQfQ+LLNnL0Fa0C6Es+22eaiTuP Ftrw== X-Received: by 10.66.174.165 with SMTP id bt5mr13015531pac.151.1391561019263; Tue, 04 Feb 2014 16:43:39 -0800 (PST) Received: from jmaggard-ThinkPad-W520.infrant-6.com ([209.249.181.1]) by mx.google.com with ESMTPSA id e3sm39592894pbc.17.2014.02.04.16.43.37 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 04 Feb 2014 16:43:38 -0800 (PST) From: Justin Maggard To: uclibc@uclibc.org Subject: [PATCH] pread/pwrite: handle targets that align 64bit values in register pairs Date: Tue, 4 Feb 2014 16:43:30 -0800 Message-Id: <1391561010-10984-1-git-send-email-jmaggard10@gmail.com> X-Mailer: git-send-email 1.7.9.5 Cc: Justin Maggard X-BeenThere: uclibc@uclibc.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Discussion and development of uClibc \(the embedded C library\)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: uclibc-bounces@uclibc.org Sender: uclibc-bounces@uclibc.org Recent changes to pread/pwrite in the 0.9.33 branch to use the proper linux kernel syscalls failed to consider architectures that align 64-bit values in register pairs. These targets are already marked because their truncate64 syscall required a different number of args as well. Use the existing __UCLIBC_TRUNCATE64_HAS_4_ARGS__ definition to also determine whether we should use 5 or 6 args for pread/pwrite. --- libc/sysdeps/linux/common/pread_write.c | 51 +++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/libc/sysdeps/linux/common/pread_write.c b/libc/sysdeps/linux/common/pread_write.c index b13de66..b8d527b 100644 --- a/libc/sysdeps/linux/common/pread_write.c +++ b/libc/sysdeps/linux/common/pread_write.c @@ -43,6 +43,19 @@ extern __typeof(pwrite64) __libc_pwrite64; #include # define __NR___syscall_pread __NR_pread64 +# ifdef __UCLIBC_TRUNCATE64_HAS_4_ARGS__ +static __inline__ _syscall6(ssize_t, __syscall_pread, int, fd, void *, buf, + size_t, count, int, dummy, off_t, offset_hi, off_t, offset_lo) + +ssize_t __libc_pread(int fd, void *buf, size_t count, off_t offset) +{ + int oldtype = LIBC_CANCEL_ASYNC (); + int result = __syscall_pread(fd, buf, count, 0, __LONG_LONG_PAIR(offset >> 31, offset)); + LIBC_CANCEL_RESET (oldtype); + return result; + +} +# else static __inline__ _syscall5(ssize_t, __syscall_pread, int, fd, void *, buf, size_t, count, off_t, offset_hi, off_t, offset_lo) @@ -54,9 +67,21 @@ ssize_t __libc_pread(int fd, void *buf, size_t count, off_t offset) return result; } +# endif weak_alias(__libc_pread,pread) # ifdef __UCLIBC_HAS_LFS__ +# ifdef __UCLIBC_TRUNCATE64_HAS_4_ARGS__ +ssize_t __libc_pread64(int fd, void *buf, size_t count, off64_t offset) +{ + uint32_t low = offset & 0xffffffff; + uint32_t high = offset >> 32; + int oldtype = LIBC_CANCEL_ASYNC (); + int result = __syscall_pread(fd, buf, count, 0, __LONG_LONG_PAIR(high, low)); + LIBC_CANCEL_RESET (oldtype); + return result; +} +# else ssize_t __libc_pread64(int fd, void *buf, size_t count, off64_t offset) { uint32_t low = offset & 0xffffffff; @@ -66,6 +91,7 @@ ssize_t __libc_pread64(int fd, void *buf, size_t count, off64_t offset) LIBC_CANCEL_RESET (oldtype); return result; } +# endif weak_alias(__libc_pread64,pread64) # endif /* __UCLIBC_HAS_LFS__ */ @@ -75,6 +101,18 @@ weak_alias(__libc_pread64,pread64) #endif # define __NR___syscall_pwrite __NR_pwrite +# ifdef __UCLIBC_TRUNCATE64_HAS_4_ARGS__ +static __inline__ _syscall6(ssize_t, __syscall_pwrite, int, fd, const void *, buf, + size_t, count, int, dummy, off_t, offset_hi, off_t, offset_lo) + +ssize_t __libc_pwrite(int fd, const void *buf, size_t count, off_t offset) +{ + int oldtype = LIBC_CANCEL_ASYNC (); + int result = __syscall_pwrite(fd, buf, count, 0, __LONG_LONG_PAIR(offset >> 31, offset)); + LIBC_CANCEL_RESET (oldtype); + return result; +} +# else static __inline__ _syscall5(ssize_t, __syscall_pwrite, int, fd, const void *, buf, size_t, count, off_t, offset_hi, off_t, offset_lo) @@ -85,9 +123,21 @@ ssize_t __libc_pwrite(int fd, const void *buf, size_t count, off_t offset) LIBC_CANCEL_RESET (oldtype); return result; } +# endif weak_alias(__libc_pwrite,pwrite) # ifdef __UCLIBC_HAS_LFS__ +# ifdef __UCLIBC_TRUNCATE64_HAS_4_ARGS__ +ssize_t __libc_pwrite64(int fd, const void *buf, size_t count, off64_t offset) +{ + uint32_t low = offset & 0xffffffff; + uint32_t high = offset >> 32; + int oldtype = LIBC_CANCEL_ASYNC (); + int result = __syscall_pwrite(fd, buf, count, 0, __LONG_LONG_PAIR(high, low)); + LIBC_CANCEL_RESET (oldtype); + return result; +} +# else ssize_t __libc_pwrite64(int fd, const void *buf, size_t count, off64_t offset) { uint32_t low = offset & 0xffffffff; @@ -97,5 +147,6 @@ ssize_t __libc_pwrite64(int fd, const void *buf, size_t count, off64_t offset) LIBC_CANCEL_RESET (oldtype); return result; } +# endif weak_alias(__libc_pwrite64,pwrite64) # endif /* __UCLIBC_HAS_LFS__ */