about summary refs log tree commit diff
path: root/library/std/src/sys/sync
diff options
context:
space:
mode:
Diffstat (limited to 'library/std/src/sys/sync')
-rw-r--r--library/std/src/sys/sync/condvar/mod.rs26
-rw-r--r--library/std/src/sys/sync/mutex/mod.rs29
-rw-r--r--library/std/src/sys/sync/once/mod.rs14
-rw-r--r--library/std/src/sys/sync/rwlock/mod.rs20
-rw-r--r--library/std/src/sys/sync/thread_parking/mod.rs26
5 files changed, 70 insertions, 45 deletions
diff --git a/library/std/src/sys/sync/condvar/mod.rs b/library/std/src/sys/sync/condvar/mod.rs
index d0c998a5597..cb67d273759 100644
--- a/library/std/src/sys/sync/condvar/mod.rs
+++ b/library/std/src/sys/sync/condvar/mod.rs
@@ -1,5 +1,5 @@
-cfg_if::cfg_if! {
-    if #[cfg(any(
+cfg_select! {
+    any(
         all(target_os = "windows", not(target_vendor="win7")),
         target_os = "linux",
         target_os = "android",
@@ -9,28 +9,34 @@ cfg_if::cfg_if! {
         target_os = "fuchsia",
         all(target_family = "wasm", target_feature = "atomics"),
         target_os = "hermit",
-    ))] {
+    ) => {
         mod futex;
         pub use futex::Condvar;
-    } else if #[cfg(any(
+    }
+    any(
         target_family = "unix",
         target_os = "teeos",
-    ))] {
+    ) => {
         mod pthread;
         pub use pthread::Condvar;
-    } else if #[cfg(all(target_os = "windows", target_vendor = "win7"))] {
+    }
+    all(target_os = "windows", target_vendor = "win7") => {
         mod windows7;
         pub use windows7::Condvar;
-    } else if #[cfg(all(target_vendor = "fortanix", target_env = "sgx"))] {
+    }
+    all(target_vendor = "fortanix", target_env = "sgx") => {
         mod sgx;
         pub use sgx::Condvar;
-    } else if #[cfg(target_os = "solid_asp3")] {
+    }
+    target_os = "solid_asp3" => {
         mod itron;
         pub use itron::Condvar;
-    } else if #[cfg(target_os = "xous")] {
+    }
+    target_os = "xous" => {
         mod xous;
         pub use xous::Condvar;
-    } else {
+    }
+    _ => {
         mod no_threads;
         pub use no_threads::Condvar;
     }
diff --git a/library/std/src/sys/sync/mutex/mod.rs b/library/std/src/sys/sync/mutex/mod.rs
index 360df3fc4b5..c885b0eabae 100644
--- a/library/std/src/sys/sync/mutex/mod.rs
+++ b/library/std/src/sys/sync/mutex/mod.rs
@@ -1,5 +1,5 @@
-cfg_if::cfg_if! {
-    if #[cfg(any(
+cfg_select! {
+    any(
         all(target_os = "windows", not(target_vendor = "win7")),
         target_os = "linux",
         target_os = "android",
@@ -8,31 +8,38 @@ cfg_if::cfg_if! {
         target_os = "dragonfly",
         all(target_family = "wasm", target_feature = "atomics"),
         target_os = "hermit",
-    ))] {
+    ) => {
         mod futex;
         pub use futex::Mutex;
-    } else if #[cfg(target_os = "fuchsia")] {
+    }
+    target_os = "fuchsia" => {
         mod fuchsia;
         pub use fuchsia::Mutex;
-    } else if #[cfg(any(
+    }
+    any(
         target_family = "unix",
         target_os = "teeos",
-    ))] {
+    ) => {
         mod pthread;
         pub use pthread::Mutex;
-    } else if #[cfg(all(target_os = "windows", target_vendor = "win7"))] {
+    }
+    all(target_os = "windows", target_vendor = "win7") => {
         mod windows7;
         pub use windows7::{Mutex, raw};
-    } else if #[cfg(all(target_vendor = "fortanix", target_env = "sgx"))] {
+    }
+    all(target_vendor = "fortanix", target_env = "sgx") => {
         mod sgx;
         pub use sgx::Mutex;
-    } else if #[cfg(target_os = "solid_asp3")] {
+    }
+    target_os = "solid_asp3" => {
         mod itron;
         pub use itron::Mutex;
-    } else if #[cfg(target_os = "xous")] {
+    }
+    target_os = "xous" => {
         mod xous;
         pub use xous::Mutex;
-    } else {
+    }
+    _ => {
         mod no_threads;
         pub use no_threads::Mutex;
     }
diff --git a/library/std/src/sys/sync/once/mod.rs b/library/std/src/sys/sync/once/mod.rs
index 0e38937b121..8adeb1f259d 100644
--- a/library/std/src/sys/sync/once/mod.rs
+++ b/library/std/src/sys/sync/once/mod.rs
@@ -7,8 +7,8 @@
 // This also gives us the opportunity to optimize the implementation a bit which
 // should help the fast path on call sites.
 
-cfg_if::cfg_if! {
-    if #[cfg(any(
+cfg_select! {
+    any(
         all(target_os = "windows", not(target_vendor="win7")),
         target_os = "linux",
         target_os = "android",
@@ -18,19 +18,21 @@ cfg_if::cfg_if! {
         target_os = "dragonfly",
         target_os = "fuchsia",
         target_os = "hermit",
-    ))] {
+    ) => {
         mod futex;
         pub use futex::{Once, OnceState};
-    } else if #[cfg(any(
+    }
+    any(
         windows,
         target_family = "unix",
         all(target_vendor = "fortanix", target_env = "sgx"),
         target_os = "solid_asp3",
         target_os = "xous",
-    ))] {
+    ) => {
         mod queue;
         pub use queue::{Once, OnceState};
-    } else {
+    }
+    _ => {
         mod no_threads;
         pub use no_threads::{Once, OnceState};
     }
diff --git a/library/std/src/sys/sync/rwlock/mod.rs b/library/std/src/sys/sync/rwlock/mod.rs
index 70ba6bf38ef..82f1dd18dee 100644
--- a/library/std/src/sys/sync/rwlock/mod.rs
+++ b/library/std/src/sys/sync/rwlock/mod.rs
@@ -1,5 +1,5 @@
-cfg_if::cfg_if! {
-    if #[cfg(any(
+cfg_select! {
+    any(
         all(target_os = "windows", not(target_vendor = "win7")),
         target_os = "linux",
         target_os = "android",
@@ -9,24 +9,28 @@ cfg_if::cfg_if! {
         target_os = "fuchsia",
         all(target_family = "wasm", target_feature = "atomics"),
         target_os = "hermit",
-    ))] {
+    ) => {
         mod futex;
         pub use futex::RwLock;
-    } else if #[cfg(any(
+    }
+    any(
         target_family = "unix",
         all(target_os = "windows", target_vendor = "win7"),
         all(target_vendor = "fortanix", target_env = "sgx"),
         target_os = "xous",
-    ))] {
+    ) => {
         mod queue;
         pub use queue::RwLock;
-    } else if #[cfg(target_os = "solid_asp3")] {
+    }
+    target_os = "solid_asp3" => {
         mod solid;
         pub use solid::RwLock;
-    } else if #[cfg(target_os = "teeos")] {
+    }
+    target_os = "teeos" => {
         mod teeos;
         pub use teeos::RwLock;
-    } else {
+    }
+    _ => {
         mod no_threads;
         pub use no_threads::RwLock;
     }
diff --git a/library/std/src/sys/sync/thread_parking/mod.rs b/library/std/src/sys/sync/thread_parking/mod.rs
index f4d8fa0a58c..b9fb27b4eef 100644
--- a/library/std/src/sys/sync/thread_parking/mod.rs
+++ b/library/std/src/sys/sync/thread_parking/mod.rs
@@ -1,5 +1,5 @@
-cfg_if::cfg_if! {
-    if #[cfg(any(
+cfg_select! {
+    any(
         all(target_os = "windows", not(target_vendor = "win7")),
         target_os = "linux",
         target_os = "android",
@@ -9,30 +9,36 @@ cfg_if::cfg_if! {
         target_os = "dragonfly",
         target_os = "fuchsia",
         target_os = "hermit",
-    ))] {
+    ) => {
         mod futex;
         pub use futex::Parker;
-    } else if #[cfg(any(
+    }
+    any(
         target_os = "netbsd",
         all(target_vendor = "fortanix", target_env = "sgx"),
         target_os = "solid_asp3",
-    ))] {
+    ) => {
         mod id;
         pub use id::Parker;
-    } else if #[cfg(target_vendor = "win7")] {
+    }
+    target_vendor = "win7" => {
         mod windows7;
         pub use windows7::Parker;
-    } else if #[cfg(all(target_vendor = "apple", not(miri)))] {
+    }
+    all(target_vendor = "apple", not(miri)) => {
         // Doesn't work in Miri, see <https://github.com/rust-lang/miri/issues/2589>.
         mod darwin;
         pub use darwin::Parker;
-    } else if #[cfg(target_os = "xous")] {
+    }
+    target_os = "xous" => {
         mod xous;
         pub use xous::Parker;
-    } else if #[cfg(target_family = "unix")] {
+    }
+    target_family = "unix" => {
         mod pthread;
         pub use pthread::Parker;
-    } else {
+    }
+    _ => {
         mod unsupported;
         pub use unsupported::Parker;
     }