Skip to content

Commit 18f314e

Browse files
committed
Auto merge of #94609 - esp-rs:esp-idf-stat-type-fixes, r=Mark-Simulacrum
espidf: fix stat Marking as draft as currently dependant on [a libc fix](rust-lang/libc#2708) and release.
2 parents 5cdab3a + 3569d43 commit 18f314e

File tree

3 files changed

+30
-15
lines changed

3 files changed

+30
-15
lines changed

library/std/src/os/unix/process.rs

+12-12
Original file line numberDiff line numberDiff line change
@@ -24,26 +24,26 @@ pub trait CommandExt: Sealed {
2424
#[stable(feature = "rust1", since = "1.0.0")]
2525
fn uid(
2626
&mut self,
27-
#[cfg(not(target_os = "vxworks"))] id: u32,
28-
#[cfg(target_os = "vxworks")] id: u16,
27+
#[cfg(not(any(target_os = "vxworks", target_os = "espidf")))] id: u32,
28+
#[cfg(any(target_os = "vxworks", target_os = "espidf"))] id: u16,
2929
) -> &mut process::Command;
3030

3131
/// Similar to `uid`, but sets the group ID of the child process. This has
3232
/// the same semantics as the `uid` field.
3333
#[stable(feature = "rust1", since = "1.0.0")]
3434
fn gid(
3535
&mut self,
36-
#[cfg(not(target_os = "vxworks"))] id: u32,
37-
#[cfg(target_os = "vxworks")] id: u16,
36+
#[cfg(not(any(target_os = "vxworks", target_os = "espidf")))] id: u32,
37+
#[cfg(any(target_os = "vxworks", target_os = "espidf"))] id: u16,
3838
) -> &mut process::Command;
3939

4040
/// Sets the supplementary group IDs for the calling process. Translates to
4141
/// a `setgroups` call in the child process.
4242
#[unstable(feature = "setgroups", issue = "90747")]
4343
fn groups(
4444
&mut self,
45-
#[cfg(not(target_os = "vxworks"))] groups: &[u32],
46-
#[cfg(target_os = "vxworks")] groups: &[u16],
45+
#[cfg(not(any(target_os = "vxworks", target_os = "espidf")))] groups: &[u32],
46+
#[cfg(any(target_os = "vxworks", target_os = "espidf"))] groups: &[u16],
4747
) -> &mut process::Command;
4848

4949
/// Schedules a closure to be run just before the `exec` function is
@@ -160,26 +160,26 @@ pub trait CommandExt: Sealed {
160160
impl CommandExt for process::Command {
161161
fn uid(
162162
&mut self,
163-
#[cfg(not(target_os = "vxworks"))] id: u32,
164-
#[cfg(target_os = "vxworks")] id: u16,
163+
#[cfg(not(any(target_os = "vxworks", target_os = "espidf")))] id: u32,
164+
#[cfg(any(target_os = "vxworks", target_os = "espidf"))] id: u16,
165165
) -> &mut process::Command {
166166
self.as_inner_mut().uid(id);
167167
self
168168
}
169169

170170
fn gid(
171171
&mut self,
172-
#[cfg(not(target_os = "vxworks"))] id: u32,
173-
#[cfg(target_os = "vxworks")] id: u16,
172+
#[cfg(not(any(target_os = "vxworks", target_os = "espidf")))] id: u32,
173+
#[cfg(any(target_os = "vxworks", target_os = "espidf"))] id: u16,
174174
) -> &mut process::Command {
175175
self.as_inner_mut().gid(id);
176176
self
177177
}
178178

179179
fn groups(
180180
&mut self,
181-
#[cfg(not(target_os = "vxworks"))] groups: &[u32],
182-
#[cfg(target_os = "vxworks")] groups: &[u16],
181+
#[cfg(not(any(target_os = "vxworks", target_os = "espidf")))] groups: &[u32],
182+
#[cfg(any(target_os = "vxworks", target_os = "espidf"))] groups: &[u16],
183183
) -> &mut process::Command {
184184
self.as_inner_mut().groups(groups);
185185
self

library/std/src/sys/unix/fd.rs

+17-2
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,21 @@ use crate::sys_common::{AsInner, FromInner, IntoInner};
1111

1212
use libc::{c_int, c_void};
1313

14+
#[cfg(any(
15+
target_os = "android",
16+
target_os = "linux",
17+
target_os = "emscripten",
18+
target_os = "l4re"
19+
))]
20+
use libc::off64_t;
21+
#[cfg(not(any(
22+
target_os = "linux",
23+
target_os = "emscripten",
24+
target_os = "l4re",
25+
target_os = "android"
26+
)))]
27+
use libc::off_t as off64_t;
28+
1429
#[derive(Debug)]
1530
pub struct FileDesc(OwnedFd);
1631

@@ -109,7 +124,7 @@ impl FileDesc {
109124
self.as_raw_fd(),
110125
buf.as_mut_ptr() as *mut c_void,
111126
cmp::min(buf.len(), READ_LIMIT),
112-
offset as i64,
127+
offset as off64_t,
113128
))
114129
.map(|n| n as usize)
115130
}
@@ -176,7 +191,7 @@ impl FileDesc {
176191
self.as_raw_fd(),
177192
buf.as_ptr() as *const c_void,
178193
cmp::min(buf.len(), READ_LIMIT),
179-
offset as i64,
194+
offset as off64_t,
180195
))
181196
.map(|n| n as usize)
182197
}

library/std/src/sys/unix/fs.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -966,7 +966,7 @@ impl File {
966966
SeekFrom::End(off) => (libc::SEEK_END, off),
967967
SeekFrom::Current(off) => (libc::SEEK_CUR, off),
968968
};
969-
let n = cvt(unsafe { lseek64(self.as_raw_fd(), pos, whence) })?;
969+
let n = cvt(unsafe { lseek64(self.as_raw_fd(), pos as off64_t, whence) })?;
970970
Ok(n as u64)
971971
}
972972

0 commit comments

Comments
 (0)