Skip to content

Commit

Permalink
Use Unsupported on platforms where available_concurrency is not i…
Browse files Browse the repository at this point in the history
…mplemented.
  • Loading branch information
CDirkx committed Jun 21, 2021
1 parent 05ec710 commit 888418a
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 21 deletions.
6 changes: 2 additions & 4 deletions library/std/src/sys/hermit/thread.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#![allow(dead_code)]

use super::unsupported;
use crate::ffi::CStr;
use crate::io;
use crate::mem;
Expand Down Expand Up @@ -97,10 +98,7 @@ impl Thread {
}

pub fn available_concurrency() -> io::Result<NonZeroUsize> {
Err(io::Error::new_const(
io::ErrorKind::NotFound,
&"The number of hardware threads is not known for the target platform",
))
unsupported()
}

pub mod guard {
Expand Down
6 changes: 2 additions & 4 deletions library/std/src/sys/sgx/thread.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#![cfg_attr(test, allow(dead_code))] // why is this necessary?
use super::unsupported;
use crate::ffi::CStr;
use crate::io;
use crate::num::NonZeroUsize;
Expand Down Expand Up @@ -137,10 +138,7 @@ impl Thread {
}

pub fn available_concurrency() -> io::Result<NonZeroUsize> {
Err(io::Error::new_const(
io::ErrorKind::NotFound,
&"The number of hardware threads is not known for the target platform",
))
unsupported()
}

pub mod guard {
Expand Down
2 changes: 1 addition & 1 deletion library/std/src/sys/unix/thread.rs
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ pub fn available_concurrency() -> io::Result<NonZeroUsize> {
Ok(unsafe { NonZeroUsize::new_unchecked(cpus as usize) })
} else {
// FIXME: implement on vxWorks, Redox, Haiku, l4re
Err(io::Error::new_const(io::ErrorKind::NotFound, &"The number of hardware threads is not known for the target platform"))
Err(io::Error::new_const(io::ErrorKind::Unsupported, &"Getting the number of hardware threads is not supported on the target platform"))
}
}
}
Expand Down
5 changes: 1 addition & 4 deletions library/std/src/sys/unsupported/thread.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,7 @@ impl Thread {
}

pub fn available_concurrency() -> io::Result<NonZeroUsize> {
Err(io::Error::new_const(
io::ErrorKind::NotFound,
&"The number of hardware threads is not known for the target platform",
))
unsupported()
}

pub mod guard {
Expand Down
5 changes: 1 addition & 4 deletions library/std/src/sys/wasi/thread.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,7 @@ impl Thread {
}

pub fn available_concurrency() -> io::Result<NonZeroUsize> {
Err(io::Error::new_const(
io::ErrorKind::NotFound,
&"The number of hardware threads is not known for the target platform",
))
unsupported()
}

pub mod guard {
Expand Down
6 changes: 2 additions & 4 deletions library/std/src/sys/wasm/atomics/thread.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use super::unsupported;
use crate::ffi::CStr;
use crate::io;
use crate::num::NonZeroUsize;
Expand Down Expand Up @@ -41,10 +42,7 @@ impl Thread {
}

pub fn available_concurrency() -> io::Result<NonZeroUsize> {
Err(io::Error::new_const(
io::ErrorKind::NotFound,
&"The number of hardware threads is not known for the target platform",
))
unsupported()
}

pub mod guard {
Expand Down

0 comments on commit 888418a

Please sign in to comment.