Skip to content

Commit f69aa06

Browse files
committed
Hermit: Unify std::env::args with Unix
The only differences between these implementations are that Unix uses relaxed ordering, but Hermit uses acquire/release, and Unix truncates `argv` at the first null pointer, but Hermit doesn't. Since Hermit aims for Unix compatibility, unify it with Unix.
1 parent c980f0e commit f69aa06

File tree

3 files changed

+9
-38
lines changed

3 files changed

+9
-38
lines changed

Diff for: library/std/src/sys/args/hermit.rs

-32
This file was deleted.

Diff for: library/std/src/sys/args/mod.rs

+4-5
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,17 @@
66
mod common;
77

88
cfg_if::cfg_if! {
9-
if #[cfg(all(target_family = "unix", not(any(target_os = "espidf", target_os = "vita"))))] {
9+
if #[cfg(any(
10+
all(target_family = "unix", not(any(target_os = "espidf", target_os = "vita"))),
11+
target_os = "hermit",
12+
))] {
1013
mod unix;
1114
pub use common::Args;
1215
pub use unix::*;
1316
} else if #[cfg(target_family = "windows")] {
1417
mod windows;
1518
pub use common::Args;
1619
pub use windows::*;
17-
} else if #[cfg(target_os = "hermit")] {
18-
mod hermit;
19-
pub use common::Args;
20-
pub use hermit::*;
2120
} else if #[cfg(all(target_vendor = "fortanix", target_env = "sgx"))] {
2221
mod sgx;
2322
pub use sgx::*;

Diff for: library/std/src/sys/args/unix.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
#![allow(dead_code)] // runtime init functions not used during testing
77

88
use crate::ffi::CStr;
9+
#[cfg(target_os = "hermit")]
10+
use crate::os::hermit::ffi::OsStringExt;
11+
#[cfg(not(target_os = "hermit"))]
912
use crate::os::unix::ffi::OsStringExt;
1013
use crate::sys::args::Args;
1114

@@ -70,6 +73,7 @@ pub fn args() -> Args {
7073
target_os = "illumos",
7174
target_os = "emscripten",
7275
target_os = "haiku",
76+
target_os = "hermit",
7377
target_os = "l4re",
7478
target_os = "fuchsia",
7579
target_os = "redox",
@@ -97,7 +101,7 @@ mod imp {
97101

98102
unsafe fn really_init(argc: isize, argv: *const *const u8) {
99103
// These don't need to be ordered with each other or other stores,
100-
// because they only hold the unmodified system-provide argv/argc.
104+
// because they only hold the unmodified system-provided argv/argc.
101105
ARGC.store(argc, Ordering::Relaxed);
102106
ARGV.store(argv as *mut _, Ordering::Relaxed);
103107
}

0 commit comments

Comments
 (0)