diff options
| author | Christiaan Dirkx <christiaan@dirkx.email> | 2021-06-21 11:31:07 +0200 |
|---|---|---|
| committer | Christiaan Dirkx <christiaan@dirkx.email> | 2021-06-21 11:31:07 +0200 |
| commit | 888418a079f0daf6447d36ae533366a26eecdbc9 (patch) | |
| tree | 8108b718ca5b078578d49bef810de44793bbfbd6 | |
| parent | 05ec710c8088513f226d129f157b854d65e877c3 (diff) | |
| download | rust-888418a079f0daf6447d36ae533366a26eecdbc9.tar.gz rust-888418a079f0daf6447d36ae533366a26eecdbc9.zip | |
Use `Unsupported` on platforms where `available_concurrency` is not implemented.
| -rw-r--r-- | library/std/src/sys/hermit/thread.rs | 6 | ||||
| -rw-r--r-- | library/std/src/sys/sgx/thread.rs | 6 | ||||
| -rw-r--r-- | library/std/src/sys/unix/thread.rs | 2 | ||||
| -rw-r--r-- | library/std/src/sys/unsupported/thread.rs | 5 | ||||
| -rw-r--r-- | library/std/src/sys/wasi/thread.rs | 5 | ||||
| -rw-r--r-- | library/std/src/sys/wasm/atomics/thread.rs | 6 |
6 files changed, 9 insertions, 21 deletions
diff --git a/library/std/src/sys/hermit/thread.rs b/library/std/src/sys/hermit/thread.rs index 3d00e626e1a..6da79d19f59 100644 --- a/library/std/src/sys/hermit/thread.rs +++ b/library/std/src/sys/hermit/thread.rs @@ -1,5 +1,6 @@ #![allow(dead_code)] +use super::unsupported; use crate::ffi::CStr; use crate::io; use crate::mem; @@ -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 { diff --git a/library/std/src/sys/sgx/thread.rs b/library/std/src/sys/sgx/thread.rs index b82ae86521a..cbb8ba96401 100644 --- a/library/std/src/sys/sgx/thread.rs +++ b/library/std/src/sys/sgx/thread.rs @@ -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; @@ -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 { diff --git a/library/std/src/sys/unix/thread.rs b/library/std/src/sys/unix/thread.rs index e49971de940..df2ba0a8bc8 100644 --- a/library/std/src/sys/unix/thread.rs +++ b/library/std/src/sys/unix/thread.rs @@ -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")) } } } diff --git a/library/std/src/sys/unsupported/thread.rs b/library/std/src/sys/unsupported/thread.rs index 47005ead196..dc75d4ee672 100644 --- a/library/std/src/sys/unsupported/thread.rs +++ b/library/std/src/sys/unsupported/thread.rs @@ -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 { diff --git a/library/std/src/sys/wasi/thread.rs b/library/std/src/sys/wasi/thread.rs index 959077f7b54..9ec02bbec26 100644 --- a/library/std/src/sys/wasi/thread.rs +++ b/library/std/src/sys/wasi/thread.rs @@ -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 { diff --git a/library/std/src/sys/wasm/atomics/thread.rs b/library/std/src/sys/wasm/atomics/thread.rs index 8207a41035d..09714835104 100644 --- a/library/std/src/sys/wasm/atomics/thread.rs +++ b/library/std/src/sys/wasm/atomics/thread.rs @@ -1,3 +1,4 @@ +use super::unsupported; use crate::ffi::CStr; use crate::io; use crate::num::NonZeroUsize; @@ -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 { |
