use std::sync::atomic;
#[inline(always)]
pub fn full_fence() {
asm_fence();
atomic::fence(atomic::Ordering::SeqCst);
}
#[inline(always)]
pub fn compiler_fence() {
asm_fence();
atomic::compiler_fence(atomic::Ordering::SeqCst);
}
#[inline(always)]
fn asm_fence() {
if cfg!(miri) {
return;
}
#[cfg(any(
target_arch = "x86",
target_arch = "x86_64",
target_arch = "arm",
target_arch = "aarch64",
target_arch = "riscv32",
target_arch = "riscv64",
target_arch = "loongarch64",
))]
unsafe {
std::arch::asm!("", options(nostack, preserves_flags));
}
}