1[package]
2name = "portable-atomic"
3version = "1.11.0" #publish:version
4edition = "2018"
5rust-version = "1.34" # For Atomic{I,U}{8,16,32,64}
6license = "Apache-2.0 OR MIT"
7repository = "https://github.com/taiki-e/portable-atomic"
8keywords = ["atomic"]
9categories = ["concurrency", "embedded", "hardware-support", "no-std", "no-std::no-alloc"]
10exclude = ["/.*", "/tools", "/target-specs", "/DEVELOPMENT.md"]
11description = """
12Portable atomic types including support for 128-bit atomics, atomic float, etc.
13"""
14
15[package.metadata.docs.rs]
16# NB: sync with:
17# - env.TEST_FEATURES in .github/workflows/ci.yml.
18# - test_features list in tools/build.sh and tools/test.sh.
19features = ["float", "std", "serde", "critical-section"]
20rustdoc-args = ["--cfg", "portable_atomic_unstable_f16", "--cfg", "portable_atomic_unstable_f128"]
21targets = ["x86_64-unknown-linux-gnu"]
22
23[package.metadata.cargo_check_external_types]
24# The following are external types that are allowed to be exposed in our public API.
25allowed_external_types = [
26 "serde::*",
27]
28
29[lib]
30doc-scrape-examples = false
31
32[features]
33default = ["fallback"]
34
35# (enabled by default) Enable fallback implementations.
36#
37# Disabling this allows only atomic types for which the platform natively supports atomic operations.
38fallback = []
39
40# Provide `AtomicF{32,64}`.
41#
42# See documentation for more: https://github.com/taiki-e/portable-atomic#optional-features-float
43float = []
44
45# Use `std`.
46std = []
47
48# Emit compile error if atomic CAS is not available.
49#
50# See documentation for more: https://github.com/taiki-e/portable-atomic#optional-features-require-cas
51require-cas = []
52
53# Assume the target is single core, to enable implementations based on disabling interrupts.
54# IMPORTANT: This feature is unsafe. See the documentation for the safety contract:
55# https://github.com/taiki-e/portable-atomic#optional-features-unsafe-assume-single-core
56unsafe-assume-single-core = []
57
58# The following are sub-features of the unsafe-assume-single-core feature and if enabled without
59# the unsafe-assume-single-core feature will result in a compile error.
60# There is no explicit "unsafe-" prefix because the user has already opted in to "unsafe" by
61# enabling the unsafe-assume-single-core feature, but misuse of these features is also usually
62# considered unsound.
63# See the interrupt module's readme for more: https://github.com/taiki-e/portable-atomic/blob/HEAD/src/imp/interrupt/README.md
64
65# For RISC-V targets, generate code for S mode to disable interrupts.
66s-mode = []
67# For RISC-V targets, use AMO instructions even if A-extension is disabled.
68# This feature requires Rust 1.72+.
69force-amo = []
70# For Arm targets, also disable FIQs when disabling interrupts.
71disable-fiq = []
72
73# Note: serde and critical-section are public dependencies.
74[dependencies]
75# Implements serde::{Serialize,Deserialize} for atomic types.
76#
77# See documentation for more: https://github.com/taiki-e/portable-atomic#optional-features-serde
78serde = { version = "1.0.60", optional = true, default-features = false }
79
80# Use `critical-section`.
81#
82# See documentation for more: https://github.com/taiki-e/portable-atomic#optional-features-critical-section
83critical-section = { version = "1", optional = true }
84
85[dev-dependencies]
86build-context = "0.1"
87crossbeam-utils = "=0.8.16" # The latest crossbeam-utils requires Rust 1.60
88fastrand = "2"
89paste = "1"
90quickcheck = { version = "1", default-features = false, git = "https://github.com/taiki-e/quickcheck.git", rev = "83b1d59" } # https://github.com/BurntSushi/quickcheck/pull/304 + https://github.com/BurntSushi/quickcheck/pull/282 + https://github.com/BurntSushi/quickcheck/pull/296 + f16/f128 support + lower MSRV
91serde_test = { git = "https://github.com/taiki-e/serde_test.git", rev = "f35c385" } # support {i,u}128
92sptr = "0.3"
93static_assertions = "1"
94test-helper = { features = ["sys", "cpuinfo", "critical-section-std"], git = "https://github.com/taiki-e/test-helper.git", rev = "d2272e8" }
95
96[target.'cfg(unix)'.dev-dependencies]
97libc = "=0.2.163" # newer libc requires Rust 1.63
98
99[target.'cfg(windows)'.dev-dependencies]
100windows-sys = { version = "0.59", features = [
101 "Win32_Foundation",
102 "Win32_System_Threading",
103] }
104
105[lints]
106workspace = true
107
108[workspace]
109members = [
110 "bench",
111 "portable-atomic-util",
112 "tests/api-test",
113]
114
115# This table is shared by projects under github.com/taiki-e.
116# Expect for unexpected_cfgs.check-cfg, it is not intended for manual editing.
117[workspace.lints.rust]
118deprecated_safe = "warn"
119improper_ctypes = "warn"
120improper_ctypes_definitions = "warn"
121non_ascii_idents = "warn"
122rust_2018_idioms = "warn"
123single_use_lifetimes = "warn"
124unexpected_cfgs = { level = "warn", check-cfg = [
125 'cfg(target_arch,values("xtensa"))', # 1.81+ https://github.com/rust-lang/rust/pull/125141
126 'cfg(target_arch,values("amdgpu"))', # 1.86+ https://github.com/rust-lang/rust/pull/134740
127 'cfg(target_os,values("psx"))', # 1.84+ https://github.com/rust-lang/rust/pull/131168
128 'cfg(target_env,values("psx"))', # pre-1.84 https://github.com/rust-lang/rust/pull/131168
129 'cfg(target_feature,values("lse2","lse128","rcpc3"))', # 1.82+ https://github.com/rust-lang/rust/pull/128192
130 'cfg(target_feature,values("quadword-atomics"))', # 1.83+ https://github.com/rust-lang/rust/pull/130873
131 'cfg(target_feature,values("zaamo","zabha"))', # 1.83+ https://github.com/rust-lang/rust/pull/130877
132 'cfg(target_pointer_width,values("128"))',
133 # Known custom cfgs, excluding those that may be set by build script.
134 # Not public API.
135 'cfg(portable_atomic_test_outline_atomics_detect_false,qemu,valgrind)',
136 # Public APIs, considered unstable unless documented as stable in readme.
137 'cfg(portable_atomic_no_outline_atomics,portable_atomic_outline_atomics,portable_atomic_unstable_f16,portable_atomic_unstable_f128)',
138 # Public unstable API(s) - portable-atomic-util
139 'cfg(portable_atomic_unstable_coerce_unsized)',
140] }
141unnameable_types = "warn"
142unreachable_pub = "warn"
143# unsafe_op_in_unsafe_fn = "warn" # Set at crate-level instead since https://github.com/rust-lang/rust/pull/100081 merged in Rust 1.65 is not available on MSRV
144[workspace.lints.clippy]
145all = "warn" # Downgrade deny-by-default lints
146pedantic = "warn"
147as_ptr_cast_mut = "warn"
148as_underscore = "warn"
149default_union_representation = "warn"
150inline_asm_x86_att_syntax = "warn"
151trailing_empty_array = "warn"
152transmute_undefined_repr = "warn"
153undocumented_unsafe_blocks = "warn"
154unused_trait_names = "warn"
155# Suppress buggy or noisy clippy lints
156bool_assert_comparison = { level = "allow", priority = 1 }
157borrow_as_ptr = { level = "allow", priority = 1 } # https://github.com/rust-lang/rust-clippy/issues/8286
158cast_lossless = { level = "allow", priority = 1 } # https://godbolt.org/z/Pv6vbGG6E
159declare_interior_mutable_const = { level = "allow", priority = 1 } # https://github.com/rust-lang/rust-clippy/issues/7665
160doc_markdown = { level = "allow", priority = 1 }
161float_cmp = { level = "allow", priority = 1 } # https://github.com/rust-lang/rust-clippy/issues/7725
162incompatible_msrv = { level = "allow", priority = 1 } # buggy: doesn't consider cfg, https://github.com/rust-lang/rust-clippy/issues/12280, https://github.com/rust-lang/rust-clippy/issues/12257#issuecomment-2093667187
163lint_groups_priority = { level = "allow", priority = 1 } # https://github.com/rust-lang/rust-clippy/issues/12920
164manual_assert = { level = "allow", priority = 1 }
165manual_range_contains = { level = "allow", priority = 1 } # https://github.com/rust-lang/rust-clippy/issues/6455#issuecomment-1225966395
166missing_errors_doc = { level = "allow", priority = 1 }
167module_name_repetitions = { level = "allow", priority = 1 } # buggy: https://github.com/rust-lang/rust-clippy/issues?q=is%3Aissue+is%3Aopen+module_name_repetitions
168naive_bytecount = { level = "allow", priority = 1 }
169nonminimal_bool = { level = "allow", priority = 1 } # buggy: https://github.com/rust-lang/rust-clippy/issues?q=is%3Aissue+is%3Aopen+nonminimal_bool
170range_plus_one = { level = "allow", priority = 1 } # buggy: https://github.com/rust-lang/rust-clippy/issues?q=is%3Aissue+is%3Aopen+range_plus_one
171similar_names = { level = "allow", priority = 1 }
172single_match = { level = "allow", priority = 1 }
173single_match_else = { level = "allow", priority = 1 }
174struct_excessive_bools = { level = "allow", priority = 1 }
175struct_field_names = { level = "allow", priority = 1 }
176too_many_arguments = { level = "allow", priority = 1 }
177too_many_lines = { level = "allow", priority = 1 }
178type_complexity = { level = "allow", priority = 1 }
179unreadable_literal = { level = "allow", priority = 1 }
180