Skip to content

Commit 8a7cab8

Browse files
committed
Auto merge of #115547 - WaffleLapkin:spin_looping, r=Mark-Simulacrum
Simplify `core::hint::spin_loop` The grouping was inconsistent and not really helpful. r? t-libs
2 parents 203c57d + 1811fe6 commit 8a7cab8

File tree

1 file changed

+17
-24
lines changed

1 file changed

+17
-24
lines changed

library/core/src/hint.rs

+17-24
Original file line numberDiff line numberDiff line change
@@ -175,34 +175,27 @@ pub fn spin_loop() {
175175
unsafe { crate::arch::x86_64::_mm_pause() };
176176
}
177177

178-
// RISC-V platform spin loop hint implementation
178+
#[cfg(target_arch = "riscv32")]
179179
{
180-
// RISC-V RV32 and RV64 share the same PAUSE instruction, but they are located in different
181-
// modules in `core::arch`.
182-
// In this case, here we call `pause` function in each core arch module.
183-
#[cfg(target_arch = "riscv32")]
184-
{
185-
crate::arch::riscv32::pause();
186-
}
187-
#[cfg(target_arch = "riscv64")]
188-
{
189-
crate::arch::riscv64::pause();
190-
}
180+
crate::arch::riscv32::pause();
191181
}
192182

193-
#[cfg(any(target_arch = "aarch64", all(target_arch = "arm", target_feature = "v6")))]
183+
#[cfg(target_arch = "riscv64")]
194184
{
195-
#[cfg(target_arch = "aarch64")]
196-
{
197-
// SAFETY: the `cfg` attr ensures that we only execute this on aarch64 targets.
198-
unsafe { crate::arch::aarch64::__isb(crate::arch::aarch64::SY) };
199-
}
200-
#[cfg(target_arch = "arm")]
201-
{
202-
// SAFETY: the `cfg` attr ensures that we only execute this on arm targets
203-
// with support for the v6 feature.
204-
unsafe { crate::arch::arm::__yield() };
205-
}
185+
crate::arch::riscv64::pause();
186+
}
187+
188+
#[cfg(target_arch = "aarch64")]
189+
{
190+
// SAFETY: the `cfg` attr ensures that we only execute this on aarch64 targets.
191+
unsafe { crate::arch::aarch64::__isb(crate::arch::aarch64::SY) };
192+
}
193+
194+
#[cfg(all(target_arch = "arm", target_feature = "v6"))]
195+
{
196+
// SAFETY: the `cfg` attr ensures that we only execute this on arm targets
197+
// with support for the v6 feature.
198+
unsafe { crate::arch::arm::__yield() };
206199
}
207200
}
208201

0 commit comments

Comments
 (0)