Define __STATFS_MATCHES_STATFS64

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 commit is contained in:
Alistair Francis 2019-08-13 13:35:28 -07:00
parent 3007ad2140
commit acab05949f
9 changed files with 37 additions and 2 deletions

View File

@ -72,8 +72,13 @@
/* And for rlim_t and rlim64_t. */ /* And for rlim_t and rlim64_t. */
# define __RLIM_T_MATCHES_RLIM64_T 1 # define __RLIM_T_MATCHES_RLIM64_T 1
/* And for fsblkcnt_t, fsblkcnt64_t, fsfilcnt_t and fsfilcnt64_t. */
# define __STATFS_MATCHES_STATFS64 1
#else #else
# define __RLIM_T_MATCHES_RLIM64_T 0 # define __RLIM_T_MATCHES_RLIM64_T 0
# define __STATFS_MATCHES_STATFS64 0
#endif #endif
/* Number of descriptors that can fit in an `fd_set'. */ /* Number of descriptors that can fit in an `fd_set'. */

View File

@ -64,5 +64,9 @@
/* Number of descriptors that can fit in an `fd_set'. */ /* Number of descriptors that can fit in an `fd_set'. */
#define __FD_SETSIZE 256 #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 */ #endif /* bits/typesizes.h */

View File

@ -69,6 +69,9 @@
/* And for __rlim_t and __rlim64_t. */ /* And for __rlim_t and __rlim64_t. */
#define __RLIM_T_MATCHES_RLIM64_T 1 #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'. */ /* Number of descriptors that can fit in an `fd_set'. */
#define __FD_SETSIZE 1024 #define __FD_SETSIZE 1024

View File

@ -34,7 +34,7 @@
#if defined __USE_FILE_OFFSET64 #if defined __USE_FILE_OFFSET64
# define __field64(type, type64, name) type64 name # define __field64(type, type64, name) type64 name
#elif __WORDSIZE == 64 #elif __WORDSIZE == 64 || __STATFS_MATCHES_STATFS64
# define __field64(type, type64, name) type name # define __field64(type, type64, name) type name
#elif __BYTE_ORDER == __LITTLE_ENDIAN #elif __BYTE_ORDER == __LITTLE_ENDIAN
# define __field64(type, type64, name) \ # define __field64(type, type64, name) \

View File

@ -73,10 +73,14 @@
/* And for __rlim_t and __rlim64_t. */ /* And for __rlim_t and __rlim64_t. */
# define __RLIM_T_MATCHES_RLIM64_T 1 # define __RLIM_T_MATCHES_RLIM64_T 1
/* And for fsblkcnt_t, fsblkcnt64_t, fsfilcnt_t and fsfilcnt64_t. */
# define __STATFS_MATCHES_STATFS64 1
#else #else
# define __RLIM_T_MATCHES_RLIM64_T 0 # define __RLIM_T_MATCHES_RLIM64_T 0
#endif
# define __STATFS_MATCHES_STATFS64 0
#endif
/* Number of descriptors that can fit in an `fd_set'. */ /* Number of descriptors that can fit in an `fd_set'. */
#define __FD_SETSIZE 1024 #define __FD_SETSIZE 1024

View File

@ -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. */ /* Note that f_files and f_ffree may validly be a sign-extended -1. */
static inline int statfs_overflow (struct statfs *buf) 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 if (buf->__f_blocks_pad == 0 && buf->__f_bfree_pad == 0
&& buf->__f_bavail_pad == 0 && buf->__f_bavail_pad == 0
&& (buf->__f_files_pad == 0 && (buf->__f_files_pad == 0
@ -61,4 +64,5 @@ static inline int statfs_overflow (struct statfs *buf)
__set_errno (EOVERFLOW); __set_errno (EOVERFLOW);
return -1; return -1;
#endif
} }

View File

@ -78,8 +78,13 @@
/* And for __rlim_t and __rlim64_t. */ /* And for __rlim_t and __rlim64_t. */
# define __RLIM_T_MATCHES_RLIM64_T 1 # define __RLIM_T_MATCHES_RLIM64_T 1
/* And for fsblkcnt_t, fsblkcnt64_t, fsfilcnt_t and fsfilcnt64_t. */
# define __STATFS_MATCHES_STATFS64 1
#else #else
# define __RLIM_T_MATCHES_RLIM64_T 0 # define __RLIM_T_MATCHES_RLIM64_T 0
# define __STATFS_MATCHES_STATFS64 0
#endif #endif
/* Number of descriptors that can fit in an `fd_set'. */ /* Number of descriptors that can fit in an `fd_set'. */

View File

@ -72,8 +72,13 @@
/* And for __rlim_t and __rlim64_t. */ /* And for __rlim_t and __rlim64_t. */
# define __RLIM_T_MATCHES_RLIM64_T 1 # define __RLIM_T_MATCHES_RLIM64_T 1
/* And for fsblkcnt_t, fsblkcnt64_t, fsfilcnt_t and fsfilcnt64_t. */
# define __STATFS_MATCHES_STATFS64 1
#else #else
# define __RLIM_T_MATCHES_RLIM64_T 0 # define __RLIM_T_MATCHES_RLIM64_T 0
# define __STATFS_MATCHES_STATFS64 0
#endif #endif
/* Number of descriptors that can fit in an `fd_set'. */ /* Number of descriptors that can fit in an `fd_set'. */

View File

@ -84,8 +84,13 @@
/* And for __rlim_t and __rlim64_t. */ /* And for __rlim_t and __rlim64_t. */
# define __RLIM_T_MATCHES_RLIM64_T 1 # define __RLIM_T_MATCHES_RLIM64_T 1
/* And for fsblkcnt_t, fsblkcnt64_t, fsfilcnt_t and fsfilcnt64_t. */
# define __STATFS_MATCHES_STATFS64 1
#else #else
# define __RLIM_T_MATCHES_RLIM64_T 0 # define __RLIM_T_MATCHES_RLIM64_T 0
# define __STATFS_MATCHES_STATFS64 0
#endif #endif
/* Number of descriptors that can fit in an `fd_set'. */ /* Number of descriptors that can fit in an `fd_set'. */