Skip to content

Commit 1f35797

Browse files
authored
Unrolled build for rust-lang#139711
Rollup merge of rust-lang#139711 - thaliaarchi:hermit-args, r=jhpratt Hermit: Unify `std::env::args` with Unix The only differences between these implementations of `std::env::args` 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. The atomic orderings were established in rust-lang#74006 (cc `@euclio)` for Unix and rust-lang#100579 (cc `@joboet)` for Hermit and, before those, they used mutexes and non-atomic statics. I think the difference in orderings is simply from them being changed at different times. The commented explanation for using acquire/release for Hermit is “to broadcast writes by the OS”. I'm not experienced enough with atomics to accurately judge, but I think acquire/release is stronger than needed. Either way, they should match. Truncating at the first null pointer seems desirable, though I don't know whether it is necessary in practice on Hermit. cc `@mkroening` `@stlankes` for Hermit
2 parents 8f2819b + c1f0498 commit 1f35797

File tree

3 files changed

+9
-40
lines changed

3 files changed

+9
-40
lines changed

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

-35
This file was deleted.

Diff for: 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(any(
7+
all(target_family = "unix", not(any(target_os = "espidf", target_os = "vita"))),
8+
target_os = "hermit",
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::*;

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

1114
#[path = "common.rs"]
@@ -73,6 +76,7 @@ pub fn args() -> Args {
7376
target_os = "illumos",
7477
target_os = "emscripten",
7578
target_os = "haiku",
79+
target_os = "hermit",
7680
target_os = "l4re",
7781
target_os = "fuchsia",
7882
target_os = "redox",
@@ -100,7 +104,7 @@ mod imp {
100104

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

0 commit comments

Comments
 (0)