From a861a0b0cb16dd0cfcb642c3d294fba754cf6df2 Mon Sep 17 00:00:00 2001 From: Xing Xue Date: Tue, 29 Jul 2025 12:08:16 -0400 Subject: [PATCH] Fix the types of 'struct stat'/'stat stat64' fields 'st_*tim'. --- libc-test/build.rs | 10 ++++++++++ src/unix/aix/mod.rs | 6 +++--- src/unix/aix/powerpc64.rs | 6 +++--- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/libc-test/build.rs b/libc-test/build.rs index 8bbd708e1c9fc..7690716dab042 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -5659,6 +5659,16 @@ fn test_aix(target: &str) { // header does not define a separate standalone union type for it. ("ld_info", "_file") => true, + // On AIX, when _ALL_SOURCE is defined, the types of the following fields + // differ from those used when _XOPEN_SOURCE is defined. The former uses + // 'struct st_timespec', while the latter uses 'struct timespec'. + ("stat", "st_atim") => true, + ("stat", "st_mtim") => true, + ("stat", "st_ctim") => true, + ("stat64", "st_atim") => true, + ("stat64", "st_mtim") => true, + ("stat64", "st_ctim") => true, + _ => false, } }); diff --git a/src/unix/aix/mod.rs b/src/unix/aix/mod.rs index 21c5d4fe56554..b42d0b6d25102 100644 --- a/src/unix/aix/mod.rs +++ b/src/unix/aix/mod.rs @@ -464,9 +464,9 @@ s! { pub st_gid: crate::gid_t, pub st_rdev: dev_t, pub st_ssize: c_int, - pub st_atim: st_timespec, - pub st_mtim: st_timespec, - pub st_ctim: st_timespec, + pub st_atim: crate::timespec, + pub st_mtim: crate::timespec, + pub st_ctim: crate::timespec, pub st_blksize: blksize_t, pub st_blocks: blkcnt_t, pub st_vfstype: c_int, diff --git a/src/unix/aix/powerpc64.rs b/src/unix/aix/powerpc64.rs index 1a8ebb1cc7f6b..856fd0d127d70 100644 --- a/src/unix/aix/powerpc64.rs +++ b/src/unix/aix/powerpc64.rs @@ -69,9 +69,9 @@ s! { pub st_gid: crate::gid_t, pub st_rdev: crate::dev_t, pub st_ssize: c_int, - pub st_atim: crate::st_timespec, - pub st_mtim: crate::st_timespec, - pub st_ctim: crate::st_timespec, + pub st_atim: crate::timespec, + pub st_mtim: crate::timespec, + pub st_ctim: crate::timespec, pub st_blksize: crate::blksize_t, pub st_blocks: crate::blkcnt_t, pub st_vfstype: c_int,