@@ -267,39 +267,29 @@ pub const unsafe fn assert_unchecked(cond: bool) {
267267#[inline(always)]
268268#[stable(feature = "renamed_spin_loop", since = "1.49.0")]
269269pub fn spin_loop() {
270- #[cfg(target_arch = "x86")]
271- {
272- // SAFETY: the `cfg` attr ensures that we only execute this on x86 targets.
273- unsafe { crate::arch::x86::_mm_pause() };
274- }
275-
276- #[cfg(target_arch = "x86_64")]
277- {
278- // SAFETY: the `cfg` attr ensures that we only execute this on x86_64 targets.
279- unsafe { crate::arch::x86_64::_mm_pause() };
280- }
281-
282- #[cfg(target_arch = "riscv32")]
283- {
284- crate::arch::riscv32::pause();
285- }
286-
287- #[cfg(target_arch = "riscv64")]
288- {
289- crate::arch::riscv64::pause();
290- }
291-
292- #[cfg(any(target_arch = "aarch64", target_arch = "arm64ec"))]
293- {
294- // SAFETY: the `cfg` attr ensures that we only execute this on aarch64 targets.
295- unsafe { crate::arch::aarch64::__isb(crate::arch::aarch64::SY) };
296- }
297-
298- #[cfg(all(target_arch = "arm", target_feature = "v6"))]
299- {
300- // SAFETY: the `cfg` attr ensures that we only execute this on arm targets
301- // with support for the v6 feature.
302- unsafe { crate::arch::arm::__yield() };
270+ crate::cfg_select! {
271+ target_arch = "x86" => {
272+ // SAFETY: the `cfg` attr ensures that we only execute this on x86 targets.
273+ unsafe { crate::arch::x86::_mm_pause() }
274+ }
275+ target_arch = "x86_64" => {
276+ // SAFETY: the `cfg` attr ensures that we only execute this on x86_64 targets.
277+ unsafe { crate::arch::x86_64::_mm_pause() }
278+ }
279+ target_arch = "riscv32" => crate::arch::riscv32::pause(),
280+ target_arch = "riscv64" => crate::arch::riscv64::pause(),
281+ any(target_arch = "aarch64", target_arch = "arm64ec") => {
282+ // SAFETY: the `cfg` attr ensures that we only execute this on aarch64 targets.
283+ unsafe { crate::arch::aarch64::__isb(crate::arch::aarch64::SY) }
284+ }
285+ all(target_arch = "arm", target_feature = "v6") => {
286+ // SAFETY: the `cfg` attr ensures that we only execute this on arm targets
287+ // with support for the v6 feature.
288+ unsafe { crate::arch::arm::__yield() }
289+ }
290+ target_arch = "loongarch32" => crate::arch::loongarch32::ibar::<0>(),
291+ target_arch = "loongarch64" => crate::arch::loongarch64::ibar::<0>(),
292+ _ => { /* do nothing */ }
303293 }
304294}
305295
0 commit comments