Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions library/std/src/sys/thread/unix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ pub fn available_parallelism() -> io::Result<NonZero<usize>> {
target_os = "aix",
target_vendor = "apple",
target_os = "cygwin",
all(target_os = "wasi", target_feature = "atomics"),
) => {
#[allow(unused_assignments)]
#[allow(unused_mut)]
Expand Down Expand Up @@ -314,6 +315,10 @@ pub fn available_parallelism() -> io::Result<NonZero<usize>> {
Ok(NonZero::new_unchecked(set.count_ones() as usize))
}
}
all(target_os = "wasi", not(target_feature = "atomics")) => {
// Single-threaded WASM always has exactly one thread of execution.
Ok(NonZero::new(1).unwrap())
}
Comment on lines +318 to +321
_ => {
// FIXME: implement on Redox, l4re
Err(io::const_error!(io::ErrorKind::Unsupported, "getting the number of hardware threads is not supported on the target platform"))
Expand Down
1 change: 0 additions & 1 deletion library/std/tests/thread.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ fn thread_local_hygeiene() {
target_env = "sgx",
target_os = "solid_asp3",
target_os = "teeos",
target_os = "wasi"
),
should_panic
)]
Expand Down
Loading