From d8a0c27bdbda01f851a34393bb502dbd4c18fa84 Mon Sep 17 00:00:00 2001 From: dybucc <149513579+dybucc@users.noreply.github.com> Date: Tue, 7 Jul 2026 17:04:31 +0200 Subject: [PATCH 1/2] nuttx: fix wchar_t definition under arm fix signedness of wchar_t under arm and aarch64. this was not correctly handled as this type will likely be defined in terms of predefined compiler macros [^1]. these macros expand to different types on our currently supported nuttx targets. they are only signed integers under riscv [^2]. [^1]: https://github.com/search?q=repo%3Aapache%2Fnuttx+%2F%5Cb_wchar_t%5Cb%2F&type=code [^2]: https://c.godbolt.org/z/czMY79vsh --- src/unix/nuttx/mod.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/unix/nuttx/mod.rs b/src/unix/nuttx/mod.rs index 0f65225fe48f3..4a75ef291173e 100644 --- a/src/unix/nuttx/mod.rs +++ b/src/unix/nuttx/mod.rs @@ -30,7 +30,14 @@ pub type suseconds_t = i32; pub type tcflag_t = u32; pub type clockid_t = i32; pub type time_t = i64; -pub type wchar_t = i32; + +cfg_if! { + if #[cfg(any(target_arch = "riscv32", target_arch = "riscv64"))] { + pub type wchar_t = c_int; + } else if #[cfg(any(target_arch = "arm", target_arch = "aarch64"))] { + pub type wchar_t = c_uint; + } +} s! { pub struct stat { From 0e9c84b43d96debb81f536e370651faf2f699939 Mon Sep 17 00:00:00 2001 From: dybucc <149513579+dybucc@users.noreply.github.com> Date: Fri, 3 Jul 2026 08:23:28 +0200 Subject: [PATCH 2/2] nuttx: mirror type definitions --- src/unix/mod.rs | 1 + src/unix/nuttx/mod.rs | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/unix/mod.rs b/src/unix/mod.rs index 59fd7254441f4..66ab0d5ca988a 100644 --- a/src/unix/mod.rs +++ b/src/unix/mod.rs @@ -14,6 +14,7 @@ pub type intptr_t = isize; pub type uintptr_t = usize; pub type ssize_t = isize; +#[cfg(not(target_os = "nuttx"))] pub type pid_t = i32; pub type in_addr_t = u32; pub type in_port_t = u16; diff --git a/src/unix/nuttx/mod.rs b/src/unix/nuttx/mod.rs index 4a75ef291173e..62b3cba42c7ef 100644 --- a/src/unix/nuttx/mod.rs +++ b/src/unix/nuttx/mod.rs @@ -6,6 +6,7 @@ use crate::{ DIR, }; +pub type pid_t = c_int; pub type nlink_t = u16; pub type ino_t = u16; pub type blkcnt_t = u64; @@ -24,11 +25,11 @@ pub type pthread_rwlockattr_t = i32; pub type pthread_t = i32; pub type rlim_t = i64; pub type sa_family_t = u16; -pub type socklen_t = u32; +pub type socklen_t = c_uint; pub type speed_t = usize; pub type suseconds_t = i32; pub type tcflag_t = u32; -pub type clockid_t = i32; +pub type clockid_t = c_int; pub type time_t = i64; cfg_if! {