From patchwork Thu Jan 7 17:18:26 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: 564378 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 102D71402DE for ; Fri, 8 Jan 2016 04:19:07 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b=Aza1u5Vp; 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:to:cc:subject:date:message-id:in-reply-to :references; q=dns; s=default; b=vEmS411E1MrhlnUlXA1OS5b8T3nPeGp 9m3cNifVscbR+/ED58EJtWKa0AGT9Q1edkdPLWm21cXX8Eb6QktI8d1YoqDdhfiX hmPnRPax3qXQ5xcModcEjwf+ZV6IMLOLdR/sgeO8w6WX2UJc2rTn2cBOUJ41+rKA hTLc+/PPvi5U= 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:cc:subject:date:message-id:in-reply-to :references; s=default; bh=Uxm0isuiYdDLZexRIhCo7moS+tw=; b=Aza1u 5Vpdsg69RB8WcugrKvIQZ7Fypj2f+F5NZORQe1dOxnWOSQY/c7l3+hWv1WogJBdc gVsEGYtXcaXgqsAt1dic7ZPVzIUQi88gJehaac+Pbee7N0YXR02YO8yNIXgg6cne hLWI8/MuA/qvp5sq1ADQdGowDUXbqAInGoVSoA= Received: (qmail 35828 invoked by alias); 7 Jan 2016 17:18:44 -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 35691 invoked by uid 89); 7 Jan 2016 17:18:43 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.4 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 spammy=236, 186, 23, 6, 24, 7 X-HELO: mail-qk0-f180.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:cc:subject:date:message-id:in-reply-to :references; bh=Alfo0yT6OxnwBgCj+MWjphpvsSQGeeCZ109PFeY5bVk=; b=cHjtWhXJ8Ma+6htCoQdWnXCMoJ0xw4M3g/dfQUlcLPpG+tdYTQhzvVFpRdy6kzbTBR P3cmdr5ayO8gWfGG25BVF6us+cOqc33oB0nbapqr+jgCG5iTBZN8Ah/7M/r1kxSEoAx4 vAhEXrKlzeaU7HRHv572J5FNHQMnD6XlnhNRX/vWEYuZGH3cNPx7tK5KY7MEBjDDqxt8 c5Rah/DSHmJt+tlcNZXHR8nuFbPOLpg8eTx8wWNh3f+Zb7A2NeaxXNRzj88PR2NKGF2E yDdN9a4AJJGY2gPw8xvIUxidh4KFHL2coXDsiU/u3u0q3LVkERgSK59yS8g2nrhLX0DD Fj+w== X-Gm-Message-State: ALoCoQlmKw3fkHIt4I4BIyvfB4YIYAUgLW+g/cD7EZbR5mfClnR1PTyJBnm1Kb3vUJ/WilZvSln8xFNXa7jbJx0ujeg6XnyqVA== X-Received: by 10.13.228.131 with SMTP id n125mr86627566ywe.65.1452187118169; Thu, 07 Jan 2016 09:18:38 -0800 (PST) From: Adhemerval Zanella To: libc-alpha@sourceware.org Cc: Adhemerval Zanella Subject: [PATCH 2/4] Consolidate off_t/off64_t syscall argument passing Date: Thu, 7 Jan 2016 15:18:26 -0200 Message-Id: <1452187108-6504-3-git-send-email-adhemerval.zanella@linaro.org> In-Reply-To: <1452187108-6504-1-git-send-email-adhemerval.zanella@linaro.org> References: <1452187108-6504-1-git-send-email-adhemerval.zanella@linaro.org> From: Adhemerval Zanella This patch add two new macros to use along with off_t and off64_t argument syscalls. The rationale for this change is: 1. Remove multiple implementations for the same syscall for different architectures (for instance, pread have 6 different implementations). 2. Also remove the requirement to use syscall wrappers for cancellable entrypoints. The macro usage should be used along __ALIGNMENT_ARG to follow ABI constrains for architecture where it applies. For instance, pread can be rewritten as: return SYSCALL_CANCEL (pread, fd, buf, count, __ALIGNMENT_ARG SYSCALL_LL (offset)); Another macro, SYSCALL_LL64, is provided for off64_t. For ILP32 ABI with 64-bits kernel registers pass interface a new defined is used, __ASSUME_WORDSIZE64_ILP32, to indicate that the SYSCALL_LL{64} should be uses as for a 64-bit ABI. The changes itself are not currently used in any implementation, so no code change is expected. * sysdeps/unix/sysv/linux/alpha/sysdep.h: Include generic sysdep.h. * sysdeps/unix/sysv/linux/arm/sysdep.h: Likewise. * sysdeps/unix/sysv/linux/hppa/sysdep.h: Likewise. * sysdeps/unix/sysv/linux/i386/sysdep.h: Likewise. * sysdeps/unix/sysv/linux/ia64/sysdep.h: Likewise. * sysdeps/unix/sysv/linux/m68k/sysdep.h: Likewise. * sysdeps/unix/sysv/linux/microblaze/sysdep.h: Likewise. * sysdeps/unix/sysv/linux/mips/mips32/sysdep.h: Likewise. * sysdeps/unix/sysv/linux/mips/mips64/n32/sysdep.h: Likewise. * sysdeps/unix/sysv/linux/mips/mips64/n64/sysdep.h: Likewise. * sysdeps/unix/sysv/linux/powerpc/powerpc32/sysdep.h: Likewise. * sysdeps/unix/sysv/linux/powerpc/powerpc64/sysdep.h: Likewise. * sysdeps/unix/sysv/linux/s390/s390-32/sysdep.h: Likewise. * sysdeps/unix/sysv/linux/s390/s390-64/sysdep.h: Likewise. * sysdeps/unix/sysv/linux/sh/sysdep.h: Likewise. * sysdeps/unix/sysv/linux/sparc/sysdep.h: Likewise. * sysdeps/unix/sysv/linux/x86_64/sysdep.h: Likewise. * sysdeps/unix/sysv/linux/generic/sysdep.h (__NR__llseek): Define only if it is not already defined. (SYSCALL_LL): Define. (SYSCALL_LL64): Likewise. * sysdeps/unix/sysv/linux/x86_64/kernel-features.h [__ILP32] (__ASSUME_WORDSIZE64_ILP32): Define. * sysdeps/unix/sysv/linux/mips/kernel-features.h [_MIPS_SIM == _ABIN32] (__ASSUME_WORDSIZE64_ILP32): Likewise. --- ChangeLog | 26 ++++++++++++++++++++++ sysdeps/unix/sysv/linux/alpha/sysdep.h | 1 + sysdeps/unix/sysv/linux/arm/sysdep.h | 1 + sysdeps/unix/sysv/linux/generic/sysdep.h | 13 +++++++++++ sysdeps/unix/sysv/linux/hppa/sysdep.h | 1 + sysdeps/unix/sysv/linux/i386/sysdep.h | 1 + sysdeps/unix/sysv/linux/ia64/sysdep.h | 1 + sysdeps/unix/sysv/linux/m68k/sysdep.h | 1 + sysdeps/unix/sysv/linux/microblaze/sysdep.h | 1 + sysdeps/unix/sysv/linux/mips/kernel-features.h | 6 +++++ sysdeps/unix/sysv/linux/mips/mips32/sysdep.h | 1 + sysdeps/unix/sysv/linux/mips/mips64/n32/sysdep.h | 1 + sysdeps/unix/sysv/linux/mips/mips64/n64/sysdep.h | 1 + sysdeps/unix/sysv/linux/powerpc/powerpc32/sysdep.h | 1 + sysdeps/unix/sysv/linux/powerpc/powerpc64/sysdep.h | 1 + sysdeps/unix/sysv/linux/s390/s390-32/sysdep.h | 1 + sysdeps/unix/sysv/linux/s390/s390-64/sysdep.h | 1 + sysdeps/unix/sysv/linux/sh/sysdep.h | 1 + sysdeps/unix/sysv/linux/sparc/sysdep.h | 1 + sysdeps/unix/sysv/linux/x86_64/kernel-features.h | 6 +++++ sysdeps/unix/sysv/linux/x86_64/sysdep.h | 1 + 21 files changed, 68 insertions(+) diff --git a/sysdeps/unix/sysv/linux/alpha/sysdep.h b/sysdeps/unix/sysv/linux/alpha/sysdep.h index b6efc66..d6a1ac9 100644 --- a/sysdeps/unix/sysv/linux/alpha/sysdep.h +++ b/sysdeps/unix/sysv/linux/alpha/sysdep.h @@ -27,6 +27,7 @@ /* There is some commonality. */ #include #include +#include #include diff --git a/sysdeps/unix/sysv/linux/arm/sysdep.h b/sysdeps/unix/sysv/linux/arm/sysdep.h index 3986547..2d3be92 100644 --- a/sysdeps/unix/sysv/linux/arm/sysdep.h +++ b/sysdeps/unix/sysv/linux/arm/sysdep.h @@ -23,6 +23,7 @@ /* There is some commonality. */ #include #include +#include /* Defines RTLD_PRIVATE_ERRNO and USE_DL_SYSINFO. */ #include diff --git a/sysdeps/unix/sysv/linux/generic/sysdep.h b/sysdeps/unix/sysv/linux/generic/sysdep.h index 4f2c65d..22bfe59 100644 --- a/sysdeps/unix/sysv/linux/generic/sysdep.h +++ b/sysdeps/unix/sysv/linux/generic/sysdep.h @@ -22,7 +22,9 @@ #include /* Provide the common name to allow more code reuse. */ +#ifndef __NR__llseek #define __NR__llseek __NR_llseek +#endif #if __WORDSIZE == 64 /* By defining the older names, glibc will build syscall wrappers for @@ -41,3 +43,14 @@ #define __ALIGNMENT_ARG #define __ALIGNMENT_COUNT(a,b) a #endif + +/* Provide a common macro to pass 64-bit value on syscalls. */ +#if __WORDSIZE == 64 || defined __ASSUME_WORDSIZE64_ILP32 +# define SYSCALL_LL(__val) (__val) +# define SYSCALL_LL64(__val) (__val) +#else +#define SYSCALL_LL(__val) \ + __LONG_LONG_PAIR (__val >> 31, __val) +#define SYSCALL_LL64(__val) \ + __LONG_LONG_PAIR ((long) (__val >> 32), (long) (__val & 0xffffffff)) +#endif diff --git a/sysdeps/unix/sysv/linux/hppa/sysdep.h b/sysdeps/unix/sysv/linux/hppa/sysdep.h index b459f0a..7b43695 100644 --- a/sysdeps/unix/sysv/linux/hppa/sysdep.h +++ b/sysdeps/unix/sysv/linux/hppa/sysdep.h @@ -24,6 +24,7 @@ #include #include #include +#include /* Defines RTLD_PRIVATE_ERRNO. */ #include diff --git a/sysdeps/unix/sysv/linux/i386/sysdep.h b/sysdeps/unix/sysv/linux/i386/sysdep.h index 5fcb175..8776d8e 100644 --- a/sysdeps/unix/sysv/linux/i386/sysdep.h +++ b/sysdeps/unix/sysv/linux/i386/sysdep.h @@ -22,6 +22,7 @@ /* There is some commonality. */ #include #include +#include /* Defines RTLD_PRIVATE_ERRNO and USE_DL_SYSINFO. */ #include #include diff --git a/sysdeps/unix/sysv/linux/ia64/sysdep.h b/sysdeps/unix/sysv/linux/ia64/sysdep.h index 8dfc582..9b95454 100644 --- a/sysdeps/unix/sysv/linux/ia64/sysdep.h +++ b/sysdeps/unix/sysv/linux/ia64/sysdep.h @@ -22,6 +22,7 @@ #include #include +#include #include #include #include diff --git a/sysdeps/unix/sysv/linux/m68k/sysdep.h b/sysdeps/unix/sysv/linux/m68k/sysdep.h index ce48496..ff4dea0 100644 --- a/sysdeps/unix/sysv/linux/m68k/sysdep.h +++ b/sysdeps/unix/sysv/linux/m68k/sysdep.h @@ -18,6 +18,7 @@ . */ #include +#include #include /* Defines RTLD_PRIVATE_ERRNO. */ diff --git a/sysdeps/unix/sysv/linux/microblaze/sysdep.h b/sysdeps/unix/sysv/linux/microblaze/sysdep.h index abc13c2..f06aa1b 100644 --- a/sysdeps/unix/sysv/linux/microblaze/sysdep.h +++ b/sysdeps/unix/sysv/linux/microblaze/sysdep.h @@ -22,6 +22,7 @@ #include #include #include +#include /* Defines RTLD_PRIVATE_ERRNO. */ #include diff --git a/sysdeps/unix/sysv/linux/mips/kernel-features.h b/sysdeps/unix/sysv/linux/mips/kernel-features.h index 586871d..4c46ae7 100644 --- a/sysdeps/unix/sysv/linux/mips/kernel-features.h +++ b/sysdeps/unix/sysv/linux/mips/kernel-features.h @@ -53,3 +53,9 @@ #if _MIPS_SIM == _ABIO32 #define __ASSUME_ALIGNED_REGISTER_PAIRS 1 #endif + +/* Define that mips64-n32 is a ILP32 ABI to set the correct interface to + pass 64-bits values through syscalls. */ +#if _MIPS_SIM == _ABIN32 +# define __ASSUME_WORDSIZE64_ILP32 1 +#endif diff --git a/sysdeps/unix/sysv/linux/mips/mips32/sysdep.h b/sysdeps/unix/sysv/linux/mips/mips32/sysdep.h index 2160df7..6551794 100644 --- a/sysdeps/unix/sysv/linux/mips/mips32/sysdep.h +++ b/sysdeps/unix/sysv/linux/mips/mips32/sysdep.h @@ -21,6 +21,7 @@ /* There is some commonality. */ #include #include +#include #include diff --git a/sysdeps/unix/sysv/linux/mips/mips64/n32/sysdep.h b/sysdeps/unix/sysv/linux/mips/mips64/n32/sysdep.h index 466dcde..88efe74 100644 --- a/sysdeps/unix/sysv/linux/mips/mips64/n32/sysdep.h +++ b/sysdeps/unix/sysv/linux/mips/mips64/n32/sysdep.h @@ -21,6 +21,7 @@ /* There is some commonality. */ #include #include +#include #include diff --git a/sysdeps/unix/sysv/linux/mips/mips64/n64/sysdep.h b/sysdeps/unix/sysv/linux/mips/mips64/n64/sysdep.h index db8b237..09ea9fa 100644 --- a/sysdeps/unix/sysv/linux/mips/mips64/n64/sysdep.h +++ b/sysdeps/unix/sysv/linux/mips/mips64/n64/sysdep.h @@ -21,6 +21,7 @@ /* There is some commonality. */ #include #include +#include #include diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/sysdep.h b/sysdeps/unix/sysv/linux/powerpc/powerpc32/sysdep.h index 6d8990c..390ce24 100644 --- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/sysdep.h +++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/sysdep.h @@ -20,6 +20,7 @@ #include #include +#include #include /* Some systen calls got renamed over time, but retained the same semantics. diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/sysdep.h b/sysdeps/unix/sysv/linux/powerpc/powerpc64/sysdep.h index 91fd096..761f3ea 100644 --- a/sysdeps/unix/sysv/linux/powerpc/powerpc64/sysdep.h +++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/sysdep.h @@ -22,6 +22,7 @@ #include #include +#include #include /* Define __set_errno() for INLINE_SYSCALL macro below. */ diff --git a/sysdeps/unix/sysv/linux/s390/s390-32/sysdep.h b/sysdeps/unix/sysv/linux/s390/s390-32/sysdep.h index 3540416..672b326 100644 --- a/sysdeps/unix/sysv/linux/s390/s390-32/sysdep.h +++ b/sysdeps/unix/sysv/linux/s390/s390-32/sysdep.h @@ -22,6 +22,7 @@ #include #include #include +#include #include /* For RTLD_PRIVATE_ERRNO. */ #include diff --git a/sysdeps/unix/sysv/linux/s390/s390-64/sysdep.h b/sysdeps/unix/sysv/linux/s390/s390-64/sysdep.h index 6f390ff..980f202 100644 --- a/sysdeps/unix/sysv/linux/s390/s390-64/sysdep.h +++ b/sysdeps/unix/sysv/linux/s390/s390-64/sysdep.h @@ -23,6 +23,7 @@ #include #include #include +#include #include /* For RTLD_PRIVATE_ERRNO. */ #include diff --git a/sysdeps/unix/sysv/linux/sh/sysdep.h b/sysdeps/unix/sysv/linux/sh/sysdep.h index 8618d12..b8cafcc 100644 --- a/sysdeps/unix/sysv/linux/sh/sysdep.h +++ b/sysdeps/unix/sysv/linux/sh/sysdep.h @@ -23,6 +23,7 @@ /* There is some commonality. */ #include #include +#include #include /* For Linux we can use the system call table in the header file diff --git a/sysdeps/unix/sysv/linux/sparc/sysdep.h b/sysdeps/unix/sysv/linux/sparc/sysdep.h index cb197b6..615a0cb 100644 --- a/sysdeps/unix/sysv/linux/sparc/sysdep.h +++ b/sysdeps/unix/sysv/linux/sparc/sysdep.h @@ -22,6 +22,7 @@ #include #include #include +#include #ifdef __ASSEMBLER__ diff --git a/sysdeps/unix/sysv/linux/x86_64/kernel-features.h b/sysdeps/unix/sysv/linux/x86_64/kernel-features.h index 0b84f11..1b116d9 100644 --- a/sysdeps/unix/sysv/linux/x86_64/kernel-features.h +++ b/sysdeps/unix/sysv/linux/x86_64/kernel-features.h @@ -35,4 +35,10 @@ # define __ASSUME_GETCPU_SYSCALL 1 #endif +/* Define that mips64-n32 is a ILP32 ABI to set the correct interface to + pass 64-bits values through syscalls. */ +#ifdef __ILP32__ +# define __ASSUME_WORDSIZE64_ILP32 1 +#endif + #include_next diff --git a/sysdeps/unix/sysv/linux/x86_64/sysdep.h b/sysdeps/unix/sysv/linux/x86_64/sysdep.h index d023d68..723ebf2 100644 --- a/sysdeps/unix/sysv/linux/x86_64/sysdep.h +++ b/sysdeps/unix/sysv/linux/x86_64/sysdep.h @@ -21,6 +21,7 @@ /* There is some commonality. */ #include #include +#include #include #if IS_IN (rtld)