diff options
author | bors <bors@rust-lang.org> | 2022-03-12 18:33:30 +0000 |
---|---|---|
committer | bors <bors@rust-lang.org> | 2022-03-12 18:33:30 +0000 |
commit | 331859198faafb3544374bf79627b3a7189321b6 (patch) | |
tree | 6b0a07053d29e5067f95f37b16e8dd4414eba8d3 | |
parent | bc9ea0bb6af452fd94b07de833aa6ee3ef839e5b (diff) | |
parent | ab62380241b431beb929a2f986fe08375e87a091 (diff) | |
download | rust-libc-331859198faafb3544374bf79627b3a7189321b6.tar.gz |
Auto merge of #2708 - MabezDev:esp-idf-stat-types, r=Amanieu
Correct the size of certain types on espidf platform
This was initially discovered in https://github.com/esp-rs/rust/issues/92, the reason stat fails on the esp-idf platform is because the `stat` struct has a different layout on the Rust side compared to the C side.
-rw-r--r-- | src/unix/mod.rs | 11 | ||||
-rw-r--r-- | src/unix/newlib/mod.rs | 16 |
2 files changed, 22 insertions, 5 deletions
diff --git a/src/unix/mod.rs b/src/unix/mod.rs index 5ff2294e79..b6d08f7dc4 100644 --- a/src/unix/mod.rs +++ b/src/unix/mod.rs @@ -23,8 +23,15 @@ pub type uintptr_t = usize; pub type ssize_t = isize; pub type pid_t = i32; -pub type uid_t = u32; -pub type gid_t = u32; +cfg_if! { + if #[cfg(target_os = "espidf")] { + pub type uid_t = ::c_ushort; + pub type gid_t = ::c_ushort; + } else { + pub type uid_t = u32; + pub type gid_t = u32; + } +} pub type in_addr_t = u32; pub type in_port_t = u16; pub type sighandler_t = ::size_t; diff --git a/src/unix/newlib/mod.rs b/src/unix/newlib/mod.rs index f1d738cb05..8f85afb41c 100644 --- a/src/unix/newlib/mod.rs +++ b/src/unix/newlib/mod.rs @@ -1,17 +1,27 @@ pub type blkcnt_t = i32; pub type blksize_t = i32; pub type clockid_t = ::c_ulong; -pub type dev_t = u32; + +cfg_if! { + if #[cfg(target_os = "espidf")] { + pub type dev_t = ::c_short; + pub type ino_t = ::c_ushort; + pub type off_t = ::c_long; + } else { + pub type dev_t = u32; + pub type ino_t = u32; + pub type off_t = i64; + } +} + pub type fsblkcnt_t = u64; pub type fsfilcnt_t = u32; pub type id_t = u32; -pub type ino_t = u32; pub type key_t = ::c_int; pub type loff_t = ::c_longlong; pub type mode_t = ::c_uint; pub type nfds_t = u32; pub type nlink_t = ::c_ushort; -pub type off_t = i64; pub type pthread_t = ::c_ulong; pub type pthread_key_t = ::c_uint; pub type rlim_t = u32; |