Skip to content

Commit 94bdeff

Browse files
committed
Simplify process stubs.
1 parent de64fd9 commit 94bdeff

File tree

7 files changed

+11
-113
lines changed

7 files changed

+11
-113
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ pub mod ffi;
3333
pub mod fs;
3434
pub mod io;
3535
pub mod net;
36+
#[cfg(not(target_os = "freertos"))]
3637
pub mod process;
3738
pub mod raw;
3839
pub mod thread;
@@ -69,6 +70,7 @@ pub mod prelude {
6970
#[doc(no_inline)]
7071
#[stable(feature = "rust1", since = "1.0.0")]
7172
pub use super::io::{AsRawFd, FromRawFd, IntoRawFd, RawFd};
73+
#[cfg(not(target_os = "freertos"))]
7274
#[doc(no_inline)]
7375
#[stable(feature = "rust1", since = "1.0.0")]
7476
pub use super::process::{CommandExt, ExitStatusExt};

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,9 @@ pub use self::l4re::net;
6969
pub mod net_fd;
7070
pub mod os;
7171
pub mod path;
72+
#[cfg_attr(target_os = "freertos", path = "../unsupported/pipe.rs")]
7273
pub mod pipe;
74+
#[cfg_attr(target_os = "freertos", path = "../unsupported/process.rs")]
7375
pub mod process;
7476
pub mod rand;
7577
#[cfg_attr(target_os = "freertos", path = "../wasm/rwlock_atomics.rs")]
@@ -252,6 +254,7 @@ where
252254
}
253255
}
254256

257+
#[cfg(not(target_os = "freertos"))]
255258
pub fn cvt_nz(error: libc::c_int) -> crate::io::Result<()> {
256259
if error == 0 { Ok(()) } else { Err(crate::io::Error::from_raw_os_error(error)) }
257260
}

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

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,6 @@ use crate::sys::cvt_r;
99

1010
pub struct AnonPipe(FileDesc);
1111

12-
#[cfg(target_os = "freertos")]
13-
pub fn anon_pipe() -> io::Result<(AnonPipe, AnonPipe)> {
14-
crate::sys::unsupported()
15-
}
16-
17-
#[cfg(not(target_os = "freertos"))]
1812
pub fn anon_pipe() -> io::Result<(AnonPipe, AnonPipe)> {
1913
use crate::sys::cvt;
2014
let mut fds = [0; 2];

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

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,9 @@ pub use crate::ffi::OsString as EnvKey;
44
pub use crate::sys_common::process::CommandEnvs;
55

66
mod process_common;
7-
#[cfg(not(any(target_os = "freertos", target_os = "fuchsia")))]
7+
#[cfg(not(target_os = "fuchsia"))]
88
#[path = "process_unix.rs"]
99
mod process_inner;
10-
#[cfg(target_os = "freertos")]
11-
#[path = "process_freertos.rs"]
12-
mod process_inner;
1310
#[cfg(target_os = "fuchsia")]
1411
#[path = "process_fuchsia.rs"]
1512
mod process_inner;

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ use crate::sys::fs::OpenOptions;
2020
use libc::{c_char, c_int, gid_t, uid_t, EXIT_FAILURE, EXIT_SUCCESS};
2121

2222
cfg_if::cfg_if! {
23-
if #[cfg(any(target_os = "freertos", target_os = "fuchsia"))] {
23+
if #[cfg(target_os = "fuchsia")] {
2424
// fuchsia doesn't have /dev/null
2525
} else if #[cfg(target_os = "redox")] {
2626
const DEV_NULL: &str = "null:\0";
@@ -123,7 +123,7 @@ pub enum ChildStdio {
123123

124124
// On Fuchsia, null stdio is the default, so we simply don't specify
125125
// any actions at the time of spawning.
126-
#[cfg(any(target_os = "freertos", target_os = "fuchsia"))]
126+
#[cfg(target_os = "fuchsia")]
127127
Null,
128128
}
129129

@@ -363,7 +363,7 @@ impl Stdio {
363363
Ok((ChildStdio::Owned(theirs.into_fd()), Some(ours)))
364364
}
365365

366-
#[cfg(not(any(target_os = "freertos", target_os = "fuchsia")))]
366+
#[cfg(not(target_os = "fuchsia"))]
367367
Stdio::Null => {
368368
let mut opts = OpenOptions::new();
369369
opts.read(readable);
@@ -373,7 +373,7 @@ impl Stdio {
373373
Ok((ChildStdio::Owned(fd.into_fd()), None))
374374
}
375375

376-
#[cfg(any(target_os = "freertos", target_os = "fuchsia"))]
376+
#[cfg(target_os = "fuchsia")]
377377
Stdio::Null => Ok((ChildStdio::Null, None)),
378378
}
379379
}
@@ -398,7 +398,7 @@ impl ChildStdio {
398398
ChildStdio::Explicit(fd) => Some(fd),
399399
ChildStdio::Owned(ref fd) => Some(fd.raw()),
400400

401-
#[cfg(any(target_os = "freertos", target_os = "fuchsia"))]
401+
#[cfg(target_os = "fuchsia")]
402402
ChildStdio::Null => None,
403403
}
404404
}

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

Lines changed: 0 additions & 78 deletions
This file was deleted.

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

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,6 @@ use libc::{c_int, gid_t, pid_t, uid_t};
1717
////////////////////////////////////////////////////////////////////////////////
1818

1919
impl Command {
20-
#[cfg(target_os = "freertos")]
21-
pub fn spawn(
22-
&mut self,
23-
default: Stdio,
24-
needs_stdin: bool,
25-
) -> io::Result<(Process, StdioPipes)> {
26-
crate::sys::unsupported()
27-
}
28-
29-
#[cfg(not(target_os = "freertos"))]
3020
pub fn spawn(
3121
&mut self,
3222
default: Stdio,
@@ -174,16 +164,6 @@ impl Command {
174164
// allocation). Instead we just close it manually. This will never
175165
// have the drop glue anyway because this code never returns (the
176166
// child will either exec() or invoke libc::exit)
177-
#[cfg(target_os = "freertos")]
178-
unsafe fn do_exec(
179-
&mut self,
180-
stdio: ChildPipes,
181-
maybe_envp: Option<&CStringArray>
182-
) -> Result<!, io::Error> {
183-
crate::sys::unsupported()
184-
}
185-
186-
#[cfg(not(target_os = "freertos"))]
187167
unsafe fn do_exec(
188168
&mut self,
189169
stdio: ChildPipes,

0 commit comments

Comments
 (0)