From patchwork Tue Oct 22 15:59:21 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 35223 Received: (qmail 120387 invoked by alias); 22 Oct 2019 16:04: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 120310 invoked by uid 89); 22 Oct 2019 16:04:19 -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=1571760257; x=1603296257; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=y/nXtOWhhfiiRkavgdHcMeVHWsNZAUU6fMDv31lRA9A=; b=b0PQBLgAEHqmAyEx3A3sitx+Lx9yMFc0FUukqfwgPcjc1FmpixWMHxuG paY1pOhmcfg4Ux6PMcjWxdYF3LIO/slO4HpPcLBso5STYMLe3niVf9i1b 2LoN5XzAbpOV22FHeyChUr27BtDWHnGttBO5LYQANggHFSY4PtT728E+k NlW+QfpO0LTiv5e99bbDtz2VWohBlK+IB57JSyprvvvvr8rrYxiHma0GA e+VEgWoC9wnTsLCg5Qe+3wIz25oWNyj8rbZJFjVoVQHKvyR2zLFuVkHcl aaZSdfALkSNJ09ndyt8ooU237lJY+Icqr3mx+89hPvxNDSjwcqD5Uy9/K A==; IronPort-SDR: JrGSzLrPc5Pz3Sau/jbxT1h/QP2XilMBEEo8TfGgOKgLWL3+Uldfitzk681zqzgtEopDdYoTAm OWu03zTlhKD6oETldnNdIB3N5wLOZ6aD4U0ofoJAZRwr6NA3i9dPqI9y6Nyi3If5+qX0ueKDMm nu+MkAP+ZGPm7Y9VQH8+pJ/Km8/pZX1yqiH4LFXc1swgA+exL65wBFZqvK3ysvl9sdVu6UnTrT Q0+KD4s2sA+kDxLvcH9KexhIYuciFthsAlEr/LH5lKpn5HguysEvrYGe7vJuAZ8WUOF4fTzqoA n7w= IronPort-SDR: qIPMJr36WrKWdzZ6gPA3OHmkwegKtCCKpsTBA4ztlfEG/qVETWu/djZm6dpkIMovpgnSQfyGA7 Z8jxpjlVbVRN4QnyZTGt83hNSM7O5bBRzBPODB7c9d2u/q5I6lQceHv75Gfm3yykHBLkA9p1aO sqWBWWJBO/zAFGLFDCQhJBagVHHqy7XCK/i3p2/CNYe9dX4qWf8+lNdnH7No0zpQJzsL376OqQ hjAlCFUBVCIW7GNVEDYw4rOX0K/2i0O4cfuOhz36zp+tZ9ANv6xq/3xUDo4iEoBjgAUZu5rR8p PeaDSlBUUkldgbZ6AgifOGWS IronPort-SDR: JM8koDcVkyWfOhwbax3bPG9ncfB4uod1KjBPEQLuhQi/hjVnlegBYz1uD7SSmTcsqS8Ddsjv1g F7HpDf049IMITWI2eQM9W2/8cIfdVqpQy8LHJGQbOzlghTmGHySUK/ZzbykSz4XPr+aG9/usWY GzdF9bGCUmAfKZPNHUl3UsRM8JWFt+gsPG7IM0VrZins9/bqjGzHLFXIxFsaU7EHyUWqpVYZ3I 2x0JJsBwQlZav+qYLXk/MrgnvhYurCooYqfp5fpH2nI2vGO1fKSjRVaD7mQa1gzimqhYUpf+/I CFo= WDCIronportException: Internal From: Alistair Francis To: libc-alpha@sourceware.org Cc: alistair23@gmaill.com, Alistair Francis Subject: [PATCH v6 2/2] Define __STATFS_MATCHES_STATFS64 Date: Tue, 22 Oct 2019 08:59:21 -0700 Message-Id: <20191022155921.8697-2-alistair.francis@wdc.com> In-Reply-To: <20191022155921.8697-1-alistair.francis@wdc.com> References: <20191022155921.8697-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'. */