Skip to content

Commit 8f0b186

Browse files
authored
Rollup merge of #84655 - CDirkx:wasm, r=m-ou-se
Cleanup of `wasm` Some more cleanup of `sys`, this time `wasm` - Reuse `unsupported::args` (functionally equivalent implementation, just an empty iterator). - Split out `atomics` implementation of `wasm::thread`, the non-`atomics` implementation is reused from `unsupported`. - Move all of the `atomics` code to a separate directory `wasm/atomics`. ````@rustbot```` label: +T-libs-impl r? ````@m-ou-se````
2 parents 0c8c21d + cf79c06 commit 8f0b186

File tree

8 files changed

+14
-65
lines changed

8 files changed

+14
-65
lines changed

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

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use crate::ffi::OsString;
2+
use crate::fmt;
23

34
pub struct Args {}
45

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

-42
This file was deleted.

library/std/src/sys/wasm/thread.rs renamed to library/std/src/sys/wasm/atomics/thread.rs

+4-18
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,10 @@ impl Thread {
1313
unsupported()
1414
}
1515

16-
pub fn yield_now() {
17-
// do nothing
18-
}
16+
pub fn yield_now() {}
1917

20-
pub fn set_name(_name: &CStr) {
21-
// nope
22-
}
18+
pub fn set_name(_name: &CStr) {}
2319

24-
#[cfg(not(target_feature = "atomics"))]
25-
pub fn sleep(_dur: Duration) {
26-
panic!("can't sleep");
27-
}
28-
29-
#[cfg(target_feature = "atomics")]
3020
pub fn sleep(dur: Duration) {
3121
use crate::arch::wasm32;
3222
use crate::cmp;
@@ -46,9 +36,7 @@ impl Thread {
4636
}
4737
}
4838

49-
pub fn join(self) {
50-
self.0
51-
}
39+
pub fn join(self) {}
5240
}
5341

5442
pub mod guard {
@@ -61,11 +49,9 @@ pub mod guard {
6149
}
6250
}
6351

64-
// This is only used by atomics primitives when the `atomics` feature is
65-
// enabled. In that mode we currently just use our own thread-local to store our
52+
// We currently just use our own thread-local to store our
6653
// current thread's ID, and then we lazily initialize it to something allocated
6754
// from a global counter.
68-
#[cfg(target_feature = "atomics")]
6955
pub fn my_id() -> u32 {
7056
use crate::sync::atomic::{AtomicU32, Ordering::SeqCst};
7157

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

+9-5
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#![deny(unsafe_op_in_unsafe_fn)]
1818

1919
pub mod alloc;
20+
#[path = "../unsupported/args.rs"]
2021
pub mod args;
2122
#[path = "../unix/cmath.rs"]
2223
pub mod cmath;
@@ -37,7 +38,6 @@ pub mod pipe;
3738
pub mod process;
3839
#[path = "../unsupported/stdio.rs"]
3940
pub mod stdio;
40-
pub mod thread;
4141
#[path = "../unsupported/thread_local_dtor.rs"]
4242
pub mod thread_local_dtor;
4343
#[path = "../unsupported/thread_local_key.rs"]
@@ -49,21 +49,25 @@ pub use crate::sys_common::os_str_bytes as os_str;
4949

5050
cfg_if::cfg_if! {
5151
if #[cfg(target_feature = "atomics")] {
52-
#[path = "condvar_atomics.rs"]
52+
#[path = "atomics/condvar.rs"]
5353
pub mod condvar;
54-
#[path = "mutex_atomics.rs"]
54+
#[path = "atomics/mutex.rs"]
5555
pub mod mutex;
56-
#[path = "rwlock_atomics.rs"]
56+
#[path = "atomics/rwlock.rs"]
5757
pub mod rwlock;
58-
#[path = "futex_atomics.rs"]
58+
#[path = "atomics/futex.rs"]
5959
pub mod futex;
60+
#[path = "atomics/thread.rs"]
61+
pub mod thread;
6062
} else {
6163
#[path = "../unsupported/condvar.rs"]
6264
pub mod condvar;
6365
#[path = "../unsupported/mutex.rs"]
6466
pub mod mutex;
6567
#[path = "../unsupported/rwlock.rs"]
6668
pub mod rwlock;
69+
#[path = "../unsupported/thread.rs"]
70+
pub mod thread;
6771
}
6872
}
6973

0 commit comments

Comments
 (0)