Skip to content

Commit 85ae7e6

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 5305773 commit 85ae7e6

File tree

3 files changed

+9
-71
lines changed

3 files changed

+9
-71
lines changed

library/std/src/sys/args/hermit.rs

-66
This file was deleted.

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

+4-4
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@
33
#![forbid(unsafe_op_in_unsafe_fn)]
44

55
cfg_if::cfg_if! {
6-
if #[cfg(all(target_family = "unix", not(any(target_os = "espidf", target_os = "vita"))))] {
6+
if #[cfg(all(
7+
any(target_family = "unix", target_os = "hermit"),
8+
not(any(target_os = "espidf", target_os = "vita")),
9+
))] {
710
mod unix;
811
pub use unix::*;
912
} else if #[cfg(target_family = "windows")] {
1013
mod windows;
1114
pub use windows::*;
12-
} else if #[cfg(target_os = "hermit")] {
13-
mod hermit;
14-
pub use hermit::*;
1515
} else if #[cfg(all(target_vendor = "fortanix", target_env = "sgx"))] {
1616
mod sgx;
1717
pub use sgx::*;

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, OsString};
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::{fmt, vec};
1114

@@ -105,6 +108,7 @@ impl DoubleEndedIterator for Args {
105108
target_os = "illumos",
106109
target_os = "emscripten",
107110
target_os = "haiku",
111+
target_os = "hermit",
108112
target_os = "l4re",
109113
target_os = "fuchsia",
110114
target_os = "redox",
@@ -132,7 +136,7 @@ mod imp {
132136

133137
unsafe fn really_init(argc: isize, argv: *const *const u8) {
134138
// These don't need to be ordered with each other or other stores,
135-
// because they only hold the unmodified system-provide argv/argc.
139+
// because they only hold the unmodified system-provided argv/argc.
136140
ARGC.store(argc, Ordering::Relaxed);
137141
ARGV.store(argv as *mut _, Ordering::Relaxed);
138142
}

0 commit comments

Comments
 (0)