Skip to content

Commit 3318591

Browse files
committed
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 esp-rs/rust#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.
2 parents bc9ea0b + ab62380 commit 3318591

File tree

2 files changed

+22
-5
lines changed

2 files changed

+22
-5
lines changed

src/unix/mod.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,15 @@ pub type uintptr_t = usize;
2323
pub type ssize_t = isize;
2424

2525
pub type pid_t = i32;
26-
pub type uid_t = u32;
27-
pub type gid_t = u32;
26+
cfg_if! {
27+
if #[cfg(target_os = "espidf")] {
28+
pub type uid_t = ::c_ushort;
29+
pub type gid_t = ::c_ushort;
30+
} else {
31+
pub type uid_t = u32;
32+
pub type gid_t = u32;
33+
}
34+
}
2835
pub type in_addr_t = u32;
2936
pub type in_port_t = u16;
3037
pub type sighandler_t = ::size_t;

src/unix/newlib/mod.rs

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,27 @@
11
pub type blkcnt_t = i32;
22
pub type blksize_t = i32;
33
pub type clockid_t = ::c_ulong;
4-
pub type dev_t = u32;
4+
5+
cfg_if! {
6+
if #[cfg(target_os = "espidf")] {
7+
pub type dev_t = ::c_short;
8+
pub type ino_t = ::c_ushort;
9+
pub type off_t = ::c_long;
10+
} else {
11+
pub type dev_t = u32;
12+
pub type ino_t = u32;
13+
pub type off_t = i64;
14+
}
15+
}
16+
517
pub type fsblkcnt_t = u64;
618
pub type fsfilcnt_t = u32;
719
pub type id_t = u32;
8-
pub type ino_t = u32;
920
pub type key_t = ::c_int;
1021
pub type loff_t = ::c_longlong;
1122
pub type mode_t = ::c_uint;
1223
pub type nfds_t = u32;
1324
pub type nlink_t = ::c_ushort;
14-
pub type off_t = i64;
1525
pub type pthread_t = ::c_ulong;
1626
pub type pthread_key_t = ::c_uint;
1727
pub type rlim_t = u32;

0 commit comments

Comments
 (0)