From patchwork Wed Feb 24 18:51:03 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: 587582 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 97AE61402EC for ; Thu, 25 Feb 2016 05:51:26 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b=VX1BGU6W; 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:subject:to:references:from:message-id:date :mime-version:in-reply-to:content-type :content-transfer-encoding; q=dns; s=default; b=V2+uTK4OjRtTlsBn 6vxLL3z0B0NaQy+awWi4tRbrOIHYnK68yRirw4CmrFUN+Dejd0XN0blJn2H2sw4R t5/QJhYtNdG2qqmO8By2pnaz/tHBCaoqyZEdZk/txATnxqRWFpcE2ddyDlVe0Zio m/mdm4E8OpnyneALUPgsJPWiaRg= 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:subject:to:references:from:message-id:date :mime-version:in-reply-to:content-type :content-transfer-encoding; s=default; bh=tw8QoBE383Br0+RCd7lE8k 48tKw=; b=VX1BGU6WeVeRCQC2XSme+V2dG2o08VN/rPsiLgO0O3om1qZFHxiLNx 8CXKlKDZOPVG9q4pvevS+G+XCrQ98aQYvDh3LcAUmJf33gjpO7ya+IklJPhEggUQ JNdfpCrc3w6eySjFOswoqlTUShypdArKIfXplluYMDihQ0NA1Pmhs= Received: (qmail 68404 invoked by alias); 24 Feb 2016 18:51:12 -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 68341 invoked by uid 89); 24 Feb 2016 18:51:11 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=2.1 required=5.0 tests=BAYES_50, RCVD_IN_DNSWL_LOW, SPF_PASS, UNSUBSCRIBE_BODY autolearn=no version=3.3.2 spammy=584, strong_alias, 585, catched X-HELO: mail-yk0-f177.google.com X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-type :content-transfer-encoding; bh=1et+a1gtakPRCt25gKXSyAAoVRk1Eji/YuyRHl2Awyw=; b=Zod+xv/4MDKGIJfQ9WZrlxJPfJwSpq/fhI7M6BoQVfJfCX3n6/BNBggoINpuvAxtVN Dnq60PUEaTGWDvsd24H+331qxbIEBNe32KN4CmS6DpW1AsuGFHP7YbZlQE5VvpuVEr5d yRgogLFXLnfcF7VGBU/FD8PNTjmbbDvEbnGEh8+lqJG+SXLMe3hIHM5k5ZKKLAuy3tz8 dAXXhhLqdXYnE7ommpotmJnD6SYB8w2dUx86htZNhGf8F8nM3rrDFCRNjApLi4ezKswx ZoI8mWk7Xen8UEooYFirrlVNtwdEo+3/ToNDsI+j/UXkIbuDwkJD0VAK3RCgnw88KQgH GThQ== X-Gm-Message-State: AG10YOS8ToAcl6/Zh2Wtus311P831ZcTr8aSoUwAVa/SuSI7nqBrJAz6C6D2FADnEOWV2tzl X-Received: by 10.37.41.66 with SMTP id p63mr20335510ybp.183.1456339867052; Wed, 24 Feb 2016 10:51:07 -0800 (PST) Subject: Re: [PATCH 4/4] Consolidate pwrite/pwrite64 implementations To: libc-alpha@sourceware.org, Adhemerval Zanella References: <1456240627-18774-1-git-send-email-adhemerval.zanella@linaro.org> <1456240627-18774-5-git-send-email-adhemerval.zanella@linaro.org> <20160223185125.GW19841@vapier.lan> From: Adhemerval Zanella Message-ID: <56CDFB97.7070607@linaro.org> Date: Wed, 24 Feb 2016 15:51:03 -0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.5.1 MIME-Version: 1.0 In-Reply-To: <20160223185125.GW19841@vapier.lan> On 23-02-2016 15:51, Mike Frysinger wrote: > On 23 Feb 2016 12:17, Adhemerval Zanella wrote: >> * sysdeps/unix/sysv/linux/arm/pwrite.c: Remove file. >> * sysdeps/unix/sysv/linux/arm/pwrite64.c: Likewise. >> * sysdeps/unix/sysv/linux/generic/wordsize-32/pwrite.c: Likewise. >> * sysdeps/unix/sysv/linux/generic/wordsize-32/pwrite64.c: Likewise. >> * sysdeps/unix/sysv/linux/mips/pwrite.c: Likewise. >> * sysdeps/unix/sysv/linux/mips/pwrite64.c: Likewise. >> * sysdeps/unix/sysv/linux/powerpc/powerpc32/pwrite.c: Likewise. >> * sysdeps/unix/sysv/linux/powerpc/powerpc32/pwrite64.c: Likewise. >> * sysdeps/unix/sysv/linux/sh/pwrite.c: Likewise. >> * sysdeps/unix/sysv/linux/sh/pwrite64.c: Likewise. > > you aren't removing the mips/sh implementations anymore In fact I fixed in CL, I just didn't update in commit msg. I will fix it. > >> --- a/sysdeps/unix/sysv/linux/mips/pwrite.c >> +++ b/sysdeps/unix/sysv/linux/mips/pwrite.c >> >> +/* The n32 have sizeof(off_t) != sizeof(off64_t) so we can't strong/weak >> + alias the pwrite to pwrite64. We undefine the __ASSUME_WORDSIZE64_ILP32 >> + so two implementation are built. */ >> +#if _MIPS_SIM == _ABIN32 >> +# undef __ASSUME_WORDSIZE64_ILP32 >> #endif >> >> +#include > > this style seems fragile to me. would it not be better to add a > specific knob for files to set ? I agree and I am inclined to add another define, set by the ABI sysdep.h, to indicate either off_t and off64_t is the same size (so pread64 can alias to pread). So we will have basically 3 scenarios: 1. __WORDSIZE == 32 pread with off_t pread64 with off64_t 2. __WORDSIZE == 64 and __ASSUME_OFF_DIFF_OFF64 pread with off_t pread64 with off64_t 3. __WORDSIZE == 64 pread being and alias to pread64 pread64 So for mip64-n32 it will define __ASSUME_OFF_DIFF_OFF64 and thus we can remove the mips specific implementations. The result patch is as above and a similar strategy is done for pread: --- diff --git a/sysdeps/unix/sysv/linux/arm/pread.c b/sysdeps/unix/sysv/linux/arm/pread.c deleted file mode 100644 index 8c9b878..0000000 --- a/sysdeps/unix/sysv/linux/arm/pread.c +++ /dev/null diff --git a/sysdeps/unix/sysv/linux/arm/pread64.c b/sysdeps/unix/sysv/linux/arm/pread64.c deleted file mode 100644 index 3364b6a..0000000 --- a/sysdeps/unix/sysv/linux/arm/pread64.c +++ /dev/null diff --git a/sysdeps/unix/sysv/linux/generic/wordsize-32/pread.c b/sysdeps/unix/sysv/linux/generic/wordsize-32/pread.c deleted file mode 100644 index 0dff648..0000000 --- a/sysdeps/unix/sysv/linux/generic/wordsize-32/pread.c +++ /dev/null diff --git a/sysdeps/unix/sysv/linux/generic/wordsize-32/pread64.c b/sysdeps/unix/sysv/linux/generic/wordsize-32/pread64.c deleted file mode 100644 index 8931900..0000000 --- a/sysdeps/unix/sysv/linux/generic/wordsize-32/pread64.c +++ /dev/null diff --git a/sysdeps/unix/sysv/linux/mips/kernel-features.h b/sysdeps/unix/sysv/linux/mips/kernel-features.h index 17ab696..7cb32cd 100644 --- a/sysdeps/unix/sysv/linux/mips/kernel-features.h +++ b/sysdeps/unix/sysv/linux/mips/kernel-features.h @@ -58,4 +58,5 @@ pass 64-bits values through syscalls. */ #if _MIPS_SIM == _ABIN32 # define __ASSUME_WORDSIZE64_ILP32 1 +# define __ASSUME_OFF_DIFF_OFF64 1 #endif diff --git a/sysdeps/unix/sysv/linux/mips/pread.c b/sysdeps/unix/sysv/linux/mips/pread.c deleted file mode 100644 index 02755cb..0000000 --- a/sysdeps/unix/sysv/linux/mips/pread.c +++ /dev/null diff --git a/sysdeps/unix/sysv/linux/mips/pread64.c b/sysdeps/unix/sysv/linux/mips/pread64.c deleted file mode 100644 index ed0e91c..0000000 --- a/sysdeps/unix/sysv/linux/mips/pread64.c +++ /dev/null diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/pread.c b/sysdeps/unix/sysv/linux/powerpc/powerpc32/pread.c deleted file mode 100644 index 2d67013..0000000 --- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/pread.c +++ /dev/null diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/pread64.c b/sysdeps/unix/sysv/linux/powerpc/powerpc32/pread64.c deleted file mode 100644 index 712ab72..0000000 --- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/pread64.c +++ /dev/null diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/sysdep.h b/sysdeps/unix/sysv/linux/powerpc/powerpc32/sysdep.h index 390ce24..c12fd7f 100644 --- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/sysdep.h +++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/sysdep.h @@ -27,13 +27,6 @@ Handle them here so they can be catched by both C and assembler stubs in glibc. */ -#ifdef __NR_pread64 -# ifdef __NR_pread -# error "__NR_pread and __NR_pread64 both defined???" -# endif -# define __NR_pread __NR_pread64 -#endif - #ifdef __NR_pwrite64 # ifdef __NR_pwrite # error "__NR_pwrite and __NR_pwrite64 both defined???" diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/sysdep.h b/sysdeps/unix/sysv/linux/powerpc/powerpc64/sysdep.h index 761f3ea..c39a0f2 100644 --- a/sysdeps/unix/sysv/linux/powerpc/powerpc64/sysdep.h +++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/sysdep.h @@ -34,13 +34,6 @@ Handle them here so they can be catched by both C and assembler stubs in glibc. */ -#ifdef __NR_pread64 -# ifdef __NR_pread -# error "__NR_pread and __NR_pread64 both defined???" -# endif -# define __NR_pread __NR_pread64 -#endif - #ifdef __NR_pwrite64 # ifdef __NR_pwrite # error "__NR_pwrite and __NR_pwrite64 both defined???" diff --git a/sysdeps/unix/sysv/linux/pread.c b/sysdeps/unix/sysv/linux/pread.c index 4aa3c67..5663092 100644 --- a/sysdeps/unix/sysv/linux/pread.c +++ b/sysdeps/unix/sysv/linux/pread.c @@ -16,33 +16,22 @@ License along with the GNU C Library; if not, see . */ -#include -#include -#include #include - #include -#include -#ifdef __NR_pread64 /* Newer kernels renamed but it's the same. */ -# ifdef __NR_pread -# error "__NR_pread and __NR_pread64 both defined???" -# endif -# define __NR_pread __NR_pread64 -#endif +#if __WORDSIZE != 64 || defined (__ASSUME_OFF_DIFF_OFF64) +# ifndef __NR_pread +# define __NR_pread __NR_pread64 +# endif ssize_t __libc_pread (int fd, void *buf, size_t count, off_t offset) { - ssize_t result; - - assert (sizeof (offset) == 4); - result = SYSCALL_CANCEL (pread, fd, buf, count, - __LONG_LONG_PAIR (offset >> 31, offset)); - - return result; + return SYSCALL_CANCEL (pread, fd, buf, count, + __ALIGNMENT_ARG SYSCALL_LL (offset)); } strong_alias (__libc_pread, __pread) weak_alias (__libc_pread, pread) +#endif diff --git a/sysdeps/unix/sysv/linux/pread64.c b/sysdeps/unix/sysv/linux/pread64.c index 7b5019a..c599f76 100644 --- a/sysdeps/unix/sysv/linux/pread64.c +++ b/sysdeps/unix/sysv/linux/pread64.c @@ -16,28 +16,25 @@ License along with the GNU C Library; if not, see . */ -#include -#include #include - #include -#include -#ifdef __NR_pread64 /* Newer kernels renamed but it's the same. */ -# ifdef __NR_pread -# error "__NR_pread and __NR_pread64 both defined???" -# endif -# define __NR_pread __NR_pread64 +#ifndef __NR_pread64 +# define __NR_pread64 __NR_pread #endif - ssize_t __libc_pread64 (int fd, void *buf, size_t count, off64_t offset) { - return SYSCALL_CANCEL (pread, fd, buf, count, - __LONG_LONG_PAIR ((off_t) (offset >> 32), - (off_t) (offset & 0xffffffff))); + return SYSCALL_CANCEL (pread64, fd, buf, count, + __ALIGNMENT_ARG SYSCALL_LL64 (offset)); } weak_alias (__libc_pread64, __pread64) weak_alias (__libc_pread64, pread64) + +#if __WORDSIZE == 64 && !defined (__ASSUME_OFF_DIFF_OFF64) +strong_alias (__libc_pread64, __libc_pread) +weak_alias (__libc_pread64, __pread) +weak_alias (__libc_pread64, pread) +#endif diff --git a/sysdeps/unix/sysv/linux/sh/pread.c b/sysdeps/unix/sysv/linux/sh/pread.c index 8afada5..d3f99f3 100644 --- a/sysdeps/unix/sysv/linux/sh/pread.c +++ b/sysdeps/unix/sysv/linux/sh/pread.c @@ -16,28 +16,8 @@ License along with the GNU C Library; if not, see . */ -#include -#include -#include -#include - -#include -#include - -#ifdef __NR_pread64 /* Newer kernels renamed but it's the same. */ -# ifdef __NR_pread -# error "__NR_pread and __NR_pread64 both defined???" -# endif -# define __NR_pread __NR_pread64 -#endif - - -ssize_t -__libc_pread (int fd, void *buf, size_t count, off_t offset) -{ - return SYSCALL_CANCEL (pread, fd, buf, count, 0, - __LONG_LONG_PAIR (offset >> 31, offset)); -} - -strong_alias (__libc_pread, __pread) -weak_alias (__libc_pread, pread) +/* SH4 ABI does not really require argument alignment for 64-bits, but + the kernel interface for pread adds a dummy long argument before the + offset. */ +#define __ALIGNMENT_ARG +#include diff --git a/sysdeps/unix/sysv/linux/sh/pread64.c b/sysdeps/unix/sysv/linux/sh/pread64.c index cfc751d..b2e8a25 100644 --- a/sysdeps/unix/sysv/linux/sh/pread64.c +++ b/sysdeps/unix/sysv/linux/sh/pread64.c @@ -16,28 +16,8 @@ License along with the GNU C Library; if not, see . */ -#include -#include -#include - -#include -#include - -#ifdef __NR_pread64 /* Newer kernels renamed but it's the same. */ -# ifdef __NR_pread -# error "__NR_pread and __NR_pread64 both defined???" -# endif -# define __NR_pread __NR_pread64 -#endif - - -ssize_t -__libc_pread64 (int fd, void *buf, size_t count, off64_t offset) -{ - return SYSCALL_CANCEL (pread, fd, buf, count, 0, - __LONG_LONG_PAIR ((off_t) (offset >> 32), - (off_t) (offset & 0xffffffff))); -} - -weak_alias (__libc_pread64, __pread64) -weak_alias (__libc_pread64, pread64) +/* SH4 ABI does not really require argument alignment for 64-bits, but + the kernel interface for pread adds a dummy long argument before the + offset. */ +#define __ALIGNMENT_ARG +#include diff --git a/sysdeps/unix/sysv/linux/wordsize-64/pread64.c b/sysdeps/unix/sysv/linux/wordsize-64/pread64.c deleted file mode 100644 index b7f298d..0000000 --- a/sysdeps/unix/sysv/linux/wordsize-64/pread64.c +++ /dev/null @@ -1 +0,0 @@ -/* Empty since the pread syscall is equivalent. */ diff --git a/sysdeps/unix/sysv/linux/wordsize-64/syscalls.list b/sysdeps/unix/sysv/linux/wordsize-64/syscalls.list index 19cc6d9..7d5f6a5 100644 --- a/sysdeps/unix/sysv/linux/wordsize-64/syscalls.list +++ b/sysdeps/unix/sysv/linux/wordsize-64/syscalls.list @@ -3,7 +3,6 @@ # Whee! 64-bit systems naturally implement llseek. llseek EXTRA lseek i:iii __libc_lseek __lseek lseek __libc_lseek64 __llseek llseek __lseek64 lseek64 lseek llseek - -pread - pread Ci:ibni __libc_pread __libc_pread64 __pread pread __pread64 pread64 pwrite - pwrite Ci:ibni __libc_pwrite __libc_pwrite64 __pwrite pwrite __pwrite64 pwrite64 fstatfs - fstatfs i:ip __fstatfs fstatfs fstatfs64 __fstatfs64 statfs - statfs i:sp __statfs statfs statfs64