nuttx: clean up module#5245
Conversation
| pub type key_t = u32; | ||
| pub type nlink_t = u16; | ||
| pub type ino_t = u16; | ||
| pub type ino_t = u32; |
There was a problem hiding this comment.
"nuttx: fix ino_t definition" this happened just last week apache/nuttx@50377d0, I have no clue what the release/support schedule looks like but we should probably hold off a bit. Or at least hear from the maintainers.
There was a problem hiding this comment.
just pinged the maintainers.
| pub type locale_t = *mut i8; | ||
| pub type mode_t = u32; | ||
| pub type nfds_t = u32; | ||
| pub type off_t = i64; |
There was a problem hiding this comment.
"nuttx: provide correct lfs support": It looks like we were already supporting CONFIG_FS_LARGEFILE - why the change?
There was a problem hiding this comment.
we were not correctly supporting that configuration. without it enabled, all targets get 32-bit file offset types. with it enabled, they all get 64-bit file offset types.
it would likely come off as a surprise if somebody didn't have CONFIG_FS_LARGEFILE enabled but found that our types are 64-bits either way.
There was a problem hiding this comment.
I mean we were only supporting CONFIG_FS_LARGEFILE, right? That's completely fine, every platform has dozens of ways you could configure it that make something break for Rust.
There was a problem hiding this comment.
I mean we were only supporting
CONFIG_FS_LARGEFILE, right? That's completely fine, every platform has dozens of ways you could configure it that make something break for Rust.
Yes, it is unlikely to support arbitrary configurations of the NuttX ABI on the Rust side, so we must restrict the configuration options that affect fundamental data type definitions and only support the most commonly used combinations.
| } | ||
|
|
||
| cfg_if! { | ||
| if #[cfg(nuttx_small_mm)] { |
There was a problem hiding this comment.
"nuttx: expose cfg for small memory model" similarly, I don't think there is any need to add this - it's extra configuration complexity in libc and has no known users. This would probably have to be a separate target in rustc, anyway.
This comment has been minimized.
This comment has been minimized.
| // types are themselves 64-bits wide. We choose to expose ony the latter. | ||
| cfg_if! { | ||
| if #[cfg(gnu_file_offset_bits64)] { | ||
| pub type fsblkcnt_t = u64; |
There was a problem hiding this comment.
There are too many configuration options inside Nuttx; it would be better to only support specific projects. For example, FS_LARGEFS must be enabled; otherwise, compilation becomes overly difficult.
There was a problem hiding this comment.
done. thanks for getting back.
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
|
This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
| pub type uintptr_t = usize; | ||
| pub type ssize_t = isize; | ||
|
|
||
| #[cfg(not(target_os = "nuttx"))] |
There was a problem hiding this comment.
There was a problem hiding this comment.
not really, the latest commit replicates the nuttx definition 1 more closely. if anything, the link you provide matches the current definition (a c int and not necessarily a fixed-width integer.)
Description
This PR consists of an overall clean up of the NuttX module. It adds missing types, fixes one type definition, replaces equivalent with mirrored definitions (fixed-width types with "variable" C types,) and provides correct support for some build-time configuration options.
The build-time configuration options correspond with
CONFIG_SMALL_MEMORYandCONFIG_FS_LARGEFILE. The former enables types with pointer bit width (size_tandssize_t) to be narrower than required in the target. It is enabled by default in 16-bit machine word targets but can also be enabled in other targets. The latter option enables support for LFS bindings. The default under all targets is to expose 32-bit types and no suffixed 64-bit types. It is only if the above option is set that (1) suffixed types are exposed and (2) unsuffixed types are made 64-bits wide. I have decided against exposing the suffixed types because it's redundant.Sources
Checklist
libc-test/semverhave been updated*LASTor*MAXare included (see #3131)cd libc-test && cargo test --target mytarget); especially relevant for platforms that may not be checked in CI@rustbot label +stable-nominated