Skip to content

Commit 39b405b

Browse files
authored
Unrolled build for rust-lang#116723
Rollup merge of rust-lang#116723 - ivmarkov:master, r=dtolnay Fix broken build on ESP-IDF caused by rust-lang#115108 `@ijackson` rust-lang#115108 broke the build for ESP-IDF. I'm still checking whether this PR fixes everything - once I'm ready will remove the "Draft" status. `@dtolnay` FYI
2 parents 8de6f99 + b3c95c5 commit 39b405b

File tree

3 files changed

+24
-4
lines changed

3 files changed

+24
-4
lines changed

library/std/src/sys/unix/process/mod.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ pub use crate::sys_common::process::CommandEnvs;
66
#[cfg_attr(any(target_os = "espidf", target_os = "horizon"), allow(unused))]
77
mod process_common;
88

9+
#[cfg(any(target_os = "espidf", target_os = "horizon", target_os = "vita"))]
10+
mod process_unsupported;
11+
912
cfg_if::cfg_if! {
1013
if #[cfg(target_os = "fuchsia")] {
1114
#[path = "process_fuchsia.rs"]
@@ -15,8 +18,9 @@ cfg_if::cfg_if! {
1518
#[path = "process_vxworks.rs"]
1619
mod process_inner;
1720
} else if #[cfg(any(target_os = "espidf", target_os = "horizon", target_os = "vita"))] {
18-
#[path = "process_unsupported.rs"]
19-
mod process_inner;
21+
mod process_inner {
22+
pub use super::process_unsupported::*;
23+
}
2024
} else {
2125
#[path = "process_unix.rs"]
2226
mod process_inner;

library/std/src/sys/unix/process/process_unsupported.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,12 @@ pub struct ExitStatusError(NonZero_c_int);
6363

6464
impl Into<ExitStatus> for ExitStatusError {
6565
fn into(self) -> ExitStatus {
66-
ExitStatus(self.0.into())
66+
ExitStatus::from(c_int::from(self.0))
6767
}
6868
}
6969

7070
impl ExitStatusError {
7171
pub fn code(self) -> Option<NonZeroI32> {
72-
ExitStatus(self.0.into()).code().map(|st| st.try_into().unwrap())
72+
ExitStatus::from(c_int::from(self.0)).code().map(|st| st.try_into().unwrap())
7373
}
7474
}

library/std/src/sys/unix/process/process_unsupported/wait_status.rs

+16
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
//! Emulated wait status for non-Unix #[cfg(unix) platforms
22
//!
33
//! Separate module to facilitate testing against a real Unix implementation.
4+
use core::ffi::NonZero_c_int;
45

56
use crate::ffi::c_int;
67
use crate::fmt;
78

9+
use super::ExitStatusError;
10+
811
/// Emulated wait status for use by `process_unsupported.rs`
912
///
1013
/// Uses the "traditional unix" encoding. For use on platfors which are `#[cfg(unix)]`
@@ -40,6 +43,19 @@ impl ExitStatus {
4043
if (w & 0x7f) == 0 { Some((w & 0xff00) >> 8) } else { None }
4144
}
4245

46+
#[allow(unused)]
47+
pub fn exit_ok(&self) -> Result<(), ExitStatusError> {
48+
// This assumes that WIFEXITED(status) && WEXITSTATUS==0 corresponds to status==0. This is
49+
// true on all actual versions of Unix, is widely assumed, and is specified in SuS
50+
// https://pubs.opengroup.org/onlinepubs/9699919799/functions/wait.html. If it is not
51+
// true for a platform pretending to be Unix, the tests (our doctests, and also
52+
// process_unix/tests.rs) will spot it. `ExitStatusError::code` assumes this too.
53+
match NonZero_c_int::try_from(self.wait_status) {
54+
/* was nonzero */ Ok(failure) => Err(ExitStatusError(failure)),
55+
/* was zero, couldn't convert */ Err(_) => Ok(()),
56+
}
57+
}
58+
4359
pub fn signal(&self) -> Option<i32> {
4460
let signal = self.wait_status & 0x007f;
4561
if signal > 0 && signal < 0x7f { Some(signal) } else { None }

0 commit comments

Comments
 (0)