#[cfg(doc)]
use core::{
cell::UnsafeCell,
sync::atomic::Ordering::{AcqRel, Acquire, Relaxed, Release, SeqCst},
};
use core::{mem::MaybeUninit, sync::atomic::Ordering};
pub trait Primitive: crate::private::PrimitivePriv {}
#[cfg_attr(
not(atomic_maybe_uninit_no_diagnostic_namespace),
diagnostic::on_unimplemented(
message = "atomic load of `{Self}` is not available on this target",
label = "this associated function is not available on this target",
note = "see <https://docs.rs/atomic-maybe-uninit/latest/atomic_maybe_uninit/#platform-support> for more."
)
)]
pub trait AtomicLoad: Primitive {
unsafe fn atomic_load(src: *const MaybeUninit<Self>, order: Ordering) -> MaybeUninit<Self>;
}
#[cfg_attr(
not(atomic_maybe_uninit_no_diagnostic_namespace),
diagnostic::on_unimplemented(
message = "atomic store of `{Self}` is not available on this target",
label = "this associated function is not available on this target",
note = "see <https://docs.rs/atomic-maybe-uninit/latest/atomic_maybe_uninit/#platform-support> for more."
)
)]
pub trait AtomicStore: Primitive {
unsafe fn atomic_store(dst: *mut MaybeUninit<Self>, val: MaybeUninit<Self>, order: Ordering);
}
#[cfg_attr(
not(atomic_maybe_uninit_no_diagnostic_namespace),
diagnostic::on_unimplemented(
message = "atomic swap of `{Self}` is not available on this target",
label = "this associated function is not available on this target",
note = "see <https://docs.rs/atomic-maybe-uninit/latest/atomic_maybe_uninit/#platform-support> for more."
)
)]
pub trait AtomicSwap: AtomicLoad + AtomicStore {
unsafe fn atomic_swap(
dst: *mut MaybeUninit<Self>,
val: MaybeUninit<Self>,
order: Ordering,
) -> MaybeUninit<Self>;
}
#[cfg_attr(
not(atomic_maybe_uninit_no_diagnostic_namespace),
diagnostic::on_unimplemented(
message = "atomic compare and exchange of `{Self}` is not available on this target",
label = "this associated function is not available on this target",
note = "see <https://docs.rs/atomic-maybe-uninit/latest/atomic_maybe_uninit/#platform-support> for more."
)
)]
pub trait AtomicCompareExchange: AtomicLoad + AtomicStore {
unsafe fn atomic_compare_exchange(
dst: *mut MaybeUninit<Self>,
current: MaybeUninit<Self>,
new: MaybeUninit<Self>,
success: Ordering,
failure: Ordering,
) -> (MaybeUninit<Self>, bool);
#[inline]
unsafe fn atomic_compare_exchange_weak(
dst: *mut MaybeUninit<Self>,
current: MaybeUninit<Self>,
new: MaybeUninit<Self>,
success: Ordering,
failure: Ordering,
) -> (MaybeUninit<Self>, bool) {
unsafe { Self::atomic_compare_exchange(dst, current, new, success, failure) }
}
}