radium/
types.rs

1//! Best-effort atomic types
2//!
3//! This module exports `RadiumType` aliases that map to the `AtomicType` on
4//! targets that have it, or `Cell<type>` on targets that do not. This alias can
5//! be used as a consistent name for crates that need portable names for
6//! non-portable types.
7
8/// Best-effort atomic `bool` type.
9pub type RadiumBool = if_atomic! {
10    if atomic(bool) { core::sync::atomic::AtomicBool }
11    else { core::cell::Cell<bool> }
12};
13
14/// Best-effort atomic `i8` type.
15pub type RadiumI8 = if_atomic! {
16    if atomic(8) { core::sync::atomic::AtomicI8 }
17    else { core::cell::Cell<i8> }
18};
19
20/// Best-effort atomic `u8` type.
21pub type RadiumU8 = if_atomic! {
22    if atomic(8) { core::sync::atomic::AtomicU8 }
23    else { core::cell::Cell<u8> }
24};
25
26/// Best-effort atomic `i16` type.
27pub type RadiumI16 = if_atomic! {
28    if atomic(16) { core::sync::atomic::AtomicI16 }
29    else { core::cell::Cell<i16> }
30};
31
32/// Best-effort atomic `u16` type.
33pub type RadiumU16 = if_atomic! {
34    if atomic(16) { core::sync::atomic::AtomicU16 }
35    else { core::cell::Cell<u16> }
36};
37
38/// Best-effort atomic `i32` type.
39pub type RadiumI32 = if_atomic! {
40    if atomic(32) { core::sync::atomic::AtomicI32 }
41    else { core::cell::Cell<i32> }
42};
43
44/// Best-effort atomic `u32` type.
45pub type RadiumU32 = if_atomic! {
46    if atomic(32) { core::sync::atomic::AtomicU32 }
47    else { core::cell::Cell<u32> }
48};
49
50/// Best-effort atomic `i64` type.
51pub type RadiumI64 = if_atomic! {
52    if atomic(64) { core::sync::atomic::AtomicI64 }
53    else { core::cell::Cell<i64> }
54};
55
56/// Best-effort atomic `u64` type.
57pub type RadiumU64 = if_atomic! {
58    if atomic(64) { core::sync::atomic::AtomicU64 }
59    else { core::cell::Cell<u64> }
60};
61
62/// Best-effort atomic `isize` type.
63pub type RadiumIsize = if_atomic! {
64    if atomic(size) { core::sync::atomic::AtomicIsize }
65    else { core::cell::Cell<isize> }
66};
67
68/// Best-effort atomic `usize` type.
69pub type RadiumUsize = if_atomic! {
70    if atomic(size) { core::sync::atomic::AtomicUsize }
71    else { core::cell::Cell<usize> }
72};
73
74/// Best-effort atomic pointer type.
75pub type RadiumPtr<T> = if_atomic! {
76    if atomic(ptr) { core::sync::atomic::AtomicPtr<T> }
77    else { core::cell::Cell<*mut T> }
78};