From 3232f542f635cfabbfe0ee9d6f1ac638d801ae5d 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 6abed2e3fb19ef683287f4ae1cbddba634ce0d16 Mon Sep 17 00:00:00 2001 From: dybucc <149513579+dybucc@users.noreply.github.com> Date: Sun, 7 Jun 2026 13:08:10 +0200 Subject: [PATCH 2/2] refactor: change definition of `off_t` in newlib The newlib definition is either one of a signed 64 bit integer or a C `long`. The former is only present when `_off_t` (note the starting underscore) is defined under `machine/_types.h`. `off_t` is defined as a `c_long` in all other cases. There's some special casing for Cygwin, but that is unimportant in the `libc` crate because the Cygwin module is not a child module of the newlib module. Except in `vita`, espressif's platforms, devkitA64 for `aarch64`, and RTEMS, this type is always defined under `machine/_types.h`. Otherwise, it's defined as a `c_long` under `sys/_types.h`. More details can be found in the accompanying PR. --- src/unix/newlib/mod.rs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/unix/newlib/mod.rs b/src/unix/newlib/mod.rs index 62501a0d9fdee..8772669d6a17f 100644 --- a/src/unix/newlib/mod.rs +++ b/src/unix/newlib/mod.rs @@ -6,14 +6,15 @@ 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", + target_os = "rtems", + target_arch = "aarch64" + ))] { 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;