[v6] Define __STATFS_MATCHES_STATFS64

Message ID 20191023210739.31432-1-alistair.francis@wdc.com
State New
Headers show
Series
  • [v6] Define __STATFS_MATCHES_STATFS64
Related show

Commit Message

Alistair Francis Oct. 23, 2019, 9:07 p.m.
Add a new macro __STATFS_MATCHES_STATFS64 that specifies if fsblkcnt_t
matches fsblkcnt64_t and if fsfilcnt_t matches fsfilcnt64_t.

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.

v6:
 - Drop paragraph from commit
 - Fix Alpha and Hurd configuration
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                     | 4 ++++
 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, 37 insertions(+), 2 deletions(-)

-- 
2.23.0

Comments

Joseph Myers Oct. 23, 2019, 9:25 p.m. | #1
On Wed, 23 Oct 2019, Alistair Francis wrote:

> Add a new macro __STATFS_MATCHES_STATFS64 that specifies if fsblkcnt_t

> matches fsblkcnt64_t and if fsfilcnt_t matches fsfilcnt64_t.

> 

> 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.

> 

> v6:

>  - Drop paragraph from commit

>  - Fix Alpha and Hurd configuration


This patch version is OK.

-- 
Joseph S. Myers
joseph@codesourcery.com

Patch

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..3600137f501 100644
--- a/sysdeps/mach/hurd/bits/typesizes.h
+++ b/sysdeps/mach/hurd/bits/typesizes.h
@@ -64,5 +64,9 @@ 
 /* 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 not the same type for all ABI purposes.  */
+# define __STATFS_MATCHES_STATFS64  0
+
 
 #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..687b4df006a 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
 
+/* Not for fsblkcnt_t, fsblkcnt64_t, fsfilcnt_t and fsfilcnt64_t.  */
+# define __STATFS_MATCHES_STATFS64  0
+
 /* 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'.  */