Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 23 additions & 33 deletions library/core/src/hint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -267,39 +267,29 @@ pub const unsafe fn assert_unchecked(cond: bool) {
#[inline(always)]
#[stable(feature = "renamed_spin_loop", since = "1.49.0")]
pub fn spin_loop() {
#[cfg(target_arch = "x86")]
{
// SAFETY: the `cfg` attr ensures that we only execute this on x86 targets.
unsafe { crate::arch::x86::_mm_pause() };
}

#[cfg(target_arch = "x86_64")]
{
// SAFETY: the `cfg` attr ensures that we only execute this on x86_64 targets.
unsafe { crate::arch::x86_64::_mm_pause() };
}

#[cfg(target_arch = "riscv32")]
{
crate::arch::riscv32::pause();
}

#[cfg(target_arch = "riscv64")]
{
crate::arch::riscv64::pause();
}

#[cfg(any(target_arch = "aarch64", target_arch = "arm64ec"))]
{
// SAFETY: the `cfg` attr ensures that we only execute this on aarch64 targets.
unsafe { crate::arch::aarch64::__isb(crate::arch::aarch64::SY) };
}

#[cfg(all(target_arch = "arm", target_feature = "v6"))]
{
// SAFETY: the `cfg` attr ensures that we only execute this on arm targets
// with support for the v6 feature.
unsafe { crate::arch::arm::__yield() };
crate::cfg_select! {
target_arch = "x86" => {
// SAFETY: the `cfg` attr ensures that we only execute this on x86 targets.
unsafe { crate::arch::x86::_mm_pause() }
}
target_arch = "x86_64" => {
// SAFETY: the `cfg` attr ensures that we only execute this on x86_64 targets.
unsafe { crate::arch::x86_64::_mm_pause() }
}
target_arch = "riscv32" => crate::arch::riscv32::pause(),
target_arch = "riscv64" => crate::arch::riscv64::pause(),
any(target_arch = "aarch64", target_arch = "arm64ec") => {
// SAFETY: the `cfg` attr ensures that we only execute this on aarch64 targets.
unsafe { crate::arch::aarch64::__isb(crate::arch::aarch64::SY) }
}
all(target_arch = "arm", target_feature = "v6") => {
// SAFETY: the `cfg` attr ensures that we only execute this on arm targets
// with support for the v6 feature.
unsafe { crate::arch::arm::__yield() }
}
target_arch = "loongarch32" => crate::arch::loongarch32::ibar::<0>(),
target_arch = "loongarch64" => crate::arch::loongarch64::ibar::<0>(),
_ => { /* do nothing */ }
}
}

Expand Down
Loading