From patchwork Mon Oct 21 15:46:27 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 1180704 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-106161-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=wdc.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="kCtm2lkV"; dkim=pass (2048-bit key; unprotected) header.d=wdc.com header.i=@wdc.com header.b="GsV9jQnc"; dkim-atps=neutral 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 46xh2l72Lrz9sP3 for ; Tue, 22 Oct 2019 02:51:43 +1100 (AEDT) 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:mime-version:content-transfer-encoding; q=dns; s= default; b=cU8rr883VoX5VmRhHwsWDfPWeZJDVhq3I1IRu7TxbEUzzInM+wo7T S9gizyP9+Mc6yo84U+UD851WHLbZyJTpBGxnArjv3mxivyDBxi8jjfsnZx/II/OE +cfFpryGknxES1D5RR7QKsboc8AUsvd6p+8XYfho4jo/zUp2BJoZxc= 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:mime-version:content-transfer-encoding; s=default; bh=1Hb20cw68dHp+jS/TanZas//eTI=; b=kCtm2lkV9TLoEHMvPGAvZ2PEAqZH w68qWlKMRUogQl4WXFxj8fjQ0lO9R9EYiG7J/OwjbW/BXbzpVZLl8h0v25pZ1fe0 7osm7fFL2i46DrSiPPYj24zcOebG05Y/zEgP41dU9+zfu+c47e+UGFVYDQ7fNKLJ lIBR+YADrCLvGfw= Received: (qmail 90534 invoked by alias); 21 Oct 2019 15:51:32 -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 90463 invoked by uid 89); 21 Oct 2019 15:51:31 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.4 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_NUMSUBJECT autolearn=ham version=3.3.1 spammy= X-HELO: esa4.hgst.iphmx.com DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1571673089; x=1603209089; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=y/nXtOWhhfiiRkavgdHcMeVHWsNZAUU6fMDv31lRA9A=; b=GsV9jQncLDc099n3cOhZSnzam9RWHw6oa4QA1Yzi/XmtXl2OW6oHMtev SzATPUDaDiwYLIEFhkgs1SpHyBg26mRsq/6g+PJa7aC2bg2jRXdUZxoJx lg3KPSh1PAZ1TI+u9FbPAlXNUhn6om6JI6q7e1+3inpiez96asxbTotbN hIAtKSa7BmYD8JYf1GC1WnfN+EofM45/Mkyl1gO4wr9sdF18NqHUo2/rH q2zwRPyv78BhUeYoLe6nNfmIv1RBkWmzN4Fcw29YjsFq+HHcb5t0eP+09 1VNX+iwssZe1kQDmIHR6jeyyPQsnrwbRSgoVwMCnRkKMbXz9X8AgBFLGl g==; IronPort-SDR: GI+Wb3nnTLwl20xSLmSMPuaq+NGZuORROC8D5mlWDyPRQIU3AVKJMuUxY7hmQ3lDWMqVR6Xoy5 RvUgQrUp4UW47HkfpQgSuFVTdjHl6ANPBA2C3wcAzBJsAs2o4udE3OYKSOaBE1SPJy0E7N+yL3 HtFeWkEe1+UUabe8Jd28MIcP1VuQGpBBIWhMaxhgZ/4o0VVhl3O5gw8QmxWItp8Vdkz2Xsq0Bb NpJ1B/3kZBgOmHSVKv4chm0tLfF++70I+E8sV6XxEZhRFeszxDLeYtNmXpilKPQgyKfE1n6qm2 9/I= IronPort-SDR: EIdMSaaO3CvgCq6nZvKBODK/epLLm9meLeZEgQKse9MBLNOAsQBzu1WhXo6dHwxN9mM4JUn3vR fTWjrjX/eYD+nZcCOVKt1DQzP8n0tlTpRF3kcJw18dMZTo0d2pyd1fObQz7DOSSehWAs6RDmQk KBtzl87fig9WrBc02y1qEmN79Wji8ONrBWp2TkeYf4b3+ZipXFmjpiGGzE3pS8AyISUOZ+cS6H 5Xs5eCGa/H405BbsD+7oVRvJdITnLc+dD0uH3p3KcE88EyBy4qq8afVZlPYS0GXxmpDM6BezqO 5A7TUytjHyrU9SsgRBL+oLUY IronPort-SDR: /iUuczeXFhyQoPaVeBJNr319+S5kelC+NGUMrOQi4vcDlzzojYzuRUtPxmjde0LyDn7kjJUd/i VwMhoBO8JMo+CX7sOOa0YMMoNy1VP40g70tW/VrEla5tBfxmRa4VmJaK2vTZDrn5wEiuwxgUSv 8mmNT7b2F7uhnO/rVtj5Hz4LLtmDCmyzbZKPK9w3cLTPzIbj9NYE+OeFernAmLptOK2ZCqfW9p SC6hzP/CytUrVohlu3poknb9fNWzzmNBEfrq1XOFlo2QRNV1eDBFSXRF/8pRdWoEelfGPV+rwh EXA= WDCIronportException: Internal From: Alistair Francis To: libc-alpha@sourceware.org Cc: alistair23@gmail.com, Alistair Francis Subject: [PATCH v5 2/2] Define __STATFS_MATCHES_STATFS64 Date: Mon, 21 Oct 2019 08:46:27 -0700 Message-Id: <20191021154627.23713-2-alistair.francis@wdc.com> In-Reply-To: <20191021154627.23713-1-alistair.francis@wdc.com> References: <20191021154627.23713-1-alistair.francis@wdc.com> MIME-Version: 1.0 Add a new macro __STATFS_MATCHES_STATFS64 that specifies if fsblkcnt_t matches fsblkcnt64_t and if fsfilcnt_t matches fsfilcnt64_t. On a 32-bit platform with a 64-bit ino_t type (__STATFS_MATCHES_STATFS64 == 1) we want to update the statfs struct to remove the padding as it isn't required. As we don't have the padding we also need to update the overflow checker to not access the undefined members. --- This change was tested by running user space tests for RV32 and RV64. This patch doesn't use the new macro. The RV32 port uses the macro, this is a preperation patch. v5: - Add missing changed to : - sysdeps/unix/sysv/linux/alpha/bits/typesizes.h - sysdeps/mach/hurd/bits/typesizes.h v4: - Convert to 0/1 convention instead of defined/not - Move "|| defined __STATFS_MATCHES_STATFS64" in the __WORDSIZE == 64 v2: - Change to if defined instead of if == 1 - Introduce __STATFS_MATCHES_STATFS64 bits/typesizes.h | 5 +++++ sysdeps/mach/hurd/bits/typesizes.h | 6 ++++++ sysdeps/unix/sysv/linux/alpha/bits/typesizes.h | 3 +++ sysdeps/unix/sysv/linux/generic/bits/statfs.h | 2 +- sysdeps/unix/sysv/linux/generic/bits/typesizes.h | 6 +++++- sysdeps/unix/sysv/linux/generic/wordsize-32/overflow.h | 4 ++++ sysdeps/unix/sysv/linux/s390/bits/typesizes.h | 5 +++++ sysdeps/unix/sysv/linux/sparc/bits/typesizes.h | 5 +++++ sysdeps/unix/sysv/linux/x86/bits/typesizes.h | 5 +++++ 9 files changed, 39 insertions(+), 2 deletions(-) diff --git a/bits/typesizes.h b/bits/typesizes.h index 779945bf099..ae6eff5fc5f 100644 --- a/bits/typesizes.h +++ b/bits/typesizes.h @@ -72,8 +72,13 @@ /* And for rlim_t and rlim64_t. */ # define __RLIM_T_MATCHES_RLIM64_T 1 + +/* And for fsblkcnt_t, fsblkcnt64_t, fsfilcnt_t and fsfilcnt64_t. */ +# define __STATFS_MATCHES_STATFS64 1 #else # define __RLIM_T_MATCHES_RLIM64_T 0 + +# define __STATFS_MATCHES_STATFS64 0 #endif /* Number of descriptors that can fit in an `fd_set'. */ diff --git a/sysdeps/mach/hurd/bits/typesizes.h b/sysdeps/mach/hurd/bits/typesizes.h index c30de12d1d4..e4c975ebd07 100644 --- a/sysdeps/mach/hurd/bits/typesizes.h +++ b/sysdeps/mach/hurd/bits/typesizes.h @@ -64,5 +64,11 @@ /* Number of descriptors that can fit in an `fd_set'. */ #define __FD_SETSIZE 256 +/* Tell the libc code that fsblkcnt_t, fsblkcnt64_t, fsfilcnt_t and + fsfilcnt64_t are actually the same type for all ABI purposes, even + if possibly expressed as different base types for C type-checking + purposes. */ +# define __STATFS_MATCHES_STATFS64 1 + #endif /* bits/typesizes.h */ diff --git a/sysdeps/unix/sysv/linux/alpha/bits/typesizes.h b/sysdeps/unix/sysv/linux/alpha/bits/typesizes.h index 20231152e33..5eb96f9a1e7 100644 --- a/sysdeps/unix/sysv/linux/alpha/bits/typesizes.h +++ b/sysdeps/unix/sysv/linux/alpha/bits/typesizes.h @@ -69,6 +69,9 @@ /* And for __rlim_t and __rlim64_t. */ #define __RLIM_T_MATCHES_RLIM64_T 1 +/* And for fsblkcnt_t, fsblkcnt64_t, fsfilcnt_t and fsfilcnt64_t. */ +# define __STATFS_MATCHES_STATFS64 1 + /* Number of descriptors that can fit in an `fd_set'. */ #define __FD_SETSIZE 1024 diff --git a/sysdeps/unix/sysv/linux/generic/bits/statfs.h b/sysdeps/unix/sysv/linux/generic/bits/statfs.h index c4069aba620..e622daf2240 100644 --- a/sysdeps/unix/sysv/linux/generic/bits/statfs.h +++ b/sysdeps/unix/sysv/linux/generic/bits/statfs.h @@ -34,7 +34,7 @@ #if defined __USE_FILE_OFFSET64 # define __field64(type, type64, name) type64 name -#elif __WORDSIZE == 64 +#elif __WORDSIZE == 64 || __STATFS_MATCHES_STATFS64 # define __field64(type, type64, name) type name #elif __BYTE_ORDER == __LITTLE_ENDIAN # define __field64(type, type64, name) \ diff --git a/sysdeps/unix/sysv/linux/generic/bits/typesizes.h b/sysdeps/unix/sysv/linux/generic/bits/typesizes.h index 05e3cfee454..0c8c2e0c12a 100644 --- a/sysdeps/unix/sysv/linux/generic/bits/typesizes.h +++ b/sysdeps/unix/sysv/linux/generic/bits/typesizes.h @@ -73,10 +73,14 @@ /* And for __rlim_t and __rlim64_t. */ # define __RLIM_T_MATCHES_RLIM64_T 1 + +/* And for fsblkcnt_t, fsblkcnt64_t, fsfilcnt_t and fsfilcnt64_t. */ +# define __STATFS_MATCHES_STATFS64 1 #else # define __RLIM_T_MATCHES_RLIM64_T 0 -#endif +# define __STATFS_MATCHES_STATFS64 0 +#endif /* Number of descriptors that can fit in an `fd_set'. */ #define __FD_SETSIZE 1024 diff --git a/sysdeps/unix/sysv/linux/generic/wordsize-32/overflow.h b/sysdeps/unix/sysv/linux/generic/wordsize-32/overflow.h index 66546b07ccd..f63dbfae899 100644 --- a/sysdeps/unix/sysv/linux/generic/wordsize-32/overflow.h +++ b/sysdeps/unix/sysv/linux/generic/wordsize-32/overflow.h @@ -51,6 +51,9 @@ static inline int stat_overflow (struct stat *buf) /* Note that f_files and f_ffree may validly be a sign-extended -1. */ static inline int statfs_overflow (struct statfs *buf) { +#if __STATFS_MATCHES_STATFS64 + return 0; +#else if (buf->__f_blocks_pad == 0 && buf->__f_bfree_pad == 0 && buf->__f_bavail_pad == 0 && (buf->__f_files_pad == 0 @@ -61,4 +64,5 @@ static inline int statfs_overflow (struct statfs *buf) __set_errno (EOVERFLOW); return -1; +#endif } diff --git a/sysdeps/unix/sysv/linux/s390/bits/typesizes.h b/sysdeps/unix/sysv/linux/s390/bits/typesizes.h index 94234f92427..38034e3ad40 100644 --- a/sysdeps/unix/sysv/linux/s390/bits/typesizes.h +++ b/sysdeps/unix/sysv/linux/s390/bits/typesizes.h @@ -78,8 +78,13 @@ /* And for __rlim_t and __rlim64_t. */ # define __RLIM_T_MATCHES_RLIM64_T 1 + +/* And for fsblkcnt_t, fsblkcnt64_t, fsfilcnt_t and fsfilcnt64_t. */ +# define __STATFS_MATCHES_STATFS64 1 #else # define __RLIM_T_MATCHES_RLIM64_T 0 + +# define __STATFS_MATCHES_STATFS64 0 #endif /* Number of descriptors that can fit in an `fd_set'. */ diff --git a/sysdeps/unix/sysv/linux/sparc/bits/typesizes.h b/sysdeps/unix/sysv/linux/sparc/bits/typesizes.h index 037f530d65b..c93f428017b 100644 --- a/sysdeps/unix/sysv/linux/sparc/bits/typesizes.h +++ b/sysdeps/unix/sysv/linux/sparc/bits/typesizes.h @@ -72,8 +72,13 @@ /* And for __rlim_t and __rlim64_t. */ # define __RLIM_T_MATCHES_RLIM64_T 1 + +/* And for fsblkcnt_t, fsblkcnt64_t, fsfilcnt_t and fsfilcnt64_t. */ +# define __STATFS_MATCHES_STATFS64 1 #else # define __RLIM_T_MATCHES_RLIM64_T 0 + +# define __STATFS_MATCHES_STATFS64 0 #endif /* Number of descriptors that can fit in an `fd_set'. */ diff --git a/sysdeps/unix/sysv/linux/x86/bits/typesizes.h b/sysdeps/unix/sysv/linux/x86/bits/typesizes.h index 012651b3ab5..168990f9dda 100644 --- a/sysdeps/unix/sysv/linux/x86/bits/typesizes.h +++ b/sysdeps/unix/sysv/linux/x86/bits/typesizes.h @@ -84,8 +84,13 @@ /* And for __rlim_t and __rlim64_t. */ # define __RLIM_T_MATCHES_RLIM64_T 1 + +/* And for fsblkcnt_t, fsblkcnt64_t, fsfilcnt_t and fsfilcnt64_t. */ +# define __STATFS_MATCHES_STATFS64 1 #else # define __RLIM_T_MATCHES_RLIM64_T 0 + +# define __STATFS_MATCHES_STATFS64 0 #endif /* Number of descriptors that can fit in an `fd_set'. */