diff mbox

Use Linux-like in struct statx, struct statx_timestamp [BZ #25292]

Message ID 87zhfpzmuw.fsf@oldenburg2.str.redhat.com
State New, archived
Headers show

Commit Message

Florian Weimer Dec. 18, 2019, 3:15 p.m. UTC
uint64_t is defined as unsigned long int on 64-bit architectures,
while the kernel defines it as unsigned long long int.  It is
desirable to align with Linux types, to match printf format
specifiers and the types of pointers to struct members.

In retrospect, it was a mistake to add struct statx to the
existing <sys/stat.h> header because the header now requires
long long support for _GNU_SOURCE even in cases where struct stat
does not inherently require it.  It would have been better to create
a separate <sys/statx.h> header file, to isolate <sys/stat.h> from
any compatibility concerns with legacy compilers.

Tested with build-many-glibcs.py, on x86_64-linux-gnu and
i686-linux-gnu with Linux 5.3 kernel headers, and with historic
kernel headers on powerpc64-linux-gnu and s390x-linux-gnu
(from kernel-headers-3.10.0-327.el7; these headers do not contain
a statx backport).

 io/bits/types/struct_statx.h           | 34 +++++++++++++++++-----------------
 io/bits/types/struct_statx_timestamp.h |  6 +++---
 2 files changed, 20 insertions(+), 20 deletions(-)
diff mbox


diff --git a/io/bits/types/struct_statx.h b/io/bits/types/struct_statx.h
index d042372a1b..5d1b7d07f9 100644
--- a/io/bits/types/struct_statx.h
+++ b/io/bits/types/struct_statx.h
@@ -29,27 +29,27 @@ 
    argument of the statx function.)  */
 struct statx
-  __uint32_t stx_mask;
-  __uint32_t stx_blksize;
-  __uint64_t stx_attributes;
-  __uint32_t stx_nlink;
-  __uint32_t stx_uid;
-  __uint32_t stx_gid;
-  __uint16_t stx_mode;
-  __uint16_t __statx_pad1[1];
-  __uint64_t stx_ino;
-  __uint64_t stx_size;
-  __uint64_t stx_blocks;
-  __uint64_t stx_attributes_mask;
+  unsigned int stx_mask;
+  unsigned int stx_blksize;
+  __extension__ unsigned long long int stx_attributes;
+  unsigned int stx_nlink;
+  unsigned int stx_uid;
+  unsigned int stx_gid;
+  unsigned short int stx_mode;
+  unsigned short int __statx_pad1[1];
+  __extension__ unsigned long long int stx_ino;
+  __extension__ unsigned long long int stx_size;
+  __extension__ unsigned long long int stx_blocks;
+  __extension__ unsigned long long int stx_attributes_mask;
   struct statx_timestamp stx_atime;
   struct statx_timestamp stx_btime;
   struct statx_timestamp stx_ctime;
   struct statx_timestamp stx_mtime;
-  __uint32_t stx_rdev_major;
-  __uint32_t stx_rdev_minor;
-  __uint32_t stx_dev_major;
-  __uint32_t stx_dev_minor;
-  __uint64_t __statx_pad2[14];
+  unsigned int stx_rdev_major;
+  unsigned int stx_rdev_minor;
+  unsigned int stx_dev_major;
+  unsigned int stx_dev_minor;
+  __extension__ unsigned long long int __statx_pad2[14];
 #endif /* __statx_defined */
diff --git a/io/bits/types/struct_statx_timestamp.h b/io/bits/types/struct_statx_timestamp.h
index c1691065e8..98c9fb9fd5 100644
--- a/io/bits/types/struct_statx_timestamp.h
+++ b/io/bits/types/struct_statx_timestamp.h
@@ -25,9 +25,9 @@ 
 struct statx_timestamp
-  __int64_t tv_sec;
-  __uint32_t tv_nsec;
-  __int32_t __statx_timestamp_pad1[1];
+  __extension__ long long int tv_sec;
+  unsigned int tv_nsec;
+  int __statx_timestamp_pad1[1];
 #endif /* __statx_timestamp_defined */