From 2c31b68d4e69dcad00bbde501d1848e211211bc4 Mon Sep 17 00:00:00 2001 From: dybucc <149513579+dybucc@users.noreply.github.com> Date: Mon, 1 Jun 2026 18:28:17 +0200 Subject: [PATCH 1/2] refactor: change definition of `time_t` in newlib At present, the newlib module uses a faulty definition of the `time_t` type that falls back to a 32-bti signed integer if the target does not match either one of the `horizon` operating system or the espressif ESP-IDF with the 32-bit compatibility shim for `time_t` values. In all current upstream repos forking newlib, the definition follows a default where `time_t` is defined as a 64-bit type. It only falls back to a 32-bit type if a non-default build-time option is issues to the `configure` script, or otherwise if the host machine is detected to support `c_long`s larger than 32 bits. --- src/unix/newlib/mod.rs | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/unix/newlib/mod.rs b/src/unix/newlib/mod.rs index a14cc1afe1bee..62501a0d9fdee 100644 --- a/src/unix/newlib/mod.rs +++ b/src/unix/newlib/mod.rs @@ -54,13 +54,10 @@ cfg_if! { pub type useconds_t = u32; cfg_if! { - if #[cfg(any( - target_os = "horizon", - all(target_os = "espidf", not(espidf_time32)) - ))] { - pub type time_t = c_longlong; - } else { + if #[cfg(all(target_os = "espidf", espidf_time32))] { pub type time_t = i32; + } else { + pub type time_t = i64; } } From 915701c115752d111ec64caa1bbb4a4119f6a437 Mon Sep 17 00:00:00 2001 From: dybucc <149513579+dybucc@users.noreply.github.com> Date: Wed, 3 Jun 2026 18:41:42 +0200 Subject: [PATCH 2/2] refactor: change definition of `off_t` in newlib The newlib definition is shown to be always a `c_long` when not running under any one of Cygwin and a machine not following the LP64 memory model abstraction. This seems to hold across all targets currently supported in the `libc` crate. The exceptions that were being made for `espidf` and `vita` did not seem correct. The definitions in their corresponding forks fit exactly those of the upstream newlib repo maintained by the Cygwin developers. More details can be found in the accompanying PR. --- src/unix/newlib/mod.rs | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/unix/newlib/mod.rs b/src/unix/newlib/mod.rs index 62501a0d9fdee..d93352480a8e0 100644 --- a/src/unix/newlib/mod.rs +++ b/src/unix/newlib/mod.rs @@ -6,21 +6,17 @@ pub type blksize_t = i32; pub type clockid_t = c_ulong; cfg_if! { - if #[cfg(any(target_os = "espidf"))] { + if #[cfg(any(target_os = "espidf", target_os = "vita"))] { pub type dev_t = c_short; pub type ino_t = c_ushort; - pub type off_t = c_long; - } else if #[cfg(any(target_os = "vita"))] { - pub type dev_t = c_short; - pub type ino_t = c_ushort; - pub type off_t = c_int; } else { pub type dev_t = u32; pub type ino_t = u32; - pub type off_t = i64; } } +pub type off_t = c_long; + pub type fsblkcnt_t = u64; pub type fsfilcnt_t = u32; pub type id_t = u32;