From 2bf894fb33adeaff7e4b3f903d98cf1c41769908 Mon Sep 17 00:00:00 2001 From: Taiki Endo Date: Sun, 8 Dec 2024 23:38:28 +0900 Subject: [PATCH] utils: Move atomic module behind atomic feature --- Cargo.toml | 2 +- crossbeam-channel/Cargo.toml | 2 +- crossbeam-epoch/Cargo.toml | 2 +- crossbeam-epoch/src/lib.rs | 6 +----- crossbeam-utils/Cargo.toml | 6 ++++++ crossbeam-utils/src/lib.rs | 21 ++++----------------- 6 files changed, 14 insertions(+), 25 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 241d9ad3c..cba6991ba 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -38,7 +38,7 @@ crossbeam-channel = { version = "0.5.10", path = "crossbeam-channel", default-fe crossbeam-deque = { version = "0.8.4", path = "crossbeam-deque", default-features = false, optional = true } crossbeam-epoch = { version = "0.9.17", path = "crossbeam-epoch", default-features = false, optional = true } crossbeam-queue = { version = "0.3.10", path = "crossbeam-queue", default-features = false, optional = true } -crossbeam-utils = { version = "0.8.18", path = "crossbeam-utils", default-features = false } +crossbeam-utils = { version = "0.8.18", path = "crossbeam-utils", default-features = false, features = ["atomic"] } [dev-dependencies] rand = "0.8" diff --git a/crossbeam-channel/Cargo.toml b/crossbeam-channel/Cargo.toml index 8d4adf8aa..22f0c543b 100644 --- a/crossbeam-channel/Cargo.toml +++ b/crossbeam-channel/Cargo.toml @@ -24,7 +24,7 @@ default = ["std"] std = ["crossbeam-utils/std"] [dependencies] -crossbeam-utils = { version = "0.8.18", path = "../crossbeam-utils", default-features = false } +crossbeam-utils = { version = "0.8.18", path = "../crossbeam-utils", default-features = false, features = ["atomic"] } [dev-dependencies] num_cpus = "1.13.0" diff --git a/crossbeam-epoch/Cargo.toml b/crossbeam-epoch/Cargo.toml index 841b7e04f..918215fa7 100644 --- a/crossbeam-epoch/Cargo.toml +++ b/crossbeam-epoch/Cargo.toml @@ -34,7 +34,7 @@ alloc = [] loom = ["loom-crate", "crossbeam-utils/loom"] [dependencies] -crossbeam-utils = { version = "0.8.18", path = "../crossbeam-utils", default-features = false } +crossbeam-utils = { version = "0.8.18", path = "../crossbeam-utils", default-features = false, features = ["atomic"] } # Enable the use of loom for concurrency testing. # diff --git a/crossbeam-epoch/src/lib.rs b/crossbeam-epoch/src/lib.rs index 2da6d30a1..9bca1d9e8 100644 --- a/crossbeam-epoch/src/lib.rs +++ b/crossbeam-epoch/src/lib.rs @@ -116,11 +116,7 @@ mod primitive { } } pub(crate) mod sync { - pub(crate) mod atomic { - pub(crate) use core::sync::atomic::{ - compiler_fence, fence, AtomicPtr, AtomicUsize, Ordering, - }; - } + pub(crate) use core::sync::atomic; #[cfg(feature = "alloc")] pub(crate) use alloc::sync::Arc; } diff --git a/crossbeam-utils/Cargo.toml b/crossbeam-utils/Cargo.toml index 9b7e3b43c..ead50eeae 100644 --- a/crossbeam-utils/Cargo.toml +++ b/crossbeam-utils/Cargo.toml @@ -14,6 +14,9 @@ description = "Utilities for concurrent programming" keywords = ["scoped", "thread", "atomic", "cache"] categories = ["algorithms", "concurrency", "data-structures", "no-std"] +[package.metadata.docs.rs] +all-features = true + [features] default = ["std"] @@ -21,6 +24,9 @@ default = ["std"] # This is enabled by default. std = [] +# Enable `atomic` module. +atomic = [] + [dependencies] # Enable the use of loom for concurrency testing. diff --git a/crossbeam-utils/src/lib.rs b/crossbeam-utils/src/lib.rs index 9d954888c..173678e19 100644 --- a/crossbeam-utils/src/lib.rs +++ b/crossbeam-utils/src/lib.rs @@ -33,6 +33,7 @@ ) ))] #![warn(missing_docs, unsafe_op_in_unsafe_fn)] +#![cfg_attr(docsrs, feature(doc_cfg))] #[cfg(feature = "std")] extern crate std; @@ -67,28 +68,14 @@ mod primitive { pub(crate) use core::hint::spin_loop; } pub(crate) mod sync { - pub(crate) mod atomic { - pub(crate) use core::sync::atomic::{compiler_fence, Ordering}; - #[cfg(not(crossbeam_no_atomic))] - pub(crate) use core::sync::atomic::{ - AtomicBool, AtomicI16, AtomicI8, AtomicIsize, AtomicU16, AtomicU8, AtomicUsize, - }; - #[cfg(not(crossbeam_no_atomic))] - #[cfg(any(target_has_atomic = "32", not(target_pointer_width = "16")))] - pub(crate) use core::sync::atomic::{AtomicI32, AtomicU32}; - #[cfg(not(crossbeam_no_atomic))] - #[cfg(any( - target_has_atomic = "64", - not(any(target_pointer_width = "16", target_pointer_width = "32")), - ))] - pub(crate) use core::sync::atomic::{AtomicI64, AtomicU64}; - } - + pub(crate) use core::sync::atomic; #[cfg(feature = "std")] pub(crate) use std::sync::{Arc, Condvar, Mutex}; } } +#[cfg(feature = "atomic")] +#[cfg_attr(docsrs, doc(cfg(feature = "atomic")))] pub mod atomic; mod cache_padded;