From 757a302e297741225b2bc2ba407193f8300c8071 Mon Sep 17 00:00:00 2001 From: R4 Cheng Date: Wed, 15 Apr 2026 21:42:11 -0700 Subject: [PATCH] fix(newlib): update stat struct to match official headers - Source: https://sourceware.org/git/?p=newlib-cygwin.git;a=blob;f=newlib/libc/include/sys/stat.h;h=6525272dd40123d6ea4e7355a8e6f3a3f3d0dbb8;hb=HEAD - Note: If any platforms that meet the above criteria are added, they would need to create their own definition and use that (maybe a cfg_if!) - by @ian-h-chamberlain ps. thank @zetanumbers for checking targets --- src/unix/newlib/generic.rs | 14 +++++--------- src/unix/newlib/horizon/mod.rs | 18 ------------------ src/unix/newlib/vita/mod.rs | 18 ------------------ 3 files changed, 5 insertions(+), 45 deletions(-) diff --git a/src/unix/newlib/generic.rs b/src/unix/newlib/generic.rs index 303de806b653f..c020e8e7702d4 100644 --- a/src/unix/newlib/generic.rs +++ b/src/unix/newlib/generic.rs @@ -1,5 +1,5 @@ //! Common types used by most newlib platforms - +use crate::off_t; #[allow(unused_imports)] // needed for platforms that don't use the prelude here use crate::prelude::*; @@ -9,7 +9,6 @@ s! { __val: u32, } - #[cfg(all(not(target_os = "vita"), not(target_os = "horizon")))] pub struct stat { pub st_dev: crate::dev_t, pub st_ino: crate::ino_t, @@ -18,13 +17,10 @@ s! { pub st_uid: crate::uid_t, pub st_gid: crate::gid_t, pub st_rdev: crate::dev_t, - pub st_size: crate::off_t, - pub st_atime: crate::time_t, - pub st_spare1: c_long, - pub st_mtime: crate::time_t, - pub st_spare2: c_long, - pub st_ctime: crate::time_t, - pub st_spare3: c_long, + pub st_size: off_t, + 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_spare4: [c_long; 2usize], diff --git a/src/unix/newlib/horizon/mod.rs b/src/unix/newlib/horizon/mod.rs index e94a0bb1c13d8..1f27bbee8d1bc 100644 --- a/src/unix/newlib/horizon/mod.rs +++ b/src/unix/newlib/horizon/mod.rs @@ -1,6 +1,5 @@ //! ARMv6K Nintendo 3DS C Newlib definitions -use crate::off_t; use crate::prelude::*; pub type wchar_t = c_uint; @@ -68,23 +67,6 @@ s! { pub struct sched_param { pub sched_priority: c_int, } - - pub struct stat { - pub st_dev: crate::dev_t, - pub st_ino: crate::ino_t, - pub st_mode: crate::mode_t, - pub st_nlink: crate::nlink_t, - pub st_uid: crate::uid_t, - pub st_gid: crate::gid_t, - pub st_rdev: crate::dev_t, - pub st_size: off_t, - 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_spare4: [c_long; 2usize], - } } pub const SIGEV_NONE: c_int = 1; diff --git a/src/unix/newlib/vita/mod.rs b/src/unix/newlib/vita/mod.rs index 95abf9076a05f..f67982af7e27c 100644 --- a/src/unix/newlib/vita/mod.rs +++ b/src/unix/newlib/vita/mod.rs @@ -1,4 +1,3 @@ -use crate::off_t; use crate::prelude::*; pub type clock_t = c_long; @@ -61,23 +60,6 @@ s! { pub sched_priority: c_int, } - pub struct stat { - pub st_dev: crate::dev_t, - pub st_ino: crate::ino_t, - pub st_mode: crate::mode_t, - pub st_nlink: crate::nlink_t, - pub st_uid: crate::uid_t, - pub st_gid: crate::gid_t, - pub st_rdev: crate::dev_t, - pub st_size: off_t, - pub st_atime: crate::time_t, - pub st_mtime: crate::time_t, - pub st_ctime: crate::time_t, - pub st_blksize: crate::blksize_t, - pub st_blocks: crate::blkcnt_t, - pub st_spare4: [c_long; 2usize], - } - #[repr(align(8))] pub struct dirent { __offset: [u8; 88],