diff mbox series

[uclibc-ng-devel] bits/stat.h: Declare st_mtim if defined(__USE_XOPEN2K8), everywhere

Message ID 20240727-stat-v1-1-73212ba93d28@gmx.net
State Accepted
Headers show
Series [uclibc-ng-devel] bits/stat.h: Declare st_mtim if defined(__USE_XOPEN2K8), everywhere | expand

Commit Message

J. Neuschäfer July 27, 2024, 10:06 a.m. UTC
While building software that sets _POSIX_C_SOURCE=200809L and uses
stat.st_mtim for ARM, it was noticed that st_mtim was not defined.

This seems to be because common/bits/stat.h was picked up, which does
not take __USE_XOPEN2K8 as a reason to enable st_mtim and related
fields. This appears to be an oversight, and porting the check from
common-generic/bits/stat.h to other architectures does indeed fix the
build issue.

This patch is based on commit 50bd6d06e ("Fix memory corruption due to
struct stat field").

Signed-off-by: J. Neuschäfer <j.neuschaefer@gmx.net>
---
 libc/sysdeps/linux/alpha/bits/stat.h   | 2 +-
 libc/sysdeps/linux/common/bits/stat.h  | 4 ++--
 libc/sysdeps/linux/frv/bits/stat.h     | 4 ++--
 libc/sysdeps/linux/ia64/bits/stat.h    | 4 ++--
 libc/sysdeps/linux/m68k/bits/stat.h    | 4 ++--
 libc/sysdeps/linux/mips/bits/stat.h    | 4 ++--
 libc/sysdeps/linux/nds32/bits/stat.h   | 4 ++--
 libc/sysdeps/linux/powerpc/bits/stat.h | 4 ++--
 8 files changed, 15 insertions(+), 15 deletions(-)


---
base-commit: 05b11809bd11450aff3d20e43f18415ce58601e7
change-id: 20240727-stat-3fad5c0d2dfb

Best regards,
--
J. Neuschäfer <j.neuschaefer@gmx.net>

Comments

Waldemar Brodkorb July 30, 2024, 12:46 a.m. UTC | #1
Hi J.,
J. Neuschäfer wrote,

> While building software that sets _POSIX_C_SOURCE=200809L and uses
> stat.st_mtim for ARM, it was noticed that st_mtim was not defined.
> 
> This seems to be because common/bits/stat.h was picked up, which does
> not take __USE_XOPEN2K8 as a reason to enable st_mtim and related
> fields. This appears to be an oversight, and porting the check from
> common-generic/bits/stat.h to other architectures does indeed fix the
> build issue.
> 
> This patch is based on commit 50bd6d06e ("Fix memory corruption due to
> struct stat field").
> 
> Signed-off-by: J. Neuschäfer <j.neuschaefer@gmx.net>

LGTM, applied and pushed,
 best regards
  Waldemar
diff mbox series

Patch

diff --git a/libc/sysdeps/linux/alpha/bits/stat.h b/libc/sysdeps/linux/alpha/bits/stat.h
index 88bc6617d..f2dca250d 100644
--- a/libc/sysdeps/linux/alpha/bits/stat.h
+++ b/libc/sysdeps/linux/alpha/bits/stat.h
@@ -40,7 +40,7 @@ 

    Use neat tidy anonymous unions and structures when possible.  */

-#ifdef __USE_MISC
+#if defined(__USE_MISC) || defined(__USE_XOPEN2K8)
 # if __GNUC_PREREQ(3,3)
 #  define __ST_TIME(X)				\
 	__extension__ union {			\
diff --git a/libc/sysdeps/linux/common/bits/stat.h b/libc/sysdeps/linux/common/bits/stat.h
index 07c09f50a..fc76cc3e7 100644
--- a/libc/sysdeps/linux/common/bits/stat.h
+++ b/libc/sysdeps/linux/common/bits/stat.h
@@ -61,7 +61,7 @@  struct stat
 #else
     __blkcnt64_t st_blocks;		/* Number 512-byte blocks allocated. */
 #endif
-#ifdef __USE_MISC
+#if defined(__USE_MISC) || defined(__USE_XOPEN2K8)
     /* Nanosecond resolution timestamps are stored in a format
        equivalent to 'struct timespec'.  This is the type used
        whenever possible but the Unix namespace rules do not allow the
@@ -107,7 +107,7 @@  struct stat64
     __blksize_t st_blksize;		/* Optimal block size for I/O.  */

     __blkcnt64_t st_blocks;		/* Number 512-byte blocks allocated. */
-#ifdef __USE_MISC
+#if defined(__USE_MISC) || defined(__USE_XOPEN2K8)
     /* Nanosecond resolution timestamps are stored in a format
        equivalent to 'struct timespec'.  This is the type used
        whenever possible but the Unix namespace rules do not allow the
diff --git a/libc/sysdeps/linux/frv/bits/stat.h b/libc/sysdeps/linux/frv/bits/stat.h
index 381d207f2..18321c080 100644
--- a/libc/sysdeps/linux/frv/bits/stat.h
+++ b/libc/sysdeps/linux/frv/bits/stat.h
@@ -70,7 +70,7 @@  struct stat
     __blkcnt64_t st_blocks;		/* Number 512-byte blocks allocated. */
 #endif

-#ifdef __USE_MISC
+#if defined(__USE_MISC) || defined(__USE_XOPEN2K8)
     /* Nanosecond resolution timestamps are stored in a format
        equivalent to 'struct timespec'.  This is the type used
        whenever possible but the Unix namespace rules do not allow the
@@ -117,7 +117,7 @@  struct stat64
     __blksize_t st_blksize;		/* Optimal block size for I/O.  */

     __blkcnt64_t st_blocks;		/* Number 512-byte blocks allocated. */
-#ifdef __USE_MISC
+#if defined(__USE_MISC) || defined(__USE_XOPEN2K8)
     /* Nanosecond resolution timestamps are stored in a format
        equivalent to 'struct timespec'.  This is the type used
        whenever possible but the Unix namespace rules do not allow the
diff --git a/libc/sysdeps/linux/ia64/bits/stat.h b/libc/sysdeps/linux/ia64/bits/stat.h
index 6723166e7..2b70b8cf8 100644
--- a/libc/sysdeps/linux/ia64/bits/stat.h
+++ b/libc/sysdeps/linux/ia64/bits/stat.h
@@ -38,7 +38,7 @@  struct stat
     int pad0;
     __dev_t st_rdev;		/* Device number, if device.  */
     __off_t st_size;		/* Size of file, in bytes.  */
-#ifdef __USE_MISC
+#if defined(__USE_MISC) || defined(__USE_XOPEN2K8)
     /* Nanosecond resolution timestamps are stored in a format
        equivalent to 'struct timespec'.  This is the type used
        whenever possible but the Unix namespace rules do not allow the
@@ -77,7 +77,7 @@  struct stat64
     int pad0;
     __dev_t st_rdev;		/* Device number, if device.  */
     __off_t st_size;		/* Size of file, in bytes.  */
-#ifdef __USE_MISC
+#if defined(__USE_MISC) || defined(__USE_XOPEN2K8)
     /* Nanosecond resolution timestamps are stored in a format
        equivalent to 'struct timespec'.  This is the type used
        whenever possible but the Unix namespace rules do not allow the
diff --git a/libc/sysdeps/linux/m68k/bits/stat.h b/libc/sysdeps/linux/m68k/bits/stat.h
index 7b9c3d144..70da1b384 100644
--- a/libc/sysdeps/linux/m68k/bits/stat.h
+++ b/libc/sysdeps/linux/m68k/bits/stat.h
@@ -60,7 +60,7 @@  struct stat
 #else
     __blkcnt64_t st_blocks;		/* Number 512-byte blocks allocated. */
 #endif
-#ifdef __USE_MISC
+#if defined(__USE_MISC) || defined(__USE_XOPEN2K8)
     /* Nanosecond resolution timestamps are stored in a format
        equivalent to 'struct timespec'.  This is the type used
        whenever possible but the Unix namespace rules do not allow the
@@ -106,7 +106,7 @@  struct stat64
     __blksize_t st_blksize;		/* Optimal block size for I/O.  */

     __blkcnt64_t st_blocks;		/* Number 512-byte blocks allocated. */
-#ifdef __USE_MISC
+#if defined(__USE_MISC) || defined(__USE_XOPEN2K8)
     /* Nanosecond resolution timestamps are stored in a format
        equivalent to 'struct timespec'.  This is the type used
        whenever possible but the Unix namespace rules do not allow the
diff --git a/libc/sysdeps/linux/mips/bits/stat.h b/libc/sysdeps/linux/mips/bits/stat.h
index 539fa33d2..bad2a0244 100644
--- a/libc/sysdeps/linux/mips/bits/stat.h
+++ b/libc/sysdeps/linux/mips/bits/stat.h
@@ -60,7 +60,7 @@  struct stat
     long int st_pad2[2];
     __off64_t st_size;		/* Size of file, in bytes.  */
 #endif
-#ifdef __USE_MISC
+#if defined(__USE_MISC) || defined(__USE_XOPEN2K8)
     /* Nanosecond resolution timestamps are stored in a format
        equivalent to 'struct timespec'.  This is the type used
        whenever possible but the Unix namespace rules do not allow the
@@ -103,7 +103,7 @@  struct stat {
     unsigned int st_rdev;	/* Device number, if device.  */
     int st_pad2[3];
     __off_t st_size;		/* Size of file, in bytes.  */
-#ifdef __USE_MISC
+#if defined(__USE_MISC) || defined(__USE_XOPEN2K8)
     /* Nanosecond resolution timestamps are stored in a format
        equivalent to 'struct timespec'.  This is the type used
        whenever possible but the Unix namespace rules do not allow the
diff --git a/libc/sysdeps/linux/nds32/bits/stat.h b/libc/sysdeps/linux/nds32/bits/stat.h
index c4e09e0f2..5272751f4 100644
--- a/libc/sysdeps/linux/nds32/bits/stat.h
+++ b/libc/sysdeps/linux/nds32/bits/stat.h
@@ -64,7 +64,7 @@  struct stat
 #else
     __blkcnt64_t st_blocks;		/* Number 512-byte blocks allocated. */
 #endif
-#ifdef __USE_MISC
+#if defined(__USE_MISC) || defined(__USE_XOPEN2K8)
     /* Nanosecond resolution timestamps are stored in a format
        equivalent to 'struct timespec'.  This is the type used
        whenever possible but the Unix namespace rules do not allow the
@@ -110,7 +110,7 @@  struct stat64
     __blksize_t st_blksize;		/* Optimal block size for I/O.  */

     __blkcnt64_t st_blocks;		/* Number 512-byte blocks allocated. */
-#ifdef __USE_MISC
+#if defined(__USE_MISC) || defined(__USE_XOPEN2K8)
     /* Nanosecond resolution timestamps are stored in a format
        equivalent to 'struct timespec'.  This is the type used
        whenever possible but the Unix namespace rules do not allow the
diff --git a/libc/sysdeps/linux/powerpc/bits/stat.h b/libc/sysdeps/linux/powerpc/bits/stat.h
index 7494586b5..ce2ebf896 100644
--- a/libc/sysdeps/linux/powerpc/bits/stat.h
+++ b/libc/sysdeps/linux/powerpc/bits/stat.h
@@ -59,7 +59,7 @@  struct stat
 # else
     __blkcnt64_t st_blocks;		/* Number 512-byte blocks allocated. */
 # endif
-#ifdef __USE_MISC
+#if defined(__USE_MISC) || defined(__USE_XOPEN2K8)
     /* Nanosecond resolution timestamps are stored in a format
        equivalent to 'struct timespec'.  This is the type used
        whenever possible but the Unix namespace rules do not allow the
@@ -99,7 +99,7 @@  struct stat64
     __off64_t st_size;			/* Size of file, in bytes.  */
     __blksize_t st_blksize;		/* Optimal block size for I/O.  */
     __blkcnt64_t st_blocks;		/* Number 512-byte blocks allocated. */
-#ifdef __USE_MISC
+#if defined(__USE_MISC) || defined(__USE_XOPEN2K8)
     /* Nanosecond resolution timestamps are stored in a format
        equivalent to 'struct timespec'.  This is the type used
        whenever possible but the Unix namespace rules do not allow the